CVS commit: src/sys/dev/pci/ixgbe

2012-06-16 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Jun 16 19:54:01 UTC 2012

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

Log Message:
Add explicit (void *) casts for when sysctl_createv() is passed
CTLTYPE_INT but the address of a structure (and a function).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/ixgbe/ixgbe.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/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.3 src/sys/dev/pci/ixgbe/ixgbe.c:1.4
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.3	Sat Jun  2 21:36:45 2012
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sat Jun 16 19:54:01 2012
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: src/sys/dev/ixgbe/ixgbe.c,v 1.51 2011/04/25 23:34:21 jfv Exp $*/
-/*$NetBSD: ixgbe.c,v 1.3 2012/06/02 21:36:45 dsl Exp $*/
+/*$NetBSD: ixgbe.c,v 1.4 2012/06/16 19:54:01 dsl Exp $*/
 
 #include opt_inet.h
 
@@ -5468,14 +5468,14 @@ ixgbe_add_hw_stats(struct adapter *adapt
 		if (sysctl_createv(log, 0, rnode, cnode,
 		CTLFLAG_READONLY, CTLTYPE_INT,
 		txd_head, SYSCTL_DESCR(Transmit Descriptor Head),
-		ixgbe_sysctl_tdh_handler, 0, txr,
+		ixgbe_sysctl_tdh_handler, 0, (void *)txr,
 		0, CTL_CREATE, CTL_EOL) != 0)
 			break;
 
 		if (sysctl_createv(log, 0, rnode, cnode,
 		CTLFLAG_READONLY, CTLTYPE_INT,
 		txd_tail, SYSCTL_DESCR(Transmit Descriptor Tail),
-		ixgbe_sysctl_tdt_handler, 0, txr,
+		ixgbe_sysctl_tdt_handler, 0, (void *)txr,
 		0, CTL_CREATE, CTL_EOL) != 0)
 			break;
 
@@ -5494,7 +5494,7 @@ ixgbe_add_hw_stats(struct adapter *adapt
 		CTLFLAG_READONLY,
 		CTLTYPE_INT,
 		rxd_head, SYSCTL_DESCR(Receive Descriptor Head),
-		ixgbe_sysctl_rdh_handler, 0, rxr, 0,
+		ixgbe_sysctl_rdh_handler, 0, (void *)rxr, 0,
 		CTL_CREATE, CTL_EOL) != 0)
 			break;
 
@@ -5502,7 +5502,7 @@ ixgbe_add_hw_stats(struct adapter *adapt
 		CTLFLAG_READONLY,
 		CTLTYPE_INT,
 		rxd_tail, SYSCTL_DESCR(Receive Descriptor Tail),
-		ixgbe_sysctl_rdt_handler, 0, rxr, 0,
+		ixgbe_sysctl_rdt_handler, 0, (void *)rxr, 0,
 		CTL_CREATE, CTL_EOL) != 0)
 			break;
 



CVS commit: src/sys/arch/amd64

2012-06-16 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Jun 16 20:47:04 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/amd64/include: segments.h

Log Message:
memseg_baseaddr() is only called from valid_user_selector() and
both only locally.
Make static, remove one of the functions, and remove the never-set args.
Code is still very dubious.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/include/segments.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.185 src/sys/arch/amd64/amd64/machdep.c:1.186
--- src/sys/arch/amd64/amd64/machdep.c:1.185	Sat Jun 16 16:42:26 2012
+++ src/sys/arch/amd64/amd64/machdep.c	Sat Jun 16 20:47:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.185 2012/06/16 16:42:26 joerg Exp $	*/
+/*	$NetBSD: machdep.c,v 1.186 2012/06/16 20:47:04 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.185 2012/06/16 16:42:26 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.186 2012/06/16 20:47:04 dsl Exp $);
 
 /* #define XENDEBUG_LOW  */
 
@@ -332,6 +332,8 @@ int dumpsys_seg(paddr_t, paddr_t);
 
 void	init_x86_64(paddr_t);
 
+static int valid_user_selector(struct lwp *, uint64_t);
+
 /*
  * Machine-dependent startup code
  */
