CVS commit: src/sys/dev/usb

2020-12-26 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Dec 26 22:15:37 UTC 2020

Modified Files:
src/sys/dev/usb: usb_quirks.c

Log Message:
Add WayTech USB to Serial device to quirks routines, in order to prevent
uhid(4) from attaching and leave it to ugen(4) so libusb can query it.

It is used by some UPS peripherals for their management, especially the
ones from Infosec and Megatec.

Tested with Infosec E3 UPS through ups-nut-usb and `blazer_usb' driver
using the following configuration (ups.conf):

[infosec]
driver = blazer_usb
port = auto
vendorid = 0665
productid = 5161

Make sure the associated /dev/ugenXXX is accessible to `nut' user if you
use ups-nut.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/dev/usb/usb_quirks.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/usb/usb_quirks.c
diff -u src/sys/dev/usb/usb_quirks.c:1.95 src/sys/dev/usb/usb_quirks.c:1.96
--- src/sys/dev/usb/usb_quirks.c:1.95	Sat Mar 14 03:01:36 2020
+++ src/sys/dev/usb/usb_quirks.c	Sat Dec 26 22:15:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_quirks.c,v 1.95 2020/03/14 03:01:36 christos Exp $	*/
+/*	$NetBSD: usb_quirks.c,v 1.96 2020/12/26 22:15:37 jym Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.95 2020/03/14 03:01:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.96 2020/12/26 22:15:37 jym Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -206,6 +206,8 @@ Static const struct usbd_quirk_entry {
 	{ UQ_HID_IGNORE, NULL }},
  { USB_VENDOR_XRITE,		ANY,	ANY,
 	{ UQ_HID_IGNORE, NULL }},
+ { USB_VENDOR_WAYTECH,		USB_PRODUCT_WAYTECH_USB2SERIAL,		ANY,
+	{ UQ_HID_IGNORE, NULL }},
  { USB_VENDOR_KYE,		USB_PRODUCT_KYE_NICHE,			0x100,
 	{ UQ_NO_SET_PROTO, NULL }},
  { USB_VENDOR_INSIDEOUT,	USB_PRODUCT_INSIDEOUT_EDGEPORT4,	0x094,



CVS commit: src/sys/dev/usb

2020-12-26 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Dec 26 22:09:18 UTC 2020

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add WayTech Development USB to Serial product.

It is used by some UPS devices, notably Infosec and Megatec.

The vendor ID (0x0665) is known differently from various mainstream OSes;
but it is officially registered by USB-IF as `WayTech Development, Inc.'. So
be it.


To generate a diff of this commit:
cvs rdiff -u -r1.786 -r1.787 src/sys/dev/usb/usbdevs

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/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.786 src/sys/dev/usb/usbdevs:1.787
--- src/sys/dev/usb/usbdevs:1.786	Mon Sep  7 06:32:13 2020
+++ src/sys/dev/usb/usbdevs	Sat Dec 26 22:09:18 2020
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.786 2020/09/07 06:32:13 ryoon Exp $
+$NetBSD: usbdevs,v 1.787 2020/12/26 22:09:18 jym Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -250,6 +250,7 @@ vendor AVISION		0x0638	Avision
 vendor TEAC		0x0644	TEAC
 vendor SGI		0x065e	Silicon Graphics
 vendor SANWASUPPLY	0x0663	Sanwa Supply
+vendor WAYTECH		0x0665	WayTech Development, Inc.
 vendor LINKSYS		0x066b	Linksys
 vendor ACERSA		0x066e	Acer Semiconductor America
 vendor SIGMATEL		0x066f	Sigmatel
@@ -2231,6 +2232,9 @@ product MCT ML_4500		0x0302	ML-4500
 /* MediaGear products */
 product MEDIAGEAR READER9IN1	0x5003	USB2.0 9 in 1 Reader
 
+/* WayTech Development, Inc. products */
+product WAYTECH USB2SERIAL	0x5161	USB to Serial
+
 /* Meinberg Funkuhren products */
 product MEINBERG USB5131	0x0301	USB 5131 DCF77 - Radio Clock
 



CVS commit: src/sys/arch/x86/x86

2015-10-04 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Oct  4 21:08:30 UTC 2015

Modified Files:
src/sys/arch/x86/x86: cpu_ucode_intel.c

Log Message:
Cache CPU index in the non-preemptible part otherwise it can be
unreliable (and report a CPU as patched while it was not).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/x86/cpu_ucode_intel.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/cpu_ucode_intel.c
diff -u src/sys/arch/x86/x86/cpu_ucode_intel.c:1.9 src/sys/arch/x86/x86/cpu_ucode_intel.c:1.10
--- src/sys/arch/x86/x86/cpu_ucode_intel.c:1.9	Sun Oct  4 17:52:50 2015
+++ src/sys/arch/x86/x86/cpu_ucode_intel.c	Sun Oct  4 21:08:30 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode_intel.c,v 1.9 2015/10/04 17:52:50 mrg Exp $ */
+/* $NetBSD: cpu_ucode_intel.c,v 1.10 2015/10/04 21:08:30 jym Exp $ */
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.9 2015/10/04 17:52:50 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.10 2015/10/04 21:08:30 jym Exp $");
 
 #include "opt_xen.h"
 #include "opt_cpu_ucode.h"
