Re: CVS commit: src/sys/compat/sys

2011-12-20 Thread Alan Barrett

On Tue, 20 Dec 2011, Matthias Drochner wrote:

Module Name:src
Committed By:   drochner
Date:   Tue Dec 20 16:38:06 UTC 2011

Modified Files:
src/sys/compat/sys: rnd.h

Log Message:
allow kernels w/o COMPAT_50 to build


What was the actual problem?  Nothing defined by this file is supposed
to be used in a kernel without COMPAT_50; if something is being used
accidentally then I'd like to fix that.

--apb (Alan Barrett)


Re: CVS commit: src/sys/compat/sys

2011-12-20 Thread Alan Barrett

On Tue, 20 Dec 2011, Alan Barrett wrote:

On Tue, 20 Dec 2011, Matthias Drochner wrote:

Modified Files:
src/sys/compat/sys: rnd.h
Log Message:
allow kernels w/o COMPAT_50 to build


What was the actual problem?  Nothing defined by this file is 
supposed to be used in a kernel without COMPAT_50; if something 
is being used accidentally then I'd like to fix that.


OK, I found it.  rndpseudo_50.o is unconditionally compiled and 
added to libcompat in the kernel build directory.  Everything else 
in sys/compat/common is handled in the same way.


I am inclined to wrap most of the contents of 
compat/common/rndpseudo_50.c and compat/sys/rnd.h in #ifdef 
COMPAT_50 guards, although other files in compat/common and 
compat/sys do not seem to do this.


--apb (Alan Barrett)


Re: CVS commit: src

2011-12-20 Thread Joerg Sonnenberger
On which mailling list was this change discussed?

Joerg

On Tue, Dec 20, 2011 at 03:39:36PM +, Reinoud Zandijk wrote:
 Module Name:  src
 Committed By: reinoud
 Date: Tue Dec 20 15:39:36 UTC 2011
 
 Modified Files:
   src/lib/libc/sys: mmap.2
   src/sys/sys: mman.h proc.h
   src/sys/uvm: uvm_extern.h uvm_map.c uvm_mmap.c
 
 Log Message:
 Add a MAP_NOSYSCALLS flag to mmap. This flag prohibits executing of system
 calls from the mapped region. This can be used for emulation perposed or for
 extra security in the case of generated code.
 
 Its implemented by adding mapping-attributes to each uvm_map_entry. These can
 then be queried when needed.
 
 Currently the MAP_NOSYSCALLS is only implemented for x86 but other
 architectures are easy to adapt; see the sys/arch/x86/x86/syscall.c patch.
 Port maintainers are encouraged to add them for their processor ports too.
 When this feature is not yet implemented for an architecture the
 MAP_NOSYSCALLS is simply ignored with virtually no cpu cost..
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.44 -r1.45 src/lib/libc/sys/mmap.2
 cvs rdiff -u -r1.42 -r1.43 src/sys/sys/mman.h
 cvs rdiff -u -r1.311 -r1.312 src/sys/sys/proc.h
 cvs rdiff -u -r1.176 -r1.177 src/sys/uvm/uvm_extern.h
 cvs rdiff -u -r1.307 -r1.308 src/sys/uvm/uvm_map.c
 cvs rdiff -u -r1.139 -r1.140 src/sys/uvm/uvm_mmap.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.
 


Re: CVS commit: src

2011-12-20 Thread David Young
On Tue, Dec 20, 2011 at 03:39:36PM +, Reinoud Zandijk wrote:
 Currently the MAP_NOSYSCALLS is only implemented for x86 but other
 architectures are easy to adapt; see the sys/arch/x86/x86/syscall.c patch.
 Port maintainers are encouraged to add them for their processor ports too.
 When this feature is not yet implemented for an architecture the
 MAP_NOSYSCALLS is simply ignored with virtually no cpu cost..

If MAP_NOSYSCALLS is not implemented, perhaps mmap(2) should fail with
EOPNOTSUPP?  After all, the program that uses MAP_NOSYSCALLS probably
depends on it to work.

Dave

-- 
David Young
dyo...@pobox.comUrbana, IL(217) 721-9981


Re: CVS commit: src

2011-12-20 Thread Valeriy E. Ushakov
On Tue, Dec 20, 2011 at 19:22:12 +0100, Joerg Sonnenberger wrote:

 On which mailling list was this change discussed?

I guess this is for the usermode kernel, which design has also never
been discussed.


 On Tue, Dec 20, 2011 at 03:39:36PM +, Reinoud Zandijk wrote:
  Module Name:src
  Committed By:   reinoud
  Date:   Tue Dec 20 15:39:36 UTC 2011
  
  Modified Files:
  src/lib/libc/sys: mmap.2
  src/sys/sys: mman.h proc.h
  src/sys/uvm: uvm_extern.h uvm_map.c uvm_mmap.c
  
  Log Message:
  Add a MAP_NOSYSCALLS flag to mmap. This flag prohibits executing of system
  calls from the mapped region. This can be used for emulation perposed or for
  extra security in the case of generated code.
  
  Its implemented by adding mapping-attributes to each uvm_map_entry. These 
  can
  then be queried when needed.
  
  Currently the MAP_NOSYSCALLS is only implemented for x86 but other
  architectures are easy to adapt; see the sys/arch/x86/x86/syscall.c patch.
  Port maintainers are encouraged to add them for their processor ports too.
  When this feature is not yet implemented for an architecture the
  MAP_NOSYSCALLS is simply ignored with virtually no cpu cost..
  
  
  To generate a diff of this commit:
  cvs rdiff -u -r1.44 -r1.45 src/lib/libc/sys/mmap.2
  cvs rdiff -u -r1.42 -r1.43 src/sys/sys/mman.h
  cvs rdiff -u -r1.311 -r1.312 src/sys/sys/proc.h
  cvs rdiff -u -r1.176 -r1.177 src/sys/uvm/uvm_extern.h
  cvs rdiff -u -r1.307 -r1.308 src/sys/uvm/uvm_map.c
  cvs rdiff -u -r1.139 -r1.140 src/sys/uvm/uvm_mmap.c
  
  Please note that diffs are not public domain; they are subject to the
  copyright notices on the relevant files.
  

-uwe


Re: CVS commit: src

2011-12-20 Thread Jean-Yves Migeon

On 20.12.2011 16:39, Reinoud Zandijk wrote:

Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:39:36 UTC 2011

Modified Files:
src/lib/libc/sys: mmap.2
src/sys/sys: mman.h proc.h
src/sys/uvm: uvm_extern.h uvm_map.c uvm_mmap.c

Log Message:
Add a MAP_NOSYSCALLS flag to mmap. This flag prohibits executing of system
calls from the mapped region. This can be used for emulation perposed or for
extra security in the case of generated code.


IMHO, this change should have been discussed first.

Can you please elaborate on its usage? I fail to see the point about 
emulation, and even more so about the alleged extra security where this 
can be trivially bypassed. Return to libfoo and ROP are quite mainstream 
techniques these days...


--
Jean-Yves Migeon
j...@netbsd.org


Re: CVS commit: src

2011-12-20 Thread Simon Burge
Joerg Sonnenberger wrote:

 On which mailling list was this change discussed?

One thing that jumps out: Should this new code panic in sys_mmap() if it
can't handle a request instead of just failing the request?  That seems
a little ... heavy handed.

Please also stick to KNF (#defineTAB), especially when you add
something to the middle of an existing block of #defines (eg
sys/proc.h).

Cheers,
Simon.

 
 On Tue, Dec 20, 2011 at 03:39:36PM +, Reinoud Zandijk wrote:
  Module Name:src
  Committed By:   reinoud
  Date:   Tue Dec 20 15:39:36 UTC 2011
  
  Modified Files:
  src/lib/libc/sys: mmap.2
  src/sys/sys: mman.h proc.h
  src/sys/uvm: uvm_extern.h uvm_map.c uvm_mmap.c
  
  Log Message:
  Add a MAP_NOSYSCALLS flag to mmap. This flag prohibits executing of system
  calls from the mapped region. This can be used for emulation perposed or for
  extra security in the case of generated code.
  
  Its implemented by adding mapping-attributes to each uvm_map_entry. These 
  can
  then be queried when needed.
  
  Currently the MAP_NOSYSCALLS is only implemented for x86 but other
  architectures are easy to adapt; see the sys/arch/x86/x86/syscall.c patch.
  Port maintainers are encouraged to add them for their processor ports too.
  When this feature is not yet implemented for an architecture the
  MAP_NOSYSCALLS is simply ignored with virtually no cpu cost..
  
  
  To generate a diff of this commit:
  cvs rdiff -u -r1.44 -r1.45 src/lib/libc/sys/mmap.2
  cvs rdiff -u -r1.42 -r1.43 src/sys/sys/mman.h
  cvs rdiff -u -r1.311 -r1.312 src/sys/sys/proc.h
  cvs rdiff -u -r1.176 -r1.177 src/sys/uvm/uvm_extern.h
  cvs rdiff -u -r1.307 -r1.308 src/sys/uvm/uvm_map.c
  cvs rdiff -u -r1.139 -r1.140 src/sys/uvm/uvm_mmap.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

2011-12-20 Thread tsugutomo . enami
Christos Zoulas chris...@netbsd.org writes:

 Log Message:
 - Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.

It looks like fstat is using so_pcb offset directly while netstat uses
sysctl to get list of pcbs.  systat uses so_snd/rcv.  I guess it is
better not to change the layout of struct socket for compatibility,
doesn't it?

enami.


Re: CVS commit: src

2011-12-20 Thread David Holland
On Wed, Dec 21, 2011 at 12:13:50AM +0400, Valeriy E. Ushakov wrote:
   On which mailling list was this change discussed?
  
  I guess this is for the usermode kernel, which design has also never
  been discussed.

Sure, but changes to fundamental APIs are supposed to not only be
discussed to death but also approved by core... can we revert this
until that's been done?

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys

2011-12-20 Thread YAMAMOTO Takashi
hi,

 Module Name:  src
 Committed By: christos
 Date: Tue Dec 20 23:56:29 UTC 2011
 
 Modified Files:
   src/sys/compat/linux/common: linux_socket.c
   src/sys/dev: kttcp.c
   src/sys/kern: sys_socket.c uipc_socket.c uipc_socket2.c uipc_syscalls.c
   src/sys/miscfs/fifofs: fifo_vnops.c
   src/sys/netiso: tp_usrreq.c
   src/sys/sys: socket.h socketvar.h
 
 Log Message:
 - Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.

why?
i thought the reason of having this as a separate member was performance.

YAMAMOTO Takashi

 - Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
 - Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
 - Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
   errors?).
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.110 -r1.111 src/sys/compat/linux/common/linux_socket.c
 cvs rdiff -u -r1.28 -r1.29 src/sys/dev/kttcp.c
 cvs rdiff -u -r1.64 -r1.65 src/sys/kern/sys_socket.c
 cvs rdiff -u -r1.205 -r1.206 src/sys/kern/uipc_socket.c
 cvs rdiff -u -r1.109 -r1.110 src/sys/kern/uipc_socket2.c
 cvs rdiff -u -r1.148 -r1.149 src/sys/kern/uipc_syscalls.c
 cvs rdiff -u -r1.70 -r1.71 src/sys/miscfs/fifofs/fifo_vnops.c
 cvs rdiff -u -r1.40 -r1.41 src/sys/netiso/tp_usrreq.c
 cvs rdiff -u -r1.100 -r1.101 src/sys/sys/socket.h
 cvs rdiff -u -r1.126 -r1.127 src/sys/sys/socketvar.h
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


CVS commit: src/doc

2011-12-20 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Tue Dec 20 11:18:36 UTC 2011

Modified Files:
src/doc: 3RDPARTY

Log Message:
note new OpenPAM release


To generate a diff of this commit:
cvs rdiff -u -r1.891 -r1.892 src/doc/3RDPARTY

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.891 src/doc/3RDPARTY:1.892
--- src/doc/3RDPARTY:1.891	Thu Dec  8 01:11:47 2011
+++ src/doc/3RDPARTY	Tue Dec 20 11:18:35 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.891 2011/12/08 01:11:47 taca Exp $
+#	$NetBSD: 3RDPARTY,v 1.892 2011/12/20 11:18:35 drochner Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -749,8 +749,8 @@ Notes:
 Imported into src/external/bsd/openldap/dist/
 
 Package:	OpenPAM
-Version:	20071221
-Current Vers:	20071221
+Version:	20111218 (Lycopsida)
+Current Vers:	20071221 (Hydrangea)
 Maintainer:	Dag-Erling Smørgrav d...@freebsd.org
 Archive Site:	http://www.openpam.org/
 Home Page:	http://www.openpam.org/



CVS commit: src/sys/dev

2011-12-20 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Tue Dec 20 12:45:00 UTC 2011

Modified Files:
src/sys/dev: rndpseudo.c