@@ -2093,28 +2095,28 @@ cpu_mcontext_validate(struct lwp *l, con
 		return EINVAL;
 
 	if (__predict_false(pmap-pm_ldt != NULL)) {
-		error = valid_user_selector(l, gr[_REG_ES], NULL, 0);
+		error = valid_user_selector(l, gr[_REG_ES]);
 		if (error != 0)
 			return error;
 
-		error = valid_user_selector(l, gr[_REG_FS], NULL, 0);
+		error = valid_user_selector(l, gr[_REG_FS]);
 		if (error != 0)
 			return error;
 
-		error = valid_user_selector(l, gr[_REG_GS], NULL, 0);
+		error = valid_user_selector(l, gr[_REG_GS]);
 		if (error != 0)
 			return error;
 
 		if ((gr[_REG_DS]  0x) == 0)
 			return EINVAL;
-		error = valid_user_selector(l, gr[_REG_DS], NULL, 0);
+		error = valid_user_selector(l, gr[_REG_DS]);
 		if (error != 0)
 			return error;
 
 #ifndef XEN
 		if ((gr[_REG_SS]  0x) == 0)
 			return EINVAL;
-		error = valid_user_selector(l, gr[_REG_SS], NULL, 0);
+		error = valid_user_selector(l, gr[_REG_SS]);
 		if (error != 0)
 			return error;
 #endif
@@ -2169,9 +2171,8 @@ cpu_initclocks(void)
 	(*initclock_func)();
 }
 
-int
-memseg_baseaddr(struct lwp *l, uint64_t seg, char *ldtp, int llen,
-		uint64_t *addr)
+static int
+valid_user_selector(struct lwp *l, uint64_t seg)
 {
 	int off, len;
 	char *dt;
@@ -2182,18 +2183,12 @@ memseg_baseaddr(struct lwp *l, uint64_t 
 
 	seg = 0x;
 
-	if (seg == 0) {
-		if (addr != NULL)
-			*addr = 0;
+	if (seg == 0)
 		return 0;
-	}
 
 	off = (seg  0xfff8);
 	if (seg  SEL_LDT) {
-		if (ldtp != NULL) {
-			dt = ldtp;
-			len = llen;
-		} else if (pmap-pm_ldt != NULL) {
+		if (pmap-pm_ldt != NULL) {
 			len = pmap-pm_ldt_len; /* XXX broken */
 			dt = (char *)pmap-pm_ldt;
 		} else {
@@ -2220,21 +2215,10 @@ memseg_baseaddr(struct lwp *l, uint64_t 
 	if (base = VM_MAXUSER_ADDRESS)
 		return EINVAL;
 
-	if (addr == NULL)
-		return 0;
-
-	*addr = base;
-
 	return 0;
 }
 
 int
-valid_user_selector(struct lwp *l, uint64_t seg, char *ldtp, int len)
-{
-	return memseg_baseaddr(l, seg, ldtp, len, NULL);
-}
-
-int
 mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled)
 {
 	extern int start, __data_start;

Index: src/sys/arch/amd64/include/segments.h
diff -u src/sys/arch/amd64/include/segments.h:1.22 src/sys/arch/amd64/include/segments.h:1.23
--- src/sys/arch/amd64/include/segments.h:1.22	Mon Feb  7 03:54:45 2011
+++ src/sys/arch/amd64/include/segments.h	Sat Jun 16 20:47:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: segments.h,v 1.22 2011/02/07 03:54:45 chs Exp $	*/
+/*	$NetBSD: segments.h,v 1.23 2012/06/16 20:47:04 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -256,8 +256,6 @@ void idt_vec_free(int);
 #endif
 
 struct lwp;
-int memseg_baseaddr(struct lwp *, uint64_t, char *, int, uint64_t *);
-int valid_user_selector(struct lwp *, uint64_t, char *, int);
 void cpu_fsgs_zero(struct lwp *);
 void cpu_fsgs_reload(struct lwp *, int, int);
 



CVS commit: src/sys/dev/pci/ixgbe

2012-06-16 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Jun 16 19:54:01 UTC 2012

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

Log Message:
Add explicit (void *) casts for when sysctl_createv() is passed
CTLTYPE_INT but the address of a structure (and a function).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/ixgbe/ixgbe.c

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



CVS commit: src/sys/arch/amd64

2012-06-16 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Jun 16 20:47:04 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/amd64/include: segments.h

Log Message:
memseg_baseaddr() is only called from valid_user_selector() and
both only locally.
Make static, remove one of the functions, and remove the never-set args.
Code is still very dubious.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/include/segments.h

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



CVS commit: src/sys/arch/hp700/hp700

2012-06-08 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Fri Jun  8 07:53:41 UTC 2012

Modified Files:
src/sys/arch/hp700/hp700: machdep.c

Log Message:
Fix type of variable passed to sysctl (int - bool).


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/arch/hp700/hp700/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/hp700/hp700/machdep.c
diff -u src/sys/arch/hp700/hp700/machdep.c:1.113 src/sys/arch/hp700/hp700/machdep.c:1.114
--- src/sys/arch/hp700/hp700/machdep.c:1.113	Wed May 23 16:11:37 2012
+++ src/sys/arch/hp700/hp700/machdep.c	Fri Jun  8 07:53:41 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.113 2012/05/23 16:11:37 skrll Exp $	*/
+/*	$NetBSD: machdep.c,v 1.114 2012/06/08 07:53:41 dsl Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.113 2012/05/23 16:11:37 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.114 2012/06/08 07:53:41 dsl Exp $);
 
 #include opt_cputype.h
 #include opt_ddb.h
@@ -228,7 +228,7 @@ int	cpu_modelno;
 int	cpu_revision;
 
 #if NLCD  0
-int	lcd_blink_p;
+bool	lcd_blink_p;
 #endif
 
 /*
@@ -1926,7 +1926,8 @@ sysctl_machdep_boot(SYSCTLFN_ARGS)
 static int
 sysctl_machdep_heartbeat(SYSCTLFN_ARGS)
 {
-	int oldval, error;
+	int error;
+	bool oldval;
 	struct sysctlnode node = *rnode;
 	
 	oldval = lcd_blink_p;
@@ -1938,7 +1939,7 @@ sysctl_machdep_heartbeat(SYSCTLFN_ARGS)
 	if (error || newp == NULL)
 		return (error);
 
-	if (!oldval  lcd_blink_p  oldval)
+	if (!oldval  lcd_blink_p)
 		blink_lcd_timeout(NULL);
 
 	return 0;



CVS commit: src/sys/arch/hp700/hp700

2012-06-08 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Fri Jun  8 07:53:41 UTC 2012

Modified Files:
src/sys/arch/hp700/hp700: machdep.c

Log Message:
Fix type of variable passed to sysctl (int - bool).


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/arch/hp700/hp700/machdep.c

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



Re: CVS commit: src/sys/dev/dkwedge

2012-06-07 Thread David Laight
On Thu, Jun 07, 2012 at 04:15:32PM +, Michael van Elst wrote:
 Module Name:  src
 Committed By: mlelstv
 Date: Thu Jun  7 16:15:32 UTC 2012
 
 Modified Files:
   src/sys/dev/dkwedge: dkwedge_bsdlabel.c
 
 Log Message:
 Use the label's packname to create wedge names instead of the classic
 device names. Fall back to classic device names when the label has an
 empty name or the default name 'fictitious'.

You probably also want to detect duplicate names...

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/etc

2012-06-05 Thread David Laight
On Tue, Jun 05, 2012 at 10:18:28PM +0400, Aleksej Saushev wrote:
  +++ src/etc/MAKEDEV.tmplTue Jun  5 13:20:01 2012
  @@ -2092,9 +2093,9 @@ local)
  umask 0
  if [ -n $count_nodes ]; then
  count_nodes=$((count_nodes + \
  -   $(linecount $(sh $0.local $opts -s all)) ))
  +   $(linecount $($HOST_SH $0.local $opts -s 
  all)) ))
 
 Are \\s really not needed here?

Not needed for line continuations inside shell constructs.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/kern

2012-06-04 Thread David Laight
On Mon, Jun 04, 2012 at 12:02:37PM -0700, Erik Fair wrote:
 This  the immediate predecessor are definitely a netbsd-5 pull up items.

Just looked at a -5 tree.
I think only the vfs_bio change really matters.
(and the src/sys/dev/bluetooth/bcsp.c one - bool v int, but I suspect
the -5 tree has a few more of those).

The acpi ones won't matter because acpi is LE only.
Unfortunately I don't think a cvs patch will apply ...

 
 On Jun 3, 2012, at 09:23, David Laight wrote:
 
  Module Name:src
  Committed By:   dsl
  Date:   Sun Jun  3 16:23:44 UTC 2012
  
  Modified Files:
  src/sys/kern: vfs_bio.c
  
  Log Message:
  Use separate temporaries for the 'int' percentage and the 'long'
   water marks.
  Previous paniced on sparc64 due to a misaligned copy.
  
  
  To generate a diff of this commit:
  cvs rdiff -u -r1.238 -r1.239 src/sys/kern/vfs_bio.c
  
  Please note that diffs are not public domain; they are subject to the
  copyright notices on the relevant files.
  
 

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys

2012-06-03 Thread David Laight
On Sun, Jun 03, 2012 at 10:10:40AM +0900, Izumi Tsutsui wrote:
 dsl@ wrote:
...
   } Log Message:
   } Remove the code that tries to load the ffs kernel module during boot.
   } This is in line with the core decision than even modular kernels should
   }   contain the ffs code.
   } I've left in the code that tries to load nfs and ext2fs, but it
   }   isn't clear that is necessary.
   } Removes a warning message that (usually) flashes past to fast to read.
   } AFAICT all the relevant kernels contain ffs (and nfs for that matter).
...
 Can't we have an option for autoloading rootfs modules,
 like console settings configurable via installboot?

You can request it from the boot.cfg file,
there is no need for a second way - it only confuses things.

David

-- 
David Laight: da...@l8s.co.uk


CVS commit: src/sys/rump/librump/rumpkern

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 10:45:11 UTC 2012

Modified Files:
src/sys/rump/librump/rumpkern: rump.c

Log Message:
Fix build now that sysctl_createv() checks its arg type.


To generate a diff of this commit:
cvs rdiff -u -r1.240 -r1.241 src/sys/rump/librump/rumpkern/rump.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/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.240 src/sys/rump/librump/rumpkern/rump.c:1.241
--- src/sys/rump/librump/rumpkern/rump.c:1.240	Sat Feb  4 10:02:25 2012
+++ src/sys/rump/librump/rumpkern/rump.c	Sun Jun  3 10:45:10 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump.c,v 1.240 2012/02/04 10:02:25 njoly Exp $	*/
+/*	$NetBSD: rump.c,v 1.241 2012/06/03 10:45:10 dsl Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rump.c,v 1.240 2012/02/04 10:02:25 njoly Exp $);
+__KERNEL_RCSID(0, $NetBSD: rump.c,v 1.241 2012/06/03 10:45:10 dsl Exp $);
 
 #include sys/systm.h
 #define ELFSIZE ARCH_ELFSIZE
@@ -180,7 +180,7 @@ mksysctls(void)
 	sysctl_createv(NULL, 0, NULL, NULL,
 	CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_STRING, hostname,
 	SYSCTL_DESCR(System hostname), NULL, 0,
-	hostname, MAXHOSTNAMELEN, CTL_KERN, KERN_HOSTNAME, CTL_EOL);
+	hostname, MAXHOSTNAMELEN, CTL_KERN, KERN_HOSTNAME, CTL_EOL);
 }
 
 /* there's no convenient kernel entry point for this, so just craft out own */



CVS commit: src/external/cddl/osnet/dist/lib/libzfs/common

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 10:53:52 UTC 2012

Modified Files:
src/external/cddl/osnet/dist/lib/libzfs/common: libzfs_sendrecv.c

Log Message:
Not sure why this has just started to fail!
But it really isn't a good idea to compare a uint64_t to NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_sendrecv.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/dist/lib/libzfs/common/libzfs_sendrecv.c
diff -u src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_sendrecv.c:1.1.1.2 src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_sendrecv.c:1.2
--- src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_sendrecv.c:1.1.1.2	Sat Feb 27 22:30:28 2010
+++ src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_sendrecv.c	Sun Jun  3 10:53:51 2012
@@ -2245,7 +2245,7 @@ zfs_receive_one(libzfs_handle_t *hdl, in
 			(void) printf(found clone origin %s\n, zc.zc_string);
 	}
 
-	stream_wantsnewfs = (drrb-drr_fromguid == NULL ||
+	stream_wantsnewfs = (drrb-drr_fromguid == 0 ||
 	(drrb-drr_flags  DRR_FLAG_CLONE));
 
 	if (stream_wantsnewfs) {



CVS commit: src/tests/modules/k_helper

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 10:59:44 UTC 2012

Modified Files:
src/tests/modules/k_helper: k_helper.c

Log Message:
Fix build - delete extra 


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/modules/k_helper/k_helper.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/modules/k_helper/k_helper.c
diff -u src/tests/modules/k_helper/k_helper.c:1.5 src/tests/modules/k_helper/k_helper.c:1.6
--- src/tests/modules/k_helper/k_helper.c:1.5	Wed Nov  3 16:10:23 2010
+++ src/tests/modules/k_helper/k_helper.c	Sun Jun  3 10:59:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: k_helper.c,v 1.5 2010/11/03 16:10:23 christos Exp $	*/
+/*	$NetBSD: k_helper.c,v 1.6 2012/06/03 10:59:44 dsl Exp $	*/
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: k_helper.c,v 1.5 2010/11/03 16:10:23 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: k_helper.c,v 1.6 2012/06/03 10:59:44 dsl Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -88,7 +88,7 @@ SYSCTL_SETUP(sysctl_k_helper_setup, sys
 	   CTLFLAG_PERMANENT,
 	   CTLTYPE_STRING, prop_str_val,
 		   SYSCTL_DESCR(String property's value),
-		   NULL, 0, prop_str_val, 0,
+		   NULL, 0, prop_str_val, 0,
 	   CTL_VENDOR, K_HELPER, K_HELPER_PROP_STR_VAL, CTL_EOL);
 
 	sysctl_createv(clog, 0, NULL, NULL,



CVS commit: src/sys/kern

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 11:37:45 UTC 2012

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

Log Message:
Fix processing of vm.bufmem_lowater and vm.bufmem_hiwater on 64bit systems.
The values are 'u_long' so copying them into an 'int' temporary
(to avoid writing an out of range value into the actual variable)
doesn't work too well at all.
Shows up on amd64 now that the sysctl values are marked as 64bit.
sparc64 must have been badly broken for ages.


To generate a diff of this commit:
cvs rdiff -u -r1.237 -r1.238 src/sys/kern/vfs_bio.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/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.237 src/sys/kern/vfs_bio.c:1.238
--- src/sys/kern/vfs_bio.c:1.237	Sat Jun  2 21:36:46 2012
+++ src/sys/kern/vfs_bio.c	Sun Jun  3 11:37:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_bio.c,v 1.237 2012/06/02 21:36:46 dsl Exp $	*/
+/*	$NetBSD: vfs_bio.c,v 1.238 2012/06/03 11:37:44 dsl Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_bio.c,v 1.237 2012/06/02 21:36:46 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_bio.c,v 1.238 2012/06/03 11:37:44 dsl Exp $);
 
 #include opt_bufcache.h
 
@@ -1730,39 +1730,41 @@ sysctl_dobuf(SYSCTLFN_ARGS)
 static int
 sysctl_bufvm_update(SYSCTLFN_ARGS)
 {
-	int t, error, rv;
+	int error, rv;
 	struct sysctlnode node;
+	union u_int_long { unsigned int i; unsigned long l; } t;
 
+	/* Take a copy of the supplied node and its data */
 	node = *rnode;
 	node.sysctl_data = t;
-	t = *(int *)rnode-sysctl_data;
+	t = *(union u_int_long *)rnode-sysctl_data;
+
+	/* Update the copy */
 	error = sysctl_lookup(SYSCTLFN_CALL(node));
 	if (error || newp == NULL)
 		return (error);
 
-	if (t  0)
-		return EINVAL;
 	if (rnode-sysctl_data == bufcache) {
-		if (t  100)
+		if (t.i  100)
 			return (EINVAL);
-		bufcache = t;
+		bufcache = t.i;
 		buf_setwm();
 	} else if (rnode-sysctl_data == bufmem_lowater) {
-		if (bufmem_hiwater - t  16)
+		if (bufmem_hiwater - t.l  16)
 			return (EINVAL);
-		bufmem_lowater = t;
+		bufmem_lowater = t.l;
 	} else if (rnode-sysctl_data == bufmem_hiwater) {
-		if (t - bufmem_lowater  16)
+		if (t.l - bufmem_lowater  16)
 			return (EINVAL);
-		bufmem_hiwater = t;
+		bufmem_hiwater = t.l;
 	} else
 		return (EINVAL);
 
 	/* Drain until below new high water mark */
 	sysctl_unlock();
 	mutex_enter(bufcache_lock);
-	while ((t = bufmem - bufmem_hiwater) = 0) {
-		rv = buf_drain(t / (2 * 1024));
+	while (bufmem  bufmem_hiwater) {
+		rv = buf_drain((bufmem - bufmem_hiwater) / (2 * 1024));
 		if (rv = 0)
 			break;
 	}



CVS commit: src/sys/dev/pckbport

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 13:52:46 UTC 2012

Modified Files:
src/sys/dev/pckbport: synaptics.c

Log Message:
Remove a couple of (void *) casts added in the previous commin.
They aren't needed here (script error).


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pckbport/synaptics.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/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.29 src/sys/dev/pckbport/synaptics.c:1.30
--- src/sys/dev/pckbport/synaptics.c:1.29	Sat Jun  2 21:36:45 2012
+++ src/sys/dev/pckbport/synaptics.c	Sun Jun  3 13:52:46 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.29 2012/06/02 21:36:45 dsl Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.30 2012/06/03 13:52:46 dsl Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include opt_pms.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: synaptics.c,v 1.29 2012/06/02 21:36:45 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: synaptics.c,v 1.30 2012/06/03 13:52:46 dsl Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -493,7 +493,7 @@ pms_sysctl_synaptics(struct sysctllog **
 	CTLTYPE_INT, scale_x,
 	SYSCTL_DESCR(Horizontal movement scale factor),
 	pms_sysctl_synaptics_verify, 0,
-	(void *)synaptics_scale_x,
+	synaptics_scale_x,
 	0, CTL_HW, root_num, CTL_CREATE,
 	CTL_EOL)) != 0)
 		goto err;
@@ -505,7 +505,7 @@ pms_sysctl_synaptics(struct sysctllog **
 	CTLTYPE_INT, scale_y,
 	SYSCTL_DESCR(Vertical movement scale factor),
 	pms_sysctl_synaptics_verify, 0,
-	(void *)synaptics_scale_y,
+	synaptics_scale_y,
 	0, CTL_HW, root_num, CTL_CREATE,
 	CTL_EOL)) != 0)
 		goto err;



CVS commit: src/sys/kern

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 16:23:44 UTC 2012

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

Log Message:
Use separate temporaries for the 'int' percentage and the 'long'
  water marks.
Previous paniced on sparc64 due to a misaligned copy.


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/sys/kern/vfs_bio.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/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.238 src/sys/kern/vfs_bio.c:1.239
--- src/sys/kern/vfs_bio.c:1.238	Sun Jun  3 11:37:44 2012
+++ src/sys/kern/vfs_bio.c	Sun Jun  3 16:23:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_bio.c,v 1.238 2012/06/03 11:37:44 dsl Exp $	*/
+/*	$NetBSD: vfs_bio.c,v 1.239 2012/06/03 16:23:44 dsl Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_bio.c,v 1.238 2012/06/03 11:37:44 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_bio.c,v 1.239 2012/06/03 16:23:44 dsl Exp $);
 
 #include opt_bufcache.h
 
@@ -1732,12 +1732,18 @@ sysctl_bufvm_update(SYSCTLFN_ARGS)
 {
 	int error, rv;
 	struct sysctlnode node;
-	union u_int_long { unsigned int i; unsigned long l; } t;
+	unsigned int temp_bufcache;
+	unsigned long temp_water;
 
 	/* Take a copy of the supplied node and its data */
 	node = *rnode;
-	node.sysctl_data = t;
-	t = *(union u_int_long *)rnode-sysctl_data;
+	if (node.sysctl_data == bufcache) {
+	node.sysctl_data = temp_bufcache;
+	temp_bufcache = *(unsigned int *)rnode-sysctl_data;
+	} else {
+	node.sysctl_data = temp_water;
+	temp_water = *(unsigned long *)rnode-sysctl_data;
+	}
 
 	/* Update the copy */
 	error = sysctl_lookup(SYSCTLFN_CALL(node));
@@ -1745,18 +1751,18 @@ sysctl_bufvm_update(SYSCTLFN_ARGS)
 		return (error);
 
 	if (rnode-sysctl_data == bufcache) {
-		if (t.i  100)
+		if (temp_bufcache  100)
 			return (EINVAL);
-		bufcache = t.i;
+		bufcache = temp_bufcache;
 		buf_setwm();
 	} else if (rnode-sysctl_data == bufmem_lowater) {
-		if (bufmem_hiwater - t.l  16)
+		if (bufmem_hiwater - temp_water  16)
 			return (EINVAL);
-		bufmem_lowater = t.l;
+		bufmem_lowater = temp_water;
 	} else if (rnode-sysctl_data == bufmem_hiwater) {
-		if (t.l - bufmem_lowater  16)
+		if (temp_water - bufmem_lowater  16)
 			return (EINVAL);
-		bufmem_hiwater = t.l;
+		bufmem_hiwater = temp_water;
 	} else
 		return (EINVAL);
 



CVS commit: src/sys/rump/librump/rumpkern

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 10:45:11 UTC 2012

Modified Files:
src/sys/rump/librump/rumpkern: rump.c

Log Message:
Fix build now that sysctl_createv() checks its arg type.


To generate a diff of this commit:
cvs rdiff -u -r1.240 -r1.241 src/sys/rump/librump/rumpkern/rump.c

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



CVS commit: src/external/cddl/osnet/dist/lib/libzfs/common

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 10:53:52 UTC 2012

Modified Files:
src/external/cddl/osnet/dist/lib/libzfs/common: libzfs_sendrecv.c

Log Message:
Not sure why this has just started to fail!
But it really isn't a good idea to compare a uint64_t to NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/external/cddl/osnet/dist/lib/libzfs/common/libzfs_sendrecv.c

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



CVS commit: src/tests/modules/k_helper

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 10:59:44 UTC 2012

Modified Files:
src/tests/modules/k_helper: k_helper.c

Log Message:
Fix build - delete extra 


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/modules/k_helper/k_helper.c

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



CVS commit: src/sys/kern

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 11:37:45 UTC 2012

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

Log Message:
Fix processing of vm.bufmem_lowater and vm.bufmem_hiwater on 64bit systems.
The values are 'u_long' so copying them into an 'int' temporary
(to avoid writing an out of range value into the actual variable)
doesn't work too well at all.
Shows up on amd64 now that the sysctl values are marked as 64bit.
sparc64 must have been badly broken for ages.


To generate a diff of this commit:
cvs rdiff -u -r1.237 -r1.238 src/sys/kern/vfs_bio.c

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



CVS commit: src/sys/dev/pckbport

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 13:52:46 UTC 2012

Modified Files:
src/sys/dev/pckbport: synaptics.c

Log Message:
Remove a couple of (void *) casts added in the previous commin.
They aren't needed here (script error).


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pckbport/synaptics.c

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



CVS commit: src/sys/kern

2012-06-03 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  3 16:23:44 UTC 2012

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

Log Message:
Use separate temporaries for the 'int' percentage and the 'long'
  water marks.
Previous paniced on sparc64 due to a misaligned copy.


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/sys/kern/vfs_bio.c

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



CVS commit: src/sys/sys

2012-06-02 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Jun  2 21:27:51 UTC 2012

Modified Files:
src/sys/sys: cdefs.h

Log Message:
Add a __always_inline


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/sys/cdefs.h

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

Modified files:

Index: src/sys/sys/cdefs.h
diff -u src/sys/sys/cdefs.h:1.98 src/sys/sys/cdefs.h:1.99
--- src/sys/sys/cdefs.h:1.98	Mon Apr 30 20:41:33 2012
+++ src/sys/sys/cdefs.h	Sat Jun  2 21:27:51 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cdefs.h,v 1.98 2012/04/30 20:41:33 pgoyette Exp $	*/
+/*	$NetBSD: cdefs.h,v 1.99 2012/06/02 21:27:51 dsl Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -232,6 +232,12 @@
 #define	__noinline	/* nothing */
 #endif
 
+#if __GNUC_PREREQ__(3, 0)
+#define	__always_inline	__attribute__((__always_inline__))
+#else
+#define	__always_inline	/* nothing */
+#endif
+
 #if __GNUC_PREREQ__(4, 1)
 #define	__returns_twice	__attribute__((__returns_twice__))
 #else



CVS commit: src/sbin/sysctl

2012-06-02 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Jun  2 21:38:09 UTC 2012

Modified Files:
src/sbin/sysctl: sysctl.c

Log Message:
Add support for unsigned decimal values.


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sbin/sysctl/sysctl.c

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

Modified files:

Index: src/sbin/sysctl/sysctl.c
diff -u src/sbin/sysctl/sysctl.c:1.142 src/sbin/sysctl/sysctl.c:1.143
--- src/sbin/sysctl/sysctl.c:1.142	Thu Mar 15 02:02:22 2012
+++ src/sbin/sysctl/sysctl.c	Sat Jun  2 21:38:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctl.c,v 1.142 2012/03/15 02:02:22 joerg Exp $ */
+/*	$NetBSD: sysctl.c,v 1.143 2012/06/02 21:38:09 dsl Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@ __COPYRIGHT(@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = @(#)sysctl.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: sysctl.c,v 1.142 2012/03/15 02:02:22 joerg Exp $);
+__RCSID($NetBSD: sysctl.c,v 1.143 2012/06/02 21:38:09 dsl Exp $);
 #endif
 #endif /* not lint */
 
@@ -1177,6 +1177,9 @@ parse_create(char *l)
 case 'p':
 	flags |= CTLFLAG_PRIVATE;
 	break;
+case 'u':
+	flags |= CTLFLAG_UNSIGNED;
+	break;
 case 'x':
 	flags |= CTLFLAG_HEX;
 	break;
@@ -1887,6 +1890,8 @@ display_number(const struct sysctlnode *
 			printf(0x%0*x, (int)sz * 2, i);
 		else if (node-sysctl_flags  CTLFLAG_HEX)
 			printf(%#x, i);
+		else if (node-sysctl_flags  CTLFLAG_UNSIGNED)
+			printf(%u, i);
 		else
 			printf(%d, i);
 		break;
@@ -1905,6 +1910,8 @@ display_number(const struct sysctlnode *
 			printf(0x%0* PRIx64, (int)sz * 2, q);
 		else if (node-sysctl_flags  CTLFLAG_HEX)
 			printf(%# PRIx64, q);
+		else if (node-sysctl_flags  CTLFLAG_UNSIGNED)
+			printf(% PRIu64, q);
 		else
 			printf(% PRIu64, q);
 		break;



CVS commit: src/sys/sys

2012-06-02 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Jun  2 21:27:51 UTC 2012

Modified Files:
src/sys/sys: cdefs.h

Log Message:
Add a __always_inline


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/sys/cdefs.h

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



CVS commit: src/sys

2012-06-02 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Jun  2 21:36:48 UTC 2012

Modified Files:
src/sys/arch/evbppc/obs405/dev: obsled.c
src/sys/arch/i386/i386: machdep.c
src/sys/arch/macppc/dev: obio.c
src/sys/arch/sparc64/dev: lom.c
src/sys/arch/x86/x86: est.c odcm.c powernow.c
src/sys/ddb: db_variables.c
src/sys/dev/acpi: acpi_display.c acpi_power.c asus_acpi.c fujbp_acpi.c
fujhk_acpi.c sony_acpi.c
src/sys/dev/adb: adb_kbd.c adb_ms.c
src/sys/dev/bluetooth: bcsp.c btmagic.c
src/sys/dev/gpio: gpiopwm.c gpiosim.c
src/sys/dev/i2c: dbcool.c lm75.c
src/sys/dev/ic: ac97.c ath_netbsd.h
src/sys/dev/isa: toaster.c
src/sys/dev/pci: auich.c if_iwi.c if_jme.c if_msk.c if_sk.c if_vte.c
if_wpi.c
src/sys/dev/pci/ixgbe: ixgbe.c
src/sys/dev/pci/voyager: pwmclock.c
src/sys/dev/pckbport: synaptics.c
src/sys/dev/usb: ubt.c
src/sys/external/bsd/acpica/dist/include: acglobal.h acpixf.h
src/sys/external/bsd/drm/dist/bsd-core: drm_sysctl.c
src/sys/kern: init_sysctl.c kern_sysctl.c vfs_bio.c
src/sys/miscfs/syncfs: sync_subr.c
src/sys/net: if_etherip.c if_tap.c
src/sys/net80211: ieee80211_netbsd.c
src/sys/netinet: in_selsrc.c ip_input.c tcp_usrreq.c
src/sys/netipsec: ipsec_netbsd.c
src/sys/sys: sysctl.h
src/sys/uvm: uvm_meter.c

Log Message:
Add some pre-processor magic to verify that the type of the data item
  passed to sysctl_createv() actually matches the declared type for
  the item itself.
In the places where the caller specifies a function and a structure
  address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
  sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
  AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
  fallout. Most likely passing char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbppc/obs405/dev/obsled.c
cvs rdiff -u -r1.727 -r1.728 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/macppc/dev/obio.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc64/dev/lom.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x86/x86/est.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/x86/odcm.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/x86/powernow.c
cvs rdiff -u -r1.42 -r1.43 src/sys/ddb/db_variables.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/acpi/acpi_display.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/acpi/acpi_power.c
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/acpi/asus_acpi.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/acpi/fujbp_acpi.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/acpi/fujhk_acpi.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/acpi/sony_acpi.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/adb/adb_kbd.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/adb/adb_ms.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/bluetooth/bcsp.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/bluetooth/btmagic.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/gpio/gpiopwm.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/gpio/gpiosim.c
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/i2c/dbcool.c
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/i2c/lm75.c
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/ic/ac97.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ic/ath_netbsd.h
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/isa/toaster.c
cvs rdiff -u -r1.140 -r1.141 src/sys/dev/pci/auich.c
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/pci/if_iwi.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/if_jme.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/pci/if_msk.c
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/pci/if_sk.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/if_vte.c
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/pci/if_wpi.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/voyager/pwmclock.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/usb/ubt.c
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/acpica/dist/include/acglobal.h \
src/sys/external/bsd/acpica/dist/include/acpixf.h
cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm/dist/bsd-core/drm_sysctl.c
cvs rdiff -u -r1.189 -r1.190 src/sys/kern/init_sysctl.c
cvs rdiff -u -r1.234 -r1.235 src/sys/kern/kern_sysctl.c
cvs rdiff -u -r1.236 -r1.237 src/sys/kern/vfs_bio.c
cvs rdiff -u -r1.47 -r1.48 src/sys/miscfs/syncfs/sync_subr.c
cvs rdiff -u -r1.31 -r1.32 src/sys/net/if_etherip.c
cvs rdiff -u -r1.66 -r1.67 src/sys/net/if_tap.c
cvs rdiff -u -r1.20 -r1.21 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.8 -r1.9 src/sys/netinet/in_selsrc.c
cvs rdiff -u -r1.299 -r1.300 src/sys/netinet/ip_input.c
cvs rdiff -u -r1.164 -r1.165 src/sys/netinet/tcp_usrreq.c
cvs rdiff -u -r1.33 -r1.34 

CVS commit: src/sbin/sysctl

2012-06-02 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Jun  2 21:38:09 UTC 2012

Modified Files:
src/sbin/sysctl: sysctl.c

Log Message:
Add support for unsigned decimal values.


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sbin/sysctl/sysctl.c

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



Re: CVS commit: src/sys

2012-05-31 Thread David Laight
On Wed, May 30, 2012 at 05:11:09PM -0700, John Nemeth wrote:
 On Oct 11,  4:10pm, David Laight wrote:
 } 
 } Module Name:src
 } Committed By:   dsl
 } Date:   Mon May 21 21:34:16 UTC 2012
 } 
 } Modified Files:
 } src/sys/arch/i386/stand/lib: exec.c
 } src/sys/arch/sandpoint/stand/altboot: main.c
 } src/sys/lib/libsa: ext2fs.c ffsv1.c ffsv2.c globals.c lfsv1.c lfsv2.c
 } stand.h ufs.c
 } 
 } Log Message:
 } Remove the code that tries to load the ffs kernel module during boot.
 } This is in line with the core decision than even modular kernels should
 }   contain the ffs code.
 } I've left in the code that tries to load nfs and ext2fs, but it
 }   isn't clear that is necessary.
 } Removes a warning message that (usually) flashes past to fast to read.
 } AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 
  Just because all shipping kernels are currently required to
 contain ffs doesn't mean a user can't build a kernel without it
 knowing that /boot will load the appropriate module.  At the very
 least, this should have been a knob so that people can build a /boot
 that will load the appropriate filesystem if they wish.

IIRC you can explicitly request (from boot.cfg) that any module be
loaded.  There is no need for boot itself to always try to load
such a module.

The problem is that there was no was of stopping boot trying to
load (typically) ffs.kmod, and if the kernel does contain it then
it doesn't seem correct at all.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys

2012-05-31 Thread David Laight
On Thu, May 31, 2012 at 10:06:28AM +0200, Martin Husemann wrote:
 On Thu, May 31, 2012 at 07:38:53AM +0100, David Laight wrote:
  IIRC you can explicitly request (from boot.cfg) that any module be
  loaded.  There is no need for boot itself to always try to load
  such a module.
 
 Yes there is, and I agree that this is the proper way to load it if you
 create a special ffs-as-modle-only kernel.

But you don't want /boot to try to load the module if the ffs code is
present in the kernel. Since /boot has no way of knowing what is in the
loaded kernel it is inappropriate for it to try to load the module file
and for the kernel to then try to load the module.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys

