Re: CVS commit: src/share/man/man4

2011-09-03 Thread John Nemeth
On Jan 20,  1:58pm, Jukka Ruohonen wrote:
} On Tue, Aug 30, 2011 at 10:10:05AM -0500, David Young wrote:
}  
}  The driver should be converted, however, I don't think that there is
}  a case for bluntly removing bktr(4), 
} 
} Yes, I was corrected already (the conversion should go towards video(4)).
} 
} But as always, it is about picking the good defaults for GENERIC.

 In NetBSD, GENERIC kernels generally contain everything that could
possibly be useful and doesn't cause problems (some newer drivers are
buggy, some interfere with other devices, and some have caused damage
to hardware).  This means the question is very simple:  is the driver
brand new, or does it cause problems in some way?  If the answer is no
to both questions, then the driver is included; there are no other
factors to the decision.  Note that cause problems in some way does
not include consuming resources such as wired kernel memory.

}-- End of excerpt from Jukka Ruohonen


Re: CVS commit: src/share/man/man4

2011-09-03 Thread Jukka Ruohonen
On Fri, Sep 02, 2011 at 11:23:08PM -0700, John Nemeth wrote:
  In NetBSD, GENERIC kernels generally contain everything that could
 possibly be useful and doesn't cause problems (some newer drivers are
 buggy, some interfere with other devices, and some have caused damage
 to hardware).  This means the question is very simple:  is the driver
 brand new, or does it cause problems in some way?  If the answer is no
 to both questions, then the driver is included; there are no other
 factors to the decision.  Note that cause problems in some way does
 not include consuming resources such as wired kernel memory.

So if everything is clear and rational, care to explain why for instance
GATEWAY and IPSEC are commented out? And as said, my drivers will be an
exception.

- Jukka.


Re: CVS commit: src

2011-09-03 Thread Warner Losh

On Sep 2, 2011, at 11:09 AM, David Laight wrote:

 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.

C89 and C99 don't require this.  #define NULL 0 is a conforming definition.

C1X draft N1570 still has 6.3.2.3 An integer constant expression with the 
value 0, or such an expression cast to type void *, is called a null pointer 
constant. and 7.19 The macros are NULL which expands to an 
implementation-defined null pointer constant which means #define NULL 0 is 
still a conforming definition.

C++'s new standard is different though.

 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
 
 



CVS commit: src/usr.bin/tail

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 09:02:20 UTC 2011

Modified Files:
src/usr.bin/tail: extern.h forward.c misc.c read.c reverse.c tail.c

Log Message:
Instead of declaring our own err() which is different than the standard one,
and using it incorrectly in a few places because of confusion (does it print
errno or not?), declare two versions following the standard ones xerrx and,
xerr, and use those as appropriate, implementing them using them vwarn and
vwarnx.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/tail/extern.h
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/tail/forward.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/tail/misc.c
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/tail/read.c
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/tail/reverse.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/tail/tail.c

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

Modified files:

Index: src/usr.bin/tail/extern.h
diff -u src/usr.bin/tail/extern.h:1.9 src/usr.bin/tail/extern.h:1.10
--- src/usr.bin/tail/extern.h:1.9	Mon Apr 13 19:33:25 2009
+++ src/usr.bin/tail/extern.h	Sat Sep  3 05:02:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.9 2009/04/13 23:33:25 lukem Exp $	*/
+/*	$NetBSD: extern.h,v 1.10 2011/09/03 09:02:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -43,8 +43,8 @@
 int displaybytes(FILE *, off_t);
 int displaylines(FILE *, off_t);
 
-void err(int fatal, const char *fmt, ...)
- __attribute__((__format__(__printf__, 2, 3)));
+void xerr(int fatal, const char *fmt, ...) __printflike(2, 3);
+void xerrx(int fatal, const char *fmt, ...) __printflike(2, 3);
 void ierr(void);
 void oerr(void);
 

Index: src/usr.bin/tail/forward.c
diff -u src/usr.bin/tail/forward.c:1.29 src/usr.bin/tail/forward.c:1.30
--- src/usr.bin/tail/forward.c:1.29	Mon Apr 13 19:33:25 2009
+++ src/usr.bin/tail/forward.c	Sat Sep  3 05:02:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: forward.c,v 1.29 2009/04/13 23:33:25 lukem Exp $	*/
+/*	$NetBSD: forward.c,v 1.30 2011/09/03 09:02:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)forward.c	8.1 (Berkeley) 6/6/93;
 #endif
-__RCSID($NetBSD: forward.c,v 1.29 2009/04/13 23:33:25 lukem Exp $);
+__RCSID($NetBSD: forward.c,v 1.30 2011/09/03 09:02:20 christos Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -180,7 +180,7 @@
 	if (fflag) {
 		kq = kqueue();
 		if (kq  0)
-			err(1, kqueue);
+			xerr(1, kqueue);
 		action = ADD_EVENTS;
 	}
 
@@ -225,7 +225,7 @@
 
 		case USE_KQUEUE:
 			if (kevent(kq, NULL, 0, ev, 1, NULL)  0)
-err(1, kevent);
+xerr(1, kevent);
 
 			if (ev[0].filter == EVFILT_VNODE) {
 /* file was rotated, wait until it reappears */
@@ -305,7 +305,7 @@
 		start = mmap(NULL, (size_t)mmap_size, PROT_READ,
 			 MAP_FILE|MAP_SHARED, fileno(fp), mmap_offset);
 		if (start == MAP_FAILED) {
-			err(0, %s: %s, fname, strerror(EFBIG));
+			xerr(0, %s, fname);
 			return (1);
 		}
 
@@ -326,7 +326,7 @@
 			break;
 
 		if (munmap(start, mmap_size)) {
-			err(0, %s: %s, fname, strerror(errno));
+			xerr(0, %s, fname);
 			return (1);
 		}
 
@@ -344,7 +344,7 @@
 	WR(p, mmap_size - mmap_remaining);
 	file_remaining += mmap_size - mmap_remaining;
 	if (munmap(start, mmap_size)) {
-		err(0, %s: %s, fname, strerror(errno));
+		xerr(0, %s, fname);
 		return (1);
 	}
 