Log Message:
#include opt_compat_netbsd.h


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/rndpseudo.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/rndpseudo.c
diff -u src/sys/dev/rndpseudo.c:1.4 src/sys/dev/rndpseudo.c:1.5
--- src/sys/dev/rndpseudo.c:1.4	Mon Dec 19 21:53:52 2011
+++ src/sys/dev/rndpseudo.c	Tue Dec 20 12:45:00 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rndpseudo.c,v 1.4 2011/12/19 21:53:52 apb Exp $	*/
+/*	$NetBSD: rndpseudo.c,v 1.5 2011/12/20 12:45:00 apb Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,11 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rndpseudo.c,v 1.4 2011/12/19 21:53:52 apb Exp $);
+__KERNEL_RCSID(0, $NetBSD: rndpseudo.c,v 1.5 2011/12/20 12:45:00 apb Exp $);
+
+#if defined(_KERNEL_OPT)
+#include opt_compat_netbsd.h
+#endif
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h



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

2011-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 13:17:05 UTC 2011

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

Log Message:
from 
http://www.freshbsd.org/commit/openbsd/ae7f934ae5bdf57dcf3431ba55fd1da93b8f1963

Initialize abridged tag word properly. x87 spec says FNINIT says tag word
contains h (all stack locations empty) which would make abridged tag
word 00h. From the Intel 64 and IA-32 Architectures Software Developer's
Manual:

The FXSAVE instruction saves an abridged version of the x87 FPU tag word
in the FTW field (unlike the FSAVE instruction, which saves the complete
tag word). The tag information is saved in physical register order (R0
through R7), rather than in top-of- stack (TOS) order. With the FXSAVE
instruction, however, only a single bit (1 for valid or 0 for empty) is
saved for each tag.

ok rmind@


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/amd64/amd64/process_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/amd64/amd64/process_machdep.c
diff -u src/sys/arch/amd64/amd64/process_machdep.c:1.18 src/sys/arch/amd64/amd64/process_machdep.c:1.19
--- src/sys/arch/amd64/amd64/process_machdep.c:1.18	Mon Dec 20 00:25:24 2010
+++ src/sys/arch/amd64/amd64/process_machdep.c	Tue Dec 20 13:17:05 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.18 2010/12/20 00:25:24 matt Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.19 2011/12/20 13:17:05 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: process_machdep.c,v 1.18 2010/12/20 00:25:24 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: process_machdep.c,v 1.19 2011/12/20 13:17:05 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -124,7 +124,7 @@ process_read_fpregs(struct lwp *l, struc
 		memset(frame, 0, sizeof(*regs));
 		frame-fx_fcw = cw;
 		frame-fx_fsw = 0x;
-		frame-fx_ftw = 0xff;
+		frame-fx_ftw = 0x00;	/* abridged tag; all empty */
 		frame-fx_mxcsr = mxcsr;
 		frame-fx_mxcsr_mask = mxcsr_mask;
 		l-l_md.md_flags |= MDP_USEDFPU;



CVS commit: src/sys/dev

2011-12-20 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Tue Dec 20 13:42:19 UTC 2011

Modified Files:
src/sys/dev: rndpseudo.c

Log Message:
Revert previous; the #include was already present, and I got confused
by a merge error.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/rndpseudo.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/rndpseudo.c
diff -u src/sys/dev/rndpseudo.c:1.5 src/sys/dev/rndpseudo.c:1.6
--- src/sys/dev/rndpseudo.c:1.5	Tue Dec 20 12:45:00 2011
+++ src/sys/dev/rndpseudo.c	Tue Dec 20 13:42:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rndpseudo.c,v 1.5 2011/12/20 12:45:00 apb Exp $	*/
+/*	$NetBSD: rndpseudo.c,v 1.6 2011/12/20 13:42:19 apb Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -30,11 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rndpseudo.c,v 1.5 2011/12/20 12:45:00 apb Exp $);
-
-#if defined(_KERNEL_OPT)
-#include opt_compat_netbsd.h
-#endif
+__KERNEL_RCSID(0, $NetBSD: rndpseudo.c,v 1.6 2011/12/20 13:42:19 apb Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_compat_netbsd.h



CVS commit: [yamt-pagecache] src/sys

2011-12-20 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Tue Dec 20 13:46:17 UTC 2011

Modified Files:
src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c
src/sys/uvm [yamt-pagecache]: uvm_extern.h uvm_vnode.c

Log Message:
don't inline uvn_findpages in genfs_io.


To generate a diff of this commit:
cvs rdiff -u -r1.53.2.5 -r1.53.2.6 src/sys/miscfs/genfs/genfs_io.c
cvs rdiff -u -r1.176.2.4 -r1.176.2.5 src/sys/uvm/uvm_extern.h
cvs rdiff -u -r1.97.2.2 -r1.97.2.3 src/sys/uvm/uvm_vnode.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/miscfs/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.53.2.5 src/sys/miscfs/genfs/genfs_io.c:1.53.2.6
--- src/sys/miscfs/genfs/genfs_io.c:1.53.2.5	Wed Nov 30 14:31:29 2011
+++ src/sys/miscfs/genfs/genfs_io.c	Tue Dec 20 13:46:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.53.2.5 2011/11/30 14:31:29 yamt Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.53.2.6 2011/12/20 13:46:17 yamt Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.53.2.5 2011/11/30 14:31:29 yamt Exp $);
+__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.53.2.6 2011/12/20 13:46:17 yamt Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -217,7 +217,8 @@ startover:
 		}
 #endif /* defined(DEBUG) */
 		nfound = uvn_findpages(uobj, origoffset, npages,
-		ap-a_m, UFP_NOWAIT|UFP_NOALLOC|(memwrite ? UFP_NORDONLY : 0));
+		ap-a_m, NULL,
+		UFP_NOWAIT|UFP_NOALLOC|(memwrite ? UFP_NORDONLY : 0));
 		KASSERT(npages == *ap-a_count);
 		if (nfound == 0) {
 			error = EBUSY;
@@ -343,7 +344,7 @@ startover:
 		goto startover;
 	}
 
