CVS commit: src/bin/sh

2016-05-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun May  8 03:51:15 UTC 2016

Modified Files:
src/bin/sh: redir.c

Log Message:
Whitespace fixes.  No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/bin/sh/redir.c

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

Modified files:

Index: src/bin/sh/redir.c
diff -u src/bin/sh/redir.c:1.43 src/bin/sh/redir.c:1.44
--- src/bin/sh/redir.c:1.43	Mon May  2 01:46:31 2016
+++ src/bin/sh/redir.c	Sun May  8 03:51:15 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: redir.c,v 1.43 2016/05/02 01:46:31 christos Exp $	*/
+/*	$NetBSD: redir.c,v 1.44 2016/05/08 03:51:15 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)redir.c	8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: redir.c,v 1.43 2016/05/02 01:46:31 christos Exp $");
+__RCSID("$NetBSD: redir.c,v 1.44 2016/05/08 03:51:15 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -67,7 +67,7 @@ __RCSID("$NetBSD: redir.c,v 1.43 2016/05
 
 
 #define EMPTY -2		/* marks an unused slot in redirtab */
-#define	CLOSED -1		/* fd was not open before redir */
+#define CLOSED -1		/* fd was not open before redir */
 #ifndef PIPE_BUF
 # define PIPESIZE 4096		/* amount of buffering in a pipe */
 #else
@@ -222,8 +222,8 @@ redirect(union node *redir, int flags)
 		} else {
 			close(fd);
 		}
-if (fd == 0)
-fd0_redirected++;
+		if (fd == 0)
+			fd0_redirected++;
 		openredirect(n, memory, flags);
 	}
 	if (memory[1])
@@ -417,7 +417,7 @@ SHELLPROC {
 int
 fd0_redirected_p(void)
 {
-return fd0_redirected != 0;
+	return fd0_redirected != 0;
 }
 
 /*



CVS commit: src/sys

2016-05-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May  8 01:28:09 UTC 2016

Modified Files:
src/sys/kern: exec_elf.c kern_exec.c kern_pax.c
src/sys/sys: pax.h

Log Message:
Move all the randomization inside kern_pax.c so we can control it directly.
Add debugging flags to be able to set the random number externally.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/kern/exec_elf.c
cvs rdiff -u -r1.426 -r1.427 src/sys/kern/kern_exec.c
cvs rdiff -u -r1.41 -r1.42 src/sys/kern/kern_pax.c
cvs rdiff -u -r1.19 -r1.20 src/sys/sys/pax.h

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

Modified files:

Index: src/sys/kern/exec_elf.c
diff -u src/sys/kern/exec_elf.c:1.82 src/sys/kern/exec_elf.c:1.83
--- src/sys/kern/exec_elf.c:1.82	Sat Mar 19 14:56:37 2016
+++ src/sys/kern/exec_elf.c	Sat May  7 21:28:09 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_elf.c,v 1.82 2016/03/19 18:56:37 christos Exp $	*/
+/*	$NetBSD: exec_elf.c,v 1.83 2016/05/08 01:28:09 christos Exp $	*/
 
 /*-
  * Copyright (c) 1994, 2000, 2005, 2015 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.82 2016/03/19 18:56:37 christos Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.83 2016/05/08 01:28:09 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -76,7 +76,6 @@ __KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -125,32 +124,10 @@ elf_placedynexec(struct exec_package *ep
 		if (ph[i].p_type == PT_LOAD && ph[i].p_align > align)
 			align = ph[i].p_align;
 
-#ifdef PAX_ASLR
-	if (pax_aslr_epp_active(epp)) {
-		size_t pax_align, l2, delta;
-		uint32_t r;
-
-		pax_align = align;
-
-		r = cprng_fast32();
-
-		if (pax_align == 0)
-			pax_align = PGSHIFT;
-		l2 = ilog2(pax_align);
-		delta = PAX_ASLR_DELTA(r, l2, PAX_ASLR_DELTA_EXEC_LEN);
-		offset = ELF_TRUNC(delta, pax_align) + PAGE_SIZE;
-#ifdef PAX_ASLR_DEBUG
-		if (pax_aslr_debug) {
-			uprintf("%s: r=%#x l2=%#zx pax_align=%#zx delta=%#zx\n",
-			__func__, r, l2, pax_align, delta);
-			uprintf("%s: pax offset=%#jx entry=%#jx\n", __func__,
-			(uintmax_t)offset, (uintmax_t)eh->e_entry);
-		}
-#endif /* PAX_ASLR_DEBUG */
-	} else
-#endif /* PAX_ASLR */
-		offset = MAX(align, PAGE_SIZE);
-
+#ifndef PAX_ASLR
+# define pax_aslr_exec_offset(epp, align) MAX(align, PAGE_SIZE)
+#endif
+	offset = (Elf_Addr)pax_aslr_exec_offset(epp, align);
 	offset += epp->ep_vm_minaddr;
 
 	for (i = 0; i < eh->e_phnum; i++)