Index: src/usr.bin/tail/misc.c
diff -u src/usr.bin/tail/misc.c:1.6 src/usr.bin/tail/misc.c:1.7
--- src/usr.bin/tail/misc.c:1.6	Thu Aug  7 07:16:02 2003
+++ src/usr.bin/tail/misc.c	Sat Sep  3 05:02:20 2011
@@ -35,7 +35,7 @@
 #if 0
 static char sccsid[] = @(#)misc.c	8.1 (Berkeley) 6/6/93;
 #endif
-__RCSID($NetBSD: misc.c,v 1.6 2003/08/07 11:16:02 agc Exp $);
+__RCSID($NetBSD: misc.c,v 1.7 2011/09/03 09:02:20 christos Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -46,31 +46,43 @@
 #include stdlib.h
 #include string.h
 #include unistd.h
+#include err.h
 
 #include extern.h
 
 void
 ierr(void)
 {
-	err(0, %s: %s, fname, strerror(errno));
+	xerr(0, %s, fname);
 }
 
 void
 oerr(void)
 {
-	err(1, stdout: %s, strerror(errno));
+	xerr(1, stdout);
 }
 
 void
-err(int fatal, const char *fmt, ...)
+xerr(int fatal, const char *fmt, ...)
 {
 	va_list ap;
 
 	va_start(ap, fmt);
-	(void)fprintf(stderr, tail: );
-	(void)vfprintf(stderr, fmt, ap);
+	vwarn(fmt, ap);
+	va_end(ap);
+	if (fatal)
+		exit(1);
+	rval = 1;
+}
+
+void
+xerrx(int fatal, const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	vwarnx(fmt, ap);
 	va_end(ap);
-	(void)fprintf(stderr, \n);
 	if (fatal)
 		exit(1);
 	rval = 1;

Index: src/usr.bin/tail/read.c
diff -u src/usr.bin/tail/read.c:1.15 src/usr.bin/tail/read.c:1.16
--- src/usr.bin/tail/read.c:1.15	Mon Apr 13 19:33:25 2009
+++ src/usr.bin/tail/read.c	Sat Sep  3 05:02:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: read.c,v 1.15 2009/04/13 23:33:25 lukem Exp $	*/
+/*	$NetBSD: read.c,v 1.16 2011/09/03 09:02:20 christos Exp $	*/
 
 /*-

CVS commit: src/sys/kern

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 10:28:33 UTC 2011

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

Log Message:
We need to process SA_STOP signals immediately, and not deliver them to
the process. Instead of re-structuring the code to do that, call issignal()
like before in that case. (tail -F /file^Zfg should not get interrupted).


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/kern_sleepq.c

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

Modified files:

Index: src/sys/kern/kern_sleepq.c
diff -u src/sys/kern/kern_sleepq.c:1.42 src/sys/kern/kern_sleepq.c:1.43
--- src/sys/kern/kern_sleepq.c:1.42	Wed Aug 31 12:09:55 2011
+++ src/sys/kern/kern_sleepq.c	Sat Sep  3 06:28:33 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sleepq.c,v 1.42 2011/08/31 16:09:55 christos Exp $	*/
+/*	$NetBSD: kern_sleepq.c,v 1.43 2011/09/03 10:28:33 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_sleepq.c,v 1.42 2011/08/31 16:09:55 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_sleepq.c,v 1.43 2011/09/03 10:28:33 christos Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -284,7 +284,9 @@
 			 * not recurse again.
 			 */
 			mutex_enter(p-p_lock);
-			if ((sig = sigispending(l, 0)) != 0)
+			if (((sig = sigispending(l, 0)) != 0 
+			(sigprop[sig]  SA_STOP) == 0) ||
+			(sig = issignal(l)) != 0)
 error = sleepq_sigtoerror(l, sig);
 			mutex_exit(p-p_lock);
 		}



CVS commit: src/usr.bin/tail

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 10:35:13 UTC 2011

Modified Files:
src/usr.bin/tail: reverse.c

Log Message:
leave the original errno as it was. don't report EFBIG on all mmap failures.


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

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

Modified files:

Index: src/usr.bin/tail/reverse.c
diff -u src/usr.bin/tail/reverse.c:1.21 src/usr.bin/tail/reverse.c:1.22
--- src/usr.bin/tail/reverse.c:1.21	Sat Sep  3 05:02:20 2011
+++ src/usr.bin/tail/reverse.c	Sat Sep  3 06:35:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: reverse.c,v 1.21 2011/09/03 09:02:20 christos Exp $	*/
+/*	$NetBSD: reverse.c,v 1.22 2011/09/03 10:35:13 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)reverse.c	8.1 (Berkeley) 6/6/93;
 #endif
-__RCSID($NetBSD: reverse.c,v 1.21 2011/09/03 09:02:20 christos Exp $);
+__RCSID($NetBSD: reverse.c,v 1.22 2011/09/03 10:35:13 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -122,7 +122,6 @@
 
 	if ((start = mmap(NULL, (size_t)size, PROT_READ,
 	MAP_FILE|MAP_SHARED, fileno(fp), (off_t)0)) == (caddr_t)-1) {
-		errno = EFBIG;
 		xerr(0, %s, fname);
 		return;
 	}



CVS commit: src/usr.bin/tail

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 10:59:11 UTC 2011

Modified Files:
src/usr.bin/tail: forward.c read.c reverse.c tail.c

Log Message:
minor knf, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/tail/forward.c
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/tail/read.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/tail/reverse.c
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/tail/tail.c

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

Modified files:

Index: src/usr.bin/tail/forward.c
diff -u src/usr.bin/tail/forward.c:1.30 src/usr.bin/tail/forward.c:1.31
--- src/usr.bin/tail/forward.c:1.30	Sat Sep  3 05:02:20 2011
+++ src/usr.bin/tail/forward.c	Sat Sep  3 06:59:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: forward.c,v 1.30 2011/09/03 09:02:20 christos Exp $	*/
+/*	$NetBSD: forward.c,v 1.31 2011/09/03 10:59:10 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)forward.c	8.1 (Berkeley) 6/6/93;
 #endif
-__RCSID($NetBSD: forward.c,v 1.30 2011/09/03 09:02:20 christos Exp $);
+__RCSID($NetBSD: forward.c,v 1.31 2011/09/03 10:59:10 christos Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -206,15 +206,15 @@
 			memset(ev, 0, sizeof(ev));
 			if (fflag == 2  fileno(fp) != STDIN_FILENO) {
 EV_SET(ev[n], fileno(fp), EVFILT_VNODE,
-	EV_ADD | EV_ENABLE | EV_CLEAR,
-	NOTE_DELETE | NOTE_RENAME, 0, 0);
+EV_ADD | EV_ENABLE | EV_CLEAR,
+NOTE_DELETE | NOTE_RENAME, 0, 0);
 n++;
 			}
 			EV_SET(ev[n], fileno(fp), EVFILT_READ,
-EV_ADD | EV_ENABLE, 0, 0, 0);
+			EV_ADD | EV_ENABLE, 0, 0, 0);
 			n++;
 
-			if (kevent(kq, ev, n, NULL, 0, NULL)  0) {
+			if (kevent(kq, ev, n, NULL, 0, NULL) == -1) {
 close(kq);
 kq = -1;
 action = USE_SLEEP;
@@ -224,7 +224,7 @@
 			break;
 
 		case USE_KQUEUE:
-			if (kevent(kq, NULL, 0, ev, 1, NULL)  0)
+			if (kevent(kq, NULL, 0, ev, 1, NULL) == -1)
 xerr(1, kevent);
 
 			if (ev[0].filter == EVFILT_VNODE) {
@@ -290,7 +290,7 @@
 #define MMAP_MAXSIZE  (10 * 1024 * 1024)
 
 	if (!(file_size = sbp-st_size))
-		return (0);
+		return 0;
 	file_remaining = file_size;
 
 	if (file_remaining  MMAP_MAXSIZE) {
@@ -306,7 +306,7 @@
 			 MAP_FILE|MAP_SHARED, fileno(fp), mmap_offset);
 		if (start == MAP_FAILED) {
 			xerr(0, %s, fname);
-			return (1);
+			return 1;
 		}
 
 		mmap_remaining = mmap_size;
@@ -327,7 +327,7 @@
 
 		if (munmap(start, mmap_size)) {
 			xerr(0, %s, fname);
-			return (1);
+			return 1;
 		}
 
 		if (mmap_offset = MMAP_MAXSIZE) {
@@ -345,7 +345,7 @@
 	file_remaining += mmap_size - mmap_remaining;
 	if (munmap(start, mmap_size)) {
 		xerr(0, %s, fname);
-		return (1);
+		return 1;
 	}
 
 	/*
@@ -355,7 +355,7 @@
 	 */
 	if (fseeko(fp, file_remaining, SEEK_SET) == -1) {
 		ierr();
-		return (1);
+		return 1;
 	}
-	return (0);
+	return 0;
 }

Index: src/usr.bin/tail/read.c
diff -u src/usr.bin/tail/read.c:1.16 src/usr.bin/tail/read.c:1.17
--- src/usr.bin/tail/read.c:1.16	Sat Sep  3 05:02:20 2011
+++ src/usr.bin/tail/read.c	Sat Sep  3 06:59:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: read.c,v 1.16 2011/09/03 09:02:20 christos Exp $	*/
+/*	$NetBSD: read.c,v 1.17 2011/09/03 10:59:10 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)read.c	8.1 (Berkeley) 6/6/93;
 #endif
-__RCSID($NetBSD: read.c,v 1.16 2011/09/03 09:02:20 christos Exp $);
+__RCSID($NetBSD: read.c,v 1.17 2011/09/03 10:59:10 christos Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -82,7 +82,7 @@
 	}
 	if (ferror(fp)) {
 		ierr();
-		return (1);
+		return 1;
 	}
 
 	if (rflag) {
@@ -115,7 +115,7 @@
 		if ((len = p - sp) != 0)
 			WR(sp, len);
 	}
-	return (0);
+	return 0;
 }
 
 /*
@@ -181,7 +181,7 @@
 	if (ferror(fp)) {
 		free(lines);
 		ierr();
-		return (1);
+		return 1;
 	}
 	if (cnt) {
 		lines[recno].l = sp;
@@ -206,5 +206,5 @@
 			WR(lines[cnt].l, lines[cnt].len);
 	}
 	free(lines);
-	return (0);
+	return 0;
 }

Index: src/usr.bin/tail/reverse.c
diff -u src/usr.bin/tail/reverse.c:1.22 src/usr.bin/tail/reverse.c:1.23
--- src/usr.bin/tail/reverse.c:1.22	Sat Sep  3 06:35:13 2011
+++ src/usr.bin/tail/reverse.c	Sat Sep  3 06:59:11 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: reverse.c,v 1.22 2011/09/03 10:35:13 christos Exp $	*/
+/*	$NetBSD: reverse.c,v 1.23 2011/09/03 10:59:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)reverse.c	8.1 (Berkeley) 6/6/93;
 #endif
-__RCSID($NetBSD: reverse.c,v 1.22 2011/09/03 10:35:13 christos Exp $);
+__RCSID($NetBSD: reverse.c,v 1.23 2011/09/03 10:59:11 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -121,7 +121,7 @@
 	}
 
 	if ((start = mmap(NULL, (size_t)size, PROT_READ,
-	MAP_FILE|MAP_SHARED, fileno(fp), (off_t)0)) == (caddr_t)-1) {
+	MAP_FILE|MAP_SHARED, fileno(fp), (off_t)0)) == MAP_FAILED) {
 		xerr(0, 

CVS commit: src/sys/arch/usermode/dev

2011-09-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Sep  3 12:25:31 UTC 2011

Modified Files:
src/sys/arch/usermode/dev: cpu.c

Log Message:
Oops forgot to commit this one


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/usermode/dev/cpu.c

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

Modified files:

Index: src/sys/arch/usermode/dev/cpu.c
diff -u src/sys/arch/usermode/dev/cpu.c:1.24 src/sys/arch/usermode/dev/cpu.c:1.25
--- src/sys/arch/usermode/dev/cpu.c:1.24	Fri Sep  2 14:56:48 2011
+++ src/sys/arch/usermode/dev/cpu.c	Sat Sep  3 12:25:31 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.24 2011/09/02 14:56:48 reinoud Exp $ */
+/* $NetBSD: cpu.c,v 1.25 2011/09/03 12:25:31 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include opt_cpu.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.24 2011/09/02 14:56:48 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.25 2011/09/03 12:25:31 reinoud Exp $);
 
 #include sys/param.h
 #include sys/conf.h
@@ -286,7 +286,6 @@
 	panic(%s: shouldn't return, __func__);
 }
 
-extern void syscall(struct lwp *l);
 void
 cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
 void (*func)(void *), void *arg)
@@ -322,8 +321,6 @@
 	pcb2-pcb_ucp.uc_flags = _UC_STACK | _UC_CPU;
 	thunk_makecontext(pcb2-pcb_ucp, (void (*)(void))cpu_lwp_trampoline,
 	2, func, arg);
-	thunk_makecontext_1(pcb2-pcb_syscall_ucp, (void (*)(void))syscall,
-		l2);
 }
 
 void
@@ -331,6 +328,7 @@
 {
 }
 
+int syscall(lwp_t *l, struct trapframe *tr);
 void
 cpu_startup(void)
 {
@@ -347,11 +345,10 @@
 		panic(getcontext failed);
 	uvm_lwp_setuarea(lwp0, (vaddr_t)lwp0pcb);
 
-	/* init switchframes */
+	/* init trapframe (going nowhere!), maybe a panic func? */
+	lwp0pcb.pcb_tf.tf_syscall = syscall;
 	memcpy(lwp0pcb.pcb_userland_ucp, lwp0pcb.pcb_ucp, sizeof(ucontext_t));
-	memcpy(lwp0pcb.pcb_syscall_ucp,  lwp0pcb.pcb_ucp, sizeof(ucontext_t));
-	thunk_makecontext_1(lwp0pcb.pcb_syscall_ucp, (void (*)(void))syscall,
-		lwp0);
+//	thunk_makecontext_trapframe2go(lwp0pcb.pcb_userland_ucp, NULL, NULL);
 }
 
 void



CVS commit: src/sys/arch/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 12:28:46 UTC 2011

Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode files.usermode
std.usermode
src/sys/arch/usermode/usermode: pmap.c
Added Files:
src/sys/arch/usermode/include: urkelvisor.h
src/sys/arch/usermode/usermode: urkelvisor.c

Log Message:
Add usermode kernel supervisor, can be disabled with 'no options URKELVISOR'


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/conf/files.usermode
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/usermode/conf/std.usermode
cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/include/urkelvisor.h
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/usermode/usermode/pmap.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/usermode/urkelvisor.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/usermode/conf/Makefile.usermode
diff -u src/sys/arch/usermode/conf/Makefile.usermode:1.15 src/sys/arch/usermode/conf/Makefile.usermode:1.16
--- src/sys/arch/usermode/conf/Makefile.usermode:1.15	Sun Aug 28 23:16:18 2011
+++ src/sys/arch/usermode/conf/Makefile.usermode	Sat Sep  3 12:28:45 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.usermode,v 1.15 2011/08/28 23:16:18 jmcneill Exp $
+# $NetBSD: Makefile.usermode,v 1.16 2011/09/03 12:28:45 jmcneill Exp $
 
 MACHINE_ARCH=			usermode
 USETOOLS?=			no
@@ -23,6 +23,8 @@
 CPPFLAGS.init_main.c+=	-Dmain=kernmain
 
 OPT_SDL=	%SDL%
+OPT_URKELVISOR=	%URKELVISOR%
+
 .if !empty(OPT_SDL)
 SDL_CFLAGS!=	sdl-config --cflags
 SDL_LIBS!=	sdl-config --libs
@@ -31,6 +33,7 @@
 
 CPPFLAGS.thunk.c+=	${USERMODE_CPPFLAGS}
 CPPFLAGS.thunk_sdl.c+=	${SDL_CFLAGS} ${USERMODE_CPPFLAGS}
+CPPFLAGS.urkelvisor.c+=	${USERMODE_CPPFLAGS}
 
 ##
 ## (3) libkern and compat
