CVS commit: src/share/man/man7
Module Name:src Committed By: pgoyette Date: Sat Mar 25 05:58:50 UTC 2017 Modified Files: src/share/man/man7: sysctl.7 Log Message: A couple more minor changes for readability. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/share/man/man7/sysctl.7 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man7/sysctl.7 diff -u src/share/man/man7/sysctl.7:1.112 src/share/man/man7/sysctl.7:1.113 --- src/share/man/man7/sysctl.7:1.112 Sat Mar 25 05:51:28 2017 +++ src/share/man/man7/sysctl.7 Sat Mar 25 05:58:50 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: sysctl.7,v 1.112 2017/03/25 05:51:28 pgoyette Exp $ +.\" $NetBSD: sysctl.7,v 1.113 2017/03/25 05:58:50 pgoyette Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -2206,9 +2206,9 @@ If non zero, the process' children will calls. The children are created in the SSTOP state and are never scheduled for running before being stopped. -This feature helps attaching to a process with a debugger such as +This feature enables attaching to a process with a debugger such as .Xr gdb 1 -before it has the opportunity to actually do anything. +before the process has the opportunity to actually do anything. .Pp This value is inherited by the process's children, and it also applies to emulation specific system calls that fork a new process, such as @@ -2225,7 +2225,7 @@ is created in the SSTOP state and is nev before being stopped. This feature enables attaching to a process with a debugger such as .Xr gdb 1 -before it has the opportunity to actually do anything. +before the process has the opportunity to actually do anything. .Pp This value is inherited by the process's children. .It Li proc.pid.stopexit ( Dv PROC_PID_STOPEXIT )
CVS commit: src/sys/sys
Module Name:src Committed By: pgoyette Date: Sat Mar 25 05:55:36 UTC 2017 Modified Files: src/sys/sys: sysctl.h Log Message: Update a comment. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.222 -r1.223 src/sys/sys/sysctl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/sysctl.h diff -u src/sys/sys/sysctl.h:1.222 src/sys/sys/sysctl.h:1.223 --- src/sys/sys/sysctl.h:1.222 Fri Mar 24 21:43:21 2017 +++ src/sys/sys/sysctl.h Sat Mar 25 05:55:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.h,v 1.222 2017/03/24 21:43:21 pgoyette Exp $ */ +/* $NetBSD: sysctl.h,v 1.223 2017/03/25 05:55:36 pgoyette Exp $ */ /* * Copyright (c) 1989, 1993 @@ -1018,8 +1018,9 @@ struct kinfo_vmentry { #define PROC_CURPROC (~((u_int)1 << 31)) /* - * CTL_PROC tree: either corename (string), or a limit - * (rlimit..{hard,soft}, int). + * CTL_PROC tree: either corename (string), a limit + * (rlimit..{hard,soft}, int), a process stop + * condition, or paxflags. */ #define PROC_PID_CORENAME 1 #define PROC_PID_LIMIT 2
CVS commit: src/share/man/man7
Module Name:src Committed By: pgoyette Date: Sat Mar 25 05:51:28 UTC 2017 Modified Files: src/share/man/man7: sysctl.7 Log Message: Improve some grammar, let verbs agree in number with their subjects. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/share/man/man7/sysctl.7 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man7/sysctl.7 diff -u src/share/man/man7/sysctl.7:1.111 src/share/man/man7/sysctl.7:1.112 --- src/share/man/man7/sysctl.7:1.111 Fri Mar 24 21:44:13 2017 +++ src/share/man/man7/sysctl.7 Sat Mar 25 05:51:28 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: sysctl.7,v 1.111 2017/03/24 21:44:13 pgoyette Exp $ +.\" $NetBSD: sysctl.7,v 1.112 2017/03/25 05:51:28 pgoyette Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -2204,38 +2204,38 @@ Both are of type integer. If non zero, the process' children will be stopped after .Xr fork 2 calls. -The children is created in the SSTOP state and is never scheduled +The children are created in the SSTOP state and are never scheduled for running before being stopped. -This feature helps attaching a process with a debugger such as +This feature helps attaching to a process with a debugger such as .Xr gdb 1 -before it had the opportunity to actually do anything. +before it has the opportunity to actually do anything. .Pp This value is inherited by the process's children, and it also -apply to emulation specific system calls that fork a new process, such as +applies to emulation specific system calls that fork a new process, such as .Fn sproc or .Fn clone . .It Li proc.pid.stopexec ( Dv PROC_PID_STOPEXEC ) -If non zero, the process will be stopped on next +If non zero, the process will be stopped on the next .Xr exec 3 call. The process created by .Xr exec 3 is created in the SSTOP state and is never scheduled for running before being stopped. -This feature helps attaching a process with a debugger such as +This feature enables attaching to a process with a debugger such as .Xr gdb 1 -before it had the opportunity to actually do anything. +before it has the opportunity to actually do anything. .Pp This value is inherited by the process's children. .It Li proc.pid.stopexit ( Dv PROC_PID_STOPEXIT ) -If non zero, the process will be stopped on when it has cause to exit, +If non zero, the process will be stopped when it has cause to exit, either by way of calling .Xr exit 3 , .Xr _exit 2 , or by the receipt of a specific signal. The process is stopped before any of its resources or vm space is -released allowing examination of the termination state of a process +released allowing examination of the termination state of the process before it disappears. This feature can be used to examine the final conditions of the process's vmspace via
CVS commit: src/sys/arch/hp300/dev
Module Name:src Committed By: tsutsui Date: Sat Mar 25 01:48:31 UTC 2017 Modified Files: src/sys/arch/hp300/dev: dnkbd.c Log Message: Send break signal to reset keyboard state before keyboard probe. Now Apollo Domain keyboard is probed properly even after any keys are typed before boot (i.e. on bootloader prompt). Tested on 425e and A1630-82001 keyboard (that were contributed by Miod Vallat). To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hp300/dev/dnkbd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/hp300/dev/dnkbd.c diff -u src/sys/arch/hp300/dev/dnkbd.c:1.7 src/sys/arch/hp300/dev/dnkbd.c:1.8 --- src/sys/arch/hp300/dev/dnkbd.c:1.7 Thu Apr 24 12:10:27 2014 +++ src/sys/arch/hp300/dev/dnkbd.c Sat Mar 25 01:48:31 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: dnkbd.c,v 1.7 2014/04/24 12:10:27 tsutsui Exp $ */ +/* $NetBSD: dnkbd.c,v 1.8 2017/03/25 01:48:31 tsutsui Exp $ */ /* $OpenBSD: dnkbd.c,v 1.17 2009/07/23 21:05:56 blambert Exp $ */ /* @@ -263,6 +263,7 @@ static int dnkbd_probe(struct dnkbd_soft static void dnkbd_rawrepeat(void *); #endif static int dnkbd_send(struct dnkbd_softc *, const uint8_t *, size_t); +static void dnkbd_break(struct dnkbd_softc *, int); int dnkbd_match(device_t parent, cfdata_t cf, void *aux) @@ -309,6 +310,12 @@ dnkbd_attach(device_t parent, device_t s frodo_intr_establish(parent, dnkbd_intr, sc, fa->fa_line, IPL_VM); + /* send break to reset keyboard state */ + dnkbd_break(sc, 1); + delay(10 * 1000); /* 10ms for 12 space bits */ + dnkbd_break(sc, 0); + delay(10 * 1000); + /* probe for keyboard */ if (dnkbd_probe(sc) != 0) { aprint_normal("no keyboard\n"); @@ -869,6 +876,24 @@ dnkbd_send(struct dnkbd_softc *sc, const return 0; } +void +dnkbd_break(struct dnkbd_softc *sc, int onoff) +{ + bus_space_tag_t bst; + bus_space_handle_t bsh; + uint8_t reg; + + bst = sc->sc_bst; + bsh = sc->sc_bsh; + + reg = bus_space_read_1(bst, bsh, com_lctl); + if (onoff) + reg |= LCR_SBREAK; + else + reg &= ~LCR_SBREAK; + bus_space_write_1(bst, bsh, com_lctl, reg); +} + int dnkbd_intr(void *v) {
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: pgoyette Date: Sat Mar 25 01:39:20 UTC 2017 Modified Files: src/tests/lib/libc/sys: t_mprotect.c Log Message: Rather than ghecking system global state to see if mprotect might be enabled, use the newly-committed sysctl proc.curproc.paxflags variable To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/sys/t_mprotect.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_mprotect.c diff -u src/tests/lib/libc/sys/t_mprotect.c:1.5 src/tests/lib/libc/sys/t_mprotect.c:1.6 --- src/tests/lib/libc/sys/t_mprotect.c:1.5 Fri Mar 24 08:18:27 2017 +++ src/tests/lib/libc/sys/t_mprotect.c Sat Mar 25 01:39:20 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_mprotect.c,v 1.5 2017/03/24 08:18:27 martin Exp $ */ +/* $NetBSD: t_mprotect.c,v 1.6 2017/03/25 01:39:20 pgoyette Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_mprotect.c,v 1.5 2017/03/24 08:18:27 martin Exp $"); +__RCSID("$NetBSD: t_mprotect.c,v 1.6 2017/03/25 01:39:20 pgoyette Exp $"); #include #include @@ -62,23 +62,16 @@ static bool paxinit(void) { size_t len = sizeof(int); - int pax_global = -1; - int pax_enabled = -1; + int pax_flags; int rv; - rv = sysctlbyname("security.pax.mprotect.global", - &pax_global, &len, NULL, 0); + rv = sysctlbyname("proc.curproc.paxflags", + &pax_flags, &len, NULL, 0); if (rv != 0) return false; - rv = sysctlbyname("security.pax.mprotect.enabled", - &pax_enabled, &len, NULL, 0); - - if (rv != 0) - return false; - - return pax_global == 1 && pax_enabled == 1; + return ((pax_flags & CTL_PROC_PAXFLAGS_MPROTECT) != 0); } ATF_TC_WITH_CLEANUP(mprotect_access);
CVS commit: src/share/man/man7
Module Name:src Committed By: pgoyette Date: Fri Mar 24 21:44:13 UTC 2017 Modified Files: src/share/man/man7: sysctl.7 Log Message: Document new proc.curproc.paxflags variable. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/share/man/man7/sysctl.7 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man7/sysctl.7 diff -u src/share/man/man7/sysctl.7:1.110 src/share/man/man7/sysctl.7:1.111 --- src/share/man/man7/sysctl.7:1.110 Thu Jan 12 18:19:31 2017 +++ src/share/man/man7/sysctl.7 Fri Mar 24 21:44:13 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: sysctl.7,v 1.110 2017/01/12 18:19:31 abhinav Exp $ +.\" $NetBSD: sysctl.7,v 1.111 2017/03/24 21:44:13 pgoyette Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 .\" -.Dd November 17, 2016 +.Dd March 25, 2017 .Dt SYSCTL 7 .Os .Sh NAME @@ -964,7 +964,7 @@ structures is returned, whose size depends on the current number of such objects in the system. The third and fourth level numeric names are as follows: .Bl -column "KERN_PROC_SESSION" "Fourth level is:" -offset indent -.It Sy Third level name Ta Sy Fourth level is: +.It Sy Third level name Ta Sy Fourth level is : .It KERN_PROC_ALL None .It KERN_PROC_GID A group ID .It KERN_PROC_PID A process ID @@ -1347,7 +1347,7 @@ The fourth level name is an address fami select all address families. The fifth and sixth level names are as follows: .Bl -column "Fifth level name" "Sixth level is:" -offset indent -.It Sy Fifth level name Ta Sy Sixth level is: +.It Sy Fifth level name Ta Sy Sixth level is : .It NET_RT_FLAGS rtflags .It NET_RT_DUMP None .It NET_RT_IFLIST None @@ -2124,6 +2124,7 @@ points to the current process, or the PI .It proc.pid.stopfork int yes .It proc.pid.stopexec int yes .It proc.pid.stopexit int yes +.It proc.pid.paxflags int no .El .Bl -tag -width "123456" .It Li proc.pid.corename ( Dv PROC_PID_CORENAME ) @@ -2244,6 +2245,10 @@ or its resource settings with before it disappears. .Pp This value is also inherited by the process's children. +.It Li proc.pid.paxflags ( Dv PROC_PID_PAXFLAGS ) +This read-only variable returns the current value of the process's pax +flags (see +.Xr paxctl 8 ) . .El .Ss The user.* subtree ( Dv CTL_USER ) The string and integer information available for the
CVS commit: src/sys
Module Name:src Committed By: pgoyette Date: Fri Mar 24 21:43:21 UTC 2017 Modified Files: src/sys/kern: kern_resource.c src/sys/sys: sysctl.h Log Message: Add new sysctl variable proc.curproc.paxflags so a process can determine which flags were set for it. Define some values for the variable: CTL_PROC_PAXFLAGS_{ASLR,MPROTECT,GUARD} To generate a diff of this commit: cvs rdiff -u -r1.175 -r1.176 src/sys/kern/kern_resource.c cvs rdiff -u -r1.221 -r1.222 src/sys/sys/sysctl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_resource.c diff -u src/sys/kern/kern_resource.c:1.175 src/sys/kern/kern_resource.c:1.176 --- src/sys/kern/kern_resource.c:1.175 Wed Jul 13 09:52:00 2016 +++ src/sys/kern/kern_resource.c Fri Mar 24 21:43:20 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_resource.c,v 1.175 2016/07/13 09:52:00 njoly Exp $ */ +/* $NetBSD: kern_resource.c,v 1.176 2017/03/24 21:43:20 pgoyette Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.175 2016/07/13 09:52:00 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.176 2017/03/24 21:43:20 pgoyette Exp $"); #include #include @@ -813,6 +813,49 @@ sysctl_proc_findproc(lwp_t *l, pid_t pid } /* + * sysctl_proc_paxflags: helper routine to get process's paxctl flags + */ +static int +sysctl_proc_paxflags(SYSCTLFN_ARGS) +{ + struct proc *p; + struct sysctlnode node; + int paxflags; + int error; + + /* First, validate the request. */ + if (namelen != 0 || name[-1] != PROC_PID_PAXFLAGS) + return EINVAL; + + /* Find the process. Hold a reference (p_reflock), if found. */ + error = sysctl_proc_findproc(l, (pid_t)name[-2], &p); + if (error) + return error; + + /* XXX-elad */ + error = kauth_authorize_process(l->l_cred, KAUTH_PROCESS_CANSEE, p, + KAUTH_ARG(KAUTH_REQ_PROCESS_CANSEE_ENTRY), NULL, NULL); + if (error) { + rw_exit(&p->p_reflock); + return error; + } + + /* Retrieve the limits. */ + node = *rnode; + paxflags = p->p_pax; + node.sysctl_data = &paxflags; + + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + + /* If attempting to write new value, it's an error */ + if (error == 0 && newp != NULL) + error = EACCES; + + rw_exit(&p->p_reflock); + return error; +} + +/* * sysctl_proc_corename: helper routine to get or set the core file name * for a process specified by PID. */ @@ -1048,6 +1091,13 @@ sysctl_proc_setup(void) CTL_PROC, PROC_CURPROC, CTL_EOL); sysctl_createv(&proc_sysctllog, 0, NULL, NULL, + CTLFLAG_PERMANENT|CTLFLAG_READONLY, + CTLTYPE_INT, "paxflags", + SYSCTL_DESCR("Process PAX control flags"), + sysctl_proc_paxflags, 0, NULL, 0, + CTL_PROC, PROC_CURPROC, PROC_PID_PAXFLAGS, CTL_EOL); + + sysctl_createv(&proc_sysctllog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE|CTLFLAG_ANYWRITE, CTLTYPE_STRING, "corename", SYSCTL_DESCR("Core file name"), Index: src/sys/sys/sysctl.h diff -u src/sys/sys/sysctl.h:1.221 src/sys/sys/sysctl.h:1.222 --- src/sys/sys/sysctl.h:1.221 Mon Apr 4 23:31:46 2016 +++ src/sys/sys/sysctl.h Fri Mar 24 21:43:21 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.h,v 1.221 2016/04/04 23:31:46 christos Exp $ */ +/* $NetBSD: sysctl.h,v 1.222 2017/03/24 21:43:21 pgoyette Exp $ */ /* * Copyright (c) 1989, 1993 @@ -1026,7 +1026,8 @@ struct kinfo_vmentry { #define PROC_PID_STOPFORK 3 #define PROC_PID_STOPEXEC 4 #define PROC_PID_STOPEXIT 5 -#define PROC_PID_MAXID 6 +#define PROC_PID_PAXFLAGS 6 +#define PROC_PID_MAXID 7 #define PROC_PID_NAMES { \ { 0, 0 }, \ @@ -1035,6 +1036,7 @@ struct kinfo_vmentry { { "stopfork", CTLTYPE_INT }, \ { "stopexec", CTLTYPE_INT }, \ { "stopexit", CTLTYPE_INT }, \ + { "paxflags", CTLTYPE_INT }, \ } /* Limit types from */ @@ -1079,6 +1081,16 @@ struct kinfo_vmentry { } /* + * Export PAX flag definitions to userland. + * + * XXX These are duplicated from sys/pax.h but that header is not + * XXX installed. + */ +#define CTL_PROC_PAXFLAGS_ASLR 0x01 +#define CTL_PROC_PAXFLAGS_MPROTECT 0x02 +#define CTL_PROC_PAXFLAGS_GUARD 0x04 + +/* * CTL_EMUL definitions * * Second level identifier specifies which emulation variable.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: macallan Date: Fri Mar 24 21:28:03 UTC 2017 Modified Files: src/sys/dev/pci: wcfb.c Log Message: support screen blanking To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/wcfb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/wcfb.c diff -u src/sys/dev/pci/wcfb.c:1.16 src/sys/dev/pci/wcfb.c:1.17 --- src/sys/dev/pci/wcfb.c:1.16 Fri Mar 24 00:52:49 2017 +++ src/sys/dev/pci/wcfb.c Fri Mar 24 21:28:03 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wcfb.c,v 1.16 2017/03/24 00:52:49 macallan Exp $ */ +/* $NetBSD: wcfb.c,v 1.17 2017/03/24 21:28:03 macallan Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Miodrag Vallat. @@ -20,7 +20,7 @@ /* a driver for (some) 3DLabs Wildcat cards, based on OpenBSD's ifb driver */ #include -__KERNEL_RCSID(0, "$NetBSD: wcfb.c,v 1.16 2017/03/24 00:52:49 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wcfb.c,v 1.17 2017/03/24 21:28:03 macallan Exp $"); #include #include @@ -85,7 +85,7 @@ struct wcfb_softc { const struct wsscreen_descr *sc_screens[1]; struct wsscreen_list sc_screenlist; struct vcons_data vd; - int sc_mode; + int sc_mode, sc_dpms; u_char sc_cmap_red[256]; u_char sc_cmap_green[256]; u_char sc_cmap_blue[256]; @@ -251,6 +251,7 @@ wcfb_attach(device_t parent, device_t se /* make sure video output is on */ bus_space_write_4(sc->sc_regt, sc->sc_regh, WC_DPMS_STATE, WC_DPMS_ON); + sc->sc_dpms = WSDISPLAYIO_VIDEO_ON; #if 0 /* testing & debugging voodoo */ @@ -425,9 +426,20 @@ wcfb_ioctl(void *v, void *vs, u_long cmd return wsdisplayio_busid_pci(sc->sc_dev, sc->sc_pc, sc->sc_pcitag, data); - case WSDISPLAYIO_SMODE: { - /*int new_mode = *(int*)data, i;*/ + case WSDISPLAYIO_SVIDEO: { + int new_mode = *(int*)data; + if (new_mode != sc->sc_dpms) { + sc->sc_dpms = new_mode; + bus_space_write_4(sc->sc_regt, sc->sc_regh, + WC_DPMS_STATE, + (new_mode == WSDISPLAYIO_VIDEO_ON) ? + WC_DPMS_ON : WC_DPMS_STANDBY); } + } + return 0; + + case WSDISPLAYIO_GVIDEO: + *(int*)data = sc->sc_dpms; return 0; case WSDISPLAYIO_GETCMAP:
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Fri Mar 24 19:21:07 UTC 2017 Modified Files: src/sys/arch/x86/x86: pmc.c Log Message: Handle counter overflows, and sample with 50 events per interrupt. It's a pre-requisite for real sampling. Overflows are not yet displayed by pmc(1), but will be soon. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/x86/pmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmc.c diff -u src/sys/arch/x86/x86/pmc.c:1.4 src/sys/arch/x86/x86/pmc.c:1.5 --- src/sys/arch/x86/x86/pmc.c:1.4 Fri Mar 24 18:30:44 2017 +++ src/sys/arch/x86/x86/pmc.c Fri Mar 24 19:21:06 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: pmc.c,v 1.4 2017/03/24 18:30:44 maxv Exp $ */ +/* $NetBSD: pmc.c,v 1.5 2017/03/24 19:21:06 maxv Exp $ */ /* * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.4 2017/03/24 18:30:44 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.5 2017/03/24 19:21:06 maxv Exp $"); #include #include @@ -82,17 +82,26 @@ __KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.4 #include #include #include +#include +#include + +#include + +#define NEVENTS_SAMPLE 50 typedef struct { bool running; uint32_t evtmsr; /* event selector MSR */ uint64_t evtval; /* event selector value */ uint32_t ctrmsr; /* counter MSR */ - uint64_t ctrval; /* initial counter value */ + uint64_t ctrinitval; /* initial counter value */ uint64_t ctrmaxval; /* maximal counter value */ uint64_t ctrmask; } pmc_state_t; +static nmi_handler_t *pmc_nmi_handle; +static uint32_t pmc_lapic_image[MAXCPUS]; + static x86_pmc_cpuval_t pmc_val_cpus[MAXCPUS] __aligned(CACHE_LINE_SIZE); static kmutex_t pmc_lock; @@ -100,31 +109,58 @@ static pmc_state_t pmc_state[PMC_NCOUNTE static int pmc_ncounters __read_mostly; static int pmc_type __read_mostly; -static void -pmc_read_cpu(void *arg1, void *arg2) +static int +pmc_nmi(const struct trapframe *tf, void *dummy) { - pmc_state_t *pmc = (pmc_state_t *)arg1; struct cpu_info *ci = curcpu(); + pmc_state_t *pmc; + size_t i; + + if (pmc_type == PMC_TYPE_NONE) { + return 0; + } + for (i = 0; i < pmc_ncounters; i++) { + pmc = &pmc_state[i]; + if (!pmc->running) { + continue; + } + /* XXX make sure it really comes from this PMC */ + break; + } + if (i == pmc_ncounters) { + return 0; + } + + /* Count the overflow, and restart the counter */ + pmc_val_cpus[cpu_index(ci)].overfl++; + wrmsr(pmc->ctrmsr, pmc->ctrinitval); - pmc_val_cpus[cpu_index(ci)].ctrval = rdmsr(pmc->ctrmsr) & pmc->ctrmask; + return 1; } static void -pmc_read(pmc_state_t *pmc) +pmc_read_cpu(void *arg1, void *arg2) { - uint64_t xc; + pmc_state_t *pmc = (pmc_state_t *)arg1; + struct cpu_info *ci = curcpu(); - xc = xc_broadcast(0, pmc_read_cpu, pmc, NULL); - xc_wait(xc); + pmc_val_cpus[cpu_index(ci)].ctrval = + (rdmsr(pmc->ctrmsr) & pmc->ctrmask) - pmc->ctrinitval; } static void pmc_apply_cpu(void *arg1, void *arg2) { pmc_state_t *pmc = (pmc_state_t *)arg1; + bool start = (bool)arg2; struct cpu_info *ci = curcpu(); - wrmsr(pmc->ctrmsr, pmc->ctrval); + if (start) { + pmc_lapic_image[cpu_index(ci)] = i82489_readreg(LAPIC_PCINT); + i82489_writereg(LAPIC_PCINT, LAPIC_DLMODE_NMI); + } + + wrmsr(pmc->ctrmsr, pmc->ctrinitval); switch (pmc_type) { case PMC_TYPE_I686: case PMC_TYPE_K7: @@ -135,15 +171,30 @@ pmc_apply_cpu(void *arg1, void *arg2) pmc_val_cpus[cpu_index(ci)].ctrval = 0; pmc_val_cpus[cpu_index(ci)].overfl = 0; + + if (!start) { + i82489_writereg(LAPIC_PCINT, pmc_lapic_image[cpu_index(ci)]); + } +} + +static void +pmc_read(pmc_state_t *pmc) +{ + uint64_t xc; + + xc = xc_broadcast(0, pmc_read_cpu, pmc, NULL); + xc_wait(xc); } static void -pmc_apply(pmc_state_t *pmc) +pmc_apply(pmc_state_t *pmc, bool start) { uint64_t xc; - xc = xc_broadcast(0, pmc_apply_cpu, pmc, NULL); + xc = xc_broadcast(0, pmc_apply_cpu, pmc, (void *)start); xc_wait(xc); + + pmc->running = start; } static void @@ -151,19 +202,17 @@ pmc_start(pmc_state_t *pmc, struct x86_p { uint64_t event, unit; - pmc->running = true; - /* * Initialize the counter MSR. */ - pmc->ctrval = args->val; + pmc->ctrinitval = pmc->ctrmaxval - NEVENTS_SAMPLE; /* * Initialize the event MSR. */ switch (pmc_type) { case PMC_TYPE_I686: - pmc->evtval = args->event | PMC6_EVTSEL_EN | + pmc->evtval = args->event | PMC6_EVTSEL_EN | PMC6_EVTSEL_INT | (args->unit << PMC6_EVTSEL_UNIT_SHIFT) | ((args->flags & PMC_SETUP_KERNEL) ? PMC6_EVTSEL_OS : 0) | ((args->flags & PMC_SETUP_USER) ? PMC6_EVTSEL_USR : 0) | @@ -176,7 +225,7 @@ pmc_start(pmc_state_t *pmc, struct x86_p event = (args->event & K7_EVTSEL_EVENT); unit = (args->unit << K7_EVTSEL_UNIT_SHIFT) & K7_EVTSEL_UNIT; - pmc->evtval = event | unit | K7_EVTSEL_EN | + pmc->
CVS commit: src
Module Name:src Committed By: maxv Date: Fri Mar 24 18:30:44 UTC 2017 Modified Files: src/sys/arch/x86/x86: pmc.c src/usr.bin/pmc: pmc.c Log Message: Drop support for 586 PMCs; the detection is broken, and I'm not sure the code even works. No one has ever cared about this anyway, and we won't maintain it. While here, fix the mask on the counter - K7 and F10H have 48bit counters. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/x86/pmc.c cvs rdiff -u -r1.22 -r1.23 src/usr.bin/pmc/pmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmc.c diff -u src/sys/arch/x86/x86/pmc.c:1.3 src/sys/arch/x86/x86/pmc.c:1.4 --- src/sys/arch/x86/x86/pmc.c:1.3 Sat Mar 11 14:13:39 2017 +++ src/sys/arch/x86/x86/pmc.c Fri Mar 24 18:30:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: pmc.c,v 1.3 2017/03/11 14:13:39 maxv Exp $ */ +/* $NetBSD: pmc.c,v 1.4 2017/03/24 18:30:44 maxv Exp $ */ /* * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.3 2017/03/11 14:13:39 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.4 2017/03/24 18:30:44 maxv Exp $"); #include #include @@ -89,6 +89,8 @@ typedef struct { uint64_t evtval; /* event selector value */ uint32_t ctrmsr; /* counter MSR */ uint64_t ctrval; /* initial counter value */ + uint64_t ctrmaxval; /* maximal counter value */ + uint64_t ctrmask; } pmc_state_t; static x86_pmc_cpuval_t pmc_val_cpus[MAXCPUS] __aligned(CACHE_LINE_SIZE); @@ -104,9 +106,7 @@ pmc_read_cpu(void *arg1, void *arg2) pmc_state_t *pmc = (pmc_state_t *)arg1; struct cpu_info *ci = curcpu(); - pmc_val_cpus[cpu_index(ci)].ctrval = - rdmsr(pmc->ctrmsr) & 0xffULL; - pmc_val_cpus[cpu_index(ci)].overfl = 0; + pmc_val_cpus[cpu_index(ci)].ctrval = rdmsr(pmc->ctrmsr) & pmc->ctrmask; } static void @@ -126,11 +126,6 @@ pmc_apply_cpu(void *arg1, void *arg2) wrmsr(pmc->ctrmsr, pmc->ctrval); switch (pmc_type) { - case PMC_TYPE_I586: - wrmsr(MSR_CESR, pmc_state[0].evtval | - (pmc_state[1].evtval << 16)); - break; - case PMC_TYPE_I686: case PMC_TYPE_K7: case PMC_TYPE_F10H: @@ -167,13 +162,6 @@ pmc_start(pmc_state_t *pmc, struct x86_p * Initialize the event MSR. */ switch (pmc_type) { - case PMC_TYPE_I586: - pmc->evtval = args->event | - ((args->flags & PMC_SETUP_KERNEL) ? PMC5_CESR_OS : 0) | - ((args->flags & PMC_SETUP_USER) ? PMC5_CESR_USR : 0) | - ((args->flags & PMC_SETUP_EDGE) ? PMC5_CESR_E : 0); - break; - case PMC_TYPE_I686: pmc->evtval = args->event | PMC6_EVTSEL_EN | (args->unit << PMC6_EVTSEL_UNIT_SHIFT) | @@ -233,61 +221,52 @@ pmc_init(void) { const char *cpu_vendorstr; struct cpu_info *ci; + size_t i; pmc_type = PMC_TYPE_NONE; + if (cpu_class != CPUCLASS_686) + return; + ci = curcpu(); cpu_vendorstr = (char *)ci->ci_vendor; - switch (cpu_class) { - case CPUCLASS_586: - if (strncmp(cpu_vendorstr, "GenuineIntel", 12) == 0) { - pmc_type = PMC_TYPE_I586; - pmc_ncounters = 2; - pmc_state[0].ctrmsr = MSR_CTR0; - pmc_state[1].ctrmsr = MSR_CTR1; - break; + if (strncmp(cpu_vendorstr, "GenuineIntel", 12) == 0) { + /* Right now we're missing Pentium 4 support. */ + if (cpuid_level == -1 || + CPUID_TO_FAMILY(ci->ci_signature) == CPU_FAMILY_P4) + return; + pmc_type = PMC_TYPE_I686; + pmc_ncounters = 2; + for (i = 0; i < pmc_ncounters; i++) { + pmc_state[i].evtmsr = MSR_EVNTSEL0 + i; + pmc_state[i].ctrmsr = MSR_PERFCTR0 + i; + pmc_state[i].ctrmaxval = (UINT64_C(1) << 40) - 1; + pmc_state[i].ctrmask = 0xFFULL; } - - case CPUCLASS_686: - if (strncmp(cpu_vendorstr, "GenuineIntel", 12) == 0) { - /* Right now we're missing Pentium 4 support. */ - if (cpuid_level == -1 || - CPUID_TO_FAMILY(ci->ci_signature) == CPU_FAMILY_P4) -break; - pmc_type = PMC_TYPE_I686; - pmc_ncounters = 2; - pmc_state[0].evtmsr = MSR_EVNTSEL0; - pmc_state[0].ctrmsr = MSR_PERFCTR0; - pmc_state[1].evtmsr = MSR_EVNTSEL1; - pmc_state[1].ctrmsr = MSR_PERFCTR1; - } else if (strncmp(cpu_vendorstr, "AuthenticAMD", 12) == 0) { - if (CPUID_TO_FAMILY(ci->ci_signature) == 0x10) { -pmc_type = PMC_TYPE_F10H; -pmc_ncounters = 4; -pmc_state[0].evtmsr = MSR_F10H_EVNTSEL0; -pmc_state[0].ctrmsr = MSR_F10H_PERFCTR0; -pmc_state[1].evtmsr = MSR_F10H_EVNTSEL1; -pmc_state[1].ctrmsr = MSR_F10H_PERFCTR1; -pmc_state[2].evtmsr = MSR_F10H_EVNTSEL2; -pmc_state[2].ctrmsr = MSR_F10H_PERFCTR2; -pmc_state[3].evtmsr = MSR_F10H_EVNTSEL3; -pmc_state[3].ctrmsr = MSR_F10H_PERFCTR3; - } else { -/* XXX: make sure it is at least K7 */ -pmc_type = PMC_TYPE_K7; -pmc_ncounters = 4; -pmc_state[0].evtmsr = MSR_K7_EVNTSEL0; -pmc_state[0].ctrmsr = MSR_K7_PERFCTR0; -pmc_state[1].evtmsr = MSR_K7_EVNTSEL1; -pmc_state[1].ctrmsr = MS
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Fri Mar 24 18:03:32 UTC 2017 Modified Files: src/sys/arch/amd64/amd64: amd64_trap.S Log Message: Unconditionnally save the segment registers - because we could have a kernel %gs and a userland %es/%ds -, and explain why T_NMI is a special case. Note that checking %gs directly is not a good idea: recent CPUs have the FSGSBASE instruction set, which allows userland to directly modify %gs without going through the kernel. If we ever enable this set, we will have to change this function, since we won't be able to test %gs against VM_MIN_KERNEL_ADDRESS anymore. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amd64/amd64/amd64_trap.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/amd64_trap.S diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.4 src/sys/arch/amd64/amd64/amd64_trap.S:1.5 --- src/sys/arch/amd64/amd64/amd64_trap.S:1.4 Sun Aug 7 09:04:55 2016 +++ src/sys/arch/amd64/amd64/amd64_trap.S Fri Mar 24 18:03:32 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: amd64_trap.S,v 1.4 2016/08/07 09:04:55 maxv Exp $ */ +/* $NetBSD: amd64_trap.S,v 1.5 2017/03/24 18:03:32 maxv Exp $ */ /*- * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ #if 0 #include -__KERNEL_RCSID(0, "$NetBSD: amd64_trap.S,v 1.4 2016/08/07 09:04:55 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amd64_trap.S,v 1.5 2017/03/24 18:03:32 maxv Exp $"); #endif /* @@ -103,39 +103,54 @@ IDTVEC(trap01) ZTRAP(T_TRCTRAP) IDTVEC_END(trap01) +/* + * Non Maskable Interrupts are a special case: they can be triggered even + * with interrupts disabled, and once triggered they block further NMIs + * until an 'iret' instruction is executed. + * + * Therefore we don't enable interrupts, because the CPU could switch to + * another LWP, call 'iret' and unintentionally leave the NMI mode. + * + * We need to be careful about %gs too, because it is possible that we were + * running in kernel mode with a userland %gs. + */ IDTVEC(trap02) #if defined(XEN) ZTRAP(T_NMI) -#else /* defined(XEN) */ - pushq $0 - pushq $T_NMI +#else + pushq $0 + pushq $T_NMI subq $TF_REGSIZE,%rsp INTR_SAVE_GPRS - movl $MSR_GSBASE,%ecx - rdmsr - cmpl $VM_MIN_KERNEL_ADDRESS_HIGH32,%edx - jae 1f - swapgs movw %gs,TF_GS(%rsp) movw %fs,TF_FS(%rsp) movw %es,TF_ES(%rsp) movw %ds,TF_DS(%rsp) + + movl $MSR_GSBASE,%ecx + rdmsr + cmpl $VM_MIN_KERNEL_ADDRESS_HIGH32,%edx + jae noswapgs + + swapgs movq %rsp,%rdi incq CPUVAR(NTRAP) call _C_LABEL(trap) - movw TF_ES(%rsp),%es - movw TF_DS(%rsp),%ds swapgs - jmp 2f -1: + jmp nmileave + +noswapgs: movq %rsp,%rdi incq CPUVAR(NTRAP) call _C_LABEL(trap) -2: + +nmileave: + movw TF_ES(%rsp),%es + movw TF_DS(%rsp),%ds INTR_RESTORE_GPRS addq $TF_REGSIZE+16,%rsp iretq -#endif /* defined(XEN) */ +#endif IDTVEC_END(trap02) IDTVEC(trap03)
CVS commit: src/sys
Module Name:src Committed By: christos Date: Fri Mar 24 17:40:44 UTC 2017 Modified Files: src/sys/kern: kern_sig.c kern_syscall.c sys_process.c src/sys/sys: proc.h ptrace.h Log Message: Instead of copying parts of sigswitch to process_stoptrace, use it directly. Rename process_stoptrace -> proc_stoptrace and put it in kern_sig.c so we don't need to expose any more functions from it. To generate a diff of this commit: cvs rdiff -u -r1.333 -r1.334 src/sys/kern/kern_sig.c cvs rdiff -u -r1.15 -r1.16 src/sys/kern/kern_syscall.c cvs rdiff -u -r1.177 -r1.178 src/sys/kern/sys_process.c cvs rdiff -u -r1.338 -r1.339 src/sys/sys/proc.h cvs rdiff -u -r1.59 -r1.60 src/sys/sys/ptrace.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_sig.c diff -u src/sys/kern/kern_sig.c:1.333 src/sys/kern/kern_sig.c:1.334 --- src/sys/kern/kern_sig.c:1.333 Thu Mar 23 17:59:55 2017 +++ src/sys/kern/kern_sig.c Fri Mar 24 13:40:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig.c,v 1.333 2017/03/23 21:59:55 christos Exp $ */ +/* $NetBSD: kern_sig.c,v 1.334 2017/03/24 17:40:44 christos Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.333 2017/03/23 21:59:55 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.334 2017/03/24 17:40:44 christos Exp $"); #include "opt_ptrace.h" #include "opt_dtrace.h" @@ -83,6 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v #include #include #include +#include #include #include #include @@ -116,6 +117,7 @@ static sigset_t stopsigmask __cacheline sigset_t sigcantmask __cacheline_aligned; static void ksiginfo_exechook(struct proc *, void *); +static void proc_stop(struct proc *, int); static void proc_stop_callout(void *); static int sigchecktrace(void); static int sigpost(struct lwp *, sig_t, int, int); @@ -1535,7 +1537,7 @@ sigswitch(bool ppsig, int ppmask, int si */ if (p->p_stat == SACTIVE && (p->p_sflag & PS_STOPPING) == 0) { KASSERT(signo != 0); - proc_stop(p, 0, signo); + proc_stop(p, signo); KASSERT(p->p_nrlwps > 0); } @@ -2099,7 +2101,7 @@ sigexit(struct lwp *l, int signo) * Put process 'p' into the stopped state and optionally, notify the parent. */ void -proc_stop(struct proc *p, int now, int signo) +proc_stop(struct proc *p, int signo) { struct lwp *l; @@ -2121,7 +2123,7 @@ proc_stop(struct proc *p, int now, int s * LWP to stop will take care of it. */ - if (p->p_nrlwps == 0 || (now && p->p_nrlwps == 1 && p == curproc)) { + if (p->p_nrlwps == 0) { proc_stop_done(p, true, PS_NOCLDSTOP); } else { /* @@ -2254,6 +2256,27 @@ proc_unstop(struct proc *p) } } +void +proc_stoptrace(int trapno) +{ + struct lwp *l = curlwp; + struct proc *p = l->l_proc, *pp; + + mutex_enter(p->p_lock); + pp = p->p_pptr; + if (pp->p_pid == 1) { + CLR(p->p_slflag, PSL_SYSCALL); /* XXXSMP */ + mutex_exit(p->p_lock); + return; + } + + p->p_xsig = SIGTRAP; + p->p_sigctx.ps_info._signo = p->p_xsig; + p->p_sigctx.ps_info._code = trapno; + sigswitch(true, 0, p->p_xsig); + mutex_exit(p->p_lock); +} + static int filt_sigattach(struct knote *kn) { Index: src/sys/kern/kern_syscall.c diff -u src/sys/kern/kern_syscall.c:1.15 src/sys/kern/kern_syscall.c:1.16 --- src/sys/kern/kern_syscall.c:1.15 Thu Mar 23 17:59:55 2017 +++ src/sys/kern/kern_syscall.c Fri Mar 24 13:40:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_syscall.c,v 1.15 2017/03/23 21:59:55 christos Exp $ */ +/* $NetBSD: kern_syscall.c,v 1.16 2017/03/24 17:40:44 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.15 2017/03/23 21:59:55 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.16 2017/03/24 17:40:44 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_modular.h" @@ -248,7 +248,7 @@ trace_enter(register_t code, const struc #ifdef PTRACE if ((curlwp->l_proc->p_slflag & (PSL_SYSCALL|PSL_TRACED)) == (PSL_SYSCALL|PSL_TRACED)) { - process_stoptrace(TRAP_SCE); + proc_stoptrace(TRAP_SCE); if (curlwp->l_proc->p_slflag & PSL_SYSCALLEMU) { /* tracer will emulate syscall for us */ error = EJUSTRETURN; @@ -289,7 +289,7 @@ trace_exit(register_t code, const struct #ifdef PTRACE if ((p->p_slflag & (PSL_SYSCALL|PSL_TRACED|PSL_SYSCALLEMU)) == (PSL_SYSCALL|PSL_TRACED)) { - process_stoptrace(TRAP_SCX); + proc_stoptrace(TRAP_SCX); } CLR(p->p_slflag, PSL_SYSCALLEMU); #endif Index: src/sys/kern/sys_process.c diff -u src/sys/kern/sys_process.c:1.177 src/sys/kern/sys_process.c:1.178 --- src/sys/kern/sys_process.c:1.177 Thu Mar 23 17:59:55 2017 +++ src/sys/kern/sys_process.c Fri Mar 24 13:40:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_process.c,v 1.177 2017/03/23 21:59:55 christos Exp $ */ +/* $NetBSD: sys_process.c
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Fri Mar 24 17:09:37 UTC 2017 Modified Files: src/sys/arch/amd64/amd64: machdep.c src/sys/arch/i386/i386: machdep.c src/sys/arch/x86/x86: x86_machdep.c src/sys/arch/xen/conf: files.xen Log Message: Don't compile PMCs on Xen. To generate a diff of this commit: cvs rdiff -u -r1.254 -r1.255 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.781 -r1.782 src/sys/arch/i386/i386/machdep.c cvs rdiff -u -r1.89 -r1.90 src/sys/arch/x86/x86/x86_machdep.c cvs rdiff -u -r1.145 -r1.146 src/sys/arch/xen/conf/files.xen Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.254 src/sys/arch/amd64/amd64/machdep.c:1.255 --- src/sys/arch/amd64/amd64/machdep.c:1.254 Thu Mar 23 17:25:51 2017 +++ src/sys/arch/amd64/amd64/machdep.c Fri Mar 24 17:09:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.254 2017/03/23 17:25:51 maxv Exp $ */ +/* $NetBSD: machdep.c,v 1.255 2017/03/24 17:09:36 maxv Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -111,7 +111,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.254 2017/03/23 17:25:51 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.255 2017/03/24 17:09:36 maxv Exp $"); /* #define XENDEBUG_LOW */ @@ -170,7 +170,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include #include #include -#include #include #include #include @@ -1767,8 +1766,6 @@ init_x86_64(paddr_t first_avail) } #endif - pmc_init(); - pcb->pcb_dbregs = NULL; x86_dbregs_setup_initdbstate(); Index: src/sys/arch/i386/i386/machdep.c diff -u src/sys/arch/i386/i386/machdep.c:1.781 src/sys/arch/i386/i386/machdep.c:1.782 --- src/sys/arch/i386/i386/machdep.c:1.781 Thu Mar 23 18:08:06 2017 +++ src/sys/arch/i386/i386/machdep.c Fri Mar 24 17:09:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.781 2017/03/23 18:08:06 maxv Exp $ */ +/* $NetBSD: machdep.c,v 1.782 2017/03/24 17:09:36 maxv Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009 @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.781 2017/03/23 18:08:06 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.782 2017/03/24 17:09:36 maxv Exp $"); #include "opt_beep.h" #include "opt_compat_ibcs2.h" @@ -135,7 +135,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include #include #include -#include #include #include #include @@ -1410,8 +1409,6 @@ init386(paddr_t first_avail) rw_init(&svr4_fasttrap_lock); - pmc_init(); - pcb->pcb_dbregs = NULL; x86_dbregs_setup_initdbstate(); Index: src/sys/arch/x86/x86/x86_machdep.c diff -u src/sys/arch/x86/x86/x86_machdep.c:1.89 src/sys/arch/x86/x86/x86_machdep.c:1.90 --- src/sys/arch/x86/x86/x86_machdep.c:1.89 Tue Feb 14 13:29:09 2017 +++ src/sys/arch/x86/x86/x86_machdep.c Fri Mar 24 17:09:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: x86_machdep.c,v 1.89 2017/02/14 13:29:09 nonaka Exp $ */ +/* $NetBSD: x86_machdep.c,v 1.90 2017/03/24 17:09:37 maxv Exp $ */ /*- * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi, @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.89 2017/02/14 13:29:09 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.90 2017/03/24 17:09:37 maxv Exp $"); #include "opt_modular.h" #include "opt_physmem.h" @@ -66,6 +66,7 @@ __KERNEL_RCSID(0, "$NetBSD: x86_machdep. #include #include +#include #include @@ -1072,10 +1073,10 @@ machdep_init(void) void x86_startup(void) { - #if !defined(XEN) nmi_init(); -#endif /* !defined(XEN) */ + pmc_init(); +#endif } /* Index: src/sys/arch/xen/conf/files.xen diff -u src/sys/arch/xen/conf/files.xen:1.145 src/sys/arch/xen/conf/files.xen:1.146 --- src/sys/arch/xen/conf/files.xen:1.145 Fri Mar 10 14:40:56 2017 +++ src/sys/arch/xen/conf/files.xen Fri Mar 24 17:09:37 2017 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen,v 1.145 2017/03/10 14:40:56 maxv Exp $ +# $NetBSD: files.xen,v 1.146 2017/03/24 17:09:37 maxv Exp $ # NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp # NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp @@ -140,7 +140,6 @@ file arch/xen/x86/intr.c machdep file arch/xen/x86/xen_ipi.c multiprocessor file arch/x86/x86/pmap.c machdep file arch/x86/x86/pmap_tlb.c machdep -file arch/x86/x86/pmc.c machdep file arch/x86/x86/procfs_machdep.c procfs file arch/x86/x86/sys_machdep.c machdep file arch/x86/x86/tsc.c machdep
CVS commit: src/sys/compat/ossaudio
Module Name:src Committed By: nat Date: Fri Mar 24 14:32:29 UTC 2017 Modified Files: src/sys/compat/ossaudio: ossaudio.c Log Message: Update compat/ossaudio with GETISPACE/GETOSPACE corrections from libossaudio. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/compat/ossaudio/ossaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/ossaudio/ossaudio.c diff -u src/sys/compat/ossaudio/ossaudio.c:1.69 src/sys/compat/ossaudio/ossaudio.c:1.70 --- src/sys/compat/ossaudio/ossaudio.c:1.69 Fri Sep 5 09:21:55 2014 +++ src/sys/compat/ossaudio/ossaudio.c Fri Mar 24 14:32:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ossaudio.c,v 1.69 2014/09/05 09:21:55 matt Exp $ */ +/* $NetBSD: ossaudio.c,v 1.70 2017/03/24 14:32:29 nat Exp $ */ /*- * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.69 2014/09/05 09:21:55 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.70 2017/03/24 14:32:29 nat Exp $"); #include #include @@ -619,12 +619,11 @@ oss_ioctl_audio(struct lwp *l, const str } setblocksize(fp, &tmpinfo); bufinfo.fragsize = tmpinfo.blocksize; - bufinfo.fragments = tmpinfo.hiwat - - (tmpinfo.play.seek + tmpinfo.blocksize - 1) / + bufinfo.fragments = (tmpinfo.hiwat * tmpinfo.blocksize - + (tmpinfo.play.seek + tmpinfo.blocksize -1)) / tmpinfo.blocksize; bufinfo.fragstotal = tmpinfo.hiwat; - bufinfo.bytes = - tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.play.seek; + bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize; error = copyout(&bufinfo, SCARG(uap, data), sizeof bufinfo); if (error) { DPRINTF(("%s: SNDCTL_DSP_GETOSPACE = %d\n", @@ -641,12 +640,9 @@ oss_ioctl_audio(struct lwp *l, const str } setblocksize(fp, &tmpinfo); bufinfo.fragsize = tmpinfo.blocksize; - bufinfo.fragments = tmpinfo.hiwat - - (tmpinfo.record.seek + tmpinfo.blocksize - 1) / - tmpinfo.blocksize; -bufinfo.fragstotal = tmpinfo.hiwat; - bufinfo.bytes = - tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.record.seek; + bufinfo.fragments = tmpinfo.record.seek / tmpinfo.blocksize; + bufinfo.fragstotal = tmpinfo.hiwat; + bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize; error = copyout(&bufinfo, SCARG(uap, data), sizeof bufinfo); if (error) { DPRINTF(("%s: SNDCTL_DSP_GETISPACE %d %d %d %d = %d\n",
CVS commit: src/share/misc
Module Name:src Committed By: ginsbach Date: Fri Mar 24 12:49:43 UTC 2017 Modified Files: src/share/misc: acronyms.comp Log Message: Add the more prevalent media access control (MAC) in addition to medium access control To generate a diff of this commit: cvs rdiff -u -r1.178 -r1.179 src/share/misc/acronyms.comp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/misc/acronyms.comp diff -u src/share/misc/acronyms.comp:1.178 src/share/misc/acronyms.comp:1.179 --- src/share/misc/acronyms.comp:1.178 Mon Mar 13 11:50:06 2017 +++ src/share/misc/acronyms.comp Fri Mar 24 12:49:43 2017 @@ -1,4 +1,4 @@ -$NetBSD: acronyms.comp,v 1.178 2017/03/13 11:50:06 leot Exp $ +$NetBSD: acronyms.comp,v 1.179 2017/03/24 12:49:43 ginsbach Exp $ 3WHS three-way handshake 8VSB 8-state vestigial side band modulation AA anti-aliasing @@ -726,7 +726,7 @@ LVT local vector table LWP light-weight process LZW Lempel Ziv Welch MAC mandatory access control -MAC medium access control +MAC {media,medium} access control MAC message authentication {check,code} MADT multiple APIC descriptor table MB megabyte
CVS commit: src
Module Name:src Committed By: nat Date: Fri Mar 24 11:46:52 UTC 2017 Modified Files: src/distrib/sets/lists/base: shl.mi src/lib/libossaudio: shlib_version Log Message: ABI of libossaudio did not change, so there was no need to bump the version number. Pointed out by mrg@ To generate a diff of this commit: cvs rdiff -u -r1.805 -r1.806 src/distrib/sets/lists/base/shl.mi cvs rdiff -u -r1.8 -r1.9 src/lib/libossaudio/shlib_version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/base/shl.mi diff -u src/distrib/sets/lists/base/shl.mi:1.805 src/distrib/sets/lists/base/shl.mi:1.806 --- src/distrib/sets/lists/base/shl.mi:1.805 Thu Mar 23 15:50:48 2017 +++ src/distrib/sets/lists/base/shl.mi Fri Mar 24 11:46:52 2017 @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.805 2017/03/23 15:50:48 nat Exp $ +# $NetBSD: shl.mi,v 1.806 2017/03/24 11:46:52 nat Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -417,7 +417,7 @@ ./usr/lib/libopenpgpsdk.so.0.9 base-obsolete obsolete ./usr/lib/libossaudio.so base-sys-shlib compatfile ./usr/lib/libossaudio.so.1 base-sys-shlib compatfile -./usr/lib/libossaudio.so.1.2 base-sys-shlib compatfile +./usr/lib/libossaudio.so.1.1 base-sys-shlib compatfile ./usr/lib/libp2k.sobase-puffs-shlib compatfile,rump ./usr/lib/libp2k.so.2base-puffs-shlib compatfile,rump ./usr/lib/libp2k.so.2.0base-puffs-shlib compatfile,rump Index: src/lib/libossaudio/shlib_version diff -u src/lib/libossaudio/shlib_version:1.8 src/lib/libossaudio/shlib_version:1.9 --- src/lib/libossaudio/shlib_version:1.8 Thu Mar 23 15:50:48 2017 +++ src/lib/libossaudio/shlib_version Fri Mar 24 11:46:52 2017 @@ -1,5 +1,5 @@ -# $NetBSD: shlib_version,v 1.8 2017/03/23 15:50:48 nat Exp $ +# $NetBSD: shlib_version,v 1.9 2017/03/24 11:46:52 nat Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # major=1 -minor=2 +minor=1
CVS commit: src/sys/net
Module Name:src Committed By: ozaki-r Date: Fri Mar 24 11:15:25 UTC 2017 Modified Files: src/sys/net: if.c Log Message: Remove extra semicolon To generate a diff of this commit: cvs rdiff -u -r1.387 -r1.388 src/sys/net/if.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if.c diff -u src/sys/net/if.c:1.387 src/sys/net/if.c:1.388 --- src/sys/net/if.c:1.387 Thu Mar 16 09:40:48 2017 +++ src/sys/net/if.c Fri Mar 24 11:15:25 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.387 2017/03/16 09:40:48 ozaki-r Exp $ */ +/* $NetBSD: if.c,v 1.388 2017/03/24 11:15:25 ozaki-r Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.387 2017/03/16 09:40:48 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.388 2017/03/24 11:15:25 ozaki-r Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3218,7 +3218,7 @@ if_transmit(struct ifnet *ifp, struct mb goto out; } - ifp->if_obytes += m->m_pkthdr.len;; + ifp->if_obytes += m->m_pkthdr.len; if (m->m_flags & M_MCAST) ifp->if_omcasts++;
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Fri Mar 24 10:58:06 UTC 2017 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: Don't forget to flush the xpq queue, otherwise shit may happen. To generate a diff of this commit: cvs rdiff -u -r1.244 -r1.245 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.244 src/sys/arch/x86/x86/pmap.c:1.245 --- src/sys/arch/x86/x86/pmap.c:1.244 Thu Mar 23 18:08:06 2017 +++ src/sys/arch/x86/x86/pmap.c Fri Mar 24 10:58:06 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.244 2017/03/23 18:08:06 maxv Exp $ */ +/* $NetBSD: pmap.c,v 1.245 2017/03/24 10:58:06 maxv Exp $ */ /*- * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc. @@ -171,7 +171,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.244 2017/03/23 18:08:06 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.245 2017/03/24 10:58:06 maxv Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -1020,6 +1020,7 @@ pmap_emap_enter(vaddr_t va, paddr_t pa, npte = pmap_pa2pte(pa); npte |= protection_codes[prot] | PG_V; pmap_pte_set(pte, npte); + pmap_pte_flush(); } /* @@ -1058,6 +1059,8 @@ pmap_emap_remove(vaddr_t sva, vsize_t le pte = (va < VM_MIN_KERNEL_ADDRESS) ? vtopte(va) : kvtopte(va); pmap_pte_set(pte, 0); } + + pmap_pte_flush(); } __strict_weak_alias(pmap_kenter_ma, pmap_kenter_pa);
CVS commit: src/sys/dev/pci
Module Name:src Committed By: knakahara Date: Fri Mar 24 10:39:10 UTC 2017 Modified Files: src/sys/dev/pci: if_wm.c Log Message: fix typo pointed out by ozaki-r@n.o. To generate a diff of this commit: cvs rdiff -u -r1.504 -r1.505 src/sys/dev/pci/if_wm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.504 src/sys/dev/pci/if_wm.c:1.505 --- src/sys/dev/pci/if_wm.c:1.504 Fri Mar 24 10:18:55 2017 +++ src/sys/dev/pci/if_wm.c Fri Mar 24 10:39:10 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.504 2017/03/24 10:18:55 knakahara Exp $ */ +/* $NetBSD: if_wm.c,v 1.505 2017/03/24 10:39:10 knakahara Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.504 2017/03/24 10:18:55 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.505 2017/03/24 10:39:10 knakahara Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -2563,7 +2563,7 @@ alloc_retry: ifp->if_start = wm_nq_start; /* * When the number of CPUs is one and the controller can use - * MSII-X, wm(4) use MSI-X but *does not* use multiqueue. + * MSI-X, wm(4) use MSI-X but *does not* use multiqueue. * That is, wm(4) use two interrupts, one is used for Tx/Rx * and the other is used for link status changing. * In this situation, wm_nq_transmit() is disadvantageous
CVS commit: src/share/dict
Module Name:src Committed By: abhinav Date: Fri Mar 24 10:22:23 UTC 2017 Modified Files: src/share/dict: web2 Log Message: Fix spelling of `administered'. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/share/dict/web2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/dict/web2 diff -u src/share/dict/web2:1.24 src/share/dict/web2:1.25 --- src/share/dict/web2:1.24 Tue Jan 31 14:58:17 2017 +++ src/share/dict/web2 Fri Mar 24 10:22:23 2017 @@ -2654,7 +2654,7 @@ adminiculate adminiculation adminiculum administer -administerd +administered administerial administrable administrant
CVS commit: src/sys/dev/pci
Module Name:src Committed By: knakahara Date: Fri Mar 24 10:18:55 UTC 2017 Modified Files: src/sys/dev/pci: if_wm.c Log Message: remove extra "+" To generate a diff of this commit: cvs rdiff -u -r1.503 -r1.504 src/sys/dev/pci/if_wm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.503 src/sys/dev/pci/if_wm.c:1.504 --- src/sys/dev/pci/if_wm.c:1.503 Fri Mar 24 10:02:35 2017 +++ src/sys/dev/pci/if_wm.c Fri Mar 24 10:18:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.503 2017/03/24 10:02:35 knakahara Exp $ */ +/* $NetBSD: if_wm.c,v 1.504 2017/03/24 10:18:55 knakahara Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.503 2017/03/24 10:02:35 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.504 2017/03/24 10:18:55 knakahara Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -2923,7 +2923,7 @@ wm_tick(void *arg) } ifp->if_collisions += CSR_READ(sc, WMREG_COLC); - ifp->if_ierrors += 0ULL + /* ensure quad_t */ + ifp->if_ierrors += 0ULL /* ensure quad_t */ + CSR_READ(sc, WMREG_CRCERRS) + CSR_READ(sc, WMREG_ALGNERRC) + CSR_READ(sc, WMREG_SYMERRC)
CVS commit: src/sys/dev/pci
Module Name:src Committed By: knakahara Date: Fri Mar 24 10:02:35 UTC 2017 Modified Files: src/sys/dev/pci: if_wm.c Log Message: add comments about the situation wm(4) use MSI-X but does not use multiqueue. To generate a diff of this commit: cvs rdiff -u -r1.502 -r1.503 src/sys/dev/pci/if_wm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.502 src/sys/dev/pci/if_wm.c:1.503 --- src/sys/dev/pci/if_wm.c:1.502 Fri Mar 24 10:01:55 2017 +++ src/sys/dev/pci/if_wm.c Fri Mar 24 10:02:35 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.502 2017/03/24 10:01:55 knakahara Exp $ */ +/* $NetBSD: if_wm.c,v 1.503 2017/03/24 10:02:35 knakahara Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.502 2017/03/24 10:01:55 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.503 2017/03/24 10:02:35 knakahara Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -2561,10 +2561,21 @@ alloc_retry: ifp->if_ioctl = wm_ioctl; if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) { ifp->if_start = wm_nq_start; + /* + * When the number of CPUs is one and the controller can use + * MSII-X, wm(4) use MSI-X but *does not* use multiqueue. + * That is, wm(4) use two interrupts, one is used for Tx/Rx + * and the other is used for link status changing. + * In this situation, wm_nq_transmit() is disadvantageous + * because of wm_select_txqueue() and pcq(9) overhead. + */ if (wm_is_using_multiqueue(sc)) ifp->if_transmit = wm_nq_transmit; } else { ifp->if_start = wm_start; + /* + * wm_transmit() has the same disadvantage as wm_transmit(). + */ if (wm_is_using_multiqueue(sc)) ifp->if_transmit = wm_transmit; } @@ -2833,7 +2844,7 @@ wm_watchdog(struct ifnet *ifp) /* * There are still some upper layer processing which call - * ifp->if_start(). e.g. ALTQ + * ifp->if_start(). e.g. ALTQ or one CPU system */ /* Try to get more packets going. */ ifp->if_start(ifp); @@ -7611,12 +7622,12 @@ wm_deferred_start_locked(struct wm_txque } if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) { - /* XXX need for ALTQ */ + /* XXX need for ALTQ or one CPU system */ if (qid == 0) wm_nq_start_locked(ifp); wm_nq_transmit_locked(ifp, txq); } else { - /* XXX need for ALTQ */ + /* XXX need for ALTQ or one CPU system */ if (qid == 0) wm_start_locked(ifp); wm_transmit_locked(ifp, txq);
CVS commit: src/sys/dev/pci
Module Name:src Committed By: knakahara Date: Fri Mar 24 10:01:55 UTC 2017 Modified Files: src/sys/dev/pci: if_wm.c Log Message: make self-describing function the code reading sc->sc_nintrs or sc->sc_nqueues directly. To generate a diff of this commit: cvs rdiff -u -r1.501 -r1.502 src/sys/dev/pci/if_wm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.501 src/sys/dev/pci/if_wm.c:1.502 --- src/sys/dev/pci/if_wm.c:1.501 Fri Mar 24 09:59:05 2017 +++ src/sys/dev/pci/if_wm.c Fri Mar 24 10:01:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.501 2017/03/24 09:59:05 knakahara Exp $ */ +/* $NetBSD: if_wm.c,v 1.502 2017/03/24 10:01:55 knakahara Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.501 2017/03/24 09:59:05 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.502 2017/03/24 10:01:55 knakahara Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -675,6 +675,8 @@ static void wm_rxdrain(struct wm_rxqueue static void wm_rss_getkey(uint8_t *); static void wm_init_rss(struct wm_softc *); static void wm_adjust_qnum(struct wm_softc *, int); +static inline bool wm_is_using_msix(struct wm_softc *); +static inline bool wm_is_using_multiqueue(struct wm_softc *); static int wm_softint_establish(struct wm_softc *, int, int); static int wm_setup_legacy(struct wm_softc *); static int wm_setup_msix(struct wm_softc *); @@ -2559,11 +2561,11 @@ alloc_retry: ifp->if_ioctl = wm_ioctl; if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) { ifp->if_start = wm_nq_start; - if (sc->sc_nqueues > 1) + if (wm_is_using_multiqueue(sc)) ifp->if_transmit = wm_nq_transmit; } else { ifp->if_start = wm_start; - if (sc->sc_nqueues > 1) + if (wm_is_using_multiqueue(sc)) ifp->if_transmit = wm_transmit; } ifp->if_watchdog = wm_watchdog; @@ -4042,7 +4044,7 @@ wm_reset(struct wm_softc *sc) /* Clear interrupt */ CSR_WRITE(sc, WMREG_IMC, 0xU); - if (sc->sc_nintrs > 1) { + if (wm_is_using_msix(sc)) { if (sc->sc_type != WM_T_82574) { CSR_WRITE(sc, WMREG_EIMC, 0xU); CSR_WRITE(sc, WMREG_EIAC, 0); @@ -4289,7 +4291,7 @@ wm_reset(struct wm_softc *sc) /* Clear any pending interrupt events. */ CSR_WRITE(sc, WMREG_IMC, 0xU); reg = CSR_READ(sc, WMREG_ICR); - if (sc->sc_nintrs > 1) { + if (wm_is_using_msix(sc)) { if (sc->sc_type != WM_T_82574) { CSR_WRITE(sc, WMREG_EIMC, 0xU); CSR_WRITE(sc, WMREG_EIAC, 0); @@ -4587,6 +4589,20 @@ wm_adjust_qnum(struct wm_softc *sc, int sc->sc_nqueues = ncpu; } +static inline bool +wm_is_using_msix(struct wm_softc *sc) +{ + + return (sc->sc_nintrs > 1); +} + +static inline bool +wm_is_using_multiqueue(struct wm_softc *sc) +{ + + return (sc->sc_nqueues > 1); +} + static int wm_softint_establish(struct wm_softc *sc, int qidx, int intr_idx) { @@ -4844,7 +4860,7 @@ wm_itrs_writereg(struct wm_softc *sc, st eitr |= EITR_CNT_INGR; CSR_WRITE(sc, WMREG_EITR(wmq->wmq_intr_idx), eitr); - } else if (sc->sc_type == WM_T_82574 && sc->sc_nintrs > 1) { + } else if (sc->sc_type == WM_T_82574 && wm_is_using_msix(sc)) { /* * 82574 has both ITR and EITR. SET EITR when we use * the multi queue function with MSI-X. @@ -5136,8 +5152,8 @@ wm_init_locked(struct ifnet *ifp) reg |= RXCSUM_IPV6OFL | RXCSUM_TUOFL; CSR_WRITE(sc, WMREG_RXCSUM, reg); - /* Set up MSI-X */ - if (sc->sc_nintrs > 1) { + /* Set registers about MSI-X */ + if (wm_is_using_msix(sc)) { uint32_t ivar; struct wm_queue *wmq; int qid, qintr_idx; @@ -5250,7 +5266,7 @@ wm_init_locked(struct ifnet *ifp) CSR_WRITE(sc, WMREG_IVAR_MISC, ivar); } - if (sc->sc_nqueues > 1) { + if (wm_is_using_multiqueue(sc)) { wm_init_rss(sc); /* @@ -5269,7 +5285,7 @@ wm_init_locked(struct ifnet *ifp) CSR_WRITE(sc, WMREG_IMC, 0xU); sc->sc_icr = ICR_TXDW | ICR_LSC | ICR_RXSEQ | ICR_RXDMT0 | ICR_RXO | ICR_RXT0; - if (sc->sc_nintrs > 1) { + if (wm_is_using_msix(sc)) { uint32_t mask; struct wm_queue *wmq; @@ -5537,7 +5553,7 @@ wm_stop_locked(struct ifnet *ifp, int di */ CSR_WRITE(sc, WMREG_IMC, 0xU); sc->sc_icr = 0; - if (sc->sc_nintrs > 1) { + if (wm_is_using_msix(sc)) { if (sc->sc_type != WM_T_82574) { CSR_WRITE(sc, WMREG_EIMC, 0xU); CSR_WRITE(sc, WMREG_EIAC, 0); @@ -6379,7 +6395,7 @@ wm_init_txrx_queues(struct wm_softc *sc) * polling mode is less than default value. * More tuning and AIM are required. */ - if (sc->sc_nqueues > 1) + if (wm_is_using_multiqueue(sc)) wmq->wmq_itr = 50; else wmq->wmq_itr = sc->sc_itr_init;
CVS commit: src/sys/dev/pci
Module Name:src Committed By: knakahara Date: Fri Mar 24 09:59:05 UTC 2017 Modified Files: src/sys/dev/pci: if_wm.c Log Message: add prototype. I have forgotten the fix by wm_softint_establish(). Thank you christos@n.o! To generate a diff of this commit: cvs rdiff -u -r1.500 -r1.501 src/sys/dev/pci/if_wm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.500 src/sys/dev/pci/if_wm.c:1.501 --- src/sys/dev/pci/if_wm.c:1.500 Wed Mar 22 08:44:41 2017 +++ src/sys/dev/pci/if_wm.c Fri Mar 24 09:59:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.500 2017/03/22 08:44:41 knakahara Exp $ */ +/* $NetBSD: if_wm.c,v 1.501 2017/03/24 09:59:05 knakahara Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.500 2017/03/22 08:44:41 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.501 2017/03/24 09:59:05 knakahara Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -675,6 +675,7 @@ static void wm_rxdrain(struct wm_rxqueue static void wm_rss_getkey(uint8_t *); static void wm_init_rss(struct wm_softc *); static void wm_adjust_qnum(struct wm_softc *, int); +static int wm_softint_establish(struct wm_softc *, int, int); static int wm_setup_legacy(struct wm_softc *); static int wm_setup_msix(struct wm_softc *); static int wm_init(struct ifnet *);
CVS commit: src/sys/net
Module Name:src Committed By: ozaki-r Date: Fri Mar 24 09:22:46 UTC 2017 Modified Files: src/sys/net: if_ethersubr.c Log Message: Remove KERNEL_LOCK for arpresolve in ether_output Because arpresolve should be already MP-safe. To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 src/sys/net/if_ethersubr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_ethersubr.c diff -u src/sys/net/if_ethersubr.c:1.239 src/sys/net/if_ethersubr.c:1.240 --- src/sys/net/if_ethersubr.c:1.239 Tue Feb 21 03:59:31 2017 +++ src/sys/net/if_ethersubr.c Fri Mar 24 09:22:46 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ethersubr.c,v 1.239 2017/02/21 03:59:31 ozaki-r Exp $ */ +/* $NetBSD: if_ethersubr.c,v 1.240 2017/03/24 09:22:46 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.239 2017/02/21 03:59:31 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.240 2017/03/24 09:22:46 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -246,23 +246,14 @@ ether_output(struct ifnet * const ifp0, #ifdef INET case AF_INET: -#ifndef NET_MPSAFE - KERNEL_LOCK(1, NULL); -#endif if (m->m_flags & M_BCAST) (void)memcpy(edst, etherbroadcastaddr, sizeof(edst)); else if (m->m_flags & M_MCAST) ETHER_MAP_IP_MULTICAST(&satocsin(dst)->sin_addr, edst); else if ((error = arpresolve(ifp, rt, m, dst, edst, sizeof(edst))) != 0) { -#ifndef NET_MPSAFE - KERNEL_UNLOCK_ONE(NULL); -#endif return error == EWOULDBLOCK ? 0 : error; } -#ifndef NET_MPSAFE - KERNEL_UNLOCK_ONE(NULL); -#endif /* If broadcasting on a simplex interface, loopback a copy */ if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) mcopy = m_copy(m, 0, (int)M_COPYALL);
CVS commit: src/sys/arch/i386/stand/lib
Module Name:src Committed By: nonaka Date: Fri Mar 24 08:50:17 UTC 2017 Modified Files: src/sys/arch/i386/stand/lib: exec.c Log Message: efiboot: fix calculation of the kernel size when loading modules. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/arch/i386/stand/lib/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/lib/exec.c diff -u src/sys/arch/i386/stand/lib/exec.c:1.67 src/sys/arch/i386/stand/lib/exec.c:1.68 --- src/sys/arch/i386/stand/lib/exec.c:1.67 Sun Mar 12 05:33:48 2017 +++ src/sys/arch/i386/stand/lib/exec.c Fri Mar 24 08:50:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.67 2017/03/12 05:33:48 nonaka Exp $ */ +/* $NetBSD: exec.c,v 1.68 2017/03/24 08:50:17 nonaka Exp $ */ /* * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -469,14 +469,16 @@ count_netbsd(const char *file, u_long *r { u_long marks[MARK_MAX]; char kdev[64]; - char base_path[64]; + char base_path[64] = "/"; struct stat st; boot_module_t *bm; u_long sz; int err, fd; + howto = AB_SILENT; + memset(marks, 0, sizeof(marks)); - if ((fd = loadfile(file, marks, COUNT_KERNEL)) == -1) + if ((fd = loadfile(file, marks, COUNT_KERNEL | LOAD_NOTE)) == -1) return -1; close(fd); marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) & @@ -490,13 +492,13 @@ count_netbsd(const char *file, u_long *r /* If the root fs type is unusual, load its module. */ if (fsmod != NULL) - module_add(__UNCONST(fsmod)); + module_add_common(fsmod, BM_TYPE_KMOD); for (bm = boot_modules; bm; bm = bm->bm_next) { fd = module_open(bm, 0, kdev, base_path, false); if (fd == -1) continue; - sz = (image_end + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); + sz = (sz + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); err = fstat(fd, &st); if (err == -1 || st.st_size == -1) { close(fd);
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: martin Date: Fri Mar 24 08:18:27 UTC 2017 Modified Files: src/tests/lib/libc/sys: t_mprotect.c Log Message: Do not toggle global security.pax.mprotect state in an attempt to activate it for the current process. It does not work and tests should not change global system state anyway. Instead: skip the test is pax.mprotect is not globally enabled. We could use a better check for this (querying the current processes pax flags), but unfortunately we don't have one. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/sys/t_mprotect.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_mprotect.c diff -u src/tests/lib/libc/sys/t_mprotect.c:1.4 src/tests/lib/libc/sys/t_mprotect.c:1.5 --- src/tests/lib/libc/sys/t_mprotect.c:1.4 Sat May 28 14:34:49 2016 +++ src/tests/lib/libc/sys/t_mprotect.c Fri Mar 24 08:18:27 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_mprotect.c,v 1.4 2016/05/28 14:34:49 christos Exp $ */ +/* $NetBSD: t_mprotect.c,v 1.5 2017/03/24 08:18:27 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_mprotect.c,v 1.4 2016/05/28 14:34:49 christos Exp $"); +__RCSID("$NetBSD: t_mprotect.c,v 1.5 2017/03/24 08:18:27 martin Exp $"); #include #include @@ -47,13 +47,10 @@ __RCSID("$NetBSD: t_mprotect.c,v 1.4 201 #include "../common/exec_prot.h" static long page = 0; -static int pax_global = -1; -static int pax_enabled = -1; static char path[] = "mmap"; static void sighandler(int); static bool paxinit(void); -static bool paxset(int, int); static void sighandler(int signo) @@ -65,6 +62,8 @@ static bool paxinit(void) { size_t len = sizeof(int); + int pax_global = -1; + int pax_enabled = -1; int rv; rv = sysctlbyname("security.pax.mprotect.global", @@ -76,31 +75,12 @@ paxinit(void) rv = sysctlbyname("security.pax.mprotect.enabled", &pax_enabled, &len, NULL, 0); - return rv == 0; -} - -static bool -paxset(int global, int enabled) -{ - size_t len = sizeof(int); - int rv; - - rv = sysctlbyname("security.pax.mprotect.global", - NULL, NULL, &global, len); - if (rv != 0) return false; - rv = sysctlbyname("security.pax.mprotect.enabled", - NULL, NULL, &enabled, len); - - if (rv != 0) - return false; - - return true; + return pax_global == 1 && pax_enabled == 1; } - ATF_TC_WITH_CLEANUP(mprotect_access); ATF_TC_HEAD(mprotect_access, tc) { @@ -188,11 +168,6 @@ ATF_TC_BODY(mprotect_exec, tc) break; } - if (!paxinit()) - return; - if (pax_enabled == 1 && pax_global == 1) - atf_tc_skip("PaX MPROTECT restrictions enabled"); - /* * Map a page read/write and copy a trivial assembly function inside. @@ -261,8 +236,8 @@ ATF_TC_BODY(mprotect_pax, tc) size_t i; int rv; - if (!paxinit() || !paxset(1, 1)) - return; + if (!paxinit()) + atf_tc_skip("PaX MPROTECT restrictions not enabled"); /* * As noted in the original PaX documentation [1], @@ -302,9 +277,6 @@ ATF_TC_BODY(mprotect_pax, tc) } out: - if (pax_global != -1 && pax_enabled != -1) - (void)paxset(pax_global, pax_enabled); - if (str != NULL) atf_tc_fail("%s", str); }