2012-05-31 Thread David Laight
On Thu, May 31, 2012 at 08:32:42PM +0200, Martin Husemann wrote:
 On Thu, May 31, 2012 at 06:30:38PM +0100, David Laight wrote:
  But you don't want /boot to try to load the module if the ffs code is
  present in the kernel. Since /boot has no way of knowing what is in the
  loaded kernel it is inappropriate for it to try to load the module file
  and for the kernel to then try to load the module.
 
 I thought I agree with you - but now you confused me. If I create (with
 care) a kernel w/o internal ffs, I can easily edit /boot.cfg. Hard
 coding it in boot seems wrong. Isn't that what you said as well?

I think I misunderstood you...

David

-- 
David Laight: da...@l8s.co.uk


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

2012-05-22 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Tue May 22 21:10:26 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64: vector.S

Log Message:
If we get a fault setting the user %gs, or on a iret that is returning
to userspace, we must do a 'swapgs' to reload the kernel %gs_base.
Also save the %ds, %es, %fs, %gs selector values in the frame so
they can be restored if we finally return to user (probably after
an application SIGSEGV handler has fixed the error).
Without this any such fault leaves the kernel running with the wrong
%gs offset and it will most likely fault again early in trap().
Repeats until the stack tramples on something important.
iret change works, invalid %gs is a little harder to arrange.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/amd64/amd64/vector.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/vector.S
diff -u src/sys/arch/amd64/amd64/vector.S:1.40 src/sys/arch/amd64/amd64/vector.S:1.41
--- src/sys/arch/amd64/amd64/vector.S:1.40	Mon May  7 21:09:29 2012
+++ src/sys/arch/amd64/amd64/vector.S	Tue May 22 21:10:26 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.40 2012/05/07 21:09:29 dsl Exp $	*/
+/*	$NetBSD: vector.S,v 1.41 2012/05/22 21:10:26 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -224,14 +224,53 @@ IDTVEC(trap09)
 IDTVEC(trap0a)
 	TRAP(T_TSSFLT)
 
-IDTVEC(trap0b)
-	TRAP(T_SEGNPFLT)
-
-IDTVEC(trap0c)
-	TRAP(T_STKFLT)
+#ifdef XEN
+/*
+ * I don't believe XEN generates in-kernel traps for the
+ * equivalent of iret, if it does this code would be needed
+ * in order to copy the user segment registers into the fault frame.
+ */
+#define check_swapgs alltraps
+#endif
 
-IDTVEC(trap0d)
-	TRAP(T_PROTFLT)
+IDTVEC(trap0b)		/* #NP() Segment not present */
+	TRAP_NJ(T_SEGNPFLT)
+	jmp	check_swapgs
+
+IDTVEC(trap0c)		/* #SS() Stack exception */
+	TRAP_NJ(T_STKFLT)
+	jmp	check_swapgs
+
+IDTVEC(trap0d)		/* #GP() General protection */
+	TRAP_NJ(T_PROTFLT)
+#ifdef check_swapgs
+	jmp	check_swapgs
+#else
+/* We need to worry about traps while the kernel %gs_base isn't loaded.
+ * These are either loads to %gs (only 32bit) or faults on iret during
+ * return to user. */
+check_swapgs:
+	INTRENTRY_L(3f,1:)
+2:	sti
+	jmp	calltrap
+3:
+	/* Trap in kernel mode. */
+	/* If faulting instruction is 'iret' we may need to do a 'swapgs'. */
+	movq	TF_RIP(%rsp),%rax
+	cmpw	$0xcf48,(%rax)		/* Faulting instruction is iretq ? */
+	jne	5f			/* Jump if not */
+	movq	TF_RSP(%rsp),%rax	/* Must read %rsp, may be a pad word */
+	testb	$SEL_UPL,8(%rax)	/* Check %cs of outer iret frame */
+	je	2b			/* jump if iret was to kernel  */
+	jmp	1b			/* to user - must restore %gs */
+5:
+	/* Not 'iret', all moves to %gs also need a swapgs */
+	movw	(%rax),%ax
+	andb	$070,%ah		/* mask mod/rm from mod/reg/rm */
+	cmpw	$0x8e+050*256,%ax	/* Any move to %gs (reg 5) */
+	jne	2b			/* No - normal kernel fault */
+	jmp	1b			/* Yes - restore %gs */
+#endif
 
 IDTVEC(trap0e)
 	TRAP(T_PAGEFLT)
@@ -305,25 +344,20 @@ IDTVEC(exceptions)
 	.quad	_C_LABEL(Xtrap1e), _C_LABEL(Xtrap1f)
 
 /*
- * If an error is detected during trap, syscall, or interrupt exit, trap() will
- * change %eip to point to one of these labels.  We clean up the stack, if
- * necessary, and resume as if we were handling a general protection fault.
- * This will cause the process to get a SIGBUS.
- *
- * XXXfvdl currently unused, as pop %ds and pop %es are illegal in long
- * mode. However, if the x86-64 port is going to support USER_LDT, we
- * may need something like this after all.
+ * trap() calls here when it detects a fault in INTRFASTEXIT (loading the
+ * segment registers or during the iret itself).
+ * The address of the (possibly reconstructed) user trap frame is
+ * passed as an argument.
+ * Typically the code will have raised a SIGSEGV which will be actioned
+ * by the code below.
  */
-NENTRY(resume_iret)
-	ZTRAP(T_PROTFLT)
-#if 0
-NENTRY(resume_pop_ds)
-	movl	$GSEL(GDATA_SEL, SEL_KPL),%eax
-	movl	%eax,%es
-NENTRY(resume_pop_es)
-	movl	$T_PROTFLT,TF_TRAPNO(%rsp)
-	jmp	calltrap
-#endif
+_C_LABEL(trap_return_fault_return):	.globl	trap_return_fault_return
+	mov	%rdi,%rsp		/* frame for user return */
+#ifdef DIAGNOSTIC
+	/* We can't recover the saved %rbx, so suppress warning */
+	movl	CPUVAR(ILEVEL),%ebx
+#endif /* DIAGNOSTIC */
+	jmp	.Lalltraps_checkusr
 
 /*
  * All traps go through here. Call the generic trap handler, and



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

2012-05-22 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Tue May 22 21:14:37 UTC 2012

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

Log Message:
Treat traps in kernel mode during the 'return to user' iret sequence
as user faults.
Based heavily in the i386 code with the correct opcode bytes inserted.
iret path tested, arranging for segment register errors is harder.
User %fs and %gs (32bit apps) are loaded much earlier and any errors
will generate kernel panics - there is probably code to try to stop
the invalid values being set.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/amd64/amd64/trap.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/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.70 src/sys/arch/amd64/amd64/trap.c:1.71
--- src/sys/arch/amd64/amd64/trap.c:1.70	Sun Feb 19 21:06:02 2012
+++ src/sys/arch/amd64/amd64/trap.c	Tue May 22 21:14:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.70 2012/02/19 21:06:02 rmind Exp $	*/
+/*	$NetBSD: trap.c,v 1.71 2012/05/22 21:14:37 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.70 2012/02/19 21:06:02 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.71 2012/05/22 21:14:37 dsl Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -120,6 +120,7 @@ dtrace_doubletrap_func_t	dtrace_doubletr
 #endif
 
 void trap(struct trapframe *);
+void trap_return_fault_return(struct trapframe *) __dead;
 
 const char * const trap_type[] = {
 	privileged instruction fault,		/*  0 T_PRIVINFLT */
@@ -198,17 +199,14 @@ trap(struct trapframe *frame)
 	struct lwp *l = curlwp;
 	struct proc *p;
 	struct pcb *pcb;
-	extern char fusuintrfailure[], kcopy_fault[],
-		resume_iret[];
+	extern char fusuintrfailure[], kcopy_fault[];
 	extern char IDTVEC(oosyscall)[];
 	extern char IDTVEC(osyscall)[];
 	extern char IDTVEC(syscall32)[];
-#if 0
-	extern char resume_pop_ds[], resume_pop_es[];
-#endif
+#ifndef XEN
 	struct trapframe *vframe;
+#endif
 	ksiginfo_t ksi;
-	void *resume;
 	void *onfault;
 	int type, error;
 	uint64_t cr2;
@@ -310,50 +308,76 @@ copyfault:
 
 		/*
 		 * Check for failure during return to user mode.
+		 * This can happen loading invalid values into the segment
+		 * registers, or during the 'iret' itself.
 		 *
-		 * XXXfvdl check for rex prefix?
-		 *
-		 * We do this by looking at the instruction we faulted on.  The
-		 * specific instructions we recognize only happen when
+		 * We do this by looking at the instruction we faulted on.
+		 * The specific instructions we recognize only happen when
 		 * returning from a trap, syscall, or interrupt.
-		 *
-		 * XXX
-		 * The heuristic used here will currently fail for the case of
-		 * one of the 2 pop instructions faulting when returning from a
-		 * a fast interrupt.  This should not be possible.  It can be
-		 * fixed by rearranging the trap frame so that the stack format
-		 * at this point is the same as on exit from a `slow'
-		 * interrupt.
 		 */