Index: src/sys/kern/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.426 src/sys/kern/kern_exec.c:1.427
--- src/sys/kern/kern_exec.c:1.426	Mon Apr  4 19:07:06 2016
+++ src/sys/kern/kern_exec.c	Sat May  7 21:28:09 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.426 2016/04/04 23:07:06 christos Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.427 2016/05/08 01:28:09 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.426 2016/04/04 23:07:06 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.427 2016/05/08 01:28:09 christos Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -759,7 +759,7 @@ execve_loadvm(struct lwp *l, const char 
 	 */
 
 #ifdef PAX_ASLR
-#define	ASLR_GAP(epp)	(pax_aslr_epp_active(epp) ? (cprng_fast32() % PAGE_SIZE) : 0)
+#define	ASLR_GAP(epp)	pax_aslr_stack_gap(epp)
 #else
 #define	ASLR_GAP(epp)	0
 #endif

Index: src/sys/kern/kern_pax.c
diff -u src/sys/kern/kern_pax.c:1.41 src/sys/kern/kern_pax.c:1.42
--- src/sys/kern/kern_pax.c:1.41	Sun Apr 10 11:41:05 2016
+++ src/sys/kern/kern_pax.c	Sat May  7 21:28:09 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_pax.c,v 1.41 2016/04/10 15:41:05 christos Exp $	*/
+/*	$NetBSD: kern_pax.c,v 1.42 2016/05/08 01:28:09 christos Exp $	*/
 
 /*
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_pax.c,v 1.41 2016/04/10 15:41:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_pax.c,v 1.42 2016/05/08 01:28:09 christos Exp $");
 
 #include "opt_pax.h"
 
@@ -73,6 +73,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_pax.c,v
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -136,8 +137,12 @@ int pax_mprotect_debug;
 int pax_aslr_debug;
 /* flag set means disable */
 int pax_aslr_flags;
-#define PAX_ASLR_STACK	1
-#define PAX_ASLR_MMAP	2
+uint32_t pax_aslr_rand;
+#define PAX_ASLR_STACK		0x01
+#define PAX_ASLR_STACK_GAP	0x02
+#define PAX_ASLR_MMAP		0x04
+#define PAX_ASLR_EXEC_OFFSET	0x08
+#define PAX_ASLR_FIXED		0x10
 #endif
 
 static int pax_segvguard_enabled = 1;
@@ -283,6 +288,12 @@ SYSCTL_SETUP(sysctl_security_pax_setup, 
 		   SYSCTL_DESCR("Disable/Enable select ASLR features."),
 		   NULL, 0, _aslr_flags, 0,
 		   CTL_CREATE, CTL_EOL);
+	sysctl_createv(clog, 0, , NULL,
+		   

CVS commit: src/tests/bin/sh

2016-05-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat May  7 23:51:30 UTC 2016

Modified Files:
src/tests/bin/sh: t_exit.sh

Log Message:
Remove the trap_zero__explicit_return test case - it was testing undefined
behaviour (and failed with the NetBSD shell, and was marked as expected to
fail.)   Other shells do different things.   The test was worthless, and is
now gone.

OK christos@


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/bin/sh/t_exit.sh

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

Modified files:

Index: src/tests/bin/sh/t_exit.sh
diff -u src/tests/bin/sh/t_exit.sh:1.5 src/tests/bin/sh/t_exit.sh:1.6
--- src/tests/bin/sh/t_exit.sh:1.5	Tue Mar  1 12:39:35 2016
+++ src/tests/bin/sh/t_exit.sh	Sat May  7 23:51:30 2016
@@ -1,4 +1,4 @@
-# $NetBSD: t_exit.sh,v 1.5 2016/03/01 12:39:35 christos Exp $
+# $NetBSD: t_exit.sh,v 1.6 2016/05/07 23:51:30 kre Exp $
 #
 # Copyright (c) 2007 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -105,21 +105,6 @@ trap_zero__explicit_exit_body() {
 	# atf_check -s exit:0 -o match:exiting -e empty /bin/ksh helper.sh
 }
 
-# Is return really defined to operate other than in functions (& '.') ??
-atf_test_case trap_zero__explicit_return
-trap_zero__explicit_return_head() {
-	atf_set "descr" "Tests that the trap statement in a subshell in a " \
-			"script works when the subshell executes a return"
-}
-trap_zero__explicit_return_body() {
-	echo '( trap "echo exiting" 0; return; echo NO_NO_NO )' >helper.sh
-	atf_expect_fail "return from a sub-shell not defined and does not work"
-	atf_check -s exit:0 -o match:exiting -o not-match:NO_NO -e empty \
-		${TEST_SH} helper.sh
-	# test ksh by setting TEST_SH to /bin/ksh and run the entire set...
-	# atf_check -s exit:0 -o match:exiting -e empty /bin/ksh helper.sh
-}
-
 atf_test_case simple_exit
 simple_exit_head() {
 	atf_set "descr" "Tests that various values for exit status work"
@@ -166,7 +151,6 @@ atf_init_test_cases() {
 	atf_add_test_case trap_subshell
 	atf_add_test_case trap_zero__implicit_exit
 	atf_add_test_case trap_zero__explicit_exit
-	atf_add_test_case trap_zero__explicit_return
 	atf_add_test_case simple_exit
 	atf_add_test_case subshell_exit
 	atf_add_test_case subshell_background



CVS commit: src/sys/kern

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 22:12:29 UTC 2016

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

Log Message:
Tweak comment on wapbl_flush.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.76 src/sys/kern/vfs_wapbl.c:1.77
--- src/sys/kern/vfs_wapbl.c:1.76	Sat May  7 21:15:38 2016
+++ src/sys/kern/vfs_wapbl.c	Sat May  7 22:12:29 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.76 2016/05/07 21:15:38 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.77 2016/05/07 22:12:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.76 2016/05/07 21:15:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.77 2016/05/07 22:12:29 riastradh Exp $");
 
 #include 
 #include 
@@ -1536,8 +1536,10 @@ wapbl_biodone(struct buf *bp)
  *	2. Wait for enough space in the log for the current transaction.
  *	3. Synchronously write the new log records, advancing the
  *	   circular queue head.
- *	4. If wait is true, also wait for all the logged writes to
- *	   complete so that the log is empty on return.
+ *	4. Issue the pending block writes asynchronously, now that they
+ *	   are recorded in the log and can be replayed after crash.
+ *	5. If wait is true, wait for all writes to complete and for the
+ *	   log to become empty.
  *
  *	On failure, call the file system's wl_flush_abort callback.
  */



CVS commit: src/sys/kern

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 21:15:38 UTC 2016

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

Log Message:
Use %jx and a cast to uintmax_t, not %x, to print a dev_t.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.75 src/sys/kern/vfs_wapbl.c:1.76
--- src/sys/kern/vfs_wapbl.c:1.75	Sat May  7 21:11:51 2016
+++ src/sys/kern/vfs_wapbl.c	Sat May  7 21:15:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.75 2016/05/07 21:11:51 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.76 2016/05/07 21:15:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.75 2016/05/07 21:11:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.76 2016/05/07 21:15:38 riastradh Exp $");
 
 #include 
 #include 
@@ -2131,8 +2131,8 @@ wapbl_cache_sync(struct wapbl *wl, const
 	FWRITE, FSCRED);
 	if (error) {
 		WAPBL_PRINTF(WAPBL_PRINT_ERROR,
-		("wapbl_cache_sync: DIOCCACHESYNC on dev 0x%x "
-		"returned %d\n", wl->wl_devvp->v_rdev, error));
+		("wapbl_cache_sync: DIOCCACHESYNC on dev 0x%jx "
+		"returned %d\n", (uintmax_t)wl->wl_devvp->v_rdev, error));
 	}
 	if (verbose) {
 		struct bintime d;



CVS commit: src/sys/kern

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 21:11:51 UTC 2016

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

Log Message:
Clarify comment about early exit from wapbl_flush.

Note possible bug.  Requires further analysis.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.74 src/sys/kern/vfs_wapbl.c:1.75
--- src/sys/kern/vfs_wapbl.c:1.74	Sat May  7 20:59:46 2016
+++ src/sys/kern/vfs_wapbl.c	Sat May  7 21:11:51 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.74 2016/05/07 20:59:46 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.75 2016/05/07 21:11:51 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.74 2016/05/07 20:59:46 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.75 2016/05/07 21:11:51 riastradh Exp $");
 
 #include 
 #include 
@@ -1580,8 +1580,15 @@ wapbl_flush(struct wapbl *wl, int waitfo
 	wl->wl_dealloccnt);
 
 	/*
-	 * Now that we are fully locked and flushed,
-	 * do another check for nothing to do.
+	 * Now that we are exclusively locked and the file system has
+	 * issued any deferred block writes for this transaction, check
+	 * whether there are any blocks to write to the log.  If not,
+	 * skip waiting for space or writing any log entries.
+	 *
+	 * XXX Shouldn't this also check wl_dealloccnt and
+	 * wl_inohashcnt?  Perhaps wl_dealloccnt doesn't matter if the
+	 * file system didn't produce any blocks as a consequence of
+	 * it, but the same does not seem to be so of wl_inohashcnt.
 	 */
 	if (wl->wl_bufcount == 0) {
 		goto wait_out;



CVS commit: src/sys/kern

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 20:59:46 UTC 2016

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

Log Message:
Omit unused parameter to wapbl_fini.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.73 src/sys/kern/vfs_wapbl.c:1.74
--- src/sys/kern/vfs_wapbl.c:1.73	Sat May  7 20:39:33 2016
+++ src/sys/kern/vfs_wapbl.c	Sat May  7 20:59:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.73 2016/05/07 20:39:33 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.74 2016/05/07 20:59:46 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.73 2016/05/07 20:39:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.74 2016/05/07 20:59:46 riastradh Exp $");
 
 #include 
 #include 
@@ -331,7 +331,7 @@ wapbl_init(void)
 }
 
 static int
-wapbl_fini(bool interface)
+wapbl_fini(void)
 {
 
 	if (wapbl_sysctl != NULL)
@@ -3135,7 +3135,7 @@ wapbl_modcmd(modcmd_t cmd, void *arg)
 		wapbl_init();
 		return 0;
 	case MODULE_CMD_FINI:
-		return wapbl_fini(true);
+		return wapbl_fini();
 	default:
 		return ENOTTY;
 	}



CVS commit: src/sys/kern

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 20:39:33 UTC 2016

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

Log Message:
Delete debugging option wapbl_lazy_truncate.  Simplify.

Likely nobody has used this in the past decade -- you would have to
enter ddb and write 1 to it in order to enable it anyway.

Patch prepared by coypu.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.72 src/sys/kern/vfs_wapbl.c:1.73
--- src/sys/kern/vfs_wapbl.c:1.72	Sat May  7 20:18:44 2016
+++ src/sys/kern/vfs_wapbl.c	Sat May  7 20:39:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.72 2016/05/07 20:18:44 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.73 2016/05/07 20:39:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.72 2016/05/07 20:18:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.73 2016/05/07 20:39:33 riastradh Exp $");
 
 #include 
 #include 
@@ -269,12 +269,6 @@ int wapbl_replay_verify(struct wapbl_rep
 
 static int wapbl_replay_isopen1(struct wapbl_replay *);
 
-/*
- * This is useful for debugging.  If set, the log will
- * only be truncated when necessary.
- */
-int wapbl_lazy_truncate = 0;
-
 struct wapbl_ops wapbl_ops = {
 	.wo_wapbl_discard	= wapbl_discard,
 	.wo_wapbl_replay_isopen	= wapbl_replay_isopen1,
@@ -1295,19 +1289,18 @@ wapbl_advance_tail(size_t size, size_t o
 //
 
 /*
- * wapbl_truncate(wl, minfree, waitonly)
+ * wapbl_truncate(wl, minfree)
  *
  *	Wait until at least minfree bytes are available in the log.
  *
- *	If it was necessary to wait for writes to complete, and if
- *	waitonly is not true, advance the circular queue tail to
- *	reflect the new write completions and issue a write commit to
- *	the log.
+ *	If it was necessary to wait for writes to complete,
+ *	advance the circular queue tail to reflect the new write
+ *	completions and issue a write commit to the log.
  *
  *	=> Caller must hold wl->wl_rwlock writer lock.
  */
 static int
-wapbl_truncate(struct wapbl *wl, size_t minfree, int waitonly)
+wapbl_truncate(struct wapbl *wl, size_t minfree)
 {
 	size_t delta;
 	size_t avail;
@@ -1366,9 +1359,6 @@ wapbl_truncate(struct wapbl *wl, size_t 
 	if (error)
 		return error;
 
-	if (waitonly)
-		return 0;
-
 	/*
 	 * This is where head, tail and delta are unprotected
 	 * from races against itself or flush.  This is ok since
@@ -1624,7 +1614,7 @@ wapbl_flush(struct wapbl *wl, int waitfo
 		panic("wapbl_flush: current transaction too big to flush");
 	}
 
-	error = wapbl_truncate(wl, flushsize, 0);
+	error = wapbl_truncate(wl, flushsize);
 	if (error)
 		goto out;
 
@@ -1658,13 +1648,11 @@ wapbl_flush(struct wapbl *wl, int waitfo
 	flushsize);
 
 	/* Opportunistically move the tail forward if we can */
-	if (!wapbl_lazy_truncate) {
-		mutex_enter(>wl_mtx);
-		delta = wl->wl_reclaimable_bytes;
-		mutex_exit(>wl_mtx);
-		wapbl_advance_tail(wl->wl_circ_size, wl->wl_circ_off, delta,
-		, );
-	}
+	mutex_enter(>wl_mtx);
+	delta = wl->wl_reclaimable_bytes;
+	mutex_exit(>wl_mtx);
+	wapbl_advance_tail(wl->wl_circ_size, wl->wl_circ_off, delta,
+	, );
 
 	error = wapbl_write_commit(wl, head, tail);
 	if (error)
@@ -1754,7 +1742,7 @@ wapbl_flush(struct wapbl *wl, int waitfo
 	 */
 	if (waitfor) {
 		error = wapbl_truncate(wl, wl->wl_circ_size - 
-			wl->wl_reserved_bytes, wapbl_lazy_truncate);
+			wl->wl_reserved_bytes);
 	}
 
  out:



CVS commit: src/sys/kern

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 20:18:44 UTC 2016

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

Log Message:
Turn WAPBL_DEBUG panic or KASSERT into KASSERTMSG

>From coypu.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.71 src/sys/kern/vfs_wapbl.c:1.72
--- src/sys/kern/vfs_wapbl.c:1.71	Sat May  7 20:16:38 2016
+++ src/sys/kern/vfs_wapbl.c	Sat May  7 20:18:44 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.71 2016/05/07 20:16:38 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.72 2016/05/07 20:18:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.71 2016/05/07 20:16:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.72 2016/05/07 20:18:44 riastradh Exp $");
 
 #include 
 #include 
@@ -1650,16 +1650,12 @@ wapbl_flush(struct wapbl *wl, int waitfo
 
 	wapbl_advance_head(wl->wl_circ_size, wl->wl_circ_off, flushsize,
 	, );
-#ifdef WAPBL_DEBUG
-	if (head != off) {
-		panic("lost head! head=%"PRIdMAX" tail=%" PRIdMAX
-		  " off=%"PRIdMAX" flush=%zu",
-		  (intmax_t)head, (intmax_t)tail, (intmax_t)off,
-		  flushsize);
-	}
-#else
-	KASSERT(head == off);
-#endif
+
+	KASSERTMSG(head == off,
+	"lost head! head=%"PRIdMAX" tail=%" PRIdMAX
+	" off=%"PRIdMAX" flush=%zu",
+	(intmax_t)head, (intmax_t)tail, (intmax_t)off,
+	flushsize);
 
 	/* Opportunistically move the tail forward if we can */
 	if (!wapbl_lazy_truncate) {



CVS commit: src/sys/kern

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 20:16:38 UTC 2016

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

Log Message:
Document log layout and internal subroutines of vfs_wapbl.c.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.70 src/sys/kern/vfs_wapbl.c:1.71
--- src/sys/kern/vfs_wapbl.c:1.70	Sat May  7 17:47:34 2016
+++ src/sys/kern/vfs_wapbl.c	Sat May  7 20:16:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.70 2016/05/07 17:47:34 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.71 2016/05/07 20:16:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.70 2016/05/07 17:47:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.71 2016/05/07 20:16:38 riastradh Exp $");
 
 #include 
 #include 
@@ -127,12 +127,42 @@ struct wapbl {
 	off_t wl_head;		/* l:	Byte offset of log head */
 	off_t wl_tail;		/* l:	Byte offset of log tail */
 	/*
-	 * head == tail == 0 means log is empty
-	 * head == tail != 0 means log is full
-	 * see assertions in wapbl_advance() for other boundary conditions.
-	 * only truncate moves the tail, except when flush sets it to
-	 * wl_header_size only flush moves the head, except when truncate
-	 * sets it to 0.
+	 * WAPBL log layout, stored on wl_devvp at wl_logpbn:
+	 *
+	 *  ___ wl_circ_size __
+	 * /   \
+	 * +-+-+---+--++
+	 * [ commit0 | commit1 | CCWCW |  | CCCWCW ]
+	 * +-+-+---+--++
+	 *   wl_circ_off --^   ^-- wl_head^-- wl_tail
+	 *
+	 * commit0 and commit1 are commit headers.  A commit header has
+	 * a generation number, indicating which of the two headers is
+	 * more recent, and an assignment of head and tail pointers.
+	 * The rest is a circular queue of log records, starting at
+	 * the byte offset wl_circ_off.
+	 *
+	 * E marks empty space for records.
+	 * W marks records for block writes issued but waiting.
+	 * C marks completed records.
+	 *
+	 * wapbl_flush writes new records to empty `E' spaces after
+	 * wl_head from the current transaction in memory.
+	 *
+	 * wapbl_truncate advances wl_tail past any completed `C'
+	 * records, freeing them up for use.
+	 *
+	 * head == tail == 0 means log is empty.
+	 * head == tail != 0 means log is full.
+	 *
+	 * See assertions in wapbl_advance() for other boundary
+	 * conditions.
+	 *
+	 * Only wapbl_flush moves the head, except when wapbl_truncate
+	 * sets it to 0 to indicate that the log is empty.
+	 *
+	 * Only wapbl_truncate moves the tail, except when wapbl_flush
+	 * sets it to wl_circ_off to indicate that the log is full.
 	 */
 
 	struct wapbl_wc_header *wl_wc_header;	/* l	*/
@@ -721,6 +751,11 @@ wapbl_stop(struct wapbl *wl, int force)
 	return 0;
 }
 
+//
+/*
+ * Unbuffered disk I/O
+ */
+
 static int
 wapbl_doio(void *data, size_t len, struct vnode *devvp, daddr_t pbn, int flags)
 {
@@ -771,6 +806,12 @@ wapbl_doio(void *data, size_t len, struc
 	return error;
 }
 
+/*
+ * wapbl_write(data, len, devvp, pbn)
+ *
+ *	Synchronously write len bytes from data to physical block pbn
+ *	on devvp.
+ */
 int
 wapbl_write(void *data, size_t len, struct vnode *devvp, daddr_t pbn)
 {
@@ -778,6 +819,12 @@ wapbl_write(void *data, size_t len, stru
 	return wapbl_doio(data, len, devvp, pbn, B_WRITE);
 }
 
+/*
+ * wapbl_read(data, len, devvp, pbn)
+ *
+ *	Synchronously read len bytes into data from physical block pbn
+ *	on devvp.
+ */
 int
 wapbl_read(void *data, size_t len, struct vnode *devvp, daddr_t pbn)
 {
@@ -785,8 +832,16 @@ wapbl_read(void *data, size_t len, struc
 	return wapbl_doio(data, len, devvp, pbn, B_READ);
 }
 
+//
+/*
+ * Buffered disk writes -- try to coalesce writes and emit
+ * MAXPHYS-aligned blocks.
+ */
+
 /*
- * Flush buffered data if any.
+ * wapbl_buffered_flush(wl)
+ *
+ *	Flush any buffered writes from wapbl_buffered_write.
  */
 static int
 wapbl_buffered_flush(struct wapbl *wl)
@@ -804,8 +859,11 @@ wapbl_buffered_flush(struct wapbl *wl)
 }
 
 /*
- * Write data to the log.
- * Try to coalesce writes and emit MAXPHYS aligned blocks.
+ * wapbl_buffered_write(data, len, wl, pbn)
+ *
+ *	Write len bytes from data to physical block pbn on
+ *	wl->wl_devvp.  The write may not complete until
+ *	wapbl_buffered_flush.
  */
 static int
 wapbl_buffered_write(void *data, size_t len, struct wapbl *wl, daddr_t pbn)
@@ -861,8 +919,18 @@ wapbl_buffered_write(void *data, size_t 
 }
 
 /*

CVS commit: src/bin/sh

2016-05-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat May  7 20:07:47 UTC 2016

Modified Files:
src/bin/sh: jobs.c

Log Message:
Slightly improve "jobs" command output in cases where a job includes
embedded background commands or pipelines.   (just slightly...)
OK christos@


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/bin/sh/jobs.c

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

Modified files:

Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.78 src/bin/sh/jobs.c:1.79
--- src/bin/sh/jobs.c:1.78	Tue May  3 23:55:12 2016
+++ src/bin/sh/jobs.c	Sat May  7 20:07:47 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: jobs.c,v 1.78 2016/05/03 23:55:12 kre Exp $	*/
+/*	$NetBSD: jobs.c,v 1.79 2016/05/07 20:07:47 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)jobs.c	8.5 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: jobs.c,v 1.78 2016/05/03 23:55:12 kre Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.79 2016/05/07 20:07:47 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -1284,6 +1284,8 @@ cmdtxt(union node *n)
 			if (lp->next)
 cmdputs(" | ");
 		}
+		if (n->npipe.backgnd)
+			cmdputs(" &");
 		break;
 	case NSUBSHELL:
 		cmdputs("(");
@@ -1344,6 +1346,8 @@ until:
 	case NCMD:
 		cmdlist(n->ncmd.args, 1);
 		cmdlist(n->ncmd.redirect, 0);
+		if (n->ncmd.backgnd)
+			cmdputs(" &");
 		break;
 	case NARG:
 		cmdputs(n->narg.text);



CVS commit: src/bin/sh

2016-05-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat May  7 20:06:30 UTC 2016

Modified Files:
src/bin/sh: input.c

Log Message:
PR bin/51119 - don't leak FDs in unusual error cases.   OK christos@


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/bin/sh/input.c

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

Modified files:

Index: src/bin/sh/input.c
diff -u src/bin/sh/input.c:1.49 src/bin/sh/input.c:1.50
--- src/bin/sh/input.c:1.49	Mon May  2 01:46:31 2016
+++ src/bin/sh/input.c	Sat May  7 20:06:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: input.c,v 1.49 2016/05/02 01:46:31 christos Exp $	*/
+/*	$NetBSD: input.c,v 1.50 2016/05/07 20:06:30 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)input.c	8.3 (Berkeley) 6/9/95";
 #else
-__RCSID("$NetBSD: input.c,v 1.49 2016/05/02 01:46:31 christos Exp $");
+__RCSID("$NetBSD: input.c,v 1.50 2016/05/07 20:06:30 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -404,11 +404,15 @@ setinputfile(const char *fname, int push
 	 */
 	if (lseek(fd, 0, SEEK_SET) == 0) {
 		if (read(fd, magic, 4) == 4) {
-			if (memcmp(magic, "\177ELF", 4) == 0)
+			if (memcmp(magic, "\177ELF", 4) == 0) {
+(void)close(fd);
 error("Cannot execute ELF binary %s", fname);
+			}
 		}
-		if (lseek(fd, 0, SEEK_SET) != 0)
+		if (lseek(fd, 0, SEEK_SET) != 0) {
+			(void)close(fd);
 			error("Cannot rewind the file %s", fname);
+		}
 	}
 
 	fd2 = to_upper_fd(fd);	/* closes fd, returns higher equiv */



CVS commit: src/sys/kern

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 17:47:34 UTC 2016

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

Log Message:
KASSERT(A); KASSERT(B) instead of KASSERT(A && B).


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.69 src/sys/kern/vfs_wapbl.c:1.70
--- src/sys/kern/vfs_wapbl.c:1.69	Sat May  7 17:12:22 2016
+++ src/sys/kern/vfs_wapbl.c	Sat May  7 17:47:34 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.69 2016/05/07 17:12:22 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.70 2016/05/07 17:47:34 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.69 2016/05/07 17:12:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.70 2016/05/07 17:47:34 riastradh Exp $");
 
 #include 
 #include 
@@ -1505,8 +1505,8 @@ wapbl_flush(struct wapbl *wl, int waitfo
 		goto out;
 
 	off = wl->wl_head;
-	KASSERT((off == 0) || ((off >= wl->wl_circ_off) && 
-	  (off < wl->wl_circ_off + wl->wl_circ_size)));
+	KASSERT((off == 0) || (off >= wl->wl_circ_off));
+	KASSERT((off == 0) || (off < wl->wl_circ_off + wl->wl_circ_size));
 	error = wapbl_write_blocks(wl, );
 	if (error)
 		goto out;



CVS commit: src/sys/kern

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 17:12:22 UTC 2016

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

Log Message:
Rename labels to make wapbl_flush a little easier to follow.

out ---> wait_out
out2 ---> out

>From coypu.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.68 src/sys/kern/vfs_wapbl.c:1.69
--- src/sys/kern/vfs_wapbl.c:1.68	Sat May  7 06:38:47 2016
+++ src/sys/kern/vfs_wapbl.c	Sat May  7 17:12:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.68 2016/05/07 06:38:47 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.69 2016/05/07 17:12:22 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.68 2016/05/07 06:38:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.69 2016/05/07 17:12:22 riastradh Exp $");
 
 #include 
 #include 
@@ -1470,7 +1470,7 @@ wapbl_flush(struct wapbl *wl, int waitfo
 	 * do another check for nothing to do.
 	 */
 	if (wl->wl_bufcount == 0) {
-		goto out;
+		goto wait_out;
 	}
 
 #if 0
@@ -1502,20 +1502,20 @@ wapbl_flush(struct wapbl *wl, int waitfo
 
 	error = wapbl_truncate(wl, flushsize, 0);
 	if (error)
-		goto out2;
+		goto out;
 
 	off = wl->wl_head;
 	KASSERT((off == 0) || ((off >= wl->wl_circ_off) && 
 	  (off < wl->wl_circ_off + wl->wl_circ_size)));
 	error = wapbl_write_blocks(wl, );
 	if (error)
-		goto out2;
+		goto out;
 	error = wapbl_write_revocations(wl, );
 	if (error)
-		goto out2;
+		goto out;
 	error = wapbl_write_inodes(wl, );
 	if (error)
-		goto out2;
+		goto out;
 
 	reserved = 0;
 	if (wl->wl_inohashcnt)
@@ -1548,7 +1548,7 @@ wapbl_flush(struct wapbl *wl, int waitfo
 
 	error = wapbl_write_commit(wl, head, tail);
 	if (error)
-		goto out2;
+		goto out;
 
 	we = pool_get(_entry_pool, PR_WAITOK);
 
@@ -1626,7 +1626,7 @@ wapbl_flush(struct wapbl *wl, int waitfo
 		 curproc->p_pid, curlwp->l_lid));
 #endif
 
- out:
+ wait_out:
 
 	/*
 	 * If the waitfor flag is set, don't return until everything is
@@ -1637,7 +1637,7 @@ wapbl_flush(struct wapbl *wl, int waitfo
 			wl->wl_reserved_bytes, wapbl_lazy_truncate);
 	}
 
- out2:
+ out:
 	if (error) {
 		wl->wl_flush_abort(wl->wl_mount, wl->wl_deallocblks,
 		wl->wl_dealloclens, wl->wl_dealloccnt);



CVS commit: src/sys/fs/msdosfs

2016-05-07 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  7 16:43:02 UTC 2016

Modified Files:
src/sys/fs/msdosfs: msdosfs_fat.c

Log Message:
fix DEBUG build


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/fs/msdosfs/msdosfs_fat.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/fs/msdosfs/msdosfs_fat.c
diff -u src/sys/fs/msdosfs/msdosfs_fat.c:1.30 src/sys/fs/msdosfs/msdosfs_fat.c:1.31
--- src/sys/fs/msdosfs/msdosfs_fat.c:1.30	Tue May  3 18:17:28 2016
+++ src/sys/fs/msdosfs/msdosfs_fat.c	Sat May  7 16:43:02 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_fat.c,v 1.30 2016/05/03 18:17:28 mlelstv Exp $	*/
+/*	$NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.30 2016/05/03 18:17:28 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $");
 
 /*
  * kernel include files.
@@ -279,7 +279,7 @@ pcbmap(struct denode *dep, u_long findcn
 		 */
 		if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster) {
 			DPRINTF(("%s(cn, %lu not in %lu..%lu)\n", __func__,
-cn, CLUST_FIRST, pmp->pm_maxcluster));
+cn, (u_long)CLUST_FIRST, pmp->pm_maxcluster));
 			if (bp)
 brelse(bp, 0);
 			return (EINVAL);



CVS commit: src/share/man/man9

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 16:01:00 UTC 2016

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

Log Message:
Clarify wording about shared and exclusive locks.

Maybe this isn't important for users of wapbl, but it likely is
helpful for working in wapbl internals.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/share/man/man9/wapbl.9

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

Modified files:

Index: src/share/man/man9/wapbl.9
diff -u src/share/man/man9/wapbl.9:1.12 src/share/man/man9/wapbl.9:1.13
--- src/share/man/man9/wapbl.9:1.12	Sat May  7 06:47:44 2016
+++ src/share/man/man9/wapbl.9	Sat May  7 16:01:00 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: wapbl.9,v 1.12 2016/05/07 06:47:44 riastradh Exp $
+.\"	$NetBSD: wapbl.9,v 1.13 2016/05/07 16:01:00 riastradh Exp $
 .\"
 .\" Copyright (c) 2015 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -156,22 +156,31 @@ method should call
 .Pp
 Before issuing any
 .Xr buffercache 9
-writes, the file system must lock the current
+writes, the file system must acquire a shared lock on the current
 .Nm
 transaction with
 .Fn wapbl_begin ,
 which may sleep until there is room in the transaction for new writes.
-After issuing the writes, the file system must unlock the transaction
-with
+After issuing the writes, the file system must release its shared lock
+on the transaction with
 .Fn wapbl_end .
 Either all writes issued between
 .Fn wapbl_begin
 and
 .Fn wapbl_end
 will complete, or none of them will.
+.Pp
+File systems may also witness an
+.Em exclusive
+lock on the current transaction when
+.Nm
+is flushing the transaction to disk, or aborting a flush, and invokes a
+file system's callback.
 File systems can assert that the transaction is locked with
 .Fn wapbl_jlock_assert ,
-or not exclusively locked, with
+or not
+.Em exclusively
+locked, with
 .Fn wapbl_junlock_assert .
 .Pp
 If a file system requires multiple transactions to initialize an
@@ -271,8 +280,8 @@ is a callback that
 .Nm
 will invoke as
 .Fa flushfn Ns ( Fa mp , Fa deallocblks , Fa dealloclens , Fa dealloccnt )
-just before it flushes a transaction to disk, with the transaction
-locked exclusively, where
+just before it flushes a transaction to disk, with the an exclusive
+lock held on the transaction, where
 .Fa mp
 is the mount point passed to
 .Fn wapbl_start ,
@@ -312,9 +321,10 @@ free memory associated with
 and return zero.
 .It Fn wapbl_begin wl file line
 Wait for space in the current transaction for new writes, flushing it
-if necessary, and lock it.
+if necessary, and acquire a shared lock on it.
 .Pp
-The lock is not exclusive: other threads may lock the transaction too.
+The lock is not exclusive: other threads may acquire shared locks on
+the transaction too.
 The lock is not recursive: a thread may not acquire it again without
 calling
 .Fa wapbl_end
@@ -328,15 +338,20 @@ and
 are the file name and line number of the caller for debugging
 purposes.
 .It Fn wapbl_end wl
-Unlock the transaction.
+Release a shared lock on the transaction acquired with
+.Fn wapbl_begin .
 .It Fn wapbl_flush wl wait
 Flush the current transaction to disk.
 If
 .Fa wait
 is nonzero, wait for all writes in the current transaction to
 complete.
+.Pp
+The current transaction must not be locked.
 .It Fn wapbl_discard wl
 Discard the current transaction, permanently losing any writes in it.
+.Pp
+The current transaction must not be locked.
 .It Fn wapbl_add_buf wl bp
 Add the buffer
 .Fa bp
@@ -421,7 +436,8 @@ and
 .Fn wapbl_end .
 .Pp
 There is no way to assert that the current transaction is not locked at
-all -- i.e., that the caller may lock the transaction with
+all -- i.e., that the caller may acquire a shared lock on the
+transaction with
 .Fn wapbl_begin
 without danger of deadlock.
 .El



CVS commit: src/sys/dev/sbus

2016-05-07 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat May  7 15:32:08 UTC 2016

Modified Files:
src/sys/dev/sbus: mgx.c

Log Message:
add Sun /dev/fb* style goop


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/sbus/mgx.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/sbus/mgx.c
diff -u src/sys/dev/sbus/mgx.c:1.8 src/sys/dev/sbus/mgx.c:1.9
--- src/sys/dev/sbus/mgx.c:1.8	Fri Mar  4 22:08:09 2016
+++ src/sys/dev/sbus/mgx.c	Sat May  7 15:32:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mgx.c,v 1.8 2016/03/04 22:08:09 macallan Exp $ */
+/*	$NetBSD: mgx.c,v 1.9 2016/05/07 15:32:08 macallan Exp $ */
 
 /*-
  * Copyright (c) 2014 Michael Lorenz
@@ -29,7 +29,7 @@
 /* a console driver for the SSB 4096V-MGX graphics card */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mgx.c,v 1.8 2016/03/04 22:08:09 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mgx.c,v 1.9 2016/05/07 15:32:08 macallan Exp $");
 
 #include 
 #include 
@@ -58,11 +58,14 @@ __KERNEL_RCSID(0, "$NetBSD: mgx.c,v 1.8 
 #include 
 #include 
 
+#include "ioconf.h"
+
 #include "opt_wsemul.h"
 #include "opt_mgx.h"
 
 struct mgx_softc {
 	device_t	sc_dev;
+	struct fbdevice	sc_fb;		/* frame buffer device */
 	bus_space_tag_t sc_tag;
 	bus_space_handle_t sc_blith;
 	bus_space_handle_t sc_vgah;
@@ -136,6 +139,35 @@ struct wsdisplay_accessops mgx_accessops
 	NULL,	/* scroll */
 };
 
+static void	mgx_unblank(device_t);
+
+dev_type_open(mgxopen);
+dev_type_close(mgxclose);
+dev_type_ioctl(mgxioctl);
+dev_type_mmap(mgxmmap);
+
+const struct cdevsw mgx_cdevsw = {
+	.d_open = mgxopen,
+	.d_close = mgxclose,
+	.d_read = noread,
+	.d_write = nowrite,
+	.d_ioctl = mgxioctl,
+	.d_stop = nostop,
+	.d_tty = notty,
+	.d_poll = nopoll,
+	.d_mmap = mgxmmap,
+	.d_kqfilter = nokqfilter,
+	.d_discard = nodiscard,
+	.d_flag = D_OTHER
+};
+
+/* frame buffer generic driver */
+static struct fbdriver mgx_fbdriver = {
+	mgx_unblank, mgxopen, mgxclose, mgxioctl, nopoll, mgxmmap,
+	nokqfilter
+};
+
+
 static inline void
 mgx_write_vga(struct mgx_softc *sc, uint32_t reg, uint8_t val)
 {
@@ -199,6 +231,7 @@ mgx_attach(device_t parent, device_t sel
 	struct mgx_softc *sc = device_private(self);
 	struct sbus_attach_args *sa = args;
 	struct wsemuldisplaydev_attach_args aa;
+	struct fbdevice *fb = >sc_fb;
 	struct rasops_info *ri;
 	unsigned long defattr;
 	bus_space_handle_t bh;
@@ -321,6 +354,22 @@ mgx_attach(device_t parent, device_t sel
 
 	config_found(self, , wsemuldisplaydevprint);
 
+	/* now the Sun fb goop */
+	fb->fb_driver = _fbdriver;
+	fb->fb_device = sc->sc_dev;
+	fb->fb_flags = device_cfdata(sc->sc_dev)->cf_flags & FB_USERMASK;
+	fb->fb_type.fb_type = FBTYPE_MGX;
+	fb->fb_pixels = NULL;
+
+	fb->fb_type.fb_depth = 32;
+	fb->fb_type.fb_width = sc->sc_width;
+	fb->fb_type.fb_height = sc->sc_height;
+	fb->fb_linebytes = sc->sc_stride * 4;
+
+	fb->fb_type.fb_cmsize = 256;
+	fb->fb_type.fb_size = sc->sc_fbsize;
+	fb_attach(>sc_fb, isconsole);
+
 #if 0
 	{
 		uint32_t ap;
@@ -854,6 +903,22 @@ mgx_ioctl(void *v, void *vs, u_long cmd,
 			wdf->cmsize = 256;
 			return 0;
 
+	case FBIOGTYPE:
+		*(struct fbtype *)data = sc->sc_fb.fb_type;
+		break;
+
+	case FBIOGATTR:
+#define fba ((struct fbgattr *)data)
+		fba->real_type = sc->sc_fb.fb_type.fb_type;
+		fba->owner = 0;		/* XXX ??? */
+		fba->fbtype = sc->sc_fb.fb_type;
+		fba->sattr.flags = 0;
+		fba->sattr.emu_type = sc->sc_fb.fb_type.fb_type;
+		fba->sattr.dev_specific[0] = -1;
+		fba->emu_types[0] = sc->sc_fb.fb_type.fb_type;
+		fba->emu_types[1] = -1;
+#undef fba
+		break;
 		case FBIOGVIDEO:
 		case WSDISPLAYIO_GVIDEO:
 			*(int *)data = sc->sc_video;
@@ -1096,3 +1161,88 @@ mgx_set_video(struct mgx_softc *sc, int 
 	}
 	mgx_write_1(sc, ATR_DPMS, reg);
 }
+
+/* Sun fb dev goop */
+static void
+mgx_unblank(device_t dev)
+{
+	struct mgx_softc *sc = device_private(dev);
+
+	mgx_set_video(sc, WSDISPLAYIO_VIDEO_ON);
+}
+
+paddr_t
+mgxmmap(dev_t dev, off_t offset, int prot)
+{
+	struct mgx_softc *sc = device_lookup_private(_cd, minor(dev));
+
+	/* regular fb mapping at 0 */
+	if ((offset >= 0) && (offset < sc->sc_fbsize)) {
+		return bus_space_mmap(sc->sc_tag, sc->sc_paddr,
+		offset, prot, BUS_SPACE_MAP_LINEAR);
+	}
+
+	/*
+	 * Blitter registers at 0x8000, only in mapped mode.
+	 * Restrict to root, even though I'm fairly sure the DMA engine lives
+	 * elsewhere ( and isn't documented anyway )
+	 */
+	if (kauth_authorize_machdep(kauth_cred_get(),
+	KAUTH_MACHDEP_UNMANAGEDMEM,
+	NULL, NULL, NULL, NULL) != 0) {
+		aprint_normal("%s: mmap() rejected.\n",
+		device_xname(sc->sc_dev));
+		return -1;
+	}
+	if ((sc->sc_mode == WSDISPLAYIO_MODE_MAPPED) &&
+	(offset >= 0x8000) && (offset < 0x80001000)) {
+		return bus_space_mmap(sc->sc_tag, sc->sc_rpaddr,
+		offset, prot, BUS_SPACE_MAP_LINEAR);
+	}
+	return -1;
+}
+
+int
+mgxopen(dev_t dev, int flags, int mode, struct lwp *l)
+{
+	

CVS commit: src/sys/dev/sun

2016-05-07 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat May  7 15:28:57 UTC 2016

Modified Files:
src/sys/dev/sun: fbio.h

Log Message:
add FBTYPE_MGX


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/sun/fbio.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/sun/fbio.h
diff -u src/sys/dev/sun/fbio.h:1.12 src/sys/dev/sun/fbio.h:1.13
--- src/sys/dev/sun/fbio.h:1.12	Sun Sep  6 06:01:01 2015
+++ src/sys/dev/sun/fbio.h	Sat May  7 15:28:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbio.h,v 1.12 2015/09/06 06:01:01 dholland Exp $ */
+/*	$NetBSD: fbio.h,v 1.13 2016/05/07 15:28:57 macallan Exp $ */
 
 /*
  * Copyright (c) 1992 Regents of the University of California.
@@ -76,8 +76,9 @@
 #define FBTYPE_GENERIC_PCI	23	/* machfb, ofb and so on */
 #define FBTYPE_AG10E		24	/* Fujitsu AG-10e */
 #define FBTYPE_TCXCOLOR		25	/* Sun TCX, S24  */
+#define FBTYPE_MGX		26	/* Southland Media MGX  */
 
-#define	FBTYPE_LASTPLUSONE	26	/* max number of fbs (change as add) */
+#define	FBTYPE_LASTPLUSONE	27	/* max number of fbs (change as add) */
 
 /*
  * XXX These really shouldn't be here, but this is what the pmax



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

2016-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat May  7 13:08:30 UTC 2016

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

Log Message:
clarify


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/amd64/amd64/mptramp.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/mptramp.S
diff -u src/sys/arch/amd64/amd64/mptramp.S:1.19 src/sys/arch/amd64/amd64/mptramp.S:1.20
--- src/sys/arch/amd64/amd64/mptramp.S:1.19	Wed Dec  9 16:55:18 2015
+++ src/sys/arch/amd64/amd64/mptramp.S	Sat May  7 13:08:30 2016
@@ -1,13 +1,11 @@
-/*	$NetBSD: mptramp.S,v 1.19 2015/12/09 16:55:18 maxv Exp $	*/
+/*	$NetBSD: mptramp.S,v 1.20 2016/05/07 13:08:30 maxv Exp $	*/
 
 /*-
- * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * Copyright (c) 2000, 2016 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by RedBack Networks Inc.
- *
- * Author: Bill Sommerfeld
+ * by RedBack Networks Inc. (Author: Bill Sommerfeld), and Maxime Villard.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,7 +28,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-	
+
 /*
  * Copyright (c) 1999 Stefan Grefen
  *
@@ -62,10 +60,11 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 /*
  * MP startup ...
- * the stuff from cpu_spinup_trampoline to mp_startup 
- * is copied into the first 640 KB
+ * the stuff from cpu_spinup_trampoline to mp_startup is copied into the
+ * first 640 KB.
  *
  * We startup the processors now when the kthreads become ready.
  * The steps are:
@@ -74,9 +73,9 @@
  * 2) halt the processors waiting for them to be enabled
  *by a idle-thread 
  */
-	
+
 #include "opt_mpbios.h"		/* for MPDEBUG */
-		
+
 #include "assym.h"
 #include 
 #include 
@@ -91,22 +90,27 @@
 #define _TRMP_LABEL(a)  a = . - _C_LABEL(cpu_spinup_trampoline) + MP_TRAMPOLINE
 
 #ifdef MPDEBUG
-
 /*
  * Debug code to stop aux. processors in various stages based on the
  * value in cpu_trace.
  *
- * %edi points at cpu_trace;  cpu_trace[0] is the "hold point";
- * cpu_trace[1] is the point which the CPU has reached.
+ * %edi points at cpu_trace;
+ * cpu_trace[0] is the "hold point";
+ * cpu_trace[1] is the point which the CPU has reached;
  * cpu_trace[2] is the last value stored by HALTT.
  */
-
-#define HALT(x)	1: movl (%edi),%ebx;cmpl $ x,%ebx ; jle 1b ; movl $x,4(%edi)
-#define HALTT(x,y)	movl y,8(%edi); HALT(x)
+#define HALT(x) \
+1:	movl (%edi),%ebx	;	\
+	cmpl $x,%ebx		;	\
+	jle 1b			;	\
+	movl $x,4(%edi)		;
+#define HALTT(x,y) \
+	movl y,8(%edi)		;	\
+	HALT(x)			;
 #else
-#define HALT(x)	/**/
-#define HALTT(x,y) /**/
-#endif
+#define HALT(x)
+#define HALTT(x,y)
+#endif /* MPDEBUG */
 
 	.global _C_LABEL(cpu_spinup_trampoline)
 	.global _C_LABEL(cpu_spinup_trampoline_end)
@@ -156,13 +160,14 @@ _TRMP_LABEL(mp_startup)
 	pushl	$PSL_MBO
 	popfl
 
+	/* Enable PAE, SSE, and PSE if available */
 	movl	%cr4,%eax
 	orl	$(CR4_PAE|CR4_OSFXSR|CR4_OSXMMEXCPT),%eax
 	movl	RELOC(pmap_largepages),%ecx
 	orl	%ecx,%ecx
-	jz	1f
+	jz	no_PSE
 	orl	$CR4_PSE,%eax
-1:
+no_PSE:
 	movl	%eax,%cr4
 
 	movl	$MSR_EFER,%ecx
@@ -171,12 +176,15 @@ _TRMP_LABEL(mp_startup)
 	orl	$(EFER_LME|EFER_SCE),%eax
 	wrmsr
 
+	/* Load %cr3. */
 	movl	RELOC(mp_pdirpa),%ecx	/* guaranteed < 4G */
-	movl	%ecx,%cr3		/* load ptd addr into mmu */
+	movl	%ecx,%cr3		/* load PTD addr into MMU */
 
-	movl	%cr0,%eax		/* get control word */
+	/* Enable paging and the rest of it. */
+	movl	%cr0,%eax
 	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
 	movl	%eax,%cr0
+
 	jmp	mptramp_compat
 mptramp_compat:
 
@@ -194,22 +202,23 @@ _TRMP_LABEL(mptramp_jmp64)
 	.long   mptramp_longmode
 	.word   GSEL(GCODE_SEL, SEL_KPL)
 
+#define GDT_LIMIT	0x17	/* 23 = 3 * 8 - 1 */
 _TRMP_LABEL(mptramp_gdt32)
 	.quad 0x
-	.quad 0x00cf9f00
-	.quad 0x00cf9300
+	.quad 0x00cf9f00	/* CS */
+	.quad 0x00cf9300	/* DS */
 _TRMP_LABEL(mptramp_gdt32_desc)
-	.word 0x17
+	.word GDT_LIMIT
 	.long mptramp_gdt32
 
 _TRMP_LABEL(mptramp_gdt64)
 	.quad 0x
-	.quad 0x00af9a00
-	.quad 0x00cf9200
+	.quad 0x00af9a00	/* CS */
+	.quad 0x00cf9200	/* DS */
 _TRMP_LABEL(mptramp_gdt64_desc)
-	.word 0x17
+	.word GDT_LIMIT
 	.long mptramp_gdt64
-
+#undef	GDT_LIMIT
 
 _TRMP_LABEL(mptramp_longmode)
 	.code64



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

2016-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat May  7 12:45:56 UTC 2016

Modified Files:
src/sys/arch/amd64/conf: kern.ldscript
Removed Files:
src/sys/arch/amd64/conf: kern.ldscript.2MB largepages.inc

Log Message:
Large pages are supported by default for the text+rodata segments. Apply
the proper alignment for the data segment, so that more pages can benefit
from it. Reduces TLB contention.

kern.ldscript.2MB and largepages.inc are useless.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/amd64/conf/kern.ldscript
cvs rdiff -u -r1.11 -r0 src/sys/arch/amd64/conf/kern.ldscript.2MB
cvs rdiff -u -r1.4 -r0 src/sys/arch/amd64/conf/largepages.inc

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

Modified files:

Index: src/sys/arch/amd64/conf/kern.ldscript
diff -u src/sys/arch/amd64/conf/kern.ldscript:1.16 src/sys/arch/amd64/conf/kern.ldscript:1.17
--- src/sys/arch/amd64/conf/kern.ldscript:1.16	Sat Nov 14 14:01:23 2015
+++ src/sys/arch/amd64/conf/kern.ldscript	Sat May  7 12:45:55 2016
@@ -1,7 +1,15 @@
-/*	$NetBSD: kern.ldscript,v 1.16 2015/11/14 14:01:23 maxv Exp $	*/
+/*	$NetBSD: kern.ldscript,v 1.17 2016/05/07 12:45:55 maxv Exp $	*/
 
 #include "assym.h"
 
+/*
+ * PAE is enabled by default on amd64, the large page size is therefore
+ * 2MB (and not 4MB!).
+ */
+
+__PAGE_SIZE = 0x1000 ;
+__LARGE_PAGE_SIZE = 0x20 ;
+
 ENTRY(_start)
 SECTIONS
 {
@@ -22,10 +30,11 @@ SECTIONS
 	}
 
 	/*
-	 * Adjust the address for the data segment.  We want to adjust up to
-	 * the same address within the page on the next page up.
+	 * Push the data segment up to the next large page boundary so that we
+	 * can map the text+rodata segments with large pages.
 	 */
-	. = ALIGN(0x10) + (. & (0x10 - 1));
+	. = ALIGN(__LARGE_PAGE_SIZE);
+
 	__data_start = . ;
 	.data :
 	{



CVS commit: src/sys/net80211

2016-05-07 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  7 12:36:50 UTC 2016

Modified Files:
src/sys/net80211: ieee80211_input.c

Log Message:
Don't check sequence number on multicast packets in station mode.
Handle overflow of 12bit sequence number.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/net80211/ieee80211_input.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/net80211/ieee80211_input.c
diff -u src/sys/net80211/ieee80211_input.c:1.82 src/sys/net80211/ieee80211_input.c:1.83
--- src/sys/net80211/ieee80211_input.c:1.82	Wed Apr 20 09:01:04 2016
+++ src/sys/net80211/ieee80211_input.c	Sat May  7 12:36:50 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_input.c,v 1.82 2016/04/20 09:01:04 knakahara Exp $	*/
+/*	$NetBSD: ieee80211_input.c,v 1.83 2016/05/07 12:36:50 mlelstv Exp $	*/
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.81 2005/08/10 16:22:29 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.82 2016/04/20 09:01:04 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.83 2016/05/07 12:36:50 mlelstv Exp $");
 #endif
 
 #ifdef _KERNEL_OPT
@@ -282,8 +282,11 @@ ieee80211_input(struct ieee80211com *ic,
 		}
 		ni->ni_rssi = rssi;
 		ni->ni_rstamp = rstamp;
-		if (HAS_SEQ(type)) {
-			u_int8_t tid;
+		if (HAS_SEQ(type) && (ic->ic_opmode != IEEE80211_M_STA ||
+		!IEEE80211_IS_MULTICAST(wh->i_addr1))) {
+			u_int8_t tid, retry;
+			u_int16_t rxno, orxno;
+
 			if (ieee80211_has_qos(wh)) {
 tid = ((struct ieee80211_qosframe *)wh)->
 	i_qos[0] & IEEE80211_QOS_TID;
@@ -293,15 +296,20 @@ ieee80211_input(struct ieee80211com *ic,
 			} else
 tid = 0;
 			rxseq = le16toh(*(u_int16_t *)wh->i_seq);
-			if ((wh->i_fc[1] & IEEE80211_FC1_RETRY) &&
-			SEQ_LEQ(rxseq, ni->ni_rxseqs[tid])) {
+			retry = wh->i_fc[1] & IEEE80211_FC1_RETRY;
+			rxno = rxseq >> IEEE80211_SEQ_SEQ_SHIFT;
+			orxno = ni->ni_rxseqs[tid] >> IEEE80211_SEQ_SEQ_SHIFT;
+			if (retry && (
+			(orxno == 4095 && rxno == orxno) ||
+			(orxno != 4095 &&
+			 SEQ_LEQ(rxseq, ni->ni_rxseqs[tid]))
+			)) {
 /* duplicate, discard */
 IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_INPUT,
 bssid, "duplicate",
 "seqno <%u,%u> fragno <%u,%u> tid %u",
-rxseq >> IEEE80211_SEQ_SEQ_SHIFT,
-ni->ni_rxseqs[tid] >>
-	IEEE80211_SEQ_SEQ_SHIFT,
+rxno,
+orxno,
 rxseq & IEEE80211_SEQ_FRAG_MASK,
 ni->ni_rxseqs[tid] &
 	IEEE80211_SEQ_FRAG_MASK,



CVS commit: src/share/misc

2016-05-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat May  7 12:22:57 UTC 2016

Modified Files:
src/share/misc: acronyms.comp

Log Message:
Add "uaf" - use-after-free

Seen in a recent NetBSD commit message...


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/share/misc/acronyms.comp

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

Modified files:

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.162 src/share/misc/acronyms.comp:1.163
--- src/share/misc/acronyms.comp:1.162	Thu Apr 21 23:14:25 2016
+++ src/share/misc/acronyms.comp	Sat May  7 12:22:57 2016
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.162 2016/04/21 23:14:25 riastradh Exp $
+$NetBSD: acronyms.comp,v 1.163 2016/05/07 12:22:57 pgoyette Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -1271,6 +1271,7 @@ TUI	{terminal,text-based,textual} user i
 TX	{transmit out,transmitter}
 TZ	time zone
 UAC	user {access,account} control
+UAF	use-after-free
 UART	universal asynchronous receiver/transmitter
 UAT	user acceptance testing
 UC	uncacheable



CVS commit: src/sys/ufs/ffs

2016-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat May  7 11:59:09 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_subr.c

Log Message:
uaf


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ffs/ffs_subr.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/ufs/ffs/ffs_subr.c
diff -u src/sys/ufs/ffs/ffs_subr.c:1.48 src/sys/ufs/ffs/ffs_subr.c:1.49
--- src/sys/ufs/ffs/ffs_subr.c:1.48	Sun Oct 20 00:29:10 2013
+++ src/sys/ufs/ffs/ffs_subr.c	Sat May  7 11:59:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_subr.c,v 1.48 2013/10/20 00:29:10 htodd Exp $	*/
+/*	$NetBSD: ffs_subr.c,v 1.49 2016/05/07 11:59:08 maxv Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -36,7 +36,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.48 2013/10/20 00:29:10 htodd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.49 2016/05/07 11:59:08 maxv Exp $");
 
 #include 
 
@@ -127,8 +127,10 @@ ffs_getblk(struct vnode *vp, daddr_t lbl
 		(*bpp)->b_blkno = blkno;
 	if (clearbuf)
 		clrbuf(*bpp);
-	if ((*bpp)->b_blkno >= 0 && (error = fscow_run(*bpp, false)) != 0)
+	if ((*bpp)->b_blkno >= 0 && (error = fscow_run(*bpp, false)) != 0) {
 		brelse(*bpp, BC_INVAL);
+		*bpp = NULL;
+	}
 	return error;
 }
 



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

2016-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat May  7 11:49:21 UTC 2016

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

Log Message:
clarify


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/arch/amd64/amd64/locore.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.83 src/sys/arch/amd64/amd64/locore.S:1.84
--- src/sys/arch/amd64/amd64/locore.S:1.83	Wed Nov 25 16:00:09 2015
+++ src/sys/arch/amd64/amd64/locore.S	Sat May  7 11:49:21 2016
@@ -1,10 +1,39 @@
-/*	$NetBSD: locore.S,v 1.83 2015/11/25 16:00:09 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.84 2016/05/07 11:49:21 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
  */
 
 /*
+ * Copyright (c) 1998, 2000, 2007, 2008, 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum and Maxime Villard.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
  * Copyright (c) 2007 Manuel Bouyer.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -80,36 +109,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-
-/*-
- * Copyright (c) 1998, 2000, 2007, 2008 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
@@ -144,9 +143,7 @@
  *	@(#)locore.s	7.3 (Berkeley) 5/13/91
  */
 
-/*
- * override user-land alignment before including asm.h
- */
+/* Override user-land alignment before including asm.h */
 #define	ALIGN_DATA	.align	8
 #define ALIGN_TEXT	.align 16,0x90
 #define _ALIGN_TEXT	ALIGN_TEXT
@@ -184,7 +181,6 @@
 #include 
 #endif
 
-/* XXX temporary kluge; these should not be here */
 /* Get definitions for IOM_BEGIN, IOM_END, and IOM_SIZE */
 #include 
 
@@ -204,7 +200,7 @@
 #endif
 
 #define PROC0_PML4_OFF	0
-#define PROC0_STK_OFF	(PROC0_PML4_OFF + PAGE_SIZE)
+#define PROC0_STK_OFF	(PROC0_PML4_OFF + 1 * PAGE_SIZE)
 #define PROC0_PTP3_OFF	(PROC0_STK_OFF + UPAGES * PAGE_SIZE)
 #define PROC0_PTP2_OFF	(PROC0_PTP3_OFF + NKL4_KIMG_ENTRIES * PAGE_SIZE)
 #define PROC0_PTP1_OFF	

CVS commit: src/share/man/man9

2016-05-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat May  7 08:52:10 UTC 2016

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

Log Message:
Use Er for errors and Dq for double quoted strings. Whitespace nits.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/share/man/man9/namei.9

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

Modified files:

Index: src/share/man/man9/namei.9
diff -u src/share/man/man9/namei.9:1.36 src/share/man/man9/namei.9:1.37
--- src/share/man/man9/namei.9:1.36	Fri May  6 04:55:10 2016
+++ src/share/man/man9/namei.9	Sat May  7 08:52:10 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: namei.9,v 1.36 2016/05/06 04:55:10 dholland Exp $
+.\" $NetBSD: namei.9,v 1.37 2016/05/07 08:52:10 wiz Exp $
 .\"
 .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -206,7 +206,7 @@ The
 mode is the baseline behavior, for all ordinary lookups that simply
 return a vnode.
 In this mode, if the requested object does not exist,
-.Dv ENOENT
+.Er ENOENT
 is returned.
 .Pp
 The
@@ -215,7 +215,7 @@ mode is used when doing the lookup for o
 the file system namespace, such as
 .Xr mkdir 2 .
 In this mode, if the requested name already exists,
-.Dv EEXIST
+.Er EEXIST
 is returned.
 Otherwise if the requested name does not exist, the lookup succeeds
 and the returned vnode
@@ -448,7 +448,7 @@ In the rare case that another set of cre
 namei operation,
 .Em ndp-\*[Gt]ni_cnd.cn_cred
 must be set manually after
-.Fn NDINIT.
+.Fn NDINIT .
 .It Fn NDAT "ndp" "dvp"
 This macro is used after
 .Fn NDINIT
@@ -684,7 +684,7 @@ The number of symbolic links encountered
 If this exceeds a limit,
 .Nm
 fails with
-.Dv ELOOP .
+.Er ELOOP .
 This is not initialized by
 .Fn NDINIT
 and is used only internally.
@@ -742,7 +742,7 @@ does a complete path lookup by calling
 .Fn namei_init ,
 .Fn namei_tryemulroot ,
 and
-.Fn namei_cleanup.
+.Fn namei_cleanup .
 .It Fn namei_init
 sets up the basic internal state and makes some (precondition-type)
 assertions.
@@ -775,8 +775,9 @@ initializes the root directory state (bo
 and
 .Fa ni_erootdir )
 and picks the starting directory, consuming the leading slashes of an
-absolute path and handling the magic ``/../'' string for bypassing the
-emulation root.
+absolute path and handling the magic
+.Dq /../
+string for bypassing the emulation root.
 A different version
 .Fn namei_getstartdir_for_nfsd
 is used for lookups coming from
@@ -806,7 +807,7 @@ than it is for
 The latter
 .Dq fails
 with
-.Dv EJUSTRETURN .
+.Er EJUSTRETURN .
 .Nm
 translates this into succeeding and returning a null vnode.
 .Sh CODE REFERENCES



CVS commit: src/sys/dev/usb

2016-05-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May  7 08:11:49 UTC 2016

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

Log Message:
G/C more unused code


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/usb/xhci.c

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

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.44 src/sys/dev/usb/xhci.c:1.45
--- src/sys/dev/usb/xhci.c:1.44	Fri May  6 10:27:14 2016
+++ src/sys/dev/usb/xhci.c	Sat May  7 08:11:49 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.44 2016/05/06 10:27:14 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.45 2016/05/07 08:11:49 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.44 2016/05/06 10:27:14 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.45 2016/05/07 08:11:49 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -3372,11 +3372,6 @@ xhci_device_ctrl_start(struct usbd_xfer 
 		xhci_timeout, xfer);
 	}
 
-	if (sc->sc_bus.ub_usepolling) {
-		DPRINTFN(1, "polling", 0, 0, 0, 0);
-		//xhci_waitintr(sc, xfer);
-	}
-
 	return USBD_IN_PROGRESS;
 }
 
@@ -3492,11 +3487,6 @@ xhci_device_bulk_start(struct usbd_xfer 
 		xhci_timeout, xfer);
 	}
 
-	if (sc->sc_bus.ub_usepolling) {
-		DPRINTFN(1, "polling", 0, 0, 0, 0);
-		//xhci_waitintr(sc, xfer);
-	}
-
 	return USBD_IN_PROGRESS;
 }
 
@@ -3602,11 +3592,6 @@ xhci_device_intr_start(struct usbd_xfer 
 		xhci_timeout, xfer);
 	}
 
-	if (sc->sc_bus.ub_usepolling) {
-		DPRINTFN(1, "polling", 0, 0, 0, 0);
-		//xhci_waitintr(sc, xfer);
-	}
-
 	return USBD_IN_PROGRESS;
 }
 



CVS commit: src/sys/dev/usb

2016-05-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat May  7 08:09:43 UTC 2016

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

Log Message:
disable kpreempt around softint_schedule().  fixes playing on umidi.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/usb/umidi.c

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

Modified files:

Index: src/sys/dev/usb/umidi.c
diff -u src/sys/dev/usb/umidi.c:1.69 src/sys/dev/usb/umidi.c:1.70
--- src/sys/dev/usb/umidi.c:1.69	Sat Apr 23 10:15:32 2016
+++ src/sys/dev/usb/umidi.c	Sat May  7 08:09:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: umidi.c,v 1.69 2016/04/23 10:15:32 skrll Exp $	*/
+/*	$NetBSD: umidi.c,v 1.70 2016/05/07 08:09:43 mrg Exp $	*/
 
 /*
  * Copyright (c) 2001, 2012, 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.69 2016/04/23 10:15:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.70 2016/05/07 08:09:43 mrg Exp $");
 
 #include 
 #include 
@@ -1786,7 +1786,9 @@ out_jack_output(struct umidi_jack *out_j
 		 * before starting the USB transfer, and send a longer one.
 		 */
 		ep->soliciting = 1;
+		kpreempt_disable();
 		softint_schedule(ep->solicit_cookie);
+		kpreempt_enable();
 	}
 
 	if (--sc->sc_refcnt < 0)



CVS commit: src/share/man/man9

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 06:47:44 UTC 2016

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

Log Message:
Omit confusing sentence.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/share/man/man9/wapbl.9

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

Modified files:

Index: src/share/man/man9/wapbl.9
diff -u src/share/man/man9/wapbl.9:1.11 src/share/man/man9/wapbl.9:1.12
--- src/share/man/man9/wapbl.9:1.11	Sat May  7 05:46:35 2016
+++ src/share/man/man9/wapbl.9	Sat May  7 06:47:44 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: wapbl.9,v 1.11 2016/05/07 05:46:35 riastradh Exp $
+.\"	$NetBSD: wapbl.9,v 1.12 2016/05/07 06:47:44 riastradh Exp $
 .\"
 .\" Copyright (c) 2015 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -315,9 +315,6 @@ Wait for space in the current transactio
 if necessary, and lock it.
 .Pp
 The lock is not exclusive: other threads may lock the transaction too.
-However, if there is not enough space, another thread will obtain an
-exclusive lock in order to flush the transaction.
-.Pp
 The lock is not recursive: a thread may not acquire it again without
 calling
 .Fa wapbl_end



CVS commit: src/sys/kern

2016-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May  7 06:38:47 UTC 2016

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

Log Message:
Sort and deduplicate includes.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.67 src/sys/kern/vfs_wapbl.c:1.68
--- src/sys/kern/vfs_wapbl.c:1.67	Tue May  3 19:43:45 2016
+++ src/sys/kern/vfs_wapbl.c	Sat May  7 06:38:47 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.67 2016/05/03 19:43:45 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.68 2016/05/07 06:38:47 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,29 +36,30 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.67 2016/05/03 19:43:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.68 2016/05/07 06:38:47 riastradh Exp $");
 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #ifdef _KERNEL
-#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 
 #include 
 
@@ -73,17 +74,14 @@ static int wapbl_verbose_commit = 0;
 static inline size_t wapbl_space_free(size_t, off_t, off_t);
 
 #else /* !_KERNEL */
+
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 
-#include 
-#include 
-#include 
-
 #define	KDASSERT(x) assert(x)
 #define	KASSERT(x) assert(x)
 #define	wapbl_alloc(s) malloc(s)