-	if (uvn_findpages(uobj, origoffset, npages, pgs[ridx],
+	if (uvn_findpages(uobj, origoffset, npages, pgs[ridx], NULL,
 	async ? UFP_NOWAIT : UFP_ALL) != orignmempages) {
 		if (!glocked) {
 			genfs_node_unlock(vp);
@@ -430,7 +431,7 @@ startover:
 		UVMHIST_LOG(ubchist, reset npages start 0x%x end 0x%x,
 		startoffset, endoffset, 0,0);
 		npgs = npages;
-		if (uvn_findpages(uobj, startoffset, npgs, pgs,
+		if (uvn_findpages(uobj, startoffset, npgs, pgs, NULL,
 		async ? UFP_NOWAIT : UFP_ALL) != npages) {
 			if (!glocked) {
 genfs_node_unlock(vp);
@@ -856,7 +857,8 @@ genfs_do_putpages(struct vnode *vp, off_
 	off_t off;
 	/* Even for strange MAXPHYS, the shift rounds down to a page */
 #define maxpages (MAXPHYS  PAGE_SHIFT)
-	int i, error, npages, nback;
+	int i, error;
+	unsigned int npages, nback;
 	int freeflag;
 	struct vm_page *pgs[maxpages], *pg;
 	struct uvm_page_array a;
@@ -1088,6 +1090,9 @@ retry:
 		 */
 
 		if (needs_clean) {
+			unsigned int nforw;
+			unsigned int fpflags;
+
 			KDASSERT((vp-v_iflag  VI_ONWORKLST));
 			wasclean = false;
 			memset(pgs, 0, sizeof(pgs));
@@ -1095,17 +1100,25 @@ retry:
 			UVM_PAGE_OWN(pg, genfs_putpages);
 
 			/*
-			 * first look backward.
-			 *
-			 * XXX implement PG_PAGER1 incompatibility check.
+			 * XXX PG_PAGER1 incompatibility check.
+			 * this is a kludge for nfs.
 			 * probably it's better to make PG_NEEDCOMMIT a first
 			 * level citizen for uvm/genfs.
 			 */
+			fpflags = UFP_NOWAIT|UFP_NOALLOC|UFP_DIRTYONLY;
+			if ((pg-flags  PG_PAGER1) != 0) {
+fpflags |= UFP_ONLYPAGER1;
+			} else {
+fpflags |= UFP_NOPAGER1;
+			}
 
+			/*
+			 * first look backward.
+			 */
 			npages = MIN(maxpages  1, off  PAGE_SHIFT);
 			nback = npages;
 			uvn_findpages(uobj, off - PAGE_SIZE, nback, pgs[0],
-			UFP_NOWAIT|UFP_NOALLOC|UFP_DIRTYONLY|UFP_BACKWARD);
+			NULL, fpflags | UFP_BACKWARD);
 			if (nback) {
 memmove(pgs[0], pgs[npages - nback],
 nback * sizeof(pgs[0]));
@@ -1126,58 +1139,15 @@ retry:
 			/*
 			 * then look forward to fill in the remaining space in
 			 * the array of pages.
+			 *
+			 * pass our cached array of pages so that hopefully
+			 * uvn_findpages can find some good pages in it.
 			 */
 
-			for (npages = 1; npages  maxpages; npages++) {
-struct vm_page *nextpg;
-
-/*
- * regardless of the value of dirtyonly,
- * we don't need to care about clean pages here
- * as we will drop the object lock to call
- * GOP_WRITE and thus need to clear the array
- * before the next iteration anyway.
- */
-
-nextpg = uvm_page_array_fill_and_peek(a, uobj,
-pgs[npages - 1]-offset + PAGE_SIZE,
-maxpages - npages,
-UVM_PAGE_ARRAY_FILL_DIRTYONLY |
-UVM_PAGE_ARRAY_FILL_DENSE);
-if (nextpg == NULL) {
-	break;
-}
-KASSERT(nextpg-uobject == pg-uobject);
-KASSERT(nextpg-offset  pg-offset);
-KASSERT(nextpg-offset 
-pgs[npages - 1]-offset);
-if (pgs[npages - 1]-offset + PAGE_SIZE !=
-nextpg-offset) {
-	break;
-}
-if ((nextpg-flags  PG_BUSY) != 0) {
-	break;
-}
-
-/*
- * don't bother to cluster incompatible pages
- * together.
- *
- * XXX hack 

CVS commit: src/sys/uvm

2011-12-20 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Tue Dec 20 13:47:38 UTC 2011

Modified Files:
src/sys/uvm: uvm_map.c

Log Message:
comment and assertion


To generate a diff of this commit:
cvs rdiff -u -r1.306 -r1.307 src/sys/uvm/uvm_map.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/uvm/uvm_map.c
diff -u src/sys/uvm/uvm_map.c:1.306 src/sys/uvm/uvm_map.c:1.307
--- src/sys/uvm/uvm_map.c:1.306	Wed Nov 23 01:00:52 2011
+++ src/sys/uvm/uvm_map.c	Tue Dec 20 13:47:38 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_map.c,v 1.306 2011/11/23 01:00:52 matt Exp $	*/
+/*	$NetBSD: uvm_map.c,v 1.307 2011/12/20 13:47:38 yamt Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uvm_map.c,v 1.306 2011/11/23 01:00:52 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: uvm_map.c,v 1.307 2011/12/20 13:47:38 yamt Exp $);
 
 #include opt_ddb.h
 #include opt_uvmhist.h
@@ -1236,6 +1236,13 @@ uvm_map(struct vm_map *map, vaddr_t *sta
 	return error;
 }
 
+/*
+ * uvm_map_prepare:
+ *
+ * called with map unlocked.
+ * on success, returns the map locked.
+ */
+
 int
 uvm_map_prepare(struct vm_map *map, vaddr_t start, vsize_t size,
 struct uvm_object *uobj, voff_t uoffset, vsize_t align, uvm_flag_t flags,
@@ -1372,6 +1379,13 @@ retry:
 	return 0;
 }
 
+/*
+ * uvm_map_enter:
+ *
+ * called with map locked.
+ * unlock the map before returning.
+ */
+
 int
 uvm_map_enter(struct vm_map *map, const struct uvm_map_args *args,
 struct vm_map_entry *new_entry)
@@ -1407,6 +1421,7 @@ uvm_map_enter(struct vm_map *map, const 
 	UVMHIST_LOG(maphist,   uobj/offset 0x%x/%d, uobj, uoffset,0,0);
 
 	KASSERT(map-hint == prev_entry); /* bimerge case assumes this */
+	KASSERT(vm_map_locked_p(map));
 
 	if (flags  UVM_FLAG_QUANTUM) {
 		KASSERT(new_entry);
@@ -4958,6 +4973,7 @@ uvm_mapent_trymerge(struct vm_map *map, 
 	bool copying;
 	int newetype;
 
+	KASSERT(vm_map_locked_p(map));
 	if (VM_MAP_USE_KMAPENT(map)) {
 		return 0;
 	}



CVS commit: src

2011-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:39:36 UTC 2011

Modified Files:
src/lib/libc/sys: mmap.2
src/sys/sys: mman.h proc.h
src/sys/uvm: uvm_extern.h uvm_map.c uvm_mmap.c

Log Message:
Add a MAP_NOSYSCALLS flag to mmap. This flag prohibits executing of system
calls from the mapped region. This can be used for emulation perposed or for
extra security in the case of generated code.

Its implemented by adding mapping-attributes to each uvm_map_entry. These can
then be queried when needed.

Currently the MAP_NOSYSCALLS is only implemented for x86 but other
architectures are easy to adapt; see the sys/arch/x86/x86/syscall.c patch.
Port maintainers are encouraged to add them for their processor ports too.
When this feature is not yet implemented for an architecture the
MAP_NOSYSCALLS is simply ignored with virtually no cpu cost..


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/lib/libc/sys/mmap.2
cvs rdiff -u -r1.42 -r1.43 src/sys/sys/mman.h
cvs rdiff -u -r1.311 -r1.312 src/sys/sys/proc.h
cvs rdiff -u -r1.176 -r1.177 src/sys/uvm/uvm_extern.h
cvs rdiff -u -r1.307 -r1.308 src/sys/uvm/uvm_map.c
cvs rdiff -u -r1.139 -r1.140 src/sys/uvm/uvm_mmap.c

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

Modified files:

Index: src/lib/libc/sys/mmap.2
diff -u src/lib/libc/sys/mmap.2:1.44 src/lib/libc/sys/mmap.2:1.45
--- src/lib/libc/sys/mmap.2:1.44	Sat Oct 15 22:03:03 2011
+++ src/lib/libc/sys/mmap.2	Tue Dec 20 15:39:35 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: mmap.2,v 1.44 2011/10/15 22:03:03 rmind Exp $
+.\	$NetBSD: mmap.2,v 1.45 2011/12/20 15:39:35 reinoud Exp $
 .\
 .\ Copyright (c) 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -180,6 +180,9 @@ other processes using
 will be seen.
 .It Dv MAP_SHARED
 Modifications are shared.
+.It Dv MAP_NOSYSCALLS
+No system calls are to be allowed from within this mapped region. They instead
+generate an illegal instruction signal.
 .El
 .Pp
 The

Index: src/sys/sys/mman.h
diff -u src/sys/sys/mman.h:1.42 src/sys/sys/mman.h:1.43
--- src/sys/sys/mman.h:1.42	Tue Nov 18 22:13:49 2008
+++ src/sys/sys/mman.h	Tue Dec 20 15:39:35 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mman.h,v 1.42 2008/11/18 22:13:49 ad Exp $	*/
+/*	$NetBSD: mman.h,v 1.43 2011/12/20 15:39:35 reinoud Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1993
@@ -98,6 +98,14 @@ typedef	__off_t		off_t;		/* file offset 
 #define	MAP_STACK	0x2000	/* allocated from memory, swap space (stack) */
 
 /*
+ * Map attributes 0x0001 till 0x00ff
+ */
+#define MAP_ATTR(n)		((n)  MAP_ATTRIB_SHIFT)
+#define MAP_ATTRIB_SHIFT	16
+#define MAP_ATTRIB_MASK		MAP_ATTR(0xff)
+#define MAP_NOSYSCALLS		MAP_ATTR(0x01) /* no syscalls allowed */
+
+/*
  * Alignment (expressed in log2).  Must be = log2(PAGE_SIZE) and
  *  # bits in a pointer (26 (acorn26), 32 or 64).
  */

Index: src/sys/sys/proc.h
diff -u src/sys/sys/proc.h:1.311 src/sys/sys/proc.h:1.312
--- src/sys/sys/proc.h:1.311	Fri Oct 21 02:07:07 2011
+++ src/sys/sys/proc.h	Tue Dec 20 15:39:35 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: proc.h,v 1.311 2011/10/21 02:07:07 christos Exp $	*/
+/*	$NetBSD: proc.h,v 1.312 2011/12/20 15:39:35 reinoud Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -353,6 +353,7 @@ struct proc {
 #define	PK_NOCLDWAIT	0x0002 /* No zombies if child dies */
 #define	PK_32		0x0004 /* 32-bit process (used on 64-bit kernels) */
 #define	PK_CLDSIGIGN	0x0008 /* Process is ignoring SIGCHLD */
+#define PK_CHKNOSYSCALL 0x0010 /* Process needs NOSYSCALL checking */
 #define	PK_MARKER	0x8000 /* Is a dummy marker process */
 
 /*

Index: src/sys/uvm/uvm_extern.h
diff -u src/sys/uvm/uvm_extern.h:1.176 src/sys/uvm/uvm_extern.h:1.177
--- src/sys/uvm/uvm_extern.h:1.176	Thu Sep  1 06:40:28 2011
+++ src/sys/uvm/uvm_extern.h	Tue Dec 20 15:39:35 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_extern.h,v 1.176 2011/09/01 06:40:28 matt Exp $	*/
+/*	$NetBSD: uvm_extern.h,v 1.177 2011/12/20 15:39:35 reinoud Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -680,6 +680,11 @@ void			uvmspace_unshare(struct lwp *);
 
 void			uvm_whatis(uintptr_t, void (*)(const char *, ...));
 
+bool			uvm_map_setattr(struct vm_map *, vaddr_t,
+			vaddr_t, uint32_t);
+bool			uvm_map_checkattr(struct vm_map *, vaddr_t,
+			vaddr_t, uint32_t);
+
 /* uvm_meter.c */
 int			uvm_sysctl(int *, u_int, void *, size_t *,
 			void *, size_t, struct proc *);

Index: src/sys/uvm/uvm_map.c
diff -u src/sys/uvm/uvm_map.c:1.307 src/sys/uvm/uvm_map.c:1.308
--- src/sys/uvm/uvm_map.c:1.307	Tue Dec 20 13:47:38 2011
+++ src/sys/uvm/uvm_map.c	Tue Dec 20 15:39:35 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_map.c,v 1.307 2011/12/20 13:47:38 yamt Exp $	*/
+/*	$NetBSD: uvm_map.c,v 1.308 2011/12/20 15:39:35 reinoud Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 

CVS commit: src/sys/uvm

2011-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:41:01 UTC 2011

Modified Files:
src/sys/uvm: uvm_map.h

Log Message:
Ooops forgot the uvm_map.h


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/uvm/uvm_map.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/uvm/uvm_map.h
diff -u src/sys/uvm/uvm_map.h:1.67 src/sys/uvm/uvm_map.h:1.68
--- src/sys/uvm/uvm_map.h:1.67	Sun Jun 12 03:36:03 2011
+++ src/sys/uvm/uvm_map.h	Tue Dec 20 15:41:01 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_map.h,v 1.67 2011/06/12 03:36:03 rmind Exp $	*/
+/*	$NetBSD: uvm_map.h,v 1.68 2011/12/20 15:41:01 reinoud Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -139,6 +139,7 @@ struct vm_map_entry {
 	int			wired_count;	/* can be paged if == 0 */
 	struct vm_aref		aref;		/* anonymous overlay */
 	int			advice;		/* madvise advice */
+	uint32_t		map_attrib;	/* uvm-external map attributes */
 #define uvm_map_entry_stop_copy flags
 	u_int8_t		flags;		/* flags */
 



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

2011-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:41:50 UTC 2011

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

Log Message:
Part 2 - x86 implementation of MAP_NOSYSCALLS

Currently the MAP_NOSYSCALLS is only implemented for x86 but other
architectures are easy to adapt; see the sys/arch/x86/x86/syscall.c patch.
Port maintainers are encouraged to add them for their processor ports too.
When this feature is not yet implemented for an architecture the
MAP_NOSYSCALLS is simply ignored with virtually no cpu cost..


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/x86/syscall.c

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

Modified files:

Index: src/sys/arch/x86/x86/syscall.c
diff -u src/sys/arch/x86/x86/syscall.c:1.5 src/sys/arch/x86/x86/syscall.c:1.6
--- src/sys/arch/x86/x86/syscall.c:1.5	Sun Sep  4 21:14:49 2011
+++ src/sys/arch/x86/x86/syscall.c	Tue Dec 20 15:41:50 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: syscall.c,v 1.5 2011/09/04 21:14:49 christos Exp $	*/
+/*	$NetBSD: syscall.c,v 1.6 2011/12/20 15:41:50 reinoud Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: syscall.c,v 1.5 2011/09/04 21:14:49 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: syscall.c,v 1.6 2011/12/20 15:41:50 reinoud Exp $);
 
 #include opt_sa.h
 
@@ -41,6 +41,7 @@ __KERNEL_RCSID(0, $NetBSD: syscall.c,v 
 #include sys/sa.h
 #include sys/savar.h
 #include sys/ktrace.h
+#include sys/mman.h
 #include sys/syscall.h
 #include sys/syscallvar.h
 #include sys/syscall_stats.h
@@ -105,8 +106,9 @@ syscall(struct trapframe *frame)
 	const struct sysent *callp;
 	struct proc *p;
 	struct lwp *l;
+	struct vm_map *map;
 	int error;
-	register_t code, rval[2];
+	register_t code, rval[2], rip_call;
 #ifdef __x86_64__
 	/* Verify that the syscall args will fit in the trapframe space */
 	CTASSERT(offsetof(struct trapframe, tf_arg9) =
@@ -120,6 +122,39 @@ syscall(struct trapframe *frame)
 	p = l-l_proc;
 	LWP_CACHE_CREDS(l, p);
 
+	/*
+	 * The offset to adjust the PC by depends on whether we entered the
+	 * kernel through the trap or call gate.  We saved the instruction
+	 * size in tf_err on entry.
+	 */
+	rip_call = X86_TF_RIP(frame) - frame-tf_err;
+
+	/* are we allowed to execute system calls in this memory space? */
+	if (p-p_flag  PK_CHKNOSYSCALL) {
+		map = (p-p_vmspace-vm_map);
+		vm_map_lock(map);
+
+		if (uvm_map_checkattr(map, rip_call, rip_call + frame-tf_err,
+	MAP_NOSYSCALLS)) {
+			ksiginfo_t ksi;
+
+			vm_map_unlock(map);
+			X86_TF_RIP(frame) = rip_call;
+
+			/* treat as illegal instruction */
+			KSI_INIT_TRAP(ksi);
+			ksi.ksi_signo = SIGILL;
+			ksi.ksi_code = ILL_ILLTRP;
+			ksi.ksi_addr = (void *) X86_TF_RIP(frame);
+			ksi.ksi_trap = 0; /* XXX ? */
+			trapsignal(l, ksi);
+			userret(l);
+			return;
+		}
+
+		vm_map_unlock(map);
+	}
+
 	code = X86_TF_RAX(frame)  (SYS_NSYSENT - 1);
 	callp = p-p_emul-e_sysent + code;
 
@@ -173,12 +208,7 @@ syscall(struct trapframe *frame)
 	} else {
 		switch (error) {
 		case ERESTART:
-			/*
-			 * The offset to adjust the PC by depends on whether we
-			 * entered the kernel through the trap or call gate.
-			 * We saved the instruction size in tf_err on entry.
-			 */
-			X86_TF_RIP(frame) -= frame-tf_err;
+			X86_TF_RIP(frame) = rip_call;
 			break;
 		case EJUSTRETURN:
 			/* nothing to do */



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

2011-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:43:52 UTC 2011

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

Log Message:
Add int $80 and sysenter opcodes to the x86 SIGILL opcode detector


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/usermode/usermode/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/usermode/usermode/machdep.c
diff -u src/sys/arch/usermode/usermode/machdep.c:1.37 src/sys/arch/usermode/usermode/machdep.c:1.38
--- src/sys/arch/usermode/usermode/machdep.c:1.37	Wed Dec 14 19:40:02 2011
+++ src/sys/arch/usermode/usermode/machdep.c	Tue Dec 20 15:43:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.37 2011/12/14 19:40:02 reinoud Exp $ */
+/* $NetBSD: machdep.c,v 1.38 2011/12/20 15:43:51 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk rein...@netbsd.org
@@ -32,7 +32,7 @@
 #include opt_urkelvisor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.37 2011/12/14 19:40:02 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.38 2011/12/20 15:43:51 reinoud Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -279,23 +279,18 @@ int
 md_syscall_check_opcode(ucontext_t *ucp)
 {
 	uint32_t opcode;
-#if 0
-	register_t *reg;
-
-	reg = (register_t *) ucp-uc_mcontext;
-	dump_regs(reg);
-#endif
 
 	md_syscall_get_opcode(ucp, opcode);
 
-	/* undefined instruction */
-	if (opcode == 0xff0f)
+	switch (opcode) {
+	case 0xff0f:	/* UD1  */
+	case 0xff0b:	/* UD2  */
+	case 0x80cd:	/* int $80  */
+	case 0x340f:	/* sysenter */
 		return 1;
-	if (opcode == 0xff0b)
-		return 1;
-
-	/* TODO int $80 and sysenter */
-	return 0;
+	default:
+		return 0;
+	}
 }
 
 void
@@ -305,14 +300,16 @@ md_syscall_get_opcode(ucontext_t *ucp, u
 //	uint8_t  *p8  = (uint8_t *) (reg[14]);
 	uint16_t *p16 = (uint16_t*) (reg[14]);
 
-	*opcode = 0;
-
-	if (*p16 == 0xff0f)
-		*opcode = *p16;
-	if (*p16 == 0xff0b)
+	switch (*p16) {
+	case 0xff0f:	/* UD1  */
+	case 0xff0b:	/* UD2  */
+	case 0x80cd:	/* int $80  */
+	case 0x340f:	/* sysenter */
 		*opcode = *p16;
-
-	/* TODO int $80 and sysenter */
+		break;
+	default:
+		*opcode = 0;
+	}
 }
 
 void
@@ -321,12 +318,17 @@ md_syscall_inc_pc(ucontext_t *ucp, uint3
 	uint *reg = (int *) ucp-uc_mcontext;
 
 	/* advance program counter */
-	if (opcode == 0xff0f)
-		reg[14] += 2;	/* EIP */
-	if (opcode == 0xff0b)
+	switch (opcode) {
+	case 0xff0f:	/* UD1  */
+	case 0xff0b:	/* UD2  */
+	case 0x80cd:	/* int $80  */
+	case 0x340f:	/* sysenter */
 		reg[14] += 2;	/* EIP */
-
-	/* TODO int $80 and sysenter */
+		break;
+	default:
+		panic(%s, unknown illegal instruction: opcode = %x\n,
+			__func__, (uint32_t) opcode);
+	}
 }
 
 void
@@ -334,13 +336,17 @@ md_syscall_dec_pc(ucontext_t *ucp, uint3
 {
 	uint *reg = (int *) ucp-uc_mcontext;
 
-	/* advance program counter */
-	if (opcode == 0xff0f)
-		reg[14] -= 2;	/* EIP */
-	if (opcode == 0xff0b)
+	switch (opcode) {
+	case 0xff0f:	/* UD1  */
+	case 0xff0b:	/* UD2  */
+	case 0x80cd:	/* int $80  */
+	case 0x340f:	/* sysenter */
 		reg[14] -= 2;	/* EIP */
-
-	/* TODO int $80 and sysenter */
+		break;
+	default:
+		panic(%s, unknown illegal instruction: opcode = %x\n,
+			__func__, (uint32_t) opcode);
+	}
 }
 
 



CVS commit: src/sys/arch/usermode

2011-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:45:37 UTC 2011

Modified Files:
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: pmap.c syscall.c thunk.c

Log Message:
Use to the MAP_NOSYSCALLS argument to mmap() to allow for NetBSD/usermode to
execute bog-standard native programs.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/usermode/usermode/pmap.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/usermode/usermode/syscall.c
cvs rdiff -u -r1.47 -r1.48 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/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.41 src/sys/arch/usermode/include/thunk.h:1.42
--- src/sys/arch/usermode/include/thunk.h:1.41	Thu Dec 15 03:42:32 2011
+++ src/sys/arch/usermode/include/thunk.h	Tue Dec 20 15:45:36 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.41 2011/12/15 03:42:32 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.42 2011/12/20 15:45:36 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -61,6 +61,7 @@ struct thunk_termios {
 #define THUNK_MAP_FILE		0x0004
 #define THUNK_MAP_SHARED	0x0010
 #define THUNK_MAP_PRIVATE	0x0020
+#define THUNK_MAP_NOSYSCALLS	0x0040
 
 #define THUNK_PROT_NONE		0x00
 #define THUNK_PROT_READ		0x01

Index: src/sys/arch/usermode/usermode/pmap.c
diff -u src/sys/arch/usermode/usermode/pmap.c:1.79 src/sys/arch/usermode/usermode/pmap.c:1.80
--- src/sys/arch/usermode/usermode/pmap.c:1.79	Wed Dec 14 17:06:28 2011
+++ src/sys/arch/usermode/usermode/pmap.c	Tue Dec 20 15:45:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.79 2011/12/14 17:06:28 reinoud Exp $ */
+/* $NetBSD: pmap.c,v 1.80 2011/12/20 15:45:37 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk rein...@netbsd.org
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.79 2011/12/14 17:06:28 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.80 2011/12/20 15:45:37 reinoud Exp $);
 
 #include opt_memsize.h
 #include opt_kmempages.h
@@ -626,11 +626,15 @@ pmap_page_activate(struct pv_entry *pv)
 {
 	paddr_t pa = pv-pv_ppn * PAGE_SIZE;
 	vaddr_t va = pv-pv_lpn * PAGE_SIZE + VM_MIN_ADDRESS; /* L-V */
+	uint32_t map_flags;
 	void *addr;
 
+	map_flags = THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED;
+	if ((va = VM_MIN_ADDRESS)  (va  VM_MAXUSER_ADDRESS)) 
+		map_flags |= THUNK_MAP_NOSYSCALLS;
+
 	addr = thunk_mmap((void *) va, PAGE_SIZE, pv-pv_mmap_ppl,
-		THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED,
-		mem_fh, pa);
+		map_flags, mem_fh, pa);
 	dprintf_debug(page_activate: (va %p, pa %p, prot %d, ppl %d) - %p\n,
 		(void *) va, (void *) pa, pv-pv_prot, pv-pv_mmap_ppl,
 		(void *) addr);
@@ -648,14 +652,15 @@ pmap_page_deactivate(struct pv_entry *pv
 {
 	paddr_t pa = pv-pv_ppn * PAGE_SIZE;
 	vaddr_t va = pv-pv_lpn * PAGE_SIZE + VM_MIN_ADDRESS; /* L-V */
+	uint32_t map_flags;
 	void *addr;
 
 	if (pv-pv_vflags  PV_WIRED)
 		return;
 
+	map_flags = THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED;
 	addr = thunk_mmap((void *) va, PAGE_SIZE, THUNK_PROT_NONE,
-		THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED,
-		mem_fh, pa);
+		map_flags, mem_fh, pa);
 	dprintf_debug(page_deactivate: (va %p, pa %p, ppl %d) - %p\n,
 		(void *) va, (void *) pa, pv-pv_mmap_ppl, (void *) addr);
 	if (addr != (void *) va)

Index: src/sys/arch/usermode/usermode/syscall.c
diff -u src/sys/arch/usermode/usermode/syscall.c:1.18 src/sys/arch/usermode/usermode/syscall.c:1.19
--- src/sys/arch/usermode/usermode/syscall.c:1.18	Thu Dec 15 11:23:52 2011
+++ src/sys/arch/usermode/usermode/syscall.c	Tue Dec 20 15:45:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.18 2011/12/15 11:23:52 jmcneill Exp $ */
+/* $NetBSD: syscall.c,v 1.19 2011/12/20 15:45:37 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: syscall.c,v 1.18 2011/12/15 11:23:52 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: syscall.c,v 1.19 2011/12/20 15:45:37 reinoud Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -99,6 +99,8 @@ syscall(void)
 	curcpu()-ci_data.cpu_nsyscall++;
 	LWP_CACHE_CREDS(l, l-l_proc);
 
+	/* TODO are we allowed to execute system calls in this memory space? */
+
 	/* XXX do we want do do emulation? */
 	md_syscall_get_opcode(ucp, opcode);
 	md_syscall_get_syscallnumber(ucp, code);

Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.47 src/sys/arch/usermode/usermode/thunk.c:1.48
--- src/sys/arch/usermode/usermode/thunk.c:1.47	Thu Dec 15 03:42:33 2011
+++ src/sys/arch/usermode/usermode/thunk.c	Tue Dec 20 15:45:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.47 2011/12/15 03:42:33 jmcneill Exp $ */
+/* 

CVS commit: src/sys/compat/sys

2011-12-20 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Tue Dec 20 16:38:06 UTC 2011

Modified Files:
src/sys/compat/sys: rnd.h

Log Message:
allow kernels w/o COMPAT_50 to build


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/compat/sys/rnd.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/compat/sys/rnd.h
diff -u src/sys/compat/sys/rnd.h:1.1 src/sys/compat/sys/rnd.h:1.2
--- src/sys/compat/sys/rnd.h:1.1	Mon Dec 19 21:53:52 2011
+++ src/sys/compat/sys/rnd.h	Tue Dec 20 16:38:06 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rnd.h,v 1.1 2011/12/19 21:53:52 apb Exp $	*/
+/*	$NetBSD: rnd.h,v 1.2 2011/12/20 16:38:06 drochner Exp $	*/
 
 /*-
  * Copyright (c) 1997,2011 The NetBSD Foundation, Inc.
@@ -47,8 +47,6 @@
 
 #include sys/rnd.h
 
-#ifdef COMPAT_50
-
 /*
  * NetBSD-5 used void *state in the rndsource_t struct.  rndsource_t
  * was used in rnstat_t and rnstat_name_t, which were used by
@@ -149,6 +147,4 @@ int compat_50_rnd_ioctl(struct file *, u
 #define	RNDGETSRCNAME50_32	_IOWR('R', 103, rndstat_name50_32_t)
 #endif /* COMPAT_NETBSD32 */
 
-#endif /* COMPAT_50 */
-
 #endif /* !_COMPAT_SYS_RND_H_ */



CVS commit: src/lib/libc/sys

2011-12-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Dec 20 16:43:14 UTC 2011

Modified Files:
src/lib/libc/sys: mmap.2

Log Message:
New sentence, new line. Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/lib/libc/sys/mmap.2

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

Modified files:

Index: src/lib/libc/sys/mmap.2
diff -u src/lib/libc/sys/mmap.2:1.45 src/lib/libc/sys/mmap.2:1.46
--- src/lib/libc/sys/mmap.2:1.45	Tue Dec 20 15:39:35 2011
+++ src/lib/libc/sys/mmap.2	Tue Dec 20 16:43:14 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: mmap.2,v 1.45 2011/12/20 15:39:35 reinoud Exp $
+.\	$NetBSD: mmap.2,v 1.46 2011/12/20 16:43:14 wiz Exp $
 .\
 .\ Copyright (c) 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\	@(#)mmap.2	8.4 (Berkeley) 5/11/95
 .\
-.Dd October 15, 2011
+.Dd December 20, 2011
 .Dt MMAP 2
 .Os
 .Sh NAME
@@ -181,8 +181,8 @@ will be seen.
 .It Dv MAP_SHARED
 Modifications are shared.
 .It Dv MAP_NOSYSCALLS
-No system calls are to be allowed from within this mapped region. They instead
-generate an illegal instruction signal.
+No system calls are to be allowed from within this mapped region.
+They instead generate an illegal instruction signal.
 .El
 .Pp
 The



CVS commit: src/sys/kern

2011-12-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 20 16:49:37 UTC 2011

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

Log Message:
Move the diagnostic check for a missing VOP_CLOSE() to the top of vrelel().
As long as we hold the vnode interlock there is no chance for this vnode
to gain new references.

Fixes false alarms observed by Thor Lancelot Simon and reported on tech-kern.

Ok: David Holland dholl...@netbsd.org


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/vfs_vnode.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_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.14 src/sys/kern/vfs_vnode.c:1.15
--- src/sys/kern/vfs_vnode.c:1.14	Fri Oct  7 09:35:06 2011
+++ src/sys/kern/vfs_vnode.c	Tue Dec 20 16:49:37 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.14 2011/10/07 09:35:06 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.15 2011/12/20 16:49:37 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -120,7 +120,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.14 2011/10/07 09:35:06 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_vnode.c,v 1.15 2011/12/20 16:49:37 hannken Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -637,6 +637,13 @@ vrelel(vnode_t *vp, int flags)
 
 	KASSERT((vp-v_iflag  VI_XLOCK) == 0);
 
+#ifdef DIAGNOSTIC
+	if ((vp-v_type == VBLK || vp-v_type == VCHR) 
+	vp-v_specnode != NULL  vp-v_specnode-sn_opencnt != 0) {
+		vprint(vrelel: missing VOP_CLOSE(), vp);
+	}
+#endif
+
 	/*
 	 * If not clean, deactivate the vnode, but preserve
 	 * our reference across the call to VOP_INACTIVE().
@@ -706,13 +713,6 @@ retry:
 			return;
 		}
 
-#ifdef DIAGNOSTIC
-		if ((vp-v_type == VBLK || vp-v_type == VCHR) 
-		vp-v_specnode != NULL  vp-v_specnode-sn_opencnt != 0) {
-			vprint(vrelel: missing VOP_CLOSE(), vp);
-		}
-#endif
-
 		/*
 		 * The vnode can gain another reference while being
 		 * deactivated.  If VOP_INACTIVE() indicates that



CVS commit: src/sys/rump/dev/lib/librnd

2011-12-20 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Tue Dec 20 17:09:04 UTC 2011

Modified Files:
src/sys/rump/dev/lib/librnd: Makefile

Log Message:
Put the path to the compat/common directory in a .PATH line, not in
an element of the SRCS list.  This should fix a problem in which build
products were created in the source tree.

Also add a comment about where COMPAT_50 is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/dev/lib/librnd/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/rump/dev/lib/librnd/Makefile
diff -u src/sys/rump/dev/lib/librnd/Makefile:1.4 src/sys/rump/dev/lib/librnd/Makefile:1.5
--- src/sys/rump/dev/lib/librnd/Makefile:1.4	Mon Dec 19 21:56:18 2011
+++ src/sys/rump/dev/lib/librnd/Makefile	Tue Dec 20 17:09:04 2011
@@ -1,15 +1,19 @@
-#	$NetBSD: Makefile,v 1.4 2011/12/19 21:56:18 apb Exp $
+#	$NetBSD: Makefile,v 1.5 2011/12/20 17:09:04 apb Exp $
 #
 
 .PATH:	${.CURDIR}/../../../../dev
 
 LIB=	rumpdev_rnd
 
-SRCS=   rnd.c rndpseudo.c rndpool.c
-SRCS+=  ${.CURDIR}/../../../../compat/common/rndpseudo_50.c
+SRCS=	rnd.c rndpseudo.c rndpool.c
 
 SRCS+=	component.c
 
+# sys/rump/Makefile.rump sets CPPFLAGS+= -DCOMPAT_50=1,
+# so we need rndpseudo_50.c from the compat/common directory.
+.PATH:	${.CURDIR}/../../../../compat/common
+SRCS+=	rndpseudo_50.c
+
 CPPFLAGS+=	-I${RUMPTOP}/librump/rumpvfs
 
 .include bsd.lib.mk



CVS commit: src/sys/uvm

2011-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 19:49:36 UTC 2011

Modified Files:
src/sys/uvm: uvm_mmap.c

Log Message:
If we need to set the PK_CHKNOSYSCALL flag in struct proc be so nice to first
take the mutex. Tnx for pointing it out to me.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/uvm/uvm_mmap.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/uvm/uvm_mmap.c
diff -u src/sys/uvm/uvm_mmap.c:1.140 src/sys/uvm/uvm_mmap.c:1.141
--- src/sys/uvm/uvm_mmap.c:1.140	Tue Dec 20 15:39:35 2011
+++ src/sys/uvm/uvm_mmap.c	Tue Dec 20 19:49:36 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_mmap.c,v 1.140 2011/12/20 15:39:35 reinoud Exp $	*/
+/*	$NetBSD: uvm_mmap.c,v 1.141 2011/12/20 19:49:36 reinoud Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -46,7 +46,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uvm_mmap.c,v 1.140 2011/12/20 15:39:35 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: uvm_mmap.c,v 1.141 2011/12/20 19:49:36 reinoud Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_pax.h
@@ -560,8 +560,12 @@ sys_mmap(struct lwp *l, const struct sys
 panic(uvm_setattr failed?);
 		}
 		/* record if we need optimization for system call checking */
-		if (flags  MAP_NOSYSCALLS)
+		if ((flags  MAP_NOSYSCALLS) 
+((p-p_flag  PK_CHKNOSYSCALL) == 0)) {
+			mutex_enter(p-p_lock);
 			p-p_flag |= PK_CHKNOSYSCALL;
+			mutex_exit(p-p_lock);
+		}
 	}
 
  	if (fp != NULL)



CVS commit: src/sys/arch/usermode

2011-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 21:01:39 UTC 2011

Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode files.usermode
majors.usermode std.usermode
src/sys/arch/usermode/usermode: machdep.c pmap.c
Added Files:
src/sys/arch/usermode/conf: GENERIC.common GENERIC.i386
Removed Files:
src/sys/arch/usermode/conf: GENERIC GENERIC32
src/sys/arch/usermode/include: urkelvisor.h
src/sys/arch/usermode/usermode: urkelvisor.c

Log Message:
get rid of urkelvisor, and use same MD majors as the host


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r0 src/sys/arch/usermode/conf/GENERIC
cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/conf/GENERIC.common \
src/sys/arch/usermode/conf/GENERIC.i386
cvs rdiff -u -r1.2 -r0 src/sys/arch/usermode/conf/GENERIC32
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/usermode/conf/files.usermode
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/conf/majors.usermode
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/conf/std.usermode
cvs rdiff -u -r1.1 -r0 src/sys/arch/usermode/include/urkelvisor.h
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/usermode/usermode/pmap.c
cvs rdiff -u -r1.9 -r0 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.24 src/sys/arch/usermode/conf/Makefile.usermode:1.25
--- src/sys/arch/usermode/conf/Makefile.usermode:1.24	Fri Sep 16 11:28:36 2011
+++ src/sys/arch/usermode/conf/Makefile.usermode	Tue Dec 20 21:01:39 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.usermode,v 1.24 2011/09/16 11:28:36 jmcneill Exp $
+# $NetBSD: Makefile.usermode,v 1.25 2011/12/20 21:01:39 jmcneill Exp $
 
 OPT_CPU_HOST=			%CPU_HOST%
 .if !empty(OPT_CPU_HOST)
@@ -38,7 +38,6 @@ CPPFLAGS+=	-Dusermode
 CPPFLAGS.init_main.c+=	-Dmain=kernmain
 
 OPT_SDL=	%SDL%
-OPT_URKELVISOR=	%URKELVISOR%
 
 .if !empty(OPT_SDL)
 SDL_CFLAGS!=	sdl-config --cflags
@@ -48,7 +47,6 @@ USERMODE_LIBS+=	-Wl,-Bdynamic ${SDL_LIBS
 
 CPPFLAGS.thunk.c+=	${USERMODE_CPPFLAGS}
 CPPFLAGS.thunk_sdl.c+=	${SDL_CFLAGS} ${USERMODE_CPPFLAGS}
-CPPFLAGS.urkelvisor.c+=	${USERMODE_CPPFLAGS}
 
 ##
 ## (3) libkern and compat
@@ -63,11 +61,6 @@ 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
@@ -112,13 +105,6 @@ thunk_sdl.d: ${USERMODE}/usermode/thunk.
 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.11 src/sys/arch/usermode/conf/files.usermode:1.12
--- src/sys/arch/usermode/conf/files.usermode:1.11	Fri Sep 16 11:28:36 2011
+++ src/sys/arch/usermode/conf/files.usermode	Tue Dec 20 21:01:39 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.usermode,v 1.11 2011/09/16 11:28:36 jmcneill Exp $
+# $NetBSD: files.usermode,v 1.12 2011/12/20 21:01:39 jmcneill Exp $
 
 maxpartitions 8
 maxusers 8 16 64
@@ -8,7 +8,6 @@ defflag opt_sdl.hSDL
 defflag opt_cpu.hCPU_DEBUG
 defparam opt_cpu.hCPU_HOST
 defparam opt_misc.hTEXTADDR
-defflag opt_urkelvisor.h			URKELVISOR
 
 define	thunkbus { }
 

Index: src/sys/arch/usermode/conf/majors.usermode
diff -u src/sys/arch/usermode/conf/majors.usermode:1.4 src/sys/arch/usermode/conf/majors.usermode:1.5
--- src/sys/arch/usermode/conf/majors.usermode:1.4	Sun Dec 11 22:34:42 2011
+++ src/sys/arch/usermode/conf/majors.usermode	Tue Dec 20 21:01:39 2011
@@ -1,15 +1,2 @@
-# $NetBSD: majors.usermode,v 1.4 2011/12/11 22:34:42 jmcneill Exp $
-
-device-major	cons		char 0
-device-major	ctty		char 1
-device-major	mem		char 2
-#device-major	wd		char 3
-device-major	swap		char 4	block 1		vmswap
-device-major	pts		char 5			pty
-device-major	ptc		char 6			pty
-device-major	log		char 7
-device-major	com		char 8			com
-device-major	md		char 24	block 17	md
-device-major	wsdisplay	char 47			wsdisplay
-device-major	ld		char 69 block 19	ld
+# $NetBSD: majors.usermode,v 1.5 2011/12/20 21:01:39 jmcneill Exp $
 device-major	ttycons		char 159		ttycons

Index: src/sys/arch/usermode/conf/std.usermode
diff -u src/sys/arch/usermode/conf/std.usermode:1.8 

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

2011-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 21:07:56 UTC 2011

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

Log Message:
thunk_pollchar: use read instead of getchar


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.48 src/sys/arch/usermode/usermode/thunk.c:1.49
--- src/sys/arch/usermode/usermode/thunk.c:1.48	Tue Dec 20 15:45:37 2011
+++ src/sys/arch/usermode/usermode/thunk.c	Tue Dec 20 21:07:56 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.48 2011/12/20 15:45:37 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.49 2011/12/20 21:07:56 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifdef __NetBSD__
-__RCSID($NetBSD: thunk.c,v 1.48 2011/12/20 15:45:37 reinoud Exp $);
+__RCSID($NetBSD: thunk.c,v 1.49 2011/12/20 21:07:56 jmcneill Exp $);
 #endif
 
 #include sys/types.h
@@ -381,6 +381,7 @@ int
 thunk_pollchar(void)
 {
 	struct pollfd fds[1];
+	uint8_t c;
 
 	fds[0].fd = STDIN_FILENO;
 	fds[0].events = POLLIN;
@@ -388,7 +389,9 @@ thunk_pollchar(void)
 
 	if (poll(fds, __arraycount(fds), 0)  0) {
 		if (fds[0].revents  POLLIN) {
-			return getchar();
+			if (read(STDIN_FILENO, c, 1) != 1)
+return EOF;
+			return c;
 		}
 	}
 



CVS commit: src/sys/arch/usermode

2011-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 21:26:37 UTC 2011

Modified Files:
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: machdep.c thunk.c

Log Message:
set machine_arch to that of the host


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.49 -r1.50 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/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.42 src/sys/arch/usermode/include/thunk.h:1.43
--- src/sys/arch/usermode/include/thunk.h:1.42	Tue Dec 20 15:45:36 2011
+++ src/sys/arch/usermode/include/thunk.h	Tue Dec 20 21:26:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.42 2011/12/20 15:45:36 reinoud Exp $ */
+/* $NetBSD: thunk.h,v 1.43 2011/12/20 21:26:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -143,6 +143,8 @@ vaddr_t	thunk_get_vm_min_address(void);
 
 int	thunk_getcpuinfo(char *, int *);
 
+int	thunk_getmachine(char *, size_t);
+
 int	thunk_sdl_init(unsigned int, unsigned int, unsigned short);
 void *	thunk_sdl_getfb(size_t);
 int	thunk_sdl_getchar(void);

Index: src/sys/arch/usermode/usermode/machdep.c
diff -u src/sys/arch/usermode/usermode/machdep.c:1.39 src/sys/arch/usermode/usermode/machdep.c:1.40
--- src/sys/arch/usermode/usermode/machdep.c:1.39	Tue Dec 20 21:01:39 2011
+++ src/sys/arch/usermode/usermode/machdep.c	Tue Dec 20 21:26:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.39 2011/12/20 21:01:39 jmcneill Exp $ */
+/* $NetBSD: machdep.c,v 1.40 2011/12/20 21:26:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk rein...@netbsd.org
@@ -31,7 +31,7 @@
 #include opt_sdl.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.39 2011/12/20 21:01:39 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.40 2011/12/20 21:26:37 jmcneill Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -40,6 +40,7 @@ __KERNEL_RCSID(0, $NetBSD: machdep.c,v 
 #include sys/buf.h
 #include sys/boot_flag.h
 #include sys/ucontext.h
+#include sys/utsname.h
 #include machine/pcb.h
 #include machine/psl.h
 
@@ -51,7 +52,7 @@ __KERNEL_RCSID(0, $NetBSD: machdep.c,v 
 #include machine/thunk.h
 
 char machine[] = usermode;
-char machine_arch[] = usermode;
+char machine_arch[_SYS_NMLN] = ;
 
 static char **saved_argv;
 char *usermode_root_image_path = NULL;
@@ -72,6 +73,8 @@ main(int argc, char *argv[])
 
 	saved_argv = argv;
 
+	thunk_getmachine(machine_arch, sizeof(machine_arch));
+
 #if defined(SDL)
 	if (genfb_thunkbus_cnattach() == 0)
 #endif

Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.49 src/sys/arch/usermode/usermode/thunk.c:1.50
--- src/sys/arch/usermode/usermode/thunk.c:1.49	Tue Dec 20 21:07:56 2011
+++ src/sys/arch/usermode/usermode/thunk.c	Tue Dec 20 21:26:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.49 2011/12/20 21:07:56 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.50 2011/12/20 21:26:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -28,13 +28,15 @@
 
 #include sys/cdefs.h
 #ifdef __NetBSD__
-__RCSID($NetBSD: thunk.c,v 1.49 2011/12/20 21:07:56 jmcneill Exp $);
+__RCSID($NetBSD: thunk.c,v 1.50 2011/12/20 21:26:37 jmcneill Exp $);
 #endif
 
 #include sys/types.h
 #include sys/mman.h
 #include sys/reboot.h
 #include sys/poll.h
+#include sys/utsname.h
+#include sys/sysctl.h
 #include machine/vmparam.h
 
 #include aio.h
@@ -664,3 +666,27 @@ thunk_getcpuinfo(char *cp, int *len)
 	*len = rlen;
 	return 0;
 }
+
+int
+thunk_getmachine(char *buf, size_t buflen)
+{
+#ifdef __NetBSD__
+	size_t len = buflen - 1;
+
+	memset(buf, 0, buflen);
+	if (sysctlbyname(hw.machine_arch, buf, len, NULL, 0) != 0) {
+		perror(sysctlbyname hw.machine_arch failed);
+		return -1;
+	}
+#else
+	struct utsname uts;
+
+	if (uname(uts) != 0) {
+		perror(uname failed);
+		return -1;
+	}
+
+	strlcpy(buf, uts.machine, buflen);
+#endif
+	return 0;
+}



CVS commit: src/sys/dev/pci

2011-12-20 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Dec 20 21:27:29 UTC 2011

Modified Files:
src/sys/dev/pci: if_wmreg.h

Log Message:
Mark all of the Rx descriptor fields 'volatile' so that the compiler
will not re-order accesses.  Some versions of GCC (such as one in NetBSD
5.x) definitely do re-order reads from these fields if they're not
marked volatile.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/pci/if_wmreg.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/pci/if_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.45 src/sys/dev/pci/if_wmreg.h:1.46
--- src/sys/dev/pci/if_wmreg.h:1.45	Fri May 20 01:51:36 2011
+++ src/sys/dev/pci/if_wmreg.h	Tue Dec 20 21:27:29 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.45 2011/05/20 01:51:36 msaitoh Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.46 2011/12/20 21:27:29 dyoung Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -57,14 +57,14 @@ typedef struct wiseman_addr {
  * and there must be an even multiple of 8 descriptors in the ring.
  */
 typedef struct wiseman_rxdesc {
-	wiseman_addr_t	wrx_addr;	/* buffer address */
+	volatile wiseman_addr_t	wrx_addr;	/* buffer address */
 
-	uint16_t	wrx_len;	/* buffer length */
-	uint16_t	wrx_cksum;	/* checksum (starting at PCSS) */
+	volatile uint16_t	wrx_len;	/* buffer length */
+	volatile uint16_t	wrx_cksum;	/* checksum (starting at PCSS)*/
 
-	uint8_t		wrx_status;	/* Rx status */
-	uint8_t		wrx_errors;	/* Rx errors */
-	uint16_t	wrx_special;	/* special field (VLAN, etc.) */
+	volatile uint8_t	wrx_status;	/* Rx status */
+	volatile uint8_t	wrx_errors;	/* Rx errors */
+	volatile uint16_t	wrx_special;	/* special field (VLAN, etc.) */
 } __packed wiseman_rxdesc_t;
 
 /* wrx_status bits */



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

2011-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 21:35:16 UTC 2011

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

Log Message:
check return value of write, make sure we send the whole buffer to stdout


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/usermode/dev/ttycons.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/ttycons.c
diff -u src/sys/arch/usermode/dev/ttycons.c:1.12 src/sys/arch/usermode/dev/ttycons.c:1.13
--- src/sys/arch/usermode/dev/ttycons.c:1.12	Thu Dec 15 01:04:15 2011
+++ src/sys/arch/usermode/dev/ttycons.c	Tue Dec 20 21:35:16 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ttycons.c,v 1.12 2011/12/15 01:04:15 jmcneill Exp $ */
+/* $NetBSD: ttycons.c,v 1.13 2011/12/20 21:35:16 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ttycons.c,v 1.12 2011/12/15 01:04:15 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: ttycons.c,v 1.13 2011/12/20 21:35:16 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/conf.h
@@ -302,7 +302,8 @@ static void
 ttycons_start(struct tty *t)
 {
 	u_char buf[80+1];
-	int s, len; //, i;
+	u_char *p = buf;
+	int s, len, brem;
 
 	s = spltty();
 	if (t-t_state  (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) {
@@ -312,8 +313,15 @@ ttycons_start(struct tty *t)
 	t-t_state |= TS_BUSY;
 	splx(s);
 
-	len = q_to_b(t-t_outq, buf, sizeof(buf) - 1);
-	thunk_write(1, buf, len);
+	brem = q_to_b(t-t_outq, buf, sizeof(buf) - 1);
+
+	while (brem  0) {
+		len = thunk_write(1, p, brem);
+		if (len  0) {
+			p += len;
+			brem -= len;
+		}
+	}
 
 	s = spltty();
 	t-t_state = ~TS_BUSY;



CVS commit: src/sys/arch/usermode

2011-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 22:48:59 UTC 2011

Modified Files:
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: machdep.c thunk.c

Log Message:
on second thought, set machine and machine_arch both from the host and
override module_machine


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.50 -r1.51 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/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.43 src/sys/arch/usermode/include/thunk.h:1.44
--- src/sys/arch/usermode/include/thunk.h:1.43	Tue Dec 20 21:26:37 2011
+++ src/sys/arch/usermode/include/thunk.h	Tue Dec 20 22:48:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.43 2011/12/20 21:26:37 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.44 2011/12/20 22:48:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -143,7 +143,7 @@ vaddr_t	thunk_get_vm_min_address(void);
 
 int	thunk_getcpuinfo(char *, int *);
 
-int	thunk_getmachine(char *, size_t);
+int	thunk_getmachine(char *, size_t, char *, size_t);
 
 int	thunk_sdl_init(unsigned int, unsigned int, unsigned short);
 void *	thunk_sdl_getfb(size_t);

Index: src/sys/arch/usermode/usermode/machdep.c
diff -u src/sys/arch/usermode/usermode/machdep.c:1.40 src/sys/arch/usermode/usermode/machdep.c:1.41
--- src/sys/arch/usermode/usermode/machdep.c:1.40	Tue Dec 20 21:26:37 2011
+++ src/sys/arch/usermode/usermode/machdep.c	Tue Dec 20 22:48:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.40 2011/12/20 21:26:37 jmcneill Exp $ */
+/* $NetBSD: machdep.c,v 1.41 2011/12/20 22:48:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk rein...@netbsd.org
@@ -31,7 +31,7 @@
 #include opt_sdl.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.40 2011/12/20 21:26:37 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.41 2011/12/20 22:48:59 jmcneill Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -51,8 +51,9 @@ __KERNEL_RCSID(0, $NetBSD: machdep.c,v 
 #include machine/machdep.h
 #include machine/thunk.h
 
-char machine[] = usermode;
+char machine[_SYS_NMLN] = ;
 char machine_arch[_SYS_NMLN] = ;
+char module_machine_usermode[_SYS_NMLN] = ;
 
 static char **saved_argv;
 char *usermode_root_image_path = NULL;
@@ -73,7 +74,12 @@ main(int argc, char *argv[])
 
 	saved_argv = argv;
 
-	thunk_getmachine(machine_arch, sizeof(machine_arch));
+	/* Get machine and machine_arch from host */
+	thunk_getmachine(machine, sizeof(machine),
+	machine_arch, sizeof(machine_arch));
+	/* Override module_machine to be ${machine}usermode */
+	snprintf(module_machine_usermode, sizeof(module_machine_usermode),
+	%susermode, machine);
 
 #if defined(SDL)
 	if (genfb_thunkbus_cnattach() == 0)

Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.50 src/sys/arch/usermode/usermode/thunk.c:1.51
--- src/sys/arch/usermode/usermode/thunk.c:1.50	Tue Dec 20 21:26:37 2011
+++ src/sys/arch/usermode/usermode/thunk.c	Tue Dec 20 22:48:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.50 2011/12/20 21:26:37 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.51 2011/12/20 22:48:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill jmcne...@invisible.ca
@@ -28,14 +28,13 @@
 
 #include sys/cdefs.h
 #ifdef __NetBSD__
-__RCSID($NetBSD: thunk.c,v 1.50 2011/12/20 21:26:37 jmcneill Exp $);
+__RCSID($NetBSD: thunk.c,v 1.51 2011/12/20 22:48:59 jmcneill Exp $);
 #endif
 
 #include sys/types.h
 #include sys/mman.h
 #include sys/reboot.h
 #include sys/poll.h
-#include sys/utsname.h
 #include sys/sysctl.h
 #include machine/vmparam.h
 
@@ -668,25 +667,24 @@ thunk_getcpuinfo(char *cp, int *len)
 }
 
 int
-thunk_getmachine(char *buf, size_t buflen)
+thunk_getmachine(char *machine, size_t machinelen,
+char *machine_arch, size_t machine_archlen)
 {
-#ifdef __NetBSD__
-	size_t len = buflen - 1;
+	size_t len;
 
-	memset(buf, 0, buflen);
-	if (sysctlbyname(hw.machine_arch, buf, len, NULL, 0) != 0) {
-		perror(sysctlbyname hw.machine_arch failed);
-		return -1;
+	memset(machine, 0, machinelen);
+	len = machinelen - 1;
+	if (sysctlbyname(hw.machine, machine, len, NULL, 0) != 0) {
+		perror(sysctlbyname hw.machine failed);
+		abort();
 	}
-#else
-	struct utsname uts;
 
-	if (uname(uts) != 0) {
-		perror(uname failed);
-		return -1;
+	memset(machine_arch, 0, machine_archlen);
+	len = machine_archlen - 1;
+	if (sysctlbyname(hw.machine_arch, machine_arch, len, NULL, 0) != 0) {
+		perror(sysctlbyname hw.machine_arch failed);
+		abort();
 	}
 
-	strlcpy(buf, uts.machine, buflen);
-#endif
 	return 0;
 }



CVS commit: src/sys

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 20 23:56:29 UTC 2011

Modified Files:
src/sys/compat/linux/common: linux_socket.c
src/sys/dev: kttcp.c
src/sys/kern: sys_socket.c uipc_socket.c uipc_socket2.c uipc_syscalls.c
src/sys/miscfs/fifofs: fifo_vnops.c
src/sys/netiso: tp_usrreq.c
src/sys/sys: socket.h socketvar.h

Log Message:
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
  errors?).


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/kttcp.c
cvs rdiff -u -r1.64 -r1.65 src/sys/kern/sys_socket.c
cvs rdiff -u -r1.205 -r1.206 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.109 -r1.110 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.148 -r1.149 src/sys/kern/uipc_syscalls.c
cvs rdiff -u -r1.70 -r1.71 src/sys/miscfs/fifofs/fifo_vnops.c
cvs rdiff -u -r1.40 -r1.41 src/sys/netiso/tp_usrreq.c
cvs rdiff -u -r1.100 -r1.101 src/sys/sys/socket.h
cvs rdiff -u -r1.126 -r1.127 src/sys/sys/socketvar.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/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.110 src/sys/compat/linux/common/linux_socket.c:1.111
--- src/sys/compat/linux/common/linux_socket.c:1.110	Sun Jul 17 19:59:54 2011
+++ src/sys/compat/linux/common/linux_socket.c	Tue Dec 20 18:56:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.110 2011/07/17 23:59:54 christos Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.111 2011/12/20 23:56:28 christos Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.110 2011/07/17 23:59:54 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.111 2011/12/20 23:56:28 christos Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_inet.h
@@ -1376,7 +1376,7 @@ linux_sys_connect(struct lwp *l, const s
 
 	if (error == EISCONN) {
 		struct socket *so;
-		int state, prflags, nbio;
+		int state, prflags;
 
 		/* fd_getsock() will use the descriptor for us */
 		if (fd_getsock(SCARG(uap, s), so) != 0)
@@ -1384,7 +1384,6 @@ linux_sys_connect(struct lwp *l, const s
 
 		solock(so);
 		state = so-so_state;
-		nbio = so-so_nbio;
 		prflags = so-so_proto-pr_flags;
 		sounlock(so);
 		fd_putfile(SCARG(uap, s));
@@ -1393,7 +1392,8 @@ linux_sys_connect(struct lwp *l, const s
 		 * non-blocking connect; however we don't have
 		 * a convenient place to keep that state..
 		 */
-		if (nbio  (state  SS_ISCONNECTED) 
+		if ((state  (SS_ISCONNECTED|SS_NBIO)) ==
+		(SS_ISCONNECTED|SS_NBIO) 
 		(prflags  PR_CONNREQUIRED))
 			return 0;
 	}

Index: src/sys/dev/kttcp.c
diff -u src/sys/dev/kttcp.c:1.28 src/sys/dev/kttcp.c:1.29
--- src/sys/dev/kttcp.c:1.28	Thu Apr 24 07:38:36 2008
+++ src/sys/dev/kttcp.c	Tue Dec 20 18:56:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kttcp.c,v 1.28 2008/04/24 11:38:36 ad Exp $	*/
+/*	$NetBSD: kttcp.c,v 1.29 2011/12/20 23:56:28 christos Exp $	*/
 
 /*
  * Copyright (c) 2002 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kttcp.c,v 1.28 2008/04/24 11:38:36 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: kttcp.c,v 1.29 2011/12/20 23:56:28 christos Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -237,7 +237,7 @@ kttcp_sosend(struct socket *so, unsigned
 		if ((atomic  resid  so-so_snd.sb_hiwat))
 			snderr(EMSGSIZE);
 		if (space  resid  (atomic || space  so-so_snd.sb_lowat)) {
-			if (so-so_nbio)
+			if (so-so_state  SS_NBIO)
 snderr(EWOULDBLOCK);
 			SBLASTRECORDCHK(so-so_rcv,
 			kttcp_soreceive sbwait 1);
@@ -427,7 +427,7 @@ kttcp_soreceive(struct socket *so, unsig
 		}
 		if (resid == 0)
 			goto release;
-		if (so-so_nbio || (flags  MSG_DONTWAIT)) {
+		if ((so-so_so_state  SS_NBIO) || (flags  MSG_DONTWAIT|MSG_NBIO)) {
 			error = EWOULDBLOCK;
 			goto release;
 		}

Index: src/sys/kern/sys_socket.c
diff -u src/sys/kern/sys_socket.c:1.64 src/sys/kern/sys_socket.c:1.65
--- src/sys/kern/sys_socket.c:1.64	Thu Jun 30 18:38:50 2011
+++ src/sys/kern/sys_socket.c	Tue Dec 20 18:56:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_socket.c,v 1.64 2011/06/30 22:38:50 dyoung Exp $	*/
+/*	$NetBSD: sys_socket.c,v 1.65 2011/12/20 23:56:28 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: sys_socket.c,v 1.64 2011/06/30 22:38:50 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: sys_socket.c,v 1.65 2011/12/20 23:56:28 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -127,8 

CVS commit: src/tests/fs

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 21 00:17:07 UTC 2011

Modified Files:
src/tests/fs: Makefile
Added Files:
src/tests/fs/fifofs: Makefile t_fifo.c

Log Message:
Add a test for the latest fifofs fix.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/tests/fs/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/fs/fifofs/Makefile \
src/tests/fs/fifofs/t_fifo.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/fs/Makefile
diff -u src/tests/fs/Makefile:1.21 src/tests/fs/Makefile:1.22
--- src/tests/fs/Makefile:1.21	Thu Mar 10 15:02:26 2011
+++ src/tests/fs/Makefile	Tue Dec 20 19:17:06 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.21 2011/03/10 20:02:26 pooka Exp $
+# $NetBSD: Makefile,v 1.22 2011/12/21 00:17:06 christos Exp $
 
 .include bsd.own.mk
 
@@ -6,7 +6,7 @@ TESTSDIR=	${TESTSBASE}/fs
 
 SUBDIR+= 	common .WAIT
 
-TESTS_SUBDIRS+=	ffs hfs kernfs lfs msdosfs nfs nullfs psshfs ptyfs puffs
+TESTS_SUBDIRS+=	ffs fifofs hfs kernfs lfs msdosfs nfs nullfs psshfs ptyfs puffs
 TESTS_SUBDIRS+=	tmpfs umapfs union
 TESTS_SUBDIRS+=	vfs
 

Added files:

Index: src/tests/fs/fifofs/Makefile
diff -u /dev/null src/tests/fs/fifofs/Makefile:1.1
--- /dev/null	Tue Dec 20 19:17:07 2011
+++ src/tests/fs/fifofs/Makefile	Tue Dec 20 19:17:07 2011
@@ -0,0 +1,9 @@
+#	$NetBSD: Makefile,v 1.1 2011/12/21 00:17:07 christos Exp $
+#
+
+TESTSDIR=	${TESTSBASE}/fs/fifo
+WARNS=		4
+
+TESTS_C=	t_fifo
+
+.include bsd.test.mk
Index: src/tests/fs/fifofs/t_fifo.c
diff -u /dev/null src/tests/fs/fifofs/t_fifo.c:1.1
--- /dev/null	Tue Dec 20 19:17:07 2011
+++ src/tests/fs/fifofs/t_fifo.c	Tue Dec 20 19:17:07 2011
@@ -0,0 +1,237 @@
+/* Test case written by Bharat Joshi */
+#include sys/cdefs.h
+__RCSID($NetBSD: t_fifo.c,v 1.1 2011/12/21 00:17:07 christos Exp $);
+
+#include sys/types.h
+#include sys/wait.h
+
+#include stdio.h
+#include stdlib.h
+#include unistd.h
+#include fcntl.h
+#include errno.h
+#include string.h
+#include err.h
+#include signal.h
+
+#ifndef STANDALONE
+#include atf-c.h
+#endif
+
+#define FIFO_FILE_PATH   ./fifo_file
+#define NUM_MESSAGES 20
+#define MSG_SIZE 240
+#define MESSAGE  I am fine
+
+static int verbose = 0;
+
+/*
+ * child_writer
+ *
+ * Function that runs in child context and opens and write to the FIFO.
+ */
+static void
+child_writer(void)
+{
+	ssize_t rv;
+	int fd;
+	size_t count;
+	char message[MSG_SIZE] = MESSAGE;
+	static const struct timespec ts = { 0, 1 };
+
+	/* Open the fifo in write-mode */
+	for (;;) {
+		fd = open(FIFO_FILE_PATH, O_WRONLY, 0);
+		if (fd == -1) {
+			if (errno == EINTR)
+continue;
+			err(1, Child: can't open fifo in write mode);
+		}
+		break;
+	}
+
+	for (count = 0; count  NUM_MESSAGES; count++) {
+		rv = write(fd, message, MSG_SIZE);
+		if (rv == -1) {
+			warn(Child: Failed to write);
+			break;
+		}
+		if (rv != MSG_SIZE)
+			warnx(Child: wrote only %zd, rv);
+		nanosleep(ts, NULL);
+	}
+
+	close(fd);
+	if (verbose) {
+		printf(Child: Closed the fifo file\n);
+		fflush(stdout);
+	}
+}
+
+/*
+ * _sigchild_handler
+ *
+ * Called when a sigchild is delivered
+ */
+static void
+sigchild_handler(int signo)
+{
+	if (verbose) {
+		if (signo == SIGCHLD) {
+			printf(Got sigchild\n);
+		} else {
+			printf(Got %d signal\n, signo);
+		}
+		fflush(stdout);
+	}
+
+}
+
+static int
+run(void)
+{
+	pid_t pid;
+	ssize_t rv;
+	int fd, status;
+	size_t buf_size = MSG_SIZE;
+	char buf[MSG_SIZE];
+	struct sigaction action;
+	static const struct timespec ts = { 0, 5 };
+
+	/* Catch sigchild Signal */
+	memset(action, 0, sizeof(action));
+	action.sa_handler = sigchild_handler;
+	sigemptyset(action.sa_mask);
+
+	if (sigaction(SIGCHLD, action, NULL) == -1)
+		err(1, sigaction);
+
+	(void)unlink(FIFO_FILE_PATH);
+	/* First create a fifo */
+	if (mkfifo(FIFO_FILE_PATH, S_IRUSR | S_IWUSR) == -1)
+		err(1, mkfifo);
+
+	switch ((pid = fork())) {
+	case -1:
+		err(1, fork);
+	case 0:
+		/* Open the file in write mode so that subsequent read 
+		 * from parent side does not block the parent..
+		 */
+		if ((fd = open(FIFO_FILE_PATH, O_WRONLY, 0)) == -1)
+			err(1, failed to open fifo);
+
+		/* In child */
+		child_writer();
+		return 0;
+
+	default:
+		break;
+	}
+
+	if (verbose) {
+		printf(Child pid is %d\n, pid );
+		fflush(stdout);
+	}
+
+	/* In parent */
+	for (;;) {
+		if ((fd = open(FIFO_FILE_PATH, O_RDONLY, 0)) == -1) {
+			if (errno == EINTR)
+continue;
+			else
+err(1, Failed to open the fifo in read mode);
+		}
+		/* Read mode is opened */
+		break;
+
+	}
+
+	nanosleep(ts, NULL);
+	if (verbose) {
+		printf(Was sleeping...\n);
+		fflush(stdout);
+	}
+
+	for (;;) {
+		rv = read(fd, buf, buf_size);
+
+		if (rv == -1) {
+			warn(Failed to read);
+			if (errno == EINTR) {
+if (verbose) {
+	printf(Parent interrupted, 
+	continuing...\n);
+	fflush(stdout);
+}
+continue;
+			

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

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 21 00:23:31 UTC 2011

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

Log Message:
Add a fifofs test.


To generate a diff of this commit:
cvs rdiff -u -r1.427 -r1.428 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.427 src/distrib/sets/lists/tests/mi:1.428
--- src/distrib/sets/lists/tests/mi:1.427	Wed Nov 23 20:49:39 2011
+++ src/distrib/sets/lists/tests/mi	Tue Dec 20 19:23:30 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.427 2011/11/24 01:49:39 christos Exp $
+# $NetBSD: mi,v 1.428 2011/12/21 00:23:30 christos Exp $
 #
 # Note: don't delete entries from here - mark them as obsolete instead.
 #
@@ -235,10 +235,11 @@
 ./usr/libdata/debug/usr/tests/fs/ffs/t_quota2_remount.debug		tests-fs-debug		debug,atf
 ./usr/libdata/debug/usr/tests/fs/ffs/t_renamerace.debug			tests-obsolete		obsolete
 ./usr/libdata/debug/usr/tests/fs/ffs/t_snapshot.debug			tests-fs-debug		debug,atf
-./usr/libdata/debug/usr/tests/fs/ffs/t_snapshot_log.debug			tests-fs-debug		debug,atf
-./usr/libdata/debug/usr/tests/fs/ffs/t_snapshot_v2.debug			tests-fs-debug		debug,atf
+./usr/libdata/debug/usr/tests/fs/ffs/t_snapshot_log.debug		tests-fs-debug		debug,atf
+./usr/libdata/debug/usr/tests/fs/ffs/t_snapshot_v2.debug		tests-fs-debug		debug,atf
+./usr/libdata/debug/usr/tests/fs/fifofs/t_fifo.debug			tests-fs-debug		debug,atf
 ./usr/libdata/debug/usr/tests/fs/hfs	tests-fs-debug
-./usr/libdata/debug/usr/tests/fs/hfs/t_pathconvert.debug			tests-fs-debug		debug,atf
+./usr/libdata/debug/usr/tests/fs/hfs/t_pathconvert.debug		tests-fs-debug		debug,atf
 ./usr/libdata/debug/usr/tests/fs/kernfs	tests-fs-debug
 ./usr/libdata/debug/usr/tests/fs/kernfs/t_basic.debug			tests-fs-debug		debug,atf
 ./usr/libdata/debug/usr/tests/fs/lfs	tests-fs-debug
@@ -1412,19 +1413,20 @@
 ./usr/tests/fs/ffs/rump_quota			tests-obsolete		obsolete
 ./usr/tests/fs/ffs/rump_quotactl		tests-obsolete		obsolete
 ./usr/tests/fs/ffs/rump_repquota		tests-obsolete		obsolete
-./usr/tests/fs/ffs/t_fifos			tests-fs-tests		atf
-./usr/tests/fs/ffs/t_mount			tests-fs-tests		atf
-./usr/tests/fs/ffs/t_renamerace			tests-obsolete		obsolete
-./usr/tests/fs/ffs/t_snapshot			tests-fs-tests		atf
-./usr/tests/fs/ffs/t_snapshot_log		tests-fs-tests		atf
-./usr/tests/fs/ffs/t_snapshot_v2		tests-fs-tests		atf
 ./usr/tests/fs/ffs/t_clearquota			tests-fs-tests		atf
+./usr/tests/fs/ffs/t_fifos			tests-fs-tests		atf
 ./usr/tests/fs/ffs/t_getquota			tests-fs-tests		atf
+./usr/tests/fs/ffs/t_miscquota			tests-fs-tests		atf
+./usr/tests/fs/ffs/t_mount			tests-fs-tests		atf
 ./usr/tests/fs/ffs/t_quota2_1			tests-fs-tests		atf
 ./usr/tests/fs/ffs/t_quota2_remount		tests-fs-tests		atf
 ./usr/tests/fs/ffs/t_quotalimit			tests-fs-tests		atf
+./usr/tests/fs/ffs/t_renamerace			tests-obsolete		obsolete
 ./usr/tests/fs/ffs/t_setquota			tests-fs-tests		atf
-./usr/tests/fs/ffs/t_miscquota			tests-fs-tests		atf
+./usr/tests/fs/ffs/t_snapshot			tests-fs-tests		atf
+./usr/tests/fs/ffs/t_snapshot_log		tests-fs-tests		atf
+./usr/tests/fs/ffs/t_snapshot_v2		tests-fs-tests		atf
+./usr/tests/fs/fifofs/t_fifo			tests-fs-tests		atf
 ./usr/tests/fs/hfstests-fs-tests
 ./usr/tests/fs/hfs/Atffile			tests-fs-tests		atf
 ./usr/tests/fs/hfs/colon.hfs.bz2.uue			tests-fs-tests		atf



CVS commit: src/tests/fs/fifofs

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 21 01:56:17 UTC 2011

Modified Files:
src/tests/fs/fifofs: Makefile

Log Message:
correct install dir


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/fs/fifofs/Makefile

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

Modified files:

Index: src/tests/fs/fifofs/Makefile
diff -u src/tests/fs/fifofs/Makefile:1.1 src/tests/fs/fifofs/Makefile:1.2
--- src/tests/fs/fifofs/Makefile:1.1	Tue Dec 20 19:17:07 2011
+++ src/tests/fs/fifofs/Makefile	Tue Dec 20 20:56:16 2011
@@ -1,7 +1,7 @@
-#	$NetBSD: Makefile,v 1.1 2011/12/21 00:17:07 christos Exp $
+#	$NetBSD: Makefile,v 1.2 2011/12/21 01:56:16 christos Exp $
 #
 
-TESTSDIR=	${TESTSBASE}/fs/fifo
+TESTSDIR=	${TESTSBASE}/fs/fifofs
 WARNS=		4
 
 TESTS_C=	t_fifo



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

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 21 01:57:56 UTC 2011

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

Log Message:
add the directories


To generate a diff of this commit:
cvs rdiff -u -r1.428 -r1.429 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.428 src/distrib/sets/lists/tests/mi:1.429
--- src/distrib/sets/lists/tests/mi:1.428	Tue Dec 20 19:23:30 2011
+++ src/distrib/sets/lists/tests/mi	Tue Dec 20 20:57:55 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.428 2011/12/21 00:23:30 christos Exp $
+# $NetBSD: mi,v 1.429 2011/12/21 01:57:55 christos Exp $
 #
 # Note: don't delete entries from here - mark them as obsolete instead.
 #
@@ -237,6 +237,7 @@
 ./usr/libdata/debug/usr/tests/fs/ffs/t_snapshot.debug			tests-fs-debug		debug,atf
 ./usr/libdata/debug/usr/tests/fs/ffs/t_snapshot_log.debug		tests-fs-debug		debug,atf
 ./usr/libdata/debug/usr/tests/fs/ffs/t_snapshot_v2.debug		tests-fs-debug		debug,atf
+./usr/libdata/debug/usr/tests/fs/fifofs	tests-fs-debug
 ./usr/libdata/debug/usr/tests/fs/fifofs/t_fifo.debug			tests-fs-debug		debug,atf
 ./usr/libdata/debug/usr/tests/fs/hfs	tests-fs-debug
 ./usr/libdata/debug/usr/tests/fs/hfs/t_pathconvert.debug		tests-fs-debug		debug,atf
@@ -1426,6 +1427,7 @@
 ./usr/tests/fs/ffs/t_snapshot			tests-fs-tests		atf
 ./usr/tests/fs/ffs/t_snapshot_log		tests-fs-tests		atf
 ./usr/tests/fs/ffs/t_snapshot_v2		tests-fs-tests		atf
+./usr/tests/fs/fifofstests-fs-tests
 ./usr/tests/fs/fifofs/t_fifo			tests-fs-tests		atf
 ./usr/tests/fs/hfstests-fs-tests
 ./usr/tests/fs/hfs/Atffile			tests-fs-tests		atf



CVS commit: src/etc/mtree

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 21 01:58:46 UTC 2011

Modified Files:
src/etc/mtree: NetBSD.dist.tests

Log Message:
add fifofs


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/etc/mtree/NetBSD.dist.tests

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

Modified files:

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.56 src/etc/mtree/NetBSD.dist.tests:1.57
--- src/etc/mtree/NetBSD.dist.tests:1.56	Fri Nov 11 20:19:40 2011
+++ src/etc/mtree/NetBSD.dist.tests	Tue Dec 20 20:58:46 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.56 2011/11/12 01:19:40 jmmv Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.57 2011/12/21 01:58:46 christos Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -20,6 +20,7 @@
 ./usr/libdata/debug/usr/tests/dev/sysmon
 ./usr/libdata/debug/usr/tests/fs
 ./usr/libdata/debug/usr/tests/fs/ffs
+./usr/libdata/debug/usr/tests/fs/fifofs
 ./usr/libdata/debug/usr/tests/fs/hfs
 ./usr/libdata/debug/usr/tests/fs/kernfs
 ./usr/libdata/debug/usr/tests/fs/lfs
@@ -137,6 +138,7 @@
 ./usr/tests/examples
 ./usr/tests/fs
 ./usr/tests/fs/ffs
+./usr/tests/fs/fifofs
 ./usr/tests/fs/hfs
 ./usr/tests/fs/kernfs
 ./usr/tests/fs/lfs



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

2011-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec 21 02:16:57 UTC 2011

Modified Files:
src/sys/dev/pci/hdaudio: hdafg.c

Log Message:
relax the test for analog devices analog pcbeep widgets


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/hdaudio/hdafg.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/hdaudio/hdafg.c
diff -u src/sys/dev/pci/hdaudio/hdafg.c:1.14 src/sys/dev/pci/hdaudio/hdafg.c:1.15
--- src/sys/dev/pci/hdaudio/hdafg.c:1.14	Mon Dec 19 12:19:26 2011
+++ src/sys/dev/pci/hdaudio/hdafg.c	Wed Dec 21 02:16:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hdafg.c,v 1.14 2011/12/19 12:19:26 jmcneill Exp $ */
+/* $NetBSD: hdafg.c,v 1.15 2011/12/21 02:16:57 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd supp...@precedence.co.uk
@@ -60,7 +60,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hdafg.c,v 1.14 2011/12/19 12:19:26 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: hdafg.c,v 1.15 2011/12/21 02:16:57 jmcneill Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -694,10 +694,7 @@ hdafg_widget_getcaps(struct hdaudio_widg
 		COP_CFG_PORT_CONNECTIVITY(config) ==
 		  COP_PORT_FIXED_FUNCTION 
 		COP_CFG_DEFAULT_DEVICE(config) ==
-		  COP_DEVICE_OTHER 
-		COP_CFG_CONNECTION_TYPE(config) ==
-		  COP_CONN_TYPE_ATAPI_INTERNAL 
-		COP_CFG_COLOR(config) == 0x0) {
+		  COP_DEVICE_OTHER) {
 			pcbeep = true;
 		}
 		break;



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

2011-12-20 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Dec 21 07:36:03 UTC 2011

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

Log Message:
Include the fifofs Atffile


To generate a diff of this commit:
cvs rdiff -u -r1.429 -r1.430 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.429 src/distrib/sets/lists/tests/mi:1.430
--- src/distrib/sets/lists/tests/mi:1.429	Wed Dec 21 01:57:55 2011
+++ src/distrib/sets/lists/tests/mi	Wed Dec 21 07:36:02 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.429 2011/12/21 01:57:55 christos Exp $
+# $NetBSD: mi,v 1.430 2011/12/21 07:36:02 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as obsolete instead.
 #
@@ -1428,6 +1428,7 @@
 ./usr/tests/fs/ffs/t_snapshot_log		tests-fs-tests		atf
 ./usr/tests/fs/ffs/t_snapshot_v2		tests-fs-tests		atf
 ./usr/tests/fs/fifofstests-fs-tests
+./usr/tests/fs/fifofs/Atffile			tests-fs-tests		atf
 ./usr/tests/fs/fifofs/t_fifo			tests-fs-tests		atf
 ./usr/tests/fs/hfstests-fs-tests
 ./usr/tests/fs/hfs/Atffile			tests-fs-tests		atf



CVS commit: src/doc

2011-12-20 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Tue Dec 20 11:18:36 UTC 2011

Modified Files:
src/doc: 3RDPARTY

Log Message:
note new OpenPAM release


To generate a diff of this commit:
cvs rdiff -u -r1.891 -r1.892 src/doc/3RDPARTY

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



CVS commit: src/sys/dev

2011-12-20 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Tue Dec 20 12:45:00 UTC 2011

Modified Files:
src/sys/dev: rndpseudo.c

Log Message:
#include opt_compat_netbsd.h


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/rndpseudo.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/amd64

2011-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 13:17:05 UTC 2011

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

Log Message:
from 
http://www.freshbsd.org/commit/openbsd/ae7f934ae5bdf57dcf3431ba55fd1da93b8f1963

Initialize abridged tag word properly. x87 spec says FNINIT says tag word
contains h (all stack locations empty) which would make abridged tag
word 00h. From the Intel 64 and IA-32 Architectures Software Developer's
Manual:

The FXSAVE instruction saves an abridged version of the x87 FPU tag word
in the FTW field (unlike the FSAVE instruction, which saves the complete
tag word). The tag information is saved in physical register order (R0
through R7), rather than in top-of- stack (TOS) order. With the FXSAVE
instruction, however, only a single bit (1 for valid or 0 for empty) is
saved for each tag.

ok rmind@


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/amd64/amd64/process_machdep.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

2011-12-20 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Tue Dec 20 13:42:19 UTC 2011

Modified Files:
src/sys/dev: rndpseudo.c

Log Message:
Revert previous; the #include was already present, and I got confused
by a merge error.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/rndpseudo.c

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



CVS commit: [yamt-pagecache] src/sys

2011-12-20 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Tue Dec 20 13:46:17 UTC 2011

Modified Files:
src/sys/miscfs/genfs [yamt-pagecache]: genfs_io.c
src/sys/uvm [yamt-pagecache]: uvm_extern.h uvm_vnode.c

Log Message:
don't inline uvn_findpages in genfs_io.


To generate a diff of this commit:
cvs rdiff -u -r1.53.2.5 -r1.53.2.6 src/sys/miscfs/genfs/genfs_io.c
cvs rdiff -u -r1.176.2.4 -r1.176.2.5 src/sys/uvm/uvm_extern.h
cvs rdiff -u -r1.97.2.2 -r1.97.2.3 src/sys/uvm/uvm_vnode.c

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



CVS commit: src

2011-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:39:36 UTC 2011

Modified Files:
src/lib/libc/sys: mmap.2
src/sys/sys: mman.h proc.h
src/sys/uvm: uvm_extern.h uvm_map.c uvm_mmap.c

Log Message:
Add a MAP_NOSYSCALLS flag to mmap. This flag prohibits executing of system
calls from the mapped region. This can be used for emulation perposed or for
extra security in the case of generated code.

Its implemented by adding mapping-attributes to each uvm_map_entry. These can
then be queried when needed.

Currently the MAP_NOSYSCALLS is only implemented for x86 but other
architectures are easy to adapt; see the sys/arch/x86/x86/syscall.c patch.
Port maintainers are encouraged to add them for their processor ports too.
When this feature is not yet implemented for an architecture the
MAP_NOSYSCALLS is simply ignored with virtually no cpu cost..


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/lib/libc/sys/mmap.2
cvs rdiff -u -r1.42 -r1.43 src/sys/sys/mman.h
cvs rdiff -u -r1.311 -r1.312 src/sys/sys/proc.h
cvs rdiff -u -r1.176 -r1.177 src/sys/uvm/uvm_extern.h
cvs rdiff -u -r1.307 -r1.308 src/sys/uvm/uvm_map.c
cvs rdiff -u -r1.139 -r1.140 src/sys/uvm/uvm_mmap.c

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



CVS commit: src/sys/uvm

2011-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:41:01 UTC 2011

Modified Files:
src/sys/uvm: uvm_map.h

Log Message:
Ooops forgot the uvm_map.h


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/uvm/uvm_map.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/x86/x86

2011-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:41:50 UTC 2011

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

Log Message:
Part 2 - x86 implementation of MAP_NOSYSCALLS

Currently the MAP_NOSYSCALLS is only implemented for x86 but other
architectures are easy to adapt; see the sys/arch/x86/x86/syscall.c patch.
Port maintainers are encouraged to add them for their processor ports too.
When this feature is not yet implemented for an architecture the
MAP_NOSYSCALLS is simply ignored with virtually no cpu cost..


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/x86/syscall.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-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:43:52 UTC 2011

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

Log Message:
Add int $80 and sysenter opcodes to the x86 SIGILL opcode detector


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/usermode/usermode/machdep.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-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 15:45:37 UTC 2011

Modified Files:
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: pmap.c syscall.c thunk.c

Log Message:
Use to the MAP_NOSYSCALLS argument to mmap() to allow for NetBSD/usermode to
execute bog-standard native programs.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/usermode/usermode/pmap.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/usermode/usermode/syscall.c
cvs rdiff -u -r1.47 -r1.48 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/compat/sys

2011-12-20 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Tue Dec 20 16:38:06 UTC 2011

Modified Files:
src/sys/compat/sys: rnd.h

Log Message:
allow kernels w/o COMPAT_50 to build


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/compat/sys/rnd.h

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



CVS commit: src/lib/libc/sys

2011-12-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Dec 20 16:43:14 UTC 2011

Modified Files:
src/lib/libc/sys: mmap.2

Log Message:
New sentence, new line. Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/lib/libc/sys/mmap.2

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-12-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 20 16:49:37 UTC 2011

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

Log Message:
Move the diagnostic check for a missing VOP_CLOSE() to the top of vrelel().
As long as we hold the vnode interlock there is no chance for this vnode
to gain new references.

Fixes false alarms observed by Thor Lancelot Simon and reported on tech-kern.

Ok: David Holland dholl...@netbsd.org


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/vfs_vnode.c

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



CVS commit: src/sys/rump/dev/lib/librnd

2011-12-20 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Tue Dec 20 17:09:04 UTC 2011

Modified Files:
src/sys/rump/dev/lib/librnd: Makefile

Log Message:
Put the path to the compat/common directory in a .PATH line, not in
an element of the SRCS list.  This should fix a problem in which build
products were created in the source tree.

Also add a comment about where COMPAT_50 is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/dev/lib/librnd/Makefile

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



CVS commit: src/sys/uvm

2011-12-20 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Dec 20 19:49:36 UTC 2011

Modified Files:
src/sys/uvm: uvm_mmap.c

Log Message:
If we need to set the PK_CHKNOSYSCALL flag in struct proc be so nice to first
take the mutex. Tnx for pointing it out to me.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/uvm/uvm_mmap.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-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 21:01:39 UTC 2011

Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode files.usermode
majors.usermode std.usermode
src/sys/arch/usermode/usermode: machdep.c pmap.c
Added Files:
src/sys/arch/usermode/conf: GENERIC.common GENERIC.i386
Removed Files:
src/sys/arch/usermode/conf: GENERIC GENERIC32
src/sys/arch/usermode/include: urkelvisor.h
src/sys/arch/usermode/usermode: urkelvisor.c

Log Message:
get rid of urkelvisor, and use same MD majors as the host


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r0 src/sys/arch/usermode/conf/GENERIC
cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/conf/GENERIC.common \
src/sys/arch/usermode/conf/GENERIC.i386
cvs rdiff -u -r1.2 -r0 src/sys/arch/usermode/conf/GENERIC32
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/usermode/conf/files.usermode
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/conf/majors.usermode
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/conf/std.usermode
cvs rdiff -u -r1.1 -r0 src/sys/arch/usermode/include/urkelvisor.h
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/usermode/usermode/pmap.c
cvs rdiff -u -r1.9 -r0 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-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 21:07:56 UTC 2011

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

Log Message:
thunk_pollchar: use read instead of getchar


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 21:26:37 UTC 2011

Modified Files:
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: machdep.c thunk.c

Log Message:
set machine_arch to that of the host


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.49 -r1.50 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/dev/pci

2011-12-20 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Dec 20 21:27:29 UTC 2011

Modified Files:
src/sys/dev/pci: if_wmreg.h

Log Message:
Mark all of the Rx descriptor fields 'volatile' so that the compiler
will not re-order accesses.  Some versions of GCC (such as one in NetBSD
5.x) definitely do re-order reads from these fields if they're not
marked volatile.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/pci/if_wmreg.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/dev

2011-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 21:35:16 UTC 2011

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

Log Message:
check return value of write, make sure we send the whole buffer to stdout


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/usermode/dev/ttycons.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-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 20 22:48:59 UTC 2011

Modified Files:
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: machdep.c thunk.c

Log Message:
on second thought, set machine and machine_arch both from the host and
override module_machine


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/usermode/usermode/machdep.c
cvs rdiff -u -r1.50 -r1.51 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

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 20 23:56:29 UTC 2011

Modified Files:
src/sys/compat/linux/common: linux_socket.c
src/sys/dev: kttcp.c
src/sys/kern: sys_socket.c uipc_socket.c uipc_socket2.c uipc_syscalls.c
src/sys/miscfs/fifofs: fifo_vnops.c
src/sys/netiso: tp_usrreq.c
src/sys/sys: socket.h socketvar.h

Log Message:
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
  errors?).


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/kttcp.c
cvs rdiff -u -r1.64 -r1.65 src/sys/kern/sys_socket.c
cvs rdiff -u -r1.205 -r1.206 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.109 -r1.110 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.148 -r1.149 src/sys/kern/uipc_syscalls.c
cvs rdiff -u -r1.70 -r1.71 src/sys/miscfs/fifofs/fifo_vnops.c
cvs rdiff -u -r1.40 -r1.41 src/sys/netiso/tp_usrreq.c
cvs rdiff -u -r1.100 -r1.101 src/sys/sys/socket.h
cvs rdiff -u -r1.126 -r1.127 src/sys/sys/socketvar.h

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



CVS commit: src/tests/fs

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 21 00:17:07 UTC 2011

Modified Files:
src/tests/fs: Makefile
Added Files:
src/tests/fs/fifofs: Makefile t_fifo.c

Log Message:
Add a test for the latest fifofs fix.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/tests/fs/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/fs/fifofs/Makefile \
src/tests/fs/fifofs/t_fifo.c

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



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

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 21 00:23:31 UTC 2011

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

Log Message:
Add a fifofs test.


To generate a diff of this commit:
cvs rdiff -u -r1.427 -r1.428 src/distrib/sets/lists/tests/mi

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



CVS commit: src/tests/fs/fifofs

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 21 01:56:17 UTC 2011

Modified Files:
src/tests/fs/fifofs: Makefile

Log Message:
correct install dir


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/fs/fifofs/Makefile

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



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

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 21 01:57:56 UTC 2011

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

Log Message:
add the directories


To generate a diff of this commit:
cvs rdiff -u -r1.428 -r1.429 src/distrib/sets/lists/tests/mi

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



CVS commit: src/etc/mtree

2011-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 21 01:58:46 UTC 2011

Modified Files:
src/etc/mtree: NetBSD.dist.tests

Log Message:
add fifofs


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/etc/mtree/NetBSD.dist.tests

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



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

2011-12-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec 21 02:16:57 UTC 2011

Modified Files:
src/sys/dev/pci/hdaudio: hdafg.c

Log Message:
relax the test for analog devices analog pcbeep widgets


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/hdaudio/hdafg.c

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



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

2011-12-20 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Dec 21 07:36:03 UTC 2011

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

Log Message:
Include the fifofs Atffile


To generate a diff of this commit:
cvs rdiff -u -r1.429 -r1.430 src/distrib/sets/lists/tests/mi

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