-		switch (*(u_char *)frame-tf_rip) {
-		case 0xcf:	/* iret */
-			vframe = (void *)((uint64_t)frame-tf_rsp - 44);
-			resume = resume_iret;
-			break;
-/*
- * XXXfvdl these are illegal in long mode (not in compat mode, though)
- * and we do not take back the descriptors from the signal context anyway,
- * but may do so later for USER_LDT, in which case we need to intercept
- * other instructions (movl %eax, %Xs).
- */
-#if 0
-		case 0x1f:	/* popl %ds */
-			vframe = (void *)((uint64_t)frame-tf_rsp - 4);
-			resume = resume_pop_ds;
-			break;
-		case 0x07:	/* popl %es */
-			vframe = (void *)((uint64_t)frame-tf_rsp - 0);
-			resume = resume_pop_es;
+
+kernelfault:
+#ifdef XEN
+		/*
+		 * XXX: there has to be an equivalent 'problem'
+		 * but I (dsl) don't know exactly what happens!
+		 * For now panic the kernel.
+		 */
+		goto we_re_toast;
+#else
+		KSI_INIT_TRAP(ksi);
+		ksi.ksi_signo = SIGSEGV;
+		ksi.ksi_code = SEGV_ACCERR;
+		ksi.ksi_trap = type;
+
+		/* Get %rsp value before fault - there may be a pad word
+		 * below the trap frame. */
+		vframe = (void *)frame-tf_rsp;
+		switch (*(uint16_t *)frame-tf_rip) {
+		case 0xcf48:	/* iretq */
+			/*
+			 * The 'iretq' instruction faulted, wo we have the
+			 * 'user' registers saved after the kernel
+			 * %rip:%cs:%fl:%rsp:%ss of the iret, and below that
+			 * the user %rip:%cs:%fl:%rsp:%ss the 'iret' was
+			 * processing.
+			 * We must copy the user register back over the
+			 * kernel fault frame to generate a normal stack
+			 * frame (eg for sending a SIGSEGV).
+			 */
+			vframe = (void *)((char *)vframe
+			- offsetof(struct trapframe, tf_rip));
+			memmove(vframe, frame,
+			offsetof(struct trapframe, tf_rip));
+			/* Set the faulting address to the user %eip */
+			ksi.ksi_addr = (void *)vframe-tf_rip;
+			break;
+		case 0x848e:	/* 

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

2012-05-22 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Tue May 22 21:10:26 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64: vector.S

Log Message:
If we get a fault setting the user %gs, or on a iret that is returning
to userspace, we must do a 'swapgs' to reload the kernel %gs_base.
Also save the %ds, %es, %fs, %gs selector values in the frame so
they can be restored if we finally return to user (probably after
an application SIGSEGV handler has fixed the error).
Without this any such fault leaves the kernel running with the wrong
%gs offset and it will most likely fault again early in trap().
Repeats until the stack tramples on something important.
iret change works, invalid %gs is a little harder to arrange.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/amd64/amd64/vector.S

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



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

2012-05-22 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Tue May 22 21:14:37 UTC 2012

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

Log Message:
Treat traps in kernel mode during the 'return to user' iret sequence
as user faults.
Based heavily in the i386 code with the correct opcode bytes inserted.
iret path tested, arranging for segment register errors is harder.
User %fs and %gs (32bit apps) are loaded much earlier and any errors
will generate kernel panics - there is probably code to try to stop
the invalid values being set.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/amd64/amd64/trap.c

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



CVS commit: src/sys

2012-05-21 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Mon May 21 21:34:16 UTC 2012

Modified Files:
src/sys/arch/i386/stand/lib: exec.c
src/sys/arch/sandpoint/stand/altboot: main.c
src/sys/lib/libsa: ext2fs.c ffsv1.c ffsv2.c globals.c lfsv1.c lfsv2.c
stand.h ufs.c

Log Message:
Remove the code that tries to load the ffs kernel module during boot.
This is in line with the core decision than even modular kernels should
  contain the ffs code.
I've left in the code that tries to load nfs and ext2fs, but it
  isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/i386/stand/lib/exec.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r1.12 -r1.13 src/sys/lib/libsa/ext2fs.c
cvs rdiff -u -r1.5 -r1.6 src/sys/lib/libsa/ffsv1.c src/sys/lib/libsa/ffsv2.c
cvs rdiff -u -r1.8 -r1.9 src/sys/lib/libsa/globals.c
cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/lfsv1.c src/sys/lib/libsa/lfsv2.c
cvs rdiff -u -r1.75 -r1.76 src/sys/lib/libsa/stand.h
cvs rdiff -u -r1.57 -r1.58 src/sys/lib/libsa/ufs.c

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

Modified files:

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.49 src/sys/arch/i386/stand/lib/exec.c:1.50
--- src/sys/arch/i386/stand/lib/exec.c:1.49	Mon Nov 28 07:56:54 2011
+++ src/sys/arch/i386/stand/lib/exec.c	Mon May 21 21:34:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.49 2011/11/28 07:56:54 tls Exp $	 */
+/*	$NetBSD: exec.c,v 1.50 2012/05/21 21:34:16 dsl Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -297,10 +297,9 @@ common_load_kernel(const char *file, u_l
 
 	close(fd);
 
-	/* Now we know the root fs type, load modules for it. */
-	module_add(fsmod);
-	if (fsmod2 != NULL  strcmp(fsmod, fsmod2) != 0)
-		module_add(fsmod2);
+	/* If the root fs type is unusual, load its module. */
+	if (fsmod != NULL)
+		module_add(fsmod);
 
 	/*
 	 * Gather some information for the kernel. Do this after the

Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.20 src/sys/arch/sandpoint/stand/altboot/main.c:1.21
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.20	Fri Apr 27 00:35:43 2012
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Mon May 21 21:34:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.20 2012/04/27 00:35:43 nisimura Exp $ */
+/* $NetBSD: main.c,v 1.21 2012/05/21 21:34:16 dsl Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -353,9 +353,8 @@ main(int argc, char *argv[], char *boota
 		}
 
 		if (modules_enabled) {
-			module_add(fsmod);
-			if (fsmod2 != NULL  strcmp(fsmod, fsmod2) != 0)
-module_add(fsmod2);
+			if (fsmod != NULL)
+module_add(fsmod);
 			kmodloadp = marks[MARK_END];
 			btinfo_modulelist = NULL;
 			module_load(bname);

Index: src/sys/lib/libsa/ext2fs.c
diff -u src/sys/lib/libsa/ext2fs.c:1.12 src/sys/lib/libsa/ext2fs.c:1.13
--- src/sys/lib/libsa/ext2fs.c:1.12	Mon Jan 16 18:44:13 2012
+++ src/sys/lib/libsa/ext2fs.c	Mon May 21 21:34:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.c,v 1.12 2012/01/16 18:44:13 christos Exp $	*/
+/*	$NetBSD: ext2fs.c,v 1.13 2012/05/21 21:34:16 dsl Exp $	*/
 
 /*
  * Copyright (c) 1997 Manuel Bouyer.
@@ -713,10 +713,8 @@ ext2fs_open(const char *path, struct ope
 out:
 	if (rc)
 		ext2fs_close(f);
-	else {
+	else
 		fsmod = ext2fs;
-		fsmod2 = ffs;
-	}
 	return rc;
 }
 

Index: src/sys/lib/libsa/ffsv1.c
diff -u src/sys/lib/libsa/ffsv1.c:1.5 src/sys/lib/libsa/ffsv1.c:1.6
--- src/sys/lib/libsa/ffsv1.c:1.5	Sun Dec 25 06:09:08 2011
+++ src/sys/lib/libsa/ffsv1.c	Mon May 21 21:34:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ffsv1.c,v 1.5 2011/12/25 06:09:08 tsutsui Exp $ */
+/* $NetBSD: ffsv1.c,v 1.6 2012/05/21 21:34:16 dsl Exp $ */
 
 #define LIBSA_FFSv1
 
@@ -15,6 +15,4 @@
 #define ufs_dinode	ufs1_dinode
 #define indp_t		int32_t
 
-#define	FSMOD		ffs
-
 #include ufs.c
Index: src/sys/lib/libsa/ffsv2.c
diff -u src/sys/lib/libsa/ffsv2.c:1.5 src/sys/lib/libsa/ffsv2.c:1.6
--- src/sys/lib/libsa/ffsv2.c:1.5	Sun Dec 25 06:09:08 2011
+++ src/sys/lib/libsa/ffsv2.c	Mon May 21 21:34:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ffsv2.c,v 1.5 2011/12/25 06:09:08 tsutsui Exp $ */
+/* $NetBSD: ffsv2.c,v 1.6 2012/05/21 21:34:16 dsl Exp $ */
 
 #define LIBSA_FFSv2
 
@@ -15,6 +15,4 @@
 #define ufs_dinode	ufs2_dinode
 #define indp_t		int64_t
 
-#define	FSMOD		ffs
-
 #include ufs.c

Index: src/sys/lib/libsa/globals.c
diff -u src/sys/lib/libsa/globals.c:1.8 src/sys/lib/libsa/globals.c:1.9
--- src/sys/lib/libsa/globals.c:1.8	Wed Nov 19 12:36:41 2008
+++ src/sys/lib/libsa/globals.c	Mon May 21 21:34:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: globals.c,v 1.8 2008/11/19 12:36:41 ad Exp $	*/
+/*	$NetBSD: globals.c,v 1.9 

CVS commit: src/sys

2012-05-21 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Mon May 21 21:34:16 UTC 2012

Modified Files:
src/sys/arch/i386/stand/lib: exec.c
src/sys/arch/sandpoint/stand/altboot: main.c
src/sys/lib/libsa: ext2fs.c ffsv1.c ffsv2.c globals.c lfsv1.c lfsv2.c
stand.h ufs.c

Log Message:
Remove the code that tries to load the ffs kernel module during boot.
This is in line with the core decision than even modular kernels should
  contain the ffs code.
I've left in the code that tries to load nfs and ext2fs, but it
  isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/i386/stand/lib/exec.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r1.12 -r1.13 src/sys/lib/libsa/ext2fs.c
cvs rdiff -u -r1.5 -r1.6 src/sys/lib/libsa/ffsv1.c src/sys/lib/libsa/ffsv2.c
cvs rdiff -u -r1.8 -r1.9 src/sys/lib/libsa/globals.c
cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/lfsv1.c src/sys/lib/libsa/lfsv2.c
cvs rdiff -u -r1.75 -r1.76 src/sys/lib/libsa/stand.h
cvs rdiff -u -r1.57 -r1.58 src/sys/lib/libsa/ufs.c

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



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

2012-05-17 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Thu May 17 19:38:54 UTC 2012

Modified Files:
src/sys/arch/amd64/include: frameasm.h

Log Message:
Let the user of INTRENTRY_L() place a label on the 'swapgs' used
  when faulting from user space.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/amd64/include/frameasm.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/include/frameasm.h
diff -u src/sys/arch/amd64/include/frameasm.h:1.18 src/sys/arch/amd64/include/frameasm.h:1.19
--- src/sys/arch/amd64/include/frameasm.h:1.18	Mon May  7 21:04:09 2012
+++ src/sys/arch/amd64/include/frameasm.h	Thu May 17 19:38:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: frameasm.h,v 1.18 2012/05/07 21:04:09 dsl Exp $	*/
+/*	$NetBSD: frameasm.h,v 1.19 2012/05/17 19:38:53 dsl Exp $	*/
 
 #ifndef _AMD64_MACHINE_FRAMEASM_H
 #define _AMD64_MACHINE_FRAMEASM_H
@@ -73,11 +73,12 @@
 	movq	TF_RBX(%rsp),%rbx	; \
 	movq	TF_RAX(%rsp),%rax
 
-#define	INTRENTRY_L(kernel_trap) \
+#define	INTRENTRY_L(kernel_trap, usertrap) \
 	subq	$TF_REGSIZE,%rsp	; \
 	INTR_SAVE_GPRS			; \
 	testb	$SEL_UPL,TF_CS(%rsp)	; \
 	je	kernel_trap		; \
+usertrap; \
 	swapgs; \
 	movw	%gs,TF_GS(%rsp)		; \
 	movw	%fs,TF_FS(%rsp)		; \
@@ -85,7 +86,7 @@
 	movw	%ds,TF_DS(%rsp)	
 
 #define	INTRENTRY \
-	INTRENTRY_L(98f)		; \
+	INTRENTRY_L(98f,)		; \
 98:
 
 #define INTRFASTEXIT \



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

2012-05-17 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Thu May 17 19:38:54 UTC 2012

Modified Files:
src/sys/arch/amd64/include: frameasm.h

Log Message:
Let the user of INTRENTRY_L() place a label on the 'swapgs' used
  when faulting from user space.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/amd64/include/frameasm.h

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



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

2012-05-07 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Mon May  7 20:51:20 UTC 2012

Modified Files:
src/sys/arch/amd64/include: frameasm.h

Log Message:
Move all the XEN differences to a single conditional.
Merge the XEN/non-XEN versions of INTRFASTEXIT and
  INTR_RECURSE_HWFRAME by using extra defines.
Split INTRENTRY so that code can insert extra instructions
  inside user/kernel conditional.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/amd64/include/frameasm.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/include/frameasm.h
diff -u src/sys/arch/amd64/include/frameasm.h:1.16 src/sys/arch/amd64/include/frameasm.h:1.17
--- src/sys/arch/amd64/include/frameasm.h:1.16	Wed Aug 10 06:33:13 2011
+++ src/sys/arch/amd64/include/frameasm.h	Mon May  7 20:51:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: frameasm.h,v 1.16 2011/08/10 06:33:13 cherry Exp $	*/
+/*	$NetBSD: frameasm.h,v 1.17 2012/05/07 20:51:20 dsl Exp $	*/
 
 #ifndef _AMD64_MACHINE_FRAMEASM_H
 #define _AMD64_MACHINE_FRAMEASM_H
@@ -17,7 +17,23 @@
 /* Xen do not need swapgs, done by hypervisor */
 #define swapgs
 #define iretq	pushq $0 ; jmp HYPERVISOR_iret
-#endif
+#define	XEN_ONLY2(x,y)	x,y
+#define	NOT_XEN(x)
+
+#define CLI(temp_reg) \
+ 	movq CPUVAR(VCPU),%r ## temp_reg ;			\
+	movb $1,EVTCHN_UPCALL_MASK(%r ## temp_reg);
+
+#define STI(temp_reg) \
+ 	movq CPUVAR(VCPU),%r ## temp_reg ;			\
+	movb $0,EVTCHN_UPCALL_MASK(%r ## temp_reg);
+
+#else /* XEN */
+#define	XEN_ONLY2(x,y)
+#define	NOT_XEN(x)	x
+#define CLI(temp_reg) cli
+#define STI(temp_reg) sti
+#endif	/* XEN */
 
 /*
  * These are used on interrupt or trap entry or exit.
@@ -57,23 +73,27 @@
 	movq	TF_RBX(%rsp),%rbx	; \
 	movq	TF_RAX(%rsp),%rax
 
-#define	INTRENTRY \
+#define	INTRENTRY_L(kernel_trap) \
 	subq	$TF_REGSIZE,%rsp	; \
-	testq	$SEL_UPL,TF_CS(%rsp)	; \
-	je	98f			; \
+	INTR_SAVE_GPRS			; \
+	testb	$SEL_UPL,TF_CS(%rsp)	; \
+	je	kernel_trap		; \
 	swapgs; \
 	movw	%gs,TF_GS(%rsp)		; \
 	movw	%fs,TF_FS(%rsp)		; \
 	movw	%es,TF_ES(%rsp)		; \
-	movw	%ds,TF_DS(%rsp)		; \
-98:	INTR_SAVE_GPRS
+	movw	%ds,TF_DS(%rsp)	
+
+#define	INTRENTRY \
+	INTRENTRY_L(98f)		; \
+98:
 
-#ifndef XEN
 #define INTRFASTEXIT \
 	INTR_RESTORE_GPRS 		; \
 	testq	$SEL_UPL,TF_CS(%rsp)	/* Interrupted %cs */ ; \
 	je	99f			; \
-	cli; \
+/* XEN: Disabling events before going to user mode sounds like a BAD idea */ \
+	NOT_XEN(cli;)			  \
 	movw	TF_ES(%rsp),%es		; \
 	movw	TF_DS(%rsp),%ds		; \
 	swapgs; \
@@ -88,41 +108,15 @@
 	pushfq; \
 	movl	%cs,%r11d		; \
 	pushq	%r11			; \
+/* XEN: We must fixup CS, as even kernel mode runs at CPL 3 */ \
+ 	XEN_ONLY2(andb	$0xfc,(%rsp))	  \
 	pushq	%r13			;
 
-#else	/* !XEN */
-/*
- * Disabling events before going to user mode sounds like a BAD idea
- * do no restore gs either, HYPERVISOR_iret will do a swapgs
- */
-#define INTRFASTEXIT \
- 	INTR_RESTORE_GPRS 		; \
- 	testq	$SEL_UPL,TF_CS(%rsp)	; \
- 	je	99f			; \
- 	movw	TF_ES(%rsp),%es		; \
- 	movw	TF_DS(%rsp),%ds		; \
-99:	addq	$TF_REGSIZE+16,%rsp	/* + T_xxx and error code */ ; \
- 	iretq
-  
-/* We must fixup CS, as even kernel mode runs at CPL 3 */
-#define INTR_RECURSE_HWFRAME \
- 	movq	%rsp,%r10		; \
- 	movl	%ss,%r11d		; \
- 	pushq	%r11			; \
- 	pushq	%r10			; \
- 	pushfq; \
- 	movl	%cs,%r11d		; \
- 	pushq	%r11			; \
- 	andb	$0xfc,(%rsp)		; \
- 	pushq	%r13			;
- 
-#endif	/* !XEN */
- 
 #define	DO_DEFERRED_SWITCH \
 	cmpl	$0, CPUVAR(WANT_PMAPLOAD)		; \
 	jz	1f	; \
 	call	_C_LABEL(do_pmap_load)			; \
-	1:
+1:
 
 #define	CHECK_DEFERRED_SWITCH \
 	cmpl	$0, CPUVAR(WANT_PMAPLOAD)
@@ -130,18 +124,4 @@
 #define CHECK_ASTPENDING(reg)	cmpl	$0, L_MD_ASTPENDING(reg)
 #define CLEAR_ASTPENDING(reg)	movl	$0, L_MD_ASTPENDING(reg)
 
-#ifdef XEN
-#define CLI(temp_reg) \
- 	movq CPUVAR(VCPU),%r ## temp_reg ;			\
-	movb $1,EVTCHN_UPCALL_MASK(%r ## temp_reg);
-
-#define STI(temp_reg) \
- 	movq CPUVAR(VCPU),%r ## temp_reg ;			\
-	movb $0,EVTCHN_UPCALL_MASK(%r ## temp_reg);
-
-#else /* XEN */
-#define CLI(temp_reg) cli
-#define STI(temp_reg) sti
-#endif	/* XEN */
-
 #endif /* _AMD64_MACHINE_FRAMEASM_H */



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

2012-05-07 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Mon May  7 21:04:10 UTC 2012

Modified Files:
src/sys/arch/amd64/include: frameasm.h

Log Message:
Add a ';' that got deleted in a slight tidyup.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/amd64/include/frameasm.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/include/frameasm.h
diff -u src/sys/arch/amd64/include/frameasm.h:1.17 src/sys/arch/amd64/include/frameasm.h:1.18
--- src/sys/arch/amd64/include/frameasm.h:1.17	Mon May  7 20:51:20 2012
+++ src/sys/arch/amd64/include/frameasm.h	Mon May  7 21:04:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: frameasm.h,v 1.17 2012/05/07 20:51:20 dsl Exp $	*/
+/*	$NetBSD: frameasm.h,v 1.18 2012/05/07 21:04:09 dsl Exp $	*/
 
 #ifndef _AMD64_MACHINE_FRAMEASM_H
 #define _AMD64_MACHINE_FRAMEASM_H
@@ -109,7 +109,7 @@
 	movl	%cs,%r11d		; \
 	pushq	%r11			; \
 /* XEN: We must fixup CS, as even kernel mode runs at CPL 3 */ \
- 	XEN_ONLY2(andb	$0xfc,(%rsp))	  \
+ 	XEN_ONLY2(andb	$0xfc,(%rsp);)	  \
 	pushq	%r13			;
 
 #define	DO_DEFERRED_SWITCH \



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

2012-05-07 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Mon May  7 21:09:29 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64: vector.S

Log Message:
Rejig the way TRAP() and ZTRAP() are defined and add Z/TRAP_NJ() that
  excludes the 'jmp alltraps'.
Use the _NJ versions for trap entries with non-standard code.
Move all the KDTRACE_HOOKS code into a single block inside the
  IDTVEC(trap03) code. This removes a mis-predicted from every
  trap when KDTRACE_HOOKS are enabled.
Add a few blank lines, need some comments as well :-)
No functional changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/amd64/amd64/vector.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/vector.S
diff -u src/sys/arch/amd64/amd64/vector.S:1.39 src/sys/arch/amd64/amd64/vector.S:1.40
--- src/sys/arch/amd64/amd64/vector.S:1.39	Sat Apr 21 18:52:36 2012
+++ src/sys/arch/amd64/amd64/vector.S	Mon May  7 21:09:29 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.39 2012/04/21 18:52:36 christos Exp $	*/
+/*	$NetBSD: vector.S,v 1.40 2012/05/07 21:09:29 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -100,40 +100,25 @@
 
 /*/
 
-#ifndef	XEN
-#define PRE_TRAP
-#define	TRAP(a)		pushq $(a) ; jmp _C_LABEL(alltraps)
-#define	ZTRAP(a)	pushq $0 ; TRAP(a)
-#else
+#ifdef	XEN
 #define	PRE_TRAP	movq (%rsp),%rcx ; movq 8(%rsp),%r11 ; addq $0x10,%rsp 
-#define	POST_TRAP(a)	pushq $(a) ; jmp _C_LABEL(alltraps)
-#define	TRAP(a)		PRE_TRAP ; POST_TRAP(a)
-#define ZTRAP(a)	PRE_TRAP ; pushq $0 ; POST_TRAP(a)
+#else
+#define	PRE_TRAP
 #endif
 
-#define	BPTTRAP(a)	ZTRAP(a)
+#define	TRAP_NJ(a)	PRE_TRAP ; pushq $(a)
+#define	ZTRAP_NJ(a)	PRE_TRAP ; pushq $0 ; pushq $(a)
+#define	TRAP(a)		TRAP_NJ(a) ; jmp _C_LABEL(alltraps)
+#define	ZTRAP(a)	ZTRAP_NJ(a) ; jmp _C_LABEL(alltraps)
 
-#ifdef KDTRACE_HOOKS
-	.bss
-	.globl	dtrace_invop_jump_addr
-	.align	8
-	.type	dtrace_invop_jump_addr, @object
-	.size	dtrace_invop_jump_addr, 8
-dtrace_invop_jump_addr:
-	.zero	8
-	.globl	dtrace_invop_calltrap_addr
-	.align	8
-	.type	dtrace_invop_calltrap_addr, @object
-	.size	dtrace_invop_calltrap_addr, 8
-dtrace_invop_calltrap_addr:
-	.zero	8
-#endif
 	.text
 
 IDTVEC(trap00)
 	ZTRAP(T_DIVIDE)
+
 IDTVEC(trap01)
-	BPTTRAP(T_TRCTRAP)
+	ZTRAP(T_TRCTRAP)
+
 IDTVEC(trap02)
 #if defined(XEN)
 	ZTRAP(T_NMI)
@@ -167,18 +152,61 @@ IDTVEC(trap02)
 	addq	$TF_REGSIZE+16,%rsp
 	iretq
 #endif /* defined(XEN) */
+
 IDTVEC(trap03)
-	BPTTRAP(T_BPTFLT)
+#ifndef KDTRACE_HOOKS
+	ZTRAP(T_BPTFLT)
+#else
+	ZTRAP_NJ(T_BPTFLT)
+	INTRENTRY
+  	STI(si)
+	/*
+	 * DTrace Function Boundary Trace (fbt) probes are triggered
+	 * by int3 (0xcc).
+	 */
+	/* Check if there is no DTrace hook registered. */
+	cmpq	$0,dtrace_invop_jump_addr
+	je	calltrap
+
+	/*
+	 * Set our jump address for the jump back in the event that
+	 * the exception wasn't caused by DTrace at all.
+	 */
+	/* XXX: This doesn't look right for SMP - unless it is a
+	 * constant - so why set it everytime. (dsl) */
+	movq	$calltrap, dtrace_invop_calltrap_addr(%rip)
+
+	/* Jump to the code hooked in by DTrace. */
+	movq	dtrace_invop_jump_addr, %rax
+	jmpq	*dtrace_invop_jump_addr
+
+	.bss
+	.globl	dtrace_invop_jump_addr
+	.align	8
+	.type	dtrace_invop_jump_addr, @object
+	.size	dtrace_invop_jump_addr, 8
+dtrace_invop_jump_addr:
+	.zero	8
+	.globl	dtrace_invop_calltrap_addr
+	.align	8
+	.type	dtrace_invop_calltrap_addr, @object
+	.size	dtrace_invop_calltrap_addr, 8
+dtrace_invop_calltrap_addr:
+	.zero	8
+	.text
+#endif
+
 IDTVEC(trap04)
 	ZTRAP(T_OFLOW)
+
 IDTVEC(trap05)
 	ZTRAP(T_BOUND)
+
 IDTVEC(trap06)
 	ZTRAP(T_PRIVINFLT)
+
 IDTVEC(trap07)
-	PRE_TRAP;
-	pushq	$0			# dummy error code
-	pushq	$T_ASTFLT
+	ZTRAP_NJ(T_ASTFLT)
 	INTRENTRY
 #ifdef DIAGNOSTIC
 	movl	CPUVAR(ILEVEL),%ebx
@@ -186,34 +214,39 @@ IDTVEC(trap07)
 	movq	CPUVAR(SELF),%rdi
 	call	_C_LABEL(fpudna)
 	jmp	.Lalltraps_checkusr
+
 IDTVEC(trap08)
 	TRAP(T_DOUBLEFLT)
+
 IDTVEC(trap09)
 	ZTRAP(T_FPOPFLT)
+
 IDTVEC(trap0a)
 	TRAP(T_TSSFLT)
+
 IDTVEC(trap0b)
 	TRAP(T_SEGNPFLT)
+
 IDTVEC(trap0c)
 	TRAP(T_STKFLT)
+
 IDTVEC(trap0d)
 	TRAP(T_PROTFLT)
+
 IDTVEC(trap0e)
 	TRAP(T_PAGEFLT)
+
 IDTVEC(intrspurious)
 IDTVEC(trap0f)
-	PRE_TRAP;
-	pushq	$0			# dummy error code
-	pushq	$T_ASTFLT
+	ZTRAP_NJ(T_ASTFLT)
 	INTRENTRY
 #ifdef DIAGNOSTIC
 	movl	CPUVAR(ILEVEL),%ebx
 #endif /* DIAGNOSTIC */
 	jmp	.Lalltraps_checkusr
+
 IDTVEC(trap10)
-	PRE_TRAP;
-	pushq	$0			# dummy error code
-	pushq	$T_ARITHTRAP
+	ZTRAP_NJ(T_ARITHTRAP)
 .Ldo_fputrap:
 	INTRENTRY
 #ifdef DIAGNOSTIC
@@ -227,15 +260,17 @@ IDTVEC(trap10)
 1:
   	STI(si)
 	jmp	calltrap
+
 IDTVEC(trap11)
 	TRAP(T_ALIGNFLT)
+
 IDTVEC(trap12)
 	ZTRAP(T_MCA)
+
 IDTVEC(trap13)
-	PRE_TRAP;
-	pushq	$0			# dummy error code
-	pushq	$T_XMM
+	ZTRAP_NJ(T_XMM)
 	jmp	.Ldo_fputrap
+
 IDTVEC(trap14)
 

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

2012-05-07 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Mon May  7 20:51:20 UTC 2012

Modified Files:
src/sys/arch/amd64/include: frameasm.h

Log Message:
Move all the XEN differences to a single conditional.
Merge the XEN/non-XEN versions of INTRFASTEXIT and
  INTR_RECURSE_HWFRAME by using extra defines.
Split INTRENTRY so that code can insert extra instructions
  inside user/kernel conditional.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/amd64/include/frameasm.h

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



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

2012-05-07 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Mon May  7 21:04:10 UTC 2012

Modified Files:
src/sys/arch/amd64/include: frameasm.h

Log Message:
Add a ';' that got deleted in a slight tidyup.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/amd64/include/frameasm.h

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



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

2012-05-07 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Mon May  7 21:09:29 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64: vector.S

Log Message:
Rejig the way TRAP() and ZTRAP() are defined and add Z/TRAP_NJ() that
  excludes the 'jmp alltraps'.
Use the _NJ versions for trap entries with non-standard code.
Move all the KDTRACE_HOOKS code into a single block inside the
  IDTVEC(trap03) code. This removes a mis-predicted from every
  trap when KDTRACE_HOOKS are enabled.
Add a few blank lines, need some comments as well :-)
No functional changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/amd64/amd64/vector.S

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



CVS commit: src/sys

2012-04-29 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Apr 29 16:36:54 UTC 2012

Modified Files:
src/sys/kern: kern_malloc.c uipc_mbuf.c
src/sys/rump/librump/rumpkern: memalloc.c
src/sys/sys: malloc.h mbuf.h param.h

Log Message:
Remove the unused 'struct malloc_type' args to kern_malloc/realloc/free
The M_xxx arg is left on the calls to malloc() and free(),
  maybe they could be converted to an enumeration and just saved in
  the malloc header (for deep diag use).
Remove the malloc_type from mbuf extension.
Fixes rump build as well.
Welcome to 6.99.6


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/sys/kern/kern_malloc.c
cvs rdiff -u -r1.145 -r1.146 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.13 -r1.14 src/sys/rump/librump/rumpkern/memalloc.c
cvs rdiff -u -r1.111 -r1.112 src/sys/sys/malloc.h
cvs rdiff -u -r1.148 -r1.149 src/sys/sys/mbuf.h
cvs rdiff -u -r1.413 -r1.414 src/sys/sys/param.h

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

Modified files:

Index: src/sys/kern/kern_malloc.c
diff -u src/sys/kern/kern_malloc.c:1.139 src/sys/kern/kern_malloc.c:1.140
--- src/sys/kern/kern_malloc.c:1.139	Sat Apr 28 23:03:40 2012
+++ src/sys/kern/kern_malloc.c	Sun Apr 29 16:36:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_malloc.c,v 1.139 2012/04/28 23:03:40 rmind Exp $	*/
+/*	$NetBSD: kern_malloc.c,v 1.140 2012/04/29 16:36:53 dsl Exp $	*/
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_malloc.c,v 1.139 2012/04/28 23:03:40 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_malloc.c,v 1.140 2012/04/29 16:36:53 dsl Exp $);
 
 #include sys/param.h
 #include sys/malloc.h
@@ -103,7 +103,7 @@ struct malloc_header {
 } __aligned(ALIGNBYTES + 1);
 
 void *
-kern_malloc(unsigned long size, struct malloc_type *ksp, int flags)
+kern_malloc(unsigned long size, int flags)
 {
 	const int kmflags = (flags  M_NOWAIT) ? KM_NOSLEEP : KM_SLEEP;
 	size_t allocsize, hdroffset;
@@ -132,7 +132,7 @@ kern_malloc(unsigned long size, struct m
 }
 
 void
-kern_free(void *addr, struct malloc_type *ksp)
+kern_free(void *addr)
 {
 	struct malloc_header *mh;
 
@@ -147,8 +147,7 @@ kern_free(void *addr, struct malloc_type
 }
 
 void *
-kern_realloc(void *curaddr, unsigned long newsize, struct malloc_type *ksp,
-int flags)
+kern_realloc(void *curaddr, unsigned long newsize, int flags)
 {
 	struct malloc_header *mh;
 	unsigned long cursize;

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.145 src/sys/kern/uipc_mbuf.c:1.146
--- src/sys/kern/uipc_mbuf.c:1.145	Fri Feb 10 17:35:47 2012
+++ src/sys/kern/uipc_mbuf.c	Sun Apr 29 16:36:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.145 2012/02/10 17:35:47 para Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.146 2012/04/29 16:36:53 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uipc_mbuf.c,v 1.145 2012/02/10 17:35:47 para Exp $);
+__KERNEL_RCSID(0, $NetBSD: uipc_mbuf.c,v 1.146 2012/04/29 16:36:53 dsl Exp $);
 
 #include opt_mbuftrace.h
 #include opt_nmbclusters.h
@@ -73,7 +73,6 @@ __KERNEL_RCSID(0, $NetBSD: uipc_mbuf.c,
 #include sys/atomic.h
 #include sys/cpu.h
 #include sys/proc.h
-#define MBTYPES
 #include sys/mbuf.h
 #include sys/kernel.h
 #include sys/syslog.h

Index: src/sys/rump/librump/rumpkern/memalloc.c
diff -u src/sys/rump/librump/rumpkern/memalloc.c:1.13 src/sys/rump/librump/rumpkern/memalloc.c:1.14
--- src/sys/rump/librump/rumpkern/memalloc.c:1.13	Sun Apr 29 14:00:15 2012
+++ src/sys/rump/librump/rumpkern/memalloc.c	Sun Apr 29 16:36:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: memalloc.c,v 1.13 2012/04/29 14:00:15 rmind Exp $	*/
+/*	$NetBSD: memalloc.c,v 1.14 2012/04/29 16:36:53 dsl Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: memalloc.c,v 1.13 2012/04/29 14:00:15 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: memalloc.c,v 1.14 2012/04/29 16:36:53 dsl Exp $);
 
 #include sys/param.h
 #include sys/kmem.h
@@ -54,20 +54,6 @@ __KERNEL_RCSID(0, $NetBSD: memalloc.c,v
  * malloc
  */
 
-MALLOC_DEFINE(M_DEVBUF, devbuf, device driver memory);
-MALLOC_DEFINE(M_DMAMAP, DMA map, bus_dma(9) structures);
-MALLOC_DEFINE(M_FREE, free, should be on free list);
-MALLOC_DEFINE(M_PCB, pcb, protocol control block);
-MALLOC_DEFINE(M_TEMP, temp, misc. temporary data buffers);
-MALLOC_DEFINE(M_RTABLE, routetbl, routing tables);
-MALLOC_DEFINE(M_FTABLE, fragtbl, fragment reassembly header);
-MALLOC_DEFINE(M_UFSMNT, UFS mount, UFS mount structure);
-MALLOC_DEFINE(M_NETADDR, Export Host, Export host address structure);
-MALLOC_DEFINE(M_IPMOPTS, ip_moptions, internet multicast options);
-MALLOC_DEFINE(M_IPMADDR, in_multi, internet multicast address);
-MALLOC_DEFINE(M_MRTABLE, mrt, multicast routing tables);
-MALLOC_DEFINE(M_BWMETER, bwmeter, 

CVS commit: src/sys/dev/ieee1394

2012-04-29 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Apr 29 18:31:41 UTC 2012

Modified Files:
src/sys/dev/ieee1394: firewire.c firewirereg.h fwdev.c fwmem.c
fwohcivar.h if_fwip.c

Log Message:
Change to consistently use M_FW for all malloc/free.
It probably doesn't matter any more, but the code doesn't appear to
have matched its mallocs and frees - so the stats would have been awol.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/ieee1394/firewire.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ieee1394/firewirereg.h \
src/sys/dev/ieee1394/fwmem.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/ieee1394/fwdev.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/ieee1394/fwohcivar.h
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/ieee1394/if_fwip.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/ieee1394/firewire.c
diff -u src/sys/dev/ieee1394/firewire.c:1.38 src/sys/dev/ieee1394/firewire.c:1.39
--- src/sys/dev/ieee1394/firewire.c:1.38	Tue Sep  7 07:26:54 2010
+++ src/sys/dev/ieee1394/firewire.c	Sun Apr 29 18:31:40 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: firewire.c,v 1.38 2010/09/07 07:26:54 cegger Exp $	*/
+/*	$NetBSD: firewire.c,v 1.39 2012/04/29 18:31:40 dsl Exp $	*/
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: firewire.c,v 1.38 2010/09/07 07:26:54 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: firewire.c,v 1.39 2012/04/29 18:31:40 dsl Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -128,7 +128,6 @@ err:
 }
 
 MALLOC_DEFINE(M_FW, ieee1394, IEEE1394);
-MALLOC_DEFINE(M_FWXFER, fw_xfer, XFER/IEEE1394);
 
 #define FW_MAXASYRTY 4
 
@@ -1139,7 +1138,7 @@ fw_rcv(struct fw_rcv_buf *rb)
 cannot respond(bus reset)!\n);
 return;
 			}
-			rb-xfer = fw_xfer_alloc(M_FWXFER);
+			rb-xfer = fw_xfer_alloc(M_FW);
 			if (rb-xfer == NULL)
 return;
 			rb-xfer-send.spd = rb-spd;
@@ -1543,7 +1542,7 @@ fw_phy_config(struct firewire_comm *fc, 
 
 	fc-status = FWBUSPHYCONF;
 
-	xfer = fw_xfer_alloc(M_FWXFER);
+	xfer = fw_xfer_alloc(M_FW);
 	if (xfer == NULL)
 		return;
 	xfer-fc = fc;
@@ -2250,7 +2249,7 @@ fw_try_bmr(void *arg)
 	struct fw_pkt *fp;
 	int err = 0;
 
-	xfer = fw_xfer_alloc_buf(M_FWXFER, 8, 4);
+	xfer = fw_xfer_alloc_buf(M_FW, 8, 4);
 	if (xfer == NULL)
 		return;
 	xfer-send.spd = 0;

Index: src/sys/dev/ieee1394/firewirereg.h
diff -u src/sys/dev/ieee1394/firewirereg.h:1.16 src/sys/dev/ieee1394/firewirereg.h:1.17
--- src/sys/dev/ieee1394/firewirereg.h:1.16	Sun Apr 24 18:52:26 2011
+++ src/sys/dev/ieee1394/firewirereg.h	Sun Apr 29 18:31:40 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: firewirereg.h,v 1.16 2011/04/24 18:52:26 rmind Exp $	*/
+/*	$NetBSD: firewirereg.h,v 1.17 2012/04/29 18:31:40 dsl Exp $	*/
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -323,6 +323,5 @@ extern int firewire_phydma_enable;
 #include sys/mallocvar.h
 
 MALLOC_DECLARE(M_FW);
-MALLOC_DECLARE(M_FWXFER);
 
 #endif	/* _FIREWIREREG_H_ */
Index: src/sys/dev/ieee1394/fwmem.c
diff -u src/sys/dev/ieee1394/fwmem.c:1.16 src/sys/dev/ieee1394/fwmem.c:1.17
--- src/sys/dev/ieee1394/fwmem.c:1.16	Sun Jul 31 13:51:53 2011
+++ src/sys/dev/ieee1394/fwmem.c	Sun Apr 29 18:31:40 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fwmem.c,v 1.16 2011/07/31 13:51:53 uebayasi Exp $	*/
+/*	$NetBSD: fwmem.c,v 1.17 2012/04/29 18:31:40 dsl Exp $	*/
 /*-
  * Copyright (c) 2002-2003
  * 	Hidetoshi Shimokawa. All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fwmem.c,v 1.16 2011/07/31 13:51:53 uebayasi Exp $);
+__KERNEL_RCSID(0, $NetBSD: fwmem.c,v 1.17 2012/04/29 18:31:40 dsl Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -155,8 +155,6 @@ sysctl_fwmem_verify_speed(SYSCTLFN_ARGS)
 	return sysctl_fwmem_verify(SYSCTLFN_CALL(rnode), 0, FWSPD_S400);
 }
 
-MALLOC_DEFINE(M_FWMEM, fwmem, fwmem/IEEE1394);
-
 #define MAXLEN (512  fwmem_speed)
 
 struct fwmem_softc {
@@ -187,7 +185,7 @@ fwmem_open(dev_t dev, int flags, int fmt
 	} else {
 		sc-si_drv1 = (void *)-1;
 		sc-si_drv1 = malloc(sizeof(struct fwmem_softc),
-		M_FWMEM, M_WAITOK);
+		M_FW, M_WAITOK);
 		if (sc-si_drv1 == NULL)
 			return ENOMEM;
 		fms = (struct fwmem_softc *)sc-si_drv1;
@@ -195,7 +193,7 @@ fwmem_open(dev_t dev, int flags, int fmt
 		fms-sc = sc;
 		fms-refcount = 1;
 		STAILQ_INIT(fms-xferlist);
-		xfer = fw_xfer_alloc(M_FWMEM);
+		xfer = fw_xfer_alloc(M_FW);
 		STAILQ_INSERT_TAIL(fms-xferlist, xfer, link);
 	}
 	if (fwmem_debug)
@@ -457,7 +455,7 @@ fwmem_xfer_req(struct fw_device *fwdev, 
 {
 	struct fw_xfer *xfer;
 
-	xfer = fw_xfer_alloc(M_FWMEM);
+	xfer = fw_xfer_alloc(M_FW);
 	if (xfer == NULL)
 		return NULL;
 

Index: src/sys/dev/ieee1394/fwdev.c
diff -u src/sys/dev/ieee1394/fwdev.c:1.26 

CVS commit: src/sys

2012-04-29 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Apr 29 20:27:32 UTC 2012

Modified Files:
src/sys/dev: firmload.c
src/sys/dev/ieee1394: sbp.c
src/sys/fs/efs: efs_ihash.c
src/sys/kern: kern_malloc.c
src/sys/netsmb: smb_conn.c smb_dev.c smb_iod.c
src/sys/rump/librump/rumpkern: memalloc.c
src/sys/sys: malloc.h mallocvar.h

Log Message:
Remove everything to do with 'struct malloc_type' and the malloc link_set.
To make code in 'external' (etc) still compile, MALLOC_DECLARE() still
  has to generate something of type 'struct malloc_type *', with
  normal optimisation gcc generates a compile-time 0.
MALLOC_DEFINE() and friends have no effect.
Fix one or two places where the code would no longer compile.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/firmload.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/ieee1394/sbp.c
cvs rdiff -u -r1.8 -r1.9 src/sys/fs/efs/efs_ihash.c
cvs rdiff -u -r1.140 -r1.141 src/sys/kern/kern_malloc.c
cvs rdiff -u -r1.28 -r1.29 src/sys/netsmb/smb_conn.c
cvs rdiff -u -r1.39 -r1.40 src/sys/netsmb/smb_dev.c src/sys/netsmb/smb_iod.c
cvs rdiff -u -r1.14 -r1.15 src/sys/rump/librump/rumpkern/memalloc.c
cvs rdiff -u -r1.112 -r1.113 src/sys/sys/malloc.h
cvs rdiff -u -r1.11 -r1.12 src/sys/sys/mallocvar.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/dev/firmload.c
diff -u src/sys/dev/firmload.c:1.16 src/sys/dev/firmload.c:1.17
--- src/sys/dev/firmload.c:1.16	Wed Nov 24 16:31:12 2010
+++ src/sys/dev/firmload.c	Sun Apr 29 20:27:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: firmload.c,v 1.16 2010/11/24 16:31:12 dholland Exp $	*/
+/*	$NetBSD: firmload.c,v 1.17 2012/04/29 20:27:31 dsl Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: firmload.c,v 1.16 2010/11/24 16:31:12 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: firmload.c,v 1.17 2012/04/29 20:27:31 dsl Exp $);
 
 /*
  * The firmload API provides an interface for device drivers to access
@@ -50,7 +50,7 @@ __KERNEL_RCSID(0, $NetBSD: firmload.c,v
 
 #include dev/firmload.h
 
-static MALLOC_DEFINE(M_DEVFIRM, devfirm, device firmware buffers);
+MALLOC_DEFINE(M_DEVFIRM, devfirm, device firmware buffers);
 
 struct firmware_handle {
 	struct vnode	*fh_vp;

Index: src/sys/dev/ieee1394/sbp.c
diff -u src/sys/dev/ieee1394/sbp.c:1.33 src/sys/dev/ieee1394/sbp.c:1.34
--- src/sys/dev/ieee1394/sbp.c:1.33	Sat Aug 14 10:39:33 2010
+++ src/sys/dev/ieee1394/sbp.c	Sun Apr 29 20:27:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbp.c,v 1.33 2010/08/14 10:39:33 cegger Exp $	*/
+/*	$NetBSD: sbp.c,v 1.34 2012/04/29 20:27:31 dsl Exp $	*/
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: sbp.c,v 1.33 2010/08/14 10:39:33 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: sbp.c,v 1.34 2012/04/29 20:27:31 dsl Exp $);
 
 
 #include sys/param.h
@@ -344,6 +344,7 @@ struct sbp_softc {
 };
 
 MALLOC_DEFINE(M_SBP, sbp, SBP-II/IEEE1394);
+MALLOC_DECLARE(M_SBP);
 
 
 static int sbpmatch(device_t, cfdata_t, void *);

Index: src/sys/fs/efs/efs_ihash.c
diff -u src/sys/fs/efs/efs_ihash.c:1.8 src/sys/fs/efs/efs_ihash.c:1.9
--- src/sys/fs/efs/efs_ihash.c:1.8	Fri Jan 27 19:48:40 2012
+++ src/sys/fs/efs/efs_ihash.c	Sun Apr 29 20:27:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: efs_ihash.c,v 1.8 2012/01/27 19:48:40 para Exp $	*/
+/*	$NetBSD: efs_ihash.c,v 1.9 2012/04/29 20:27:31 dsl Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: efs_ihash.c,v 1.8 2012/01/27 19:48:40 para Exp $);
+__KERNEL_RCSID(0, $NetBSD: efs_ihash.c,v 1.9 2012/04/29 20:27:31 dsl Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -70,8 +70,6 @@ static u_long	ihash;		/* size of hash ta
 static kmutex_t	efs_ihash_lock;
 static kmutex_t	efs_hashlock;
 
-MALLOC_DECLARE(M_EFSINO);
-
 /*
  * Initialize inode hash table.
  */

Index: src/sys/kern/kern_malloc.c
diff -u src/sys/kern/kern_malloc.c:1.140 src/sys/kern/kern_malloc.c:1.141
--- src/sys/kern/kern_malloc.c:1.140	Sun Apr 29 16:36:53 2012
+++ src/sys/kern/kern_malloc.c	Sun Apr 29 20:27:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_malloc.c,v 1.140 2012/04/29 16:36:53 dsl Exp $	*/
+/*	$NetBSD: kern_malloc.c,v 1.141 2012/04/29 20:27:31 dsl Exp $	*/
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_malloc.c,v 1.140 2012/04/29 16:36:53 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_malloc.c,v 1.141 2012/04/29 20:27:31 dsl Exp $);
 
 #include sys/param.h
 #include sys/malloc.h
@@ -205,28 +205,10 @@ kern_realloc(void *curaddr, unsigned lon
 	return newaddr;
 }
 
-void
-malloc_type_attach(struct malloc_type *type)
-{
-	KASSERT(type-ks_magic 

CVS commit: src/sys/dev/isa

2012-04-29 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Apr 29 21:13:56 UTC 2012

Modified Files:
src/sys/dev/isa: isadmavar.h

Log Message:
Patch out the 'struct malloc_type' from the isa_dma alloc routines.
All the i386 kernels now build


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/isa/isadmavar.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/dev/isa/isadmavar.h
diff -u src/sys/dev/isa/isadmavar.h:1.25 src/sys/dev/isa/isadmavar.h:1.26
--- src/sys/dev/isa/isadmavar.h:1.25	Tue Aug 18 16:52:42 2009
+++ src/sys/dev/isa/isadmavar.h	Sun Apr 29 21:13:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: isadmavar.h,v 1.25 2009/08/18 16:52:42 dyoung Exp $	*/
+/*	$NetBSD: isadmavar.h,v 1.26 2012/04/29 21:13:56 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -92,7 +92,6 @@ struct isa_mem {
 
 #ifdef _KERNEL
 struct proc;
-struct malloc_type;
 
 void	   _isa_dmainit(struct isa_dma_state *, bus_space_tag_t,
 	   bus_dma_tag_t, device_t);
@@ -132,6 +131,10 @@ int	   _isa_drq_alloc(struct isa_dma_sta
 int	   _isa_drq_free(struct isa_dma_state *, int);
 int	   _isa_drq_isfree(struct isa_dma_state *, int);
 
+#define _isa_malloc(dma_state, c, s, p, f) \
+_isa_malloc(dma_state, c, s, f)
+#define _isa_free(v, p) _isa_free(v)
+
 void  *_isa_malloc(struct isa_dma_state *, int, size_t,
 		struct malloc_type *, int);
 void	   _isa_free(void *, struct malloc_type *);



CVS commit: src/sys

2012-04-29 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Apr 29 16:36:54 UTC 2012

Modified Files:
src/sys/kern: kern_malloc.c uipc_mbuf.c
src/sys/rump/librump/rumpkern: memalloc.c
src/sys/sys: malloc.h mbuf.h param.h

Log Message:
Remove the unused 'struct malloc_type' args to kern_malloc/realloc/free
The M_xxx arg is left on the calls to malloc() and free(),
  maybe they could be converted to an enumeration and just saved in
  the malloc header (for deep diag use).
Remove the malloc_type from mbuf extension.
Fixes rump build as well.
Welcome to 6.99.6


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/sys/kern/kern_malloc.c
cvs rdiff -u -r1.145 -r1.146 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.13 -r1.14 src/sys/rump/librump/rumpkern/memalloc.c
cvs rdiff -u -r1.111 -r1.112 src/sys/sys/malloc.h
cvs rdiff -u -r1.148 -r1.149 src/sys/sys/mbuf.h
cvs rdiff -u -r1.413 -r1.414 src/sys/sys/param.h

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



CVS commit: src/sys/dev/ieee1394

2012-04-29 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Apr 29 18:31:41 UTC 2012

Modified Files:
src/sys/dev/ieee1394: firewire.c firewirereg.h fwdev.c fwmem.c
fwohcivar.h if_fwip.c

Log Message:
Change to consistently use M_FW for all malloc/free.
It probably doesn't matter any more, but the code doesn't appear to
have matched its mallocs and frees - so the stats would have been awol.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/ieee1394/firewire.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ieee1394/firewirereg.h \
src/sys/dev/ieee1394/fwmem.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/ieee1394/fwdev.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/ieee1394/fwohcivar.h
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/ieee1394/if_fwip.c

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



CVS commit: src/sys

2012-04-29 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Apr 29 20:27:32 UTC 2012

Modified Files:
src/sys/dev: firmload.c
src/sys/dev/ieee1394: sbp.c
src/sys/fs/efs: efs_ihash.c
src/sys/kern: kern_malloc.c
src/sys/netsmb: smb_conn.c smb_dev.c smb_iod.c
src/sys/rump/librump/rumpkern: memalloc.c
src/sys/sys: malloc.h mallocvar.h

Log Message:
Remove everything to do with 'struct malloc_type' and the malloc link_set.
To make code in 'external' (etc) still compile, MALLOC_DECLARE() still
  has to generate something of type 'struct malloc_type *', with
  normal optimisation gcc generates a compile-time 0.
MALLOC_DEFINE() and friends have no effect.
Fix one or two places where the code would no longer compile.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/firmload.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/ieee1394/sbp.c
cvs rdiff -u -r1.8 -r1.9 src/sys/fs/efs/efs_ihash.c
cvs rdiff -u -r1.140 -r1.141 src/sys/kern/kern_malloc.c
cvs rdiff -u -r1.28 -r1.29 src/sys/netsmb/smb_conn.c
cvs rdiff -u -r1.39 -r1.40 src/sys/netsmb/smb_dev.c src/sys/netsmb/smb_iod.c
cvs rdiff -u -r1.14 -r1.15 src/sys/rump/librump/rumpkern/memalloc.c
cvs rdiff -u -r1.112 -r1.113 src/sys/sys/malloc.h
cvs rdiff -u -r1.11 -r1.12 src/sys/sys/mallocvar.h

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



CVS commit: src/sys/dev/isa

2012-04-29 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Apr 29 21:13:56 UTC 2012

Modified Files:
src/sys/dev/isa: isadmavar.h

Log Message:
Patch out the 'struct malloc_type' from the isa_dma alloc routines.
All the i386 kernels now build


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/isa/isadmavar.h

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



Re: CVS commit: src/lib/libc/arch/alpha/gen

2012-03-22 Thread David Laight
On Wed, Mar 21, 2012 at 11:57:25PM +0100, Nicolas Joly wrote:
 On Wed, Mar 21, 2012 at 10:42:58PM +0200, Alan Barrett wrote:
  On Wed, 21 Mar 2012, Havard Eidnes wrote:
  Modified Files:
 src/lib/libc/arch/alpha/gen: fpgetround.c fpsetround.c
  
  Log Message:
  Add some casts to get rid of bitwise op on signed value is non-portable
  warning from lint.
  
  I see no bitwise ops on signed values here.
  
  -  return ((fpcrval.u64  58)  0x3);
  +  return ((fp_rnd)(fpcrval.u64  58)  0x3);
  
  fpcrval.u64 is uint64_t.  After the integer promotions,
  it's still uint64_t (unless that's smaller than int, which is not 
  the case for any existing NetBSD port).  After 58, it's still 
  uint64_t.  0x3 is a signed int, but the usual arithmetic conversions
  should convert it to uint64_t.
 
 The commit message reference the wrong lint warning.
 
 /local/src/NetBSD/src/lib/libc/arch/alpha/gen/fpgetround.c(61): warning: 
 conversion from 'unsigned long' to 'enum unnamed' may lose accuracy [132]
 /local/src/NetBSD/src/lib/libc/arch/alpha/gen/fpsetround.c(61): warning: 
 conversion from 'unsigned long' to 'enum unnamed' may lose accuracy [132]

Which is bogus because of the ' 3' which brings the value inside valid
range.

The cast is really in the wrong place as well.

I am 100% against adding casts of numeric values to appease a tool that
isn't tracking the domains of the expressions.

David

-- 
David Laight: da...@l8s.co.uk


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

2012-03-21 Thread David Laight
On Wed, Mar 21, 2012 at 10:28:32AM -0400, Christos Zoulas wrote:
 Module Name:  src
 Committed By: christos
 Date: Wed Mar 21 14:28:32 UTC 2012
 
 Modified Files:
   src/lib/libc/gen: setmode.c
 
 Log Message:
 fix argument order.

Matt should have used my sed script ...


David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/lib/libc

2012-03-13 Thread David Laight
On Tue, Mar 13, 2012 at 10:27:08PM +0100, Joerg Sonnenberger wrote:
 On Tue, Mar 13, 2012 at 05:13:51PM -0400, Christos Zoulas wrote:
  Log Message:
  PR/45989: Martin Husemann: lint invocation does include -w only on i386
  
  - turn lint -w for all the platforms after fixing the lint warnings.
  - add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
  - change types, add casts
  - change into ansii prototypes
  - turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)
 
 Thanks for ignoring my comments. It's especially useful that you
 haven't really addressed any of the points. Checking casts from size_t
 to uint32_t is useless on a good number of our architectures. Other
 places have proper checks already in place, so this just adds bloat.
 
 Joerg

I also suspect it seriously reduces readability.
I'm very much against any casts between integral types,
I've been caught out too many times (at least once!) because casts
can also do pointer conversions.

The same goes for casts to change the integral type on function calls.
Since we require ANSI C prototypes to be in place they are worthless,
for KR C they were needed to get the correct values passed.
But that is no longer true.

I'd also vote for any code that looks at the return value
of printf() being flagged - rather than require a (void) cast of
the result. (You need to use ferror() probably after fflush() to
detect errors, especially just before calling fclose(), anything
else is mostly pointless.)

David

-- 
David Laight: da...@l8s.co.uk


CVS commit: src/usr.sbin/installboot

2012-03-10 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Mar 10 18:42:19 UTC 2012

Modified Files:
src/usr.sbin/installboot: installboot.8
src/usr.sbin/installboot/arch: i386.c

Log Message:
Some FAT16 filesystems don't have 'hidden sectors' correctly set to
the offset of the filesystem on the disk.
Let '-b s1blk' be used to fix the value.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/usr.sbin/installboot/installboot.8
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/installboot/arch/i386.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.sbin/installboot/installboot.8
diff -u src/usr.sbin/installboot/installboot.8:1.84 src/usr.sbin/installboot/installboot.8:1.85
--- src/usr.sbin/installboot/installboot.8:1.84	Sat Feb 11 07:27:25 2012
+++ src/usr.sbin/installboot/installboot.8	Sat Mar 10 18:42:18 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: installboot.8,v 1.84 2012/02/11 07:27:25 ast Exp $
+.\	$NetBSD: installboot.8,v 1.85 2012/03/10 18:42:18 dsl Exp $
 .\
 .\ Copyright (c) 2002-2012 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 February 11, 2012
+.Dd March 10, 2012
 .Dt INSTALLBOOT 8
 .Os
 .Sh NAME
@@ -165,6 +165,7 @@ at block number
 .Ar s1bno
 instead of the default location for the machine and file system type.
 .Sy [ alpha ,
+.Sy i386/amd64 (bootxx_fat16 only) ,
 .Sy pmax ,
 .Sy vax ]
 .
@@ -453,6 +454,12 @@ any
 It also uses the information in the
 .Ql Boot Parameter Block
 to get the media and filesytem properties.
+The
+.Ql hidden sectors
+field of the BPB must the offset of the partition in the disk.
+This can be set using the
+.Fl b Ar s1bno
+option.
 .
 .It Pa /usr/mdec/bootxx_ffsv1
 Primary bootstrap for

Index: src/usr.sbin/installboot/arch/i386.c
diff -u src/usr.sbin/installboot/arch/i386.c:1.37 src/usr.sbin/installboot/arch/i386.c:1.38
--- src/usr.sbin/installboot/arch/i386.c:1.37	Sun Aug 14 17:50:17 2011
+++ src/usr.sbin/installboot/arch/i386.c	Sat Mar 10 18:42:18 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: i386.c,v 1.37 2011/08/14 17:50:17 christos Exp $ */
+/* $NetBSD: i386.c,v 1.38 2012/03/10 18:42:18 dsl Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 #if !defined(__lint)
-__RCSID($NetBSD: i386.c,v 1.37 2011/08/14 17:50:17 christos Exp $);
+__RCSID($NetBSD: i386.c,v 1.38 2012/03/10 18:42:18 dsl Exp $);
 #endif /* !__lint */
 
 #include sys/param.h
@@ -79,13 +79,15 @@ struct ib_mach ib_mach_i386 =
 	{ i386, i386_setboot, no_clearboot, i386_editboot,
 		IB_RESETVIDEO | IB_CONSOLE | IB_CONSPEED | IB_CONSADDR |
 		IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT |
-		IB_MODULES | IB_BOOTCONF };
+		IB_MODULES | IB_BOOTCONF |
+		IB_STAGE1START };
 
 struct ib_mach ib_mach_amd64 =
 	{ amd64, i386_setboot, no_clearboot, i386_editboot,
 		IB_RESETVIDEO | IB_CONSOLE | IB_CONSPEED | IB_CONSADDR |
 		IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT |
-		IB_MODULES | IB_BOOTCONF };
+		IB_MODULES | IB_BOOTCONF |
+		IB_STAGE1START };
 
 /*
  * Attempting to write the 'labelsector' (or a sector near it - within 8k?)
@@ -440,6 +442,9 @@ i386_setboot(ib_params *params)
 /* Old BPB is shorter, leave zero filled */
 u = disk_buf.b[1];
 			}
+			if (params-s1start != 0)
+/* Fixup physical offset of filesytem */
+bpb-bpbHiddenSecs = htole32(params-s1start);
 			memcpy(bootstrap.b + 2, disk_buf.b + 2, u);
 		}
 		#undef USE_F



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

2012-03-10 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Mar 10 23:59:36 UTC 2012

Modified Files:
src/sys/arch/i386/stand/fatboot: Makefile fatboot.S
Added Files:
src/sys/arch/i386/stand/fatboot/fat12: Makefile

Log Message:
Add support for directly booting from FAT12 filesystems.
This shouldn't really be needed except that Linux wont
mount a small FAT16 filesystem - it always treats it as FAT12
even when you tell it otherwise.
There was enough free space before the main FS on the USB stick
I've been using for an extra small FAT fs to boot from.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/fatboot/Makefile
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/fatboot/fatboot.S
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/fatboot/fat12/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/arch/i386/stand/fatboot/Makefile
diff -u src/sys/arch/i386/stand/fatboot/Makefile:1.2 src/sys/arch/i386/stand/fatboot/Makefile:1.3
--- src/sys/arch/i386/stand/fatboot/Makefile:1.2	Sat Jan  6 20:47:15 2007
+++ src/sys/arch/i386/stand/fatboot/Makefile	Sat Mar 10 23:59:36 2012
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.2 2007/01/06 20:47:15 dsl Exp $
+# $NetBSD: Makefile,v 1.3 2012/03/10 23:59:36 dsl Exp $
 
-SUBDIR=	fat16
+SUBDIR=		fat16
+SUBDIR+=	fat12
 
 .include bsd.subdir.mk
 .include bsd.obj.mk

Index: src/sys/arch/i386/stand/fatboot/fatboot.S
diff -u src/sys/arch/i386/stand/fatboot/fatboot.S:1.3 src/sys/arch/i386/stand/fatboot/fatboot.S:1.4
--- src/sys/arch/i386/stand/fatboot/fatboot.S:1.3	Tue Apr 29 06:53:02 2008
+++ src/sys/arch/i386/stand/fatboot/fatboot.S	Sat Mar 10 23:59:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fatboot.S,v 1.3 2008/04/29 06:53:02 martin Exp $	*/
+/*	$NetBSD: fatboot.S,v 1.4 2012/03/10 23:59:36 dsl Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -50,10 +50,12 @@
 #endif
 
 /* Support for FAT32 could be added - but hasn't been yet. */
-#if FAT_ENTRY_SIZE != 16
+#if FAT_ENTRY_SIZE != 16  FAT_ENTRY_SIZE != 12
 #error Unsupported FAT_ENTRY_SIZE value
 #endif
 
+#define FAT_SIZE_STR (('0'+ FAT_ENTRY_SIZE / 10) | ('0' + FAT_ENTRY_SIZE % 10)  8)
+
 #define PBR_AFTERBPB	62		/* BPB size in floppy master BR */
 
 #ifdef TERSE_ERROR
@@ -112,8 +114,13 @@ start0:
 	mov	%sp, %bp		/* to access the pbp */
 	push	%dx			/* save drive at -2(%bp) */
 
+/* We put the LBA bios command block on stack.
+ * Since we only want a 32bit sector number, stack a zero */
+	push	%cs			/* %cs is zero */
+	push	%cs			/* 64-bit for LBA read */
+
 	set_err(ERR_NOT_FAT16)
-	cmpl	$'A'|'T'8|'1'16|'6'24, bs_file_sys_type+1(%bp)
+	cmpl	$'A'|'T'8|FAT_SIZE_STR16, bs_file_sys_type+1(%bp)
 	jne	error
 
 /* Add 'reserved' (inside ptn) to 'hidden' (ptn offset) */
@@ -121,14 +128,21 @@ start0:
 	addl	bpb_hidden_secs(%bp), %eax
 	mov	%eax, fat_sector(%bp)	/* To get first sector of FAT */
 
+#if FAT_ENTRY_SIZE == 12
+/* Read the entire FAT */
+	push	%eax
+	push	%ds
+	push	$fat_buffer
+	push	$12			/* 12 sectors is assumed 6k */
+	call	read_lba
+#endif
+
 /* Determine base of root directory */
 	movzbw	bpb_FATs(%bp), %ax	/* Count of FATs */
 	mulw	bpb_FAT_secs(%bp)	/* FAT size in %dx:%ax */
 	shl	$16,%edx
 	xchg	%ax,%dx			/* FAT size now in %edx */
 	addl	fat_sector(%bp), %edx	/* Directory is after FATs */
-	push	%cs			/* %cs is zero */
-	push	%cs			/* 64-bit for LBA read */
 	pushl	%edx			/* Sector number of root dir */
 
 	push	$0x1000			/* Read to 0x1:0 */
@@ -149,7 +163,7 @@ start0:
 /* Read in the entire root directory */
 	push	%ax			/* Sectors in root directory */
 	cwtl
-	addl	%eax, %edx		/* %edx now sector of first file */
+	addl	%eax, %edx		/* %edx now sector of first cluster */
 	call	read_lba		/* Read entire directory */
 
 /* Scan directory for our file */
@@ -195,16 +209,16 @@ found_boot:
 	jnz	1b
 	dec %cx
 	dec %cx
-	movw	%es:15(%di), %ax	/* Cluster number for file start */
+	movw	%es:(26-11)(%di), %ax	/* Cluster number for file start */
 	push	%es			/* We increment the 'segment' ... */
 	pop	%di			/* ... after each read, offset is 0 */
 
 read_data_block:
 	mov	%ax, %bx		/* Save cluster number */
 	shl	%cl, %eax		/* Convert to sector number */
-	add	%eax, %edx
-	pushl	%edx			/* Sector to read */
-	sub	%eax, %edx		/* Recover base segment */
+	jz	error			/* Sanity bail-out */
+	add	%edx, %eax
+	pushl	%eax			/* Sector to read */
 	push	%di			/* Target address segment! */
 	push	$0
 	push	sec_p_cl_w(%bp)
@@ -218,6 +232,20 @@ read_data_block:
 
 /* Lookup FAT slot number in FAT table */
 	mov	%bx, %ax		/* Recover cluster number */
+#if FAT_ENTRY_SIZE == 12
+	shr	$1, %ax
+	jc	1f
+	add	%ax, %bx
+	mov	fat_buffer(%bx), %ax
+	and	$0xf,%ah
+	jmp	2f
+1:	add	%ax, %bx
+	mov	fat_buffer(%bx), %ax
+	shr	$4, %ax
+2:
+	cmp	$0x0fff, %ax
+	jb	read_data_block
+#else
 	push	%dx
 	xor	%dx, %dx
 	divw	bpb_bytes_per_sec(%bp)
@@ -243,6 +271,7 @@ lookup_fat:
 	movzwl	fat_buffer(%bx), 

CVS commit: src/usr.sbin/installboot

2012-03-10 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Mar 10 18:42:19 UTC 2012

Modified Files:
src/usr.sbin/installboot: installboot.8
src/usr.sbin/installboot/arch: i386.c

Log Message:
Some FAT16 filesystems don't have 'hidden sectors' correctly set to
the offset of the filesystem on the disk.
Let '-b s1blk' be used to fix the value.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/usr.sbin/installboot/installboot.8
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/installboot/arch/i386.c

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



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

2012-03-10 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Mar 10 23:59:36 UTC 2012

Modified Files:
src/sys/arch/i386/stand/fatboot: Makefile fatboot.S
Added Files:
src/sys/arch/i386/stand/fatboot/fat12: Makefile

Log Message:
Add support for directly booting from FAT12 filesystems.
This shouldn't really be needed except that Linux wont
mount a small FAT16 filesystem - it always treats it as FAT12
even when you tell it otherwise.
There was enough free space before the main FS on the USB stick
I've been using for an extra small FAT fs to boot from.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/fatboot/Makefile
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/fatboot/fatboot.S
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/fatboot/fat12/Makefile

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



Re: CVS commit: src/lib/libc

2012-03-04 Thread David Laight
On Sun, Mar 04, 2012 at 01:06:03PM -0700, Warner Losh wrote:
 
 On Mar 3, 2012, at 5:55 PM, David Holland wrote:
 
  On Thu, Mar 01, 2012 at 11:14:16AM -0700, Warner Losh wrote:
  Maybe somebody can look at a full pkgsrc build to see how many
  instances of gets are in it?
  
  Given the way bulk builds work, and various logistical reasons that is
  unlikely to change, the only practical way to check this is to remove
  gets locally before doing a build.
  
  Perhaps I'll do this. Any such program is broken and needs to be
  patched. Your example is unpersuasive.
 
 So there's no way to troll through the build binaries for references
 to gets, at least in the dynamically linked binaries?  That's unfortunate.
 
 My example was a place where it was completely safe to use.
 I offered only to counter those that said it is never safe,
 which is factually untrue.
 
 But given the extreme ease with which it is unsafe to use,
 I'm with the 'get it out' crowd, but only if it doesn't provoke
 wide-spread chaos.
 without data, it is hard to say for sure the level of chaos.

Running 'objdump -D' and grepping for '\gets\' will probably find them.

I wonder it it would be worth adding a function that is like gets,
but takes a buffer length (ie discards the \n - and maybe the rest of the
line).

That could be used as a compile-time substitute when the buffer
size is known - ie when 'sizeof buffer != sizeof (char *)'

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/lib/libc

2012-03-04 Thread David Laight
On Sun, Mar 04, 2012 at 10:38:19PM +0200, Alan Barrett wrote:
 On Sun, 04 Mar 2012, David Laight wrote:
 I wonder it it would be worth adding a function that is like 
 gets, but takes a buffer length (ie discards the \n - and maybe 
 the rest of the line).
 
 C2011 has char *gets_s(char *s, rsize_t n);
 
 It discards the \n, but does not discard the rest of the line, so 
 you can't tell the difference between a line that was exactly the 
 maximum length (followed by a \n which is discarded) or a line 
 that was too long.  fgets() can tell the difference, however.

Not checking that allowed users to get root privs.
IIRC it was very long fields in the password file causing
an entry to be split.
(fixed long long ago)
So that '_s' form isn't 'secure' (or whatever _s is supposed to mean).

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/lib/libc

2012-03-04 Thread David Laight
On Sun, Mar 04, 2012 at 09:42:21PM +0100, Joerg Sonnenberger wrote:
 On Sun, Mar 04, 2012 at 08:20:20PM +, David Laight wrote:
  I wonder it it would be worth adding a function that is like gets,
  but takes a buffer length (ie discards the \n - and maybe the rest of the
  line).
  
  That could be used as a compile-time substitute when the buffer
  size is known - ie when 'sizeof buffer != sizeof (char *)'
 
 I don't think that makes too much sense. If you want to read a full
 line, use getline. If you don't, loop with fgets until the full line is
 read.

I was thinging of a header file fix to allow code to compile
without changing the source and with miminal 'security' issues.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/arch/sparc64/sparc64

2012-03-03 Thread David Laight
On Sat, Mar 03, 2012 at 03:17:32AM +, Takeshi Nakayama wrote:
 Module Name:  src
 Committed By: nakayama
 Date: Sat Mar  3 03:17:32 UTC 2012
 
 Modified Files:
   src/sys/arch/sparc64/sparc64: locore.s
 
 Log Message:
 Fix the root cause of the hack disable optimizations for uvm_bio.c
 on 32 bit kernels.
 
 gcc converts a division in the calculation of UBC_UMAP_ADDR macro
 to multiplication (smul or combination of add/sll), and the
 register of its result contains a garbage in upper 32 bits (the
 upper 32 bits of smul/add/sll's result isn't zero cleared).
 
 Then it passes to pseg_get{,_real} through pmap_extract without the
 zero clear of upper 32 bits in the optimization case.  So the
 result of pseg_get and pmap_extact sometimes gets screwed up.

Is that a gcc bug?

Or are the high register bits usually undefined for 32bit values,
and this to do with using 64bit asm in a 32bit kernel?

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/lib/libc

2012-03-01 Thread David Laight
On Thu, Mar 01, 2012 at 05:07:32PM +0100, Joerg Sonnenberger wrote:
 
 My strong dislike of *_s from C11 is not relevant. Those functions are
 not part of the core standard, but an (optional) annex.

gets() is pretty bad for anything that is system or suid.
For a normal user app it doesn't matter that much.
Invalid input genetates a core dump and/or corrupted user data.
For a test program it doesn't really matter that much.

Of course, you could have a libc.so in another directory that
contains things like gets() and other deprecated stuff and a
.NEEDED entry for the real libc - and use that to compile/run
old binaries.
Oh - except they've broken that feature of the linker.

My objection to the *_s() forms is that they are not really
inherently more 'secure' than the older functions.
They just include some of the checks the coder should have done.
So are just variants of the old function not 'secure' versions.

Microsoft's exception-throwing functions are even worse!
(Mind you Microsoft's _snprintf() is particulary borked.)

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/usr.bin/tip

2012-02-24 Thread David Laight
On Fri, Feb 24, 2012 at 09:27:09AM +0100, Joerg Sonnenberger wrote:
 On Fri, Feb 24, 2012 at 08:11:19AM +, David Laight wrote:
  On Thu, Feb 23, 2012 at 11:39:19PM +, Joerg Sonnenberger wrote:
   Module Name:  src
   Committed By: joerg
   Date: Thu Feb 23 23:39:19 UTC 2012
   
   Modified Files:
 src/usr.bin/tip: cmds.c
   
   Log Message:
   while (...);
   ;
   is really pointless, so remove the first semicolon.
  
  I tend to use an explicit 'continue' in such loops.
  Much less confusing.
 
 I generally agree, but putting the semicolon on a separate line is good
 enough for the purpose.

At least netbsd puts { and } on the same line as the keyword,
otherwise you can get things like:

...
}
while ();
{
int foo;
...

where a cursory glance gives no real indication of what the
programmer intended (especially if the 'while' line is very long!)

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/kern

2012-01-31 Thread David Laight
On Tue, Jan 31, 2012 at 07:50:26PM +, Alexander Nasonov wrote:
 Joerg Sonnenberger wrote:
  On Tue, Jan 31, 2012 at 07:32:52PM +, Alexander Nasonov wrote:
   #define sizeof_fam(s, m, n) (sizeof(s) + sizeof(((s *)NULL)-m[0]) * (n))
  
  That's still not necessarily optimal, depending on the padding rules of
  the platform. You want to do offsetof(s, m[0]) + n * sizeof((s*)NULL-m[0]).
 
 I'm aware of this but I was merely following examples from the standard.
 
 More specifically I was following DR 282 (flexible array members 
 struct padding) which was incorporated into TC2.
 
 http://std.dkuug.dk/jtc1/sc22/wg14/www/docs/dr_282.htm
 
 I can add a comment about padding to sizeof_fam. If there is no padding,
 my and your expression should return same values.

And if there is padding, and it is after the last field (and a few
other clauses) your scheme will allocate a longer buffer than needed.

The advantage of Joerg's is that you don't have to 'know' the type of
the member.

Sudden barin explosion - how about (untested):
#define sizeof_var_struct(s, m, c) \
offsetof(s, m[0]) + (c) * (offsetof(s, m[1]) -  offsetof(s, m[0]))

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/kern

2012-01-31 Thread David Laight
On Tue, Jan 31, 2012 at 09:51:17PM +, Alexander Nasonov wrote:
 Joerg Sonnenberger wrote:
  That's still not necessarily optimal, depending on the padding rules of
  the platform. You want to do offsetof(s, m[0]) + n * sizeof((s*)NULL-m[0]).
 
 Using m[0] inside offsetof is non-standard but I think this will work:
 
 offsetof(s, m) + n * sizeof((s*)NULL-m[0]).

I don't believe there is a problem using m[0], just m[non-constant-expr].

OTOH 'sizeof (s *)0-m[0]' might be deemed invalid (because it has
an inferred dereference of NULL.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/kern

2012-01-22 Thread David Laight
On Sun, Jan 22, 2012 at 03:48:51AM +, Mindaugas Rasiukevicius wrote:
 Module Name:  src
 Committed By: rmind
 Date: Sun Jan 22 03:48:51 UTC 2012
 
 Modified Files:
   src/sys/kern: kern_fileassoc.c
 
 Log Message:
 fileassoc_file_delete: pre-check whether fileassoc was used and thus avoid
 acquiring kernel-lock, which damages sys_unlink() performance.

Erm... looking at the file the locking in there looks decidedly dubious.

1) There doesn't seem to be any locking on the hash table.
2) It isn't clear why the KERNEL_LOCK was acquired in one specific path.
3) If fileassoc_file_delete() is expected to remove all references for
   a vnode, something external must have forced the state of the vnode.
   (otherwise the stuff might be added - inc. global init - while this
   code is being called.

OTOH I've actually NFI what the code in this file is for!

David

-- 
David Laight: da...@l8s.co.uk


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

2012-01-21 Thread David Laight
On Fri, Jan 20, 2012 at 12:39:44PM +0100, Matthias Drochner wrote:
 
 m...@eterna.com.au said:
  alloc/free here for whatever is using a lot of memory would be much
  better than increasing the minimum each LWP requires.
 
 Agreed. In the ppbattach case, it should be sufficient
 to put the devinfo printf into a separate function, so
 that it doesn't stack up when called recursively. (One
 just needs to make sure that the compiler doesn't
 inline it again.)