@@ -109,7 +109,7 @@ int
 cpu_ucode_intel_apply(struct cpu_ucode_softc *sc, int cpuno)
 {
 	uint32_t ucodetarget, oucodeversion, nucodeversion;
-	int platformid;
+	int platformid, cpuid;
 	struct intel1_ucode_header *uh;
 	void *uha;
 	size_t newbufsize = 0;
@@ -147,6 +147,7 @@ cpu_ucode_intel_apply(struct cpu_ucode_s
 	}
 	wrmsr(MSR_BIOS_UPDT_TRIG, (uintptr_t)uh + 48);
 	intel_getcurrentucode(&nucodeversion, &platformid);
+	cpuid = curcpu()->ci_index;
 
 	kpreempt_enable();
 
@@ -155,7 +156,7 @@ cpu_ucode_intel_apply(struct cpu_ucode_s
 		goto out;
 	}
 
-	printf("cpu %d: ucode 0x%x->0x%x\n", curcpu()->ci_index,
+	printf("cpu %d: ucode 0x%x->0x%x\n", cpuid,
 	   oucodeversion, nucodeversion);
 out:
 	if (newbufsize != 0)



CVS commit: src/crypto/external/bsd/openssh/dist

2013-10-06 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Oct  6 17:25:34 UTC 2013

Modified Files:
src/crypto/external/bsd/openssh/dist: ssh_config

Log Message:
Enable VerifyHostKeyDNS (SSHFP records verification) from DNS for hosts
under NetBSD.org domain.

Multiple TNF hosts have an up-to-date SSHFP record inside the DNS.
This offers a second channel verification for host key fingerprints
(weaker than known_hosts, but spoofing a host on first connect would
also require DNS forgery).

This can provide a trusted second channel (like DANE TLSA records) once
DNSSEC gets more widely used, but for now it is purely informational.

No regression expected, except that the ssh client will print a message
upon first connect to confirm/infirm that it got a correct SSHFP record
from DNS.

Only done for NetBSD.org domain, SSHFP are sadly more an exception than
the rule.

Notified on netbsd-users@, no objection after a week -- committed.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/crypto/external/bsd/openssh/dist/ssh_config

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/crypto/external/bsd/openssh/dist/ssh_config
diff -u src/crypto/external/bsd/openssh/dist/ssh_config:1.4 src/crypto/external/bsd/openssh/dist/ssh_config:1.5
--- src/crypto/external/bsd/openssh/dist/ssh_config:1.4	Sun Nov 21 18:29:49 2010
+++ src/crypto/external/bsd/openssh/dist/ssh_config	Sun Oct  6 17:25:34 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: ssh_config,v 1.4 2010/11/21 18:29:49 adam Exp $
+#	$NetBSD: ssh_config,v 1.5 2013/10/06 17:25:34 jym Exp $
 #	$OpenBSD: ssh_config,v 1.26 2010/01/11 01:39:46 dtucker Exp $
 
 # This is the ssh client system-wide configuration file.  See
@@ -48,3 +48,7 @@
 #   ProxyCommand ssh -q -W %h:%p gateway.example.com
 # If you use xorg from pkgsrc then uncomment the following line.
 #   XAuthLocation /usr/pkg/bin/xauth
+
+# NetBSD.org DNS provides SSHFP records - use them when possible
+Host *.netbsd.org *.NetBSD.org
+VerifyHostKeyDNS ask



CVS commit: src/sys/secmodel

2013-01-27 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Jan 28 00:51:30 UTC 2013

Modified Files:
src/sys/secmodel/extensions: secmodel_extensions.c
src/sys/secmodel/securelevel: secmodel_securelevel.c

Log Message:
Re-instate backwards compatible security.models.bsd44.{curtain,securelevel}.

They were mistakenly removed when curtain and securelevel moved to
secmodel_extensions(9).

Reported by tls@ on tech-security@.

XXX will ask for pull-up for -6.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/secmodel/extensions/secmodel_extensions.c
cvs rdiff -u -r1.28 -r1.29 \
src/sys/secmodel/securelevel/secmodel_securelevel.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/secmodel/extensions/secmodel_extensions.c
diff -u src/sys/secmodel/extensions/secmodel_extensions.c:1.3 src/sys/secmodel/extensions/secmodel_extensions.c:1.4
--- src/sys/secmodel/extensions/secmodel_extensions.c:1.3	Tue Mar 13 18:41:01 2012
+++ src/sys/secmodel/extensions/secmodel_extensions.c	Mon Jan 28 00:51:29 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_extensions.c,v 1.3 2012/03/13 18:41:01 elad Exp $ */
+/* $NetBSD: secmodel_extensions.c,v 1.4 2013/01/28 00:51:29 jym Exp $ */
 /*-
  * Copyright (c) 2011 Elad Efrat 
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_extensions.c,v 1.3 2012/03/13 18:41:01 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_extensions.c,v 1.4 2013/01/28 00:51:29 jym Exp $");
 
 #include 
 #include 
@@ -73,7 +73,7 @@ static int secmodel_extensions_network_c
 static void
 sysctl_security_extensions_setup(struct sysctllog **clog)
 {
-	const struct sysctlnode *rnode;
+	const struct sysctlnode *rnode, *rnode2;
 
 	sysctl_createv(clog, 0, NULL, &rnode,
 		   CTLFLAG_PERMANENT,
@@ -87,6 +87,23 @@ sysctl_security_extensions_setup(struct 
 		   NULL, 0, NULL, 0,
 		   CTL_CREATE, CTL_EOL);
 
+	/* Compatibility: security.models.bsd44 */
+	rnode2 = rnode;
+	sysctl_createv(clog, 0, &rnode2, &rnode2,
+		   CTLFLAG_PERMANENT,
+		   CTLTYPE_NODE, "bsd44", NULL,
+		   NULL, 0, NULL, 0,
+		   CTL_CREATE, CTL_EOL);
+
+/* Compatibility: security.models.bsd44.curtain */
+	sysctl_createv(clog, 0, &rnode2, NULL,
+		   CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+		   CTLTYPE_INT, "curtain",
+		   SYSCTL_DESCR("Curtain information about objects to "\
+		   		"users not owning them."),
+		   sysctl_extensions_curtain_handler, 0, &curtain, 0,
+		   CTL_CREATE, CTL_EOL);
+
 	sysctl_createv(clog, 0, &rnode, &rnode,
 		   CTLFLAG_PERMANENT,
 		   CTLTYPE_NODE, "extensions", NULL,

Index: src/sys/secmodel/securelevel/secmodel_securelevel.c
diff -u src/sys/secmodel/securelevel/secmodel_securelevel.c:1.28 src/sys/secmodel/securelevel/secmodel_securelevel.c:1.29
--- src/sys/secmodel/securelevel/secmodel_securelevel.c:1.28	Wed Jun 27 10:15:25 2012
+++ src/sys/secmodel/securelevel/secmodel_securelevel.c	Mon Jan 28 00:51:30 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_securelevel.c,v 1.28 2012/06/27 10:15:25 cheusov Exp $ */
+/* $NetBSD: secmodel_securelevel.c,v 1.29 2013/01/28 00:51:30 jym Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.28 2012/06/27 10:15:25 cheusov Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.29 2013/01/28 00:51:30 jym Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_insecure.h"
@@ -95,7 +95,7 @@ secmodel_securelevel_sysctl(SYSCTLFN_ARG
 void
 sysctl_security_securelevel_setup(struct sysctllog **clog)
 {
-	const struct sysctlnode *rnode;
+	const struct sysctlnode *rnode, *rnode2;
 
 	sysctl_createv(clog, 0, NULL, &rnode,
 		   CTLFLAG_PERMANENT,
@@ -109,6 +109,22 @@ sysctl_security_securelevel_setup(struct
 		   NULL, 0, NULL, 0,
 		   CTL_CREATE, CTL_EOL);
 
+	/* Compatibility: security.models.bsd44 */
+	rnode2 = rnode;
+	sysctl_createv(clog, 0, &rnode2, &rnode2,
+		   CTLFLAG_PERMANENT,
+		   CTLTYPE_NODE, "bsd44", NULL,
+		   NULL, 0, NULL, 0,
+		   CTL_CREATE, CTL_EOL);
+
+/* Compatibility: security.models.bsd44.securelevel */
+	sysctl_createv(clog, 0, &rnode2, NULL,
+		   CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+		   CTLTYPE_INT, "securelevel",
+		   SYSCTL_DESCR("System security level"),
+		   secmodel_securelevel_sysctl, 0, NULL, 0,
+		   CTL_CREATE, CTL_EOL);
+
 	sysctl_createv(clog, 0, &rnode, &rnode,
 		   CTLFLAG_PERMANENT,
 		   CTLTYPE_NODE, "securelevel", NULL,



CVS commit: src/doc

2012-08-08 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Wed Aug  8 23:24:40 UTC 2012

Modified Files:
src/doc: CHANGES.prev

Log Message:
Document virtio(4) addition in CHANGES. Noticed by Emmanuel Kasper on
tech-kern@.

virtio(4) is the VirtIO protocol used by KVM to drastically improve
the performance of virtualized peripherals.

virtio(4) originally written by minoura@; imported in src by hannken@
around 2011-10-30.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/doc/CHANGES.prev

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES.prev
diff -u src/doc/CHANGES.prev:1.109 src/doc/CHANGES.prev:1.110
--- src/doc/CHANGES.prev:1.109	Wed Jun 20 07:42:27 2012
+++ src/doc/CHANGES.prev	Wed Aug  8 23:24:40 2012
@@ -1,4 +1,4 @@
-LIST OF CHANGES FROM PREVIOUS RELEASES:			<$Revision: 1.109 $>
+LIST OF CHANGES FROM PREVIOUS RELEASES:			<$Revision: 1.110 $>
 
 
 Changes from 386bsd 0.1 + patchkit 0.2.2 to NetBSD 0.8:
@@ -11062,6 +11062,8 @@ Changes from NetBSD 5.0 to NetBSD 6.0:
 	powerpc: Switch to GDB 7.3.1.  [mrg 20111024]
 	efa(4): Add driver for ELBOX FastATA 1200. [rkujawa 20111028]
 	postfix(1): Import version 2.8.6 [tron 20111028]
+	virtio(4): Add virtio driver. Speeds up I/O under KVM platform.
+		[hannken 20111030]
 	zoneinfo: Import tzdata2011n. [apb 2002]
 	tre: Incorporate library. Adds agrep. This library provides
 		regcomp/regexec/regerror/regfree as a binary compatible



CVS commit: src/sys/arch/xen/xen

2012-07-22 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Jul 23 01:31:02 UTC 2012

Modified Files:
src/sys/arch/xen/xen: xbdback_xenbus.c

Log Message:
Add more ratechecks to avoid console spam when the backend gets a
stream of errors.

Remove the unused xbdi_errps (error per second) variable. Errors should
rather be tracked in absolute, with a threshold that forces a time penalty
to the xbdback thread when frontend goes nuts.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/xen/xen/xbdback_xenbus.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/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.56 src/sys/arch/xen/xen/xbdback_xenbus.c:1.57
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.56	Wed May 23 10:01:51 2012
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Mon Jul 23 01:31:01 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.56 2012/05/23 10:01:51 cegger Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.57 2012/07/23 01:31:01 jym Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.56 2012/05/23 10:01:51 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.57 2012/07/23 01:31:01 jym Exp $");
 
 #include 
 #include 
@@ -198,7 +198,6 @@ struct xbdback_instance {
 	/* other state */
 	int xbdi_same_page; /* are we merging two segments on the same page? */
 	uint xbdi_pendingreqs; /* number of I/O in fly */
-	int xbdi_errps; /* errors per second */
 	struct timeval xbdi_lasterr_time;/* error time tracking */
 #ifdef DEBUG
 	struct timeval xbdi_lastfragio_time; /* fragmented I/O tracking */
@@ -1460,8 +1459,11 @@ xbdback_co_io_gotfrag2(struct xbdback_in
 	seg_size = this_ls - this_fs + 1;
 
 	if (seg_size < 0) {
-		printf("xbdback_io domain %d: negative-size request (%d %d)\n",
-		   xbdi->xbdi_domid, this_ls, this_fs);
+		if (ratecheck(&xbdi->xbdi_lasterr_time, &xbdback_err_intvl)) {
+			printf("xbdback_io domain %d: negative-size request "
+			"(%d %d)\n",
+			xbdi->xbdi_domid, this_ls, this_fs);
+		}
 		xbdback_io_error(xbdi->xbdi_io, EINVAL);
 		xbdi->xbdi_io = NULL;
 		xbdi->xbdi_cont = xbdback_co_main_incr;
@@ -1775,7 +1777,9 @@ xbdback_map_shm(struct xbdback_io *xbd_i
 		xbdi->xbdi_cont = xbdback_co_wait_shm_callback;
 		return NULL;
 	default:
-		printf("xbdback_map_shm: xen_shm error %d ", error);
+		if (ratecheck(&xbdi->xbdi_lasterr_time, &xbdback_err_intvl)) {
+			printf("xbdback_map_shm: xen_shm error %d ", error);
+		}
 		xbdback_io_error(xbdi->xbdi_io, error);
 		xbdi->xbdi_io = NULL;
 		xbdi->xbdi_cont = xbdi->xbdi_cont_aux;



CVS commit: src/sys/arch/xen/xen

2012-07-22 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Jul 22 19:30:19 UTC 2012

Modified Files:
src/sys/arch/xen/xen: xen_machdep.c

Log Message:
Don't leak stack content when reading the Xen suspend value.

XXX pull-up to -6.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/xen/xen/xen_machdep.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/xen/xen/xen_machdep.c
diff -u src/sys/arch/xen/xen/xen_machdep.c:1.11 src/sys/arch/xen/xen/xen_machdep.c:1.12
--- src/sys/arch/xen/xen/xen_machdep.c:1.11	Sat Jun 30 22:50:37 2012
+++ src/sys/arch/xen/xen/xen_machdep.c	Sun Jul 22 19:30:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_machdep.c,v 1.11 2012/06/30 22:50:37 jym Exp $	*/
+/*	$NetBSD: xen_machdep.c,v 1.12 2012/07/22 19:30:19 jym Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.11 2012/06/30 22:50:37 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.12 2012/07/22 19:30:19 jym Exp $");
 
 #include "opt_xen.h"
 
@@ -247,7 +247,7 @@ sysctl_xen_suspend_setup(void)
 	CTL_CREATE, CTL_EOL);
 
 	sysctl_createv(NULL, 0, &node, &node,
-	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+	CTLFLAG_PERMANENT | CTLFLAG_READWRITE | CTLFLAG_IMMEDIATE,
 	CTLTYPE_INT, "suspend",
 	SYSCTL_DESCR("Suspend/save current Xen domain"),
 	sysctl_xen_suspend, 0, NULL, 0,
@@ -257,11 +257,10 @@ sysctl_xen_suspend_setup(void)
 static int
 sysctl_xen_suspend(SYSCTLFN_ARGS)
 {
-	int error, t;
+	int error;
 	struct sysctlnode node;
 
 	node = *rnode;
-	node.sysctl_data = &t;
 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
 
 	if (error || newp == NULL)



CVS commit: src

2012-07-02 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Jul  2 21:10:31 UTC 2012

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile uvm.9

Log Message:
Document atop(9), ptoa(9), round_page(9) and trunc_page(9).


To generate a diff of this commit:
cvs rdiff -u -r1.1767 -r1.1768 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.365 -r1.366 src/share/man/man9/Makefile
cvs rdiff -u -r1.106 -r1.107 src/share/man/man9/uvm.9

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/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1767 src/distrib/sets/lists/comp/mi:1.1768
--- src/distrib/sets/lists/comp/mi:1.1767	Wed Jun 27 22:18:06 2012
+++ src/distrib/sets/lists/comp/mi	Mon Jul  2 21:10:30 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1767 2012/06/27 22:18:06 jdf Exp $
+#	$NetBSD: mi,v 1.1768 2012/07/02 21:10:30 jym Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -9709,6 +9709,7 @@
 ./usr/share/man/cat9/VOP_WHITEOUT.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/VOP_WRITE.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/VREF.0			comp-obsolete		obsolete
+./usr/share/man/cat9/atop.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/accept_filt_add.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/accept_filt_del.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/accept_filt_generic_mod_event.0	comp-sys-catman		.cat
@@ -10617,6 +10618,7 @@
 ./usr/share/man/cat9/pserialize_read_enter.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/pserialize_read_exit.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/psignal.0			comp-sys-catman		.cat
+./usr/share/man/cat9/ptoa.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/putiobuf.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/putter.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/radio.0			comp-sys-catman		.cat
@@ -10639,6 +10641,7 @@
 ./usr/share/man/cat9/rnd_attach_source.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/rnd_detach_source.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/rnd_extract_data.0		comp-sys-catman		.cat
+./usr/share/man/cat9/round_page.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/rounddown.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/roundup.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/roundup2.0			comp-sys-catman		.cat
@@ -10833,6 +10836,7 @@
 ./usr/share/man/cat9/tprintf_open.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/transferlockers.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/trapsignal.0		comp-sys-catman		.cat
+./usr/share/man/cat9/trunc_page.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/tsleep.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/ttyldisc_add.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/ttyldisc_lookup.0		comp-sys-catman		.cat
@@ -15983,6 +15987,7 @@
 ./usr/share/man/html9/VOP_WHITEOUT.html		comp-sys-htmlman	html
 ./usr/share/man/html9/VOP_WRITE.html		comp-sys-htmlman	html
 ./usr/share/man/html9/VREF.html			comp-obsolete	obsolete
+./usr/share/man/html9/atop.html			comp-sys-htmlman	html
 ./usr/share/man/html9/accept_filt_add.html	comp-sys-htmlman	html
 ./usr/share/man/html9/accept_filt_del.html	comp-sys-htmlman	html
 ./usr/share/man/html9/accept_filt_generic_mod_event.html	comp-sys-htmlman	html
@@ -16852,6 +16857,7 @@
 ./usr/share/man/html9/pserialize_read_enter.html	comp-sys-htmlman	html
 ./usr/share/man/html9/pserialize_read_exit.html	comp-sys-htmlman	html
 ./usr/share/man/html9/psignal.html		comp-sys-htmlman	html
+./usr/share/man/html9/ptoa.html			comp-sys-htmlman	html
 ./usr/share/man/html9/putiobuf.html		comp-sys-htmlman	html
 ./usr/share/man/html9/putter.html		comp-sys-htmlman	html
 ./usr/share/man/html9/radio.html		comp-sys-htmlman	html
@@ -16873,6 +16879,7 @@
 ./usr/share/man/html9/rnd_attach_source.html	comp-sys-htmlman	html
 ./usr/share/man/html9/rnd_detach_source.html	comp-sys-htmlman	html
 ./usr/share/man/html9/rnd_extract_data.html	comp-sys-htmlman	html
+./usr/share/man/html9/round_page.html		comp-sys-htmlman	html
 ./usr/share/man/html9/rounddown.html		comp-sys-htmlman	html
 ./usr/share/man/html9/roundup.html		comp-sys-htmlman	html
 ./usr/share/man/html9/roundup2.html		comp-sys-htmlman	html
@@ -17054,6 +17061,7 @@
 ./usr/share/man/html9/tprintf_open.html		comp-sys-htmlman	html
 ./usr/share/man/html9/transferlockers.html	comp-sys-htmlman	html
 ./usr/share/man/html9/trapsignal.html		comp-sys-htmlman	html
+./usr/share/man/html9/trunc_page.html		comp-sys-htmlman	html
 ./usr/share/man/html9/tsleep.html		comp-sys-htmlman	html
 ./usr/share/man/html9/ttyldisc_add.html		comp-sys-htmlman	html
 ./usr/share/man/html9/ttyldisc_lookup.html	comp-sys-htmlman	html
@@ -22364,6 +22372,7 @@
 ./usr/share/man/man9/VOP_WHITEOUT.9		comp-sys-man		.man
 ./usr/share/man/man9/VOP_WRITE.9		comp-sys-man		.man
 ./usr/share/man/man9/VREF.9			comp-obsolete		obsolete
+./usr/share/man/man9/atop.9			comp-sys-man		.man
 ./usr/share/man/man9/accept_filt_add.9		comp-sys-man		.man
 ./usr/sh

CVS commit: src/sys/arch/xen

2012-06-30 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Jun 30 23:36:20 UTC 2012

Modified Files:
src/sys/arch/xen/x86: xen_bus_dma.c
src/sys/arch/xen/xen: balloon.c if_xennet_xenbus.c xengnt.c
xennetback_xenbus.c

Log Message:
Use setter to set xenguest_handles.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/xen/x86/xen_bus_dma.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/xen/xen/balloon.c
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/xen/xen/if_xennet_xenbus.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/xen/xen/xengnt.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/xen/xen/xennetback_xenbus.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/xen/x86/xen_bus_dma.c
diff -u src/sys/arch/xen/x86/xen_bus_dma.c:1.25 src/sys/arch/xen/x86/xen_bus_dma.c:1.26
--- src/sys/arch/xen/x86/xen_bus_dma.c:1.25	Sat Jun 30 22:50:37 2012
+++ src/sys/arch/xen/x86/xen_bus_dma.c	Sat Jun 30 23:36:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_bus_dma.c,v 1.25 2012/06/30 22:50:37 jym Exp $	*/
+/*	$NetBSD: xen_bus_dma.c,v 1.26 2012/06/30 23:36:20 jym Exp $	*/
 /*	NetBSD bus_dma.c,v 1.21 2005/04/16 07:53:35 yamt Exp */
 
 /*-
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.25 2012/06/30 22:50:37 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.26 2012/06/30 23:36:20 jym Exp $");
 
 #include 
 #include 
@@ -91,7 +91,7 @@ _xen_alloc_contig(bus_size_t size, bus_s
 		pa = VM_PAGE_TO_PHYS(pg);
 		mfn = xpmap_ptom(pa) >> PAGE_SHIFT;
 		xpmap_ptom_unmap(pa);
-		xenguest_handle(res.extent_start) = &mfn;
+		set_xen_guest_handle(res.extent_start, &mfn);
 		res.nr_extents = 1;
 		res.extent_order = 0;
 		res.address_bits = 0;
@@ -110,7 +110,7 @@ _xen_alloc_contig(bus_size_t size, bus_s
 		}
 	}
 	/* Get the new contiguous memory extent */
-	xenguest_handle(res.extent_start) = &mfn;
+	set_xen_guest_handle(res.extent_start, &mfn);
 	res.nr_extents = 1;
 	res.extent_order = order;
 	res.address_bits = get_order(high) + PAGE_SHIFT;
@@ -163,7 +163,7 @@ failed:
 	s = splvm();
 	for (pg = mlistp->tqh_first; pg != NULL; pg = pgnext) {
 		pgnext = pg->pageq.queue.tqe_next;
-		xenguest_handle(res.extent_start) = &mfn;
+		set_xen_guest_handle(res.extent_start, &mfn);
 		res.nr_extents = 1;
 		res.extent_order = 0;
 		res.address_bits = 32;

Index: src/sys/arch/xen/xen/balloon.c
diff -u src/sys/arch/xen/xen/balloon.c:1.15 src/sys/arch/xen/xen/balloon.c:1.16
--- src/sys/arch/xen/xen/balloon.c:1.15	Sat Jun 30 22:50:37 2012
+++ src/sys/arch/xen/xen/balloon.c	Sat Jun 30 23:36:20 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: balloon.c,v 1.15 2012/06/30 22:50:37 jym Exp $ */
+/* $NetBSD: balloon.c,v 1.16 2012/06/30 23:36:20 jym Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
 #define BALLOONDEBUG 0
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.15 2012/06/30 22:50:37 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.16 2012/06/30 23:36:20 jym Exp $");
 
 #include 
 #include 
@@ -407,7 +407,7 @@ balloon_inflate(struct balloon_xenbus_so
 	}
 
 	/* Hand over pages to Hypervisor */
-	xenguest_handle(reservation.extent_start) = mfn_list;
+	set_xen_guest_handle(reservation.extent_start, mfn_list);
 	reservation.nr_extents = rpages;
 
 	s = splvm();
@@ -471,7 +471,7 @@ balloon_deflate(struct balloon_xenbus_so
 	}
 
 	/* reclaim pages from balloon */
-	xenguest_handle(reservation.extent_start) = mfn_list;
+	set_xen_guest_handle(reservation.extent_start, mfn_list);
 	reservation.nr_extents = tpages;
 
 	s = splvm();

Index: src/sys/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.61 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.62
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.61	Sat Jun 30 22:50:37 2012
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Sat Jun 30 23:36:20 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.61 2012/06/30 22:50:37 jym Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.62 2012/06/30 23:36:20 jym Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -85,7 +85,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.61 2012/06/30 22:50:37 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.62 2012/06/30 23:36:20 jym Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -754,7 +754,7 @@ out_loop:
 		xpq_flush_queue();
 		splx(s);
 		/* now decrease reservation */
-		xenguest_handle(reservation.extent_start) = xennet_pages;
+		set_xen_guest_handle(reservation.extent_start, xennet_pages);
 		reservation.nr_extents = i;
 		reservation.extent_order = 0;
 		reservation.address_bits = 0;
@@ -820,7 +820,8 @@ xennet_free_rx_buffer(struct xennet_xenb
 	 * transfer not complete, we lost the page.
 	 * Get one from hypervisor
 	 */
-	xenguest_handle(xenres.extent_start) = &pfn;
+	set_xen_guest_handle(
+	xenres.extent_start,

CVS commit: src/sys/arch

2012-06-30 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Jun 30 22:50:37 UTC 2012

Modified Files:
src/sys/arch/amd64/include: pmap.h
src/sys/arch/xen/include: xenpmap.h
src/sys/arch/xen/x86: x86_xpmap.c xen_bus_dma.c
src/sys/arch/xen/xen: balloon.c if_xennet_xenbus.c xen_machdep.c
xennetback_xenbus.c

Log Message:
Extend the xpmap API, as described in [1]. This change is mechanical and
avoids exposing the MD phys_to_machine/machine_to_phys tables directly.
Added:

- xpmap_ptom handles PFN (pseudo physical) to MFN (machine frame number)
translations, and is under control of the domain.
- xpmap_mtop is its counterpart (MFN to PFN), and is under control of
hypervisor.

xpmap_ptom_map()  map a pseudo-phys address to a machine address
xpmap_ptom_unmap()unmap a pseudo-phys address (invalidation)
xpmap_ptom_isvalid()  check for pseudo-phys address validity

The parameters are physical/machine addresses, like bus_dma/bus_space(9).
As x86 MFNs are tracked by u_long (Xen's choice) while machine addresses
can be 64 bits entities (PAE), use ptoa() to avoid truncation when bit
shifting by PAGE_SHIFT.

I kept the same namespace (xpmap_) to avoid code churn.

[1] http://mail-index.netbsd.org/port-xen/2009/05/09/msg004951.html

XXX will document ptoa/atop/trunc_page separately.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/xen/include/xenpmap.h
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/xen/x86/x86_xpmap.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/xen/x86/xen_bus_dma.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/xen/xen/balloon.c
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/xen/xen/if_xennet_xenbus.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/xen/xen/xen_machdep.c
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/xen/xen/xennetback_xenbus.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/amd64/include/pmap.h
diff -u src/sys/arch/amd64/include/pmap.h:1.33 src/sys/arch/amd64/include/pmap.h:1.34
--- src/sys/arch/amd64/include/pmap.h:1.33	Mon Jun 11 15:18:26 2012
+++ src/sys/arch/amd64/include/pmap.h	Sat Jun 30 22:50:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.33 2012/06/11 15:18:26 chs Exp $	*/
+/*	$NetBSD: pmap.h,v 1.34 2012/06/30 22:50:36 jym Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -258,6 +258,7 @@ pmap_pte2pa(pt_entry_t pte)
 {
 	return xpmap_mtop_masked(pte & PG_FRAME);
 }
+
 static __inline void
 pmap_pte_set(pt_entry_t *pte, pt_entry_t npte)
 {

Index: src/sys/arch/xen/include/xenpmap.h
diff -u src/sys/arch/xen/include/xenpmap.h:1.36 src/sys/arch/xen/include/xenpmap.h:1.37
--- src/sys/arch/xen/include/xenpmap.h:1.36	Wed Jun 27 00:37:09 2012
+++ src/sys/arch/xen/include/xenpmap.h	Sat Jun 30 22:50:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: xenpmap.h,v 1.36 2012/06/27 00:37:09 jym Exp $	*/
+/*	$NetBSD: xenpmap.h,v 1.37 2012/06/30 22:50:36 jym Exp $	*/
 
 /*
  *
@@ -76,9 +76,6 @@ void xen_kpm_sync(struct pmap *, int);
 
 extern unsigned long *xpmap_phys_to_machine_mapping;
 
-#define mfn_to_pfn(mfn) (machine_to_phys_mapping[(mfn)])
-#define pfn_to_mfn(pfn) (xpmap_phys_to_machine_mapping[(pfn)])
-
 static __inline paddr_t
 xpmap_mtop_masked(paddr_t mpa)
 {
@@ -95,7 +92,8 @@ xpmap_mtop(paddr_t mpa)
 static __inline paddr_t
 xpmap_ptom_masked(paddr_t ppa)
 {
-	return (((paddr_t)xpmap_phys_to_machine_mapping[(ppa) >> PAGE_SHIFT])
+	return (
+	(paddr_t)xpmap_phys_to_machine_mapping[ppa >> PAGE_SHIFT]
 	<< PAGE_SHIFT);
 }
 
@@ -105,6 +103,26 @@ xpmap_ptom(paddr_t ppa)
 	return (xpmap_ptom_masked(ppa) | (ppa & ~PG_FRAME));
 }
 
+static __inline void
+xpmap_ptom_map(paddr_t ppa, paddr_t mpa)
+{
+	xpmap_phys_to_machine_mapping[ppa >> PAGE_SHIFT] = mpa >> PAGE_SHIFT;
+}
+
+static __inline void
+xpmap_ptom_unmap(paddr_t ppa)
+{
+	xpmap_phys_to_machine_mapping[ppa >> PAGE_SHIFT] = INVALID_P2M_ENTRY;
+}
+
+static __inline bool
+xpmap_ptom_isvalid(paddr_t ppa)
+{
+	return (
+	xpmap_phys_to_machine_mapping[ppa >> PAGE_SHIFT]
+	!= INVALID_P2M_ENTRY);
+}
+
 static inline void
 MULTI_update_va_mapping(
 	multicall_entry_t *mcl, vaddr_t va,

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.45 src/sys/arch/xen/x86/x86_xpmap.c:1.46
--- src/sys/arch/xen/x86/x86_xpmap.c:1.45	Wed Jun 27 00:37:10 2012
+++ src/sys/arch/xen/x86/x86_xpmap.c	Sat Jun 30 22:50:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.45 2012/06/27 00:37:10 jym Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.46 2012/06/30 22:50:37 jym Exp $	*/
 
 /*
  * Copyright (c) 2006 Mathieu Ropert 
@@ -69,7 +69,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.45 2012/06/27 00:37:10 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.46 2012/06/30 22:50:37 jym Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -1092,7 +1092,7 @@ xen_set_user_pgd(paddr_t page

CVS commit: src/sys/arch

2012-06-26 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Wed Jun 27 00:37:10 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/i386/conf: XEN3_DOMU
src/sys/arch/i386/i386: locore.S machdep.c
src/sys/arch/xen/conf: files.xen
src/sys/arch/xen/include: xenpmap.h
src/sys/arch/xen/include/i386: hypercalls.h
src/sys/arch/xen/x86: x86_xpmap.c xen_bus_dma.c
src/sys/arch/xen/xen: balloon.c if_xennet_xenbus.c privcmd.c
xennetback_xenbus.c

Log Message:
Retire XEN_COMPAT_030001 as detailed on port-xen@:

http://mail-index.netbsd.org/port-xen/2012/06/25/msg007431.html

The xen_p2m API comes next.

ok bouyer@.
Tested on i386 PAE and amd64 (Xen 3.3 on private test bed, and
Xen 3.4 for Amazon EC2).

FWIW, Amazon always reported:

hypervisor0 at mainbus0: Xen version 3.4.3-kaos_t1micro

multiple times for Europe and US West-1, so I guess they are now at
3.4 (32 and 64 bits).


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/i386/conf/XEN3_DOMU
cvs rdiff -u -r1.100 -r1.101 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.728 -r1.729 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.126 -r1.127 src/sys/arch/xen/conf/files.xen
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/xen/include/xenpmap.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/xen/include/i386/hypercalls.h
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/xen/x86/x86_xpmap.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/xen/x86/xen_bus_dma.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/xen/xen/balloon.c
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/xen/xen/if_xennet_xenbus.c
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/xen/xen/privcmd.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/xen/xen/xennetback_xenbus.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/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.186 src/sys/arch/amd64/amd64/machdep.c:1.187
--- src/sys/arch/amd64/amd64/machdep.c:1.186	Sat Jun 16 20:47:04 2012
+++ src/sys/arch/amd64/amd64/machdep.c	Wed Jun 27 00:37:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.186 2012/06/16 20:47:04 dsl Exp $	*/
+/*	$NetBSD: machdep.c,v 1.187 2012/06/27 00:37:07 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.186 2012/06/16 20:47:04 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.187 2012/06/27 00:37:07 jym Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -1723,7 +1723,7 @@ init_x86_64(paddr_t first_avail)
 	/* Determine physical address space */
 	avail_start = first_avail;
 	avail_end = ctob(xen_start_info.nr_pages);
-	pmap_pa_start = XPMAP_OFFSET;
+	pmap_pa_start = 0;
 	pmap_pa_end = pmap_pa_start + ctob(xen_start_info.nr_pages);
 	__PRINTK(("pmap_pa_start 0x%lx avail_start 0x%lx avail_end 0x%lx\n",
 	pmap_pa_start, avail_start, avail_end));

Index: src/sys/arch/i386/conf/XEN3_DOMU
diff -u src/sys/arch/i386/conf/XEN3_DOMU:1.43 src/sys/arch/i386/conf/XEN3_DOMU:1.44
--- src/sys/arch/i386/conf/XEN3_DOMU:1.43	Sat Mar 10 21:51:53 2012
+++ src/sys/arch/i386/conf/XEN3_DOMU	Wed Jun 27 00:37:08 2012
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOMU,v 1.43 2012/03/10 21:51:53 joerg Exp $
+# $NetBSD: XEN3_DOMU,v 1.44 2012/06/27 00:37:08 jym Exp $
 
 include 	"arch/xen/conf/std.xen"
 
@@ -166,7 +166,6 @@ options 	NFS_BOOT_DHCP,NFS_BOOT_BOOTPARA
 #options 	NFS_BOOTSTATIC_SERVER="\"server:/path/to/root\""
 
 #options 	__XEN_INTERFACE_VERSION__=0x00030205 # Xen 3.1 interface
-options 	XEN_COMPAT_030001  #compatible with Xen3 before 3.0.2
 options 	MAXPHYS=32768	#xbd doesn't handle 64k transfers
 
 config		netbsd	root on ? type ?

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.100 src/sys/arch/i386/i386/locore.S:1.101
--- src/sys/arch/i386/i386/locore.S:1.100	Sat Jun 16 17:30:19 2012
+++ src/sys/arch/i386/i386/locore.S	Wed Jun 27 00:37:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.100 2012/06/16 17:30:19 chs Exp $	*/
+/*	$NetBSD: locore.S,v 1.101 2012/06/27 00:37:08 jym Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -129,7 +129,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.100 2012/06/16 17:30:19 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.101 2012/06/27 00:37:08 jym Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_ddb.h"
@@ -169,18 +169,11 @@ __KERNEL_RCSID(0, "$NetBSD: locore.S,v 1
  */
 .section __xen_guest
 	.ascii	"GUEST_OS=netbsd,GUEST_VER=3.0,XEN_VER=xen-3.0"
-#if defined(DOM0OPS) || !defined(XEN_COMPAT_030001)
 	.ascii  ",VIRT_BASE=0xc000" /* KERNBASE */
 	.ascii  ",ELF_PADDR_OFFSET=0xc000" /* KERNBASE */
-#else
-	.ascii  ",VIRT_BASE=0xc010" /* KERNTEXTOFF */
-	.ascii  ",ELF_PADDR_OFFSET=0xc010" /* KERNTEXTOFF */
-#endif
 	.ascii  ",VIRT_ENTRY=0xc010" /* KERNTEXTOF

CVS commit: src/sys/arch/xen

2012-06-24 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Jun 24 18:31:53 UTC 2012

Modified Files:
src/sys/arch/xen/include: xenpmap.h
src/sys/arch/xen/x86: xen_pmap.c

Log Message:
Enable the map/unmap recursive mapping functions for all Xen ports for
save/restore.

For an unknown reason (to me) Xen refuses to update VM translations
when the entry is pointing back to itself (which is precisely
what our recursive VM model does). So enable the functions that take
care of this, which will avoid all sort of memory corruption upon restore
leading domU to trample upon itself.

Save/restore works again for amd64. The occasional domU frontend corruption is
still present, but is harmless to dom0. Now we have a working shell and
ddb inside domU, that helps debugging a tiny bit.

XXX pull-up to -6.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/xen/include/xenpmap.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/xen/x86/xen_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/xen/include/xenpmap.h
diff -u src/sys/arch/xen/include/xenpmap.h:1.34 src/sys/arch/xen/include/xenpmap.h:1.35
--- src/sys/arch/xen/include/xenpmap.h:1.34	Fri Apr 20 22:23:24 2012
+++ src/sys/arch/xen/include/xenpmap.h	Sun Jun 24 18:31:52 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: xenpmap.h,v 1.34 2012/04/20 22:23:24 rmind Exp $	*/
+/*	$NetBSD: xenpmap.h,v 1.35 2012/06/24 18:31:52 jym Exp $	*/
 
 /*
  *
@@ -58,11 +58,8 @@ void xen_bcast_invlpg(vaddr_t);
 
 void pmap_xen_resume(void);
 void pmap_xen_suspend(void);
-
-#ifdef PAE
-void	pmap_map_recursive_entries(void);
-void	pmap_unmap_recursive_entries(void);
-#endif /* PAE */
+void pmap_map_recursive_entries(void);
+void pmap_unmap_recursive_entries(void);
 
 #if defined(PAE) || defined(__x86_64__)
 void xen_kpm_sync(struct pmap *, int);

Index: src/sys/arch/xen/x86/xen_pmap.c
diff -u src/sys/arch/xen/x86/xen_pmap.c:1.21 src/sys/arch/xen/x86/xen_pmap.c:1.22
--- src/sys/arch/xen/x86/xen_pmap.c:1.21	Fri Apr 20 22:23:25 2012
+++ src/sys/arch/xen/x86/xen_pmap.c	Sun Jun 24 18:31:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_pmap.c,v 1.21 2012/04/20 22:23:25 rmind Exp $	*/
+/*	$NetBSD: xen_pmap.c,v 1.22 2012/06/24 18:31:53 jym Exp $	*/
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.21 2012/04/20 22:23:25 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.22 2012/06/24 18:31:53 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -241,9 +241,7 @@ pmap_extract_ma(struct pmap *pmap, vaddr
 void
 pmap_xen_suspend(void)
 {
-#ifdef PAE
 	pmap_unmap_recursive_entries();
-#endif
 
 	xpq_flush_queue();
 }
@@ -251,14 +249,11 @@ pmap_xen_suspend(void)
 void
 pmap_xen_resume(void)
 {
-#ifdef PAE
 	pmap_map_recursive_entries();
-#endif
 
 	xpq_flush_queue();
 }
 
-#ifdef PAE
 /*
  * NetBSD uses L2 shadow pages to support PAE with Xen. However, Xen does not
  * handle them correctly during save/restore, leading to incorrect page
@@ -327,7 +322,6 @@ pmap_unmap_recursive_entries(void)
 		0);
 	}
 }
-#endif /* PAE */
 
 #if defined(PAE) || defined(__x86_64__)
 



CVS commit: src/sys/arch/xen/x86

2012-06-24 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Jun 24 13:56:10 UTC 2012

Modified Files:
src/sys/arch/xen/x86: cpu.c

Log Message:
Update comment: we stopped using xcall to sync PTP between CPUs.
pmap_kpm_sync_xcall => xen_kpm_sync


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/xen/x86/cpu.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/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.92 src/sys/arch/xen/x86/cpu.c:1.93
--- src/sys/arch/xen/x86/cpu.c:1.92	Wed Jun  6 22:22:41 2012
+++ src/sys/arch/xen/x86/cpu.c	Sun Jun 24 13:56:10 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.92 2012/06/06 22:22:41 rmind Exp $	*/
+/*	$NetBSD: cpu.c,v 1.93 2012/06/24 13:56:10 jym Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.92 2012/06/06 22:22:41 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.93 2012/06/24 13:56:10 jym Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1113,7 +1113,7 @@ cpu_load_pmap(struct pmap *pmap, struct 
 	cpuid_t cid = cpu_index(ci);
 
 	mutex_enter(&ci->ci_kpm_mtx);
-	/* make new pmap visible to pmap_kpm_sync_xcall() */
+	/* make new pmap visible to xen_kpm_sync() */
 	kcpuset_atomic_set(pmap->pm_xen_ptp_cpus, cid);
 #endif
 #ifdef i386
@@ -1166,7 +1166,7 @@ cpu_load_pmap(struct pmap *pmap, struct 
 
 #endif /* __x86_64__ */
 #if defined(__x86_64__) || defined(PAE)
-	/* old pmap no longer visible to pmap_kpm_sync_xcall() */
+	/* old pmap no longer visible to xen_kpm_sync() */
 	if (oldpmap != pmap_kernel()) {
 		kcpuset_atomic_clear(oldpmap->pm_xen_ptp_cpus, cid);
 	}



CVS commit: src

2012-06-05 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Jun  5 22:51:47 UTC 2012

Modified Files:
src/external/cddl/osnet/sys/kern: misc.c
src/sys/kern: subr_pool.c
src/sys/rump/librump/rumpkern: memalloc.c vm.c
src/sys/sys: pool.h
src/sys/uvm: uvm_pdaemon.c

Log Message:
Now that pool_cache_invalidate() is synchronous and can handle per-CPU
caches, merge together pool_drain_start() and pool_drain_end() into

bool pool_drain(struct pool **ppp);

"bool" value indicates whether reclaiming was fully done (true) or not (false)
"ppp" will contain a pointer to the pool that was drained (optional).

See http://mail-index.netbsd.org/tech-kern/2012/06/04/msg013287.html


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/sys/kern/misc.c
cvs rdiff -u -r1.196 -r1.197 src/sys/kern/subr_pool.c
cvs rdiff -u -r1.15 -r1.16 src/sys/rump/librump/rumpkern/memalloc.c
cvs rdiff -u -r1.126 -r1.127 src/sys/rump/librump/rumpkern/vm.c
cvs rdiff -u -r1.74 -r1.75 src/sys/sys/pool.h
cvs rdiff -u -r1.105 -r1.106 src/sys/uvm/uvm_pdaemon.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/sys/kern/misc.c
diff -u src/external/cddl/osnet/sys/kern/misc.c:1.3 src/external/cddl/osnet/sys/kern/misc.c:1.4
--- src/external/cddl/osnet/sys/kern/misc.c:1.3	Thu Mar 10 19:35:24 2011
+++ src/external/cddl/osnet/sys/kern/misc.c	Tue Jun  5 22:51:47 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.3 2011/03/10 19:35:24 pooka Exp $	*/
+/*	$NetBSD: misc.c,v 1.4 2012/06/05 22:51:47 jym Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -133,15 +133,8 @@ void
 kmem_reap(void)
 {
 	int bufcnt;
-	uint64_t where;
 	struct pool *pp;
 	
-	/*
-	 * start draining pool resources now that we're not
-	 * holding any locks.
-	 */
-	pool_drain_start(&pp, &where);
-
 	bufcnt = uvmexp.freetarg - uvmexp.free;
 	if (bufcnt < 0)
 		bufcnt = 0;
@@ -153,9 +146,9 @@ kmem_reap(void)
 	mutex_exit(&bufcache_lock);
 
 	/*
-	 * complete draining the pools.
+	 * drain the pools.
 	 */
-	pool_drain_end(pp, where);
+	pool_drain(&pp);
 //	printf("XXXNETBSD kmem_reap called, write me\n");
 }
 

Index: src/sys/kern/subr_pool.c
diff -u src/sys/kern/subr_pool.c:1.196 src/sys/kern/subr_pool.c:1.197
--- src/sys/kern/subr_pool.c:1.196	Tue Jun  5 22:28:11 2012
+++ src/sys/kern/subr_pool.c	Tue Jun  5 22:51:47 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pool.c,v 1.196 2012/06/05 22:28:11 jym Exp $	*/
+/*	$NetBSD: subr_pool.c,v 1.197 2012/06/05 22:51:47 jym Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.196 2012/06/05 22:28:11 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.197 2012/06/05 22:51:47 jym Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -1300,7 +1300,7 @@ pool_sethardlimit(struct pool *pp, int n
 /*
  * Release all complete pages that have not been used recently.
  *
- * Might be called from interrupt context.
+ * Must not be called from interrupt context.
  */
 int
 pool_reclaim(struct pool *pp)
@@ -1311,9 +1311,7 @@ pool_reclaim(struct pool *pp)
 	bool klock;
 	int rv;
 
-	if (cpu_intr_p() || cpu_softintr_p()) {
-		KASSERT(pp->pr_ipl != IPL_NONE);
-	}
+	KASSERT(!cpu_intr_p() && !cpu_softintr_p());
 
 	if (pp->pr_drain_hook != NULL) {
 		/*
@@ -1387,17 +1385,14 @@ pool_reclaim(struct pool *pp)
 }
 
 /*
- * Drain pools, one at a time.  This is a two stage process;
- * drain_start kicks off a cross call to drain CPU-level caches
- * if the pool has an associated pool_cache.  drain_end waits
- * for those cross calls to finish, and then drains the cache
- * (if any) and pool.
+ * Drain pools, one at a time. The drained pool is returned within ppp.
  *
  * Note, must never be called from interrupt context.
  */
-void
-pool_drain_start(struct pool **ppp, uint64_t *wp)
+bool
+pool_drain(struct pool **ppp)
 {
+	bool reclaimed;
 	struct pool *pp;
 
 	KASSERT(!TAILQ_EMPTY(&pool_head));
@@ -1422,28 +1417,6 @@ pool_drain_start(struct pool **ppp, uint
 	pp->pr_refcnt++;
 	mutex_exit(&pool_head_lock);
 
-	/* If there is a pool_cache, drain CPU level caches. */
-	*ppp = pp;
-	if (pp->pr_cache != NULL) {
-		*wp = xc_broadcast(0, (xcfunc_t)pool_cache_transfer,
-		pp->pr_cache, NULL);
-	}
-}
-
-bool
-pool_drain_end(struct pool *pp, uint64_t where)
-{
-	bool reclaimed;
-
-	if (pp == NULL)
-		return false;
-
-	KASSERT(pp->pr_refcnt > 0);
-
-	/* Wait for remote draining to complete. */
-	if (pp->pr_cache != NULL)
-		xc_wait(where);
-
 	/* Drain the cache (if any) and pool.. */
 	reclaimed = pool_reclaim(pp);
 
@@ -1453,6 +1426,9 @@ pool_drain_end(struct pool *pp, uint64_t
 	cv_broadcast(&pool_busy);
 	mutex_exit(&pool_head_lock);
 
+	if (ppp != NULL)
+		*ppp = pp;
+
 	return reclaimed;
 }
 

Index: src/sys/rump/librump/rumpkern/memalloc.c
diff -u src/sys/rump/librump/rumpk

CVS commit: src/sys/kern

2012-06-05 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Jun  5 22:28:11 UTC 2012

Modified Files:
src/sys/kern: subr_pool.c

Log Message:
As pool reclaiming is unlikely to happen at interrupt or softint
context, re-enable the portion of code that allows invalidation of CPU-bound
pool caches.

Two reasons:
- CPU cached objects being invalidated, the probability of fetching an
obsolete object from the pool_cache(9) is greatly reduced. This speeds up
pool_cache_get() quite a bit as it does not have to keep destroying objects
until it finds an updated one when an invalidation is in progress.

- for situations where we have to ensure that no obsolete object remains
after a state transition (canonical example: pmap mappings between Xen VM
restoration), invalidating all pool_cache(9) is the safest way to go.

As it uses xcall(9) to broadcast the execution of pool_cache_transfer(),
pool_cache_invalidate() cannot be called from interrupt or softint context
(scheduling a xcall(9) can put a LWP to sleep).

pool_cache_xcall() => pool_cache_transfer() to reflect its use.

Invalidation being a costly process (1000s objects may be destroyed),
all places where pool_cache_invalidate() may be called from
interrupt/softint context will now get caught by the proper KASSERT(), and
fixed. Ping me when you see one.

Tested under i386 and amd64 by running ATF suite within 64MiB HVM
domains (tried triggering pgdaemon a few times).

No objection on tech-kern@.

XXX a similar fix has to be pulled up to NetBSD-6, but with a more
conservative approach.

See http://mail-index.netbsd.org/tech-kern/2012/05/29/msg013245.html


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/sys/kern/subr_pool.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/kern/subr_pool.c
diff -u src/sys/kern/subr_pool.c:1.195 src/sys/kern/subr_pool.c:1.196
--- src/sys/kern/subr_pool.c:1.195	Sat May  5 19:15:10 2012
+++ src/sys/kern/subr_pool.c	Tue Jun  5 22:28:11 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pool.c,v 1.195 2012/05/05 19:15:10 rmind Exp $	*/
+/*	$NetBSD: subr_pool.c,v 1.196 2012/06/05 22:28:11 jym Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.195 2012/05/05 19:15:10 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.196 2012/06/05 22:28:11 jym Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -191,7 +191,7 @@ static bool	pool_cache_get_slow(pool_cac
 static void	pool_cache_cpu_init1(struct cpu_info *, pool_cache_t);
 static void	pool_cache_invalidate_groups(pool_cache_t, pcg_t *);
 static void	pool_cache_invalidate_cpu(pool_cache_t, u_int);
-static void	pool_cache_xcall(pool_cache_t);
+static void	pool_cache_transfer(pool_cache_t);
 
 static int	pool_catchup(struct pool *);
 static void	pool_prime_page(struct pool *, void *,
@@ -1425,7 +1425,7 @@ pool_drain_start(struct pool **ppp, uint
 	/* If there is a pool_cache, drain CPU level caches. */
 	*ppp = pp;
 	if (pp->pr_cache != NULL) {
-		*wp = xc_broadcast(0, (xcfunc_t)pool_cache_xcall,
+		*wp = xc_broadcast(0, (xcfunc_t)pool_cache_transfer,
 		pp->pr_cache, NULL);
 	}
 }
@@ -2007,31 +2007,39 @@ pool_cache_invalidate_groups(pool_cache_
  *	Note: For pool caches that provide constructed objects, there
  *	is an assumption that another level of synchronization is occurring
  *	between the input to the constructor and the cache invalidation.
+ *
+ *	Invalidation is a costly process and should not be called from
+ *	interrupt context.
  */
 void
 pool_cache_invalidate(pool_cache_t pc)
 {
-	pcg_t *full, *empty, *part;
-#if 0
 	uint64_t where;
+	pcg_t *full, *empty, *part;
+
+	KASSERT(!cpu_intr_p() && !cpu_softintr_p());
 
 	if (ncpu < 2 || !mp_online) {
 		/*
 		 * We might be called early enough in the boot process
 		 * for the CPU data structures to not be fully initialized.
-		 * In this case, simply gather the local CPU's cache now
-		 * since it will be the only one running.
+		 * In this case, transfer the content of the local CPU's
+		 * cache back into global cache as only this CPU is currently
+		 * running.
 		 */
-		pool_cache_xcall(pc);
+		pool_cache_transfer(pc);
 	} else {
 		/*
-		 * Gather all of the CPU-specific caches into the
-		 * global cache.
+		 * Signal all CPUs that they must transfer their local
+		 * cache back to the global pool then wait for the xcall to
+		 * complete.
 		 */
-		where = xc_broadcast(0, (xcfunc_t)pool_cache_xcall, pc, NULL);
+		where = xc_broadcast(0, (xcfunc_t)pool_cache_transfer,
+		pc, NULL);
 		xc_wait(where);
 	}
-#endif
+
+	/* Empty pool caches, then invalidate objects */
 	mutex_enter(&pc->pc_lock);
 	full = pc->pc_fullgroups;
 	empty = pc->pc_emptygroups;
@@ -2415,13 +2423,13 @@ pool_cache_put_paddr(pool_cache_t pc, vo
 }
 
 /*
- * pool_cache_xcall:
+ * pool_cache_transfer:
  *
  *	Transfer obj

CVS commit: src/sys/arch

2012-05-07 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 17:45:29 UTC 2012

Modified Files:
src/sys/arch/amd64/conf: files.amd64
src/sys/arch/i386/conf: files.i386
src/sys/arch/x86/conf: files.x86
src/sys/arch/xen/conf: files.xen
Added Files:
src/sys/arch/x86/x86: db_memrw.c
Removed Files:
src/sys/arch/amd64/amd64: db_memrw.c
src/sys/arch/i386/i386: db_memrw.c

Log Message:
Merge i386 and amd64 version of db_memrw.c.

Use this opportunity to skip calculating the VA of the page. Let the CPU
deal with the invalidation itself through invlpg + destination address to
avoid converting between canonical/non canonical forms.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r0 src/sys/arch/amd64/amd64/db_memrw.c
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/amd64/conf/files.amd64
cvs rdiff -u -r1.362 -r1.363 src/sys/arch/i386/conf/files.i386
cvs rdiff -u -r1.30 -r0 src/sys/arch/i386/i386/db_memrw.c
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/x86/db_memrw.c
cvs rdiff -u -r1.125 -r1.126 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/conf/files.amd64
diff -u src/sys/arch/amd64/conf/files.amd64:1.74 src/sys/arch/amd64/conf/files.amd64:1.75
--- src/sys/arch/amd64/conf/files.amd64:1.74	Sun Nov  6 19:45:04 2011
+++ src/sys/arch/amd64/conf/files.amd64	Mon May  7 17:45:28 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: files.amd64,v 1.74 2011/11/06 19:45:04 christos Exp $
+#	$NetBSD: files.amd64,v 1.75 2012/05/07 17:45:28 jym Exp $
 #
 # new style config file for amd64 architecture
 #
@@ -36,7 +36,6 @@ file	arch/amd64/amd64/cpufunc.S
 file	arch/amd64/amd64/db_disasm.c		ddb
 file	arch/amd64/amd64/db_interface.c		ddb
 file	arch/amd64/amd64/db_machdep.c		ddb
-file	arch/amd64/amd64/db_memrw.c		ddb | kgdb
 file	arch/amd64/amd64/kobj_machdep.c		modular
 file	arch/amd64/amd64/kgdb_machdep.c		kgdb
 file	kern/subr_disk_mbr.c			disk

Index: src/sys/arch/i386/conf/files.i386
diff -u src/sys/arch/i386/conf/files.i386:1.362 src/sys/arch/i386/conf/files.i386:1.363
--- src/sys/arch/i386/conf/files.i386:1.362	Fri Nov 18 22:18:07 2011
+++ src/sys/arch/i386/conf/files.i386	Mon May  7 17:45:28 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i386,v 1.362 2011/11/18 22:18:07 jmcneill Exp $
+#	$NetBSD: files.i386,v 1.363 2012/05/07 17:45:28 jym Exp $
 #
 # new style config file for i386 architecture
 #
@@ -68,7 +68,6 @@ file	arch/i386/i386/db_dbgreg.S	ddb | ks
 file	arch/i386/i386/db_disasm.c	ddb
 file	arch/i386/i386/db_interface.c	ddb
 file	arch/i386/i386/db_machdep.c	ddb
-file	arch/i386/i386/db_memrw.c	ddb | kgdb
 file	arch/i386/i386/dumpsys.c
 file	kern/subr_disk_mbr.c		disk
 file	kern/subr_spldebug.c		spldebug

Index: src/sys/arch/x86/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.77 src/sys/arch/x86/conf/files.x86:1.78
--- src/sys/arch/x86/conf/files.x86:1.77	Fri Jan 13 21:46:00 2012
+++ src/sys/arch/x86/conf/files.x86	Mon May  7 17:45:29 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: files.x86,v 1.77 2012/01/13 21:46:00 martin Exp $
+#	$NetBSD: files.x86,v 1.78 2012/05/07 17:45:29 jym Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -71,6 +71,7 @@ file	arch/x86/x86/bus_space.c
 file	arch/x86/x86/consinit.c
 file	arch/x86/x86/core_machdep.c	coredump
 file	arch/x86/x86/cpu_topology.c
+file	arch/x86/x86/db_memrw.c		ddb | kgdb
 file	arch/x86/x86/db_trace.c		ddb
 file	arch/x86/x86/errata.c
 file	arch/x86/x86/genfb_machdep.c

Index: src/sys/arch/xen/conf/files.xen
diff -u src/sys/arch/xen/conf/files.xen:1.125 src/sys/arch/xen/conf/files.xen:1.126
--- src/sys/arch/xen/conf/files.xen:1.125	Sat Jan 14 04:22:56 2012
+++ src/sys/arch/xen/conf/files.xen	Mon May  7 17:45:29 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: files.xen,v 1.125 2012/01/14 04:22:56 pgoyette Exp $
+#	$NetBSD: files.xen,v 1.126 2012/05/07 17:45:29 jym 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 
 
@@ -43,7 +43,6 @@ file	arch/i386/i386/db_dbgreg.S	ddb | ks
 file	arch/i386/i386/db_disasm.c	ddb
 file	arch/i386/i386/db_interface.c	ddb
 file	arch/i386/i386/db_machdep.c	ddb
-file	arch/i386/i386/db_memrw.c	ddb | kgdb
 file	arch/i386/i386/dumpsys.c
 file	arch/i386/i386/gdt.c
 file	arch/i386/i386/ipkdb_glue.c	ipkdb
@@ -72,7 +71,6 @@ file	arch/amd64/amd64/cpu_in_cksum.S		(i
 file	arch/amd64/amd64/db_disasm.c		ddb
 file	arch/amd64/amd64/db_interface.c		ddb
 file	arch/amd64/amd64/db_machdep.c		ddb
-file	arch/amd64/amd64/db_memrw.c		ddb | kgdb
 file	arch/amd64/amd64/kgdb_machdep.c	 kgdb
 file	arch/amd64/amd64/kobj_machdep.c	 	modular
 file	arch/amd64/amd64/gdt.c
@@ -84,6 +82,7 @@ file	arch/amd64/amd64/lock_stubs.S
 endif
 
 file	kern/subr_disk_mbr.c		disk
+file	arch/x86/x86/db_memrw.c		ddb | kgdb
 file	arch/x86/x86/db_t

CVS commit: src/sys/arch/i386/i386

2012-05-07 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 12:23:05 UTC 2012

Modified Files:
src/sys/arch/i386/i386: db_memrw.c

Log Message:
For correctness: do not forget VA_SIGN_NEG().


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/i386/i386/db_memrw.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/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.29 src/sys/arch/i386/i386/db_memrw.c:1.30
--- src/sys/arch/i386/i386/db_memrw.c:1.29	Mon May  7 12:12:03 2012
+++ src/sys/arch/i386/i386/db_memrw.c	Mon May  7 12:23:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.29 2012/05/07 12:12:03 jym Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.30 2012/05/07 12:23:05 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.29 2012/05/07 12:12:03 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.30 2012/05/07 12:23:05 jym Exp $");
 
 #include "opt_xen.h"
 
@@ -123,7 +123,7 @@ db_write_text(vaddr_t addr, size_t size,
 		 * Get the VA for the page.
 		 */
 		if (pte & PG_PS)
-			pgva = (vaddr_t)dst & PG_LGFRAME;
+			pgva = VA_SIGN_NEG((vaddr_t)dst & PG_LGFRAME);
 		else
 			pgva = x86_trunc_page((vaddr_t)dst);
 



CVS commit: src/sys/arch/amd64/amd64

2012-05-07 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 12:20:27 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64: db_memrw.c

Log Message:
invlpg on a non canonical address is a noop, so no chance to invalidate
the TLB and the CPU will not notice the access right change.

This results in write protection faults in supervisor mode when patching
kernel code through ddb(4) (originally mapped as read only).

Bug reported by David Laight on port-amd64@ (thanks!), patch and test by
me.

i386 is unaffected as PG_LGFRAME does not mask the sign bits. For the
sake of correctness, use VA_SIGN_NEG(...) anyway.

XXX this is the patch that will be pulled-up to -5 and -6.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/amd64/db_memrw.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/amd64/amd64/db_memrw.c
diff -u src/sys/arch/amd64/amd64/db_memrw.c:1.10 src/sys/arch/amd64/amd64/db_memrw.c:1.11
--- src/sys/arch/amd64/amd64/db_memrw.c:1.10	Mon May  7 12:12:04 2012
+++ src/sys/arch/amd64/amd64/db_memrw.c	Mon May  7 12:20:27 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.10 2012/05/07 12:12:04 jym Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.11 2012/05/07 12:20:27 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -51,7 +51,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.10 2012/05/07 12:12:04 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.11 2012/05/07 12:20:27 jym Exp $");
 
 #include 
 #include 
@@ -123,7 +123,7 @@ db_write_text(vaddr_t addr, size_t size,
 		 * Get the VA for the page.
 		 */
 		if (pte & PG_PS)
-			pgva = (vaddr_t)dst & PG_LGFRAME;
+			pgva = VA_SIGN_NEG((vaddr_t)dst & PG_LGFRAME);
 		else
 			pgva = x86_trunc_page(dst);
 



CVS commit: src/sys/arch

2012-05-07 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 12:12:04 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64: db_memrw.c
src/sys/arch/i386/i386: db_memrw.c

Log Message:
Use the current destination address to compute PTE, not the address of
origin.

Harmless, except when db_write_text() passes a page boundary.

>From Bug Hunting.

XXX has to be pulled up to -5 and -6.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amd64/amd64/db_memrw.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/i386/i386/db_memrw.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/amd64/amd64/db_memrw.c
diff -u src/sys/arch/amd64/amd64/db_memrw.c:1.9 src/sys/arch/amd64/amd64/db_memrw.c:1.10
--- src/sys/arch/amd64/amd64/db_memrw.c:1.9	Wed Nov 23 01:15:02 2011
+++ src/sys/arch/amd64/amd64/db_memrw.c	Mon May  7 12:12:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.9 2011/11/23 01:15:02 jym Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.10 2012/05/07 12:12:04 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -51,7 +51,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.9 2011/11/23 01:15:02 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.10 2012/05/07 12:12:04 jym Exp $");
 
 #include 
 #include 
@@ -111,7 +111,7 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the PTE for the page.
 		 */
-		ppte = kvtopte(addr);
+		ppte = kvtopte((vaddr_t)dst);
 		pte = *ppte;
 
 		if ((pte & PG_V) == 0) {

Index: src/sys/arch/i386/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.28 src/sys/arch/i386/i386/db_memrw.c:1.29
--- src/sys/arch/i386/i386/db_memrw.c:1.28	Mon May  7 02:32:09 2012
+++ src/sys/arch/i386/i386/db_memrw.c	Mon May  7 12:12:03 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.28 2012/05/07 02:32:09 jym Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.29 2012/05/07 12:12:03 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.28 2012/05/07 02:32:09 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.29 2012/05/07 12:12:03 jym Exp $");
 
 #include "opt_xen.h"
 
@@ -111,7 +111,7 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the PTE for the page.
 		 */
-		ppte = kvtopte(addr);
+		ppte = kvtopte((vaddr_t)dst);
 		pte = *ppte;
 
 		if ((pte & PG_V) == 0) {



CVS commit: src/sys/arch/i386/i386

2012-05-06 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 02:32:09 UTC 2012

Modified Files:
src/sys/arch/i386/i386: db_memrw.c

Log Message:
Use pmap_pte_*bits macros to set/clear bits in a PTE. Remove pmap_pte_flush
calls as these operations are synchronously flushed under Xen; they should
not be cached.

XXX the code can be shared between i386 and amd64, but I will merge
them once I figure out why db_write_text() can cause page faults for
certain CPUs in long mode (code looks correct, but single stepping or
adding debug printf's makes the bug magically disappear... sigh)

Bug reported by David Laight on port-amd64@ when attempting to set
breakpoints through ddb(4).


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/i386/i386/db_memrw.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/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.27 src/sys/arch/i386/i386/db_memrw.c:1.28
--- src/sys/arch/i386/i386/db_memrw.c:1.27	Mon May  7 02:15:34 2012
+++ src/sys/arch/i386/i386/db_memrw.c	Mon May  7 02:32:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.27 2012/05/07 02:15:34 jym Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.28 2012/05/07 02:32:09 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.27 2012/05/07 02:15:34 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.28 2012/05/07 02:32:09 jym Exp $");
 
 #include "opt_xen.h"
 
@@ -97,7 +97,7 @@ db_read_bytes(vaddr_t addr, size_t size,
 static void
 db_write_text(vaddr_t addr, size_t size, const char *data)
 {
-	pt_entry_t *pte, oldpte, tmppte;
+	pt_entry_t *ppte, pte;
 	vaddr_t pgva;
 	size_t limit;
 	char *dst;
@@ -111,10 +111,10 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the PTE for the page.
 		 */
-		pte = kvtopte(addr);
-		oldpte = *pte;
+		ppte = kvtopte(addr);
+		pte = *ppte;
 
-		if ((oldpte & PG_V) == 0) {
+		if ((pte & PG_V) == 0) {
 			printf(" address %p not a valid page\n", dst);
 			return;
 		}
@@ -122,7 +122,7 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the VA for the page.
 		 */
-		if (oldpte & PG_PS)
+		if (pte & PG_PS)
 			pgva = (vaddr_t)dst & PG_LGFRAME;
 		else
 			pgva = x86_trunc_page((vaddr_t)dst);
@@ -132,7 +132,7 @@ db_write_text(vaddr_t addr, size_t size,
 		 * with this mapping and subtract it from the
 		 * total size.
 		 */
-		if (oldpte & PG_PS)
+		if (pte & PG_PS)
 			limit = NBPD_L2 - ((vaddr_t)dst & (NBPD_L2 - 1));
 		else
 			limit = PAGE_SIZE - ((vaddr_t)dst & PGOFSET);
@@ -140,9 +140,11 @@ db_write_text(vaddr_t addr, size_t size,
 			limit = size;
 		size -= limit;
 
-		tmppte = (oldpte & ~PG_KR) | PG_KW;
-		pmap_pte_set(pte, tmppte);
-		pmap_pte_flush();
+		/*
+		 * Make the kernel text page writable.
+		 */
+		pmap_pte_clearbits(ppte, PG_KR);
+		pmap_pte_setbits(ppte, PG_KW);
 		pmap_update_pg(pgva);
 		/*
 		 * MULTIPROCESSOR: no shootdown required as the PTE continues to
@@ -157,10 +159,10 @@ db_write_text(vaddr_t addr, size_t size,
 			*dst++ = *data++;
 
 		/*
-		 * Restore the old PTE.
+		 * Turn the page back to read-only.
 		 */
-		pmap_pte_set(pte, oldpte);
-		pmap_pte_flush();
+		pmap_pte_clearbits(ppte, PG_KW);
+		pmap_pte_setbits(ppte, PG_KR);
 		pmap_update_pg(pgva);
 		/*
 		 * MULTIPROCESSOR: no shootdown required as all other CPUs



CVS commit: src/sys/arch/i386/i386

2012-05-06 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 02:15:34 UTC 2012

Modified Files:
src/sys/arch/i386/i386: db_memrw.c

Log Message:
Remove XXXSMP comment and explain why no TLB shootdown is required here.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/i386/i386/db_memrw.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/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.26 src/sys/arch/i386/i386/db_memrw.c:1.27
--- src/sys/arch/i386/i386/db_memrw.c:1.26	Mon May  7 02:12:35 2012
+++ src/sys/arch/i386/i386/db_memrw.c	Mon May  7 02:15:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.26 2012/05/07 02:12:35 jym Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.27 2012/05/07 02:15:34 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.26 2012/05/07 02:12:35 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.27 2012/05/07 02:15:34 jym Exp $");
 
 #include "opt_xen.h"
 
@@ -161,22 +161,13 @@ db_write_text(vaddr_t addr, size_t size,
 		 */
 		pmap_pte_set(pte, oldpte);
 		pmap_pte_flush();
-#if 0 
+		pmap_update_pg(pgva);
 		/*
-		 * XXXSMP Not clear if this is needed for 100% correctness.
+		 * MULTIPROCESSOR: no shootdown required as all other CPUs
+		 * should be in CPUF_PAUSE state and will not cache the PTE
+		 * with the write access set.
 		 */
-		{
-			int cpumask = 0;
-			/*
-			 * shoot down in case other CPU mistakenly caches page.
-			 */
-			pmap_tlb_shootdown(pmap_kernel(), pgva, 0, PG_G);
-			pmap_tlb_shootwait();
-		}
-#else
-		pmap_update_pg(pgva);
-#endif
-		
+
 	} while (size != 0);
 }
 



CVS commit: src/sys/arch/i386/i386

2012-05-06 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 02:12:35 UTC 2012

Modified Files:
src/sys/arch/i386/i386: db_memrw.c

Log Message:
I am not quite sure that __data_start (set through location counter) is
a char... declare it as int, like amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/i386/i386/db_memrw.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/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.25 src/sys/arch/i386/i386/db_memrw.c:1.26
--- src/sys/arch/i386/i386/db_memrw.c:1.25	Tue Mar 10 20:05:30 2009
+++ src/sys/arch/i386/i386/db_memrw.c	Mon May  7 02:12:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.25 2009/03/10 20:05:30 bouyer Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.26 2012/05/07 02:12:35 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.25 2009/03/10 20:05:30 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.26 2012/05/07 02:12:35 jym Exp $");
 
 #include "opt_xen.h"
 
@@ -186,7 +186,7 @@ db_write_text(vaddr_t addr, size_t size,
 void
 db_write_bytes(vaddr_t addr, size_t size, const char *data)
 {
-	extern char __data_start;
+	extern int __data_start;
 	char *dst;
 
 	dst = (char *)addr;



CVS commit: src/sys/arch/x86/include

2012-05-05 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat May  5 15:08:29 UTC 2012

Modified Files:
src/sys/arch/x86/include: specialreg.h

Log Message:
Add latest CR4 bits:
- CR4_VMXE: VMX operations, used for hardware virtualization.
- CR4_SMXE: SMX operations, used for safer Mode Extensions (ground for
Intel's TXT - Trusted Execution Technology - platform).
- CR4_FSGSBASE: enable *FSBASE and *GSBASE instructions, for R/W access
to FS/GS segment base addresses.
- CR4_PCIDE: enable Process Context IDentifiers (other architectures may call
 these "address space identifiers").
- CR4_OSXSAVE: enable xsave and xrestore instructions
- CR4_SMEP: Supervisor Mode Execution Prevention. Allows enforcing --x rights
from cpl 0.

>From Intel® 64 and IA-32 Architectures Software Developer’s Manual,
March 2012.

Align declarations.

CPUID_* bits for these features follow.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/x86/include/specialreg.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/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.58 src/sys/arch/x86/include/specialreg.h:1.59
--- src/sys/arch/x86/include/specialreg.h:1.58	Mon Apr 30 00:04:31 2012
+++ src/sys/arch/x86/include/specialreg.h	Sat May  5 15:08:29 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.58 2012/04/30 00:04:31 christos Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.59 2012/05/05 15:08:29 jym Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -68,20 +68,26 @@
 /* the remaining 7 bits of this register are reserved */
 
 /*
- * bits in the pentiums %cr4 register:
+ * bits in the %cr4 control register:
  */
+#define CR4_VME		0x0001 /* virtual 8086 mode extension enable */
+#define CR4_PVI		0x0002 /* protected mode virtual interrupt enable */
+#define CR4_TSD		0x0004 /* restrict RDTSC instruction to cpl 0 */
+#define CR4_DE		0x0008 /* debugging extension */
+#define CR4_PSE		0x0010 /* large (4MB) page size enable */
+#define CR4_PAE		0x0020 /* physical address extension enable */
+#define CR4_MCE		0x0040 /* machine check enable */
+#define CR4_PGE		0x0080 /* page global enable */
+#define CR4_PCE		0x0100 /* enable RDPMC instruction for all cpls */
+#define CR4_OSFXSR	0x0200 /* enable fxsave/fxrestor and SSE */
+#define CR4_OSXMMEXCPT	0x0400 /* enable unmasked SSE exceptions */
+#define CR4_VMXE	0x2000 /* enable VMX operations */
+#define CR4_SMXE	0x4000 /* enable SMX operations */
+#define CR4_FSGSBASE	0x0001 /* enable *FSBASE and *GSBASE instructions */
+#define CR4_PCIDE	0x0002 /* enable Process Context IDentifiers */
+#define CR4_OSXSAVE	0x0004 /* enable xsave and xrestore */
+#define CR4_SMEP	0x0010 /* enable SMEP support */
 
-#define CR4_VME	0x0001	/* virtual 8086 mode extension enable */
-#define CR4_PVI 0x0002	/* protected mode virtual interrupt enable */
-#define CR4_TSD 0x0004	/* restrict RDTSC instruction to cpl 0 only */
-#define CR4_DE	0x0008	/* debugging extension */
-#define CR4_PSE	0x0010	/* large (4MB) page size enable */
-#define CR4_PAE 0x0020	/* physical address extension enable */
-#define CR4_MCE	0x0040	/* machine check enable */
-#define CR4_PGE	0x0080	/* page global enable */
-#define CR4_PCE	0x0100	/* enable RDPMC instruction for all cpls */
-#define CR4_OSFXSR	0x0200	/* enable fxsave/fxrestor and SSE */
-#define CR4_OSXMMEXCPT	0x0400	/* enable unmasked SSE exceptions */
 
 /*
  * CPUID "features" bits



CVS commit: src/share/man/man2

2012-04-23 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Apr 23 17:44:39 UTC 2012

Modified Files:
src/share/man/man2: siginfo.2

Log Message:
Note that si_addr may be inaccurate on certain architectures.

Example: i386/amd64 alignement fault can drive to SIGBUS (when configured
so by process), however the faulty address returned by the CPU is not
reliable.

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/share/man/man2/siginfo.2

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/man2/siginfo.2
diff -u src/share/man/man2/siginfo.2:1.5 src/share/man/man2/siginfo.2:1.6
--- src/share/man/man2/siginfo.2:1.5	Mon Jul 26 12:50:52 2010
+++ src/share/man/man2/siginfo.2	Mon Apr 23 17:44:39 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: siginfo.2,v 1.5 2010/07/26 12:50:52 christos Exp $
+.\"	$NetBSD: siginfo.2,v 1.6 2012/04/23 17:44:39 jym Exp $
 .\"
 .\" Copyright (c) 2003 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd July 26, 2010
+.Dd April 23, 2012
 .Dt SIGINFO 2
 .Os
 .Sh NAME
@@ -280,6 +280,11 @@ contains the address of the faulting dat
 .Fa si_trap
 contains a hardware specific reason.
 .Pp
+For some architectures
+the value of
+.Fa si_addr
+may be inaccurate.
+.Pp
 For
 .Dv SIGPOLL
 the



CVS commit: src/sys/arch/x86/include

2012-04-20 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Fri Apr 20 18:28:43 UTC 2012

Modified Files:
src/sys/arch/x86/include: psl.h

Log Message:
PSL_AC is user-settable.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/include/psl.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/arch/x86/include/psl.h
diff -u src/sys/arch/x86/include/psl.h:1.6 src/sys/arch/x86/include/psl.h:1.7
--- src/sys/arch/x86/include/psl.h:1.6	Thu Sep 18 21:09:18 2008
+++ src/sys/arch/x86/include/psl.h	Fri Apr 20 18:28:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: psl.h,v 1.6 2008/09/18 21:09:18 dsl Exp $	*/
+/*	$NetBSD: psl.h,v 1.7 2012/04/20 18:28:43 jym Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -71,7 +71,7 @@
 #define	PSL_USERSTATIC	(PSL_MBO | PSL_MBZ | PSL_I | PSL_IOPL | PSL_NT | PSL_VM | PSL_VIF | PSL_VIP)
 #endif
 #define PSL_USER	(PSL_C | PSL_PF | PSL_AF | PSL_Z | PSL_N | \
-PSL_T | PSL_V | PSL_D)
+PSL_T | PSL_V | PSL_D | PSL_AC)
 #define	PSL_CLEARSIG	(PSL_T | PSL_VM | PSL_AC | PSL_D)
 
 



CVS commit: src/tests/lib/libc/gen

2012-04-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Fri Apr 20 00:40:32 UTC 2012

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
ATF test for SIGBUS => BUS_ADRALN (invalid address alignment).

That one is tedious to test under x86: alignment exceptions are
not reported by this architecture unless you ask for them explicitely (by
setting the PSL_AC bit). The brokenness does not end there: %cr2 should
contain the address where the unaligned access occured, alas, it does not.

I am not aware of other architectures where this could happen. Still, my
knowledge is limited; if there is one, feel free to send me a mail and I
will update the test accordingly.

Adding insult to injury, this test can fail in various funny ways with VMs:
- under x86 QEMU, no trap() happens. As ring 3 code stays almost untouched by
QEMU VMM, I suppose the exception can only be triggered when the host
itself is capable of catching unaligned accesses.
- under Virtual Box with HVM support, i386 works fine, but amd64 fails with a
SIGILL (Illegal instruction) that happens right before entering the
signal handler. No idea why, and trying to debug it with gdb freezes the VM
(including ddb breaks).

Anyway, tested with:
- i386: P4 host, anita, Virtual Box HVM (Mac OS X)
- amd64: anita, Virtual Box HVM (Mac OS X)

XXX I would appreciate if someone could test it under a real amd64 host with
an up-to-date kernel, so I can reasonably assume that the culprit is
Virtual Box and not our amd64 port (my test machine being off line
I cannot do it myself). Results from other arches would be a plus too.

Initial issue reported by Nicolas Joly on port-amd64. Thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libc/gen/t_siginfo.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/gen/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.14 src/tests/lib/libc/gen/t_siginfo.c:1.15
--- src/tests/lib/libc/gen/t_siginfo.c:1.14	Sun Mar 18 07:14:08 2012
+++ src/tests/lib/libc/gen/t_siginfo.c	Fri Apr 20 00:40:31 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.14 2012/03/18 07:14:08 jruoho Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.15 2012/04/20 00:40:31 jym Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -48,6 +48,9 @@
 #include 
 #endif
 
+/* for sigbus */
+char *addr;
+
 /* for sigchild */
 pid_t child;
 int code;
@@ -405,6 +408,70 @@ ATF_TC_BODY(sigsegv, tc)
 	atf_tc_fail("Test did not fault as expected");
 }
 
+static void
+sigbus_action(int signo, siginfo_t *info, void *ptr)
+{
+
+	sig_debug(signo, info, (ucontext_t *)ptr);
+
+	ATF_REQUIRE_EQ(info->si_signo, SIGBUS);
+	ATF_REQUIRE_EQ(info->si_errno, 0);
+	ATF_REQUIRE_EQ(info->si_code, BUS_ADRALN);
+
+	if (strcmp(atf_config_get("atf_arch"), "i386") == 0 ||
+	strcmp(atf_config_get("atf_arch"), "x86_64") == 0) {
+		atf_tc_expect_fail("x86 architecture does not correctly "
+		"report the address where the unaligned access occured");
+	}
+
+	ATF_REQUIRE_EQ(info->si_addr, (void *)addr);
+	atf_tc_pass();
+	/* NOTREACHED */
+}
+
+ATF_TC(sigbus_adraln);
+ATF_TC_HEAD(sigbus_adraln, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr",
+	"Checks that signal trampoline correctly calls SIGBUS handler "
+	"for invalid address alignment");
+}
+
+ATF_TC_BODY(sigbus_adraln, tc)
+{
+	struct sigaction sa;
+
+	sa.sa_flags = SA_SIGINFO;
+	sa.sa_sigaction = sigbus_action;
+	sigemptyset(&sa.sa_mask);
+	sigaction(SIGBUS, &sa, NULL);
+
+	/* Enable alignement checks for x86. 0x4 is PSL_AC. */
+#if defined(__i386__)
+	__asm__("pushf; orl $0x4, (%esp); popf");
+#elif defined(__amd64__)
+	__asm__("pushf; orl $0x4, (%rsp); popf");
+#endif
+
+	addr = calloc(2, sizeof(int));
+	ATF_REQUIRE(addr != NULL);
+
+	if (strcmp(atf_config_get("atf_arch"), "i386") == 0 ||
+	strcmp(atf_config_get("atf_arch"), "x86_64") == 0) {
+		if (system("cpuctl identify 0 | grep -q QEMU") == 0) {
+			atf_tc_expect_fail("QEMU fails to trap unaligned "
+			"accesses");
+		}
+	}
+
+	/* Force an unaligned access */
+	addr++;
+	ATF_REQUIRE_EQ(*(volatile int *)addr, 0);
+
+	atf_tc_fail("Test did not fault as expected");
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -415,6 +482,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, sigfpe_flt);
 	ATF_TP_ADD_TC(tp, sigfpe_int);
 	ATF_TP_ADD_TC(tp, sigsegv);
+	ATF_TP_ADD_TC(tp, sigbus_adraln);
 
 	return atf_no_error();
 }



CVS commit: src/sys/arch/i386/i386

2012-04-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Apr 19 18:07:05 UTC 2012

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Mirror what is done for amd64 boot and ACPI wakeup code by setting
CR0_WP (write protection bit) early on boot. Although it is set later via
cpu_init(), this can help tracking down invalid writes to pages mapped
as read only from ring 0.

No regression observed when booting under anita (QEMU) or a P4 host.

Depending on your hardware or setup, you may trigger code paths I have
overlooked. So if your machine does not start properly, or you get
page faults early during boot, please report them to me.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/i386/i386/locore.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/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.98 src/sys/arch/i386/i386/locore.S:1.99
--- src/sys/arch/i386/i386/locore.S:1.98	Thu Apr 19 18:00:35 2012
+++ src/sys/arch/i386/i386/locore.S	Thu Apr 19 18:07:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $	*/
+/*	$NetBSD: locore.S,v 1.99 2012/04/19 18:07:05 jym Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -129,7 +129,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.99 2012/04/19 18:07:05 jym Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_ddb.h"
@@ -682,7 +682,7 @@ try586:	/* Use the `cpuid' instruction. 
  	 */
 	movl	%cr0,%eax		# get control word
 	# enable paging & NPX emulation
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_AM),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax
 	movl	%eax,%cr0		# and page NOW!
 
 	pushl	$begin			# jump to high mem



CVS commit: src/sys/arch

2012-04-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Apr 19 18:00:35 UTC 2012

Modified Files:
src/sys/arch/amd64/acpi: acpi_wakecode.S
src/sys/arch/amd64/amd64: locore.S mptramp.S
src/sys/arch/i386/acpi: acpi_wakecode.S
src/sys/arch/i386/i386: locore.S mptramp.S

Log Message:
Set the CR0_AM bit so processes can enable alignment check errors under
x86 through PSL_AC bit.

ATF test incoming shortly.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/acpi/acpi_wakecode.S
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amd64/amd64/mptramp.S
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/i386/acpi/acpi_wakecode.S
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/i386/i386/mptramp.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/acpi/acpi_wakecode.S
diff -u src/sys/arch/amd64/acpi/acpi_wakecode.S:1.10 src/sys/arch/amd64/acpi/acpi_wakecode.S:1.11
--- src/sys/arch/amd64/acpi/acpi_wakecode.S:1.10	Mon Aug 24 22:06:50 2009
+++ src/sys/arch/amd64/acpi/acpi_wakecode.S	Thu Apr 19 18:00:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_wakecode.S,v 1.10 2009/08/24 22:06:50 jmcneill Exp $	*/
+/*	$NetBSD: acpi_wakecode.S,v 1.11 2012/04/19 18:00:34 jym Exp $	*/
 
 /*-
  * Copyright (c) 2007 Joerg Sonnenberger 
@@ -198,7 +198,7 @@ wakeup_32:
 
 	/* Enable paging */
 	movl	%cr0,%eax
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
 	movl	%eax,%cr0
 	/* Flush prefetch queue */
 	jmp	1f

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.67 src/sys/arch/amd64/amd64/locore.S:1.68
--- src/sys/arch/amd64/amd64/locore.S:1.67	Fri Feb 24 08:06:07 2012
+++ src/sys/arch/amd64/amd64/locore.S	Thu Apr 19 18:00:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.67 2012/02/24 08:06:07 cherry Exp $	*/
+/*	$NetBSD: locore.S,v 1.68 2012/04/19 18:00:34 jym Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -626,7 +626,7 @@ start:	movw	$0x1234,0x472			# warm boot
 	 * 4. Enable paging and the rest of it.
 	 */
 	movl	%cr0,%eax
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
 	movl	%eax,%cr0
 	jmp	compat
 compat:

Index: src/sys/arch/amd64/amd64/mptramp.S
diff -u src/sys/arch/amd64/amd64/mptramp.S:1.12 src/sys/arch/amd64/amd64/mptramp.S:1.13
--- src/sys/arch/amd64/amd64/mptramp.S:1.12	Tue Apr 20 15:42:21 2010
+++ src/sys/arch/amd64/amd64/mptramp.S	Thu Apr 19 18:00:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mptramp.S,v 1.12 2010/04/20 15:42:21 jym Exp $	*/
+/*	$NetBSD: mptramp.S,v 1.13 2012/04/19 18:00:34 jym Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -173,7 +173,7 @@ _TRMP_LABEL(mp_startup)
 movl%ecx,%cr3   # load ptd addr into mmu
 
 movl%cr0,%eax   # get control word
-orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP),%eax
+orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
 movl%eax,%cr0
 	jmp	mptramp_compat
 mptramp_compat:

Index: src/sys/arch/i386/acpi/acpi_wakecode.S
diff -u src/sys/arch/i386/acpi/acpi_wakecode.S:1.14 src/sys/arch/i386/acpi/acpi_wakecode.S:1.15
--- src/sys/arch/i386/acpi/acpi_wakecode.S:1.14	Mon Aug 24 10:16:12 2009
+++ src/sys/arch/i386/acpi/acpi_wakecode.S	Thu Apr 19 18:00:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_wakecode.S,v 1.14 2009/08/24 10:16:12 jmcneill Exp $	*/
+/*	$NetBSD: acpi_wakecode.S,v 1.15 2012/04/19 18:00:34 jym Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -165,7 +165,7 @@ wakeup_32:
 	movl	WAKEUP_r_cr3 + ACPI_WAKEUP_ADDR,%eax
 	movl	%eax,%cr3
 	movl	%cr0,%eax
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax
 	movl	%eax,%cr0
 
 	/* Flush the prefetch queue */

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.97 src/sys/arch/i386/i386/locore.S:1.98
--- src/sys/arch/i386/i386/locore.S:1.97	Fri Mar  2 16:43:31 2012
+++ src/sys/arch/i386/i386/locore.S	Thu Apr 19 18:00:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.97 2012/03/02 16:43:31 bouyer Exp $	*/
+/*	$NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -129,7 +129,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.97 2012/03/02 16:43:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_ddb.h"
@@ -682,7 +682,7 @@ try586:	/* Use the `cpuid' instruction. 
  	 */
 	movl	%cr0,%eax		# get control word
 	# enable paging & NPX emulation
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|

CVS commit: src/sys/arch/xen/x86

2012-03-11 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Mar 11 17:14:30 UTC 2012

Modified Files:
src/sys/arch/xen/x86: xen_pmap.c

Log Message:
Split the map/unmap code from the sync/flush code: move xpq_flush_queue()
calls after pmap_{,un}map_recursive_entries() so that pmap's handlers
handle the flush themselves.

Now pmap_{,un}map_recursive_entries() do what their names imply, nothing more.

Fix pmap_xen_suspend()'s comment: APDPs are now gone.

pmap's handlers are called deep during kernel save/restore. We already
are at IPL_VM + kpreemption disabled. No need to wrap the xpq_flush_queue()
with splvm/splx.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/xen/x86/xen_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/xen/x86/xen_pmap.c
diff -u src/sys/arch/xen/x86/xen_pmap.c:1.19 src/sys/arch/xen/x86/xen_pmap.c:1.20
--- src/sys/arch/xen/x86/xen_pmap.c:1.19	Fri Mar  2 16:38:14 2012
+++ src/sys/arch/xen/x86/xen_pmap.c	Sun Mar 11 17:14:30 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_pmap.c,v 1.19 2012/03/02 16:38:14 bouyer Exp $	*/
+/*	$NetBSD: xen_pmap.c,v 1.20 2012/03/11 17:14:30 jym Exp $	*/
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.19 2012/03/02 16:38:14 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.20 2012/03/11 17:14:30 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -236,22 +236,16 @@ pmap_extract_ma(struct pmap *pmap, vaddr
 }
 
 /*
- * Flush all APDP entries found in pmaps
- * Required during Xen save/restore operations, as Xen does not
- * handle alternative recursive mappings properly
+ * Xen pmap's handlers for save/restore
  */
 void
 pmap_xen_suspend(void)
 {
-	int s;
-
-	s = splvm();
-	xpq_flush_queue();
-	splx(s);
-
 #ifdef PAE
 	pmap_unmap_recursive_entries();
 #endif
+
+	xpq_flush_queue();
 }
 
 void
@@ -260,6 +254,8 @@ pmap_xen_resume(void)
 #ifdef PAE
 	pmap_map_recursive_entries();
 #endif
+
+	xpq_flush_queue();
 }
 
 #ifdef PAE
@@ -294,10 +290,13 @@ pmap_map_recursive_entries(void)
 		xpmap_ptom(pmap_pdirpa(pmap_kernel(), PDIR_SLOT_PTE + i)),
 		xpmap_ptom(pmap_kernel()->pm_pdirpa[i]) | PG_V);
 	}
-
-	xpq_flush_queue();
 }
 
+/*
+ * Unmap recursive entries found in pmaps. Required during Xen
+ * save/restore operations, as Xen does not handle recursive mappings
+ * properly.
+ */
 void
 pmap_unmap_recursive_entries(void)
 {
@@ -322,13 +321,11 @@ pmap_unmap_recursive_entries(void)
 	mutex_exit(&pmaps_lock);
 
 	/* do it for pmap_kernel() too! */
-	for (i = 0; i < PDP_SIZE; i++)
+	for (i = 0; i < PDP_SIZE; i++) {
 		xpq_queue_pte_update(
 		xpmap_ptom(pmap_pdirpa(pmap_kernel(), PDIR_SLOT_PTE + i)),
 		0);
-
-	xpq_flush_queue();
-
+	}
 }
 #endif /* PAE */
 



CVS commit: src/sys/arch/x86/include

2012-03-11 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Mar 11 16:28:02 UTC 2012

Modified Files:
src/sys/arch/x86/include: pmap.h

Log Message:
Alternate PTEs got killed a few weeks ago. Clean up unused prototypes.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/x86/include/pmap.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/arch/x86/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.50 src/sys/arch/x86/include/pmap.h:1.51
--- src/sys/arch/x86/include/pmap.h:1.50	Fri Feb 17 18:40:18 2012
+++ src/sys/arch/x86/include/pmap.h	Sun Mar 11 16:28:02 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.50 2012/02/17 18:40:18 bouyer Exp $	*/
+/*	$NetBSD: pmap.h,v 1.51 2012/03/11 16:28:02 jym Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -447,9 +447,6 @@ xpmap_ptetomach(pt_entry_t *pte)
 
 paddr_t	vtomach(vaddr_t);
 #define vtomfn(va) (vtomach(va) >> PAGE_SHIFT)
-
-void	pmap_apte_flush(struct pmap *);
-void	pmap_unmap_apdp(void);
 #endif	/* XEN */
 
 /* pmap functions with machine addresses */



CVS commit: src/sys/arch/xen/x86

2012-03-11 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Mar 11 16:16:44 UTC 2012

Modified Files:
src/sys/arch/xen/x86: cpu.c

Log Message:
Typo fix.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/xen/x86/cpu.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/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.89 src/sys/arch/xen/x86/cpu.c:1.90
--- src/sys/arch/xen/x86/cpu.c:1.89	Sat Feb 25 18:57:50 2012
+++ src/sys/arch/xen/x86/cpu.c	Sun Mar 11 16:16:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.89 2012/02/25 18:57:50 bouyer Exp $	*/
+/*	$NetBSD: cpu.c,v 1.90 2012/03/11 16:16:44 jym Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.89 2012/02/25 18:57:50 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.90 2012/03/11 16:16:44 jym Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1196,7 +1196,7 @@ cpu_load_pmap(struct pmap *pmap, struct 
   * considered to be a canonical "SHADOW" PDIR with the following
   * properties: 
   * - Its recursive mapping points to itself
-  * - per-cpu recurseive mappings point to themselves on __x86_64__
+  * - per-cpu recursive mappings point to themselves on __x86_64__
   * - per-cpu L4 pages' kernel entries are expected to be in sync with
   *   the shadow
   */



CVS commit: src/sys/arch/xen/x86

2012-02-13 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Feb 13 23:54:58 UTC 2012

Modified Files:
src/sys/arch/xen/x86: cpu.c

Log Message:
PAT flags are not under control of Xen domains currently, so there is no
point in enabling them.

Avoids:
- a warning logged by hypervisor when a domain attempts to modify the PAT
MSR.
- an error during domain resuming, where a PAT flag has been set on a page
while the hypervisor does not allow it.

ok releng@.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/xen/x86/cpu.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/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.79 src/sys/arch/xen/x86/cpu.c:1.80
--- src/sys/arch/xen/x86/cpu.c:1.79	Sat Jan 28 12:15:19 2012
+++ src/sys/arch/xen/x86/cpu.c	Mon Feb 13 23:54:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.79 2012/01/28 12:15:19 cherry Exp $	*/
+/*	$NetBSD: cpu.c,v 1.80 2012/02/13 23:54:58 jym Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.79 2012/01/28 12:15:19 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.80 2012/02/13 23:54:58 jym Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -532,7 +532,6 @@ cpu_attach_common(device_t parent, devic
 		panic("unknown processor type??\n");
 	}
 
-	pat_init(ci);
 	atomic_or_32(&cpus_attached, ci->ci_cpumask);
 
 #ifdef MPVERBOSE



CVS commit: src/sys/arch

2012-02-12 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Feb 12 14:38:18 UTC 2012

Modified Files:
src/sys/arch/x86/include: cpu.h
src/sys/arch/xen/xen: clock.c xen_machdep.c

Log Message:
Xen clock management routines keep track of CPU (following MP merge).
Reflect this change in the suspend/resume routines so they can cope with
domU CPU suspend, instead of setting their cpu_info pointer to NULL.

Avoid copy/pasting by using the resume routines during attachement.

ok releng@.

No regression observed, and allows domU to suspend successfully again.
Restore is a different beast as PD/PT flags are marked "invalid" by Xen-4
hypervisor, and blocks resuming. Looking into it.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/xen/xen/clock.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/xen/xen/xen_machdep.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/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.46 src/sys/arch/x86/include/cpu.h:1.47
--- src/sys/arch/x86/include/cpu.h:1.46	Sat Jan 28 07:19:17 2012
+++ src/sys/arch/x86/include/cpu.h	Sun Feb 12 14:38:18 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.46 2012/01/28 07:19:17 cherry Exp $	*/
+/*	$NetBSD: cpu.h,v 1.47 2012/02/12 14:38:18 jym Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -413,8 +413,8 @@ void	child_trampoline(void);
 void	startrtclock(void);
 void	xen_delay(unsigned int);
 void	xen_initclocks(void);
-void	xen_suspendclocks(void);
-void	xen_resumeclocks(void);
+void	xen_suspendclocks(struct cpu_info *);
+void	xen_resumeclocks(struct cpu_info *);
 #else
 /* clock.c */
 void	initrtclock(u_long);

Index: src/sys/arch/xen/xen/clock.c
diff -u src/sys/arch/xen/xen/clock.c:1.60 src/sys/arch/xen/xen/clock.c:1.61
--- src/sys/arch/xen/xen/clock.c:1.60	Mon Jan  9 13:35:42 2012
+++ src/sys/arch/xen/xen/clock.c	Sun Feb 12 14:38:18 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.60 2012/01/09 13:35:42 cherry Exp $	*/
+/*	$NetBSD: clock.c,v 1.61 2012/02/12 14:38:18 jym Exp $	*/
 
 /*
  *
@@ -29,7 +29,7 @@
 #include "opt_xen.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.60 2012/01/09 13:35:42 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.61 2012/02/12 14:38:18 jym Exp $");
 
 #include 
 #include 
@@ -419,7 +419,7 @@ static struct evcnt hardclock_called[MAX
 void
 xen_initclocks(void)
 {
-	int err, evtch;
+	int err;
 	static bool tcdone = false;
 
 	struct cpu_info *ci = curcpu();
@@ -438,8 +438,6 @@ xen_initclocks(void)
 		callout_init(&xen_timepush_co, 0);
 	}
 #endif
-	evtch = bind_virq_to_evtch(VIRQ_TIMER);
-	aprint_verbose("Xen clock: using event channel %d\n", evtch);
 
 	if (!tcdone) { /* Do this only once */
 		mutex_init(&tmutex, MUTEX_DEFAULT, IPL_CLOCK);
@@ -451,7 +449,9 @@ xen_initclocks(void)
 	if (!tcdone) { /* Do this only once */
 		tc_init(&xen_timecounter);
 	}
+
 	/* The splhigh requirements start here. */
+	xen_resumeclocks(ci);
 
 	/*
 	 * The periodic timer looks buggy, we stop receiving events
@@ -461,16 +461,12 @@ xen_initclocks(void)
 	err = HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer,
  ci->ci_cpuid,
  NULL);
-
 	KASSERT(err == 0);
+
 	err = HYPERVISOR_set_timer_op(
 	vcpu_system_time[ci->ci_cpuid] + NS_PER_TICK);
 	KASSERT(err == 0);
 
-	event_set_handler(evtch, (int (*)(void *))xen_timer_handler,
-	ci, IPL_CLOCK, "clock");
-	hypervisor_enable_event(evtch);
-
 #ifdef DOM0OPS
 	if (!tcdone) { /* Do this only once */
 
@@ -490,7 +486,7 @@ xen_initclocks(void)
 }
 
 void
-xen_suspendclocks(void)
+xen_suspendclocks(struct cpu_info *ci)
 {
 	int evtch;
 
@@ -498,13 +494,13 @@ xen_suspendclocks(void)
 	KASSERT(evtch != -1);
 
 	hypervisor_mask_event(evtch);
-	event_remove_handler(evtch, (int (*)(void *))xen_timer_handler, NULL);
+	event_remove_handler(evtch, (int (*)(void *))xen_timer_handler, ci);
 
 	aprint_verbose("Xen clock: removed event channel %d\n", evtch);
 }
 
 void
-xen_resumeclocks(void)
+xen_resumeclocks(struct cpu_info *ci)
 {
 	int evtch;

@@ -512,7 +508,7 @@ xen_resumeclocks(void)
 	KASSERT(evtch != -1);
 
 	event_set_handler(evtch, (int (*)(void *))xen_timer_handler,
-	NULL, IPL_CLOCK, "clock");
+	ci, IPL_CLOCK, "clock");
 	hypervisor_enable_event(evtch);
 
 	aprint_verbose("Xen clock: using event channel %d\n", evtch);

Index: src/sys/arch/xen/xen/xen_machdep.c
diff -u src/sys/arch/xen/xen/xen_machdep.c:1.9 src/sys/arch/xen/xen/xen_machdep.c:1.10
--- src/sys/arch/xen/xen/xen_machdep.c:1.9	Sun Nov 20 19:41:27 2011
+++ src/sys/arch/xen/xen/xen_machdep.c	Sun Feb 12 14:38:18 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_machdep.c,v 1.9 2011/11/20 19:41:27 jym Exp $	*/
+/*	$NetBSD: xen_machdep.c,v 1.10 2012/02/12 14:38:18 jym Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_

CVS commit: src/sys/arch/xen/xen

2012-02-12 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Feb 12 14:24:08 UTC 2012

Modified Files:
src/sys/arch/xen/xen: evtchn.c

Log Message:
Xen MP merge introduced MP safety around ipl handlers. When removing an
event handler, check handler's function and arguments against the real
ones, not the ones from wrappers.

This fixes a bug where !mpsafe events could not be removed from the handler
chain, thereby blocking suspension of a domU.

ok releng@.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/xen/xen/evtchn.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/xen/xen/evtchn.c
diff -u src/sys/arch/xen/xen/evtchn.c:1.61 src/sys/arch/xen/xen/evtchn.c:1.62
--- src/sys/arch/xen/xen/evtchn.c:1.61	Thu Dec  8 03:34:44 2011
+++ src/sys/arch/xen/xen/evtchn.c	Sun Feb 12 14:24:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.c,v 1.61 2011/12/08 03:34:44 cherry Exp $	*/
+/*	$NetBSD: evtchn.c,v 1.62 2012/02/12 14:24:08 jym Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.61 2011/12/08 03:34:44 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.62 2012/02/12 14:24:08 jym Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -774,7 +774,7 @@ event_remove_handler(int evtch, int (*fu
 	for (ihp = &evts->ev_handlers, ih = evts->ev_handlers;
 	ih != NULL;
 	ihp = &ih->ih_evt_next, ih = ih->ih_evt_next) {
-		if (ih->ih_fun == func && ih->ih_arg == arg)
+		if (ih->ih_realfun == func && ih->ih_realarg == arg)
 			break;
 	}
 	if (ih == NULL) {
@@ -789,7 +789,7 @@ event_remove_handler(int evtch, int (*fu
 	for (ihp = &ipls->ipl_handlers, ih = ipls->ipl_handlers;
 	ih != NULL;
 	ihp = &ih->ih_ipl_next, ih = ih->ih_ipl_next) {
-		if (ih->ih_fun == func && ih->ih_arg == arg)
+		if (ih->ih_realfun == func && ih->ih_realarg == arg)
 			break;
 	}
 	if (ih == NULL)



CVS commit: src/sys/arch/xen/xen

2012-01-05 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Jan  5 18:11:51 UTC 2012

Modified Files:
src/sys/arch/xen/xen: balloon.c

Log Message:
Comment fix.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/xen/xen/balloon.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/xen/xen/balloon.c
diff -u src/sys/arch/xen/xen/balloon.c:1.12 src/sys/arch/xen/xen/balloon.c:1.13
--- src/sys/arch/xen/xen/balloon.c:1.12	Mon Dec 26 20:26:38 2011
+++ src/sys/arch/xen/xen/balloon.c	Thu Jan  5 18:11:50 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: balloon.c,v 1.12 2011/12/26 20:26:38 jym Exp $ */
+/* $NetBSD: balloon.c,v 1.13 2012/01/05 18:11:50 jym Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
 #define BALLOONDEBUG 0
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.12 2011/12/26 20:26:38 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.13 2012/01/05 18:11:50 jym Exp $");
 
 #include 
 #include 
@@ -692,7 +692,7 @@ sysctl_kern_xen_balloon_min(SYSCTLFN_ARG
 	return 0;
 }
 
-/* Returns the current memory reservation of the domain */
+/* Returns the maximum memory reservation of the domain */
 static int
 sysctl_kern_xen_balloon_max(SYSCTLFN_ARGS)
 {



CVS commit: src/sys/arch/xen/xen

2011-12-26 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Dec 26 20:26:38 UTC 2011

Modified Files:
src/sys/arch/xen/xen: balloon.c

Log Message:
Properly protect the min/target variables from balloon_sc, not just target.

Use their reference directly instead of going through their opaque
sysctl_data storage. It makes the locking a bit more obvious.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/xen/xen/balloon.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/xen/xen/balloon.c
diff -u src/sys/arch/xen/xen/balloon.c:1.11 src/sys/arch/xen/xen/balloon.c:1.12
--- src/sys/arch/xen/xen/balloon.c:1.11	Tue Sep 20 00:12:24 2011
+++ src/sys/arch/xen/xen/balloon.c	Mon Dec 26 20:26:38 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: balloon.c,v 1.11 2011/09/20 00:12:24 jym Exp $ */
+/* $NetBSD: balloon.c,v 1.12 2011/12/26 20:26:38 jym Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
 #define BALLOONDEBUG 0
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.11 2011/09/20 00:12:24 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.12 2011/12/26 20:26:38 jym Exp $");
 
 #include 
 #include 
@@ -129,18 +129,17 @@ struct balloon_xenbus_softc {
 	device_t sc_dev;
 	struct sysctllog *sc_log;
 
-	kmutex_t balloon_mtx;   /* Protects condvar and target (below) */
+	kmutex_t balloon_mtx;   /* Protects condvar, target and res_min (below) */
 	kcondvar_t balloon_cv;  /* Condvar variable for target (below) */
 	size_t balloon_target;  /* Target domain reservation size in pages. */
-	xen_pfn_t *sc_mfn_list; /* List of MFNs passed from/to balloon */
+	/* Minimum amount of memory reserved by domain, in KiB */
+	uint64_t balloon_res_min;
 
+	xen_pfn_t *sc_mfn_list; /* List of MFNs passed from/to balloon */
 	pool_cache_t bpge_pool; /* pool cache for balloon page entries */
 	/* linked list for tracking pages used by balloon */
 	SLIST_HEAD(, balloon_page_entry) balloon_page_entries;
 	size_t balloon_num_page_entries;
-
-	/* Minimum amount of memory reserved by domain, in KiB */
-	uint64_t balloon_res_min;
 };
 
 static size_t xenmem_get_currentreservation(void);
@@ -607,21 +606,25 @@ balloon_xenbus_watcher(struct xenbus_wat
 		   unsigned int len)
 {
 	size_t new_target;
-	uint64_t target_kb  = balloon_xenbus_read_target();
-	uint64_t target_min = balloon_sc->balloon_res_min;
-	uint64_t target_max = BALLOON_PAGES_TO_KB(xenmem_get_maxreservation());
+	uint64_t target_kb, target_max, target_min;
 
+	target_kb = balloon_xenbus_read_target();
 	if (target_kb == 0) {
 		/* bogus -- just return */
 		return;
 	}
 
+	mutex_enter(&balloon_sc->balloon_mtx);
+	target_min = balloon_sc->balloon_res_min;
+	mutex_exit(&balloon_sc->balloon_mtx);
 	if (target_kb < target_min) {
 		device_printf(balloon_sc->sc_dev,
 		"new target %"PRIu64" is below min %"PRIu64"\n",
 		target_kb, target_min);
 		return;
 	}
+
+	target_max = BALLOON_PAGES_TO_KB(xenmem_get_maxreservation());
 	if (target_kb > target_max) {
 		/*
 		 * Should not happen. Hypervisor should block balloon
@@ -664,7 +667,10 @@ sysctl_kern_xen_balloon_min(SYSCTLFN_ARG
 
 	node = *rnode;
 	node.sysctl_data = &newval;
-	newval = *(u_quad_t *)rnode->sysctl_data;
+
+	mutex_enter(&balloon_sc->balloon_mtx);
+	newval = balloon_sc->balloon_res_min;
+	mutex_exit(&balloon_sc->balloon_mtx);
 
 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
 	if (error || newp == NULL)
@@ -678,8 +684,10 @@ sysctl_kern_xen_balloon_min(SYSCTLFN_ARG
 		return EPERM;
 	}
 
-	if (*(u_quad_t *)rnode->sysctl_data != newval)
-		atomic_swap_64((u_quad_t *)rnode->sysctl_data, newval);
+	mutex_enter(&balloon_sc->balloon_mtx);
+	if (balloon_sc->balloon_res_min != newval)
+		balloon_sc->balloon_res_min = newval;
+	mutex_exit(&balloon_sc->balloon_mtx);
 
 	return 0;
 }
@@ -729,8 +737,11 @@ sysctl_kern_xen_balloon_target(SYSCTLFN_
 
 	node = *rnode;
 	node.sysctl_data = &newval;
-	/* we are just reading the value of target, no lock needed */
-	newval = BALLOON_PAGES_TO_KB(*(u_quad_t*)rnode->sysctl_data);
+
+	mutex_enter(&balloon_sc->balloon_mtx);
+	newval = BALLOON_PAGES_TO_KB(balloon_sc->balloon_target);
+	res_min = balloon_sc->balloon_res_min;
+	mutex_exit(&balloon_sc->balloon_mtx);
 
 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
 	if (newp == NULL || error != 0) {
@@ -747,7 +758,6 @@ sysctl_kern_xen_balloon_target(SYSCTLFN_
 	 * sorry.
 	 */
 	res_max = BALLOON_PAGES_TO_KB(xenmem_get_maxreservation());
-	res_min = balloon_sc->balloon_res_min;
 	if (newval < res_min || newval > res_max) {
 #if BALLOONDEBUG
 		device_printf(balloon_sc->sc_dev,
@@ -799,16 +809,14 @@ sysctl_kern_xen_balloon_setup(struct bal
 	CTLTYPE_QUAD, "current",
 	SYSCTL_DESCR("Domain's current memory reservation from "
 		"hypervisor, in KiB."),
-	sysctl_kern_xen_balloon_current, 0,
-	NULL, 0,
+	sysctl_kern_xen_balloon_current, 0, NULL, 0,
 	CTL_CREATE, CTL_E

CVS commit: src/sys/secmodel/keylock

2011-12-08 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Dec  8 11:01:59 UTC 2011

Modified Files:
src/sys/secmodel/keylock: secmodel_keylock.c

Log Message:
build fix for keylock secmodel(9).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/secmodel/keylock/secmodel_keylock.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/secmodel/keylock/secmodel_keylock.c
diff -u src/sys/secmodel/keylock/secmodel_keylock.c:1.6 src/sys/secmodel/keylock/secmodel_keylock.c:1.7
--- src/sys/secmodel/keylock/secmodel_keylock.c:1.6	Sun Dec  4 19:25:00 2011
+++ src/sys/secmodel/keylock/secmodel_keylock.c	Thu Dec  8 11:01:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_keylock.c,v 1.6 2011/12/04 19:25:00 jym Exp $ */
+/* $NetBSD: secmodel_keylock.c,v 1.7 2011/12/08 11:01:59 jym Exp $ */
 /*-
  * Copyright (c) 2009 Marc Balmer 
  * Copyright (c) 2006 Elad Efrat 
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_keylock.c,v 1.6 2011/12/04 19:25:00 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_keylock.c,v 1.7 2011/12/08 11:01:59 jym Exp $");
 
 #include 
 #include 
@@ -70,10 +70,13 @@ __KERNEL_RCSID(0, "$NetBSD: secmodel_key
 
 #include 
 
+#include 
 #include 
 
 static kauth_listener_t l_system, l_process, l_network, l_machdep, l_device;
 
+static secmodel_t keylock_sm;
+
 SYSCTL_SETUP(sysctl_security_keylock_setup,
 "sysctl security keylock setup")
 {
@@ -142,7 +145,7 @@ secmodel_keylock_stop(void)
 	kauth_unlisten_scope(l_machdep);
 	kauth_unlisten_scope(l_device);
 
-	error = secmodel_deregister(&keylock_sm);
+	error = secmodel_deregister(keylock_sm);
 	if (error != 0)
 		printf("secmodel_keylock_stop: secmodel_deregister "
 		"returned %d\n", error);



CVS commit: src

2011-12-05 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Dec  5 23:04:39 UTC 2011

Modified Files:
src: build.sh

Log Message:
do_sys_sync() is part of vfs, hence rumpvfs. Used by pmf(9) during
device suspend, so explicitly link against rumpvfs to resolve that
symbol when linking rumpdev.

Unbreaks "rumptest" target.


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/build.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/build.sh
diff -u src/build.sh:1.251 src/build.sh:1.252
--- src/build.sh:1.251	Mon Oct 17 16:22:12 2011
+++ src/build.sh	Mon Dec  5 23:04:39 2011
@@ -1,5 +1,5 @@
 #! /usr/bin/env sh
-#	$NetBSD: build.sh,v 1.251 2011/10/17 16:22:12 mbalmer Exp $
+#	$NetBSD: build.sh,v 1.252 2011/12/05 23:04:39 jym Exp $
 #
 # Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1632,7 +1632,7 @@ createmakewrapper()
 	eval cat <

CVS commit: src/distrib/sets/lists/modules

2011-12-04 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Dec  5 02:04:34 UTC 2011

Modified Files:
src/distrib/sets/lists/modules: mi

Log Message:
Set list fix...


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/distrib/sets/lists/modules/mi

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/modules/mi
diff -u src/distrib/sets/lists/modules/mi:1.38 src/distrib/sets/lists/modules/mi:1.39
--- src/distrib/sets/lists/modules/mi:1.38	Thu Nov 24 21:46:15 2011
+++ src/distrib/sets/lists/modules/mi	Mon Dec  5 02:04:34 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.38 2011/11/24 21:46:15 ahoka Exp $
+# $NetBSD: mi,v 1.39 2011/12/05 02:04:34 jym Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -143,6 +143,8 @@
 ./@MODULEDIR@/sdt/sdt.kmod			base-kernel-modules	kmod,dtrace
 ./@MODULEDIR@/secmodel_bsd44			base-kernel-modules	kmod
 ./@MODULEDIR@/secmodel_bsd44/secmodel_bsd44.kmod	base-kernel-modules	kmod
+./@MODULEDIR@/secmodel_extensions		base-kernel-modules	kmod
+./@MODULEDIR@/secmodel_extensions/secmodel_extensions.kmod	base-kernel-modules	kmod
 ./@MODULEDIR@/secmodel_overlay			base-kernel-modules	kmod
 ./@MODULEDIR@/secmodel_overlay/secmodel_overlay.kmod	base-kernel-modules	kmod
 ./@MODULEDIR@/securelevel			base-kernel-modules	kmod



CVS commit: src/sys/secmodel/securelevel

2011-12-04 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Dec  5 00:13:31 UTC 2011

Modified Files:
src/sys/secmodel/securelevel: secmodel_securelevel.c

Log Message:
secmodel_eval(9) may want to access securelevel before it is set
to the right value, so init it first before registering secmodel(9).


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 \
src/sys/secmodel/securelevel/secmodel_securelevel.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/secmodel/securelevel/secmodel_securelevel.c
diff -u src/sys/secmodel/securelevel/secmodel_securelevel.c:1.23 src/sys/secmodel/securelevel/secmodel_securelevel.c:1.24
--- src/sys/secmodel/securelevel/secmodel_securelevel.c:1.23	Sun Dec  4 19:25:00 2011
+++ src/sys/secmodel/securelevel/secmodel_securelevel.c	Mon Dec  5 00:13:30 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_securelevel.c,v 1.23 2011/12/04 19:25:00 jym Exp $ */
+/* $NetBSD: secmodel_securelevel.c,v 1.24 2011/12/05 00:13:30 jym Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.23 2011/12/04 19:25:00 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.24 2011/12/05 00:13:30 jym Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_insecure.h"
@@ -205,6 +205,7 @@ securelevel_modcmd(modcmd_t cmd, void *a
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:
+		secmodel_securelevel_init();
 		error = secmodel_register(&securelevel_sm,
 		SECMODEL_SECURELEVEL_ID, SECMODEL_SECURELEVEL_NAME,
 		NULL, securelevel_eval, NULL);
@@ -212,7 +213,6 @@ securelevel_modcmd(modcmd_t cmd, void *a
 			printf("securelevel_modcmd::init: secmodel_register "
 			"returned %d\n", error);
 
-		secmodel_securelevel_init();
 		secmodel_securelevel_start();
 		sysctl_security_securelevel_setup(&securelevel_sysctl_log);
 		break;



CVS commit: src/share/man/man9

2011-12-04 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Dec  4 23:59:25 UTC 2011

Modified Files:
src/share/man/man9: kauth.9

Log Message:
KAUTH_GENERIC_CANSEE is no more.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/share/man/man9/kauth.9

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/man9/kauth.9
diff -u src/share/man/man9/kauth.9:1.94 src/share/man/man9/kauth.9:1.95
--- src/share/man/man9/kauth.9:1.94	Sun Dec  4 21:52:37 2011
+++ src/share/man/man9/kauth.9	Sun Dec  4 23:59:25 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: kauth.9,v 1.94 2011/12/04 21:52:37 jym Exp $
+.\" $NetBSD: kauth.9,v 1.95 2011/12/04 23:59:25 jym Exp $
 .\"
 .\" Copyright (c) 2005, 2006 Elad Efrat 
 .\" All rights reserved.
@@ -155,17 +155,6 @@ Checks whether the credentials belong to
 Using this request is strongly discouraged and should only be done as a
 temporary place-holder, as it is breaking the separation between the
 interface for authorization requests from the back-end implementation.
-.It Dv KAUTH_GENERIC_CANSEE
-Checks whether an object with one set of credentials can access
-information about another object, possibly with a different set of
-credentials.
-.Pp
-.Ar arg0
-contains the credentials of the object looked at.
-.Pp
-This request should be issued only in cases where generic credentials
-check is required; otherwise it is recommended to use the object-specific
-routines.
 .El
 .Ss System Scope
 The system scope,



CVS commit: src/share/examples/secmodel

2011-12-04 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Dec  4 23:55:36 UTC 2011

Modified Files:
src/share/examples/secmodel: example.h secmodel_example.c

Log Message:
Update secmodel_examples to better describe the secmodel(9) API.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/examples/secmodel/example.h
cvs rdiff -u -r1.25 -r1.26 src/share/examples/secmodel/secmodel_example.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/examples/secmodel/example.h
diff -u src/share/examples/secmodel/example.h:1.1 src/share/examples/secmodel/example.h:1.2
--- src/share/examples/secmodel/example.h:1.1	Fri Sep 15 15:49:29 2006
+++ src/share/examples/secmodel/example.h	Sun Dec  4 23:55:36 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: example.h,v 1.1 2006/09/15 15:49:29 elad Exp $ */
+/* $NetBSD: example.h,v 1.2 2011/12/04 23:55:36 jym Exp $ */
 
 /* 
  * This file is placed in the public domain.
@@ -7,7 +7,7 @@
 #ifndef _SECMODEL_EXAMPLE_EXAMPLE_H_
 #define	_SECMODEL_EXAMPLE_EXAMPLE_H_
 
-void secmodel_example_init(void);
-void secmodel_example_start(void);
+#define SECMODEL_EXAMPLE_ID   "id.unique.secmodel.example"
+#define SECMODEL_EXAMPLE_NAME "Example security model"
 
 #endif /* !_SECMODEL_EXAMPLE_EXAMPLE_H_ */

Index: src/share/examples/secmodel/secmodel_example.c
diff -u src/share/examples/secmodel/secmodel_example.c:1.25 src/share/examples/secmodel/secmodel_example.c:1.26
--- src/share/examples/secmodel/secmodel_example.c:1.25	Thu Feb 28 17:07:49 2008
+++ src/share/examples/secmodel/secmodel_example.c	Sun Dec  4 23:55:36 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_example.c,v 1.25 2008/02/28 17:07:49 elad Exp $ */
+/* $NetBSD: secmodel_example.c,v 1.26 2011/12/04 23:55:36 jym Exp $ */
 
 /*
  * This file is placed in the public domain.
@@ -13,42 +13,52 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_example.c,v 1.25 2008/02/28 17:07:49 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_example.c,v 1.26 2011/12/04 23:55:36 jym Exp $");
 
 #include 
 #include 
 #include 
 
+#include 
 #include 
 
 #include 
-
 #include 
 
-/*
- * Initialize the security model.
- */
-void
-secmodel_example_init(void)
-{
-	return;
-}
+MODULE(MODULE_CLASS_SECMODEL, secmodel_example, NULL);
+
+static secmodel_t example_sm;
+static struct sysctllog *sysctl_example_log;
+
+static kauth_listener_t l_device, l_generic, l_machdep, l_network,
+l_process, l_system, l_vnode;
+
+static void secmodel_example_init(void);
+static void secmodel_example_start(void);
+static void secmodel_example_stop(void);
+
+static void sysctl_security_example_setup(struct sysctllog **);
+
+static int secmodel_example_device_cb(kauth_cred_t, kauth_action_t, void *,
+void *, void *, void *, void *);
+static int secmodel_example_generic_cb(kauth_cred_t, kauth_action_t, void *,
+void *, void *, void *, void *);
+static int secmodel_example_machdep_cb(kauth_cred_t, kauth_action_t, void *,
+void *, void *, void *, void *);
+static int secmodel_example_network_cb(kauth_cred_t, kauth_action_t, void *,
+void *, void *, void *, void *);
+static int secmodel_example_process_cb(kauth_cred_t, kauth_action_t, void *,
+void *, void *, void *, void *);
+static int secmodel_example_system_cb(kauth_cred_t, kauth_action_t, void *,
+void *, void *, void *, void *);
+static int secmodel_example_vnode_cb(kauth_cred_t, kauth_action_t, void *,
+void *, void *, void *, void *);
 
 /*
- * If the security model is to be used as an LKM, this routine should be
- * changed, because otherwise creating permanent sysctl(9) nodes will fail.
- *
- * To make it work, the prototype should be changed to something like:
- *
- *	void secmodel_example_sysctl(void)
- *
- * and it should be called from secmodel_start().
- *
- * In addition, the CTLFLAG_PERMANENT flag must be removed from all the
- * nodes.
+ * Creates sysctl(7) entries expected from a security model.
  */
-SYSCTL_SETUP(sysctl_security_example_setup,
-"sysctl security example setup")
+static void
+sysctl_security_example_setup(struct sysctllog **clog)
 {
 	const struct sysctlnode *rnode;
 
@@ -74,37 +84,131 @@ SYSCTL_SETUP(sysctl_security_example_set
 	sysctl_createv(clog, 0, &rnode, NULL,
 		   CTLFLAG_PERMANENT,
 		   CTLTYPE_STRING, "name", NULL,
-		   NULL, 0, __UNCONST("Example"), 0
+		   NULL, 0, __UNCONST(SECMODEL_EXAMPLE_NAME), 0
 		   CTL_CREATE, CTL_EOL);
+}
+
+/*
+ * Initialize the security model.
+ */
+static void
+secmodel_example_init(void)
+{
 
+	/* typically used to set static variables and states */
 }
 
 /*
  * Start the security model.
  */
-void
-secmodel_start(void)
+static void
+secmodel_example_start(void)
+{
+
+	/* register listeners */
+	l_device = kauth_listen_scope(KAUTH_SCOPE_DEVICE,
+	secmodel_example_device_cb, NULL);
+	l_generic = kauth_listen_scope(KAUTH_SCOPE_GENERIC,
+	secmodel_example_generic_cb, NULL);
+	l_

CVS commit: src/sys/modules

2011-12-04 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Dec  4 23:13:54 UTC 2011

Modified Files:
src/sys/modules: Makefile
Added Files:
src/sys/modules/secmodel_extensions: Makefile

Log Message:
Hook secmodel_extensions(9) to modules build.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/modules/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/secmodel_extensions/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.99 src/sys/modules/Makefile:1.100
--- src/sys/modules/Makefile:1.99	Thu Nov 24 15:52:24 2011
+++ src/sys/modules/Makefile	Sun Dec  4 23:13:54 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.99 2011/11/24 15:52:24 ahoka Exp $
+#	$NetBSD: Makefile,v 1.100 2011/12/04 23:13:54 jym Exp $
 
 .include 
 
@@ -61,6 +61,7 @@ SUBDIR+=	puffs
 SUBDIR+=	putter
 SUBDIR+=	scsiverbose
 SUBDIR+=	secmodel_bsd44
+SUBDIR+=	secmodel_extensions
 SUBDIR+=	secmodel_overlay
 SUBDIR+=	securelevel
 SUBDIR+=	smbfs

Added files:

Index: src/sys/modules/secmodel_extensions/Makefile
diff -u /dev/null src/sys/modules/secmodel_extensions/Makefile:1.1
--- /dev/null	Sun Dec  4 23:13:54 2011
+++ src/sys/modules/secmodel_extensions/Makefile	Sun Dec  4 23:13:54 2011
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2011/12/04 23:13:54 jym Exp $
+
+.include "../Makefile.inc"
+
+.PATH:	${S}/secmodel/extensions
+
+KMOD=	secmodel_extensions
+SRCS=	secmodel_extensions.c
+
+.include 



CVS commit: src/share/man/man9

2011-12-04 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Dec  4 21:52:37 UTC 2011

Modified Files:
src/share/man/man9: kauth.9

Log Message:
GETPARAMS => GETPARAM
SETPARAMS => SETPARAM


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/share/man/man9/kauth.9

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/man9/kauth.9
diff -u src/share/man/man9/kauth.9:1.93 src/share/man/man9/kauth.9:1.94
--- src/share/man/man9/kauth.9:1.93	Tue Nov  8 10:56:59 2011
+++ src/share/man/man9/kauth.9	Sun Dec  4 21:52:37 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: kauth.9,v 1.93 2011/11/08 10:56:59 wiz Exp $
+.\" $NetBSD: kauth.9,v 1.94 2011/12/04 21:52:37 jym Exp $
 .\"
 .\" Copyright (c) 2005, 2006 Elad Efrat 
 .\" All rights reserved.
@@ -476,9 +476,9 @@ or
 Checks whether viewing the scheduler affinity is allowed.
 .It Dv KAUTH_PROCESS_SCHEDULER_SETAFFINITY
 Checks whether setting the scheduler affinity is allowed.
-.It Dv KAUTH_PROCESS_SCHEDULER_GETPARAMS
+.It Dv KAUTH_PROCESS_SCHEDULER_GETPARAM
 Checks whether viewing the scheduler policy and parameters is allowed.
-.It Dv KAUTH_PROCESS_SCHEDULER_SETPARAMS
+.It Dv KAUTH_PROCESS_SCHEDULER_SETPARAM
 Checks whether modifying the scheduler policy and parameters is allowed.
 .It Dv KAUTH_PROCESS_SIGNAL
 Checks whether an object with one set of credentials can post signals



CVS commit: src

2011-12-04 Thread Jean-Yves Migeon
ways default to securelevel \-1.
+causing it to always default to
+.Em securelevel
+\-1.
 .Pp
 In order for this protection to be effective, the administrator
 must ensure that no program that is run while the security level
@@ -203,10 +226,54 @@ The system security level.
 This level may be raised by processes with appropriate privilege.
 It may only be lowered by process 1 (init).
 .El
+.Sh FUNCTIONS
+.Nm
+exposes a
+.Xr secmodel_eval 9
+evaluation routine
+to test whether the current
+.Em securelevel
+is above a certain threshold level or not.
+.Pp
+The parameters to
+.Xr secmodel_eval 9
+are:
+.Bl -tag -compact -width x
+.It id
+the unique identifier of
+.Nm :
+.Qo Dv org.netbsd.secmodel.securelevel Qc .
+.It what
+a string,
+.Qo Dv is-securelevel-above Qc
+.It arg
+a reference to an
+.Dv int
+representing the threshold level.
+.It ret
+a boolean, set by
+.Nm
+to
+.Dv true
+when the
+.Em securelevel
+is strictly above
+the threshold level,
+.Dv false
+otherwise.
+.El
+.Sh RETURN TYPES
+If successful, the evaluation returns 0 with the
+.Fa ret
+argument being either
+.Dv true
+or
+.Dv false .
 .Sh SEE ALSO
 .Xr kauth 9 ,
 .Xr secmodel 9 ,
-.Xr secmodel_bsd44 9
+.Xr secmodel_bsd44 9 ,
+.Xr secmodel_eval 9
 .Sh AUTHORS
 .An Elad Efrat Aq e...@netbsd.org
 .Sh BUGS

Index: src/share/man/man9/secmodel_suser.9
diff -u src/share/man/man9/secmodel_suser.9:1.4 src/share/man/man9/secmodel_suser.9:1.5
--- src/share/man/man9/secmodel_suser.9:1.4	Sat Oct  3 07:37:01 2009
+++ src/share/man/man9/secmodel_suser.9	Sun Dec  4 21:08:45 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: secmodel_suser.9,v 1.4 2009/10/03 07:37:01 wiz Exp $
+.\" $NetBSD: secmodel_suser.9,v 1.5 2011/12/04 21:08:45 jym Exp $
 .\"
 .\" Copyright (c) 2009 Elad Efrat 
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 2, 2009
+.Dd December 4, 2011
 .Dt SECMODEL_SUSER 9
 .Os
 .Sh NAME
@@ -40,46 +40,53 @@ The
 .Em super-user
 is the host administrator, considered to have higher privileges than other
 users.
+.Sh FUNCTIONS
+.Nm
+exposes a
+.Xr secmodel_eval 9
+evaluation routine
+to test whether a set of credentials can be assimilated to
+.Em super-user
+credentials or not.
 .Pp
-The following
-.Xr sysctl 3
-variables are exported:
-.Bl -tag -width compact
-.It security.models.suser.curtain
-If non-zero, will filter returned objects according to the user-id
-requesting information about them, preventing from users any access to
-objects they don't own.
-.Pp
-At the moment, it affects
-.Xr ps 1 ,
-.Xr netstat 1
-(for
-.Dv PF_INET ,
-.Dv PF_INET6 ,
-and
-.Dv PF_UNIX
-PCBs), and
-.Xr w 1 .
-.It security.models.suser.usermount
-Allow non-superuser mounts.
-.Pp
-If non-zero, file-systems are allowed to be mounted by an ordinary user who
-owns the point
-.Ar node
-and has at least read access to the
-.Ar special
-device
-.Xr mount 8
-arguments.
-Finally, the flags
-.Cm nosuid
-and
-.Cm nodev
-must be given for non-superuser mounts.
+The parameters to
+.Xr secmodel_eval 9
+are:
+.Bl -tag -compact -width x
+.It id
+the unique identifier of
+.Nm :
+.Qo Dv org.netbsd.secmodel.suser Qc
+.It what
+a string,
+.Qo Dv is-root Qc .
+.It arg
+the
+.Xr kauth 9
+credentials
+.Po Fa kauth_cred_t Pc
+of the caller.
+.It ret
+a boolean, set by
+.Nm
+to
+.Dv true
+when the credentials are equivalent to
+.Em super-user ,
+.Dv false
+otherwise.
 .El
+.Sh RETURN TYPES
+If successful, the evaluation returns 0 with the
+.Fa ret
+argument being either
+.Dv true
+or
+.Dv false .
 .Sh SEE ALSO
 .Xr kauth 9 ,
 .Xr secmodel 9 ,
-.Xr secmodel_bsd44 9
+.Xr secmodel_bsd44 9 ,
+.Xr secmodel_eval 9
 .Sh AUTHORS
 .An Elad Efrat Aq e...@netbsd.org

Added files:

Index: src/share/man/man9/secmodel_extensions.9
diff -u /dev/null src/share/man/man9/secmodel_extensions.9:1.1
--- /dev/null	Sun Dec  4 21:08:46 2011
+++ src/share/man/man9/secmodel_extensions.9	Sun Dec  4 21:08:45 2011
@@ -0,0 +1,120 @@
+.\" $NetBSD: secmodel_extensions.9,v 1.1 2011/12/04 21:08:45 jym Exp $
+.\"
+.\" Copyright (c) 2011 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Jean-Yves Migeon 
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED 

CVS commit: src/sys/secmodel/extensions

2011-12-04 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Dec  4 21:04:51 UTC 2011

Modified Files:
src/sys/secmodel/extensions: secmodel_extensions.c

Log Message:
When user_set_cpu_affinity is non-zero, only allow users to modify
the CPU affinity of the LWPs they own.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/secmodel/extensions/secmodel_extensions.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/secmodel/extensions/secmodel_extensions.c
diff -u src/sys/secmodel/extensions/secmodel_extensions.c:1.1 src/sys/secmodel/extensions/secmodel_extensions.c:1.2
--- src/sys/secmodel/extensions/secmodel_extensions.c:1.1	Sun Dec  4 19:25:00 2011
+++ src/sys/secmodel/extensions/secmodel_extensions.c	Sun Dec  4 21:04:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_extensions.c,v 1.1 2011/12/04 19:25:00 jym Exp $ */
+/* $NetBSD: secmodel_extensions.c,v 1.2 2011/12/04 21:04:51 jym Exp $ */
 /*-
  * Copyright (c) 2011 Elad Efrat 
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_extensions.c,v 1.1 2011/12/04 19:25:00 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_extensions.c,v 1.2 2011/12/04 21:04:51 jym Exp $");
 
 #include 
 #include 
@@ -413,7 +413,10 @@ secmodel_extensions_process_cb(kauth_cre
 
 	case KAUTH_PROCESS_SCHEDULER_SETAFFINITY:
 		if (user_set_cpu_affinity != 0) {
-			result = KAUTH_RESULT_ALLOW;
+			struct proc *p = arg0;
+
+			if (kauth_cred_uidmatch(cred, p->p_cred))
+result = KAUTH_RESULT_ALLOW;
 		}
 		break;
 



CVS commit: src/share/man/man9

2011-12-04 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Dec  4 18:34:20 UTC 2011

Modified Files:
src/share/man/man9: sysctl.9

Log Message:
- add the bool type for IMMEDIATE flag.
- minor tweak to the handler example: it leaks 't' (on stack)
  when passed to sysctl_lookup(9), as it copyout its content via
  sysctl_data. That would not be the case if CTLFLAG_IMMEDIATE flag
  was set for this node but the example does not preclude that.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/share/man/man9/sysctl.9

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/man9/sysctl.9
diff -u src/share/man/man9/sysctl.9:1.17 src/share/man/man9/sysctl.9:1.18
--- src/share/man/man9/sysctl.9:1.17	Sun May 16 05:18:35 2010
+++ src/share/man/man9/sysctl.9	Sun Dec  4 18:34:20 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sysctl.9,v 1.17 2010/05/16 05:18:35 jruoho Exp $
+.\"	$NetBSD: sysctl.9,v 1.18 2011/12/04 18:34:20 jym Exp $
 .\"
 .\" Copyright (c) 2004 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 16, 2010
+.Dd December 4, 2011
 .Dt SYSCTL 9
 .Os
 .Sh NAME
@@ -421,6 +421,7 @@ If the
 flag is set, the
 .Fa qv
 argument will be interpreted as the initial value for the new
+.Dq bool ,
 .Dq int
 or
 .Dq quad
@@ -504,6 +505,8 @@ sysctl_helper(SYSCTLFN_ARGS)
 	struct sysctlnode node;
 	int t, error;
 
+	t = *(int *)rnode-\*[Gt]sysctl_data;
+
 	node = *rnode;
 	node.sysctl_data = \*[Am]t;
 	error = sysctl_lookup(SYSCTLFN_CALL(\*[Am]node));
@@ -513,7 +516,7 @@ sysctl_helper(SYSCTLFN_ARGS)
 	if (t \*[Lt] 0 || t \*[Gt] 20)
 		return (EINVAL);
 
-	*(int*)rnode-\*[Gt]sysctl_data = t;
+	*(int *)rnode-\*[Gt]sysctl_data = t;
 	return (0);
 }
 .Ed



CVS commit: src/sys/secmodel

2011-11-28 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Nov 28 22:28:34 UTC 2011

Modified Files:
src/sys/secmodel/bsd44: secmodel_bsd44.c
src/sys/secmodel/overlay: secmodel_overlay.c

Log Message:
The secmodel(9)s init, start and stop routines are managed by each
secmodel module(7), so there is no point in calling suser/securelevel
routines from bsd44. This leads to unwanted cross-secmodel dependencies.

Do not call secmodel_bsd44_init() from secmodel_overlay_init(). Doing so
resets all curtain/securelevel values, which is not really needed when
loading an overlay filter.

Remove the secmodel_register/deregister comments, they will be
implemented differently in an upcoming patch.

ok elad@ (via private mail).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/secmodel/bsd44/secmodel_bsd44.c
cvs rdiff -u -r1.10 -r1.11 src/sys/secmodel/overlay/secmodel_overlay.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/secmodel/bsd44/secmodel_bsd44.c
diff -u src/sys/secmodel/bsd44/secmodel_bsd44.c:1.13 src/sys/secmodel/bsd44/secmodel_bsd44.c:1.14
--- src/sys/secmodel/bsd44/secmodel_bsd44.c:1.13	Fri Oct  2 18:50:13 2009
+++ src/sys/secmodel/bsd44/secmodel_bsd44.c	Mon Nov 28 22:28:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_bsd44.c,v 1.13 2009/10/02 18:50:13 elad Exp $ */
+/* $NetBSD: secmodel_bsd44.c,v 1.14 2011/11/28 22:28:33 jym Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_bsd44.c,v 1.13 2009/10/02 18:50:13 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_bsd44.c,v 1.14 2011/11/28 22:28:33 jym Exp $");
 
 #include 
 #include 
@@ -79,26 +79,19 @@ sysctl_security_bsd44_setup(struct sysct
 void
 secmodel_bsd44_init(void)
 {
-	secmodel_suser_init();
-	secmodel_securelevel_init();
+
 }
 
 void
 secmodel_bsd44_start(void)
 {
-	secmodel_suser_start();
-	secmodel_securelevel_start();
 
-	/* secmodel_register(); */
 }
 
 void
 secmodel_bsd44_stop(void)
 {
-	secmodel_suser_stop();
-	secmodel_securelevel_stop();
 
-	/* secmodel_deregister(); */
 }
 
 static int

Index: src/sys/secmodel/overlay/secmodel_overlay.c
diff -u src/sys/secmodel/overlay/secmodel_overlay.c:1.10 src/sys/secmodel/overlay/secmodel_overlay.c:1.11
--- src/sys/secmodel/overlay/secmodel_overlay.c:1.10	Fri Oct  2 18:50:13 2009
+++ src/sys/secmodel/overlay/secmodel_overlay.c	Mon Nov 28 22:28:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_overlay.c,v 1.10 2009/10/02 18:50:13 elad Exp $ */
+/* $NetBSD: secmodel_overlay.c,v 1.11 2011/11/28 22:28:34 jym Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_overlay.c,v 1.10 2009/10/02 18:50:13 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_overlay.c,v 1.11 2011/11/28 22:28:34 jym Exp $");
 
 #include 
 #include 
@@ -123,8 +123,6 @@ secmodel_overlay_init(void)
 	secmodel_suser_device_cb, NULL);
 	kauth_listen_scope(OVERLAY_ISCOPE_DEVICE,
 	secmodel_securelevel_device_cb, NULL);
-
-	secmodel_bsd44_init();
 }
 
 void
@@ -178,8 +176,6 @@ secmodel_overlay_start(void)
 	secmodel_overlay_device_cb, NULL);
 	l_vnode = kauth_listen_scope(KAUTH_SCOPE_VNODE,
 	secmodel_overlay_vnode_cb, NULL);
-
-	/* secmodel_register(); */
 }
 
 /*
@@ -205,7 +201,8 @@ secmodel_overlay_modcmd(modcmd_t cmd, vo
 	switch (cmd) {
 	case MODULE_CMD_INIT:
 		secmodel_overlay_init();
-		secmodel_bsd44_stop();
+		secmodel_suser_stop();
+		secmodel_securelevel_stop();
 		secmodel_overlay_start();
 		sysctl_security_overlay_setup(&sysctl_overlay_log);
 		break;



CVS commit: src/sys/secmodel/securelevel

2011-11-28 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Nov 28 20:57:52 UTC 2011

Modified Files:
src/sys/secmodel/securelevel: secmodel_securelevel.c

Log Message:
Whitespace fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/sys/secmodel/securelevel/secmodel_securelevel.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/secmodel/securelevel/secmodel_securelevel.c
diff -u src/sys/secmodel/securelevel/secmodel_securelevel.c:1.21 src/sys/secmodel/securelevel/secmodel_securelevel.c:1.22
--- src/sys/secmodel/securelevel/secmodel_securelevel.c:1.21	Wed Nov 23 10:47:48 2011
+++ src/sys/secmodel/securelevel/secmodel_securelevel.c	Mon Nov 28 20:57:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_securelevel.c,v 1.21 2011/11/23 10:47:48 tls Exp $ */
+/* $NetBSD: secmodel_securelevel.c,v 1.22 2011/11/28 20:57:51 jym Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -28,14 +28,14 @@
 
 /*
  * This file contains kauth(9) listeners needed to implement the traditional
- * NetBSD securelevel. 
+ * NetBSD securelevel.
  *
  * The securelevel is a system-global indication on what operations are
  * allowed or not. It affects all users, including root.
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.21 2011/11/23 10:47:48 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.22 2011/11/28 20:57:51 jym Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_insecure.h"
@@ -71,7 +71,7 @@ static struct sysctllog *securelevel_sys
  */
 int
 secmodel_securelevel_sysctl(SYSCTLFN_ARGS)
-{   
+{
 	int newsecurelevel, error;
 	struct sysctlnode node;
 
@@ -81,7 +81,7 @@ secmodel_securelevel_sysctl(SYSCTLFN_ARG
 	error = sysctl_lookup(SYSCTLFN_CALL(&node));
 	if (error || newp == NULL)
 		return (error);
-
+
 	if ((newsecurelevel < securelevel) && (l->l_proc != initproc))
 		return (EPERM);
 
@@ -424,7 +424,7 @@ secmodel_securelevel_network_cb(kauth_cr
 	return (result);
 }
 
-/*  
+/*
  * kauth(9) listener
  *
  * Security model: Traditional NetBSD
@@ -462,7 +462,7 @@ secmodel_securelevel_machdep_cb(kauth_cr
  * kauth(9) listener
  *
  * Security model: Traditional NetBSD
- * Scope: Device 
+ * Scope: Device
  * Responsibility: Securelevel
  */
 int



CVS commit: src/doc

2011-11-24 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Nov 24 18:54:20 UTC 2011

Modified Files:
src/doc: CHANGES

Log Message:
xbdback(4) is MP-SAFE. Reorder list.


To generate a diff of this commit:
cvs rdiff -u -r1.1632 -r1.1633 src/doc/CHANGES

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.1632 src/doc/CHANGES:1.1633
--- src/doc/CHANGES:1.1632	Thu Nov 24 00:56:46 2011
+++ src/doc/CHANGES	Thu Nov 24 18:54:19 2011
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.1632 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.1633 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -1175,5 +1175,6 @@ Changes from NetBSD 5.0 to NetBSD 6.0:
 		support. [tsutsui 2020]
 	arm: Add TLS (thread local storage) support.  [joerg 2018]
 	m68k: Add TLS (thread local storage) support.  [joerg 2022]
-	resolvconf(8): import openresolv-3.4.5 [roy 2024]
 	audio: Audio drivers are now MP-safe. [jmcneill 2023]
+	xbdback(4): driver is now MP-SAFE. [jym 2023]
+	resolvconf(8): import openresolv-3.4.5 [roy 2024]



CVS commit: src/sys/arch/xen/xen

2011-11-23 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Nov 24 01:47:18 UTC 2011

Modified Files:
src/sys/arch/xen/xen: xbdback_xenbus.c

Log Message:
Deep rework of the xbdback(4) driver; it now uses a thread per instance
instead of continuations directly from shm callbacks or interrupt
handlers. The whole CPS design remains but is adapted to cope with
a thread model.

This patch allows scheduling away I/O requests of domains that behave
abnormally, or even destroy them if there is a need to (without thrashing
dom0 with lots of error messages at IPL_BIO).

I took this opportunity to make the driver MPSAFE, so multiple instances
can run concurrently. Moved from home-grown pool(9) queues to
pool_cache(9), and rework the callback mechanism so that it delegates
I/O processing to thread instead of handling it itself through the
continuation trampoline.

This one fixes the potential DoS many have seen in a dom0 when trying to
suspend a NetBSD domU with a corrupted I/O ring.

Benchmarks (build.sh release runs and bonnie++) do not show any
performance regression, the "new" driver is on-par with the "old" one.

ok bouyer@.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/xen/xen/xbdback_xenbus.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/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.51 src/sys/arch/xen/xen/xbdback_xenbus.c:1.52
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.51	Mon Nov 14 21:34:50 2011
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Thu Nov 24 01:47:18 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.51 2011/11/14 21:34:50 christos Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.52 2011/11/24 01:47:18 jym Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,23 +26,27 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.51 2011/11/14 21:34:50 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.52 2011/11/24 01:47:18 jym Exp $");
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -75,39 +79,54 @@ struct xbdback_io;
 struct xbdback_fragment;
 struct xbdback_instance;
 
-/* state of a xbdback instance */
-typedef enum {CONNECTED, DISCONNECTING, DISCONNECTED} xbdback_state_t;
+/*
+ * status of a xbdback instance:
+ * WAITING: xbdback instance is connected, waiting for requests
+ * RUN: xbdi thread must be woken up, I/Os have to be processed
+ * DISCONNECTING: the instance is closing, no more I/Os can be scheduled
+ * DISCONNECTED: no I/Os, no ring, the thread should terminate.
+ */
+typedef enum {WAITING, RUN, DISCONNECTING, DISCONNECTED} xbdback_state_t;
 
 /*
- * Since there are a variety of conditions that can block our I/O
- * processing, which isn't allowed to suspend its thread's execution,
- * such things will be done in a sort of continuation-passing style.
- * 
- * Return value is NULL to indicate that execution has blocked; if
- * it's finished, set xbdi->xbdi_cont (see below) to NULL and the return
- * doesn't matter.  Otherwise it's passed as the second parameter to
- * the new value of xbdi->xbdi_cont.
+ * Each xbdback instance is managed by a single thread that handles all
+ * the I/O processing. As there are a variety of conditions that can block,
+ * everything will be done in a sort of continuation-passing style.
+ *
+ * When the execution has to block to delay processing, for example to
+ * allow system to recover because of memory shortage (via shared memory
+ * callback), the return value of a continuation can be set to NULL. In that
+ * case, the thread will go back to sleeping and wait for the proper
+ * condition before it starts processing requests again from where it left.
+ * Continuation state is "stored" in the xbdback instance (xbdi_cont and
+ * xbdi_cont_aux), and should only be manipulated by the instance thread.
  *
+ * As xbdback(4) has to handle different sort of asynchronous events (Xen
+ * event channels, biointr() soft interrupts, xenbus commands), the xbdi_lock
+ * mutex is used to protect specific elements of the xbdback instance from
+ * concurrent access: thread status and ring access (when pushing responses).
+ * 
  * Here's how the call graph is supposed to be for a single I/O:
+ *
  * xbdback_co_main()
  *|
- *| --> xbdback_co_cache_doflush() or NULL
- *| |
- *| -- xbdback_co_cache_flush2() <- xbdback_co_flush_done() <--
- *|   |   |
- *|   |-> xbdback_co_cache_flush() -> xbdback_co_flush() --
+ 

CVS commit: src/sys/arch/x86/include

2011-11-22 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Wed Nov 23 01:16:56 UTC 2011

Modified Files:
src/sys/arch/x86/include: pmap.h

Log Message:
No more users of xpmap_update(). Use pmap_pte_*() functions now.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/x86/include/pmap.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/arch/x86/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.47 src/sys/arch/x86/include/pmap.h:1.48
--- src/sys/arch/x86/include/pmap.h:1.47	Wed Nov 23 00:56:56 2011
+++ src/sys/arch/x86/include/pmap.h	Wed Nov 23 01:16:55 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.47 2011/11/23 00:56:56 jym Exp $	*/
+/*	$NetBSD: pmap.h,v 1.48 2011/11/23 01:16:55 jym Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -440,22 +440,6 @@ xpmap_ptetomach(pt_entry_t *pte)
 	return (paddr_t) (((*up_pte) & PG_FRAME) + (((vaddr_t) pte) & (~PG_FRAME & ~VA_SIGN_MASK)));
 }
 
-/*
- * xpmap_update()
- * Update an active pt entry with Xen
- * Equivalent to *pte = npte
- */
-
-static __inline void
-xpmap_update (pt_entry_t *pte, pt_entry_t npte)
-{
-int s = splvm();
-
-xpq_queue_pte_update(xpmap_ptetomach(pte), npte);
-xpq_flush_queue();
-splx(s);
-}
-
 /* Xen helpers to change bits of a pte */
 #define XPMAP_UPDATE_DIRECT	1	/* Update direct map entry flags too */
 



CVS commit: src/sys/arch/amd64/amd64

2011-11-22 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Wed Nov 23 01:15:02 UTC 2011

Modified Files:
src/sys/arch/amd64/amd64: db_memrw.c

Log Message:
Kill dependency to xpmap_update(), and use setbits/clearbits to update
kernel PTE rights.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/amd64/amd64/db_memrw.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/amd64/amd64/db_memrw.c
diff -u src/sys/arch/amd64/amd64/db_memrw.c:1.8 src/sys/arch/amd64/amd64/db_memrw.c:1.9
--- src/sys/arch/amd64/amd64/db_memrw.c:1.8	Mon Dec 20 00:25:24 2010
+++ src/sys/arch/amd64/amd64/db_memrw.c	Wed Nov 23 01:15:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.8 2010/12/20 00:25:24 matt Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.9 2011/11/23 01:15:02 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -51,9 +51,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.8 2010/12/20 00:25:24 matt Exp $");
-
-#include "opt_xen.h"
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.9 2011/11/23 01:15:02 jym Exp $");
 
 #include 
 #include 
@@ -99,7 +97,7 @@ db_read_bytes(vaddr_t addr, size_t size,
 static void
 db_write_text(vaddr_t addr, size_t size, const char *data)
 {
-	pt_entry_t *pte, oldpte, tmppte;
+	pt_entry_t *ppte, pte;
 	vaddr_t pgva;
 	size_t limit;
 	char *dst;
@@ -113,10 +111,10 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the PTE for the page.
 		 */
-		pte = kvtopte(addr);
-		oldpte = *pte;
+		ppte = kvtopte(addr);
+		pte = *ppte;
 
-		if ((oldpte & PG_V) == 0) {
+		if ((pte & PG_V) == 0) {
 			printf(" address %p not a valid page\n", dst);
 			return;
 		}
@@ -124,7 +122,7 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the VA for the page.
 		 */
-		if (oldpte & PG_PS)
+		if (pte & PG_PS)
 			pgva = (vaddr_t)dst & PG_LGFRAME;
 		else
 			pgva = x86_trunc_page(dst);
@@ -134,7 +132,7 @@ db_write_text(vaddr_t addr, size_t size,
 		 * with this mapping and subtract it from the
 		 * total size.
 		 */
-		if (oldpte & PG_PS)
+		if (pte & PG_PS)
 			limit = NBPD_L2 - ((vaddr_t)dst & (NBPD_L2 - 1));
 		else
 			limit = PAGE_SIZE - ((vaddr_t)dst & PGOFSET);
@@ -142,12 +140,11 @@ db_write_text(vaddr_t addr, size_t size,
 			limit = size;
 		size -= limit;
 
-		tmppte = (oldpte & ~PG_KR) | PG_KW;
-#ifdef XEN
-		xpmap_update(pte, tmppte);
-#else
-		*pte = tmppte;
-#endif
+		/*
+		 * Make the kernel text page writable.
+		 */
+		pmap_pte_clearbits(ppte, PG_KR);
+		pmap_pte_setbits(ppte, PG_KW);
 		pmap_update_pg(pgva);
 
 		/*
@@ -158,14 +155,10 @@ db_write_text(vaddr_t addr, size_t size,
 			*dst++ = *data++;
 
 		/*
-		 * Restore the old PTE.
+		 * Turn the page back to read-only.
 		 */
-#ifdef XEN
-		xpmap_update(pte, oldpte);
-#else
-		*pte = oldpte;
-#endif
-
+		pmap_pte_clearbits(ppte, PG_KW);
+		pmap_pte_setbits(ppte, PG_KR);
 		pmap_update_pg(pgva);
 		
 	} while (size != 0);



CVS commit: src/sys/arch

2011-11-22 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Wed Nov 23 00:56:56 UTC 2011

Modified Files:
src/sys/arch/x86/include: pmap.h
src/sys/arch/xen/include: xenpmap.h
src/sys/arch/xen/x86: xen_pmap.c

Log Message:
Move Xen-specific functions to Xen pmap. Requested by cherry@.

Un'ifdef XEN in xen_pmap.c, it is always defined there.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/xen/include/xenpmap.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/xen/x86/xen_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/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.46 src/sys/arch/x86/include/pmap.h:1.47
--- src/sys/arch/x86/include/pmap.h:1.46	Sun Nov 20 19:41:27 2011
+++ src/sys/arch/x86/include/pmap.h	Wed Nov 23 00:56:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.46 2011/11/20 19:41:27 jym Exp $	*/
+/*	$NetBSD: pmap.h,v 1.47 2011/11/23 00:56:56 jym Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -456,24 +456,14 @@ xpmap_update (pt_entry_t *pte, pt_entry_
 splx(s);
 }
 
-
 /* Xen helpers to change bits of a pte */
 #define XPMAP_UPDATE_DIRECT	1	/* Update direct map entry flags too */
 
 paddr_t	vtomach(vaddr_t);
 #define vtomfn(va) (vtomach(va) >> PAGE_SHIFT)
 
-void	pmap_xen_resume(void);
-void	pmap_xen_suspend(void);
-
 void	pmap_apte_flush(struct pmap *);
 void	pmap_unmap_apdp(void);
-
-#ifdef PAE
-void	pmap_map_recursive_entries(void);
-void	pmap_unmap_recursive_entries(void);
-#endif /* PAE */
-
 #endif	/* XEN */
 
 /* pmap functions with machine addresses */

Index: src/sys/arch/xen/include/xenpmap.h
diff -u src/sys/arch/xen/include/xenpmap.h:1.31 src/sys/arch/xen/include/xenpmap.h:1.32
--- src/sys/arch/xen/include/xenpmap.h:1.31	Tue Nov  8 17:16:52 2011
+++ src/sys/arch/xen/include/xenpmap.h	Wed Nov 23 00:56:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: xenpmap.h,v 1.31 2011/11/08 17:16:52 cherry Exp $	*/
+/*	$NetBSD: xenpmap.h,v 1.32 2011/11/23 00:56:56 jym Exp $	*/
 
 /*
  *
@@ -53,6 +53,13 @@ void xen_bcast_tlbflush(void);
 void xen_mcast_invlpg(vaddr_t, uint32_t);
 void xen_bcast_invlpg(vaddr_t);
 
+void pmap_xen_resume(void);
+void pmap_xen_suspend(void);
+
+#ifdef PAE
+void	pmap_map_recursive_entries(void);
+void	pmap_unmap_recursive_entries(void);
+#endif /* PAE */
 
 #define xpq_queue_pin_l1_table(pa)	\
 	xpq_queue_pin_table(pa, MMUEXT_PIN_L1_TABLE)

Index: src/sys/arch/xen/x86/xen_pmap.c
diff -u src/sys/arch/xen/x86/xen_pmap.c:1.9 src/sys/arch/xen/x86/xen_pmap.c:1.10
--- src/sys/arch/xen/x86/xen_pmap.c:1.9	Sun Nov 20 19:41:27 2011
+++ src/sys/arch/xen/x86/xen_pmap.c	Wed Nov 23 00:56:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_pmap.c,v 1.9 2011/11/20 19:41:27 jym Exp $	*/
+/*	$NetBSD: xen_pmap.c,v 1.10 2011/11/23 00:56:56 jym Exp $	*/
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.9 2011/11/20 19:41:27 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.10 2011/11/23 00:56:56 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -137,10 +137,9 @@ __KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v
 #include 
 #include 
 
-#ifdef XEN
 #include 
 #include 
-#endif
+#include 
 
 #define COUNT(x)	/* nothing */
 



CVS commit: src/sys/arch

2011-11-20 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Nov 20 19:41:27 UTC 2011

Modified Files:
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: pmap.c
src/sys/arch/xen/x86: xen_pmap.c
src/sys/arch/xen/xen: xen_machdep.c

Log Message:
Expose pmap_pdp_cache publicly to x86/xen pmap. Provide suspend/resume
callbacks for Xen pmap.

Turn static internal callbacks of pmap_pdp_cache.

XXX the implementation of pool_cache_invalidate(9) is still wrong, and
IMHO this needs fixing before -6. See
http://mail-index.netbsd.org/tech-kern/2011/11/18/msg011924.html


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.141 -r1.142 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/xen/x86/xen_pmap.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/xen/xen/xen_machdep.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/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.45 src/sys/arch/x86/include/pmap.h:1.46
--- src/sys/arch/x86/include/pmap.h:1.45	Tue Nov  8 17:16:52 2011
+++ src/sys/arch/x86/include/pmap.h	Sun Nov 20 19:41:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.45 2011/11/08 17:16:52 cherry Exp $	*/
+/*	$NetBSD: pmap.h,v 1.46 2011/11/20 19:41:27 jym Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -125,6 +125,11 @@ extern struct pmap_head pmaps;
 extern kmutex_t pmaps_lock;/* protects pmaps */
 
 /*
+ * pool_cache(9) that PDPs are allocated from 
+ */
+extern struct pool_cache pmap_pdp_cache;
+
+/*
  * the pmap structure
  *
  * note that the pm_obj contains the lock pointer, the reference count,
@@ -261,8 +266,6 @@ u_int		x86_mmap_flags(paddr_t);
 
 bool		pmap_is_curpmap(struct pmap *);
 
-void		pmap_invalidate_pool_caches(void);
-
 vaddr_t reserve_dumppages(vaddr_t); /* XXX: not a pmap fn */
 
 typedef enum tlbwhy {
@@ -411,15 +414,7 @@ vaddr_t	pmap_map(vaddr_t, paddr_t, paddr
 void	pmap_cpu_init_late(struct cpu_info *);
 bool	sse2_idlezero_page(void *);
 
-
 #ifdef XEN
-
-void	pmap_unmap_all_apdp_pdes(void);
-#ifdef PAE
-void	pmap_map_recursive_entries(void);
-void	pmap_unmap_recursive_entries(void);
-#endif /* PAE */
-
 #include 
 
 #define XPTE_MASK	L1_FRAME
@@ -468,9 +463,17 @@ xpmap_update (pt_entry_t *pte, pt_entry_
 paddr_t	vtomach(vaddr_t);
 #define vtomfn(va) (vtomach(va) >> PAGE_SHIFT)
 
+void	pmap_xen_resume(void);
+void	pmap_xen_suspend(void);
+
 void	pmap_apte_flush(struct pmap *);
 void	pmap_unmap_apdp(void);
 
+#ifdef PAE
+void	pmap_map_recursive_entries(void);
+void	pmap_unmap_recursive_entries(void);
+#endif /* PAE */
+
 #endif	/* XEN */
 
 /* pmap functions with machine addresses */

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.141 src/sys/arch/x86/x86/pmap.c:1.142
--- src/sys/arch/x86/x86/pmap.c:1.141	Tue Nov  8 17:16:52 2011
+++ src/sys/arch/x86/x86/pmap.c	Sun Nov 20 19:41:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.141 2011/11/08 17:16:52 cherry Exp $	*/
+/*	$NetBSD: pmap.c,v 1.142 2011/11/20 19:41:27 jym Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.141 2011/11/08 17:16:52 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.142 2011/11/20 19:41:27 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -508,17 +508,14 @@ static char *csrcp, *cdstp, *zerop, *ptp
 
 int pmap_enter_default(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int);
 
-/*
- * pool and cache that PDPs are allocated from
- */
-
-static struct pool_cache pmap_pdp_cache;
-int	pmap_pdp_ctor(void *, void *, int);
-void	pmap_pdp_dtor(void *, void *);
+/* PDP pool_cache(9) and its callbacks */
+struct pool_cache pmap_pdp_cache;
+static int  pmap_pdp_ctor(void *, void *, int);
+static void pmap_pdp_dtor(void *, void *);
 #ifdef PAE
 /* need to allocate items of 4 pages */
-void *pmap_pdp_alloc(struct pool *, int);
-void pmap_pdp_free(struct pool *, void *);
+static void *pmap_pdp_alloc(struct pool *, int);
+static void pmap_pdp_free(struct pool *, void *);
 static struct pool_allocator pmap_pdp_allocator = {
 	.pa_alloc = pmap_pdp_alloc,
 	.pa_free = pmap_pdp_free,
@@ -2014,7 +2011,7 @@ pmap_get_ptp(struct pmap *pmap, vaddr_t 
 /*
  * pmap_pdp_ctor: constructor for the PDP cache.
  */
-int
+static int
 pmap_pdp_ctor(void *arg, void *v, int flags)
 {
 	pd_entry_t *pdir = v;
@@ -2121,7 +2118,7 @@ pmap_pdp_ctor(void *arg, void *v, int fl
  * pmap_pdp_dtor: destructor for the PDP cache.
  */
 
-void
+static void
 pmap_pdp_dtor(void *arg, void *v)
 {
 #ifdef XEN
@@ -2152,7 +2149,7 @@ pmap_pdp_dtor(void *arg, void *v)
 
 /* pmap_pdp_alloc: Allocate a page for the pdp memory pool. */
 
-void *
+static void *
 pmap_pdp_alloc(struct pool *pp, int flags)
 {
 	return (void *)uvm_km_alloc(kernel_map,
@@ -2165,7 +2162,7 @@ pmap_pdp_alloc(

CVS commit: src

2011-11-14 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Nov 15 00:50:57 UTC 2011

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile

Log Message:
pool_cache_sethiwat(9), pool_cache_setlowat(9), pool_cache_sethardlimit(9)


To generate a diff of this commit:
cvs rdiff -u -r1.1708 -r1.1709 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.358 -r1.359 src/share/man/man9/Makefile

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/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1708 src/distrib/sets/lists/comp/mi:1.1709
--- src/distrib/sets/lists/comp/mi:1.1708	Tue Nov 15 00:19:42 2011
+++ src/distrib/sets/lists/comp/mi	Tue Nov 15 00:50:55 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1708 2011/11/15 00:19:42 jym Exp $
+#	$NetBSD: mi,v 1.1709 2011/11/15 00:50:55 jym Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -10389,6 +10389,9 @@
 ./usr/share/man/cat9/pool_cache_get_paddr.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/pool_cache_init.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/pool_cache_invalidate.0	comp-sys-catman		.cat
+./usr/share/man/cat9/pool_cache_sethiwat.0	comp-sys-catman		.cat
+./usr/share/man/cat9/pool_cache_setlowat.0	comp-sys-catman		.cat
+./usr/share/man/cat9/pool_cache_sethardlimit.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/pool_cache_invalidate_local.0	comp-obsolete	obsolete
 ./usr/share/man/cat9/pool_cache_put.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/pool_cache_put_paddr.0	comp-sys-catman		.cat
@@ -16489,6 +16492,9 @@
 ./usr/share/man/html9/pool_cache_get_paddr.html	comp-sys-htmlman	html
 ./usr/share/man/html9/pool_cache_init.html	comp-sys-htmlman	html
 ./usr/share/man/html9/pool_cache_invalidate.html	comp-sys-htmlman	html
+./usr/share/man/html9/pool_cache_sethiwat.html	comp-sys-htmlman	html
+./usr/share/man/html9/pool_cache_setlowat.html	comp-sys-htmlman	html
+./usr/share/man/html9/pool_cache_sethardlimit.html	comp-sys-htmlman	html
 ./usr/share/man/html9/pool_cache_invalidate_local.html	comp-obsolete	obsolete
 ./usr/share/man/html9/pool_cache_put.html	comp-sys-htmlman	html
 ./usr/share/man/html9/pool_cache_put_paddr.html	comp-sys-htmlman	html
@@ -22756,6 +22762,9 @@
 ./usr/share/man/man9/pool_cache_get_paddr.9	comp-sys-man		.man
 ./usr/share/man/man9/pool_cache_init.9		comp-sys-man		.man
 ./usr/share/man/man9/pool_cache_invalidate.9	comp-sys-man		.man
+./usr/share/man/man9/pool_cache_sethiwat.9	comp-sys-man		.man
+./usr/share/man/man9/pool_cache_setlowat.9	comp-sys-man		.man
+./usr/share/man/man9/pool_cache_sethardlimit.9	comp-sys-man		.man
 ./usr/share/man/man9/pool_cache_invalidate_local.9	comp-obsolete	obsolete
 ./usr/share/man/man9/pool_cache_put.9		comp-sys-man		.man
 ./usr/share/man/man9/pool_cache_put_paddr.9	comp-sys-man		.man

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.358 src/share/man/man9/Makefile:1.359
--- src/share/man/man9/Makefile:1.358	Tue Nov 15 00:19:42 2011
+++ src/share/man/man9/Makefile	Tue Nov 15 00:50:55 2011
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.358 2011/11/15 00:19:42 jym Exp $
+#   $NetBSD: Makefile,v 1.359 2011/11/15 00:50:55 jym Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -636,7 +636,10 @@ MLINKS+=pool_cache.9 pool_cache_init.9 \
 	pool_cache.9 pool_cache_put_paddr.9 \
 	pool_cache.9 pool_cache_put.9 \
 	pool_cache.9 pool_cache_destruct_object.9 \
-	pool_cache.9 pool_cache_invalidate.9
+	pool_cache.9 pool_cache_invalidate.9 \
+	pool_cache.9 pool_cache_sethiwat.9 \
+	pool_cache.9 pool_cache_setlowat.9 \
+	pool_cache.9 pool_cache_sethardlimit.9
 MLINKS+=powerhook_establish.9 powerhook_disestablish.9
 MLINKS+=preempt.9 yield.9
 MLINKS+=pserialize.9 pserialize_create.9 \



CVS commit: src/share/man/man9

2011-11-14 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Nov 15 00:32:34 UTC 2011

Modified Files:
src/share/man/man9: pool_cache.9

Log Message:
Document pool_cache_sethardlimit(9), the faithful friend of
pool_sethardlimit(9).


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/share/man/man9/pool_cache.9

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/man9/pool_cache.9
diff -u src/share/man/man9/pool_cache.9:1.18 src/share/man/man9/pool_cache.9:1.19
--- src/share/man/man9/pool_cache.9:1.18	Wed Jun  1 20:49:22 2011
+++ src/share/man/man9/pool_cache.9	Tue Nov 15 00:32:34 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pool_cache.9,v 1.18 2011/06/01 20:49:22 dyoung Exp $
+.\"	$NetBSD: pool_cache.9,v 1.19 2011/11/15 00:32:34 jym Exp $
 .\"
 .\" Copyright (c)2003 YAMAMOTO Takashi,
 .\" All rights reserved.
@@ -53,7 +53,7 @@
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\" 
-.Dd June 1, 2011
+.Dd November 15, 2011
 .Dt POOL_CACHE 9
 .Os
 .\" 
@@ -68,7 +68,8 @@
 .Nm pool_cache_destruct_object ,
 .Nm pool_cache_invalidate ,
 .Nm pool_cache_sethiwat ,
-.Nm pool_cache_setlowat
+.Nm pool_cache_setlowat ,
+.Nm pool_cache_sethardlimit
 .Nd resource-pool cache manager
 .\" 
 .Sh SYNOPSIS
@@ -114,6 +115,9 @@
 .Ft void
 .Fn pool_cache_setlowat \
 "pool_cache_t pc" "int nitems"
+.Ft void
+.Fn pool_cache_sethardlimit \
+"pool_cache_t pc" "int nitems" "const char *warnmess" "int ratecap"
 .\" 
 .Sh DESCRIPTION
 These utility routines provide management of pools of fixed-sized
@@ -124,8 +128,19 @@ This can be used by applications to guar
 amount of memory needed to continue operation independent of the memory
 resources currently available from the system-wide memory allocator.
 .Pp
-Global and per-CPU caches of constructed objects are maintained.
-The two levels of cache work together to allow for low overhead
+.Nm
+follows the
+.Xr pool 9
+API closely and offers routines that are functionally equivalent to
+their
+.Xr pool 9
+counterparts.
+In addition,
+.Nm
+provides object management functions used to manipulate
+objects allocated from the pool.
+It also maintains global and per-CPU caches, both levels
+of cache work together to allow for low overhead
 allocation and release of objects, and improved L1/L2/L3 hardware
 cache locality in multiprocessor systems.
 .\" 
@@ -281,7 +296,7 @@ It's implemented as a macro.
 .Pp
 Force destruction of an object
 .Fa object
-and its release back into the pool.
+and release it back into the pool.
 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 .It Fn pool_cache_invalidate "pc"
 .Pp
@@ -320,6 +335,18 @@ at which point the VM system will try to
 Set the minimum number of items to keep in the pool.
 The number pages in the pool will not decrease below the required value to
 accommodate the minimum number of items specified by this function.
+.\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+.It Fn pool_cache_sethardlimit "pc" "nitems" "warnmess" "ratecap"
+Set the hard limit for the backing
+.Xr pool 9
+to
+.Fa nitems .
+When the hard limit is reached, the warning message
+.Fa warnmess
+will be logged.
+.Fa ratecap
+represents the minimal interval (in seconds) after which another warning
+message is issued when the pool hits its hard limit again.
 .El
 .\" 
 .Sh CODE REFERENCES



CVS commit: src

2011-11-14 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Nov 15 00:19:43 UTC 2011

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile

Log Message:
pool_sethardlimit.9 => pool.9


To generate a diff of this commit:
cvs rdiff -u -r1.1707 -r1.1708 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.357 -r1.358 src/share/man/man9/Makefile

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/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1707 src/distrib/sets/lists/comp/mi:1.1708
--- src/distrib/sets/lists/comp/mi:1.1707	Sun Nov 13 22:25:21 2011
+++ src/distrib/sets/lists/comp/mi	Tue Nov 15 00:19:42 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1707 2011/11/13 22:25:21 christos Exp $
+#	$NetBSD: mi,v 1.1708 2011/11/15 00:19:42 jym Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -10400,6 +10400,7 @@
 ./usr/share/man/cat9/pool_put.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/pool_sethiwat.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/pool_setlowat.0		comp-sys-catman		.cat
+./usr/share/man/cat9/pool_sethardlimit.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/postsig.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/powerhook_disestablish.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/powerhook_establish.0	comp-sys-catman		.cat
@@ -16499,6 +16500,7 @@
 ./usr/share/man/html9/pool_put.html		comp-sys-htmlman	html
 ./usr/share/man/html9/pool_sethiwat.html	comp-sys-htmlman	html
 ./usr/share/man/html9/pool_setlowat.html	comp-sys-htmlman	html
+./usr/share/man/html9/pool_sethardlimit.html	comp-sys-htmlman	html
 ./usr/share/man/html9/postsig.html		comp-sys-htmlman	html
 ./usr/share/man/html9/powerhook_disestablish.html	comp-sys-htmlman	html
 ./usr/share/man/html9/powerhook_establish.html	comp-sys-htmlman	html
@@ -22765,6 +22767,7 @@
 ./usr/share/man/man9/pool_put.9			comp-sys-man		.man
 ./usr/share/man/man9/pool_sethiwat.9		comp-sys-man		.man
 ./usr/share/man/man9/pool_setlowat.9		comp-sys-man		.man
+./usr/share/man/man9/pool_sethardlimit.9	comp-sys-man		.man
 ./usr/share/man/man9/postsig.9			comp-sys-man		.man
 ./usr/share/man/man9/powerhook_disestablish.9	comp-sys-man		.man
 ./usr/share/man/man9/powerhook_establish.9	comp-sys-man		.man

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.357 src/share/man/man9/Makefile:1.358
--- src/share/man/man9/Makefile:1.357	Tue Nov  1 13:36:15 2011
+++ src/share/man/man9/Makefile	Tue Nov 15 00:19:42 2011
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.357 2011/11/01 13:36:15 yamt Exp $
+#   $NetBSD: Makefile,v 1.358 2011/11/15 00:19:42 jym Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -627,7 +627,8 @@ MLINKS+=pmf.9 pmf_device_register.9 pmf.
 	pmf.9 pmf_set_platform.9 pmf.9 pmf_get_platform.9
 MLINKS+=pool.9 pool_create.9 pool.9 pool_destroy.9 pool.9 pool_get.9 \
 	pool.9 pool_init.9 pool.9 pool_put.9 pool.9 pool_prime.9 \
-	pool.9 pool_sethiwat.9 pool.9 pool_setlowat.9
+	pool.9 pool_sethiwat.9 pool.9 pool_setlowat.9 \
+	pool.9 pool_sethardlimit.9
 MLINKS+=pool_cache.9 pool_cache_init.9 \
 	pool_cache.9 pool_cache_destroy.9 \
 	pool_cache.9 pool_cache_get_paddr.9 \



CVS commit: src/share/man/man9

2011-11-13 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Nov 14 02:38:06 UTC 2011

Modified Files:
src/share/man/man9: pool.9

Log Message:
Document pool_sethardlimit.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/share/man/man9/pool.9

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/man9/pool.9
diff -u src/share/man/man9/pool.9:1.43 src/share/man/man9/pool.9:1.44
--- src/share/man/man9/pool.9:1.43	Wed Apr 30 13:10:58 2008
+++ src/share/man/man9/pool.9	Mon Nov 14 02:38:05 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pool.9,v 1.43 2008/04/30 13:10:58 martin Exp $
+.\"	$NetBSD: pool.9,v 1.44 2011/11/14 02:38:05 jym Exp $
 .\"
 .\" Copyright (c) 1997, 1998, 2007 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd July 25, 2007
+.Dd November 14, 2011
 .Dt POOL 9
 .Os
 .Sh NAME
@@ -37,7 +37,8 @@
 .Nm pool_put ,
 .Nm pool_prime ,
 .Nm pool_sethiwat ,
-.Nm pool_setlowat
+.Nm pool_setlowat ,
+.Nm pool_sethardlimit
 .Nd resource-pool manager
 .Sh SYNOPSIS
 .In sys/pool.h
@@ -64,6 +65,9 @@
 .Fn pool_sethiwat "struct pool *pp" "int n"
 .Ft void
 .Fn pool_setlowat "struct pool *pp" "int n"
+.Ft void
+.Fn pool_sethardlimit "struct pool *pp" "int n" \
+"const char *warnmess" "int ratecap"
 .Sh DESCRIPTION
 These utility routines provide management of pools of fixed-sized
 areas of memory.
@@ -218,12 +222,13 @@ This function may return
 in case the requested number of items could not be allocated.
 Otherwise,
 the return value is 0.
-.Ss SETTING POOL RESOURCE WATERMARKS
+.Ss SETTING POOL RESOURCE WATERMARKS AND LIMITS
 A pool will attempt to increase its resource usage to keep up with the demand
 for its items.
 Conversely,
 it will return unused memory to the system should the number of accumulated
 unused items in the pool exceed a programmable limit.
+.Pp
 The limits for the minimum and maximum number of items which a pool should keep
 at hand are known as the high and low
 .Sy watermarks .
@@ -233,6 +238,13 @@ and
 .Fn pool_setlowat
 set a pool's high and low watermarks, respectively.
 .Pp
+The hard limit represents the maximum number of items a pool is allowed
+to allocate at any given time.
+Unless modified via
+.Fn pool_sethardlimit ,
+the hard limit defaults to
+.Dv UINT_MAX .
+.Pp
 .Fn pool_sethiwat
 .Bl -tag -offset indent -width "flags"
 .It Fa pp
@@ -260,6 +272,20 @@ Unlike
 .Fn pool_prime ,
 this function does not allocate the necessary memory up-front.
 .El
+.Pp
+.Fn pool_sethardlimit
+.Bl -tag -offset indent -width "flags"
+.It Fa pp
+The handle identifying the pool resource instance.
+.It Fa n
+The maximum number of items to be allocated from the pool (i.e. the
+hard limit).
+.It Fa warnmess
+The warning message that will be logged when the hard limit is reached.
+.It Fa ratecap
+The minimal interval (in seconds) after which another warning message
+is issued when the pool hits its hard limit again.
+.El
 .Ss POTENTIAL PITFALLS
 Note that undefined behaviour results when mixing the storage providing
 methods supported by the pool resource routines.



CVS commit: src/sys/arch

2011-11-09 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Nov 10 00:12:05 UTC 2011

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/i386/i386: machdep.c
src/sys/arch/x86/include: cpu.h

Log Message:
Turn the 'i386_use_pae' variable into simply 'use_pae'. Technically
speaking we are also running with PAE enabled in long mode under amd64,
so this variable will be used in various places across x86 machdep to
branch at runtime to functions that require extra handling for PAE mode.


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.711 -r1.712 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/x86/include/cpu.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/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.169 src/sys/arch/amd64/amd64/machdep.c:1.170
--- src/sys/arch/amd64/amd64/machdep.c:1.169	Sun Nov  6 15:51:09 2011
+++ src/sys/arch/amd64/amd64/machdep.c	Thu Nov 10 00:12:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.169 2011/11/06 15:51:09 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.170 2011/11/10 00:12:04 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.169 2011/11/06 15:51:09 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.170 2011/11/10 00:12:04 jym Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -242,7 +242,7 @@ int	physmem;
 uint64_t	dumpmem_low;
 uint64_t	dumpmem_high;
 int	cpu_class;
-
+int	use_pae;
 
 #ifndef NO_SPARSE_DUMP
 int sparse_dump = 0;
@@ -568,10 +568,10 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc
 		   NULL, 0, &tsc_freq, 0,
 		   CTL_MACHDEP, CTL_CREATE, CTL_EOL);
 	sysctl_createv(clog, 0, NULL, NULL,
-		   CTLFLAG_PERMANENT | CTLFLAG_IMMEDIATE,
+		   CTLFLAG_PERMANENT,
 		   CTLTYPE_INT, "pae",
 		   SYSCTL_DESCR("Whether the kernel uses PAE"),
-		   NULL, 1, NULL, 0,
+		   NULL, 0, &use_pae, 0,
 		   CTL_MACHDEP, CTL_CREATE, CTL_EOL);
 #ifndef NO_SPARSE_DUMP
 	/* XXXjld Does this really belong under machdep, and not e.g. kern? */
@@ -1646,6 +1646,8 @@ init_x86_64(paddr_t first_avail)
 
 	pcb = lwp_getpcb(&lwp0);
 
+	use_pae = 1; /* PAE always enabled in long mode */
+
 #ifdef XEN
 	pcb->pcb_cr3 = xen_start_info.pt_base - KERNBASE;
 	__PRINTK(("pcb_cr3 0x%lx\n", xen_start_info.pt_base - KERNBASE));

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.711 src/sys/arch/i386/i386/machdep.c:1.712
--- src/sys/arch/i386/i386/machdep.c:1.711	Sun Nov  6 15:35:29 2011
+++ src/sys/arch/i386/i386/machdep.c	Thu Nov 10 00:12:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.711 2011/11/06 15:35:29 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.712 2011/11/10 00:12:04 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.711 2011/11/06 15:35:29 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.712 2011/11/10 00:12:04 jym Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -246,12 +246,12 @@ struct mtrr_funcs *mtrr_funcs;
 int	physmem;
 
 int	cpu_class;
+int	use_pae;
 int	i386_fpu_present;
 int	i386_fpu_exception;
 int	i386_fpu_fdivbug;
 
 int	i386_use_fxsave;
-int	i386_use_pae = 0;
 int	i386_has_sse;
 int	i386_has_sse2;
 
@@ -713,7 +713,7 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc
 		   CTLFLAG_PERMANENT,
 		   CTLTYPE_INT, "pae", 
 		   SYSCTL_DESCR("Whether the kernel uses PAE"),
-		   NULL, 0, &i386_use_pae, 0,
+		   NULL, 0, &use_pae, 0,
 		   CTL_MACHDEP, CTL_CREATE, CTL_EOL);
 }
 
@@ -1348,7 +1348,9 @@ init386(paddr_t first_avail)
 	cpu_init_msrs(&cpu_info_primary, true);
 
 #ifdef PAE
-	i386_use_pae = 1;
+	use_pae = 1;
+#else
+	use_pae = 0;
 #endif
 
 #ifdef XEN

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.41 src/sys/arch/x86/include/cpu.h:1.42
--- src/sys/arch/x86/include/cpu.h:1.41	Sun Nov  6 15:18:18 2011
+++ src/sys/arch/x86/include/cpu.h	Thu Nov 10 00:12:05 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.41 2011/11/06 15:18:18 cherry Exp $	*/
+/*	$NetBSD: cpu.h,v 1.42 2011/11/10 00:12:05 jym Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -362,9 +362,9 @@ extern int cpu;
 extern int cpuid_level;
 extern int cpu_class;
 extern char cpu_brand_string[];
+extern int use_pae;
 
 extern int i386_use_fxsave;
-extern int i386_use_pae;
 extern int i386_has_sse;
 extern int i386_has_sse2;
 



CVS commit: src/share/man/man9

2011-11-07 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Nov  8 00:55:53 UTC 2011

Modified Files:
src/share/man/man9: kauth.9

Log Message:
Small improvements to kauth(9).


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/share/man/man9/kauth.9

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/man9/kauth.9
diff -u src/share/man/man9/kauth.9:1.91 src/share/man/man9/kauth.9:1.92
--- src/share/man/man9/kauth.9:1.91	Thu Apr 28 12:22:35 2011
+++ src/share/man/man9/kauth.9	Tue Nov  8 00:55:53 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: kauth.9,v 1.91 2011/04/28 12:22:35 wiz Exp $
+.\" $NetBSD: kauth.9,v 1.92 2011/11/08 00:55:53 jym Exp $
 .\"
 .\" Copyright (c) 2005, 2006 Elad Efrat 
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd August 10, 2009
+.Dd November 8, 2011
 .Dt KAUTH 9
 .Os
 .Sh NAME
@@ -77,11 +77,21 @@ the requested operation, and possibly ot
 .Pp
 Every listener examines the passed information and returns its decision
 regarding the requested operation.
-It can either allow, deny, or defer the operation -- in which case, the
-decision is left to the other listeners.
+It can either return:
 .Pp
-For an operation to be allowed, all listeners must not return any deny
-or defer decisions.
+.Bl -tag -width KAUTH_RESULT_ALLOW -compact
+.It Dv KAUTH_RESULT_ALLOW
+The listener allows the operation.
+.It Dv KAUTH_RESULT_DENY
+The listener denies the operation.
+.It Dv KAUTH_RESULT_DEFER
+The listener defers the decision to other listeners.
+.El
+.Pp
+For an operation to be allowed, at least one listener has to return
+.Dv KAUTH_RESULT_ALLOW
+while no other listener returned
+.Dv KAUTH_RESULT_DENY .
 .Pp
 Scopes manage listeners that operate in the same aspect of the system.
 .Ss Kernel Programming Interface
@@ -104,12 +114,14 @@ It is declared as
 .Ft int Fn kauth_authorize_action "kauth_scope_t scope" "kauth_cred_t cred" \
 "kauth_action_t op" "void *arg0" "void *arg1" "void *arg2" "void *arg3"
 .Pp
-An authorization request can return one of two possible values.
-Zero indicates success -- the operation is allowed;
-.Er EPERM
-(see
-.Xr errno 2 )
-indicates failure -- the operation is denied.
+An authorization request can return one of two possible values:
+.Bl -tag -width ".It Dv 0 Po zero Pc" -compact
+.It Dv 0 Po zero Pc
+indicates success; operation is allowed.
+.It Dv EPERM
+indicates failure; operation is denied. See
+.Xr errno 2 .
+.El 
 .Pp
 Each scope has its own authorization wrapper, to make it easy to call from various
 places by eliminating the need to specify the scope and/or cast values.



CVS commit: src/bin/dd

2011-11-07 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Nov  7 22:24:23 UTC 2011

Modified Files:
src/bin/dd: args.c extern.h misc.c

Log Message:
As suggested by Enami, rework the msgfmt logic a bit:
- error out when an unknown specifier is used. Do this in f_msgfmt(),
before dd(1) starts operation.
- allow buffer_write() to flush the internal buffer even when NULL is
passed as parameter.

Some whitespace fixes too.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/bin/dd/args.c
cvs rdiff -u -r1.21 -r1.22 src/bin/dd/extern.h
cvs rdiff -u -r1.22 -r1.23 src/bin/dd/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/dd/args.c
diff -u src/bin/dd/args.c:1.36 src/bin/dd/args.c:1.37
--- src/bin/dd/args.c:1.36	Sun Nov  6 21:22:23 2011
+++ src/bin/dd/args.c	Mon Nov  7 22:24:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.36 2011/11/06 21:22:23 jym Exp $	*/
+/*	$NetBSD: args.c,v 1.37 2011/11/07 22:24:23 jym Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)args.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: args.c,v 1.36 2011/11/06 21:22:23 jym Exp $");
+__RCSID("$NetBSD: args.c,v 1.37 2011/11/07 22:24:23 jym Exp $");
 #endif
 #endif /* not lint */
 
@@ -274,6 +274,12 @@ static void
 f_msgfmt(char *arg)
 {
 
+	/*
+	 * If the format string is not valid, dd_write_msg() will print
+	 * an error and exit.
+	 */
+	dd_write_msg(arg, 0);
+
 	msgfmt = arg;
 }
 #endif	/* NO_MSGFMT */

Index: src/bin/dd/extern.h
diff -u src/bin/dd/extern.h:1.21 src/bin/dd/extern.h:1.22
--- src/bin/dd/extern.h:1.21	Sun Nov  6 21:22:23 2011
+++ src/bin/dd/extern.h	Mon Nov  7 22:24:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.21 2011/11/06 21:22:23 jym Exp $	*/
+/*	$NetBSD: extern.h,v 1.22 2011/11/07 22:24:23 jym Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -48,6 +48,11 @@ void block_close(void);
 void unblock(void);
 void unblock_close(void);
 #endif
+
+#ifndef NO_MSGFMT
+int dd_write_msg(const char *, int);
+#endif
+
 void dd_out(int);
 void def(void);
 void def_close(void);

Index: src/bin/dd/misc.c
diff -u src/bin/dd/misc.c:1.22 src/bin/dd/misc.c:1.23
--- src/bin/dd/misc.c:1.22	Sun Nov  6 21:22:23 2011
+++ src/bin/dd/misc.c	Mon Nov  7 22:24:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.22 2011/11/06 21:22:23 jym Exp $	*/
+/*	$NetBSD: misc.c,v 1.23 2011/11/07 22:24:23 jym Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)misc.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: misc.c,v 1.22 2011/11/06 21:22:23 jym Exp $");
+__RCSID("$NetBSD: misc.c,v 1.23 2011/11/07 22:24:23 jym Exp $");
 #endif
 #endif /* not lint */
 
@@ -66,7 +66,6 @@ static void human_summary(void);
 static void quiet_summary(void);
 
 static void buffer_write(const char *, size_t, int);
-static int  dd_write_msg(const char *);
 #endif /* NO_MSGFMT */
 
 void
@@ -171,30 +170,42 @@ buffer_write(const char *str, size_t siz
 	unsigned int i;
 
 	for (i = 0; i < size; i++) {
-		wbuf[cnt++] = str[i];
-		if (cnt >= sizeof(wbuf) || flush == 1) {
+		if (str != NULL) {
+			wbuf[cnt++] = str[i];
+		}
+		if (cnt >= sizeof(wbuf)) {
 			(void)write(STDERR_FILENO, wbuf, cnt);
 			cnt = 0;
 		}
 	}
+
+	if (flush != 0) {
+		(void)write(STDERR_FILENO, wbuf, cnt);
+		cnt = 0;
+	}
 }
 
-static int
-dd_write_msg(const char *fmt)
+/*
+ * Write summary to stderr according to format 'fmt'. If 'enable' is 0, it
+ * will not attempt to write anything. Can be used to validate the
+ * correctness of the 'fmt' string.
+ */
+int
+dd_write_msg(const char *fmt, int enable)
 {
 	char hbuf[7], nbuf[32];
 	const char *ptr;
 	int64_t mS;
-struct timeval tv;
+	struct timeval tv;
 
 	(void)gettimeofday(&tv, NULL);
 	mS = tv2mS(tv) - tv2mS(st.start);
 	if (mS == 0)
 		mS = 1;
 
-#define ADDC(c) do { buffer_write(&c, 1, 0); } \
+#define ADDC(c) do { if (enable != 0) buffer_write(&c, 1, 0); } \
 	while (/*CONSTCOND*/0)
-#define ADDS(p) do { buffer_write(p, strlen(p), 0); } \
+#define ADDS(p) do { if (enable != 0) buffer_write(p, strlen(p), 0); } \
 	while (/*CONSTCOND*/0)
 
 	for (ptr = fmt; *ptr; ptr++) {
@@ -280,20 +291,21 @@ dd_write_msg(const char *fmt)
 			ADDS("block");
 			if (st.swab != 1) ADDS("s");
 			break;
-		default:
-			ADDS("%");
-			if (*ptr == '\0')
-goto done;
-			/*FALLTHROUGH*/
 		case '%':
 			ADDC(*ptr);
 			break;
+		default:
+			if (*ptr == '\0')
+goto done;
+			errx(EXIT_FAILURE, "unknown specifier '%c' in "
+			"msgfmt string", *ptr);
+			/* NOTREACHED */
 		}
 	}
 
 done:
 	/* flush buffer */
-	buffer_write("\0", 1, 1);
+	buffer_write(NULL, 0, 1);
 	return 0;
 }
 
@@ -301,24 +313,24 @@ static void
 custom_summary(void)
 {
 
-	dd_write_msg(msgfmt);
+	dd_write_msg(msgfmt, 1);
 }
 
 static void
 human_summary(void)
 {
-	(void)dd_write_msg("%I+%i records in\n%O+%o records out\n");
+	(void)dd_write_msg("%I+%i re

CVS commit: src/bin/dd

2011-11-06 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Nov  6 21:22:23 UTC 2011

Modified Files:
src/bin/dd: Makefile args.c dd.1 dd.c extern.h misc.c

Log Message:
Add a new command to dd(1): msgfmt. The command modifies the
output of the information summary returned by dd(1). This can be used
to specify messages in a more usable (or parseable) format like
human-readable values.

My intent is to re-use this for building image files and quick I/O
benchmarking.

Reviewed by tsutsui@ on tech-userlevel. See also
http://mail-index.netbsd.org/tech-userlevel/2010/12/03/msg004179.html

Some examples:

 $ dd if=/dev/zero of=/dev/null bs=1m count=1 msgfmt=human
1+0 records in
1+0 records out
1048576 bytes (1,0 MB) transferred in 0.001 secs (1048576000 bytes/sec - 1,0 
GB/sec)

 $ dd if=/dev/zero of=/dev/null count=1 msgfmt='
 > %E
 > %s
 > %b
 > '
500 KB/sec
0.001
512


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/bin/dd/Makefile
cvs rdiff -u -r1.35 -r1.36 src/bin/dd/args.c
cvs rdiff -u -r1.23 -r1.24 src/bin/dd/dd.1
cvs rdiff -u -r1.47 -r1.48 src/bin/dd/dd.c
cvs rdiff -u -r1.20 -r1.21 src/bin/dd/extern.h
cvs rdiff -u -r1.21 -r1.22 src/bin/dd/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/dd/Makefile
diff -u src/bin/dd/Makefile:1.15 src/bin/dd/Makefile:1.16
--- src/bin/dd/Makefile:1.15	Fri Feb  4 19:42:12 2011
+++ src/bin/dd/Makefile	Sun Nov  6 21:22:23 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.15 2011/02/04 19:42:12 pooka Exp $
+#	$NetBSD: Makefile,v 1.16 2011/11/06 21:22:23 jym Exp $
 #	@(#)Makefile	8.1 (Berkeley) 5/31/93
 
 RUMPPRG=dd
@@ -8,7 +8,7 @@ DPADD+=	${LIBUTIL}
 LDADD+=	-lutil
 
 .ifdef SMALLPROG
-CPPFLAGS+=	-DNO_CONV -DSMALL
+CPPFLAGS+=	-DNO_CONV -DNO_MSGFMT -DSMALL
 .else
 SRCS+=		conv_tab.c
 .ifndef CRUNCHEDPROG

Index: src/bin/dd/args.c
diff -u src/bin/dd/args.c:1.35 src/bin/dd/args.c:1.36
--- src/bin/dd/args.c:1.35	Fri Sep 16 16:06:23 2011
+++ src/bin/dd/args.c	Sun Nov  6 21:22:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.35 2011/09/16 16:06:23 joerg Exp $	*/
+/*	$NetBSD: args.c,v 1.36 2011/11/06 21:22:23 jym Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)args.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: args.c,v 1.35 2011/09/16 16:06:23 joerg Exp $");
+__RCSID("$NetBSD: args.c,v 1.36 2011/11/06 21:22:23 jym Exp $");
 #endif
 #endif /* not lint */
 
@@ -56,15 +56,22 @@ __RCSID("$NetBSD: args.c,v 1.35 2011/09/
 #include "extern.h"
 
 static int	c_arg(const void *, const void *);
-#ifndef	NO_CONV
+
+#ifdef NO_MSGFMT
+static void	f_msgfmt(char *) __dead;
+#else
+static void	f_msgfmt(char *);
+#endif /* NO_MSGFMT */
+
+#ifdef NO_CONV
+static void	f_conv(char *) __dead;
+#else
+static void	f_conv(char *);
 static int	c_conv(const void *, const void *);
-#endif
+#endif /* NO_CONV */
+
 static void	f_bs(char *);
 static void	f_cbs(char *);
-#ifdef	NO_CONV
-__dead
-#endif
-static void	f_conv(char *);
 static void	f_count(char *);
 static void	f_files(char *);
 static void	f_ibs(char *);
@@ -90,6 +97,7 @@ static const struct arg {
 	{ "ibs",	f_ibs,		C_IBS,	 C_BS|C_IBS },
 	{ "if",		f_if,		C_IF,	 C_IF },
 	{ "iseek",	f_skip,		C_SKIP,	 C_SKIP },
+	{ "msgfmt",	f_msgfmt,	C_SKIP,	 C_SKIP },
 	{ "obs",	f_obs,		C_OBS,	 C_BS|C_OBS },
 	{ "of",		f_of,		C_OF,	 C_OF },
 	{ "oseek",	f_seek,		C_SEEK,	 C_SEEK },
@@ -252,6 +260,24 @@ f_if(char *arg)
 	in.name = arg;
 }
 
+#ifdef NO_MSGFMT
+/* Build a small version (i.e. for a ramdisk root) */
+static void
+f_msgfmt(char *arg)
+{
+
+	errx(EXIT_FAILURE, "msgfmt option disabled");
+	/* NOTREACHED */
+}
+#else	/* NO_MSGFMT */
+static void
+f_msgfmt(char *arg)
+{
+
+	msgfmt = arg;
+}
+#endif	/* NO_MSGFMT */
+
 static void
 f_obs(char *arg)
 {

Index: src/bin/dd/dd.1
diff -u src/bin/dd/dd.1:1.23 src/bin/dd/dd.1:1.24
--- src/bin/dd/dd.1:1.23	Wed Dec 22 09:42:53 2010
+++ src/bin/dd/dd.1	Sun Nov  6 21:22:23 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: dd.1,v 1.23 2010/12/22 09:42:53 enami Exp $
+.\"	$NetBSD: dd.1,v 1.24 2011/11/06 21:22:23 jym Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"	@(#)dd.1	8.2 (Berkeley) 1/13/94
 .\"
-.Dd December 22, 2010
+.Dd November 6, 2011
 .Dt DD 1
 .Os
 .Sh NAME
@@ -97,6 +97,74 @@ Seek on the input file
 blocks.
 This is synonymous with
 .Cm skip= Ns Ar n .
+.It Cm msgfmt= Ns Ar fmt
+Specify the message format
+.Ar fmt
+to be used when writing information to standard output.
+Possible values are:
+.Bl -tag -width x -offset indent -compact
+.It quiet
+turns off information summary report except for errors and
+.Cm progress .
+.It posix
+default information summary report as specified by POSIX.
+.It human
+default information summary report extended with human-readable
+values.
+.El
+.Pp
+When
+.Ar fmt
+does not correspond to any value given above,
+it contai

CVS commit: src/share/man/man7

2011-11-02 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Nov  3 00:29:00 UTC 2011

Modified Files:
src/share/man/man7: sysctl.7

Log Message:
Minor typo fix.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 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.67 src/share/man/man7/sysctl.7:1.68
--- src/share/man/man7/sysctl.7:1.67	Sat Sep 24 17:08:16 2011
+++ src/share/man/man7/sysctl.7	Thu Nov  3 00:29:00 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sysctl.7,v 1.67 2011/09/24 17:08:16 christos Exp $
+.\"	$NetBSD: sysctl.7,v 1.68 2011/11/03 00:29:00 jym Exp $
 .\"
 .\" Copyright (c) 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -142,7 +142,7 @@ The highest valid file system type numbe
 Returns configuration information about the file system type given as a fourth
 level identifier.
 .It Li vfs.generic.usermount ( VFS_USERMOUNT )
-Determines if non superuser mounts are allowed, default to no
+Determines if non superuser mounts are allowed, defaults to
 .Dv 0 .
 .It Li vfs.generic.magiclinks ( VFS_MAGICLINKS )
 Controls if expansion of variables is going to be performed on pathnames



CVS commit: src/sys/kern

2011-11-01 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Nov  1 15:39:37 UTC 2011

Modified Files:
src/sys/kern: kern_kthread.c

Log Message:
Avoid crashing when we do not explictly pass down a CPU when creating
a kthread(9) in the LSIDL (KTHREAD_IDLE) state.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/kern/kern_kthread.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/kern/kern_kthread.c
diff -u src/sys/kern/kern_kthread.c:1.37 src/sys/kern/kern_kthread.c:1.38
--- src/sys/kern/kern_kthread.c:1.37	Sat Oct 29 20:11:08 2011
+++ src/sys/kern/kern_kthread.c	Tue Nov  1 15:39:37 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_kthread.c,v 1.37 2011/10/29 20:11:08 jym Exp $	*/
+/*	$NetBSD: kern_kthread.c,v 1.38 2011/11/01 15:39:37 jym Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.37 2011/10/29 20:11:08 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.38 2011/11/01 15:39:37 jym Exp $");
 
 #include 
 #include 
@@ -140,8 +140,12 @@ kthread_create(pri_t pri, int flag, stru
 		l->l_stat = LSRUN;
 		sched_enqueue(l, false);
 		lwp_unlock(l);
-	} else
-		lwp_unlock_to(l, ci->ci_schedstate.spc_lwplock);
+	} else {
+		if (ci != NULL)
+			lwp_unlock_to(l, ci->ci_schedstate.spc_lwplock);
+		else
+			lwp_unlock(l);
+	}
 	mutex_exit(proc0.p_lock);
 
 	/* All done! */



CVS commit: src/sys/kern

2011-10-29 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Oct 29 20:11:09 UTC 2011

Modified Files:
src/sys/kern: kern_kthread.c

Log Message:
Typo fix.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/kern/kern_kthread.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/kern/kern_kthread.c
diff -u src/sys/kern/kern_kthread.c:1.36 src/sys/kern/kern_kthread.c:1.37
--- src/sys/kern/kern_kthread.c:1.36	Sun Aug  7 14:03:16 2011
+++ src/sys/kern/kern_kthread.c	Sat Oct 29 20:11:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_kthread.c,v 1.36 2011/08/07 14:03:16 rmind Exp $	*/
+/*	$NetBSD: kern_kthread.c,v 1.37 2011/10/29 20:11:08 jym Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.36 2011/08/07 14:03:16 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_kthread.c,v 1.37 2011/10/29 20:11:08 jym Exp $");
 
 #include 
 #include 
@@ -209,7 +209,7 @@ kthread_join(lwp_t *l)
 
 	/*
 	 * - Wait if some other thread has occupied the target.
-	 * - Speicfy our kthread as a target and notify it.
+	 * - Specify our kthread as a target and notify it.
 	 * - Wait for the target kthread to notify us.
 	 */
 	mutex_enter(&kthread_lock);



CVS commit: src/sys/kern

2011-10-29 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Oct 29 11:41:32 UTC 2011

Modified Files:
src/sys/kern: kern_cpu.c

Log Message:
Fix comment.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/kern/kern_cpu.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/kern/kern_cpu.c
diff -u src/sys/kern/kern_cpu.c:1.51 src/sys/kern/kern_cpu.c:1.52
--- src/sys/kern/kern_cpu.c:1.51	Sun Sep 11 14:54:49 2011
+++ src/sys/kern/kern_cpu.c	Sat Oct 29 11:41:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_cpu.c,v 1.51 2011/09/11 14:54:49 jdc Exp $	*/
+/*	$NetBSD: kern_cpu.c,v 1.52 2011/10/29 11:41:32 jym Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.51 2011/09/11 14:54:49 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.52 2011/10/29 11:41:32 jym Exp $");
 
 #include 
 #include 
@@ -80,8 +80,8 @@ __KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v
 #include 
 
 /*
- * If the port has state that cpu_data is the first thing in cpu_info,
- * verify the claim is true.  This will prevent the from getting out
+ * If the port has stated that cpu_data is the first thing in cpu_info,
+ * verify that the claim is true. This will prevent them from getting out
  * of sync.
  */
 #ifdef __HAVE_CPU_DATA_FIRST



CVS commit: src/usr.bin/pmap

2011-10-25 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Oct 25 23:45:19 UTC 2011

Modified Files:
src/usr.bin/pmap: main.c

Log Message:
Move getuid() out of the loop, uid should not change behind our back. KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/pmap/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/pmap/main.c
diff -u src/usr.bin/pmap/main.c:1.23 src/usr.bin/pmap/main.c:1.24
--- src/usr.bin/pmap/main.c:1.23	Tue Oct 25 22:13:22 2011
+++ src/usr.bin/pmap/main.c	Tue Oct 25 23:45:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.23 2011/10/25 22:13:22 jym Exp $ */
+/*	$NetBSD: main.c,v 1.24 2011/10/25 23:45:19 jym Exp $ */
 
 /*
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.23 2011/10/25 22:13:22 jym Exp $");
+__RCSID("$NetBSD: main.c,v 1.24 2011/10/25 23:45:19 jym Exp $");
 #endif
 
 #include 
@@ -289,6 +289,8 @@ main(int argc, char *argv[])
 		exit(0);
 	}
 
+	uid = getuid();
+
 	do {
 		if (pid == -1) {
 			if (argc == 0)
@@ -309,8 +311,6 @@ main(int argc, char *argv[])
 			}
 		}
 
-		uid = getuid();
-
 		errno = 0;
 		/* find the process id */
 		if (pid == 0) {
@@ -321,7 +321,7 @@ main(int argc, char *argv[])
 			}
 		} else {
 			kproc = kvm_getproc2(kd, KERN_PROC_PID, pid,
-sizeof(struct kinfo_proc2), &rc);
+			sizeof(struct kinfo_proc2), &rc);
 			if (kproc == NULL || rc == 0) {
 errno = ESRCH;
 			} else if (uid != 0 && uid != kproc->p_uid) {
@@ -341,7 +341,7 @@ main(int argc, char *argv[])
 
 		/* dump it */
 		if (many) {
-			if (kproc)
+			if (kproc != NULL)
 printf("process %d:\n", kproc->p_pid);
 			else
 printf("kernel:\n");



CVS commit: src/usr.bin/pmap

2011-10-25 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Oct 25 22:13:22 UTC 2011

Modified Files:
src/usr.bin/pmap: main.c

Log Message:
kill(2) might not be a good test after all, users can send signals
to setuid binaries (like SIGINT for ping(8)). So apply the exact same
rights as procfs, and test uid against proc p_uid (real owner of process).

Bail out if we are not root and we attempt to print mappings of a process
that the user does not really own.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/pmap/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/pmap/main.c
diff -u src/usr.bin/pmap/main.c:1.22 src/usr.bin/pmap/main.c:1.23
--- src/usr.bin/pmap/main.c:1.22	Tue Oct 18 20:54:56 2011
+++ src/usr.bin/pmap/main.c	Tue Oct 25 22:13:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.22 2011/10/18 20:54:56 jym Exp $ */
+/*	$NetBSD: main.c,v 1.23 2011/10/25 22:13:22 jym Exp $ */
 
 /*
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.22 2011/10/18 20:54:56 jym Exp $");
+__RCSID("$NetBSD: main.c,v 1.23 2011/10/25 22:13:22 jym Exp $");
 #endif
 
 #include 
@@ -118,6 +118,7 @@ main(int argc, char *argv[])
 {
 	kvm_t *kd;
 	pid_t pid;
+	uid_t uid;
 	int which, many, ch, rc;
 	char errbuf[_POSIX2_LINE_MAX + 1];
 	struct kinfo_proc2 *kproc;
@@ -308,33 +309,36 @@ main(int argc, char *argv[])
 			}
 		}
 
-		/*
-		 * Only print mappings for processes we can send a signal(7)
-		 * to, or kernel mappings if we are root
-		 */
-		if (kill(pid, 0) == -1 ||
-		   (pid == 0 && getuid() != 0)) {
-			errno = EPERM;
-			warn("%d", pid);
-			pid = -1;
-			continue;
-
-		}
+		uid = getuid();
 
+		errno = 0;
 		/* find the process id */
-		if (pid == 0)
+		if (pid == 0) {
 			kproc = NULL;
-		else {
+			if (uid != 0) {
+/* only root can print kernel mappings */
+errno = EPERM;
+			}
+		} else {
 			kproc = kvm_getproc2(kd, KERN_PROC_PID, pid,
-	 sizeof(struct kinfo_proc2), &rc);
+sizeof(struct kinfo_proc2), &rc);
 			if (kproc == NULL || rc == 0) {
 errno = ESRCH;
-warn("%d", pid);
-pid = -1;
-continue;
+			} else if (uid != 0 && uid != kproc->p_uid) {
+/*
+ * only the real owner of the process and
+ * root can print process mappings
+ */
+errno = EPERM;
 			}
 		}
 
+		if (errno != 0) {
+			warn("%d", pid);
+			pid = -1;
+			continue;
+		}
+
 		/* dump it */
 		if (many) {
 			if (kproc)



CVS commit: src/sys/arch/xen/xen

2011-10-24 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Oct 24 18:13:51 UTC 2011

Modified Files:
src/sys/arch/xen/xen: xbdback_xenbus.c

Log Message:
Move disconnection code to a separate function, similar to what is done
with xbdback_connect.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/xen/xen/xbdback_xenbus.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/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.46 src/sys/arch/xen/xen/xbdback_xenbus.c:1.47
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.46	Wed Aug 24 20:49:34 2011
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Mon Oct 24 18:13:50 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.46 2011/08/24 20:49:34 jym Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.47 2011/10/24 18:13:50 jym Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.46 2011/08/24 20:49:34 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.47 2011/10/24 18:13:50 jym Exp $");
 
 #include 
 #include 
@@ -628,12 +628,31 @@ err:
 	return -1;
 }
 
+static int
+xbdback_disconnect(struct xbdback_instance *xbdi)
+{
+	int s;
+	
+	hypervisor_mask_event(xbdi->xbdi_evtchn);
+	event_remove_handler(xbdi->xbdi_evtchn, xbdback_evthandler,
+	xbdi);
+	xbdi->xbdi_status = DISCONNECTING;
+	s = splbio();
+	xbdi_put(xbdi);
+	while (xbdi->xbdi_status != DISCONNECTED) {
+		tsleep(&xbdi->xbdi_status, PRIBIO, "xbddis", 0);
+	}
+	splx(s);
+	xenbus_switch_state(xbdi->xbdi_xbusd, NULL, XenbusStateClosing);
+
+	return 0;
+}
+
 static void
 xbdback_frontend_changed(void *arg, XenbusState new_state)
 {
 	struct xbdback_instance *xbdi = arg;
 	struct xenbus_device *xbusd = xbdi->xbdi_xbusd;
-	int s;
 
 	XENPRINTF(("xbdback %s: new state %d\n", xbusd->xbusd_path, new_state));
 	switch(new_state) {
@@ -646,17 +665,7 @@ xbdback_frontend_changed(void *arg, Xenb
 		xbdback_connect(xbdi);
 		break;
 	case XenbusStateClosing:
-		hypervisor_mask_event(xbdi->xbdi_evtchn);
-		event_remove_handler(xbdi->xbdi_evtchn, xbdback_evthandler,
-		xbdi);
-		xbdi->xbdi_status = DISCONNECTING;
-		s = splbio();
-		xbdi_put(xbdi);
-		while (xbdi->xbdi_status != DISCONNECTED) {
-			tsleep(&xbdi->xbdi_status, PRIBIO, "xbddis", 0);
-		}
-		splx(s);
-		xenbus_switch_state(xbusd, NULL, XenbusStateClosing);
+		xbdback_disconnect(xbdi);
 		break;
 	case XenbusStateClosed:
 		/* otherend_changed() should handle it for us */



CVS commit: src/share/man/man4

2011-10-23 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Oct 23 22:02:45 UTC 2011

Modified Files:
src/share/man/man4: ddb.4

Log Message:
ps/l shows LWP name, not command name.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/share/man/man4/ddb.4

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/man4/ddb.4
diff -u src/share/man/man4/ddb.4:1.146 src/share/man/man4/ddb.4:1.147
--- src/share/man/man4/ddb.4:1.146	Sun Oct 23 13:20:59 2011
+++ src/share/man/man4/ddb.4	Sun Oct 23 22:02:45 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ddb.4,v 1.146 2011/10/23 13:20:59 jym Exp $
+.\"	$NetBSD: ddb.4,v 1.147 2011/10/23 22:02:45 jym Exp $
 .\"
 .\" Copyright (c) 1997 - 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -584,7 +584,7 @@ LWPs currently running on a CPU are mark
 .It Cm /l
 show each LWP ID, process ID, process status, CPU ID the LWP runs on,
 process flags, kernel virtual address of LWP structure,
-command name and wait channel message.
+LWP name and wait channel message.
 LWPs currently running on a CPU are marked with the '\&>' sign.
 This is the default.
 .El



CVS commit: src/sys/kern

2011-10-23 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Oct 23 21:41:23 UTC 2011

Modified Files:
src/sys/kern: subr_workqueue.c

Log Message:
Turn a workqueue(9) name into an array in the struct workqueue, rather
than a const char *. This avoids keeping a reference to a string
owned by caller (string could be allocated on stack).


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/kern/subr_workqueue.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/kern/subr_workqueue.c
diff -u src/sys/kern/subr_workqueue.c:1.31 src/sys/kern/subr_workqueue.c:1.32
--- src/sys/kern/subr_workqueue.c:1.31	Wed Jul 27 14:35:34 2011
+++ src/sys/kern/subr_workqueue.c	Sun Oct 23 21:41:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_workqueue.c,v 1.31 2011/07/27 14:35:34 uebayasi Exp $	*/
+/*	$NetBSD: subr_workqueue.c,v 1.32 2011/10/23 21:41:23 jym Exp $	*/
 
 /*-
  * Copyright (c)2002, 2005, 2006, 2007 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.31 2011/07/27 14:35:34 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.32 2011/10/23 21:41:23 jym Exp $");
 
 #include 
 #include 
@@ -58,7 +58,7 @@ struct workqueue {
 	void *wq_arg;
 	int wq_flags;
 
-	const char *wq_name;
+	char wq_name[MAXCOMLEN];
 	pri_t wq_prio;
 	void *wq_ptr;
 };
@@ -142,8 +142,9 @@ workqueue_init(struct workqueue *wq, con
 pri_t prio, int ipl)
 {
 
+	strncpy(wq->wq_name, name, sizeof(wq->wq_name));
+
 	wq->wq_prio = prio;
-	wq->wq_name = name;
 	wq->wq_func = callback_func;
 	wq->wq_arg = callback_arg;
 }



CVS commit: src/sys/ddb

2011-10-23 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Oct 23 13:30:20 UTC 2011

Modified Files:
src/sys/ddb: db_proc.c

Log Message:
Like ddb(4) "ps/l", use '>' sign to indicate running LWPs for the /w
modifier.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/ddb/db_proc.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/ddb/db_proc.c
diff -u src/sys/ddb/db_proc.c:1.5 src/sys/ddb/db_proc.c:1.6
--- src/sys/ddb/db_proc.c:1.5	Tue Apr 12 17:46:38 2011
+++ src/sys/ddb/db_proc.c	Sun Oct 23 13:30:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_proc.c,v 1.5 2011/04/12 17:46:38 nakayama Exp $	*/
+/*	$NetBSD: db_proc.c,v 1.6 2011/10/23 13:30:20 jym Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_proc.c,v 1.5 2011/04/12 17:46:38 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_proc.c,v 1.6 2011/10/23 13:30:20 jym Exp $");
 
 #ifndef _KERNEL
 #include 
@@ -237,13 +237,16 @@ db_show_all_procs(db_expr_t addr, bool h
 } else {
 	wbuf[0] = '\0';
 }
+run = (l.l_stat == LSONPROC ||
+(l.l_pflag & LP_RUNNING) != 0);
 db_read_bytes((db_addr_t)&p.p_emul->e_name,
 sizeof(ename), (char *)&ename);
 db_read_bytes((db_addr_t)ename,
 sizeof(db_nbuf), db_nbuf);
 db_printf(
-"%4d %16s %8s %4d %-12s %-18lx\n",
-l.l_lid, p.p_comm, db_nbuf,
+"%c%4d %16s %8s %4d %-12s %-18lx\n",
+(run ? '>' : ' '), l.l_lid,
+p.p_comm, db_nbuf,
 l.l_priority, wbuf, (long)l.l_wchan);
 lp = LIST_NEXT((&l), l_sibling);
 if (lp != NULL) {



CVS commit: src/share/man/man4

2011-10-23 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Oct 23 13:20:59 UTC 2011

Modified Files:
src/share/man/man4: ddb.4

Log Message:
Document "show proc". Be more verbose about commands that print
information about processes especially the '>' sign (e.g. LWP is
currently running).

Bump date. Straight from Hackathon@ESPCI.


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/share/man/man4/ddb.4

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/man4/ddb.4
diff -u src/share/man/man4/ddb.4:1.145 src/share/man/man4/ddb.4:1.146
--- src/share/man/man4/ddb.4:1.145	Mon Aug 29 22:01:47 2011
+++ src/share/man/man4/ddb.4	Sun Oct 23 13:20:59 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ddb.4,v 1.145 2011/08/29 22:01:47 jym Exp $
+.\"	$NetBSD: ddb.4,v 1.146 2011/10/23 13:20:59 jym Exp $
 .\"
 .\" Copyright (c) 1997 - 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -56,7 +56,7 @@
 .\" any improvements or extensions that they make and grant Carnegie Mellon
 .\" the rights to redistribute these changes.
 .\"
-.Dd August 29, 2011
+.Dd October 23, 2011
 .Dt DDB 4
 .Os
 .Sh NAME
@@ -568,21 +568,24 @@ show process information in a
 .Xr ps 1
 style format.
 Information printed includes: process ID, parent process ID,
-process group, UID, process status, process flags, process
+process group, UID, process status, process flags, number of LWPs,
 command name, and process wait channel message.
 .It Cm /a
-show the kernel virtual addresses of each process'
-proc structure, u-area, and vmspace structure.
+show each process ID, command name, kernel virtual addresses of
+each process' proc structure, u-area, and vmspace structure.
 The vmspace address is also the address of the process'
 vm_map structure, and can be used in the
 .Ic show map
 command.
 .It Cm /w
-show each process' PID, command, system call emulation, wait channel
-address, and wait channel message.
+show each LWP ID, process ID, command name, system call emulation,
+priority, wait channel message and wait channel address.
+LWPs currently running on a CPU are marked with the '\&>' sign.
 .It Cm /l
-show each process' associated LWP information, including each LWP's
-LID, flags, kernel LWP structure address, u-area, and wait channel.
+show each LWP ID, process ID, process status, CPU ID the LWP runs on,
+process flags, kernel virtual address of LWP structure,
+command name and wait channel message.
+LWPs currently running on a CPU are marked with the '\&>' sign.
 This is the default.
 .El
 .It Ic show arptab
@@ -694,6 +697,22 @@ Print the log entries for this pool.
 .It Cm /p
 Print the pagelist for this pool.
 .El
+.It Ic show proc Ns Oo Cm /ap Oc Ar address | pid
+Show information about a process and its LWPs.
+LWPs currently running on a CPU are marked with the '\&>' sign.
+.Bl -tag -width 4n -compact
+.It Cm /a
+The argument passed is the kernel virtual address
+of LWP structure.
+.It Cm /p
+The argument passed is a PID.
+Note that
+.Ar pid
+is interpreted using the current radix (see
+.Cm trace/t
+command for details).
+This is the default.
+.El
 .It Ic show registers Ns Op Cm /u
 Display the register set.
 If



CVS commit: src/sys/arch

2011-10-18 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Oct 18 23:43:06 UTC 2011

Modified Files:
src/sys/arch/x86/x86: pmap.c
src/sys/arch/xen/x86: xen_pmap.c

Log Message:
Move Xen specific functions out of x86 native pmap to xen_pmap.c.

Provide a wrapper to trigger pmap pool_cache(9) invalidations without
exposing the caches to outside world.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/xen/x86/xen_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.136 src/sys/arch/x86/x86/pmap.c:1.137
--- src/sys/arch/x86/x86/pmap.c:1.136	Tue Oct 18 23:14:28 2011
+++ src/sys/arch/x86/x86/pmap.c	Tue Oct 18 23:43:06 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.136 2011/10/18 23:14:28 jym Exp $	*/
+/*	$NetBSD: pmap.c,v 1.137 2011/10/18 23:43:06 jym Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.136 2011/10/18 23:14:28 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.137 2011/10/18 23:43:06 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -4412,118 +4412,18 @@ x86_mmap_flags(paddr_t mdpgno)
 	return pflag;
 }
 
-#ifdef XEN
 /*
- * Flush all APDP entries found in pmaps
- * Required during Xen save/restore operations, as it does not
- * handle alternative recursive mappings properly
+ * Invalidates pool_cache(9) used by pmap(9).
  */
 void
-pmap_unmap_all_apdp_pdes(void)
+pmap_invalidate_pool_caches(void)
 {
-
-	int i;
-	int s;
-	struct pmap *pm;
-
-	s = splvm();
-
-	pmap_unmap_apdp();
-
-	mutex_enter(&pmaps_lock);
-	/*
-	 * Set APDP entries to 0 in all pmaps.
-	 * Note that for PAE kernels, this only clears the APDP entries
-	 * found in the L2 shadow pages, as pmap_pdirpa() is used to obtain
-	 * the PA of the pmap->pm_pdir[] pages (forming the 4 contiguous
-	 * pages of PAE PD: 3 for user space, 1 for the L2 kernel shadow page)
-	 */
-	LIST_FOREACH(pm, &pmaps, pm_list) {
-		for (i = 0; i < PDP_SIZE; i++) {
-			xpq_queue_pte_update(
-			xpmap_ptom(pmap_pdirpa(pm, PDIR_SLOT_APTE + i)), 0);
-		}
-	}
-	mutex_exit(&pmaps_lock);
-
-	xpq_flush_queue();
-
-	splx(s);
-
-}
-
-#ifdef PAE
-/*
- * NetBSD uses L2 shadow pages to support PAE with Xen. However, Xen does not
- * handle them correctly during save/restore, leading to incorrect page
- * tracking and pinning during restore.
- * For save/restore to succeed, two functions are introduced:
- * - pmap_map_recursive_entries(), used by resume code to set the recursive
- *   mapping entries to their correct value
- * - pmap_unmap_recursive_entries(), used by suspend code to clear all
- *   PDIR_SLOT_PTE entries
- */
-void
-pmap_map_recursive_entries(void)
-{
-
-	int i;
-	struct pmap *pm;
-
-	mutex_enter(&pmaps_lock);
-
-	LIST_FOREACH(pm, &pmaps, pm_list) {
-		for (i = 0; i < PDP_SIZE; i++) {
-			xpq_queue_pte_update(
-			xpmap_ptom(pmap_pdirpa(pm, PDIR_SLOT_PTE + i)),
-			xpmap_ptom((pm)->pm_pdirpa[i]) | PG_V);
-		}
-	}
-
-	mutex_exit(&pmaps_lock);
-
-	for (i = 0; i < PDP_SIZE; i++) {
-		xpq_queue_pte_update(
-		xpmap_ptom(pmap_pdirpa(pmap_kernel(), PDIR_SLOT_PTE + i)),
-		xpmap_ptom(pmap_kernel()->pm_pdirpa[i]) | PG_V);
-	}
-
-	xpq_flush_queue();
-}
-
-void
-pmap_unmap_recursive_entries(void)
-{
-
-	int i;
-	struct pmap *pm;
-
+#ifdef XEN
 	/*
 	 * We must invalidate all shadow pages found inside the pmap_pdp_cache.
 	 * They are technically considered by Xen as L2 pages, although they
 	 * are not currently found inside pmaps list.
 	 */
 	pool_cache_invalidate(&pmap_pdp_cache);
-
-	mutex_enter(&pmaps_lock);
-
-	LIST_FOREACH(pm, &pmaps, pm_list) {
-		for (i = 0; i < PDP_SIZE; i++) {
-			xpq_queue_pte_update(
-			xpmap_ptom(pmap_pdirpa(pm, PDIR_SLOT_PTE + i)), 0);
-		}
-	}
-
-	mutex_exit(&pmaps_lock);
-
-	/* do it for pmap_kernel() too! */
-	for (i = 0; i < PDP_SIZE; i++)
-		xpq_queue_pte_update(
-		xpmap_ptom(pmap_pdirpa(pmap_kernel(), PDIR_SLOT_PTE + i)),
-		0);
-
-	xpq_flush_queue();
-
+#endif
 }
-#endif /* PAE */
-#endif /* XEN */

Index: src/sys/arch/xen/x86/xen_pmap.c
diff -u src/sys/arch/xen/x86/xen_pmap.c:1.5 src/sys/arch/xen/x86/xen_pmap.c:1.6
--- src/sys/arch/xen/x86/xen_pmap.c:1.5	Tue Sep 20 00:12:24 2011
+++ src/sys/arch/xen/x86/xen_pmap.c	Tue Oct 18 23:43:06 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_pmap.c,v 1.5 2011/09/20 00:12:24 jym Exp $	*/
+/*	$NetBSD: xen_pmap.c,v 1.6 2011/10/18 23:43:06 jym Exp $	*/
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.5 2011/09/20 00:12:24 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.6 2011/10/18 23:43:06 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -440,3 +440,113 @@ pmap_extract_ma(struct pmap *pma

CVS commit: src/sys/arch/x86

2011-10-18 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Oct 18 23:14:28 UTC 2011

Modified Files:
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: pmap.c

Log Message:
Make "pmaps" (list of non-kernel pmaps) and "pmaps_lock" externally
visible. Required by pmap MD code that could reside in other
files, notably Xen's pmap.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.135 -r1.136 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/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.42 src/sys/arch/x86/include/pmap.h:1.43
--- src/sys/arch/x86/include/pmap.h:1.42	Tue Sep 20 00:12:23 2011
+++ src/sys/arch/x86/include/pmap.h	Tue Oct 18 23:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.42 2011/09/20 00:12:23 jym Exp $	*/
+/*	$NetBSD: pmap.h,v 1.43 2011/10/18 23:14:28 jym Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -119,6 +119,12 @@
 LIST_HEAD(pmap_head, pmap); /* struct pmap_head: head of a pmap list */
 
 /*
+ * linked list of all non-kernel pmaps
+ */
+extern struct pmap_head pmaps;
+extern kmutex_t pmaps_lock;/* protects pmaps */
+
+/*
  * the pmap structure
  *
  * note that the pm_obj contains the lock pointer, the reference count,
@@ -245,6 +251,8 @@ u_int		x86_mmap_flags(paddr_t);
 
 bool		pmap_is_curpmap(struct pmap *);
 
+void		pmap_invalidate_pool_caches(void);
+
 vaddr_t reserve_dumppages(vaddr_t); /* XXX: not a pmap fn */
 
 typedef enum tlbwhy {

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.135 src/sys/arch/x86/x86/pmap.c:1.136
--- src/sys/arch/x86/x86/pmap.c:1.135	Tue Oct 11 23:53:31 2011
+++ src/sys/arch/x86/x86/pmap.c	Tue Oct 18 23:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.135 2011/10/11 23:53:31 yamt Exp $	*/
+/*	$NetBSD: pmap.c,v 1.136 2011/10/18 23:14:28 jym Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.135 2011/10/11 23:53:31 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.136 2011/10/18 23:14:28 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -325,7 +325,8 @@ pd_entry_t * const normal_pdes[] = PDES_
 
 long nkptp[] = NKPTP_INITIALIZER;
 
-static kmutex_t pmaps_lock;
+struct pmap_head pmaps;
+kmutex_t pmaps_lock;
 
 static vaddr_t pmap_maxkvaddr;
 
@@ -481,12 +482,6 @@ static vaddr_t virtual_avail __read_most
 static vaddr_t virtual_end __read_mostly;	/* VA of last free KVA */
 
 /*
- * linked list of all non-kernel pmaps
- */
-
-static struct pmap_head pmaps;
-
-/*
  * pool that pmap structures are allocated from
  */
 



CVS commit: src/usr.bin/pmap

2011-10-18 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Oct 18 20:54:57 UTC 2011

Modified Files:
src/usr.bin/pmap: main.c

Log Message:
Disallow printing of kernel mappings if we are not root.

pid 0 is a special case for kill(pid, 0), and unlikely to be the
correct test there. This follows the procfs "mem" rights changes that
happened some time ago.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/pmap/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/pmap/main.c
diff -u src/usr.bin/pmap/main.c:1.21 src/usr.bin/pmap/main.c:1.22
--- src/usr.bin/pmap/main.c:1.21	Thu Jun 23 22:50:53 2011
+++ src/usr.bin/pmap/main.c	Tue Oct 18 20:54:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.21 2011/06/23 22:50:53 christos Exp $ */
+/*	$NetBSD: main.c,v 1.22 2011/10/18 20:54:56 jym Exp $ */
 
 /*
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.21 2011/06/23 22:50:53 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.22 2011/10/18 20:54:56 jym Exp $");
 #endif
 
 #include 
@@ -308,15 +308,23 @@ main(int argc, char *argv[])
 			}
 		}
 
+		/*
+		 * Only print mappings for processes we can send a signal(7)
+		 * to, or kernel mappings if we are root
+		 */
+		if (kill(pid, 0) == -1 ||
+		   (pid == 0 && getuid() != 0)) {
+			errno = EPERM;
+			warn("%d", pid);
+			pid = -1;
+			continue;
+
+		}
+
 		/* find the process id */
 		if (pid == 0)
 			kproc = NULL;
 		else {
-			if (kill(pid, 0) == -1) {
-warn("%d", pid);
-pid = -1;
-continue;
-			}
 			kproc = kvm_getproc2(kd, KERN_PROC_PID, pid,
 	 sizeof(struct kinfo_proc2), &rc);
 			if (kproc == NULL || rc == 0) {



CVS commit: src/external/bsd/less/dist

2011-10-16 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Oct 16 21:02:32 UTC 2011

Modified Files:
src/external/bsd/less/dist: less.1

Log Message:
Document the MORE environment variable.

Noted by James K. Lowden  in a
private mail.

Will submit upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/less/dist/less.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/less/dist/less.1
diff -u src/external/bsd/less/dist/less.1:1.1.1.1 src/external/bsd/less/dist/less.1:1.2
--- src/external/bsd/less/dist/less.1:1.1.1.1	Sun Jul  3 18:01:00 2011
+++ src/external/bsd/less/dist/less.1	Sun Oct 16 21:02:31 2011
@@ -1666,6 +1666,10 @@ Takes precedence over the number of line
 (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
 the window system's idea of the screen size takes precedence over the
 LINES and COLUMNS environment variables.)
+.IP MORE
+Options which are passed to 
+.I more
+automatically.
 .IP PATH
 User's search path (used to find a lesskey file 
 on MS-DOS and OS/2 systems).



CVS commit: src

2011-09-30 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Fri Sep 30 22:17:51 UTC 2011

Modified Files:
src: UPDATING

Log Message:
Inform that the prop_{array,dictionary}_send_syscall(3) change breaks
backward compatibility with old quota2 binaries, so ensure that you
update both (proplib + quota2 executables) simultaneously when updating
a -current installation.


To generate a diff of this commit:
cvs rdiff -u -r1.228 -r1.229 src/UPDATING

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/UPDATING
diff -u src/UPDATING:1.228 src/UPDATING:1.229
--- src/UPDATING:1.228	Wed Aug 17 09:18:38 2011
+++ src/UPDATING	Fri Sep 30 22:17:50 2011
@@ -1,4 +1,4 @@
-$NetBSD: UPDATING,v 1.228 2011/08/17 09:18:38 mrg Exp $
+$NetBSD: UPDATING,v 1.229 2011/09/30 22:17:50 jym Exp $
 
 This file (UPDATING) is intended to be a brief reference to recent
 changes that might cause problems in the build process, and a guide for
@@ -15,6 +15,12 @@ See also: BUILDING, build.sh, Makefile.
 
 Recent changes:
 ^^^
+20111001:
+	the prop_*_send_syscall() functions from proplib(3) have been
+	changed and their new version is not backward compatible with the old
+	one. So ensure that all consumers of these functions (currently:
+	quota2 code and its tests) are updated together with the new lib.
+
 20110817:
 	sparc has been changed to use GCC 4.5.3, so any objdir or
 	DESTDIR for them should be deleted before updating.



CVS commit: src

2011-09-30 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Fri Sep 30 22:08:20 UTC 2011

Modified Files:
src/common/include/prop: prop_array.h prop_dictionary.h
src/common/lib/libprop: prop_array.3 prop_dictionary.3 prop_kern.c
prop_send_syscall.3
src/distrib/sets/lists/comp: mi
src/lib/libprop: Makefile
src/lib/libquota: getufsquota.c
src/usr.bin/quota: getvfsquota.c
src/usr.sbin/edquota: edquota.c
src/usr.sbin/quotaon: quotaon.c
src/usr.sbin/repquota: repquota.c

Log Message:
Fix an implementation inconsistency with the prop_*_send_syscall() and
prop_*_recv_syscall() functions from proplib(3). They now share the
same logic as the one from prop_*_send_ioctl() functions:
- returns an int
- 0 indicates "no error", otherwise returns the error number (and
set errno)

Many consumers of the prop_*_{ioctl, syscall} expect errno to be set
on error and use err() to display the error message. As such, ensures that
errno gets set before returning from these functions.

prop_*_send_syscall() functions returned a boolean, and now return an int.
Fix all call sites to use the new paradigm (only quota2 is affected in src).

As the prop_*_{send,recv}_syscall() API appeared in -current and is only
used by the recent quota2 code, I am not bumping the lib. The API change
only affects the prop_*_send_syscall() function (recv_syscall()s were
already used correctly), so ensure you are not mixing "old" -current
quota binaries with a new proplib(3) (or the other way around). This
change will be announced via a HEADS-UP and UPDATING.

Does not affect the kernel part of proplib.

Document the correct API in prop_array(3) and prop_dictionary(3).

Thanks to Francois Tigeot for noticing the API inconsistency and
reporting it on tech-kern@.

ok bouyer@.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/common/include/prop/prop_array.h
cvs rdiff -u -r1.13 -r1.14 src/common/include/prop/prop_dictionary.h
cvs rdiff -u -r1.12 -r1.13 src/common/lib/libprop/prop_array.3
cvs rdiff -u -r1.17 -r1.18 src/common/lib/libprop/prop_dictionary.3
cvs rdiff -u -r1.16 -r1.17 src/common/lib/libprop/prop_kern.c
cvs rdiff -u -r1.4 -r1.5 src/common/lib/libprop/prop_send_syscall.3
cvs rdiff -u -r1.1682 -r1.1683 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.18 -r1.19 src/lib/libprop/Makefile
cvs rdiff -u -r1.2 -r1.3 src/lib/libquota/getufsquota.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/quota/getvfsquota.c
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/edquota/edquota.c
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/quotaon/quotaon.c
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/repquota/repquota.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/include/prop/prop_array.h
diff -u src/common/include/prop/prop_array.h:1.12 src/common/include/prop/prop_array.h:1.13
--- src/common/include/prop/prop_array.h:1.12	Thu Mar 24 17:05:39 2011
+++ src/common/include/prop/prop_array.h	Fri Sep 30 22:08:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: prop_array.h,v 1.12 2011/03/24 17:05:39 bouyer Exp $*/
+/* $NetBSD: prop_array.h,v 1.13 2011/09/30 22:08:18 jym Exp $*/
 
 /*-
  * Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
@@ -70,10 +70,12 @@ struct plistref;
 
 #if !defined(_KERNEL) && !defined(_STANDALONE)
 bool		prop_array_externalize_to_pref(prop_array_t, struct plistref *);
+bool		prop_array_internalize_from_pref(const struct plistref *,
+		 prop_array_t *);
 int		prop_array_send_ioctl(prop_array_t, int, unsigned long);
 int		prop_array_recv_ioctl(int, unsigned long, prop_array_t *);
-bool		prop_array_send_syscall(prop_array_t, struct plistref *);
-bool		prop_array_recv_syscall(const struct plistref *,
+int		prop_array_send_syscall(prop_array_t, struct plistref *);
+int		prop_array_recv_syscall(const struct plistref *,
 	prop_array_t *);
 #elif defined(_KERNEL)
 int		prop_array_copyin(const struct plistref *, prop_array_t *);

Index: src/common/include/prop/prop_dictionary.h
diff -u src/common/include/prop/prop_dictionary.h:1.13 src/common/include/prop/prop_dictionary.h:1.14
--- src/common/include/prop/prop_dictionary.h:1.13	Thu Mar 24 17:05:39 2011
+++ src/common/include/prop/prop_dictionary.h	Fri Sep 30 22:08:18 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: prop_dictionary.h,v 1.13 2011/03/24 17:05:39 bouyer Exp $	*/
+/*	$NetBSD: prop_dictionary.h,v 1.14 2011/09/30 22:08:18 jym Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
@@ -86,6 +86,8 @@ struct plistref;
 
 #if !defined(_KERNEL) && !defined(_STANDALONE)
 bool		prop_dictionary_externalize_to_pref(prop_dictionary_t, struct plistref *);
+bool		prop_dictionary_internalize_from_pref(const struct plistref *,
+		  prop_dictionary_t *);
 int		prop_dictionary_send_ioctl(prop_dictionary_t, int,
 	   unsigned long);
 int		prop_dictionary_recv_ioctl(i

CVS commit: src/common/lib/libprop

2011-09-27 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Sep 27 11:12:49 UTC 2011

Modified Files:
src/common/lib/libprop: prop_send_ioctl.3

Log Message:
Indicate type of return variable for prop_dictionary_sendrecv_ioctl.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/common/lib/libprop/prop_send_ioctl.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libprop/prop_send_ioctl.3
diff -u src/common/lib/libprop/prop_send_ioctl.3:1.7 src/common/lib/libprop/prop_send_ioctl.3:1.8
--- src/common/lib/libprop/prop_send_ioctl.3:1.7	Thu Jan 20 10:45:10 2011
+++ src/common/lib/libprop/prop_send_ioctl.3	Tue Sep 27 11:12:49 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: prop_send_ioctl.3,v 1.7 2011/01/20 10:45:10 wiz Exp $
+.\"	$NetBSD: prop_send_ioctl.3,v 1.8 2011/09/27 11:12:49 jym Exp $
 .\"
 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -49,6 +49,7 @@
 .Ft int
 .Fn prop_dictionary_recv_ioctl "int fd" "unsigned long cmd" \
 "prop_dictionary_t *dictp"
+.Ft int
 .Fn prop_dictionary_sendrecv_ioctl "prop_dictionary_t dict" "int fd" \
 "unsigned long cmd" "prop_dictionary_t *dictp"
 .Sh DESCRIPTION



CVS commit: src/sys

2011-09-26 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Sep 27 01:02:39 UTC 2011

Modified Files:
src/sys/arch/evbmips/evbmips: interrupt.c
src/sys/arch/mips/mips: mips_softint.c pmap_tlb.c syscall.c
vm_machdep.c
src/sys/arch/mips/ralink: ralink_gpio.c ralink_intr.c
src/sys/arch/mips/rmi: rmixl_fmn.c rmixl_intr.c
src/sys/arch/powerpc/booke: booke_pmap.c e500_intr.c trap.c
src/sys/arch/powerpc/booke/dev: pq3etsec.c
src/sys/arch/powerpc/booke/pci: pq3pci.c
src/sys/arch/powerpc/include: userret.h
src/sys/arch/powerpc/include/oea: pmap.h
src/sys/arch/powerpc/pic: intr.c
src/sys/arch/powerpc/powerpc: process_machdep.c softint_machdep.c
trap.c
src/sys/arch/x86/x86: pmap.c
src/sys/arch/xen/x86: xen_ipi.c
src/sys/common/pmap/tlb: pmap.c pmap_tlb.c
src/sys/dev/ic: siisata.c
src/sys/dev/usb: usb_mem.c
src/sys/kern: kern_mutex_obj.c kern_softint.c kern_synch.c subr_evcnt.c
subr_pcu.c subr_pool.c
src/sys/lib/libkern: libkern.h
src/sys/uvm: uvm_bio.c uvm_map.c uvm_pglist.c

Log Message:
Modify *ASSERTMSG() so they are now used as variadic macros. The main goal
is to provide routines that do as KASSERT(9) says: append a message
to the panic format string when the assertion triggers, with optional
arguments.

Fix call sites to reflect the new definition.

Discussed on tech-kern@. See
http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/evbmips/evbmips/interrupt.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/mips/mips/mips_softint.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/mips/pmap_tlb.c
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/mips/mips/syscall.c
cvs rdiff -u -r1.140 -r1.141 src/sys/arch/mips/mips/vm_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/ralink/ralink_gpio.c \
src/sys/arch/mips/ralink/ralink_intr.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/rmi/rmixl_fmn.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/rmi/rmixl_intr.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/booke/booke_pmap.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/powerpc/booke/e500_intr.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/powerpc/booke/trap.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/powerpc/booke/dev/pq3etsec.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/booke/pci/pq3pci.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/powerpc/include/userret.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/powerpc/include/oea/pmap.h
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/powerpc/pic/intr.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/powerpc/powerpc/process_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/powerpc/powerpc/softint_machdep.c
cvs rdiff -u -r1.144 -r1.145 src/sys/arch/powerpc/powerpc/trap.c
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/xen/x86/xen_ipi.c
cvs rdiff -u -r1.9 -r1.10 src/sys/common/pmap/tlb/pmap.c
cvs rdiff -u -r1.10 -r1.11 src/sys/common/pmap/tlb/pmap_tlb.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/siisata.c
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/usb/usb_mem.c
cvs rdiff -u -r1.4 -r1.5 src/sys/kern/kern_mutex_obj.c
cvs rdiff -u -r1.37 -r1.38 src/sys/kern/kern_softint.c
cvs rdiff -u -r1.290 -r1.291 src/sys/kern/kern_synch.c
cvs rdiff -u -r1.10 -r1.11 src/sys/kern/subr_evcnt.c
cvs rdiff -u -r1.9 -r1.10 src/sys/kern/subr_pcu.c
cvs rdiff -u -r1.189 -r1.190 src/sys/kern/subr_pool.c
cvs rdiff -u -r1.100 -r1.101 src/sys/lib/libkern/libkern.h
cvs rdiff -u -r1.78 -r1.79 src/sys/uvm/uvm_bio.c
cvs rdiff -u -r1.304 -r1.305 src/sys/uvm/uvm_map.c
cvs rdiff -u -r1.61 -r1.62 src/sys/uvm/uvm_pglist.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/evbmips/evbmips/interrupt.c
diff -u src/sys/arch/evbmips/evbmips/interrupt.c:1.17 src/sys/arch/evbmips/evbmips/interrupt.c:1.18
--- src/sys/arch/evbmips/evbmips/interrupt.c:1.17	Sun Jul 10 00:03:53 2011
+++ src/sys/arch/evbmips/evbmips/interrupt.c	Tue Sep 27 01:02:33 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: interrupt.c,v 1.17 2011/07/10 00:03:53 matt Exp $	*/
+/*	$NetBSD: interrupt.c,v 1.18 2011/09/27 01:02:33 jym Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.17 2011/07/10 00:03:53 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.18 2011/09/27 01:02:33 jym Exp $");
 
 #include 
 #include 
@@ -66,15 +66,14 @@ cpu_intr(int ppl, vaddr_t pc, uint32_t s
 		splx(ipl);	/* lower to interrupt level */
 
 		KASSERTMSG(ci->ci_cpl == ipl,
-		("%s: cpl (%d) != ipl (%d)",
-		__func__, ci->ci_cpl, ipl));
+		"%s: cpl (%d) != ipl (%d)", __func__, ci->ci_cpl, ipl);
 		KASSERT(pending != 0);
 
 		if (pending & MIPS_INT_MASK_5) {
 			struct clockframe cf;
 			KASSERTMSG(ipl == IPL_SCHED,
-			("%s: ipl (%d)

CVS commit: src

2011-09-26 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Sep 27 00:36:51 UTC 2011

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: KASSERT.9 Makefile

Log Message:
Document new *ASSERTMSG() prototype, and update KASSERT(9).

See also
http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html


To generate a diff of this commit:
cvs rdiff -u -r1.1679 -r1.1680 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.12 -r1.13 src/share/man/man9/KASSERT.9
cvs rdiff -u -r1.349 -r1.350 src/share/man/man9/Makefile

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/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1679 src/distrib/sets/lists/comp/mi:1.1680
--- src/distrib/sets/lists/comp/mi:1.1679	Sun Sep 25 04:11:47 2011
+++ src/distrib/sets/lists/comp/mi	Tue Sep 27 00:36:49 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1679 2011/09/25 04:11:47 christos Exp $
+#	$NetBSD: mi,v 1.1680 2011/09/27 00:36:49 jym Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -9410,6 +9410,7 @@
 ./usr/share/man/cat9/KASSERT.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/KASSERTMSG.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/KDASSERT.0			comp-sys-catman		.cat
+./usr/share/man/cat9/KDASSERTMSG.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/KNOTE.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/LWP_CACHE_CREDS.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/MALLOC.0			comp-sys-catman		.cat
@@ -15503,6 +15504,7 @@
 ./usr/share/man/html9/KASSERT.html		comp-sys-htmlman	html
 ./usr/share/man/html9/KASSERTMSG.html		comp-sys-htmlman	html
 ./usr/share/man/html9/KDASSERT.html		comp-sys-htmlman	html
+./usr/share/man/html9/KDASSERTMSG.html		comp-sys-htmlman	html
 ./usr/share/man/html9/KNOTE.html		comp-sys-htmlman	html
 ./usr/share/man/html9/LWP_CACHE_CREDS.html	comp-sys-htmlman	html
 ./usr/share/man/html9/MALLOC.html		comp-sys-htmlman	html
@@ -21681,6 +21683,7 @@
 ./usr/share/man/man9/KASSERT.9			comp-sys-man		.man
 ./usr/share/man/man9/KASSERTMSG.9		comp-sys-man		.man
 ./usr/share/man/man9/KDASSERT.9			comp-sys-man		.man
+./usr/share/man/man9/KDASSERTMSG.9		comp-sys-man		.man
 ./usr/share/man/man9/KNOTE.9			comp-sys-man		.man
 ./usr/share/man/man9/LWP_CACHE_CREDS.9		comp-sys-man		.man
 ./usr/share/man/man9/MALLOC.9			comp-sys-man		.man

Index: src/share/man/man9/KASSERT.9
diff -u src/share/man/man9/KASSERT.9:1.12 src/share/man/man9/KASSERT.9:1.13
--- src/share/man/man9/KASSERT.9:1.12	Wed Apr  6 05:40:19 2011
+++ src/share/man/man9/KASSERT.9	Tue Sep 27 00:36:51 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: KASSERT.9,v 1.12 2011/04/06 05:40:19 jruoho Exp $
+.\" $NetBSD: KASSERT.9,v 1.13 2011/09/27 00:36:51 jym Exp $
 .\"
 .\" Copyright (c) 2006 Igor Sobrado
 .\" All rights reserved.
@@ -24,21 +24,24 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 6, 2011
+.Dd September 27, 2011
 .Dt KASSERT 9
 .Os
 .Sh NAME
 .Nm KASSERT ,
 .Nm KASSERTMSG ,
-.Nm KDASSERT
+.Nm KDASSERT ,
+.Nm KDASSERTMSG
 .Nd kernel expression verification macros
 .Sh SYNOPSIS
 .Ft void
 .Fn KASSERT expression
 .Ft void
-.Fn KASSERTMSG expression message
+.Fn KASSERTMSG expression format ...
 .Ft void
 .Fn KDASSERT expression
+.Ft void
+.Fn KDASSERTMSG expression format ...
 .Sh DESCRIPTION
 These machine independent assertion-checking macros cause a kernel
 .Xr panic 9
@@ -62,6 +65,8 @@ the macros are defined to be no-ops.
 .It
 The
 .Fn KDASSERT
+and
+.Fn KDASSERTMSG
 tests are included only in kernels compiled with the
 .Dv DEBUG
 configuration option.
@@ -91,11 +96,16 @@ vs. diagnostic), the expression that fai
 number the failure happened on.
 The
 .Fn KASSERTMSG
-macro appends additional
-.Fa message
+and
+.Fn KDASSERTMSG
+macros append
 to the
 .Xr panic 9
-format string.
+format string the message specified by
+.Fa format
+and its subsequent arguments, similar to
+.Xr printf 9
+functions.
 .Sh SEE ALSO
 .Xr config 1 ,
 .Xr options 4 ,

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.349 src/share/man/man9/Makefile:1.350
--- src/share/man/man9/Makefile:1.349	Sat Jul 30 18:19:05 2011
+++ src/share/man/man9/Makefile	Tue Sep 27 00:36:51 2011
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.349 2011/07/30 18:19:05 rmind Exp $
+#   $NetBSD: Makefile,v 1.350 2011/09/27 00:36:51 jym Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -81,7 +81,8 @@ MLINKS+=dmover.9 dmover_backend_register
 MAN+=	CTASSERT.9
 MAN+=	KASSERT.9
 MLINKS+=KASSERT.9 KASSERTMSG.9 \
-	KASSERT.9 KDASSERT.9
+	KASSERT.9 KDASSERT.9 \
+	KASSERT.9 KDASSERTMSG.9
 
 MLINKS+=accept_filter.9 accept_filt_add.9
 MLINKS+=accept_filter.9 accept_filt_del.9



CVS commit: src/sys/arch/xen/xen

2011-09-26 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Sep 26 21:44:09 UTC 2011

Modified Files:
src/sys/arch/xen/xen: if_xennet_xenbus.c

Log Message:
Fix a fallout with my xensuspend merge: talk_to_backend() returns a
boolean, so checking for "true" with "== 0" is... wrong.

Now xennet(4) should work as expected, and not stay in the InitWait state
(which blocks network communication with the backend).

Thanks to riz@ and sborrill@ for reporting breakage with -current
xennet(4) after my merge.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/xen/xen/if_xennet_xenbus.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/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.52 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.53
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.52	Tue Sep 20 00:12:24 2011
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Mon Sep 26 21:44:09 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.52 2011/09/20 00:12:24 jym Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.53 2011/09/26 21:44:09 jym Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -85,7 +85,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.52 2011/09/20 00:12:24 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.53 2011/09/26 21:44:09 jym Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -223,7 +223,7 @@ static void xennet_free_rx_buffer(struct
 static void xennet_tx_complete(struct xennet_xenbus_softc *);
 static void xennet_rx_mbuf_free(struct mbuf *, void *, size_t, void *);
 static int  xennet_handler(void *);
-static int  xennet_talk_to_backend(struct xennet_xenbus_softc *);
+static bool xennet_talk_to_backend(struct xennet_xenbus_softc *);
 #ifdef XENNET_DEBUG_DUMP
 static void xennet_hex_dump(const unsigned char *, size_t, const char *, int);
 #endif
@@ -518,7 +518,7 @@ abort_resume:
 	return false;
 }
 
-static int
+static bool
 xennet_talk_to_backend(struct xennet_xenbus_softc *sc)
 {
 	int error;
@@ -657,7 +657,7 @@ static void xennet_backend_changed(void 
 	case XenbusStateInitWait:
 		if (sc->sc_backend_status == BEST_CONNECTED)
 			break;
-		if (xennet_talk_to_backend(sc) == 0)
+		if (xennet_talk_to_backend(sc))
 			xenbus_switch_state(sc->sc_xbusd, NULL,
 			XenbusStateConnected);
 		break;



CVS commit: src/sys/lib/libkern

2011-09-25 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Sep 25 20:31:18 UTC 2011

Modified Files:
src/sys/lib/libkern: libkern.h

Log Message:
Do as Joerg said and kill the __STDC__ blocks. They only make sense for
things used by assembler, which won't be the case for these macros.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/lib/libkern/libkern.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/lib/libkern/libkern.h
diff -u src/sys/lib/libkern/libkern.h:1.99 src/sys/lib/libkern/libkern.h:1.100
--- src/sys/lib/libkern/libkern.h:1.99	Thu Sep  1 22:35:17 2011
+++ src/sys/lib/libkern/libkern.h	Sun Sep 25 20:31:18 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: libkern.h,v 1.99 2011/09/01 22:35:17 jym Exp $	*/
+/*	$NetBSD: libkern.h,v 1.100 2011/09/25 20:31:18 jym Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -177,13 +177,8 @@ tolower(int ch)
 #ifdef NDEBUG		/* tradition! */
 #define	assert(e)	((void)0)
 #else
-#ifdef __STDC__
 #define	assert(e)	(__predict_true((e)) ? (void)0 :		\
 			kern_assert("", __FILE__, __LINE__, #e))
-#else
-#define	assert(e)	(__predict_true((e)) ? (void)0 :		\
-			kern_assert("", __FILE__, __LINE__, "e"))
-#endif
 #endif
 
 #ifdef __COVERITY__
@@ -209,13 +204,8 @@ tolower(int ch)
 	if (__predict_false(!(e)))	\
 		panic msg;		\
 	} while (/*CONSTCOND*/ 0)
-#ifdef __STDC__
 #define	KASSERT(e)	(__predict_true((e)) ? (void)0 :		\
 			kern_assert("diagnostic ", __FILE__, __LINE__, #e))
-#else
-#define	KASSERT(e)	(__predict_true((e)) ? (void)0 :		\
-			kern_assert("diagnostic ", __FILE__, __LINE__,"e"))
-#endif
 #endif
 
 #ifndef DEBUG
@@ -231,13 +221,8 @@ tolower(int ch)
 	if (__predict_false(!(e)))	\
 		panic msg;		\
 	} while (/*CONSTCOND*/ 0)
-#ifdef __STDC__
 #define	KDASSERT(e)	(__predict_true((e)) ? (void)0 :		\
 			kern_assert("debugging ", __FILE__, __LINE__, #e))
-#else
-#define	KDASSERT(e)	(__predict_true((e)) ? (void)0 :		\
-			kern_assert("debugging ", __FILE__, __LINE__, "e"))
-#endif
 #endif
 /*
  * XXX: For compatibility we use SMALL_RANDOM by default.



CVS commit: src/sys/arch/x86/x86

2011-09-25 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Sep 25 18:39:31 UTC 2011

Modified Files:
src/sys/arch/x86/x86: pmap.c

Log Message:
Fix a small typo in comment: pmaps_lock is the lock that keeps all
pmaps in sync for kernel mappings (including when they are obtained from
pool caches).


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 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.130 src/sys/arch/x86/x86/pmap.c:1.131
--- src/sys/arch/x86/x86/pmap.c:1.130	Tue Sep 20 00:12:23 2011
+++ src/sys/arch/x86/x86/pmap.c	Sun Sep 25 18:39:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.130 2011/09/20 00:12:23 jym Exp $	*/
+/*	$NetBSD: pmap.c,v 1.131 2011/09/25 18:39:30 jym Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.130 2011/09/20 00:12:23 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.131 2011/09/25 18:39:30 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1982,7 +1982,7 @@ pmap_pdp_ctor(void *arg, void *v, int fl
 #endif
 
 	/*
-	 * NOTE: The `pmap_lock' is held when the PDP is allocated.
+	 * NOTE: The `pmaps_lock' is held when the PDP is allocated.
 	 */
 
 #if defined(XEN) && defined(__x86_64__)



CVS commit: src/sys/arch

2011-09-24 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Sep 24 21:24:52 UTC 2011

Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/i386/i386: cpufunc.S

Log Message:
White space fix.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/i386/cpufunc.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/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.20 src/sys/arch/amd64/amd64/cpufunc.S:1.21
--- src/sys/arch/amd64/amd64/cpufunc.S:1.20	Sat Sep 24 10:32:52 2011
+++ src/sys/arch/amd64/amd64/cpufunc.S	Sat Sep 24 21:24:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.20 2011/09/24 10:32:52 jym Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.21 2011/09/24 21:24:52 jym Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -252,7 +252,7 @@ NENTRY(msr_onfault)
 	movq	L_PCB(%r8), %r8
 	movq	$0, PCB_ONFAULT(%r8)
 	movl	$EFAULT, %eax
-ret
+	ret
 
 #ifndef XEN
 ENTRY(wbinvd)

Index: src/sys/arch/i386/i386/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.16 src/sys/arch/i386/i386/cpufunc.S:1.17
--- src/sys/arch/i386/i386/cpufunc.S:1.16	Sat Sep 24 10:32:52 2011
+++ src/sys/arch/i386/i386/cpufunc.S	Sat Sep 24 21:24:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.16 2011/09/24 10:32:52 jym Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.17 2011/09/24 21:24:52 jym Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.16 2011/09/24 10:32:52 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.17 2011/09/24 21:24:52 jym Exp $");
 
 #include "opt_xen.h"
 
@@ -165,11 +165,11 @@ ENTRY(rdmsr_safe)
  * MSR operations fault handler
  */
 NENTRY(msr_onfault)
-   	movl	CPUVAR(CURLWP), %ecx
+	movl	CPUVAR(CURLWP), %ecx
 	movl	L_PCB(%ecx), %ecx
 	movl	$0, PCB_ONFAULT(%ecx)
 	movl	$EFAULT, %eax
-ret
+	ret
 
 END(rdmsr_safe)
 



CVS commit: src/sys/arch/x86/x86

2011-09-24 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Sep 24 10:49:14 UTC 2011

Modified Files:
src/sys/arch/x86/x86: intel_busclock.c

Log Message:
Be conservative when reading MSR_FSB_FREQ by using rdmsr_safe(). We cannot
tell in advance when new CPU model/family combo will come and trying to
read that MSR early during boot may cause unhandled faults.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/x86/intel_busclock.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/intel_busclock.c
diff -u src/sys/arch/x86/x86/intel_busclock.c:1.12 src/sys/arch/x86/x86/intel_busclock.c:1.13
--- src/sys/arch/x86/x86/intel_busclock.c:1.12	Wed Feb 23 11:43:23 2011
+++ src/sys/arch/x86/x86/intel_busclock.c	Sat Sep 24 10:49:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_busclock.c,v 1.12 2011/02/23 11:43:23 jruoho Exp $	*/
+/*	$NetBSD: intel_busclock.c,v 1.13 2011/09/24 10:49:13 jym Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intel_busclock.c,v 1.12 2011/02/23 11:43:23 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_busclock.c,v 1.13 2011/09/24 10:49:13 jym Exp $");
 
 #include 
 #include 
@@ -104,13 +104,11 @@
 		 * Newer CPUs will GP when attemping to access MSR_FSB_FREQ.
 		 * In the long-term, use ACPI instead of all this.
 		 */
-		switch (CPUID2EXTMODEL(ci->ci_signature)) {
-		case 0x2:
-			aprint_debug("%s: unable to determine bus speed",
-			device_xname(ci->ci_dev));
+		if (rdmsr_safe(MSR_FSB_FREQ, &msr) == EFAULT) {
+			aprint_debug_dev(ci->ci_dev,
+			"unable to determine bus speed");
 			goto print_msr;
 		}
-		msr = rdmsr(MSR_FSB_FREQ);
 		bus = (msr >> 0) & 0x7;
 		switch (bus) {
 		case 1:
@@ -123,7 +121,11 @@
 		}
 		break;
 	case 0xd: /* Pentium M (90 nm, Dothan) */
-		msr = rdmsr(MSR_FSB_FREQ);
+		if (rdmsr_safe(MSR_FSB_FREQ, &msr) == EFAULT) {
+			aprint_debug_dev(ci->ci_dev,
+			"unable to determine bus speed");
+			goto print_msr;
+		}
 		bus = (msr >> 0) & 0x7;
 		switch (bus) {
 		case 0:
@@ -144,15 +146,18 @@
 		 * Newer CPUs will GP when attemping to access MSR_FSB_FREQ.
 		 * In the long-term, use ACPI instead of all this.
 		 */
-		switch (CPUID2EXTMODEL(ci->ci_signature)) {
-		case 0x1:
-			aprint_debug("%s: unable to determine bus speed",
-			device_xname(ci->ci_dev));
+		if (rdmsr_safe(MSR_FSB_FREQ, &msr) == EFAULT) {
+			aprint_debug_dev(ci->ci_dev,
+			"unable to determine bus speed");
 			goto print_msr;
 		}
 		/* FALLTHROUGH */
 	case 0xf: /* Core Xeon */
-		msr = rdmsr(MSR_FSB_FREQ);
+		if (rdmsr_safe(MSR_FSB_FREQ, &msr) == EFAULT) {
+			aprint_debug_dev(ci->ci_dev,
+			"unable to determine bus speed");
+			goto print_msr;
+		}
 		bus = (msr >> 0) & 0x7;
 		switch (bus) {
 		case 5:



CVS commit: src/sys/arch

2011-09-24 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Sep 24 10:32:53 UTC 2011

Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/i386/i386: cpufunc.S
src/sys/arch/x86/include: cpufunc.h

Log Message:
Import rdmsr_safe(msr, *value) for x86 world. It allows reading MSRs
in a safe way by handling the fault that might trigger for certain
register <> CPU/arch combos.

Requested by Jukka. Patch adapted from one found in DragonflyBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/i386/i386/cpufunc.S
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/include/cpufunc.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/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.19 src/sys/arch/amd64/amd64/cpufunc.S:1.20
--- src/sys/arch/amd64/amd64/cpufunc.S:1.19	Sun Jun 12 03:35:37 2011
+++ src/sys/arch/amd64/amd64/cpufunc.S	Sat Sep 24 10:32:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.19 2011/06/12 03:35:37 rmind Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.20 2011/09/24 10:32:52 jym Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -33,6 +33,8 @@
  * Functions to provide access to i386-specific instructions.
  */
 
+#include 
+
 #include 
 #include 
 #include 
@@ -221,6 +223,37 @@
 	wrmsr
 	ret
 
+/*
+ * Support for reading MSRs in the safe manner (returns EFAULT on fault)
+ */
+/* int rdmsr_safe(u_int msr, uint64_t *data) */
+ENTRY(rdmsr_safe)
+	movq	CPUVAR(CURLWP), %r8
+	movq	L_PCB(%r8), %r8
+	movq	$_C_LABEL(msr_onfault), PCB_ONFAULT(%r8)
+
+	movl	%edi, %ecx /* u_int msr */
+	rdmsr			/* Read MSR pointed by %ecx. Returns
+   hi byte in edx, lo in %eax */
+	salq	$32, %rdx	/* sign-shift %rdx left */
+	movl	%eax, %eax	/* zero-extend %eax -> %rax */
+	orq	%rdx, %rax
+	movq	%rax, (%rsi)  /* *data */
+	xorq	%rax, %rax/* "no error" */
+
+	movq	%rax, PCB_ONFAULT(%r8)
+	ret
+
+/*
+ * MSR operations fault handler
+ */
+NENTRY(msr_onfault)
+	movq	CPUVAR(CURLWP), %r8
+	movq	L_PCB(%r8), %r8
+	movq	$0, PCB_ONFAULT(%r8)
+	movl	$EFAULT, %eax
+ret
+
 #ifndef XEN
 ENTRY(wbinvd)
 	wbinvd

Index: src/sys/arch/i386/i386/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.15 src/sys/arch/i386/i386/cpufunc.S:1.16
--- src/sys/arch/i386/i386/cpufunc.S:1.15	Fri Mar 18 15:32:02 2011
+++ src/sys/arch/i386/i386/cpufunc.S	Sat Sep 24 10:32:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.15 2011/03/18 15:32:02 joerg Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.16 2011/09/24 10:32:52 jym Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -35,8 +35,10 @@
  * These are shared with NetBSD/xen.
  */
 
+#include 
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.15 2011/03/18 15:32:02 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.16 2011/09/24 10:32:52 jym Exp $");
 
 #include "opt_xen.h"
 
@@ -137,6 +139,40 @@
 	ret
 END(wrmsr_locked)
 
+/*
+ * Support for reading MSRs in the safe manner (returns EFAULT on fault)
+ */
+/* int rdmsr_safe(u_int msr, uint64_t *data) */
+ENTRY(rdmsr_safe)
+	movl	CPUVAR(CURLWP), %ecx
+	movl	L_PCB(%ecx), %ecx
+	movl	$_C_LABEL(msr_onfault), PCB_ONFAULT(%ecx)
+
+	movl	4(%esp), %ecx /* u_int msr */
+	rdmsr
+	movl	8(%esp), %ecx /* *data */
+	movl	%eax, (%ecx)  /* low-order bits */
+	movl	%edx, 4(%ecx) /* high-order bits */
+	xorl	%eax, %eax/* "no error" */
+
+	movl	CPUVAR(CURLWP), %ecx
+	movl	L_PCB(%ecx), %ecx
+	movl	%eax, PCB_ONFAULT(%ecx)
+
+	ret
+
+/*
+ * MSR operations fault handler
+ */
+NENTRY(msr_onfault)
+   	movl	CPUVAR(CURLWP), %ecx
+	movl	L_PCB(%ecx), %ecx
+	movl	$0, PCB_ONFAULT(%ecx)
+	movl	$EFAULT, %eax
+ret
+
+END(rdmsr_safe)
+
 ENTRY(cpu_counter)
 	rdtsc
 	addl	CPUVAR(CC_SKEW), %eax

Index: src/sys/arch/x86/include/cpufunc.h
diff -u src/sys/arch/x86/include/cpufunc.h:1.12 src/sys/arch/x86/include/cpufunc.h:1.13
--- src/sys/arch/x86/include/cpufunc.h:1.12	Wed Jul  7 01:14:53 2010
+++ src/sys/arch/x86/include/cpufunc.h	Sat Sep 24 10:32:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.12 2010/07/07 01:14:53 chs Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.13 2011/09/24 10:32:52 jym Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -118,6 +118,7 @@
 
 uint64_t	rdmsr(u_int);
 uint64_t	rdmsr_locked(u_int, u_int);
+int		rdmsr_safe(u_int, uint64_t *);
 uint64_t	rdtsc(void);
 uint64_t	rdpmc(u_int);
 void		wrmsr(u_int, uint64_t);



CVS commit: src/sys/arch/xen

2011-09-22 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Sep 22 23:02:35 UTC 2011

Modified Files:
src/sys/arch/xen/conf: files.xen
src/sys/arch/xen/xen: hypervisor.c
src/sys/arch/xen/xenbus: xenbus_dev.c xenbus_probe.c

Log Message:
Expose Xen kernfs entries inside a domU. Patch originally from sborrill@,
slightly modified by me to profit from runtime checks for dom0 privileges
instead of using compile time macros (DOM0OPS).

It should now be possible to use pkgsrc's sysutils/xentools inside
a domU to query XenStore entries (or even modify part of it if the domain
has enough rights).


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/xen/conf/files.xen
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/xen/xen/hypervisor.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/xen/xenbus/xenbus_dev.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/xen/xenbus/xenbus_probe.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/xen/conf/files.xen
diff -u src/sys/arch/xen/conf/files.xen:1.122 src/sys/arch/xen/conf/files.xen:1.123
--- src/sys/arch/xen/conf/files.xen:1.122	Wed Aug 10 11:39:45 2011
+++ src/sys/arch/xen/conf/files.xen	Thu Sep 22 23:02:34 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.xen,v 1.122 2011/08/10 11:39:45 cherry Exp $
+#	$NetBSD: files.xen,v 1.123 2011/09/22 23:02:34 jym 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 
 
@@ -176,7 +176,7 @@
 attach xenbus at xendevbus
 file arch/xen/xenbus/xenbus_client.c xenbus needs-flag
 file arch/xen/xenbus/xenbus_comms.c xenbus needs-flag
-file arch/xen/xenbus/xenbus_dev.c xenbus & dom0ops needs-flag
+file arch/xen/xenbus/xenbus_dev.c xenbus needs-flag
 file arch/xen/xenbus/xenbus_probe.c xenbus needs-flag
 file arch/xen/xenbus/xenbus_xs.c xenbus needs-flag
 

Index: src/sys/arch/xen/xen/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.57 src/sys/arch/xen/xen/hypervisor.c:1.58
--- src/sys/arch/xen/xen/hypervisor.c:1.57	Tue Sep 20 00:12:24 2011
+++ src/sys/arch/xen/xen/hypervisor.c	Thu Sep 22 23:02:35 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.57 2011/09/20 00:12:24 jym Exp $ */
+/* $NetBSD: hypervisor.c,v 1.58 2011/09/22 23:02:35 jym Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.57 2011/09/20 00:12:24 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.58 2011/09/22 23:02:35 jym Exp $");
 
 #include 
 #include 
@@ -210,11 +210,8 @@
 #endif /* NPCI */
 	union hypervisor_attach_cookie hac;
 
-#ifdef DOM0OPS
-	if (xendomain_is_privileged()) {
-		xenkernfs_init();
-	}
-#endif
+	xenkernfs_init();
+
 	xen_version = HYPERVISOR_xen_version(XENVER_version, NULL);
 	aprint_normal(": Xen version %d.%d\n", (xen_version & 0x) >> 16,
 	   xen_version & 0x);
@@ -367,8 +364,6 @@
 	return (UNCONF);
 }
 
-#if defined(DOM0OPS)
-
 #define DIR_MODE	(S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
 
 kernfs_parentdir_t *kernxen_pkt;
@@ -383,4 +378,3 @@
 	kernfs_addentry(NULL, dkt);
 	kernxen_pkt = KERNFS_ENTOPARENTDIR(dkt);
 }
-#endif /* DOM0OPS */

Index: src/sys/arch/xen/xenbus/xenbus_dev.c
diff -u src/sys/arch/xen/xenbus/xenbus_dev.c:1.8 src/sys/arch/xen/xenbus/xenbus_dev.c:1.9
--- src/sys/arch/xen/xenbus/xenbus_dev.c:1.8	Mon Mar 16 06:17:39 2009
+++ src/sys/arch/xen/xenbus/xenbus_dev.c	Thu Sep 22 23:02:35 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_dev.c,v 1.8 2009/03/16 06:17:39 cegger Exp $ */
+/* $NetBSD: xenbus_dev.c,v 1.9 2011/09/22 23:02:35 jym Exp $ */
 /*
  * xenbus_dev.c
  * 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xenbus_dev.c,v 1.8 2009/03/16 06:17:39 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenbus_dev.c,v 1.9 2011/09/22 23:02:35 jym Exp $");
 
 #include "opt_xen.h"
 
@@ -92,10 +92,13 @@
 	PRIVCMD_MODE);
 	kernfs_addentry(kernxen_pkt, dkt);
 
-	kfst = KERNFS_ALLOCTYPE(xsd_port_fileops);
-	KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK);
-	KERNFS_INITENTRY(dkt, DT_REG, "xsd_port", NULL, kfst, VREG, XSD_MODE);
-	kernfs_addentry(kernxen_pkt, dkt);
+	if (xendomain_is_dom0()) {
+		kfst = KERNFS_ALLOCTYPE(xsd_port_fileops);
+		KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK);
+		KERNFS_INITENTRY(dkt, DT_REG, "xsd_port", NULL,
+		kfst, VREG, XSD_MODE);
+		kernfs_addentry(kernxen_pkt, dkt);
+	}
 }
 
 struct xenbus_dev_data {

Index: src/sys/arch/xen/xenbus/xenbus_probe.c
diff -u src/sys/arch/xen/xenbus/xenbus_probe.c:1.34 src/sys/arch/xen/xenbus/xenbus_probe.c:1.35
--- src/sys/arch/xen/xenbus/xenbus_probe.c:1.34	Tue Sep 20 00:12:25 2011
+++ src/sys/arch/xen/xenbus/xenbus_probe.c	Thu Sep 22 23:02:35 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_probe.c,v 1.34 2011/09/20 00:12:25 jym Exp $ */
+/* $NetBSD: xenbus_probe.c,v 1.35 2011/09/22 23:02:35 jym Exp $ */
 /**
  * 

CVS commit: src/sys/dev/pci

2011-09-22 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Sep 22 08:42:53 UTC 2011

Modified Files:
src/sys/dev/pci: if_bnx.c

Log Message:
The bnx(4) handler runs at IPL_NET (works with spin mutexes), while
allocations can be deferred to a workqueue(9): set its highest IPL to
IPL_NET and not IPL_NONE, which is protected by an adaptive/sleeping mutex.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/pci/if_bnx.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_bnx.c
diff -u src/sys/dev/pci/if_bnx.c:1.44 src/sys/dev/pci/if_bnx.c:1.45
--- src/sys/dev/pci/if_bnx.c:1.44	Fri Jul 15 11:29:31 2011
+++ src/sys/dev/pci/if_bnx.c	Thu Sep 22 08:42:53 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bnx.c,v 1.44 2011/07/15 11:29:31 jym Exp $	*/
+/*	$NetBSD: if_bnx.c,v 1.45 2011/09/22 08:42:53 jym Exp $	*/
 /*	$OpenBSD: if_bnx.c,v 1.85 2009/11/09 14:32:41 dlg Exp $ */
 
 /*-
@@ -35,7 +35,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.3 2006/04/13 14:12:26 ru Exp $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.44 2011/07/15 11:29:31 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.45 2011/09/22 08:42:53 jym Exp $");
 
 /*
  * The following controllers are supported by this driver:
@@ -707,7 +707,7 @@
 
 	/* create workqueue to handle packet allocations */
 	if (workqueue_create(&sc->bnx_wq, device_xname(self),
-	bnx_alloc_pkts, sc, PRI_NONE, IPL_NONE, WQ_MPSAFE) != 0) {
+	bnx_alloc_pkts, sc, PRI_NONE, IPL_NET, WQ_MPSAFE) != 0) {
 		aprint_error_dev(self, "failed to create workqueue\n");
 		goto bnx_attach_fail;
 	}



CVS commit: src/usr.bin/vmstat

2011-09-21 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Wed Sep 21 12:08:02 UTC 2011

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Use __arraycount(), as done above.


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.183 src/usr.bin/vmstat/vmstat.c:1.184
--- src/usr.bin/vmstat/vmstat.c:1.183	Tue Sep  6 18:44:46 2011
+++ src/usr.bin/vmstat/vmstat.c	Wed Sep 21 12:08:02 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.183 2011/09/06 18:44:46 joerg Exp $ */
+/* $NetBSD: vmstat.c,v 1.184 2011/09/21 12:08:02 jym Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.183 2011/09/06 18:44:46 joerg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.184 2011/09/21 12:08:02 jym Exp $");
 #endif
 #endif /* not lint */
 
@@ -1486,8 +1486,7 @@
 
 		cpuhit = 0;
 		cpumiss = 0;
-		for (i = 0; i < sizeof(pc->pc_cpus) / sizeof(pc->pc_cpus[0]);
-		i++) {
+		for (i = 0; i < __arraycount(pc->pc_cpus); i++) {
 			if ((addr = pc->pc_cpus[i]) == NULL)
 				continue;
 			deref_kptr(addr, cc, sizeof(*cc),



CVS commit: src/share/man/man4

2011-09-20 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Sep 20 18:58:40 UTC 2011

Modified Files:
src/share/man/man4: uaudio.4 ulpt.4 usb.4 uscanner.4 uvideo.4

Log Message:
Use mdoc(7) references for links to specifications. While here, fix
URLs for USB device class spec documents, and bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/share/man/man4/uaudio.4
cvs rdiff -u -r1.11 -r1.12 src/share/man/man4/ulpt.4
cvs rdiff -u -r1.92 -r1.93 src/share/man/man4/usb.4
cvs rdiff -u -r1.10 -r1.11 src/share/man/man4/uscanner.4
cvs rdiff -u -r1.5 -r1.6 src/share/man/man4/uvideo.4

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/man4/uaudio.4
diff -u src/share/man/man4/uaudio.4:1.23 src/share/man/man4/uaudio.4:1.24
--- src/share/man/man4/uaudio.4:1.23	Wed Apr 30 13:10:54 2008
+++ src/share/man/man4/uaudio.4	Tue Sep 20 18:58:40 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: uaudio.4,v 1.23 2008/04/30 13:10:54 martin Exp $
+.\" $NetBSD: uaudio.4,v 1.24 2011/09/20 18:58:40 jym Exp $
 .\"
 .\" Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd June 22, 2005
+.Dd September 20, 2011
 .Dt UAUDIO 4
 .Os
 .Sh NAME
@@ -107,13 +107,12 @@
 Audio class specification is indispensable
 reading.
 .Sh SEE ALSO
-The
-.Tn USB
-specifications can be found at:
-.Dv http://www.usb.org/developers/docs.html
-.Pp
 .Xr audio 4 ,
 .Xr usb 4
+.Rs
+.%T "USB Approved Class Specification Documents"
+.%U http://www.usb.org/developers/devclass_docs/
+.Re
 .Sh HISTORY
 The
 .Nm

Index: src/share/man/man4/ulpt.4
diff -u src/share/man/man4/ulpt.4:1.11 src/share/man/man4/ulpt.4:1.12
--- src/share/man/man4/ulpt.4:1.11	Sun May 17 05:08:57 2009
+++ src/share/man/man4/ulpt.4	Tue Sep 20 18:58:40 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: ulpt.4,v 1.11 2009/05/17 05:08:57 fair Exp $
+.\" $NetBSD: ulpt.4,v 1.12 2011/09/20 18:58:40 jym Exp $
 .\"
 .\" Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -71,8 +71,8 @@
 .%T USB Device Class Definition for Printing Devices
 .%I USB Implementors Forum
 .%D January 2000
+.%U http://www.usb.org/developers/devclass_docs/usbprint11.pdf
 .Re
-.Pa http://www.usb.org/developers/devclass_docs/usbprint11.pdf
 .Sh HISTORY
 The
 .Nm

Index: src/share/man/man4/usb.4
diff -u src/share/man/man4/usb.4:1.92 src/share/man/man4/usb.4:1.93
--- src/share/man/man4/usb.4:1.92	Mon Mar 22 18:58:31 2010
+++ src/share/man/man4/usb.4	Tue Sep 20 18:58:40 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: usb.4,v 1.92 2010/03/22 18:58:31 joerg Exp $
+.\" $NetBSD: usb.4,v 1.93 2011/09/20 18:58:40 jym Exp $
 .\"
 .\" Copyright (c) 1999-2008 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -554,11 +554,6 @@
 an interrupt context, but need to sleep, e.g., time-out
 abort of transfers.
 .Sh SEE ALSO
-The
-.Tn USB
-specifications can be found at:
-.D1 http://www.usb.org/developers/docs/
-.Pp
 .Xr usbhidaction 1 ,
 .Xr usbhidctl 1 ,
 .Xr cardbus 4 ,
@@ -570,6 +565,10 @@
 .Xr slhci 4 ,
 .Xr uhci 4 ,
 .Xr usbdevs 8
+.Rs
+.%T Universal Serial Bus Specifications Documents
+.%U http://www.usb.org/developers/docs/
+.Re
 .Sh HISTORY
 The
 .Nm

Index: src/share/man/man4/uscanner.4
diff -u src/share/man/man4/uscanner.4:1.10 src/share/man/man4/uscanner.4:1.11
--- src/share/man/man4/uscanner.4:1.10	Wed Apr 30 13:10:54 2008
+++ src/share/man/man4/uscanner.4	Tue Sep 20 18:58:40 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: uscanner.4,v 1.10 2008/04/30 13:10:54 martin Exp $
+.\" $NetBSD: uscanner.4,v 1.11 2011/09/20 18:58:40 jym Exp $
 .\"
 .\" Copyright (c) 2000 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -76,8 +76,10 @@
 .Xr scanimage 1 ,
 .Xr usb 4 ,
 .Xr usscanner 4
-.br
-.Pa http://www.buzzard.org.uk/jonathan/scanners-usb.html
+.Rs
+.%T USB Scanners under Linux
+.%U http://www.buzzard.org.uk/jonathan/scanners-usb.html
+.Re
 .Sh HISTORY
 The
 .Nm

Index: src/share/man/man4/uvideo.4
diff -u src/share/man/man4/uvideo.4:1.5 src/share/man/man4/uvideo.4:1.6
--- src/share/man/man4/uvideo.4:1.5	Sun Sep 21 18:02:00 2008
+++ src/share/man/man4/uvideo.4	Tue Sep 20 18:58:40 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: uvideo.4,v 1.5 2008/09/21 18:02:00 jmcneill Exp $
+.\"	$NetBSD: uvideo.4,v 1.6 2011/09/20 18:58:40 jym Exp $
 .\"
 .\" Copyright (c) 2008 Patrick Mahoney
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 21, 2008
+.Dd September 20, 2011
 .Dt UVIDEO 4
 .Os
 .Sh NAME
@@ -46,11 +46,13 @@
 Every device has one control interface.
 Each device optionally provides streaming interfaces (input or output).
 .Sh SEE ALSO
-The USB Specifications can be found at:
-.Dv http://www.usb.org/developers/docs.html
-.Pp
+.Xr usb 4 ,
 .Xr video 4 ,
 .Xr video 9
+.Rs

CVS commit: src/doc

2011-09-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Sep 20 00:33:43 UTC 2011

Modified Files:
src/doc: CHANGES

Log Message:
Xen suspend/resume code is now committed in -curent.


To generate a diff of this commit:
cvs rdiff -u -r1.1608 -r1.1609 src/doc/CHANGES

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.1608 src/doc/CHANGES:1.1609
--- src/doc/CHANGES:1.1608	Sat Sep 17 17:00:12 2011
+++ src/doc/CHANGES	Tue Sep 20 00:33:43 2011
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.1608 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.1609 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -1122,3 +1122,5 @@
 	file: Update to 5.09 [christos 20110916]
 	mppb(4): Add driver for Prometheus Zorro III to PCI bridge.
 		[rkujawa 20110917]
+	xen: Provide experimental support for suspend/resume in
+		NetBSD domUs. [jym 20110920]



CVS commit: src/doc

2011-09-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Sep 20 00:31:06 UTC 2011

Modified Files:
src/doc: NetBSD-6

Log Message:
Xen suspend/resume will be part of NetBSD-6.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/doc/NetBSD-6

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/NetBSD-6
diff -u src/doc/NetBSD-6:1.8 src/doc/NetBSD-6:1.9
--- src/doc/NetBSD-6:1.8	Tue Aug 16 04:04:57 2011
+++ src/doc/NetBSD-6	Tue Sep 20 00:31:06 2011
@@ -28,6 +28,7 @@
 + support for resizing ffs - riz
 + production support for fss
 + Xen/SMP
++ Xen suspend/resume
 + automated test framework for testing releng autobuilds
 + full functionality for NPF - SMP-aware packet filter - rmind
 + fixed IPSEC NAT-T
@@ -39,7 +40,6 @@
 ---
 + mobile IPv6 - we have the mods, need application of same to the repo
 + kernel modules need work
-+ Xen suspend/resume - jym working on it
 + TNF funding for release engineering
 
 May not make 6.0



CVS commit: src/doc

2011-09-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Sep 20 00:29:57 UTC 2011

Modified Files:
src/doc: BRANCHES

Log Message:
jym-xensuspend is now terminated.


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/doc/BRANCHES

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/BRANCHES
diff -u src/doc/BRANCHES:1.309 src/doc/BRANCHES:1.310
--- src/doc/BRANCHES:1.309	Sun Jun 12 03:50:42 2011
+++ src/doc/BRANCHES	Tue Sep 20 00:29:57 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: BRANCHES,v 1.309 2011/06/12 03:50:42 rmind Exp $
+#	$NetBSD: BRANCHES,v 1.310 2011/09/20 00:29:57 jym Exp $
 #
 # This file contains a list of branches that exist in the NetBSD CVS
 # tree and their current state.
@@ -357,9 +357,9 @@
 
 Branch:		jym-xensuspend
 Description:	Implement xm save/restore/migrate for NetBSD domU
-Status:		Active
+Status:		Terminated
 Start Date:	2009-02-08
-End Date:
+End Date:	2011-09-20
 Base Tag:	jym-xensuspend-base
 Maintainer:	Jean-Yves Migeon 
 Scope:		kernel



CVS commit: src/share/man/man3

2011-09-18 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sun Sep 18 17:43:20 UTC 2011

Modified Files:
src/share/man/man3: attribute.3

Log Message:
typo: prefict -> predict


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/share/man/man3/attribute.3

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/man3/attribute.3
diff -u src/share/man/man3/attribute.3:1.10 src/share/man/man3/attribute.3:1.11
--- src/share/man/man3/attribute.3:1.10	Sat Mar 19 04:59:44 2011
+++ src/share/man/man3/attribute.3	Sun Sep 18 17:43:20 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: attribute.3,v 1.10 2011/03/19 04:59:44 jruoho Exp $
+.\" $NetBSD: attribute.3,v 1.11 2011/09/18 17:43:20 jym Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -59,7 +59,7 @@
 .Pp
 .Fn __predict_true "exp"
 .Pp
-.Fn __prefict_false "exp"
+.Fn __predict_false "exp"
 .Sh DESCRIPTION
 The
 .Tn GNU



CVS commit: src/etc/powerd/scripts

2011-09-17 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Sep 17 14:44:18 UTC 2011

Modified Files:
src/etc/powerd/scripts: sleep_button

Log Message:
- use -q to test for presence of a sysctl(7) variable silently
- modify powerd(8) sleep_button script so it can handle the soon-to-be
Xen suspend command.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/etc/powerd/scripts/sleep_button

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/powerd/scripts/sleep_button
diff -u src/etc/powerd/scripts/sleep_button:1.8 src/etc/powerd/scripts/sleep_button:1.9
--- src/etc/powerd/scripts/sleep_button:1.8	Fri May 27 09:28:42 2011
+++ src/etc/powerd/scripts/sleep_button	Sat Sep 17 14:44:18 2011
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#	$NetBSD: sleep_button,v 1.8 2011/05/27 09:28:42 plunky Exp $
+#	$NetBSD: sleep_button,v 1.9 2011/09/17 14:44:18 jym Exp $
 #
 # Generic script for sleep button events.
 #
@@ -17,8 +17,10 @@
 	/etc/rc.d/network stop
 	/etc/rc.d/wpa_supplicant stop
 
-	if /sbin/sysctl hw.acpi.sleep.state >/dev/null 2>&1; then
+	if /sbin/sysctl -q hw.acpi.sleep.state; then
 		/sbin/sysctl -w hw.acpi.sleep.state=3
+	elif /sbin/sysctl -q machdep.xen.suspend; then
+		/sbin/sysctl -w machdep.xen.suspend=1
 	else
 		sleep 1
 		if /etc/rc.d/apmd onestatus >/dev/null ; then



CVS commit: [jym-xensuspend] src/sys/arch/x86/x86

2011-09-17 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Sep 17 10:59:58 UTC 2011

Modified Files:
src/sys/arch/x86/x86 [jym-xensuspend]: pmap.c

Log Message:
Fix comment, as noted by cherry@.


To generate a diff of this commit:
cvs rdiff -u -r1.77.2.12 -r1.77.2.13 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.77.2.12 src/sys/arch/x86/x86/pmap.c:1.77.2.13
--- src/sys/arch/x86/x86/pmap.c:1.77.2.12	Sat Aug 27 15:37:30 2011
+++ src/sys/arch/x86/x86/pmap.c	Sat Sep 17 10:59:58 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.77.2.12 2011/08/27 15:37:30 jym Exp $	*/
+/*	$NetBSD: pmap.c,v 1.77.2.13 2011/09/17 10:59:58 jym Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77.2.12 2011/08/27 15:37:30 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77.2.13 2011/09/17 10:59:58 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -4434,10 +4434,10 @@
  * handle them correctly during save/restore, leading to incorrect page
  * tracking and pinning during restore.
  * For save/restore to succeed, two functions are introduced:
- * - pmap_map_shadow_entries(), used by resume code to set the last entry
- *   of PDIR_SLOT_PTE so that it points to the correct L2 shadow page
- * - pmap_unmap_shadow_entries(), used by suspend code to clear all
- *   PDIR_SLOT_PTE entries pointing to L2 shadow entries
+ * - pmap_map_recursive_entries(), used by resume code to set the recursive
+ *   mapping entries to their correct value
+ * - pmap_unmap_recursive_entries(), used by suspend code to clear all
+ *   PDIR_SLOT_PTE entries
  */
 void
 pmap_map_recursive_entries(void)



  1   2   3   4   >