@@ -43,11 +46,17 @@
 ##
 MD_OBJS=	thunk.o
 MD_CFILES=	${USERMODE}/usermode/thunk.c
+MD_SFILES=
+
+.if !empty(OPT_URKELVISOR)
+MD_OBJS+=	urkelvisor.o
+MD_CFILES+=	${USERMODE}/usermode/urkelvisor.c
+.endif
+
 .if !empty(OPT_SDL)
 MD_OBJS+=	thunk_sdl.o
 MD_CFILES+=	${USERMODE}/usermode/thunk_sdl.c
 .endif
-MD_SFILES=
 
 ##
 ## (5) link settings
@@ -82,6 +91,13 @@
 thunk_sdl.o: ${USERMODE}/usermode/thunk_sdl.c
 	${CC} ${CPPFLAGS.thunk_sdl.c} -c -o $@ ${USERMODE}/usermode/thunk_sdl.c
 
+urkelvisor.d: ${USERMODE}/usermode/urkelvisor.c
+	${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
+	${CPPFLAGS.urkelvisor.c} ${USERMODE}/usermode/urkelvisor.c
+
+urkelvisor.o: ${USERMODE}/usermode/urkelvisor.c
+	${CC} ${CPPFLAGS.urkelvisor.c} -c -o $@ ${USERMODE}/usermode/urkelvisor.c
+
 ##
 ## (7) misc settings
 ##

Index: src/sys/arch/usermode/conf/files.usermode
diff -u src/sys/arch/usermode/conf/files.usermode:1.7 src/sys/arch/usermode/conf/files.usermode:1.8
--- src/sys/arch/usermode/conf/files.usermode:1.7	Sat Aug 27 21:43:06 2011
+++ src/sys/arch/usermode/conf/files.usermode	Sat Sep  3 12:28:45 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.usermode,v 1.7 2011/08/27 21:43:06 jmcneill Exp $
+# $NetBSD: files.usermode,v 1.8 2011/09/03 12:28:45 jmcneill Exp $
 
 maxpartitions 8
 maxusers 8 16 64
@@ -6,6 +6,7 @@
 defparam opt_memsize.hMEMSIZE
 defflag opt_sdl.hSDL
 defflag opt_cpu.hCPU_DEBUG
+defflag opt_urkelvisor.h			URKELVISOR
 
 define	thunkbus { }
 

Index: src/sys/arch/usermode/conf/std.usermode
diff -u src/sys/arch/usermode/conf/std.usermode:1.5 src/sys/arch/usermode/conf/std.usermode:1.6
--- src/sys/arch/usermode/conf/std.usermode:1.5	Mon Aug 22 15:26:55 2011
+++ src/sys/arch/usermode/conf/std.usermode	Sat Sep  3 12:28:45 2011
@@ -1,4 +1,4 @@
-# $NetBSD: std.usermode,v 1.5 2011/08/22 15:26:55 reinoud Exp $
+# $NetBSD: std.usermode,v 1.6 2011/09/03 12:28:45 jmcneill Exp $
 
 machine usermode
 include conf/std
@@ -8,6 +8,8 @@
 options 	EXEC_ELF64
 options 	EXEC_SCRIPT
 
+options 	URKELVISOR
+
 # Defaults
 options		NKMEMPAGES=2048
 #options		NKMEMPAGES_MAX_DEFAULT=2048

Index: src/sys/arch/usermode/usermode/pmap.c
diff -u src/sys/arch/usermode/usermode/pmap.c:1.50 src/sys/arch/usermode/usermode/pmap.c:1.51
--- src/sys/arch/usermode/usermode/pmap.c:1.50	Thu Sep  1 16:23:55 2011
+++ src/sys/arch/usermode/usermode/pmap.c	Sat Sep  3 12:28:46 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.50 2011/09/01 16:23:55 reinoud Exp $ */
+/* $NetBSD: pmap.c,v 1.51 2011/09/03 12:28:46 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk rein...@netbsd.org
@@ -27,10 +27,11 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.50 2011/09/01 16:23:55 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.51 2011/09/03 12:28:46 jmcneill Exp $);
 
 #include opt_memsize.h
 #include opt_kmempages.h
+#include opt_urkelvisor.h
 
 #include sys/types.h
 #include sys/param.h
@@ -40,6 +41,10 @@
 #include sys/pool.h
 #include machine/thunk.h
 
+#ifdef URKELVISOR
+#include machine/urkelvisor.h
+#endif
+
 #include uvm/uvm.h

CVS commit: src/sys/arch/usermode/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 12:33:03 UTC 2011

Modified Files:
src/sys/arch/usermode/usermode: machdep.c pmap.c

Log Message:
move call of urkelvisor_init to main instead of pmap_bootstrap


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/usermode/usermode/pmap.c

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

Modified files:

Index: src/sys/arch/usermode/usermode/machdep.c
diff -u src/sys/arch/usermode/usermode/machdep.c:1.20 src/sys/arch/usermode/usermode/machdep.c:1.21
--- src/sys/arch/usermode/usermode/machdep.c:1.20	Thu Sep  1 15:15:06 2011
+++ src/sys/arch/usermode/usermode/machdep.c	Sat Sep  3 12:33:02 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.20 2011/09/01 15:15:06 reinoud Exp $ */
+/* $NetBSD: machdep.c,v 1.21 2011/09/03 12:33:02 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill jmcne...@invisible.ca
@@ -26,8 +26,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include opt_memsize.h
+#include opt_sdl.h
+#include opt_urkelvisor.h
+
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.20 2011/09/01 15:15:06 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.21 2011/09/03 12:33:02 jmcneill Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -45,8 +49,9 @@
 
 #include machine/thunk.h
 
-#include opt_memsize.h
-#include opt_sdl.h
+#if defined(URKELVISOR)
+#include machine/urkelvisor.h
+#endif
 
 char machine[] = usermode;
 char machine_arch[] = usermode;
@@ -103,6 +108,10 @@
 
 	pmap_bootstrap();
 
+#if defined(URKELVISOR)
+	urkelvisor_init();
+#endif
+
 	splraise(IPL_HIGH);
 
 	kernmain();

Index: src/sys/arch/usermode/usermode/pmap.c
diff -u src/sys/arch/usermode/usermode/pmap.c:1.51 src/sys/arch/usermode/usermode/pmap.c:1.52
--- src/sys/arch/usermode/usermode/pmap.c:1.51	Sat Sep  3 12:28:46 2011
+++ src/sys/arch/usermode/usermode/pmap.c	Sat Sep  3 12:33:03 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.51 2011/09/03 12:28:46 jmcneill Exp $ */
+/* $NetBSD: pmap.c,v 1.52 2011/09/03 12:33:03 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk rein...@netbsd.org
@@ -27,11 +27,10 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.51 2011/09/03 12:28:46 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.52 2011/09/03 12:33:03 jmcneill Exp $);
 
 #include opt_memsize.h
 #include opt_kmempages.h
-#include opt_urkelvisor.h
 
 #include sys/types.h
 #include sys/param.h
@@ -41,10 +40,6 @@
 #include sys/pool.h
 #include machine/thunk.h
 
-#ifdef URKELVISOR
-#include machine/urkelvisor.h
-#endif
-
 #include uvm/uvm.h
 
 struct pv_entry {
@@ -304,10 +299,6 @@
 		(uint64_t) (free_end - (free_start + fpos))/1024/1024);
 	aprint_debug(\t%PRIu64 MB of kmem left\n,
 		(uint64_t) (kmem_ext_end - kmem_ext_cur_end)/1024/1024);
-
-#ifdef URKELVISOR
-	urkelvisor_init();
-#endif
 }
 
 void



CVS commit: src/sys/arch/usermode/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 12:48:22 UTC 2011

Modified Files:
src/sys/arch/usermode/usermode: urkelvisor.c

Log Message:
if emulating the syscall, toggle insyscall as the child won't get stopped a
second time


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/usermode/usermode/urkelvisor.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/usermode/usermode/urkelvisor.c
diff -u src/sys/arch/usermode/usermode/urkelvisor.c:1.1 src/sys/arch/usermode/usermode/urkelvisor.c:1.2
--- src/sys/arch/usermode/usermode/urkelvisor.c:1.1	Sat Sep  3 12:28:46 2011
+++ src/sys/arch/usermode/usermode/urkelvisor.c	Sat Sep  3 12:48:22 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: urkelvisor.c,v 1.1 2011/09/03 12:28:46 jmcneill Exp $ */
+/* $NetBSD: urkelvisor.c,v 1.2 2011/09/03 12:48:22 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h
 #ifdef __NetBSD__
-__RCSID($NetBSD: urkelvisor.c,v 1.1 2011/09/03 12:28:46 jmcneill Exp $);
+__RCSID($NetBSD: urkelvisor.c,v 1.2 2011/09/03 12:48:22 jmcneill Exp $);
 #endif
 
 #include sys/types.h
@@ -129,6 +129,8 @@
 			insyscall = !insyscall;
 			if (insyscall) {
 sig = handle_syscall(urkel_pid);
+if (sig)
+	insyscall = !insyscall;
 			}
 		} else {
 			sig = WSTOPSIG(status);



CVS commit: src/usr.bin/fstat

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 13:22:56 UTC 2011

Modified Files:
src/usr.bin/fstat: fstat.1

Log Message:
Mention that fstat -f will not list open unix sockets on that filesystem.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/fstat/fstat.1

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

Modified files:

Index: src/usr.bin/fstat/fstat.1
diff -u src/usr.bin/fstat/fstat.1:1.25 src/usr.bin/fstat/fstat.1:1.26
--- src/usr.bin/fstat/fstat.1:1.25	Sun Jan  4 12:19:39 2009
+++ src/usr.bin/fstat/fstat.1	Sat Sep  3 09:22:55 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: fstat.1,v 1.25 2009/01/04 17:19:39 wiz Exp $
+.\	$NetBSD: fstat.1,v 1.26 2011/09/03 13:22:55 christos Exp $
 .\
 .\ Copyright (c) 1987, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -28,9 +28,9 @@
 .\ SUCH DAMAGE.
 .\
 .\ from: @(#)fstat.1	8.3 (Berkeley) 2/25/94
-.\	$NetBSD: fstat.1,v 1.25 2009/01/04 17:19:39 wiz Exp $
+.\	$NetBSD: fstat.1,v 1.26 2011/09/03 13:22:55 christos Exp $
 .\
-.Dd January 4, 2009
+.Dd September 3, 2011
 .Dt FSTAT 1
 .Os
 .Sh NAME
@@ -65,6 +65,14 @@
 .Pa /usr/src
 resides, type
 .Dq Li fstat -f /usr/src .
+Note that this will not list
+.Dv AF_LOCAL
+domain sockets open in the filesystem.
+To find all the
+.Dv AF_LOCAL
+domain sockets, use
+.Nm
+to list all the sockets, and look for the ones that belong in the filesystem.
 .It Fl M
 Extract values associated with the name list from the specified core
 instead of the default



CVS commit: src/usr.bin/fstat

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 13:24:19 UTC 2011

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

Log Message:
- minor KNF
- for system processes (0, 1) where fd_lastfile == -1, fail early.
- instead of printing the pcb connection address, print the pathname if
  possible for unix domain sockets.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/fstat/fstat.c

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

Modified files:

Index: src/usr.bin/fstat/fstat.c
diff -u src/usr.bin/fstat/fstat.c:1.90 src/usr.bin/fstat/fstat.c:1.91
--- src/usr.bin/fstat/fstat.c:1.90	Wed Apr 13 20:35:35 2011
+++ src/usr.bin/fstat/fstat.c	Sat Sep  3 09:24:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: fstat.c,v 1.90 2011/04/14 00:35:35 rmind Exp $	*/
+/*	$NetBSD: fstat.c,v 1.91 2011/09/03 13:24:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)fstat.c	8.3 (Berkeley) 5/2/95;
 #else
-__RCSID($NetBSD: fstat.c,v 1.90 2011/04/14 00:35:35 rmind Exp $);
+__RCSID($NetBSD: fstat.c,v 1.91 2011/09/03 13:24:19 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -322,11 +322,15 @@
 	if (p-p_fd == 0 || p-p_cwdi == 0)
 		return;
 	if (!KVM_READ(p-p_fd, filed, sizeof (filed))) {
-		warnx(can't read filedesc at %p for pid %d, (void *)(uintptr_t)p-p_fd, Pid);
+		warnx(can't read filedesc at %p for pid %d,
+		(void *)(uintptr_t)p-p_fd, Pid);
 		return;
 	}
+	if (filed.fd_lastfile == -1)
+		return;
 	if (!KVM_READ(p-p_cwdi, cwdi, sizeof(cwdi))) {
-		warnx(can't read cwdinfo at %p for pid %d, (void *)(uintptr_t)p-p_cwdi, Pid);
+		warnx(can't read cwdinfo at %p for pid %d,
+		(void *)(uintptr_t)p-p_cwdi, Pid);
 		return;
 	}
 	if (!KVM_READ(filed.fd_dt, dt, sizeof(dt))) {
@@ -335,7 +339,8 @@
 	}
 	if ((unsigned)filed.fd_lastfile = dt.dt_nfiles ||
 	filed.fd_freefile  filed.fd_lastfile + 1) {
-		dprintf(filedesc corrupted at %p for pid %d, (void *)(uintptr_t)p-p_fd, Pid);
+		dprintf(filedesc corrupted at %p for pid %d,
+		(void *)(uintptr_t)p-p_fd, Pid);
 		return;
 	}
 	/*
@@ -476,7 +481,7 @@
 			break;
 		}
 	}
-	return (badtype);
+	return badtype;
 }
 
 static void
@@ -685,21 +690,21 @@
 	if (!KVM_READ(VTOLAYER(vp), layer_node, sizeof(layer_node))) {
 		dprintf(can't read layer_node at %p for pid %d,
 		VTOLAYER(vp), Pid);
-		return (error);
+		return error;
 	}
 	if (!KVM_READ(vp-v_mount, mount, sizeof(struct mount))) {
 		dprintf(can't read mount struct at %p for pid %d,
 		vp-v_mount, Pid);
-		return (error);
+		return error;
 	}
 	vp = layer_node.layer_lowervp;
 	if (!KVM_READ(vp, vn, sizeof(struct vnode))) {
 		dprintf(can't read vnode at %p for pid %d, vp, Pid);
-		return (error);
+		return error;
 	}
 	if ((badtype = vfilestat(vn, fsp)) == NULL)
 		fsp-fsid = mount.mnt_stat.f_fsidx.__fsid_val[0];
-	return (badtype);
+	return badtype;
 }
 
 static char *
@@ -715,10 +720,10 @@
 
 	for (mt = mhead; mt != NULL; mt = mt-next)
 		if (m == mt-m)
-			return (mt-mntonname);
+			return mt-mntonname;
 	if (!KVM_READ(m, mount, sizeof(struct mount))) {
 		warnx(can't read mount table at %p, m);
-		return (NULL);
+		return NULL;
 	}
 	if ((mt = malloc(sizeof (struct mtab))) == NULL) {
 		err(1, malloc(%u), (unsigned int)sizeof(struct mtab));
@@ -728,7 +733,7 @@
 	MNAMELEN);
 	mt-next = mhead;
 	mhead = mt;
-	return (mt-mntonname);
+	return mt-mntonname;
 }
 
 #ifdef INET6
@@ -925,22 +930,42 @@
 	case AF_LOCAL:
 		/* print address of pcb and connected pcb */
 		if (so.so_pcb) {
+			char shoconn[4], *cp;
+
 			(void)printf( %lx, (long)so.so_pcb);
 			if (kvm_read(kd, (u_long)so.so_pcb, (char *)unpcb,
 			sizeof(struct unpcb)) != sizeof(struct unpcb)){
 dprintf(can't read unpcb at %p, so.so_pcb);
 goto bad;
 			}
-			if (unpcb.unp_conn) {
-char shoconn[4], *cp;
 
-cp = shoconn;
-if (!(so.so_state  SS_CANTRCVMORE))
-	*cp++ = '';
-*cp++ = '-';
-if (!(so.so_state  SS_CANTSENDMORE))
-	*cp++ = '';
-*cp = '\0';
+			cp = shoconn;
+			if (!(so.so_state  SS_CANTRCVMORE))
+*cp++ = '';
+			*cp++ = '-';
+			if (!(so.so_state  SS_CANTSENDMORE))
+*cp++ = '';
+			*cp = '\0';
+			if (unpcb.unp_addr) {
+struct sockaddr_un *sun = 
+	malloc(unpcb.unp_addrlen);
+if (sun == NULL)
+err(1, malloc(%zu),
+	unpcb.unp_addrlen);
+if (kvm_read(kd, (u_long)unpcb.unp_addr,
+sun, unpcb.unp_addrlen) !=
+(ssize_t)unpcb.unp_addrlen) {
+	dprintf(can't read sun at %p,
+	unpcb.unp_addr);
+	free(sun);
+} else {
+	(void)printf( %s %s,
+	shoconn, sun-sun_path);
+	free(sun);
+	break;
+}
+			}
+			if (unpcb.unp_conn) {
 (void)printf( %s %lx, shoconn,
 (long)unpcb.unp_conn);
 			}
@@ -1037,8 +1062,8 @@
 		warn(stat(%s), filename);
 		return 0;
 	}
-	if ((cur = malloc(sizeof(DEVS))) == NULL) {
-		err(1, malloc(%u), (unsigned int)sizeof(DEVS));
+	

CVS commit: src/sys/kern

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 14:09:03 UTC 2011

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

Log Message:
Make sure that we initialize all accounting bytes.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/kern/kern_acct.c

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

Modified files:

Index: src/sys/kern/kern_acct.c
diff -u src/sys/kern/kern_acct.c:1.92 src/sys/kern/kern_acct.c:1.93
--- src/sys/kern/kern_acct.c:1.92	Sat Apr 30 21:15:18 2011
+++ src/sys/kern/kern_acct.c	Sat Sep  3 10:09:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_acct.c,v 1.92 2011/05/01 01:15:18 rmind Exp $	*/
+/*	$NetBSD: kern_acct.c,v 1.93 2011/09/03 14:09:03 christos Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -71,7 +71,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_acct.c,v 1.92 2011/05/01 01:15:18 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_acct.c,v 1.93 2011/09/03 14:09:03 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -411,6 +411,8 @@
 	if (acct_state != ACCT_ACTIVE)
 		return 0;
 
+	memset(acct, 0, sizeof(acct));	/* to zerofill padded data */
+
 	rw_enter(acct_lock, RW_READER);
 
 	/* If accounting isn't enabled, don't bother */
@@ -434,7 +436,7 @@
 	 */
 
 	/* (1) The name of the command that ran */
-	memcpy(acct.ac_comm, p-p_comm, sizeof(acct.ac_comm));
+	strncpy(acct.ac_comm, p-p_comm, sizeof(acct.ac_comm));
 
 	/* (2) The amount of user and system time that was used */
 	mutex_enter(p-p_lock);



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

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 14:23:50 UTC 2011

Modified Files:
src/sys/arch/usermode/include: asm.h bswap.h byte_swap.h disklabel.h
elf_machdep.h endian.h endian_machdep.h int_const.h int_fmtio.h
int_limits.h int_mwgwtypes.h int_types.h limits.h
netbsd32_machdep.h param.h ptrace.h wchar_limits.h
Added Files:
src/sys/arch/usermode/include: Makefile.headers genheaders.sh

Log Message:
Instead of doing #include /usr/include/machine/.., use the headers
that ship with the kernel sources as #include ../../$host/include/$hdr,
and auto-generate these ugly headers with a script.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/include/Makefile.headers \
src/sys/arch/usermode/include/genheaders.sh
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/include/asm.h \
src/sys/arch/usermode/include/bswap.h \
src/sys/arch/usermode/include/byte_swap.h \
src/sys/arch/usermode/include/elf_machdep.h \
src/sys/arch/usermode/include/endian.h \
src/sys/arch/usermode/include/endian_machdep.h \
src/sys/arch/usermode/include/int_const.h \
src/sys/arch/usermode/include/int_fmtio.h \
src/sys/arch/usermode/include/int_limits.h \
src/sys/arch/usermode/include/int_mwgwtypes.h \
src/sys/arch/usermode/include/int_types.h \
src/sys/arch/usermode/include/limits.h \
src/sys/arch/usermode/include/netbsd32_machdep.h \
src/sys/arch/usermode/include/param.h \
src/sys/arch/usermode/include/wchar_limits.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/include/disklabel.h \
src/sys/arch/usermode/include/ptrace.h

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

Modified files:

Index: src/sys/arch/usermode/include/asm.h
diff -u src/sys/arch/usermode/include/asm.h:1.2 src/sys/arch/usermode/include/asm.h:1.3
--- src/sys/arch/usermode/include/asm.h:1.2	Wed Oct 21 16:06:59 2009
+++ src/sys/arch/usermode/include/asm.h	Sat Sep  3 14:23:50 2011
@@ -1,34 +1,18 @@
-/* $NetBSD: asm.h,v 1.2 2009/10/21 16:06:59 snj Exp $ */
+/* $NetBSD: asm.h,v 1.3 2011/09/03 14:23:50 jmcneill Exp $ */
 
-/*-
- * Copyright (c) 2007 Jared D. McNeill jmcne...@invisible.ca
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+/*
+ * Automatically generated by genheaders.sh on Sat Sep  3 10:13:14 EDT 2011
+ * Do not modify directly!
  */
+#ifndef _USERMODE_ASM_H
+#define _USERMODE_ASM_H
 
-#ifndef _ARCH_USERMODE_INCLUDE_ASM_H
-#define _ARCH_USERMODE_INCLUDE_ASM_H
+#if defined(__i386__)
+#include ../../i386/include/asm.h
+#elif defined(__x86_64__)
+#include ../../amd64/include/asm.h
+#else
+#error port me
+#endif
 
-#include /usr/include/machine/asm.h
-
-#endif /* !_ARCH_USERMODE_INCLUDE_ASM_H */
+#endif
Index: src/sys/arch/usermode/include/bswap.h
diff -u src/sys/arch/usermode/include/bswap.h:1.2 src/sys/arch/usermode/include/bswap.h:1.3
--- src/sys/arch/usermode/include/bswap.h:1.2	Wed Oct 21 16:06:59 2009
+++ src/sys/arch/usermode/include/bswap.h	Sat Sep  3 14:23:50 2011
@@ -1,34 +1,18 @@
-/* $NetBSD: bswap.h,v 1.2 2009/10/21 16:06:59 snj Exp $ */
+/* $NetBSD: bswap.h,v 1.3 2011/09/03 14:23:50 jmcneill Exp $ */
 
-/*-
- * Copyright (c) 2007 Jared D. McNeill jmcne...@invisible.ca
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the 

CVS commit: src/sys/arch/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 15:00:28 UTC 2011

Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode
src/sys/arch/usermode/dev: cpu.c ld_thunkbus.c
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: machdep.c thunk.c trap.c urkelvisor.c

Log Message:
Get this compiling (but not quite linking yet) on Linux


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/usermode/dev/cpu.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/usermode/dev/ld_thunkbus.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/usermode/usermode/thunk.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/usermode/usermode/trap.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/usermode/urkelvisor.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/usermode/conf/Makefile.usermode
diff -u src/sys/arch/usermode/conf/Makefile.usermode:1.16 src/sys/arch/usermode/conf/Makefile.usermode:1.17
--- src/sys/arch/usermode/conf/Makefile.usermode:1.16	Sat Sep  3 12:28:45 2011
+++ src/sys/arch/usermode/conf/Makefile.usermode	Sat Sep  3 15:00:27 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.usermode,v 1.16 2011/09/03 12:28:45 jmcneill Exp $
+# $NetBSD: Makefile.usermode,v 1.17 2011/09/03 15:00:27 jmcneill Exp $
 
 MACHINE_ARCH=			usermode
 USETOOLS?=			no
@@ -14,12 +14,16 @@
 ##
 ## (2) compile settings
 ##
+USERMODE_HOSTOS!=uname -s
 USERMODE_LIBS=	-lrt
+.if ${USERMODE_HOSTOS} == Linux
+USERMODE_LIBS+=	-lpthread
+.endif
 USERMODE_CPPFLAGS=-U_KERNEL -I/usr/include
 USERMODE_CPPFLAGS+=${CWARNFLAGS} ${NOGCCERROR:D:U-Werror}
 
 DEFCOPTS=	-fno-omit-frame-pointer
-CPPFLAGS+=	-Dusermode
+CPPFLAGS+=	-Dusermode -D__NetBSD__ -Wno-unused-but-set-variable
 CPPFLAGS.init_main.c+=	-Dmain=kernmain
 
 OPT_SDL=	%SDL%
@@ -63,8 +67,8 @@
 ##
 SYSTEM_LD=	@${_MKSHMSG}link  ${.CURDIR:T}/${.TARGET}; \
 		${_MKSHECHO}\
-		${CC} ${COPTS} -Wl,-Map,$@.map,-Bstatic -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS}; \
-		${CC} ${COPTS} -Wl,-Map,$@.map,-Bstatic -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS}
+		${CC} -static ${COPTS} -Wl,-Map,$@.map -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS}; \
+		${CC} -static ${COPTS} -Wl,-Map,$@.map -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS}
 NVFLAGS=	-n
 
 ##

Index: src/sys/arch/usermode/dev/cpu.c
diff -u src/sys/arch/usermode/dev/cpu.c:1.25 src/sys/arch/usermode/dev/cpu.c:1.26
--- src/sys/arch/usermode/dev/cpu.c:1.25	Sat Sep  3 12:25:31 2011
+++ src/sys/arch/usermode/dev/cpu.c	Sat Sep  3 15:00:28 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.25 2011/09/03 12:25:31 reinoud Exp $ */
+/* $NetBSD: cpu.c,v 1.26 2011/09/03 15:00:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include opt_cpu.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.25 2011/09/03 12:25:31 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.26 2011/09/03 15:00:28 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/conf.h
@@ -133,6 +133,7 @@
 	usermode_reboot();
 
 	/* NOTREACHED */
+	__builtin_unreachable();
 }
 
 void
@@ -149,7 +150,6 @@
 lwp_t *
 cpu_switchto(lwp_t *oldlwp, lwp_t *newlwp, bool returning)
 {
-	extern int errno;
 	struct pcb *oldpcb = oldlwp ? lwp_getpcb(oldlwp) : NULL;
 	struct pcb *newpcb = lwp_getpcb(newlwp);
 	struct cpu_info *ci = curcpu();
@@ -182,10 +182,10 @@
 	curlwp = newlwp;
 	if (oldpcb) {
 		if (thunk_swapcontext(oldpcb-pcb_ucp, newpcb-pcb_ucp))
-			panic(swapcontext failed: %d, errno);
+			panic(swapcontext failed);
 	} else {
 		if (thunk_setcontext(newpcb-pcb_ucp))
-			panic(setcontext failed: %d, errno);
+			panic(setcontext failed);
 	}
 
 #ifdef CPU_DEBUG
@@ -290,7 +290,6 @@
 cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
 void (*func)(void *), void *arg)
 {
-	extern int errno;
 	struct pcb *pcb1 = lwp_getpcb(l1);
 	struct pcb *pcb2 = lwp_getpcb(l2);
 
@@ -313,7 +312,7 @@
 		pcb2-pcb_needfree = false;
 
 	if (thunk_getcontext(pcb2-pcb_ucp))
-		panic(getcontext failed: %d, errno);
+		panic(getcontext failed);
 
 	pcb2-pcb_ucp.uc_stack.ss_sp = stack;
 	pcb2-pcb_ucp.uc_stack.ss_size = stacksize;

Index: src/sys/arch/usermode/dev/ld_thunkbus.c
diff -u src/sys/arch/usermode/dev/ld_thunkbus.c:1.6 src/sys/arch/usermode/dev/ld_thunkbus.c:1.7
--- src/sys/arch/usermode/dev/ld_thunkbus.c:1.6	Thu Aug 25 19:08:35 2011
+++ src/sys/arch/usermode/dev/ld_thunkbus.c	Sat Sep  3 15:00:28 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_thunkbus.c,v 1.6 2011/08/25 19:08:35 reinoud Exp $ */
+/* $NetBSD: ld_thunkbus.c,v 1.7 2011/09/03 15:00:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill 

CVS commit: src/sys/arch/usermode/usermode

2011-09-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Sep  3 15:33:56 UTC 2011

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

Log Message:
Add SIGILL handler, doing nothing than printing out details.
Move the address check to be done later so pmap and uvm have their go first.

Also some minor cosmetic fixes


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/usermode/usermode/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/usermode/usermode/trap.c
diff -u src/sys/arch/usermode/usermode/trap.c:1.19 src/sys/arch/usermode/usermode/trap.c:1.20
--- src/sys/arch/usermode/usermode/trap.c:1.19	Sat Sep  3 15:00:28 2011
+++ src/sys/arch/usermode/usermode/trap.c	Sat Sep  3 15:33:56 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.19 2011/09/03 15:00:28 jmcneill Exp $ */
+/* $NetBSD: trap.c,v 1.20 2011/09/03 15:33:56 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk rein...@netbsd.org
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.19 2011/09/03 15:00:28 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.20 2011/09/03 15:33:56 reinoud Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -52,6 +52,8 @@
 /* forwards and externals */
 void setup_signal_handlers(void);
 static void mem_access_handler(int sig, siginfo_t *info, void *ctx);
+static void illegal_instruction_handler(int sig, siginfo_t *info, void *ctx);
+extern int errno;
 
 bool pmap_fault(pmap_t pmap, vaddr_t va, vm_prot_t *atype);
 
@@ -75,8 +77,14 @@
 		panic(couldn't register SIGSEGV handler : %d,
 		thunk_geterrno());
 	if (thunk_sigaction(SIGBUS, sa, NULL) == -1)
-		panic(couldn't register SIGBUS handler : %d,
-		thunk_geterrno());
+		panic(couldn't register SIGBUS handler : %d, thunk_geterrno());
+
+	sigemptyset(sa.sa_mask);
+	sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
+	sa.sa_sigaction = illegal_instruction_handler;
+	if (thunk_sigaction(SIGILL, sa, NULL) == -1)
+		panic(couldn't register SIGILL handler : %d, thunk_geterrno());
+
 	if ((sigstk.ss_sp = thunk_malloc(SIGSTKSZ)) == NULL)
 		panic(can't allocate signal stack space\n);
 	sigstk.ss_size  = SIGSTKSZ;
@@ -119,7 +127,7 @@
 
 #if 0
 		va = (vaddr_t) info-si_addr;
-		printf(trap lwp = %p pid = %d lid = %d, va = %p\n,
+		printf(mem trap lwp = %p pid = %d lid = %d, va = %p\n,
 		curlwp,
 		curlwp-l_proc-p_pid,
 		curlwp-l_lid,
@@ -130,21 +138,16 @@
 		printf(\tsi_signo = %d\n, info-si_signo);
 		printf(\tsi_errno = %d\n, info-si_errno);
 		printf(\tsi_code  = %d\n, info-si_code);
-		if (info-si_code == SEGV_MAPERR) {
+		if (info-si_code == SEGV_MAPERR)
 			printf(\t\tSEGV_MAPERR\n);
-		}
-		if (info-si_code == SEGV_ACCERR) {
+		if (info-si_code == SEGV_ACCERR)
 			printf(\t\tSEGV_ACCERR\n);
-		}
-		if (info-si_code == BUS_ADRALN) {
+		if (info-si_code == BUS_ADRALN)
 			printf(\t\tBUS_ADRALN\n);
-		}
-		if (info-si_code == BUS_ADRERR) {
+		if (info-si_code == BUS_ADRERR)
 			printf(\t\tBUS_ADRERR\n);
-		}
-		if (info-si_code == BUS_OBJERR) {
+		if (info-si_code == BUS_OBJERR)
 			printf(\t\tBUS_OBJERR\n);
-		}
 		printf(\tsi_addr = %p\n, info-si_addr);
 		printf(\tsi_trap = %d\n, info-si_trap);
 #endif
@@ -152,10 +155,6 @@
 		va = (vaddr_t) info-si_addr;
 		va = trunc_page(va);
 
-		/* sanity */
-		if ((va  VM_MIN_ADDRESS) || (va = VM_MAX_ADDRESS))
-			panic(peeing outside the box!);
-
 		kmem = 1;
 		vm_map = kernel_map;
 		if ((va = VM_MIN_ADDRESS)  (va  VM_MAXUSER_ADDRESS)) {
@@ -173,6 +172,14 @@
 			pcb-pcb_onfault = onfault;
 		}
 
+		/* sanity */
+		if ((va  VM_MIN_ADDRESS) || (va = VM_MAX_ADDRESS))
+			panic(peeing outside the box!);
+
+		/* extra debug for now */
+		if (va == 0)
+			panic(NULL deref\n);
+
 #if 0
 	if (old_old_va)
 		thunk_pwrite(debug_fh, (void *) old_old_va, PAGE_SIZE, old_old_va);
@@ -210,3 +217,60 @@
 	}
 }
 
+static void
+illegal_instruction_handler(int sig, siginfo_t *info, void *ctx)
+{
+	static volatile int recurse = 0;
+	struct proc *p;
+	struct lwp *l;
+	struct pcb *pcb;
+	vaddr_t va;
+
+	recurse++;
+	if (recurse  1)
+		printf(enter trap recursion level %d\n, recurse);
+	if (info-si_signo == SIGILL) {
+		l = curlwp;
+		p = l-l_proc;
+		pcb = lwp_getpcb(l);
+
+#if 1
+		va = (vaddr_t) info-si_addr;
+		printf(illegal instruction trap lwp = %p pid = %d lid = %d, va = %p\n,
+		curlwp,
+		curlwp-l_proc-p_pid,
+		curlwp-l_lid,
+		(void *) va);
+#endif
+#if 1
+		printf(SIGILL!\n);
+		printf(\tsi_signo = %d\n, info-si_signo);
+		printf(\tsi_errno = %d\n, info-si_errno);
+		printf(\tsi_code  = %d\n, info-si_code);
+		if (info-si_code == ILL_ILLOPC)
+			printf(\t\tIllegal opcode);
+		if (info-si_code == ILL_ILLOPN)
+			printf(\t\tIllegal operand);
+		if (info-si_code == ILL_ILLADR)
+			printf(\t\tIllegal addressing mode);
+		if (info-si_code == ILL_ILLTRP)
+			printf(\t\tIllegal trap);
+		if (info-si_code == 

CVS commit: src/sys/dev/usb

2011-09-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep  3 16:19:47 UTC 2011

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

Log Message:
Correct vendor code for Kingston DT101 G2


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

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

Modified files:

Index: src/sys/dev/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.593 src/sys/dev/usb/usbdevs:1.594
--- src/sys/dev/usb/usbdevs:1.593	Sat Sep  3 01:51:20 2011
+++ src/sys/dev/usb/usbdevs	Sat Sep  3 16:19:47 2011
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.593 2011/09/03 01:51:20 asau Exp $
+$NetBSD: usbdevs,v 1.594 2011/09/03 16:19:47 mlelstv Exp $
 
 /*
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1674,7 +1674,7 @@
 product KINGSTON KNU101TX	0x000a	KNU101TX USB Ethernet
 product KINGSTON DT101_II	0x1625	DT 101 II
 product KINGSTON DTMINI10	0x162c	DT Mini 10
-product KINGSTON DT101_G2	0x1625	DT 101 G2
+product KINGSTON DT101_G2	0x1642	DT 101 G2
 
 /* Kodak products */
 product KODAK DC220		0x0100	Digital Science DC220



CVS commit: src/sys/dev/usb

2011-09-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep  3 16:21:18 UTC 2011

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
Regenerate for Kingston DT101 G2


To generate a diff of this commit:
cvs rdiff -u -r1.586 -r1.587 src/sys/dev/usb/usbdevs.h
cvs rdiff -u -r1.587 -r1.588 src/sys/dev/usb/usbdevs_data.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/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.586 src/sys/dev/usb/usbdevs.h:1.587
--- src/sys/dev/usb/usbdevs.h:1.586	Sat Sep  3 01:53:01 2011
+++ src/sys/dev/usb/usbdevs.h	Sat Sep  3 16:21:18 2011
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.586 2011/09/03 01:53:01 asau Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.587 2011/09/03 16:21:18 mlelstv Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.593 2011/09/03 01:51:20 asau Exp
+ *	NetBSD: usbdevs,v 1.594 2011/09/03 16:19:47 mlelstv Exp
  */
 
 /*
@@ -1681,7 +1681,7 @@
 #define	USB_PRODUCT_KINGSTON_KNU101TX	0x000a		/* KNU101TX USB Ethernet */
 #define	USB_PRODUCT_KINGSTON_DT101_II	0x1625		/* DT 101 II */
 #define	USB_PRODUCT_KINGSTON_DTMINI10	0x162c		/* DT Mini 10 */
-#define	USB_PRODUCT_KINGSTON_DT101_G2	0x1625		/* DT 101 G2 */
+#define	USB_PRODUCT_KINGSTON_DT101_G2	0x1642		/* DT 101 G2 */
 
 /* Kodak products */
 #define	USB_PRODUCT_KODAK_DC220	0x0100		/* Digital Science DC220 */

Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.587 src/sys/dev/usb/usbdevs_data.h:1.588
--- src/sys/dev/usb/usbdevs_data.h:1.587	Sat Sep  3 01:53:01 2011
+++ src/sys/dev/usb/usbdevs_data.h	Sat Sep  3 16:21:18 2011
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.587 2011/09/03 01:53:01 asau Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.588 2011/09/03 16:21:18 mlelstv Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.593 2011/09/03 01:51:20 asau Exp
+ *	NetBSD: usbdevs,v 1.594 2011/09/03 16:19:47 mlelstv Exp
  */
 
 /*



CVS commit: src/sys/arch/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 18:42:13 UTC 2011

Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode files.usermode
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: pmap.c thunk.c

Log Message:
Let NetBSD/usermode build  link on a Linux host:
 - Need to add options CPU_HOST=i386 or CPU_HOST=amd64 for membar  atomic_ops
 - Don't use MAP_* and PROT_* with thunk API since the kernel and host
   might not be the same; add THUNK_MAP_* and THUNK_PROT_* and translate them
 - Add thunk_posix_memalign
 - allocate mem_uvm with thunk_posix_memalign instead of thunk_malloc
 - Fix thunk_mmap callers to always pass either THUNK_MAP_PRIVATE or
   THUNK_MAP_SHARED
 - mkstemp on Linux requires exactly 6 X characters at the end of the
   template string, so add an X


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/conf/files.usermode
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/usermode/usermode/pmap.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/usermode/usermode/thunk.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/usermode/conf/Makefile.usermode
diff -u src/sys/arch/usermode/conf/Makefile.usermode:1.17 src/sys/arch/usermode/conf/Makefile.usermode:1.18
--- src/sys/arch/usermode/conf/Makefile.usermode:1.17	Sat Sep  3 15:00:27 2011
+++ src/sys/arch/usermode/conf/Makefile.usermode	Sat Sep  3 18:42:13 2011
@@ -1,6 +1,11 @@
-# $NetBSD: Makefile.usermode,v 1.17 2011/09/03 15:00:27 jmcneill Exp $
+# $NetBSD: Makefile.usermode,v 1.18 2011/09/03 18:42:13 jmcneill Exp $
 
+OPT_CPU_HOST=			%CPU_HOST%
+.if !empty(OPT_CPU_HOST)
+MACHINE_ARCH=			${OPT_CPU_HOST}
+.else
 MACHINE_ARCH=			usermode
+.endif
 USETOOLS?=			no
 NEED_OWN_INSTALL_TARGET?=	no
 .include bsd.own.mk
@@ -15,12 +20,17 @@
 ## (2) compile settings
 ##
 USERMODE_HOSTOS!=uname -s
+USERMODE_HOSTMACHINE!=uname -m
 USERMODE_LIBS=	-lrt
+USERMODE_CPPFLAGS=-U_KERNEL -I/usr/include
+USERMODE_CPPFLAGS+=${CWARNFLAGS} ${NOGCCERROR:D:U-Werror}
+
 .if ${USERMODE_HOSTOS} == Linux
 USERMODE_LIBS+=	-lpthread
+CPPFLAGS+=-Dstrtoul=netbsd_strtoul
+CPPFLAGS+=-Dstrtoll=netbsd_strtoll
+CPPFLAGS+=-Dstrtoull=netbsd_strtoull
 .endif
-USERMODE_CPPFLAGS=-U_KERNEL -I/usr/include
-USERMODE_CPPFLAGS+=${CWARNFLAGS} ${NOGCCERROR:D:U-Werror}
 
 DEFCOPTS=	-fno-omit-frame-pointer
 CPPFLAGS+=	-Dusermode -D__NetBSD__ -Wno-unused-but-set-variable
@@ -42,8 +52,8 @@
 ##
 ## (3) libkern and compat
 ##
-KERN_AS=	obj
-COMPAT_AS=	obj
+KERN_AS=	library
+COMPAT_AS=	library
 
 ##
 ## (4) local objects, compile rules, and dependencies

Index: src/sys/arch/usermode/conf/files.usermode
diff -u src/sys/arch/usermode/conf/files.usermode:1.8 src/sys/arch/usermode/conf/files.usermode:1.9
--- src/sys/arch/usermode/conf/files.usermode:1.8	Sat Sep  3 12:28:45 2011
+++ src/sys/arch/usermode/conf/files.usermode	Sat Sep  3 18:42:13 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.usermode,v 1.8 2011/09/03 12:28:45 jmcneill Exp $
+# $NetBSD: files.usermode,v 1.9 2011/09/03 18:42:13 jmcneill Exp $
 
 maxpartitions 8
 maxusers 8 16 64
@@ -6,6 +6,7 @@
 defparam opt_memsize.hMEMSIZE
 defflag opt_sdl.hSDL
 defflag opt_cpu.hCPU_DEBUG
+defparam opt_cpu.hCPU_HOST
 defflag opt_urkelvisor.h			URKELVISOR
 
 define	thunkbus { }

Index: src/sys/arch/usermode/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.24 src/sys/arch/usermode/include/thunk.h:1.25
--- src/sys/arch/usermode/include/thunk.h:1.24	Sat Sep  3 15:00:28 2011
+++ src/sys/arch/usermode/include/thunk.h	Sat Sep  3 18:42:13 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.24 2011/09/03 15:00:28 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.25 2011/09/03 18:42:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -35,7 +35,6 @@
 #include sys/fcntl.h
 #include sys/ucontext.h
 #include sys/signal.h
-#include sys/mman.h
 
 struct thunk_timeval {
 	int64_t tv_sec;
@@ -57,6 +56,17 @@
 	int32_t c_ospeed;
 };
 
+#define THUNK_MAP_ANON		0x0001
+#define THUNK_MAP_FIXED		0x0002
+#define THUNK_MAP_FILE		0x0004
+#define THUNK_MAP_SHARED	0x0010
+#define THUNK_MAP_PRIVATE	0x0020
+
+#define THUNK_PROT_NONE		0x00
+#define THUNK_PROT_READ		0x01
+#define THUNK_PROT_WRITE	0x02
+#define THUNK_PROT_EXEC		0x04
+
 struct aiocb;
 
 int	thunk_setitimer(int, const struct thunk_itimerval *, struct thunk_itimerval *);
@@ -108,6 +118,7 @@
 void *	thunk_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset);
 int	thunk_munmap(void *addr, size_t len);
 int	thunk_mprotect(void *addr, size_t len, int prot);
+int	thunk_posix_memalign(void **, size_t, size_t);
 
 char *	thunk_getenv(const char *);
 

Index: src/sys/arch/usermode/usermode/pmap.c
diff -u 

CVS commit: src/sys/arch/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 19:06:49 UTC 2011

Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode
src/sys/arch/usermode/dev: cpu.c

Log Message:
unbreak build on netbsd


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/usermode/dev/cpu.c

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

Modified files:

Index: src/sys/arch/usermode/conf/Makefile.usermode
diff -u src/sys/arch/usermode/conf/Makefile.usermode:1.18 src/sys/arch/usermode/conf/Makefile.usermode:1.19
--- src/sys/arch/usermode/conf/Makefile.usermode:1.18	Sat Sep  3 18:42:13 2011
+++ src/sys/arch/usermode/conf/Makefile.usermode	Sat Sep  3 19:06:48 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.usermode,v 1.18 2011/09/03 18:42:13 jmcneill Exp $
+# $NetBSD: Makefile.usermode,v 1.19 2011/09/03 19:06:48 jmcneill Exp $
 
 OPT_CPU_HOST=			%CPU_HOST%
 .if !empty(OPT_CPU_HOST)
@@ -30,10 +30,11 @@
 CPPFLAGS+=-Dstrtoul=netbsd_strtoul
 CPPFLAGS+=-Dstrtoll=netbsd_strtoll
 CPPFLAGS+=-Dstrtoull=netbsd_strtoull
+CPPFLAGS+=-D__NetBSD__ -Wno-unused-but-set-variable
 .endif
 
 DEFCOPTS=	-fno-omit-frame-pointer
-CPPFLAGS+=	-Dusermode -D__NetBSD__ -Wno-unused-but-set-variable
+CPPFLAGS+=	-Dusermode
 CPPFLAGS.init_main.c+=	-Dmain=kernmain
 
 OPT_SDL=	%SDL%

Index: src/sys/arch/usermode/dev/cpu.c
diff -u src/sys/arch/usermode/dev/cpu.c:1.26 src/sys/arch/usermode/dev/cpu.c:1.27
--- src/sys/arch/usermode/dev/cpu.c:1.26	Sat Sep  3 15:00:28 2011
+++ src/sys/arch/usermode/dev/cpu.c	Sat Sep  3 19:06:49 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.26 2011/09/03 15:00:28 jmcneill Exp $ */
+/* $NetBSD: cpu.c,v 1.27 2011/09/03 19:06:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include opt_cpu.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.26 2011/09/03 15:00:28 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.27 2011/09/03 19:06:49 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/conf.h
@@ -52,6 +52,12 @@
 #include uvm/uvm_extern.h
 #include uvm/uvm_page.h
 
+#if __GNUC_PREREQ__(4,4)
+#define cpu_unreachable()	__builtin_unreachable()
+#else
+#define cpu_unreachable()	do { thunk_abort(); } while (0)
+#endif
+
 static int	cpu_match(device_t, cfdata_t, void *);
 static void	cpu_attach(device_t, device_t, void *);
 
@@ -133,7 +139,7 @@
 	usermode_reboot();
 
 	/* NOTREACHED */
-	__builtin_unreachable();
+	cpu_unreachable();
 }
 
 void



CVS commit: src/sys/arch/usermode/dev

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 19:07:32 UTC 2011

Modified Files:
src/sys/arch/usermode/dev: ld_thunkbus.c

Log Message:
add a workaround for kern/45327


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/dev/ld_thunkbus.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/usermode/dev/ld_thunkbus.c
diff -u src/sys/arch/usermode/dev/ld_thunkbus.c:1.7 src/sys/arch/usermode/dev/ld_thunkbus.c:1.8
--- src/sys/arch/usermode/dev/ld_thunkbus.c:1.7	Sat Sep  3 15:00:28 2011
+++ src/sys/arch/usermode/dev/ld_thunkbus.c	Sat Sep  3 19:07:32 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_thunkbus.c,v 1.7 2011/09/03 15:00:28 jmcneill Exp $ */
+/* $NetBSD: ld_thunkbus.c,v 1.8 2011/09/03 19:07:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -26,8 +26,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define BROKEN_SIGINFO
+
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ld_thunkbus.c,v 1.7 2011/09/03 15:00:28 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: ld_thunkbus.c,v 1.8 2011/09/03 19:07:32 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/proc.h
@@ -69,6 +71,10 @@
 	struct ld_thunkbus_transfer sc_tt;
 };
 
+#ifdef BROKEN_SIGINFO
+struct ld_thunkbus_transfer *ld_thunkbus_tt;
+#endif
+
 CFATTACH_DECL_NEW(ld_thunkbus, sizeof(struct ld_thunkbus_softc),
 ld_thunkbus_match, ld_thunkbus_attach, NULL, NULL);
 
@@ -80,6 +86,12 @@
 	if (taa-taa_type != THUNKBUS_TYPE_DISKIMAGE)
 		return 0;
 
+#ifdef BROKEN_SIGINFO
+	/* We can only have one instance if siginfo doesn't work */
+	if (ld_thunkbus_tt != NULL)
+		return 0;
+#endif
+
 	return 1;
 }
 
@@ -105,6 +117,10 @@
 		return;
 	}
 
+#ifdef BROKEN_SIGINFO
+	ld_thunkbus_tt = sc-sc_tt;
+#endif
+
 	aprint_naive(\n);
 	aprint_normal(: %s (%lld)\n, path, (long long)size);
 
@@ -132,15 +148,22 @@
 static void
 ld_thunkbus_sig(int sig, siginfo_t *info, void *ctx)
 {
-	struct ld_thunkbus_transfer *tt;
+	struct ld_thunkbus_transfer *tt = NULL;
 	struct ld_thunkbus_softc *sc;
 
 	curcpu()-ci_idepth++;
 
 	if (info-si_signo == SIGIO) {
-		tt = info-si_value.sival_ptr;
-		sc = tt-tt_sc;
-		softint_schedule(sc-sc_ih);
+#ifdef BROKEN_SIGINFO
+		tt = ld_thunkbus_tt;
+#else
+		if (info-si_code == SI_ASYNCIO)
+			tt = info-si_value.sival_ptr;
+#endif
+		if (tt) {
+			sc = tt-tt_sc;
+			softint_schedule(sc-sc_ih);
+		}
 	}
 
 	curcpu()-ci_idepth--;



CVS commit: src/sys/kern

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 19:33:40 UTC 2011

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

Log Message:
PR/45327: Jared McNeill: ptrace: siginfo doesn't work with traced processes
When saving the signal in p-p_xstat, clear it from the pending mask, but
don't remove it from the siginfo queue, so that next time the debugger
delivers it, the original information is found.
When posting a signal from the debugger l-l_sigpendset is not set, so we
use the process pending signal and add it back to the process pending set.


To generate a diff of this commit:
cvs rdiff -u -r1.312 -r1.313 src/sys/kern/kern_sig.c

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

Modified files:

Index: src/sys/kern/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.312 src/sys/kern/kern_sig.c:1.313
--- src/sys/kern/kern_sig.c:1.312	Wed Aug 31 18:43:19 2011
+++ src/sys/kern/kern_sig.c	Sat Sep  3 15:33:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.312 2011/08/31 22:43:19 rmind Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.313 2011/09/03 19:33:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kern_sig.c,v 1.312 2011/08/31 22:43:19 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: kern_sig.c,v 1.313 2011/09/03 19:33:40 christos Exp $);
 
 #include opt_ptrace.h
 #include opt_compat_sunos.h
@@ -1850,8 +1850,12 @@
 		 */
 		if ((p-p_slflag  PSL_TRACED) != 0 
 		(p-p_lflag  PL_PPWAIT) == 0  signo != SIGKILL) {
-			/* Take the signal. */
-			(void)sigget(sp, NULL, signo, NULL);
+			/*
+			 * Take the signal, but don't remove it from the
+			 * siginfo queue, because the debugger can send
+			 * it later.
+			 */
+			sigdelset(sp-sp_set, signo);
 			p-p_xstat = signo;
 
 			/* Emulation-specific handling of signal trace */
@@ -1966,6 +1970,7 @@
 	sig_t		action;
 	sigset_t	*returnmask;
 	ksiginfo_t	ksi;
+	sigpend_t	*sp;
 
 	l = curlwp;
 	p = l-l_proc;
@@ -1993,7 +1998,12 @@
 	 */
 	action = SIGACTION_PS(ps, signo).sa_handler;
 	l-l_ru.ru_nsignals++;
-	sigget(l-l_sigpendset, ksi, signo, NULL);
+	if ((sp = l-l_sigpendset) == NULL) {
+		/* From the debugger */
+		sp = p-p_sigpend;
+		sigaddset(sp-sp_set, signo);
+	}
+	sigget(sp, ksi, signo, NULL);
 
 	if (ktrpoint(KTR_PSIG)) {
 		mutex_exit(p-p_lock);



CVS commit: src/sys/arch/usermode/dev

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 20:02:34 UTC 2011

Modified Files:
src/sys/arch/usermode/dev: ld_thunkbus.c

Log Message:
Now that pr45327 is fixed, remove BROKEN_SIGINFO code.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/dev/ld_thunkbus.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/usermode/dev/ld_thunkbus.c
diff -u src/sys/arch/usermode/dev/ld_thunkbus.c:1.8 src/sys/arch/usermode/dev/ld_thunkbus.c:1.9
--- src/sys/arch/usermode/dev/ld_thunkbus.c:1.8	Sat Sep  3 19:07:32 2011
+++ src/sys/arch/usermode/dev/ld_thunkbus.c	Sat Sep  3 20:02:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_thunkbus.c,v 1.8 2011/09/03 19:07:32 jmcneill Exp $ */
+/* $NetBSD: ld_thunkbus.c,v 1.9 2011/09/03 20:02:34 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -26,10 +26,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define BROKEN_SIGINFO
-
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ld_thunkbus.c,v 1.8 2011/09/03 19:07:32 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: ld_thunkbus.c,v 1.9 2011/09/03 20:02:34 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/proc.h
@@ -71,10 +69,6 @@
 	struct ld_thunkbus_transfer sc_tt;
 };
 
-#ifdef BROKEN_SIGINFO
-struct ld_thunkbus_transfer *ld_thunkbus_tt;
-#endif
-
 CFATTACH_DECL_NEW(ld_thunkbus, sizeof(struct ld_thunkbus_softc),
 ld_thunkbus_match, ld_thunkbus_attach, NULL, NULL);
 
@@ -86,12 +80,6 @@
 	if (taa-taa_type != THUNKBUS_TYPE_DISKIMAGE)
 		return 0;
 
-#ifdef BROKEN_SIGINFO
-	/* We can only have one instance if siginfo doesn't work */
-	if (ld_thunkbus_tt != NULL)
-		return 0;
-#endif
-
 	return 1;
 }
 
@@ -117,10 +105,6 @@
 		return;
 	}
 
-#ifdef BROKEN_SIGINFO
-	ld_thunkbus_tt = sc-sc_tt;
-#endif
-
 	aprint_naive(\n);
 	aprint_normal(: %s (%lld)\n, path, (long long)size);
 
@@ -154,12 +138,8 @@
 	curcpu()-ci_idepth++;
 
 	if (info-si_signo == SIGIO) {
-#ifdef BROKEN_SIGINFO
-		tt = ld_thunkbus_tt;
-#else
 		if (info-si_code == SI_ASYNCIO)
 			tt = info-si_value.sival_ptr;
-#endif
 		if (tt) {
 			sc = tt-tt_sc;
 			softint_schedule(sc-sc_ih);



CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-09-03 Thread Michael L. Hitch
Module Name:src
Committed By:   mhitch
Date:   Sun Sep  4 01:15:14 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: xengnt.c

Log Message:
Use a mutex to protect updates to gnt_entries.  Fixes a KASSERT panic
with an MP kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.18.2.1 -r1.18.2.2 src/sys/arch/xen/xen/xengnt.c

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

Modified files:

Index: src/sys/arch/xen/xen/xengnt.c
diff -u src/sys/arch/xen/xen/xengnt.c:1.18.2.1 src/sys/arch/xen/xen/xengnt.c:1.18.2.2
--- src/sys/arch/xen/xen/xengnt.c:1.18.2.1	Thu Jun 23 14:19:50 2011
+++ src/sys/arch/xen/xen/xengnt.c	Sun Sep  4 01:15:13 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: xengnt.c,v 1.18.2.1 2011/06/23 14:19:50 cherry Exp $  */
+/*  $NetBSD: xengnt.c,v 1.18.2.2 2011/09/04 01:15:13 mhitch Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xengnt.c,v 1.18.2.1 2011/06/23 14:19:50 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: xengnt.c,v 1.18.2.2 2011/09/04 01:15:13 mhitch Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -35,6 +35,7 @@
 #include sys/queue.h
 #include sys/extent.h
 #include sys/kernel.h
+#include sys/mutex.h
 #include uvm/uvm.h
 
 #include xen/hypervisor.h
@@ -62,6 +63,8 @@
 /* empty entry in the list */
 #define XENGNT_NO_ENTRY 0x
 
+static kmutex_t	gnt_mutex;
+
 /* VM address of the grant table */
 grant_entry_t *grant_table;
 
@@ -101,6 +104,7 @@
 		gnt_entries[i] = XENGNT_NO_ENTRY;
 
 	last_gnt_entry = 0;
+	mutex_init(gnt_mutex, MUTEX_DEFAULT, IPL_VM);
 	xengnt_resume();
 
 }
@@ -192,13 +196,13 @@
 xengnt_get_entry(void)
 {
 	grant_ref_t entry;
-	int s = splvm();
 	static struct timeval xengnt_nonmemtime;
 	static const struct timeval xengnt_nonmemintvl = {5,0};
 
+	mutex_enter(gnt_mutex);
 	if (last_gnt_entry == 0) {
 		if (xengnt_more_entries()) {
-			splx(s);
+			mutex_exit(gnt_mutex);
 			if (ratecheck(xengnt_nonmemtime, xengnt_nonmemintvl))
 printf(xengnt_get_entry: out of grant 
 table entries\n);
@@ -209,7 +213,7 @@
 	last_gnt_entry--;
 	entry = gnt_entries[last_gnt_entry];
 	gnt_entries[last_gnt_entry] = XENGNT_NO_ENTRY;
-	splx(s);
+	mutex_exit(gnt_mutex);
 	KASSERT(entry != XENGNT_NO_ENTRY);
 	KASSERT(last_gnt_entry = 0);
 	KASSERT(last_gnt_entry = gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE);
@@ -222,13 +226,13 @@
 static void
 xengnt_free_entry(grant_ref_t entry)
 {
-	int s = splvm();
+	mutex_enter(gnt_mutex);
 	KASSERT(gnt_entries[last_gnt_entry] == XENGNT_NO_ENTRY);
 	KASSERT(last_gnt_entry = 0);
 	KASSERT(last_gnt_entry = gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE);
 	gnt_entries[last_gnt_entry] = entry;
 	last_gnt_entry++;
-	splx(s);
+	mutex_exit(gnt_mutex);
 }
 
 int



CVS commit: src/usr.bin/tail

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 09:02:20 UTC 2011

Modified Files:
src/usr.bin/tail: extern.h forward.c misc.c read.c reverse.c tail.c

Log Message:
Instead of declaring our own err() which is different than the standard one,
and using it incorrectly in a few places because of confusion (does it print
errno or not?), declare two versions following the standard ones xerrx and,
xerr, and use those as appropriate, implementing them using them vwarn and
vwarnx.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/tail/extern.h
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/tail/forward.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/tail/misc.c
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/tail/read.c
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/tail/reverse.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/tail/tail.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

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 10:28:33 UTC 2011

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

Log Message:
We need to process SA_STOP signals immediately, and not deliver them to
the process. Instead of re-structuring the code to do that, call issignal()
like before in that case. (tail -F /file^Zfg should not get interrupted).


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/kern_sleepq.c

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



CVS commit: src/usr.bin/tail

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 10:35:13 UTC 2011

Modified Files:
src/usr.bin/tail: reverse.c

Log Message:
leave the original errno as it was. don't report EFBIG on all mmap failures.


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

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



CVS commit: src/usr.bin/tail

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 10:59:11 UTC 2011

Modified Files:
src/usr.bin/tail: forward.c read.c reverse.c tail.c

Log Message:
minor knf, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/tail/forward.c
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/tail/read.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/tail/reverse.c
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/tail/tail.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/usermode/dev

2011-09-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Sep  3 12:25:31 UTC 2011

Modified Files:
src/sys/arch/usermode/dev: cpu.c

Log Message:
Oops forgot to commit this one


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/usermode/dev/cpu.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/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 12:28:46 UTC 2011

Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode files.usermode
std.usermode
src/sys/arch/usermode/usermode: pmap.c
Added Files:
src/sys/arch/usermode/include: urkelvisor.h
src/sys/arch/usermode/usermode: urkelvisor.c

Log Message:
Add usermode kernel supervisor, can be disabled with 'no options URKELVISOR'


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/conf/files.usermode
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/usermode/conf/std.usermode
cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/include/urkelvisor.h
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/usermode/usermode/pmap.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/usermode/urkelvisor.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/usermode/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 12:33:03 UTC 2011

Modified Files:
src/sys/arch/usermode/usermode: machdep.c pmap.c

Log Message:
move call of urkelvisor_init to main instead of pmap_bootstrap


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/usermode/usermode/pmap.c

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



CVS commit: src/usr.bin/fstat

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 13:22:56 UTC 2011

Modified Files:
src/usr.bin/fstat: fstat.1

Log Message:
Mention that fstat -f will not list open unix sockets on that filesystem.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/fstat/fstat.1

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



CVS commit: src/usr.bin/fstat

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 13:24:19 UTC 2011

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

Log Message:
- minor KNF
- for system processes (0, 1) where fd_lastfile == -1, fail early.
- instead of printing the pcb connection address, print the pathname if
  possible for unix domain sockets.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/fstat/fstat.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

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 14:09:03 UTC 2011

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

Log Message:
Make sure that we initialize all accounting bytes.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/kern/kern_acct.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/usermode/include

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 14:23:50 UTC 2011

Modified Files:
src/sys/arch/usermode/include: asm.h bswap.h byte_swap.h disklabel.h
elf_machdep.h endian.h endian_machdep.h int_const.h int_fmtio.h
int_limits.h int_mwgwtypes.h int_types.h limits.h
netbsd32_machdep.h param.h ptrace.h wchar_limits.h
Added Files:
src/sys/arch/usermode/include: Makefile.headers genheaders.sh

Log Message:
Instead of doing #include /usr/include/machine/.., use the headers
that ship with the kernel sources as #include ../../$host/include/$hdr,
and auto-generate these ugly headers with a script.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/include/Makefile.headers \
src/sys/arch/usermode/include/genheaders.sh
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/include/asm.h \
src/sys/arch/usermode/include/bswap.h \
src/sys/arch/usermode/include/byte_swap.h \
src/sys/arch/usermode/include/elf_machdep.h \
src/sys/arch/usermode/include/endian.h \
src/sys/arch/usermode/include/endian_machdep.h \
src/sys/arch/usermode/include/int_const.h \
src/sys/arch/usermode/include/int_fmtio.h \
src/sys/arch/usermode/include/int_limits.h \
src/sys/arch/usermode/include/int_mwgwtypes.h \
src/sys/arch/usermode/include/int_types.h \
src/sys/arch/usermode/include/limits.h \
src/sys/arch/usermode/include/netbsd32_machdep.h \
src/sys/arch/usermode/include/param.h \
src/sys/arch/usermode/include/wchar_limits.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/include/disklabel.h \
src/sys/arch/usermode/include/ptrace.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/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 15:00:28 UTC 2011

Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode
src/sys/arch/usermode/dev: cpu.c ld_thunkbus.c
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: machdep.c thunk.c trap.c urkelvisor.c

Log Message:
Get this compiling (but not quite linking yet) on Linux


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/usermode/dev/cpu.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/usermode/dev/ld_thunkbus.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/usermode/usermode/thunk.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/usermode/usermode/trap.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/usermode/urkelvisor.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/usermode/usermode

2011-09-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Sep  3 15:33:56 UTC 2011

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

Log Message:
Add SIGILL handler, doing nothing than printing out details.
Move the address check to be done later so pmap and uvm have their go first.

Also some minor cosmetic fixes


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/usermode/usermode/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/dev/usb

2011-09-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep  3 16:19:47 UTC 2011

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

Log Message:
Correct vendor code for Kingston DT101 G2


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

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



CVS commit: src/sys/dev/usb

2011-09-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep  3 16:21:18 UTC 2011

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
Regenerate for Kingston DT101 G2


To generate a diff of this commit:
cvs rdiff -u -r1.586 -r1.587 src/sys/dev/usb/usbdevs.h
cvs rdiff -u -r1.587 -r1.588 src/sys/dev/usb/usbdevs_data.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/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 18:42:13 UTC 2011

Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode files.usermode
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: pmap.c thunk.c

Log Message:
Let NetBSD/usermode build  link on a Linux host:
 - Need to add options CPU_HOST=i386 or CPU_HOST=amd64 for membar  atomic_ops
 - Don't use MAP_* and PROT_* with thunk API since the kernel and host
   might not be the same; add THUNK_MAP_* and THUNK_PROT_* and translate them
 - Add thunk_posix_memalign
 - allocate mem_uvm with thunk_posix_memalign instead of thunk_malloc
 - Fix thunk_mmap callers to always pass either THUNK_MAP_PRIVATE or
   THUNK_MAP_SHARED
 - mkstemp on Linux requires exactly 6 X characters at the end of the
   template string, so add an X


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/conf/files.usermode
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/usermode/usermode/pmap.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/usermode/usermode/thunk.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/usermode

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 19:06:49 UTC 2011

Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode
src/sys/arch/usermode/dev: cpu.c

Log Message:
unbreak build on netbsd


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/usermode/dev/cpu.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/usermode/dev

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 19:07:32 UTC 2011

Modified Files:
src/sys/arch/usermode/dev: ld_thunkbus.c

Log Message:
add a workaround for kern/45327


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/dev/ld_thunkbus.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

2011-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep  3 19:33:40 UTC 2011

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

Log Message:
PR/45327: Jared McNeill: ptrace: siginfo doesn't work with traced processes
When saving the signal in p-p_xstat, clear it from the pending mask, but
don't remove it from the siginfo queue, so that next time the debugger
delivers it, the original information is found.
When posting a signal from the debugger l-l_sigpendset is not set, so we
use the process pending signal and add it back to the process pending set.


To generate a diff of this commit:
cvs rdiff -u -r1.312 -r1.313 src/sys/kern/kern_sig.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/usermode/dev

2011-09-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Sep  3 20:02:34 UTC 2011

Modified Files:
src/sys/arch/usermode/dev: ld_thunkbus.c

Log Message:
Now that pr45327 is fixed, remove BROKEN_SIGINFO code.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/dev/ld_thunkbus.c

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