Recursion in the kernel?
Isn't that really frowned upon itself?

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/dev/bluetooth

2012-01-11 Thread David Laight
On Wed, Jan 11, 2012 at 05:27:45PM +, Iain Hibbert wrote:
 Module Name:  src
 Committed By: plunky
 Date: Wed Jan 11 17:27:45 UTC 2012
 
 Modified Files:
   src/sys/dev/bluetooth: bthidev.c btkbd.c
 
 Log Message:
 offset processing of input reports to a kernel thread, to avoid
 locking issues when a child device needs to call back into the
 Bluetooth stack (eg when caps-lock is pressed, and wskbd wants
 to change a LED)

Actually, I suspect it would be better to make X (etc) always use
a separate context when reflecting indications back to the driver.

As has been pointed out changing the LED for caps-lock (and other
locks) is pressed should change the LEDs on all keyboards, and
the inter-device cross call could also cause problems.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/dev/rasops

2011-12-26 Thread David Laight
On Sat, Dec 24, 2011 at 02:13:21AM +, Michael Lorenz wrote:
 Module Name:  src
 Committed By: macallan
 Date: Sat Dec 24 02:13:21 UTC 2011
 
 Modified Files:
   src/sys/dev/rasops: rasops32.c
 
 Log Message:
 rename alpha variable to avoid conflict with a platform macro on alpha

Hmmm... I wonder if it would (have been) better to #define 'variables'
used as pre-processor predicates to themselves (ie #define alpha alpha)
to avoid these issues?

Probably a bit late to change things though!

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/dev

2011-12-02 Thread David Laight
On Thu, Dec 01, 2011 at 04:48:34PM -0500, Christos Zoulas wrote:
 On Dec 1,  5:50pm, da...@l8s.co.uk (David Laight) wrote:
 -- Subject: Re: CVS commit: src/sys/dev
 
 | I'd rather the .c file wasn't polluted with #ifdefs.
 | Probably better to #define fss_compat_ioctl(...) EINVAL somewhere.
 | 
 | We ought to sort out a way of making the compat code loadable
 | - in which case this would need to be a real function call
 | (possibly an indirect one).
 
 I like that idea. Perhaps we can just make the compat symbols weak
 and check for NULL before calling them (or magic autoload module stubs).
 That is provided the loader does the necessary magic when it loads/unloads
 the module...

I think it might be easier to call via a function pointer,
and get the module load/unload code to update the variable.
A non-modular kernel could then contain a direct function call.

The updated code would need to go via some kind of wrapper
(in the main kernel) that held a reference count on the module.
Not sure that is easy without copying the arguments.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/lib/libcrypt

2011-12-01 Thread David Laight
On Tue, Nov 29, 2011 at 09:23:20PM +0100, Joerg Sonnenberger wrote:
 On Tue, Nov 29, 2011 at 09:09:38PM +0100, Matthias Drochner wrote:
  Anyway, here is a first cut on an explicit_bzero function
  which doesn't get optimized away. I've put it to src/common
  because the same thing makes sense in the kernel too.
  Comments?
 
 Just make it an alias on memset. That's good enough. I think calling it
 something like secure_memset or safe_memset is better, but opinions
 might differ.

I'm not sure that 'secure' or 'safe' are good prefixes for any function name.
You need to say WHY is is better.

This is also true of the plethora of names for 'better' strcpy()
and sprintf() functions available on some platforms.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/dev

2011-12-01 Thread David Laight
On Wed, Nov 30, 2011 at 01:13:10PM -0500, Christos Zoulas wrote:
 On Nov 30, 12:13pm, bou...@antioche.eu.org (Manuel Bouyer) wrote:
...
 Keeps the headers tidy, and it will make it easy in the future to delete
 compatibility code. I would also move the compat code somewhere too,
 and call a function around it:
 
 default:
 #ifdef COMPAT_50
   error = fss_compat_ioctl(...);
 #else
   error = EINVAL;
 #endif
 }
 
 christos

I'd rather the .c file wasn't polluted with #ifdefs.
Probably better to #define fss_compat_ioctl(...) EINVAL somewhere.

We ought to sort out a way of making the compat code loadable
- in which case this would need to be a real function call
(possibly an indirect one).

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/dev

2011-12-01 Thread David Laight
On Thu, Dec 01, 2011 at 01:00:22PM -0600, David Young wrote:
 
 IIRC, our module loader cannot (yet) load a strong alias over a weak
 alias and restore the weak alias when the module containing the strong
 alias is unloaded.  That would have been nice to have when bpf was
 modularized.

That would be a nice trick...
I was thinking is something horrid that would make the source clean(ish).

Avoiding the function call is only necessary for very space-constrained
kernels.  Which could be done by using a #define instead of the weak alias.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/dev/ic

2011-11-03 Thread David Laight
On Wed, Nov 02, 2011 at 04:54:51PM +, Jonathan A. Kollasch wrote:
 Module Name:  src
 Committed By: jakllsch
 Date: Wed Nov  2 16:54:51 UTC 2011
 
 Modified Files:
   src/sys/dev/ic: ahcisatareg.h
 
 Log Message:
 Additionally apply __aligned(8) to all __packed hardware data structures.
 (The hardware actually requires much larger alignment on these structures
 (128 to 1024 bytes), but 8 is big enough for the compiler to generate more
 efficient code on strict alignment architectures.)

If these structures only have the odd field that needs non-native
alignments (eg 32bit on 16bit alignment or 64bit on 32bit alignment)
then it can be achieved by applying __aligned() to that single field.

That also allows the compiler to generate larger-than-byte accesses
on strict alignment systems.

See the mbr definition in (IIRC) disklabel.h and the 64bit types
in amd64's compat32 for examples.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/arch/sandpoint/stand/altboot

2011-10-31 Thread David Laight
On Sun, Oct 30, 2011 at 09:08:33PM +, Frank Wille wrote:
 Module Name:  src
 Committed By: phx
 Date: Sun Oct 30 21:08:33 UTC 2011
 
 Modified Files:
   src/sys/arch/sandpoint/stand/altboot: brdsetup.c dsk.c entry.S fxp.c
   globals.h nvt.c rge.c skg.c stg.c vge.c
 
 Log Message:
 Added in8() and out8() to access a byte with reorder-protection.
 Use it in all drivers instead of (volatile uint8_t *).

This isn't really an ideal solution, I've have to fight membar
instructions embedded into byteswapping accesses on ppc linux.
Drivers may want to do several accesses that can be reordered
before/after one that matters - so need greater control than
enforcing specific membars.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/libexec/ld.elf_so/arch/powerpc

2011-10-28 Thread David Laight
On Wed, Oct 26, 2011 at 03:56:58PM +, Chuck Silvers wrote:
 Module Name:  src
 Committed By: chs
 Date: Wed Oct 26 15:56:58 UTC 2011
 
 Modified Files:
   src/libexec/ld.elf_so/arch/powerpc: Makefile.inc
 
 Log Message:
 avoid linker warnings with the new binutils by not forcing ld.elf_so
 to be soft-float.  the floating-point usage in ld.elf_so is only
 because of stdarg functions like printf(), and gcc 4.5 is good
 about not actually executing the FP instructions in such functions
 unless FP values are passed to them, which ld.elf_so doesn't do.

I thought gcc had a habit of using FP registers for memory copy?
(Or some other integer-only action)
Or is that only a problem with specific architectures due to the
way the instruction set has been defined to gcc.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/lib/libperfuse

2011-10-23 Thread David Laight
On Sun, Oct 23, 2011 at 05:13:13PM +1100, matthew green wrote:
...
  perfuse memory usage can grow quite large when using a lot of vnodes,
  and the amount of data memory involved is not easy to forcast. We therefore
  raise the limit to the maximum.
...
 this seems like the wrong answer.  if rlimits aren't enough, then the
 *user* should be increasing them, not the system.

This again brings up the issue of the default 'rlimit' values.
The current 'hard' limits are based on some global system limits [1].
Letting a user process get near these limits is not a good idea,
and 'root' can increase it's hard limit anyway.

I'm not entirely sure there shouldn't also be a limit for the
amount of non-pageable kernel memory a process can use.

If a program sets 's 'soft' limits to the 'hard' ones there are
a lot of 'local user DoS' attacks available...

For things like open files, I'm not even sure there should be
a global kernel limit. I suspect that actually dates from times
when there was a statically allocated array of them.
Possibly open should be able to fail due to a likely lack of
kernel memory (especially for non-root), but a global count
is rather pointless. Knowing the current value, and the highest
value is probably useful.

David

[1] The 'memory' limits are based on the amount of physical memory,
the relevant system limit would actually include the amount of swap.

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/lib/libc

2011-10-16 Thread David Laight
On Sun, Oct 16, 2011 at 01:23:38AM -0400, Christos Zoulas wrote:
...
 | close on exec fixes:
 | - open + fcntl - open O_CLOEXEC
...
 Thanks, but then shouldn't we also add:
 
 #if O_CLOEXEC == 0
   (void)fcntl(sp-fts_rfd, F_SETFD, FD_CLOEXEC);
 #endif
 
 after the open?

In which case it would be cleaner to have something like:

#if define(O_CLOEXEC)  O_CLOEXEC != 0
#define open_cloexec(name, mode) open(name, (mode) | O_CLOEXEC)
#else
static inline int
open_cloexec(const char *name, unsigned int mode)
{
int fd = open(name, mode);
if (fd = 0)
fcntl(fd, F_SETFD, 0);
return fd;
}
#endif

and the use open_clowxec() in the code.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/dev/ata

2011-10-05 Thread David Laight
On Wed, Oct 05, 2011 at 06:52:37PM +0200, Wolfgang Solfrank wrote:
 ...  You would tell the controller the cylinder/head/sector
 of the first sector you wanted to read, and when multiple sectors were
 requested, the controller would increment only the sector number.
 Since the controller wouldn't even know the number of sectors on a track,
 it wouldn't be able to cross a track boundary.

I suspect some PC BIOS/floppy have that 'feature'!
IIRC there is a bug booting from floppies with less than 8k/track
due to the way bootxx_xxxfs gets loaded.

There has been some confusion about the difference between reads for
multiple sectors and the 'multi-sector' read feature.
The latter changes the interface slightly - I think it means you
only get one data/dma request burst for multiple sectors.

With LBA reads the underlying (reported) geometry shouldn't matter.
But yes, avoiding requests for 256 sectors is probably a good idea!

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/usr.bin/audio/record

2011-09-22 Thread David Laight
On Thu, Sep 22, 2011 at 09:28:56PM +0200, Marc Balmer wrote:
 
 Am 22.09.2011 um 19:34 schrieb Christos Zoulas:
 
  In article dbe1242c-f99e-4b75-b356-516245aca...@msys.ch,
  Marc Balmer  m...@msys.ch wrote:
if (outfd == STDOUT_FILENO)
return;
  
  - if (lseek(outfd, SEEK_SET, 0)  0)
  + if (lseek(outfd, (off_t)0, SEEK_SET) == (off_t)-1)
err(1, could not seek to start of file for header rewrite);
  
  Fwiw, this never caused a problem since SEEK_SET is defined 0.  But why
  is an explicit typecast to off_t needed?  Aren't integer cast
  automatically?
  
  It is belt-and-suspenders if the prototype is not in scope.
  
 
 In this case, wouldn't it do the right thing even without a
 prototype in scope?

Depends on the architecture.

 Would it even compile without a prototype in scope?

Depends on the compilation options.

Personally I'd compile with the missing prototype being a compile error,
and remove the cast.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/tests/lib/libm

2011-09-16 Thread David Laight
On Fri, Sep 16, 2011 at 08:41:47PM +0200, Martin Husemann wrote:
 On Fri, Sep 16, 2011 at 09:16:23PM +0300, Jukka Ruohonen wrote:
  Is there any consistent way to know which functions are available on VAX? 
  Or even more generally, any consistent way to know which libm(3) functions
  are available on which architectures?  (That is, there are ugly hacks like
  #ifdef i386 || sparc || amd64 too.)
 
 Good question. I consider all those as hacks, they should be documented
 and fixed, the soone the better.
 
 Or, if there are hidden reasons, we should document them better and rename
 the ifdefs to some __HAVE_... feature tests.
 
 For VAX it is pretty easy: there is no NAN nor +/-INF (and IIRC zero is
 zero, no +/- zero). Everything else is a bug somewhere and fixable.

The other things I can think of are:
- Denormalised values near zero (normally true)
- Strange byte orderings.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/external/bsd/bind/dist/lib/isc/include/isc

2011-09-14 Thread David Laight
On Tue, Sep 13, 2011 at 03:07:44PM -0400, Christos Zoulas wrote:
 Module Name:  src
 Committed By: christos
 Date: Tue Sep 13 19:07:44 UTC 2011
 
 Modified Files:
   src/external/bsd/bind/dist/lib/isc/include/isc: util.h
 
 Log Message:
 Some versions of linux have probably marked fwrite(3) as
 __attribute__((__warn_unused_result__))

What sort of moonshine are those guys on?

Checking the result of fwrite() (and fprintf()) for error is often
pointless since the error doesn't happen until the data is written.
Unless the app always calls fflush() and ferror() before fclose()
checking the result from ferror/fprintf will only give a false
sense of security - and make the code unreadable.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/etc/mtree

2011-09-07 Thread David Laight
On Wed, Sep 07, 2011 at 08:13:20AM +, David Holland wrote:
 
 The fundamental problem is that the make library finds files by
 implicit path searches (of various kinds) which is inherently wobbly
 no matter how many bandaids are applied.

Especially in large items like libc andthe kernel...

 The robust approach is to change the makefiles to do
 
 .for S in $(SRCS:M*.c)
 $(OBJDIR)/$(S:T:R).o: $(S)
   $(COMPILE.c) $(S) -o $(.TARGET)
 .endfor

I tried to do that (without the actual commands) just to force
the .o file to depend on the relevant .c .S (or .cpp) file.
It would save make doing a lot of stat() calls searching for
the source - and always get the right one when, for example,
libc has a .S file that you don't want.

Unfortunately it all exploded due to the way lex and yacc
generate stuff.

In my case I was still using the commands from the suffix rule.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/etc/mtree

2011-09-05 Thread David Laight
On Mon, Sep 05, 2011 at 03:13:49PM +0100, Iain Hibbert wrote:
 
 IMO these cases are worth handling just because if an OBJDIR is specified,
 it should be used. The alternative being that the OBJDIR is used
 sometimes?  Thats just wrong..

A lot of the OBJDIR support happens by magic in make.
Mostly make will look for files in SRCDIR before OBJDIR.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src

2011-09-02 Thread David Laight
On Thu, Sep 01, 2011 at 08:19:07AM +0100, Iain Hibbert wrote:
 On Wed, 31 Aug 2011, Warner Losh wrote:
 
  In the absence of both the prototype and a cast, NULL (which can be 0)
  will be passed as an int, not as a pointer.
 
 NetBSD C headers define NULL as ((void *)0), and our Makefiles use -Wall
 (includes -Wimplicit-function-declaration) to avoid such situations..

ISTR that ansi C (or some recent version of it) does require that
NULL be a pointer constant - so that it gets passed correctly to
varargs functions that expect a data pointer.

Without function prototypes this is a bigger problem, especially
since (char *)0 isn't a useful definition!
This is where 'lint' comes in handy, since it (effectively) checked
that args matched the inferred prototype ...

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src

2011-08-23 Thread David Laight
On Tue, Aug 23, 2011 at 10:31:37AM +1000, matthew green wrote:
  
  One last concern: extended API set 2 support is not yet complete.
  Shouldn't we bump for once when it is done, instead of bumping for each
  system call added?
 
 the minor number should be bumped any time a symbol is added to a
 library.

However it is also reasonable to 'ride' another recent minor version
change.
I'd have thought that these functions could be added 'hidded' to allow
other developers (etc) to do further testing, then the version
bumped when they are made visible by default.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/bin/sh

2011-08-23 Thread David Laight
On Tue, Aug 23, 2011 at 06:04:39AM -0400, Christos Zoulas wrote:
 Module Name:  src
 Committed By: christos
 Date: Tue Aug 23 10:04:39 UTC 2011
 
 Modified Files:
   src/bin/sh: expand.c
 
 Log Message:
 PR/45269: Andreas Gustafsson: Instead of falling off the edge when eating 
 trailing newlines
 if the block has moved, arrange so that trailing newlines are never placed in 
 the string
 in the first place, by accumulating them and adding them only after we've 
 encountered a
 non-newline character. This allows also for more efficient appending since we 
 know how much
 we need beforehand. From FreeBSD.
 

I'm not sure the old netbsd code is wrong - after the fix in rev 1.68
(netbsd 3 timescales).
All the values used when stripping the newlines should be valid.
Maybe there is something iffy with the sequence points in some of
the earlier code - or gcc is just getting them wrong.
The string buffer being extended shouldn't make a difference - even
if it isn't the last fragment of the heap list.

I've done a test with rev 1.84 and got the string extended while adding the
output from $(...) and it was ok - but I'm using a much older gcc.

I think it might be worth looking as the asm output from gcc for
a compilation that is known to get it wrong.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/bin/sh

2011-08-23 Thread David Laight
On Tue, Aug 23, 2011 at 06:04:39AM -0400, Christos Zoulas wrote:
 Module Name:  src
 Committed By: christos
 Date: Tue Aug 23 10:04:39 UTC 2011
 
 Modified Files:
   src/bin/sh: expand.c
 
 Log Message:
 PR/45269: Andreas Gustafsson: Instead of falling off the edge when eating 
 trailing newlines
 if the block has moved, arrange so that trailing newlines are never placed in 
 the string
 in the first place, by accumulating them and adding them only after we've 
 encountered a
 non-newline character. This allows also for more efficient appending since we 
 know how much
 we need beforehand. From FreeBSD.

I've checked - we already had a fix for the bug that the freebsd change
was for (running back off the beginning of the buffer).

The newer gcc's are doing something else unexpected.
Possibly even gcc 4.1.

I'm not sure we should assume that this change fixes the underlying
problem.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/arch/ofppc/ofppc

2011-08-18 Thread David Laight
On Thu, Aug 18, 2011 at 08:55:44AM +, Frank Wille wrote:
 Module Name:  src
 Committed By: phx
 Date: Thu Aug 18 08:55:43 UTC 2011
 
 Modified Files:
   src/sys/arch/ofppc/ofppc: disksubr.c
 
 Log Message:
 First check whether an MBR is present. Then use it for locating the disklabel.
 Otherwise try to construct a disklabel from RDB partitions, and when
 everything fails, look for a raw NetBSD disklabel in LABELSECTOR.
 This is the same sequence as in ofwboot now.
 Also fixed some typos in the comments.

Might be worth looking/using/updating the MI(ish) code that i386
uses when playing 'hunt the label'.
After all disks get moved between machines.

David

-- 
David Laight: da...@l8s.co.uk


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

2011-08-09 Thread David Laight
On Tue, Aug 09, 2011 at 10:14:08AM +0200, Manuel Bouyer wrote:
 On Tue, Aug 09, 2011 at 10:47:18AM +0300, Jukka Ruohonen wrote:
  On Tue, Aug 09, 2011 at 09:44:09AM +0200, Alan Barrett wrote:
   Whether or not available as a module is a good reason for 
   removing something from GENERIC is a separate topic which I will 
   not consider in this message.
  
  Fortunately, people can vote with their own work; henceforth all drivers
  I write will be available only as modules.
 
 You mean, your work cannot be inclued in non-modular kernels ?
 this is silly. 

I must find some round tuits and change the kernel config/build
to build modules then link the required ones into a partially
linked kernel with 'ld -r' before doing a final link to a fully
fixed up kernel.
This should also make it possible for a user to include an
extra module.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src

2011-08-01 Thread David Laight
On Mon, Aug 01, 2011 at 12:28:55PM +, Marc Balmer wrote:
 According to the Oxford Dictionary of Etymology, a wether is a male sheep
 or ram.

I always thought it was a ram without its 'bits'...

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys

2011-07-30 Thread David Laight
On Sat, Jul 30, 2011 at 11:04:24PM +0200, Joerg Sonnenberger wrote:
... 
 Note that for a uncontested resource, the overhead of a mutex for a
 single operation tends to be comparable, if store fences have a similar
 price than bus locked operation on an owned cache line.

I remember being told that you couldn't avoid a lock, and algorithms
that claimed to do so were broken.
The so-called atomic ops effectively use the data item itself
as the lock.
For a single access this might be a gain because 'unlock' often
needs another synchronising bus cycle.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sbin/disklabel

2011-07-26 Thread David Laight
On Tue, Jul 26, 2011 at 09:56:24AM +0200, Alan Barrett wrote:
 On Mon, 25 Jul 2011, Christos Zoulas wrote:
 Modified Files:
  src/sbin/disklabel: disklabel.8
 
 Log Message:
 mention that we don't handle more than 2TB disks/partitions.
 
 I think the limit's actually (2**32 - 1) sectors.  With
 512-byte sectors, that's one sector less than 2TB.

I've always wondered if the label could lie about the physical sector size?
Making it look like you'd copied a disk image from a disk with (say) 8k sectors!
But I don't think the fs support for large sectors is adequately phyical
sector size agnostic.
8k sectors, 8k fragments and 64k blocks should work for FFSv1 and FFSv2.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/crypto/external/bsd/openssl/lib/libcrypto/arch

2011-07-25 Thread David Laight
On Mon, Jul 25, 2011 at 11:52:52AM +0200, Joerg Sonnenberger wrote:
 Much better. One thing remains. It would be nice to replace
   .byte 0xf3,0xc3
 with either a simple ret or a ret $0, depending on whether it has a
 label on it or not. The reason for this mess seems to be a bug in
 certain generation of AMD CPUs. So essentially,

IIRC it is something to do with branch prediction?
But my memory keeps thinking of a constraint about the number
of branches/labels in a cache line - and I'm sure the non-use of
1 byte return instructions was all related.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/crypto/external/bsd/openssl/lib/libcrypto/arch

2011-07-25 Thread David Laight
On Mon, Jul 25, 2011 at 08:38:13PM +0200, Joerg Sonnenberger wrote:
 On Mon, Jul 25, 2011 at 07:24:57PM +0100, David Laight wrote:
  On Mon, Jul 25, 2011 at 11:52:52AM +0200, Joerg Sonnenberger wrote:
   Much better. One thing remains. It would be nice to replace
 .byte 0xf3,0xc3
   with either a simple ret or a ret $0, depending on whether it has a
   label on it or not. The reason for this mess seems to be a bug in
   certain generation of AMD CPUs. So essentially,
  
  IIRC it is something to do with branch prediction?
  But my memory keeps thinking of a constraint about the number
  of branches/labels in a cache line - and I'm sure the non-use of
  1 byte return instructions was all related.
 
 When I asked around, I get the following reference, which seems to
 summarize the situation nicely:
 
 http://mikedimmick.blogspot.com/2008/03/what-heck-does-ret-mean.html

That is sort of consistent with what I remember from those guides.
I wonder what the additional cost of 'rep ret' and 'ret $0' is
on other cpus (apart from the obvious extra code byte).

Looking at the code (now with fewer 'rep ret') I notice that a fair
number of the jumps are unconditional - why have an unconditional jump
to a return instruction!
I also haven't checked what the critical paths are, and what the static
predicton will do! I also don't know the cycle times of these special
instructions to know how much it really matters!

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/arch

2011-07-18 Thread David Laight
On Mon, Jul 18, 2011 at 02:18:54AM +0200, Jean-Yves Migeon wrote:
 On 18.07.2011 02:00, David Young wrote:
  Can we please use ansi function definitions in newly committed code?
  
  This was tedious enough without converting to ANSI function definitions.
  A good job for Coccinelle (spatch)?
 
 Sadly, no: last time I tried (when moving kvm(3) code to ANSI style), I
 had to do it manually. It's even the opposite, spatch has issues when
 parsing non-ANSI declarations, so you have to do the conversion all by
 yourself first...

I've a sed script that will change most of them
see ftp.netbsd.org:~dsl/protoz

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/kern

2011-06-05 Thread David Laight
On Thu, Jun 02, 2011 at 09:21:11PM +0100, David Laight wrote:
 On Thu, Jun 02, 2011 at 06:54:44PM +, David Laight wrote:
  Module Name:src
  Committed By:   dsl
  Date:   Thu Jun  2 18:54:44 UTC 2011
  
  Modified Files:
  src/sys/kern: vfs_syscalls.c
  
  Log Message:
  Fix type in comment
  (before I replace the 'l' with 'curlwp')
 
 Actually I've thought about this some more.
 While, on the face of it, removing the 'struct lwp *' parameter to all system
 calls might seem an optimisation, I suspect that, especially on systems where
 arguments are passed in registers, it is a pessimisation.
 
 Passing 'l' is a register rename (or copy) so is almost zero cost.
 
 Recovering curlwp may involve a function call, and is, at best, a real
 memory access of global data (possibly via an asm statement) that will
 be slow and multiple accesses might need caching in a local anyway.

Well, an amd64 GENERIC kernel grows by 1.5k, and I've given up trying to get
an i386 MONOLITHIC to compile - too much crap in compat.

David

-- 
David Laight: da...@l8s.co.uk


CVS commit: src/sys/compat

2011-06-05 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jun  5 08:42:59 UTC 2011

Modified Files:
src/sys/compat/linux/common: linux_sched.c
src/sys/compat/netbsd32: netbsd32_fs.c netbsd32_netbsd.c

Log Message:
Delete some splurious commas and very unexpected trailing space


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/compat/linux/common/linux_sched.c
cvs rdiff -u -r1.60 -r1.61 src/sys/compat/netbsd32/netbsd32_fs.c
cvs rdiff -u -r1.170 -r1.171 src/sys/compat/netbsd32/netbsd32_netbsd.c

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

Modified files:

Index: src/sys/compat/linux/common/linux_sched.c
diff -u src/sys/compat/linux/common/linux_sched.c:1.63 src/sys/compat/linux/common/linux_sched.c:1.64
--- src/sys/compat/linux/common/linux_sched.c:1.63	Wed Jul  7 01:30:35 2010
+++ src/sys/compat/linux/common/linux_sched.c	Sun Jun  5 08:42:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_sched.c,v 1.63 2010/07/07 01:30:35 chs Exp $	*/
+/*	$NetBSD: linux_sched.c,v 1.64 2011/06/05 08:42:59 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.63 2010/07/07 01:30:35 chs Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.64 2011/06/05 08:42:59 dsl Exp $);
 
 #include sys/param.h
 #include sys/mount.h
@@ -696,4 +696,4 @@
 	printf(linux_sys_sched_setaffinity\n);
 #endif
 	return 0;
-};
+}

Index: src/sys/compat/netbsd32/netbsd32_fs.c
diff -u src/sys/compat/netbsd32/netbsd32_fs.c:1.60 src/sys/compat/netbsd32/netbsd32_fs.c:1.61
--- src/sys/compat/netbsd32/netbsd32_fs.c:1.60	Sat Jan 22 22:26:10 2011
+++ src/sys/compat/netbsd32/netbsd32_fs.c	Sun Jun  5 08:42:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_fs.c,v 1.60 2011/01/22 22:26:10 matt Exp $	*/
+/*	$NetBSD: netbsd32_fs.c,v 1.61 2011/06/05 08:42:59 dsl Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: netbsd32_fs.c,v 1.60 2011/01/22 22:26:10 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: netbsd32_fs.c,v 1.61 2011/06/05 08:42:59 dsl Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -759,7 +759,7 @@
 
 int
 netbsd32___mount50(struct lwp *l, const struct netbsd32___mount50_args *uap,
-	register_t *retval) 
+	register_t *retval)
 {
 	/* {
 		syscallarg(netbsd32_charp) type;

Index: src/sys/compat/netbsd32/netbsd32_netbsd.c
diff -u src/sys/compat/netbsd32/netbsd32_netbsd.c:1.170 src/sys/compat/netbsd32/netbsd32_netbsd.c:1.171
--- src/sys/compat/netbsd32/netbsd32_netbsd.c:1.170	Sun May  1 02:08:15 2011
+++ src/sys/compat/netbsd32/netbsd32_netbsd.c	Sun Jun  5 08:42:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_netbsd.c,v 1.170 2011/05/01 02:08:15 rmind Exp $	*/
+/*	$NetBSD: netbsd32_netbsd.c,v 1.171 2011/06/05 08:42:59 dsl Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001, 2008 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: netbsd32_netbsd.c,v 1.170 2011/05/01 02:08:15 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: netbsd32_netbsd.c,v 1.171 2011/06/05 08:42:59 dsl Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ddb.h
@@ -1863,7 +1863,7 @@
 
 	NETBSD32TOP_UAP(set, sigset_t);
 	return (sys___sigsuspend14(l, ua, retval));
-};
+}
 
 int
 netbsd32_fchroot(struct lwp *l, const struct netbsd32_fchroot_args *uap, register_t *retval)



<    1   2   3   4   5   6   7   8   9   >