CVS commit: src/lib/libc/sys

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:39:21 UTC 2018

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

Log Message:
Note in vfork(2) that SIGTSTP is masked

SIGSTOP is no longer masked, but it was never documented.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/sys/vfork.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/vfork.2
diff -u src/lib/libc/sys/vfork.2:1.27 src/lib/libc/sys/vfork.2:1.28
--- src/lib/libc/sys/vfork.2:1.27	Fri Jul 18 16:02:50 2014
+++ src/lib/libc/sys/vfork.2	Sat May 19 05:39:21 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: vfork.2,v 1.27 2014/07/18 16:02:50 dholland Exp $
+.\"	$NetBSD: vfork.2,v 1.28 2018/05/19 05:39:21 kamil Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)vfork.2	8.1 (Berkeley) 6/4/93
 .\"
-.Dd July 18, 2014
+.Dd May 19, 2018
 .Dt VFORK 2
 .Os
 .Sh NAME
@@ -130,6 +130,7 @@ To avoid a possible deadlock situation, 
 in the middle of a
 .Fn vfork
 are never sent
+.Dv SIGTSTP ,
 .Dv SIGTTOU
 or
 .Dv SIGTTIN



CVS commit: src/lib/libc/sys

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:39:21 UTC 2018

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

Log Message:
Note in vfork(2) that SIGTSTP is masked

SIGSTOP is no longer masked, but it was never documented.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/sys/vfork.2

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



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

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:25:21 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Cover SIGTSTP, SIGTTIN and SIGTTOU in traceme_vfork_raise ATF tests

SIGTSTP, SIGTTIN and SIGTTOU are special case signals ignored in a
vfork(2)ed child. Assert the behavior of raise(2) after calling
PT_TRACE_ME.

Renumber existing traceme_vfork_raise tests.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/tests/lib/libc/sys/t_ptrace_wait.c

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



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

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:25:21 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Cover SIGTSTP, SIGTTIN and SIGTTOU in traceme_vfork_raise ATF tests

SIGTSTP, SIGTTIN and SIGTTOU are special case signals ignored in a
vfork(2)ed child. Assert the behavior of raise(2) after calling
PT_TRACE_ME.

Renumber existing traceme_vfork_raise tests.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/tests/lib/libc/sys/t_ptrace_wait.c

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

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.46 src/tests/lib/libc/sys/t_ptrace_wait.c:1.47
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.46	Sat May 19 05:07:42 2018
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Sat May 19 05:25:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.46 2018/05/19 05:07:42 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.47 2018/05/19 05:25:21 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.46 2018/05/19 05:07:42 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.47 2018/05/19 05:25:21 kamil Exp $");
 
 #include 
 #include 
@@ -513,6 +513,9 @@ traceme_vfork_raise(int sigval)
 		validate_status_signaled(status, SIGKILL, 0);
 		break;
 	case SIGCONT:
+	case SIGTSTP:
+	case SIGTTIN:
+	case SIGTTOU:
 		validate_status_exited(status, exitval);
 		break;
 	default:
@@ -542,9 +545,12 @@ ATF_TC_BODY(test, tc)\
 
 TRACEME_VFORK_RAISE(traceme_vfork_raise1, SIGKILL) /* non-maskable */
 TRACEME_VFORK_RAISE(traceme_vfork_raise2, SIGSTOP) /* non-maskable */
-TRACEME_VFORK_RAISE(traceme_vfork_raise3, SIGABRT) /* regular abort trap */
-TRACEME_VFORK_RAISE(traceme_vfork_raise4, SIGHUP)  /* hangup */
-TRACEME_VFORK_RAISE(traceme_vfork_raise5, SIGCONT) /* continued? */
+TRACEME_VFORK_RAISE(traceme_vfork_raise3, SIGTSTP) /* ignored in vfork(2) */
+TRACEME_VFORK_RAISE(traceme_vfork_raise4, SIGTTIN) /* ignored in vfork(2) */
+TRACEME_VFORK_RAISE(traceme_vfork_raise5, SIGTTOU) /* ignored in vfork(2) */
+TRACEME_VFORK_RAISE(traceme_vfork_raise6, SIGABRT) /* regular abort trap */
+TRACEME_VFORK_RAISE(traceme_vfork_raise7, SIGHUP)  /* hangup */
+TRACEME_VFORK_RAISE(traceme_vfork_raise8, SIGCONT) /* continued? */
 
 /// 
 
@@ -7119,6 +7125,9 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, traceme_vfork_raise3);
 	ATF_TP_ADD_TC(tp, traceme_vfork_raise4);
 	ATF_TP_ADD_TC(tp, traceme_vfork_raise5);
+	ATF_TP_ADD_TC(tp, traceme_vfork_raise6);
+	ATF_TP_ADD_TC(tp, traceme_vfork_raise7);
+	ATF_TP_ADD_TC(tp, traceme_vfork_raise8);
 
 	ATF_TP_ADD_TC(tp, traceme_vfork_breakpoint);
 



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

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:10:16 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_fork.c

Log Message:
Reflect reality in the comment

The watcher process is emitting SIGKILL, not SIGTERM.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_fork.c

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



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

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:10:16 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_fork.c

Log Message:
Reflect reality in the comment

The watcher process is emitting SIGKILL, not SIGTERM.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_fork.c

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

Modified files:

Index: src/tests/lib/libc/sys/t_fork.c
diff -u src/tests/lib/libc/sys/t_fork.c:1.2 src/tests/lib/libc/sys/t_fork.c:1.3
--- src/tests/lib/libc/sys/t_fork.c:1.2	Sat May 19 02:42:58 2018
+++ src/tests/lib/libc/sys/t_fork.c	Sat May 19 05:10:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fork.c,v 1.2 2018/05/19 02:42:58 kamil Exp $	*/
+/*	$NetBSD: t_fork.c,v 1.3 2018/05/19 05:10:16 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2018\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_fork.c,v 1.2 2018/05/19 02:42:58 kamil Exp $");
+__RCSID("$NetBSD: t_fork.c,v 1.3 2018/05/19 05:10:16 kamil Exp $");
 
 #include 
 #include 
@@ -141,7 +141,7 @@ raise_raw(int sig)
 
 	/*
 	 * Spawn a dedicated thread to watch for a stopped child and emit
-	 * the SIGTERM signal to it.
+	 * the SIGKILL signal to it.
 	 *
 	 * This is required in vfork(2)ing parent and optional in fork(2).
 	 *



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

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:07:42 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Enable traceme_vfork_raise2 in ATF ptrace(2) tests

raise(SIGSTOP) is now handled correctly by the kernel, in a child that
vfork(2)ed and called PT_TRACE_ME.

Implement a helper process emitting SIGKILL to a stopped child of a
vfork(2)ed process.

Sponsored by 


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

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



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

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:07:42 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Enable traceme_vfork_raise2 in ATF ptrace(2) tests

raise(SIGSTOP) is now handled correctly by the kernel, in a child that
vfork(2)ed and called PT_TRACE_ME.

Implement a helper process emitting SIGKILL to a stopped child of a
vfork(2)ed process.

Sponsored by 


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

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

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.45 src/tests/lib/libc/sys/t_ptrace_wait.c:1.46
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.45	Wed May 16 03:52:35 2018
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Sat May 19 05:07:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.45 2018/05/16 03:52:35 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.46 2018/05/19 05:07:42 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.45 2018/05/16 03:52:35 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.46 2018/05/19 05:07:42 kamil Exp $");
 
 #include 
 #include 
@@ -429,13 +429,54 @@ ATF_TC_BODY(traceme_pid1_parent, tc)
 static void
 traceme_vfork_raise(int sigval)
 {
-	const int exitval = 5;
-	pid_t child, wpid;
+	const int exitval = 5, exitval_watcher = 10;
+	pid_t child, parent, watcher, wpid;
+	int rv;
 #if defined(TWAIT_HAVE_STATUS)
 	int status;
 	int expect_core = (sigval == SIGABRT) ? 1 : 0;
 #endif
 
+	/*
+	 * Spawn a dedicated thread to watch for a stopped child and emit
+	 * the SIGKILL signal to it.
+	 *
+	 * vfork(2) might clobber watcher, this means that it's safer and
+	 * simpler to reparent this process to initproc and forget about it.
+	 */
+	if (sigval == SIGSTOP) {
+		parent = getpid();
+
+		watcher = fork();
+		ATF_REQUIRE(watcher != 1);
+		if (watcher == 0) {
+			/* Double fork(2) trick to reparent to initproc */
+			watcher = fork();
+			FORKEE_ASSERT_NEQ(watcher, -1);
+			if (watcher != 0)
+_exit(exitval_watcher);
+
+			child = await_stopped_child(parent);
+
+			errno = 0;
+			rv = kill(child, SIGKILL);
+			FORKEE_ASSERT_EQ(rv, 0);
+			FORKEE_ASSERT_EQ(errno, 0);
+
+			/* This exit value will be collected by initproc */
+			_exit(0);
+		}
+		DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
+		TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(watcher, , 0),
+		  watcher);
+
+		validate_status_exited(status, exitval_watcher);
+
+		DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
+		TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(watcher,
+		   , 0));
+	}
+
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = vfork()) != -1);
 	if (child == 0) {
@@ -446,6 +487,7 @@ traceme_vfork_raise(int sigval)
 		FORKEE_ASSERT(raise(sigval) == 0);
 
 		switch (sigval) {
+		case SIGSTOP:
 		case SIGKILL:
 		case SIGABRT:
 		case SIGHUP:
@@ -468,6 +510,8 @@ traceme_vfork_raise(int sigval)
 		validate_status_signaled(status, sigval, expect_core);
 		break;
 	case SIGSTOP:
+		validate_status_signaled(status, SIGKILL, 0);
+		break;
 	case SIGCONT:
 		validate_status_exited(status, exitval);
 		break;
@@ -497,7 +541,7 @@ ATF_TC_BODY(test, tc)\
 }
 
 TRACEME_VFORK_RAISE(traceme_vfork_raise1, SIGKILL) /* non-maskable */
-// TRACEME_VFORK_RAISE(traceme_vfork_raise2, SIGSTOP) /* non-maskable */ // TODO
+TRACEME_VFORK_RAISE(traceme_vfork_raise2, SIGSTOP) /* non-maskable */
 TRACEME_VFORK_RAISE(traceme_vfork_raise3, SIGABRT) /* regular abort trap */
 TRACEME_VFORK_RAISE(traceme_vfork_raise4, SIGHUP)  /* hangup */
 TRACEME_VFORK_RAISE(traceme_vfork_raise5, SIGCONT) /* continued? */
@@ -7071,7 +7115,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, traceme_pid1_parent);
 
 	ATF_TP_ADD_TC(tp, traceme_vfork_raise1);
-//	ATF_TP_ADD_TC(tp, traceme_vfork_raise2); // not yet
+	ATF_TP_ADD_TC(tp, traceme_vfork_raise2);
 	ATF_TP_ADD_TC(tp, traceme_vfork_raise3);
 	ATF_TP_ADD_TC(tp, traceme_vfork_raise4);
 	ATF_TP_ADD_TC(tp, traceme_vfork_raise5);



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

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:04:09 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
Add new auxiliary functions in t_ptrace_wait.h

New functions:
 - FORKEE_ASSERT_NEQ()
 - await_stopped_child()

Both will be used soon in a new ATF ptrace(2) test.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/sys/t_ptrace_wait.h

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

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.4 src/tests/lib/libc/sys/t_ptrace_wait.h:1.5
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.4	Sun May 13 23:01:25 2018
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Sat May 19 05:04:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.4 2018/05/13 23:01:25 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.5 2018/05/19 05:04:09 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -153,6 +153,17 @@ do {	\
 		#x, vx, #y, vy);	\
 } while (/*CONSTCOND*/0)
 
+#define FORKEE_ASSERT_NEQ(x, y)		\
+do {	\
+	uintmax_t vx = (x);		\
+	uintmax_t vy = (y);		\
+	int ret = vx != vy;		\
+	if (!ret)			\
+		errx(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: "	\
+		"%s(%ju) != %s(%ju)", __FILE__, __LINE__, __func__,	\
+		#x, vx, #y, vy);	\
+} while (/*CONSTCOND*/0)
+
 #define FORKEE_ASSERTX(x)		\
 do {	\
 	int ret = (x);			\
@@ -364,6 +375,61 @@ await_zombie(pid_t process)
 	await_zombie_raw(process, 1000);
 }
 
+static pid_t __used
+await_stopped_child(pid_t process)
+{
+	struct kinfo_proc2 *p = NULL;
+	size_t i, len;
+	pid_t child = -1;
+
+	int name[] = {
+		[0] = CTL_KERN,
+		[1] = KERN_PROC2,
+		[2] = KERN_PROC_ALL,
+		[3] = 0,
+		[4] = sizeof(struct kinfo_proc2),
+		[5] = 0
+	};
+
+	const size_t namelen = __arraycount(name);
+
+	/* Await the process becoming a zombie */
+	while(1) {
+		name[5] = 0;
+
+		FORKEE_ASSERT_EQ(sysctl(name, namelen, 0, , NULL, 0), 0);
+
+		FORKEE_ASSERT_EQ(reallocarr(,
+		len,
+		sizeof(struct kinfo_proc2)), 0);
+
+		name[5] = len;
+
+		FORKEE_ASSERT_EQ(sysctl(name, namelen, p, , NULL, 0), 0);
+
+		for (i = 0; i < len/sizeof(struct kinfo_proc2); i++) {
+			if (p[i].p_pid == getpid())
+continue;
+			if (p[i].p_ppid != process)
+continue;
+			if (p[i].p_stat != LSSTOP)
+continue;
+			child = p[i].p_pid;
+			break;
+		}
+
+		if (child != -1)
+			break;
+
+		FORKEE_ASSERT_EQ(usleep(1000), 0);
+	}
+
+	/* Free the buffer */
+	FORKEE_ASSERT_EQ(reallocarr(, 0, sizeof(struct kinfo_proc2)), 0);
+
+	return child;
+}
+
 /* Happy number sequence -- this function is used to just consume cpu cycles */
 #define	HAPPY_NUMBER	1
 



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

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:04:09 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
Add new auxiliary functions in t_ptrace_wait.h

New functions:
 - FORKEE_ASSERT_NEQ()
 - await_stopped_child()

Both will be used soon in a new ATF ptrace(2) test.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/sys/t_ptrace_wait.h

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



CVS commit: src/sys/kern

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:01:42 UTC 2018

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

Log Message:
Stop masking raise(SIGSTOP) in a vfork(2)ed child that called PT_TRACE_ME.

Sponsored by 


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

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



CVS commit: src/sys/kern

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 05:01:42 UTC 2018

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

Log Message:
Stop masking raise(SIGSTOP) in a vfork(2)ed child that called PT_TRACE_ME.

Sponsored by 


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

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

Modified files:

Index: src/sys/kern/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.345 src/sys/kern/kern_sig.c:1.346
--- src/sys/kern/kern_sig.c:1.345	Sat May 19 02:42:58 2018
+++ src/sys/kern/kern_sig.c	Sat May 19 05:01:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.345 2018/05/19 02:42:58 kamil Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.346 2018/05/19 05:01:42 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.345 2018/05/19 02:42:58 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.346 2018/05/19 05:01:42 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -1781,7 +1781,9 @@ issignal(struct lwp *l)
  * XXX Don't hold proc_lock for p_lflag,
  * but it's not a big deal.
  */
-if (p->p_slflag & PSL_TRACED ||
+if ((ISSET(p->p_slflag, PSL_TRACED) &&
+ !(ISSET(p->p_lflag, PL_PPWAIT) &&
+ (p->p_pptr == p->p_opptr))) ||
 ((p->p_lflag & PL_ORPHANPG) != 0 &&
 prop & SA_TTYSTOP)) {
 	/* Ignore the signal. */



CVS commit: src

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 02:42:59 UTC 2018

Modified Files:
src/sys/kern: kern_sig.c
src/tests/lib/libc/sys: t_fork.c

Log Message:
Stop masking SIGSTOP in a vfork(2)ed child

Keep the traditional BSD behavior masking SIGTSTP, SIGTTIN and SIGTTOU in
a vfork(2)ed child before exec(3)/exit(3). This is useful in shells and
prevents deadlocking, when a parent cannot unstop the sleeping child.

Change the behavior for SIGSTOP. This signal is by design not maskable and
this property shall be obeyed without exceptions. The STOP behavior is
expected in the context of debuggers and useful in standalone programs.

It is still possible to stop a vfork(2)ed child, however it requires
proc.curproc.stopfork=1, but it is not a flexible solution.

FreeBSD and OpenBSD keep masking SIGSTOP in a vfork(2)ed child.
Linux does not mask stop signals in the same scenarios.

This fixes ATF test: t_vfork:raise2.
No known regressions reported in the existing ATF tests.

Discussed with 

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.344 -r1.345 src/sys/kern/kern_sig.c
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_fork.c

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



CVS commit: src

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 19 02:42:59 UTC 2018

Modified Files:
src/sys/kern: kern_sig.c
src/tests/lib/libc/sys: t_fork.c

Log Message:
Stop masking SIGSTOP in a vfork(2)ed child

Keep the traditional BSD behavior masking SIGTSTP, SIGTTIN and SIGTTOU in
a vfork(2)ed child before exec(3)/exit(3). This is useful in shells and
prevents deadlocking, when a parent cannot unstop the sleeping child.

Change the behavior for SIGSTOP. This signal is by design not maskable and
this property shall be obeyed without exceptions. The STOP behavior is
expected in the context of debuggers and useful in standalone programs.

It is still possible to stop a vfork(2)ed child, however it requires
proc.curproc.stopfork=1, but it is not a flexible solution.

FreeBSD and OpenBSD keep masking SIGSTOP in a vfork(2)ed child.
Linux does not mask stop signals in the same scenarios.

This fixes ATF test: t_vfork:raise2.
No known regressions reported in the existing ATF tests.

Discussed with 

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.344 -r1.345 src/sys/kern/kern_sig.c
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_fork.c

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

Modified files:

Index: src/sys/kern/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.344 src/sys/kern/kern_sig.c:1.345
--- src/sys/kern/kern_sig.c:1.344	Wed May 16 00:42:15 2018
+++ src/sys/kern/kern_sig.c	Sat May 19 02:42:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.344 2018/05/16 00:42:15 kamil Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.345 2018/05/19 02:42:58 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.344 2018/05/16 00:42:15 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.345 2018/05/19 02:42:58 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -114,6 +114,7 @@ static callout_t	proc_stop_ch	__cachelin
 
 sigset_t		contsigmask	__cacheline_aligned;
 static sigset_t		stopsigmask	__cacheline_aligned;
+static sigset_t		vforksigmask	__cacheline_aligned;
 sigset_t		sigcantmask	__cacheline_aligned;
 
 static void	ksiginfo_exechook(struct proc *, void *);
@@ -322,6 +323,7 @@ siginit(struct proc *p)
 	ps = p->p_sigacts;
 	sigemptyset();
 	sigemptyset();
+	sigemptyset();
 	sigemptyset();
 	for (signo = 1; signo < NSIG; signo++) {
 		prop = sigprop[signo];
@@ -329,6 +331,8 @@ siginit(struct proc *p)
 			sigaddset(, signo);
 		if (prop & SA_STOP)
 			sigaddset(, signo);
+		if (prop & SA_STOP && signo != SIGSTOP)
+			sigaddset(, signo);
 		if (prop & SA_CANTMASK)
 			sigaddset(, signo);
 		if (prop & SA_IGNORE && signo != SIGCONT)
@@ -1682,14 +1686,14 @@ issignal(struct lwp *l)
 			sp = >l_sigpend;
 			ss = sp->sp_set;
 			if ((p->p_lflag & PL_PPWAIT) != 0)
-sigminusset(, );
+sigminusset(, );
 			sigminusset(>l_sigmask, );
 
 			if ((signo = firstsig()) == 0) {
 sp = >p_sigpend;
 ss = sp->sp_set;
 if ((p->p_lflag & PL_PPWAIT) != 0)
-	sigminusset(, );
+	sigminusset(, );
 sigminusset(>l_sigmask, );
 
 if ((signo = firstsig()) == 0) {

Index: src/tests/lib/libc/sys/t_fork.c
diff -u src/tests/lib/libc/sys/t_fork.c:1.1 src/tests/lib/libc/sys/t_fork.c:1.2
--- src/tests/lib/libc/sys/t_fork.c:1.1	Fri May 18 06:39:58 2018
+++ src/tests/lib/libc/sys/t_fork.c	Sat May 19 02:42:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fork.c,v 1.1 2018/05/18 06:39:58 kamil Exp $	*/
+/*	$NetBSD: t_fork.c,v 1.2 2018/05/19 02:42:58 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2018\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_fork.c,v 1.1 2018/05/18 06:39:58 kamil Exp $");
+__RCSID("$NetBSD: t_fork.c,v 1.2 2018/05/19 02:42:58 kamil Exp $");
 
 #include 
 #include 
@@ -139,12 +139,6 @@ raise_raw(int sig)
 	pid_t child, parent, watcher, wpid;
 	int expect_core = (sig == SIGABRT) ? 1 : 0;
 
-#ifdef VFORK
-	if (sig == SIGSTOP) {
-		atf_tc_expect_fail("SIGSTOP shall not be ignored");
-	}
-#endif
-
 	/*
 	 * Spawn a dedicated thread to watch for a stopped child and emit
 	 * the SIGTERM signal to it.



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

2018-05-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 19 01:53:24 UTC 2018

Modified Files:
src/external/bsd/byacc/dist: btyaccpar.c yaccpar.c

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/byacc/dist/btyaccpar.c
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/byacc/dist/yaccpar.c

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



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

2018-05-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 19 01:53:24 UTC 2018

Modified Files:
src/external/bsd/byacc/dist: btyaccpar.c yaccpar.c

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/byacc/dist/btyaccpar.c
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/byacc/dist/yaccpar.c

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

Modified files:

Index: src/external/bsd/byacc/dist/btyaccpar.c
diff -u src/external/bsd/byacc/dist/btyaccpar.c:1.4 src/external/bsd/byacc/dist/btyaccpar.c:1.5
--- src/external/bsd/byacc/dist/btyaccpar.c:1.4	Mon Jun  5 14:54:30 2017
+++ src/external/bsd/byacc/dist/btyaccpar.c	Fri May 18 21:53:24 2018
@@ -1,10 +1,8 @@
-/*	$NetBSD: btyaccpar.c,v 1.4 2017/06/05 18:54:30 christos Exp $	*/
-
 /* This file generated automatically using
- * @Id: skel2c,v 1.4 2016/06/07 00:26:09 tom Exp @
+ * Id: skel2c,v 1.4 2016/06/07 00:26:09 tom Exp 
  */
 
-/* @Id: btyaccpar.skel,v 1.6 2017/04/30 23:40:34 tom Exp @ */
+/* Id: btyaccpar.skel,v 1.7 2017/05/01 00:13:19 tom Exp  */
 
 #include "defs.h"
 
@@ -109,17 +107,17 @@ const char *const hdr_defs[] =
 "{ \\",
 "if (n == 0) \\",
 "{ \\",
-"(loc).first_line   = ((rhs)[-1]).last_line; \\",
-"(loc).first_column = ((rhs)[-1]).last_column; \\",
-"(loc).last_line= ((rhs)[-1]).last_line; \\",
-"(loc).last_column  = ((rhs)[-1]).last_column; \\",
+"(loc).first_line   = YYRHSLOC(rhs, 0).last_line; \\",
+"(loc).first_column = YYRHSLOC(rhs, 0).last_column; \\",
+"(loc).last_line= YYRHSLOC(rhs, 0).last_line; \\",
+"(loc).last_column  = YYRHSLOC(rhs, 0).last_column; \\",
 "} \\",
 "else \\",
 "{ \\",
-"(loc).first_line   = ((rhs)[ 0 ]).first_line; \\",
-"(loc).first_column = ((rhs)[ 0 ]).first_column; \\",
-"(loc).last_line= ((rhs)[n-1]).last_line; \\",
-"(loc).last_column  = ((rhs)[n-1]).last_column; \\",
+"(loc).first_line   = YYRHSLOC(rhs, 1).first_line; \\",
+"(loc).first_column = YYRHSLOC(rhs, 1).first_column; \\",
+"(loc).last_line= YYRHSLOC(rhs, n).last_line; \\",
+"(loc).last_column  = YYRHSLOC(rhs, n).last_column; \\",
 "} \\",
 "} while (0)",
 "#endif /* YYLLOC_DEFAULT */",
@@ -322,7 +320,7 @@ const char *const body_1[] =
 "newsize = YYMAXDEPTH;",
 "",
 "i = (int) (data->s_mark - data->s_base);",
-"newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));",
+"newss = realloc(data->s_base, newsize * sizeof(*newss));",
 "if (newss == 0)",
 "return YYENOMEM;",
 "",
@@ -387,13 +385,13 @@ const char *const body_1[] =
 "#endif",
 "return p;",
 "}",
-"p->yystack.s_base= (YYINT *) malloc(size * sizeof(YYINT));",
+"p->yystack.s_base= malloc(size * sizeof(YYINT));",
 "if (p->yystack.s_base == NULL) return NULL;",
-"p->yystack.l_base= (YYSTYPE *) malloc(size * sizeof(YYSTYPE));",
+"p->yystack.l_base= malloc(size * sizeof(YYSTYPE));",
 "if (p->yystack.l_base == NULL) return NULL;",
 "memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));",
 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
-"p->yystack.p_base= (YYLTYPE *) malloc(size * sizeof(YYLTYPE));",
+"p->yystack.p_base= malloc(size * sizeof(YYLTYPE));",
 "if (p->yystack.p_base == NULL) return NULL;",
 "memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));",
 "#endif",
@@ -438,7 +436,7 @@ const char *const body_2[] =
 "#endif /* YYBTYACC */",
 #endif			/* defined(YYBTYACC) */
 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
-"YYLTYPE  yyerror_loc_range[2]; /* position of error start & end */",
+"YYLTYPE  yyerror_loc_range[3]; /* position of error start (0 unused) */",
 "#endif",
 "#if YYDEBUG",
 "const char *yys;",
@@ -860,7 +858,7 @@ const char *const body_3[] =
 "",
 "YYERROR_CALL(\"syntax error\");",
 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
-"yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */",
+"yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */",
 "#endif",
 "",
 "#if !YYBTYACC",
@@ -889,7 +887,7 @@ const char *const body_3[] =
 "*++yystack.l_mark = yylval;",
 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
 "/* lookahead position is error end position */",
-"yyerror_loc_range[1] = yylloc;",
+"yyerror_loc_range[2] = yylloc;",
 "YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */",
 "   

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

2018-05-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 19 01:52:49 UTC 2018

Modified Files:
src/external/bsd/byacc/dist: btyaccpar.skel

Log Message:
provide bison compatibility for YYLLOC_DEFAULT


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/byacc/dist/btyaccpar.skel

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

Modified files:

Index: src/external/bsd/byacc/dist/btyaccpar.skel
diff -u src/external/bsd/byacc/dist/btyaccpar.skel:1.4 src/external/bsd/byacc/dist/btyaccpar.skel:1.5
--- src/external/bsd/byacc/dist/btyaccpar.skel:1.4	Mon Jun  5 14:54:30 2017
+++ src/external/bsd/byacc/dist/btyaccpar.skel	Fri May 18 21:52:48 2018
@@ -74,17 +74,17 @@ do \
 { \
 if (n == 0) \
 { \
-(loc).first_line   = ((rhs)[-1]).last_line; \
-(loc).first_column = ((rhs)[-1]).last_column; \
-(loc).last_line= ((rhs)[-1]).last_line; \
-(loc).last_column  = ((rhs)[-1]).last_column; \
+(loc).first_line   = YYRHSLOC(rhs, 0).last_line; \
+(loc).first_column = YYRHSLOC(rhs, 0).last_column; \
+(loc).last_line= YYRHSLOC(rhs, 0).last_line; \
+(loc).last_column  = YYRHSLOC(rhs, 0).last_column; \
 } \
 else \
 { \
-(loc).first_line   = ((rhs)[ 0 ]).first_line; \
-(loc).first_column = ((rhs)[ 0 ]).first_column; \
-(loc).last_line= ((rhs)[n-1]).last_line; \
-(loc).last_column  = ((rhs)[n-1]).last_column; \
+(loc).first_line   = YYRHSLOC(rhs, 1).first_line; \
+(loc).first_column = YYRHSLOC(rhs, 1).first_column; \
+(loc).last_line= YYRHSLOC(rhs, n).last_line; \
+(loc).last_column  = YYRHSLOC(rhs, n).last_column; \
 } \
 } while (0)
 #endif /* YYLLOC_DEFAULT */
@@ -371,7 +371,7 @@ YYPARSE_DECL()
 YYParseState *yyerrctx = NULL;
 %%endif
 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
-YYLTYPE  yyerror_loc_range[2]; /* position of error start & end */
+YYLTYPE  yyerror_loc_range[3]; /* position of error start (0 unused) */
 #endif
 #if YYDEBUG
 const char *yys;
@@ -773,7 +773,7 @@ yyerrhandler:
 
 YYERROR_CALL("syntax error");
 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
-yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
+yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
 #endif
 
 #if !YYBTYACC
@@ -802,7 +802,7 @@ yyinrecovery:
 *++yystack.l_mark = yylval;
 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
 /* lookahead position is error end position */
-yyerror_loc_range[1] = yylloc;
+yyerror_loc_range[2] = yylloc;
 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
 *++yystack.p_mark = yyloc;
 #endif
@@ -818,7 +818,7 @@ yyinrecovery:
 if (yystack.s_mark <= yystack.s_base) goto yyabort;
 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
 /* the current TOS position is the error start position */
-yyerror_loc_range[0] = *yystack.p_mark;
+yyerror_loc_range[1] = *yystack.p_mark;
 #endif
 #if defined(YYDESTRUCT_CALL)
 %%ifdef YYBTYACC
@@ -904,10 +904,10 @@ yyreduce:
 if (!yytrial)
 %%endif
 {
-YYLLOC_DEFAULT(yyloc, _mark[1-yym], yym);
+YYLLOC_DEFAULT(yyloc, _mark[-yym], yym);
 /* just in case YYERROR is invoked within the action, save
the start of the rhs as the error start position */
-yyerror_loc_range[0] = yystack.p_mark[1-yym];
+yyerror_loc_range[1] = yystack.p_mark[1-yym];
 }
 #endif
 



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

2018-05-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 19 01:52:49 UTC 2018

Modified Files:
src/external/bsd/byacc/dist: btyaccpar.skel

Log Message:
provide bison compatibility for YYLLOC_DEFAULT


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/byacc/dist/btyaccpar.skel

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



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

2018-05-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 19 01:51:05 UTC 2018

Modified Files:
src/external/bsd/byacc/dist: skel2c

Log Message:
Add awk line


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.4 -r1.2 src/external/bsd/byacc/dist/skel2c

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



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

2018-05-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 19 01:51:05 UTC 2018

Modified Files:
src/external/bsd/byacc/dist: skel2c

Log Message:
Add awk line


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.4 -r1.2 src/external/bsd/byacc/dist/skel2c

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

Modified files:

Index: src/external/bsd/byacc/dist/skel2c
diff -u src/external/bsd/byacc/dist/skel2c:1.1.1.4 src/external/bsd/byacc/dist/skel2c:1.2
--- src/external/bsd/byacc/dist/skel2c:1.1.1.4	Sat Feb 11 14:30:02 2017
+++ src/external/bsd/byacc/dist/skel2c	Fri May 18 21:51:05 2018
@@ -1,3 +1,4 @@
+#!/usr/bin/awk -f
 # vile: awkmode
 function noident(given) {
 	gsub(/\$/,"@", given);



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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 21:05:10 UTC 2018

Modified Files:
src/sys/arch/usermode/target/x86_64: cpu_x86_64.c

Log Message:
Remove outdated comment


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/target/x86_64/cpu_x86_64.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/target/x86_64

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 21:05:10 UTC 2018

Modified Files:
src/sys/arch/usermode/target/x86_64: cpu_x86_64.c

Log Message:
Remove outdated comment


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/target/x86_64/cpu_x86_64.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/target/x86_64/cpu_x86_64.c
diff -u src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.3 src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.4
--- src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.3	Fri May 18 20:11:48 2018
+++ src/sys/arch/usermode/target/x86_64/cpu_x86_64.c	Fri May 18 21:05:10 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_x86_64.c,v 1.3 2018/05/18 20:11:48 reinoud Exp $ */
+/* $NetBSD: cpu_x86_64.c,v 1.4 2018/05/18 21:05:10 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk 
@@ -27,15 +27,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
- * Note that this machdep.c uses the `dummy' mcontext_t defined for usermode.
- * This is basicly a blob of PAGE_SIZE big. We might want to switch over to
- * non-generic mcontext_t's one day, but will this break non-NetBSD hosts?
- */
-
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c,v 1.3 2018/05/18 20:11:48 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c,v 1.4 2018/05/18 21:05:10 reinoud Exp $");
 
 #include 
 #include 



CVS commit: src/sys/netinet6

2018-05-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 18 21:03:33 UTC 2018

Modified Files:
src/sys/netinet6: nd6_rtr.c

Log Message:
Add missing m_put_rcvif_psref.


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/netinet6/nd6_rtr.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/netinet6/nd6_rtr.c
diff -u src/sys/netinet6/nd6_rtr.c:1.141 src/sys/netinet6/nd6_rtr.c:1.142
--- src/sys/netinet6/nd6_rtr.c:1.141	Tue May  1 07:21:39 2018
+++ src/sys/netinet6/nd6_rtr.c	Fri May 18 21:03:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6_rtr.c,v 1.141 2018/05/01 07:21:39 maxv Exp $	*/
+/*	$NetBSD: nd6_rtr.c,v 1.142 2018/05/18 21:03:33 maxv Exp $	*/
 /*	$KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.141 2018/05/01 07:21:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.142 2018/05/18 21:03:33 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -177,6 +177,7 @@ nd6_rs_input(struct mbuf *m, int off, in
 	IP6_EXTHDR_GET(nd_rs, struct nd_router_solicit *, m, off, icmp6len);
 	if (nd_rs == NULL) {
 		ICMP6_STATINC(ICMP6_STAT_TOOSHORT);
+		m_put_rcvif_psref(ifp, );
 		return;
 	}
 



CVS commit: src/sys/netinet6

2018-05-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 18 21:03:33 UTC 2018

Modified Files:
src/sys/netinet6: nd6_rtr.c

Log Message:
Add missing m_put_rcvif_psref.


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/netinet6/nd6_rtr.c

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



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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:24:57 UTC 2018

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

Log Message:
Include OUR types.h and not the machine's. A small step to allow for
crosscompilation.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/usermode/include/thunk.h

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

Modified files:

Index: src/sys/arch/usermode/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.62 src/sys/arch/usermode/include/thunk.h:1.63
--- src/sys/arch/usermode/include/thunk.h:1.62	Fri Feb  6 10:25:13 2015
+++ src/sys/arch/usermode/include/thunk.h	Fri May 18 20:24:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.62 2015/02/06 10:25:13 prlw1 Exp $ */
+/* $NetBSD: thunk.h,v 1.63 2018/05/18 20:24:57 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill 
@@ -29,7 +29,7 @@
 #ifndef _ARCH_USERMODE_INCLUDE_THUNK_H
 #define _ARCH_USERMODE_INCLUDE_THUNK_H
 
-#include 
+#include "types.h"
 #include 
 #include 
 #include 



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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:24:16 UTC 2018

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

Log Message:
Replace the dynamically allocated signal stack to a static claimed one and add
diagnostic messages that can be enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/usermode/usermode/trap.c

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

Modified files:

Index: src/sys/arch/usermode/usermode/trap.c
diff -u src/sys/arch/usermode/usermode/trap.c:1.66 src/sys/arch/usermode/usermode/trap.c:1.67
--- src/sys/arch/usermode/usermode/trap.c:1.66	Sat Aug  4 14:53:32 2012
+++ src/sys/arch/usermode/usermode/trap.c	Fri May 18 20:24:16 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.66 2012/08/04 14:53:32 reinoud Exp $ */
+/* $NetBSD: trap.c,v 1.67 2018/05/18 20:24:16 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.66 2012/08/04 14:53:32 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.67 2018/05/18 20:24:16 reinoud Exp $");
 
 #include 
 #include 
@@ -62,6 +62,7 @@ static sigfunc_t sigio;
 static sigfunc_t pass_on;
 
 /* raw signal handlers */
+static charsig_stack[SIGSTKSZ];
 static stack_t sigstk;
 ucontext_t jump_ucp;
 
@@ -108,8 +109,7 @@ setup_signal_handlers(void)
 	 * effects. Especially ld.so and friends have such tiny stacks that
 	 * its not feasable.
 	 */
-	if ((sigstk.ss_sp = thunk_malloc(SIGSTKSZ)) == NULL)
-		panic("can't allocate signal stack space\n");
+	sigstk.ss_sp= sig_stack;
 	sigstk.ss_size  = SIGSTKSZ;
 	sigstk.ss_flags = 0;
 	if (thunk_sigaltstack(, 0) < 0)
@@ -293,8 +293,8 @@ print_illegal_instruction_siginfo(int si
 #endif
 }
 #else /* DEBUG */
-#define print_mem_access_siginfo(s, i, c, p, v, sp)
-#define print_illegal_instruction_siginfo(s, i, c, p, v, sp)
+#define print_mem_access_siginfo(s, i, c, p, v, sp) {}
+#define print_illegal_instruction_siginfo(s, i, c, p, v, sp) {}
 #endif /* DEBUG */
 
 
@@ -349,7 +349,7 @@ handle_signal(int sig, siginfo_t *info, 
 		sp = fp - sizeof(register_t);	/* slack */
 
 		/* sanity check before copying */
-		if (fp - 2*PAGE_SIZE < (vaddr_t) pcb->sys_stack)
+		if (fp - 4*PAGE_SIZE < (vaddr_t) pcb->sys_stack)
 			panic("%s: out of system stack", __func__);
 	}
 
@@ -431,6 +431,11 @@ pagefault(siginfo_t *info, vaddr_t from_
 	}
 
 	/* ask UVM */
+#if 0
+thunk_printf("%s: l %p, pcb %p, ", __func__, l, pcb);
+thunk_printf("pc %p, va %p ", (void *) pc, (void *) va);
+thunk_printf("derived atype %d\n", atype);
+#endif
 	thunk_printf_debug("pmap fault couldn't handle it! : "
 		"derived atype %d\n", atype);
 
@@ -452,10 +457,6 @@ pagefault(siginfo_t *info, vaddr_t from_
 		goto out;
 	}
 
-	/* something got wrong */
-	thunk_printf("%s: uvm fault %d, pc %p, va %p, from_kernel %d\n",
-		__func__, error, (void *) pc, (void *) va, from_kernel);
-
 	/* check if its from copyin/copyout */
 	if (onfault) {
 		panic("%s: can't call onfault yet\n", __func__);
@@ -468,11 +469,18 @@ pagefault(siginfo_t *info, vaddr_t from_
 		goto out;
 	}
 
-	if (from_kernel)
+	if (from_kernel) {
+		thunk_printf("%s: uvm fault %d, pc %p, va %p, from_kernel %d\n",
+			__func__, error, (void *) pc, (void *) va, from_kernel);
 		panic("Unhandled page fault in kernel mode");
+	}
 
 	/* send signal */
-	thunk_printf("giving signal to userland\n");
+	/* something got wrong */
+	thunk_printf_debug("%s: uvm fault %d, pc %p, va %p, from_kernel %d\n",
+		__func__, error, (void *) pc, (void *) va, from_kernel);
+
+	thunk_printf_debug("giving signal to userland\n");
 
 	KASSERT(from_userland);
 	KSI_INIT_TRAP();



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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:24:57 UTC 2018

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

Log Message:
Include OUR types.h and not the machine's. A small step to allow for
crosscompilation.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/usermode/include/thunk.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/usermode

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:24:16 UTC 2018

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

Log Message:
Replace the dynamically allocated signal stack to a static claimed one and add
diagnostic messages that can be enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/usermode/usermode/trap.c

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



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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:21:14 UTC 2018

Modified Files:
src/sys/arch/usermode/target/i386: cpu_i386.c

Log Message:
Use knowledge of mcontext for i386 support


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/target/i386/cpu_i386.c

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

Modified files:

Index: src/sys/arch/usermode/target/i386/cpu_i386.c
diff -u src/sys/arch/usermode/target/i386/cpu_i386.c:1.4 src/sys/arch/usermode/target/i386/cpu_i386.c:1.5
--- src/sys/arch/usermode/target/i386/cpu_i386.c:1.4	Sat Mar  3 21:15:16 2012
+++ src/sys/arch/usermode/target/i386/cpu_i386.c	Fri May 18 20:21:14 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_i386.c,v 1.4 2012/03/03 21:15:16 reinoud Exp $ */
+/* $NetBSD: cpu_i386.c,v 1.5 2018/05/18 20:21:14 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk 
@@ -27,14 +27,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
- * Note that this machdep.c uses the `dummy' mcontext_t defined for usermode.
- * This is basicly a blob of PAGE_SIZE big. We might want to switch over to
- * non-generic mcontext_t's one day, but will this break non-NetBSD hosts?
- */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.4 2012/03/03 21:15:16 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.5 2018/05/18 20:21:14 reinoud Exp $");
 
 #include 
 #include 
@@ -117,7 +112,7 @@ sendsig_siginfo(const ksiginfo_t *ksi, c
 	KASSERT(mutex_owned(p->p_lock));
 
 	ucp = >pcb_userret_ucp;
-	reg = (register_t *) >uc_mcontext;
+	reg = (register_t *) >uc_mcontext.__gregs;
 #if 0
 	thunk_printf("%s: ", __func__);
 	thunk_printf("flags %d, ", (int) ksi->ksi_flags);
@@ -198,7 +193,7 @@ setregs(struct lwp *l, struct exec_packa
 
 	/* set up the user context */
 	ucp = >pcb_userret_ucp;
-	reg = (int *) >uc_mcontext;
+	reg = (int *) >uc_mcontext.__gregs;
 	for (i = 4; i < 11; i++)
 		reg[i] = 0;
 
@@ -228,7 +223,7 @@ setregs(struct lwp *l, struct exec_packa
 void
 md_syscall_get_syscallnumber(ucontext_t *ucp, uint32_t *code)
 {
-	uint *reg = (int *) >uc_mcontext;
+	uint *reg = (int *) >uc_mcontext.__gregs;
 	*code = reg[11];			/* EAX */
 }
 
@@ -236,7 +231,7 @@ int
 md_syscall_getargs(lwp_t *l, ucontext_t *ucp, int nargs, int argsize,
 	register_t *args)
 {
-	uint *reg = (int *) >uc_mcontext;
+	uint *reg = (int *) >uc_mcontext.__gregs;
 	register_t *sp = (register_t *) reg[17];/* ESP */
 	int ret;
 
@@ -250,7 +245,7 @@ void
 md_syscall_set_returnargs(lwp_t *l, ucontext_t *ucp,
 	int error, register_t *rval)
 {
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 
 	reg[16] &= ~PSL_C;		/* EFL */
 	if (error > 0) {
@@ -270,7 +265,7 @@ register_t
 md_get_pc(ucontext_t *ucp)
 {
 	KASSERT(ucp);
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 
 	return reg[14];			/* EIP */
 }
@@ -279,7 +274,7 @@ register_t
 md_get_sp(ucontext_t *ucp)
 {
 	KASSERT(ucp);
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 
 	return reg[17];			/* ESP */
 }
@@ -307,7 +302,7 @@ void
 md_syscall_get_opcode(ucontext_t *ucp, uint32_t *opcode)
 {
 	KASSERT(ucp);
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 //	uint8_t  *p8  = (uint8_t *) (reg[14]);
 	uint16_t *p16 = (uint16_t*) (reg[14]);	/* EIP */
 
@@ -328,7 +323,7 @@ void
 md_syscall_inc_pc(ucontext_t *ucp, uint32_t opcode)
 {
 	KASSERT(ucp);
-	uint *reg = (int *) >uc_mcontext;
+	uint *reg = (int *) >uc_mcontext.__gregs;
 
 	/* advance program counter */
 	switch (opcode) {
@@ -349,7 +344,7 @@ void
 md_syscall_dec_pc(ucontext_t *ucp, uint32_t opcode)
 {
 	KASSERT(ucp);
-	uint *reg = (int *) >uc_mcontext;
+	uint *reg = (int *) >uc_mcontext.__gregs;
 
 	switch (opcode) {
 	case 0xff0f:	/* UD1  */



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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:21:14 UTC 2018

Modified Files:
src/sys/arch/usermode/target/i386: cpu_i386.c

Log Message:
Use knowledge of mcontext for i386 support


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/target/i386/cpu_i386.c

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



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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:11:48 UTC 2018

Modified Files:
src/sys/arch/usermode/target/x86_64: cpu_x86_64.c

Log Message:
Use knowledge about the mcontext


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/target/x86_64/cpu_x86_64.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/target/x86_64/cpu_x86_64.c
diff -u src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.2 src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.3
--- src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.2	Sat Jan 14 17:42:52 2012
+++ src/sys/arch/usermode/target/x86_64/cpu_x86_64.c	Fri May 18 20:11:48 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_x86_64.c,v 1.2 2012/01/14 17:42:52 reinoud Exp $ */
+/* $NetBSD: cpu_x86_64.c,v 1.3 2018/05/18 20:11:48 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk 
@@ -35,7 +35,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c,v 1.2 2012/01/14 17:42:52 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c,v 1.3 2018/05/18 20:11:48 reinoud Exp $");
 
 #include 
 #include 
@@ -118,7 +118,7 @@ sendsig_siginfo(const ksiginfo_t *ksi, c
 	KASSERT(mutex_owned(p->p_lock));
 
 	ucp = >pcb_userret_ucp;
-	reg = (register_t *) >uc_mcontext;
+	reg = (register_t *) >uc_mcontext.__gregs;
 #if 0
 	thunk_printf("%s: ", __func__);
 	thunk_printf("flags %d, ", (int) ksi->ksi_flags);
@@ -195,7 +195,7 @@ setregs(struct lwp *l, struct exec_packa
 
 	/* set up the user context */
 	ucp = >pcb_userret_ucp;
-	reg = (register_t *) >uc_mcontext;
+	reg = (register_t *) >uc_mcontext.__gregs;
 	for (i = 0; i < 15; i++)
 		reg[i] = 0;
 
@@ -213,7 +213,7 @@ setregs(struct lwp *l, struct exec_packa
 void
 md_syscall_get_syscallnumber(ucontext_t *ucp, uint32_t *code)
 {
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 	*code = reg[14];			/* RAX */
 }
 
@@ -221,7 +221,7 @@ int
 md_syscall_getargs(lwp_t *l, ucontext_t *ucp, int nargs, int argsize,
 	register_t *args)
 {
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 	register_t *sp = (register_t *) reg[24];/* RSP */
 	int ret;
 
@@ -251,7 +251,7 @@ void
 md_syscall_set_returnargs(lwp_t *l, ucontext_t *ucp,
 	int error, register_t *rval)
 {
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 
 	reg[23] &= ~PSL_C;		/* RFLAGS */
 	if (error > 0) {
@@ -270,7 +270,7 @@ md_syscall_set_returnargs(lwp_t *l, ucon
 register_t
 md_get_pc(ucontext_t *ucp)
 {
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 
 	return reg[21];			/* RIP */
 }
@@ -278,7 +278,7 @@ md_get_pc(ucontext_t *ucp)
 register_t
 md_get_sp(ucontext_t *ucp)
 {
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 
 	return reg[24];			/* RSP */
 }
@@ -306,7 +306,7 @@ md_syscall_check_opcode(ucontext_t *ucp)
 void
 md_syscall_get_opcode(ucontext_t *ucp, uint32_t *opcode)
 {
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 //	uint8_t  *p8  = (uint8_t *) (reg[21]);
 	uint16_t *p16 = (uint16_t*) (reg[21]);	/* RIP */
 
@@ -326,7 +326,7 @@ md_syscall_get_opcode(ucontext_t *ucp, u
 void
 md_syscall_inc_pc(ucontext_t *ucp, uint32_t opcode)
 {
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 
 	/* advance program counter */
 	switch (opcode) {
@@ -346,7 +346,7 @@ md_syscall_inc_pc(ucontext_t *ucp, uint3
 void
 md_syscall_dec_pc(ucontext_t *ucp, uint32_t opcode)
 {
-	register_t *reg = (register_t *) >uc_mcontext;
+	register_t *reg = (register_t *) >uc_mcontext.__gregs;
 
 	switch (opcode) {
 	case 0xff0f:	/* UD1  */



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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:11:48 UTC 2018

Modified Files:
src/sys/arch/usermode/target/x86_64: cpu_x86_64.c

Log Message:
Use knowledge about the mcontext


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/target/x86_64/cpu_x86_64.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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:10:25 UTC 2018

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

Log Message:
Second part for creating sensible coredumps


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/usermode/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/usermode/usermode/process_machdep.c
diff -u src/sys/arch/usermode/usermode/process_machdep.c:1.4 src/sys/arch/usermode/usermode/process_machdep.c:1.5
--- src/sys/arch/usermode/usermode/process_machdep.c:1.4	Sat Jan 13 15:15:03 2018
+++ src/sys/arch/usermode/usermode/process_machdep.c	Fri May 18 20:10:25 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: process_machdep.c,v 1.4 2018/01/13 15:15:03 reinoud Exp $ */
+/* $NetBSD: process_machdep.c,v 1.5 2018/05/18 20:10:25 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill 
@@ -26,58 +26,135 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+
+/* from sys/arch/amd64/amd64/process_machdep.c */
+/*
+ * This file may seem a bit stylized, but that so that it's easier to port.
+ * Functions to be implemented here are:
+ *
+ * process_read_regs(proc, regs)
+ *	Get the current user-visible register set from the process
+ *	and copy it into the regs structure ().
+ *	The process is stopped at the time read_regs is called.
+ *
+ * process_write_regs(proc, regs)
+ *	Update the current register set from the passed in regs
+ *	structure.  Take care to avoid clobbering special CPU
+ *	registers or privileged bits in the PSL.
+ *	The process is stopped at the time write_regs is called.
+ *
+ * process_read_fpregs(proc, regs, sz)
+ *	Get the current user-visible register set from the process
+ *	and copy it into the regs structure ().
+ *	The process is stopped at the time read_fpregs is called.
+ *
+ * process_write_fpregs(proc, regs, sz)
+ *	Update the current register set from the passed in regs
+ *	structure.  Take care to avoid clobbering special CPU
+ *	registers or privileged bits in the PSL.
+ *	The process is stopped at the time write_fpregs is called.
+ *
+ * process_read_dbregs(proc, regs, sz)
+ *	Get the current user-visible register set from the process
+ *	and copy it into the regs structure ().
+ *	The process is stopped at the time read_dbregs is called.
+ *
+ * process_write_dbregs(proc, regs, sz)
+ *	Update the current register set from the passed in regs
+ *	structure.  Take care to avoid clobbering special CPU
+ *	registers or privileged bits in the PSL.
+ *	The process is stopped at the time write_dbregs is called.
+ *
+ * process_sstep(proc)
+ *	Arrange for the process to trap after executing a single instruction.
+ *
+ * process_set_pc(proc)
+ *	Set the process's program counter.
+ */
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.4 2018/01/13 15:15:03 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.5 2018/05/18 20:10:25 reinoud Exp $");
 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+#include 
+
+#include 
+
 int
 process_read_regs(struct lwp *l, struct reg *regs)
 {
+ 	struct pcb *pcb = lwp_getpcb(l);
+	ucontext_t *ucp;
+ 	register_t *reg;
+
+	ucp = >pcb_userret_ucp;
+	reg = (register_t *) >uc_mcontext.__gregs;
+
+	memcpy(regs, reg, sizeof(__gregset_t));
+
 	return 0;
 }
 
 int
 process_read_fpregs(struct lwp *l, struct fpreg *regs, size_t *sz)
 {
+ 	struct pcb *pcb = lwp_getpcb(l);
+	ucontext_t *ucp;
+ 	register_t *reg;
+
+	ucp = >pcb_userret_ucp;
+	reg = (register_t *) >uc_mcontext.__fpregs;
+
+	*sz = sizeof(__fpregset_t);
+	memcpy(regs, reg, *sz);
+
 	return 0;
 }
 
 int
 process_write_regs(struct lwp *l, const struct reg *regs)
 {
+thunk_printf("%s called, not implemented\n", __func__);
 	return 0;
 }
 
 int
 process_write_fpregs(struct lwp *l, const struct fpreg *regs, size_t sz)
 {
+thunk_printf("%s called, not implemented\n", __func__);
 	return 0;
 }
 
 int
 process_sstep(struct lwp *l, int sstep)
 {
+thunk_printf("%s called, not implemented\n", __func__);
 	return 0;
 }
 
 int
 process_set_pc(struct lwp *l, void *addr)
 {
+thunk_printf("%s called, not implemented\n", __func__);
 	return 0;
 }
 
 int
 process_write_dbregs(struct lwp *l, const struct dbreg *regs, size_t sz)
 {
+thunk_printf("%s called, not implemented\n", __func__);
 	return 0;
 }
 
 int
 process_read_dbregs(struct lwp *l, struct dbreg *regs, size_t *sz)
 {
+thunk_printf("%s called, not implemented\n", __func__);
 	return 0;
 }
 



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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:10:25 UTC 2018

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

Log Message:
Second part for creating sensible coredumps


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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:09:33 UTC 2018

Modified Files:
src/sys/arch/usermode/include: reg.h

Log Message:
Implement own process register capture from userland.

NetBSD/usermode now creates readable and sensible coredumps


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/reg.h

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

Modified files:

Index: src/sys/arch/usermode/include/reg.h
diff -u src/sys/arch/usermode/include/reg.h:1.3 src/sys/arch/usermode/include/reg.h:1.4
--- src/sys/arch/usermode/include/reg.h:1.3	Sat Jan 13 14:39:15 2018
+++ src/sys/arch/usermode/include/reg.h	Fri May 18 20:09:32 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: reg.h,v 1.3 2018/01/13 14:39:15 reinoud Exp $ */
+/* $NetBSD: reg.h,v 1.4 2018/05/18 20:09:32 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill 
@@ -29,10 +29,16 @@
 #ifndef _ARCH_USERMODE_INCLUDE_REG_H
 #define _ARCH_USERMODE_INCLUDE_REG_H
 
+#include "machine/mcontext.h"
+
+/* registers are already in the right order since they follow mcontext.h */
 struct reg {
+	__gregset_t regs;
 };
 
+/* registers are already in the right order since they follow mcontext.h */
 struct fpreg {
+__fpregset_t fpregs;
 };
 
 /* x86_64 only */



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

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 20:09:33 UTC 2018

Modified Files:
src/sys/arch/usermode/include: reg.h

Log Message:
Implement own process register capture from userland.

NetBSD/usermode now creates readable and sensible coredumps


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/reg.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/conf

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 19:04:11 UTC 2018

Added Files:
src/sys/arch/usermode/conf: kern.ldscript

Log Message:
Where did kern.ldscript go?


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/conf/kern.ldscript

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/conf

2018-05-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 18 19:04:11 UTC 2018

Added Files:
src/sys/arch/usermode/conf: kern.ldscript

Log Message:
Where did kern.ldscript go?


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/conf/kern.ldscript

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

Added files:

Index: src/sys/arch/usermode/conf/kern.ldscript
diff -u /dev/null src/sys/arch/usermode/conf/kern.ldscript:1.1
--- /dev/null	Fri May 18 19:04:11 2018
+++ src/sys/arch/usermode/conf/kern.ldscript	Fri May 18 19:04:10 2018
@@ -0,0 +1,73 @@
+/*	$NetBSD: kern.ldscript,v 1.1 2018/05/18 19:04:10 reinoud Exp $	*/
+
+#include "assym.h"
+
+ENTRY(_start)
+SECTIONS
+{
+	/* Read-only sections, merged into text segment: */
+	.text :
+	{
+		*(.text)
+		*(.text.*)
+		*(.stub)
+	}
+	_etext = . ;
+	PROVIDE (etext = .) ;
+
+	.rodata :
+	{
+		*(.rodata)
+		*(.rodata.*)
+	}
+
+	/*
+	 * Adjust the address for the data segment.  We want to adjust up to
+	 * the same address within the page on the next page up.
+	 */
+	. = ALIGN(0x10) + (. & (0x10 - 1));
+	__data_start = . ;
+	.data :
+	{
+		*(.data)
+	}
+
+	. = ALIGN(COHERENCY_UNIT);
+	.data.cacheline_aligned :
+	{
+		*(.data.cacheline_aligned)
+	}
+	. = ALIGN(COHERENCY_UNIT);
+	.data.read_mostly :
+	{
+		*(.data.read_mostly)
+	}
+	. = ALIGN(COHERENCY_UNIT);
+
+	_edata = . ;
+	PROVIDE (edata = .) ;
+	__bss_start = . ;
+	.bss :
+	{
+		*(.bss)
+		*(.bss.*)
+		*(COMMON)
+		. = ALIGN(64 / 8);
+	}
+	. = ALIGN(64 / 8);
+	_end = . ;
+	PROVIDE (end = .) ;
+	.note.netbsd.ident :
+	{
+		KEEP(*(.note.netbsd.ident));
+	}
+}
+
+SECTIONS
+{
+	.text :
+	AT (ADDR(.text) & 0x0fff)
+	{
+		*(.text)
+	} = 0
+}



CVS commit: src/sys/netipsec

2018-05-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 18 19:02:49 UTC 2018

Modified Files:
src/sys/netipsec: ipsec_input.c xform_ah.c xform_esp.c

Log Message:
IP6_EXTHDR_GET -> M_REGION_GET, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/netipsec/ipsec_input.c
cvs rdiff -u -r1.100 -r1.101 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.88 -r1.89 src/sys/netipsec/xform_esp.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/netipsec/ipsec_input.c
diff -u src/sys/netipsec/ipsec_input.c:1.69 src/sys/netipsec/ipsec_input.c:1.70
--- src/sys/netipsec/ipsec_input.c:1.69	Sun Apr 29 14:54:09 2018
+++ src/sys/netipsec/ipsec_input.c	Fri May 18 19:02:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec_input.c,v 1.69 2018/04/29 14:54:09 maxv Exp $	*/
+/*	$NetBSD: ipsec_input.c,v 1.70 2018/05/18 19:02:49 maxv Exp $	*/
 /*	$FreeBSD: ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $	*/
 /*	$OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $	*/
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.69 2018/04/29 14:54:09 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.70 2018/05/18 19:02:49 maxv Exp $");
 
 /*
  * IPsec input processing.
@@ -139,7 +139,7 @@ ipsec4_fixup_checksum(struct mbuf *m)
 
 	switch (ip->ip_p) {
 	case IPPROTO_TCP:
-		IP6_EXTHDR_GET(th, struct tcphdr *, m, poff, sizeof(*th));
+		M_REGION_GET(th, struct tcphdr *, m, poff, sizeof(*th));
 		if (th == NULL)
 			return NULL;
 		off = th->th_off << 2;
@@ -151,7 +151,7 @@ ipsec4_fixup_checksum(struct mbuf *m)
 		th->th_sum = in4_cksum(m, IPPROTO_TCP, poff, plen);
 		break;
 	case IPPROTO_UDP:
-		IP6_EXTHDR_GET(uh, struct udphdr *, m, poff, sizeof(*uh));
+		M_REGION_GET(uh, struct udphdr *, m, poff, sizeof(*uh));
 		if (uh == NULL)
 			return NULL;
 		off = sizeof(*uh);

Index: src/sys/netipsec/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.100 src/sys/netipsec/xform_ah.c:1.101
--- src/sys/netipsec/xform_ah.c:1.100	Sun May 13 18:34:59 2018
+++ src/sys/netipsec/xform_ah.c	Fri May 18 19:02:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.100 2018/05/13 18:34:59 maxv Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.101 2018/05/18 19:02:49 maxv Exp $	*/
 /*	$FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.100 2018/05/13 18:34:59 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.101 2018/05/18 19:02:49 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -530,7 +530,7 @@ ah_input(struct mbuf *m, struct secasvar
 	rplen = HDRSIZE(sav);
 
 	/* XXX don't pullup, just copy header */
-	IP6_EXTHDR_GET(ah, struct newah *, m, skip, rplen);
+	M_REGION_GET(ah, struct newah *, m, skip, rplen);
 	if (ah == NULL) {
 		/* m already freed */
 		return ENOBUFS;

Index: src/sys/netipsec/xform_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.88 src/sys/netipsec/xform_esp.c:1.89
--- src/sys/netipsec/xform_esp.c:1.88	Sun May 13 18:34:59 2018
+++ src/sys/netipsec/xform_esp.c	Fri May 18 19:02:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.88 2018/05/13 18:34:59 maxv Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.89 2018/05/18 19:02:49 maxv Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.88 2018/05/13 18:34:59 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.89 2018/05/18 19:02:49 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -309,7 +309,7 @@ esp_input(struct mbuf *m, struct secasva
 	skip, m->m_pkthdr.len);
 
 	/* XXX don't pullup, just copy header */
-	IP6_EXTHDR_GET(esp, struct newesp *, m, skip, sizeof(struct newesp));
+	M_REGION_GET(esp, struct newesp *, m, skip, sizeof(struct newesp));
 	if (esp == NULL) {
 		/* m already freed */
 		return ENOBUFS;



CVS commit: src/sys/netipsec

2018-05-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 18 19:02:49 UTC 2018

Modified Files:
src/sys/netipsec: ipsec_input.c xform_ah.c xform_esp.c

Log Message:
IP6_EXTHDR_GET -> M_REGION_GET, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/netipsec/ipsec_input.c
cvs rdiff -u -r1.100 -r1.101 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.88 -r1.89 src/sys/netipsec/xform_esp.c

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



CVS commit: src/sys/netinet

2018-05-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 18 18:58:51 UTC 2018

Modified Files:
src/sys/netinet: dccp_usrreq.c ip_carp.c tcp_input.c tcp_sack.c
udp_usrreq.c

Log Message:
IP6_EXTHDR_GET -> M_REGION_GET, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/netinet/dccp_usrreq.c
cvs rdiff -u -r1.95 -r1.96 src/sys/netinet/ip_carp.c
cvs rdiff -u -r1.407 -r1.408 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.35 -r1.36 src/sys/netinet/tcp_sack.c
cvs rdiff -u -r1.251 -r1.252 src/sys/netinet/udp_usrreq.c

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



CVS commit: src/sys/netinet

2018-05-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 18 18:58:51 UTC 2018

Modified Files:
src/sys/netinet: dccp_usrreq.c ip_carp.c tcp_input.c tcp_sack.c
udp_usrreq.c

Log Message:
IP6_EXTHDR_GET -> M_REGION_GET, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/netinet/dccp_usrreq.c
cvs rdiff -u -r1.95 -r1.96 src/sys/netinet/ip_carp.c
cvs rdiff -u -r1.407 -r1.408 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.35 -r1.36 src/sys/netinet/tcp_sack.c
cvs rdiff -u -r1.251 -r1.252 src/sys/netinet/udp_usrreq.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/netinet/dccp_usrreq.c
diff -u src/sys/netinet/dccp_usrreq.c:1.18 src/sys/netinet/dccp_usrreq.c:1.19
--- src/sys/netinet/dccp_usrreq.c:1.18	Thu May  3 07:01:08 2018
+++ src/sys/netinet/dccp_usrreq.c	Fri May 18 18:58:51 2018
@@ -1,5 +1,5 @@
 /*	$KAME: dccp_usrreq.c,v 1.67 2005/11/03 16:05:04 nishida Exp $	*/
-/*	$NetBSD: dccp_usrreq.c,v 1.18 2018/05/03 07:01:08 maxv Exp $ */
+/*	$NetBSD: dccp_usrreq.c,v 1.19 2018/05/18 18:58:51 maxv Exp $ */
 
 /*
  * Copyright (c) 2003 Joacim Häggmark, Magnus Erixzon, Nils-Erik Mattsson 
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.18 2018/05/03 07:01:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.19 2018/05/18 18:58:51 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -230,7 +230,7 @@ dccp_input(struct mbuf *m, ...)
 	if (isipv6) {
 		DCCP_DEBUG((LOG_INFO, "Got DCCP ipv6 packet, iphlen = %u!\n", iphlen));
 		ip6 = mtod(m, struct ip6_hdr *);
-		IP6_EXTHDR_GET(dh, struct dccphdr *, m, iphlen, sizeof(*dh));
+		M_REGION_GET(dh, struct dccphdr *, m, iphlen, sizeof(*dh));
 		if (dh == NULL) {
 			dccpstat.dccps_badlen++;
 			return;
@@ -256,7 +256,7 @@ dccp_input(struct mbuf *m, ...)
 		 * Get IP and DCCP header together in first mbuf.
 		 */
 		ip = mtod(m, struct ip *);
-		IP6_EXTHDR_GET(dh, struct dccphdr *, m, iphlen, sizeof(*dh));
+		M_REGION_GET(dh, struct dccphdr *, m, iphlen, sizeof(*dh));
 		if (dh == NULL) {
 			dccpstat.dccps_badlen++;
 			return;

Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.95 src/sys/netinet/ip_carp.c:1.96
--- src/sys/netinet/ip_carp.c:1.95	Wed Mar 21 15:33:25 2018
+++ src/sys/netinet/ip_carp.c	Fri May 18 18:58:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_carp.c,v 1.95 2018/03/21 15:33:25 maxv Exp $	*/
+/*	$NetBSD: ip_carp.c,v 1.96 2018/05/18 18:58:51 maxv Exp $	*/
 /*	$OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.95 2018/03/21 15:33:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.96 2018/05/18 18:58:51 maxv Exp $");
 
 /*
  * TODO:
@@ -615,7 +615,7 @@ _carp6_proto_input(struct mbuf *m, int o
 
 	/* verify that we have a complete carp packet */
 	len = m->m_len;
-	IP6_EXTHDR_GET(ch, struct carp_header *, m, off, sizeof(*ch));
+	M_REGION_GET(ch, struct carp_header *, m, off, sizeof(*ch));
 	if (ch == NULL) {
 		CARP_STATINC(CARP_STAT_BADLEN);
 		CARP_LOG(sc, ("packet size %u too small", len));

Index: src/sys/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.407 src/sys/netinet/tcp_input.c:1.408
--- src/sys/netinet/tcp_input.c:1.407	Thu May  3 07:13:48 2018
+++ src/sys/netinet/tcp_input.c	Fri May 18 18:58:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.407 2018/05/03 07:13:48 maxv Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.408 2018/05/18 18:58:51 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.407 2018/05/03 07:13:48 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.408 2018/05/18 18:58:51 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -200,7 +200,6 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_input.c,
 #endif
 
 #ifndef INET6
-/* always need ip6.h for IP6_EXTHDR_GET */
 #include 
 #endif
 
@@ -1238,7 +1237,7 @@ tcp_input(struct mbuf *m, ...)
 	}
 #endif
 
-	IP6_EXTHDR_GET(th, struct tcphdr *, m, toff, sizeof(struct tcphdr));
+	M_REGION_GET(th, struct tcphdr *, m, toff, sizeof(struct tcphdr));
 	if (th == NULL) {
 		TCP_STATINC(TCP_STAT_RCVSHORT);
 		return;
@@ -1336,7 +1335,7 @@ tcp_input(struct mbuf *m, ...)
 	tlen -= off;
 
 	if (off > sizeof(struct tcphdr)) {
-		IP6_EXTHDR_GET(th, struct tcphdr *, m, toff, off);
+		M_REGION_GET(th, struct tcphdr *, m, toff, off);
 		if (th == NULL) {
 			TCP_STATINC(TCP_STAT_RCVSHORT);
 			return;

Index: src/sys/netinet/tcp_sack.c
diff -u src/sys/netinet/tcp_sack.c:1.35 src/sys/netinet/tcp_sack.c:1.36
--- src/sys/netinet/tcp_sack.c:1.35	Thu May  3 07:13:48 2018
+++ src/sys/netinet/tcp_sack.c	Fri May 18 18:58:51 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_sack.c,v 1.35 2018/05/03 07:13:48 maxv Exp $ */
+/* $NetBSD: tcp_sack.c,v 1.36 2018/05/18 18:58:51 maxv Exp $ */
 

CVS commit: src/sys

2018-05-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 18 18:52:17 UTC 2018

Modified Files:
src/sys/netinet: ip6.h
src/sys/sys: mbuf.h

Log Message:
IP6_EXTHDR_GET performs a basic mbuf operation, which has nothing to do
with IPv6. So declare an IP-independent M_REGION_GET, and make
IP6_EXTHDR_GET an alias to it.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/netinet/ip6.h
cvs rdiff -u -r1.205 -r1.206 src/sys/sys/mbuf.h

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



CVS commit: src/sys

2018-05-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 18 18:52:17 UTC 2018

Modified Files:
src/sys/netinet: ip6.h
src/sys/sys: mbuf.h

Log Message:
IP6_EXTHDR_GET performs a basic mbuf operation, which has nothing to do
with IPv6. So declare an IP-independent M_REGION_GET, and make
IP6_EXTHDR_GET an alias to it.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/netinet/ip6.h
cvs rdiff -u -r1.205 -r1.206 src/sys/sys/mbuf.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/netinet/ip6.h
diff -u src/sys/netinet/ip6.h:1.24 src/sys/netinet/ip6.h:1.25
--- src/sys/netinet/ip6.h:1.24	Fri May 18 18:28:40 2018
+++ src/sys/netinet/ip6.h	Fri May 18 18:52:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6.h,v 1.24 2018/05/18 18:28:40 maxv Exp $	*/
+/*	$NetBSD: ip6.h,v 1.25 2018/05/18 18:52:17 maxv Exp $	*/
 /*	$KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $	*/
 
 /*
@@ -266,30 +266,8 @@ struct ip6_frag {
 #define IPV6_MAXPACKET	65535	/* ip6 max packet size without Jumbo payload*/
 
 #ifdef _KERNEL
-/*
- * IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to
- * "len") is located in single mbuf, on contiguous memory region.
- * The pointer to the region will be returned to pointer variable "val",
- * with type "typ".
- */
 #define IP6_EXTHDR_GET(val, typ, m, off, len) \
-do {	\
-	struct mbuf *_t;		\
-	int _tmp;			\
-	if ((m)->m_len >= (off) + (len))\
-		(val) = (typ)(mtod((m), char *) + (off));		\
-	else {\
-		_t = m_pulldown((m), (off), (len), &_tmp);		\
-		if (_t) {		\
-			if (_t->m_len < _tmp + (len))			\
-panic("m_pulldown malfunction");	\
-			(val) = (typ)(mtod(_t, char *) + _tmp);	\
-		} else {		\
-			(val) = (typ)NULL;\
-			(m) = NULL;	\
-		}			\
-	}\
-} while (/*CONSTCOND*/ 0)
+	M_REGION_GET(val, typ, m, off, len)
 #endif /*_KERNEL*/
 
 #endif /* !_NETINET_IP6_H_ */

Index: src/sys/sys/mbuf.h
diff -u src/sys/sys/mbuf.h:1.205 src/sys/sys/mbuf.h:1.206
--- src/sys/sys/mbuf.h:1.205	Thu May  3 21:37:29 2018
+++ src/sys/sys/mbuf.h	Fri May 18 18:52:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.h,v 1.205 2018/05/03 21:37:29 christos Exp $	*/
+/*	$NetBSD: mbuf.h,v 1.206 2018/05/18 18:52:17 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -644,6 +644,31 @@ do {	\
 #define	M_SETCTX(m, c)		((void)((m)->m_pkthdr._rcvif.ctx = (void *)(c)))
 #define	M_CLEARCTX(m)		M_SETCTX((m), NULL)
 
+/*
+ * M_REGION_GET ensures that the "len"-sized region of type "typ" starting
+ * from "off" within "m" is located in a single mbuf, contiguously.
+ *
+ * The pointer to the region will be returned to pointer variable "val".
+ */
+#define M_REGION_GET(val, typ, m, off, len) \
+do {	\
+	struct mbuf *_t;		\
+	int _tmp;			\
+	if ((m)->m_len >= (off) + (len))\
+		(val) = (typ)(mtod((m), char *) + (off));		\
+	else {\
+		_t = m_pulldown((m), (off), (len), &_tmp);		\
+		if (_t) {		\
+			if (_t->m_len < _tmp + (len))			\
+panic("m_pulldown malfunction");	\
+			(val) = (typ)(mtod(_t, char *) + _tmp);	\
+		} else {		\
+			(val) = (typ)NULL;\
+			(m) = NULL;	\
+		}			\
+	}\
+} while (/*CONSTCOND*/ 0)
+
 #endif /* defined(_KERNEL) */
 
 /*



CVS commit: src/sys/netinet

2018-05-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 18 18:28:40 UTC 2018

Modified Files:
src/sys/netinet: ip6.h

Log Message:
Remove IP6_EXTHDR_GET0, remove pointless XXXs, and style.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/netinet/ip6.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/netinet/ip6.h
diff -u src/sys/netinet/ip6.h:1.23 src/sys/netinet/ip6.h:1.24
--- src/sys/netinet/ip6.h:1.23	Tue Dec 25 18:33:46 2007
+++ src/sys/netinet/ip6.h	Fri May 18 18:28:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6.h,v 1.23 2007/12/25 18:33:46 perry Exp $	*/
+/*	$NetBSD: ip6.h,v 1.24 2018/05/18 18:28:40 maxv Exp $	*/
 /*	$KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $	*/
 
 /*
@@ -126,13 +126,12 @@ struct ip6_hdr_pseudo {
  * Extension Headers
  */
 
-struct	ip6_ext {
+struct ip6_ext {
 	u_int8_t ip6e_nxt;
 	u_int8_t ip6e_len;
 } __packed;
 
 /* Hop-by-Hop options header */
-/* XXX should we pad it to force alignment on an 8-byte boundary? */
 struct ip6_hbh {
 	u_int8_t ip6h_nxt;	/* next header */
 	u_int8_t ip6h_len;	/* length in units of 8 octets */
@@ -140,7 +139,6 @@ struct ip6_hbh {
 } __packed;
 
 /* Destination options header */
-/* XXX should we pad it to force alignment on an 8-byte boundary? */
 struct ip6_dest {
 	u_int8_t ip6d_nxt;	/* next header */
 	u_int8_t ip6d_len;	/* length in units of 8 octets */
@@ -159,7 +157,7 @@ struct ip6_dest {
 #define IP6OPT_RTALERT_LEN	4
 #define IP6OPT_RTALERT_MLD	0	/* Datagram contains an MLD message */
 #define IP6OPT_RTALERT_RSVP	1	/* Datagram contains an RSVP message */
-#define IP6OPT_RTALERT_ACTNET	2 	/* contains an Active Networks msg */
+#define IP6OPT_RTALERT_ACTNET	2	/* contains an Active Networks msg */
 #define IP6OPT_MINLEN		2
 
 #define IP6OPT_TYPE(o)		((o) & 0xC0)
@@ -222,10 +220,10 @@ struct ip6_opt_router {
 
 /* Routing header */
 struct ip6_rthdr {
-	u_int8_t  ip6r_nxt;	/* next header */
-	u_int8_t  ip6r_len;	/* length in units of 8 octets */
-	u_int8_t  ip6r_type;	/* routing type */
-	u_int8_t  ip6r_segleft;	/* segments left */
+	u_int8_t ip6r_nxt;	/* next header */
+	u_int8_t ip6r_len;	/* length in units of 8 octets */
+	u_int8_t ip6r_type;	/* routing type */
+	u_int8_t ip6r_segleft;	/* segments left */
 	/* followed by routing type specific data */
 } __packed;
 
@@ -273,10 +271,6 @@ struct ip6_frag {
  * "len") is located in single mbuf, on contiguous memory region.
  * The pointer to the region will be returned to pointer variable "val",
  * with type "typ".
- * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the
- * very top of mbuf.  GET0 is likely to make memory copy than GET.
- *
- * XXX we're now testing this, needs m_pulldown()
  */
 #define IP6_EXTHDR_GET(val, typ, m, off, len) \
 do {	\
@@ -296,24 +290,6 @@ do {	\
 		}			\
 	}\
 } while (/*CONSTCOND*/ 0)
-
-#define IP6_EXTHDR_GET0(val, typ, m, off, len) \
-do {	\
-	struct mbuf *_t;		\
-	if ((off) == 0 && (m)->m_len >= len)\
-		(val) = (typ)mtod((m), void *);			\
-	else {\
-		_t = m_pulldown((m), (off), (len), NULL);		\
-		if (_t) {		\
-			if (_t->m_len < (len))\
-panic("m_pulldown malfunction");	\
-			(val) = (typ)mtod(_t, void *);			\
-		} else {		\
-			(val) = (typ)NULL;\
-			(m) = NULL;	\
-		}			\
-	}\
-} while (/*CONSTCOND*/ 0)
 #endif /*_KERNEL*/
 
 #endif /* !_NETINET_IP6_H_ */



CVS commit: src/sys/netinet

2018-05-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 18 18:28:40 UTC 2018

Modified Files:
src/sys/netinet: ip6.h

Log Message:
Remove IP6_EXTHDR_GET0, remove pointless XXXs, and style.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/netinet/ip6.h

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



CVS commit: src/usr.sbin/sysinst

2018-05-18 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri May 18 12:23:23 UTC 2018

Modified Files:
src/usr.sbin/sysinst: bsddisklabel.c defs.h menus.mi net.c partman.c
util.c
src/usr.sbin/sysinst/arch/alpha: md.c
src/usr.sbin/sysinst/arch/emips: md.c
src/usr.sbin/sysinst/arch/hp300: md.c
src/usr.sbin/sysinst/arch/hppa: md.c
src/usr.sbin/sysinst/arch/i386: md.c
src/usr.sbin/sysinst/arch/landisk: md.c
src/usr.sbin/sysinst/arch/mipsco: md.c
src/usr.sbin/sysinst/arch/mvme68k: md.c
src/usr.sbin/sysinst/arch/pmax: md.c
src/usr.sbin/sysinst/arch/x68k: md.c

Log Message:
deconst -> __UNCONST, the former involves UB with NULL arithmetic.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/bsddisklabel.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/sysinst/menus.mi
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/sysinst/net.c
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/sysinst/partman.c
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/sysinst/util.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/arch/alpha/md.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sysinst/arch/emips/md.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sysinst/arch/hp300/md.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/arch/hppa/md.c
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/sysinst/arch/i386/md.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sysinst/arch/landisk/md.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/arch/mipsco/md.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sysinst/arch/mvme68k/md.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/arch/pmax/md.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sysinst/arch/x68k/md.c

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



CVS commit: src/usr.sbin/sysinst

2018-05-18 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri May 18 12:23:23 UTC 2018

Modified Files:
src/usr.sbin/sysinst: bsddisklabel.c defs.h menus.mi net.c partman.c
util.c
src/usr.sbin/sysinst/arch/alpha: md.c
src/usr.sbin/sysinst/arch/emips: md.c
src/usr.sbin/sysinst/arch/hp300: md.c
src/usr.sbin/sysinst/arch/hppa: md.c
src/usr.sbin/sysinst/arch/i386: md.c
src/usr.sbin/sysinst/arch/landisk: md.c
src/usr.sbin/sysinst/arch/mipsco: md.c
src/usr.sbin/sysinst/arch/mvme68k: md.c
src/usr.sbin/sysinst/arch/pmax: md.c
src/usr.sbin/sysinst/arch/x68k: md.c

Log Message:
deconst -> __UNCONST, the former involves UB with NULL arithmetic.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/bsddisklabel.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/sysinst/menus.mi
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/sysinst/net.c
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/sysinst/partman.c
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/sysinst/util.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/arch/alpha/md.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sysinst/arch/emips/md.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sysinst/arch/hp300/md.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/arch/hppa/md.c
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/sysinst/arch/i386/md.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sysinst/arch/landisk/md.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/arch/mipsco/md.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sysinst/arch/mvme68k/md.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/arch/pmax/md.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sysinst/arch/x68k/md.c

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

Modified files:

Index: src/usr.sbin/sysinst/bsddisklabel.c
diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.2 src/usr.sbin/sysinst/bsddisklabel.c:1.3
--- src/usr.sbin/sysinst/bsddisklabel.c:1.2	Sun Aug  3 16:09:38 2014
+++ src/usr.sbin/sysinst/bsddisklabel.c	Fri May 18 12:23:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bsddisklabel.c,v 1.2 2014/08/03 16:09:38 martin Exp $	*/
+/*	$NetBSD: bsddisklabel.c,v 1.3 2018/05/18 12:23:22 joerg Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -800,7 +800,7 @@ check_partitions(void)
 	} else
 		rv = -1;
 	if (rv != 0) {
-		process_menu(MENU_ok, deconst(MSG_No_Bootcode));
+		process_menu(MENU_ok, __UNCONST(MSG_No_Bootcode));
 		return 0;
 	}
 #endif
@@ -808,7 +808,7 @@ check_partitions(void)
 	fstype = pm->bsdlabel[pm->rootpart].pi_fstype;
 	if (fstype == FS_BSDFFS &&
 	(pm->bsdlabel[pm->rootpart].pi_flags & PIF_FFSv2) != 0) {
-		process_menu(MENU_ok, deconst(MSG_cannot_ufs2_root));
+		process_menu(MENU_ok, __UNCONST(MSG_cannot_ufs2_root));
 		return 0;
 	}
 #endif

Index: src/usr.sbin/sysinst/defs.h
diff -u src/usr.sbin/sysinst/defs.h:1.9 src/usr.sbin/sysinst/defs.h:1.10
--- src/usr.sbin/sysinst/defs.h:1.9	Mon May 11 13:07:57 2015
+++ src/usr.sbin/sysinst/defs.h	Fri May 18 12:23:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.9 2015/05/11 13:07:57 martin Exp $	*/
+/*	$NetBSD: defs.h,v 1.10 2018/05/18 12:23:22 joerg Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -45,12 +45,6 @@
 
 const char *getfslabelname(uint8_t);
 
-static inline void *
-deconst(const void *p)
-{
-	return (char *)0 + ((const char *)p - (const char *)0);
-}
-
 #include "msg_defs.h"
 #include "menu_defs.h"
 

Index: src/usr.sbin/sysinst/menus.mi
diff -u src/usr.sbin/sysinst/menus.mi:1.11 src/usr.sbin/sysinst/menus.mi:1.12
--- src/usr.sbin/sysinst/menus.mi:1.11	Sun Dec 11 00:56:34 2016
+++ src/usr.sbin/sysinst/menus.mi	Fri May 18 12:23:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: menus.mi,v 1.11 2016/12/11 00:56:34 alnsn Exp $	*/
+/*	$NetBSD: menus.mi,v 1.12 2018/05/18 12:23:22 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -664,7 +664,7 @@ menu pmpartentry, x=50, y=5, exit, defau
 };
 	option MSG_fmtasraid,	exit, action {
 	if (pm->gpt || pm->isspecial) {
-		process_menu(MENU_ok, deconst(MSG_notsupported));
+		process_menu(MENU_ok, __UNCONST(MSG_notsupported));
 		return -1;
 	}
 	pm->unsaved = 1;
@@ -673,7 +673,7 @@ menu pmpartentry, x=50, y=5, exit, defau
 };
 	option MSG_fmtaslvm,	exit, action {
 	if (pm->gpt || pm->isspecial) {
-		process_menu(MENU_ok, deconst(MSG_notsupported));
+		process_menu(MENU_ok, __UNCONST(MSG_notsupported));
 		return -1;
 	}
 	pm->unsaved = 1;
@@ -683,7 +683,7 @@ menu pmpartentry, x=50, y=5, exit, defau
 };
 	option MSG_encrypt,		exit, action {
 	if (pm->gpt || pm->isspecial) {
-		process_menu(MENU_ok, deconst(MSG_notsupported));
+		process_menu(MENU_ok, __UNCONST(MSG_notsupported));
 		return -1;
 	}
 	pm->unsaved = 1;

Index: 

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

2018-05-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May 18 10:09:02 UTC 2018

Modified Files:
src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixgbe.h ixv.c

Log Message:
 Revert new watchdog timer commits. The new watchdog timer made stability
worse than before. It seems unknown problems exists.

http://mail-index.netbsd.org/source-changes/2018/05/08/msg095020.html
http://mail-index.netbsd.org/source-changes/2018/05/16/msg095240.html


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.152 -r1.153 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/pci/ixgbe/ixv.c

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

Modified files:

Index: src/sys/dev/pci/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.44 src/sys/dev/pci/ixgbe/ix_txrx.c:1.45
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.44	Wed May 16 08:08:24 2018
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Fri May 18 10:09:02 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.44 2018/05/16 08:08:24 msaitoh Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.45 2018/05/18 10:09:02 msaitoh Exp $ */
 
 /**
 
@@ -130,10 +130,9 @@ static void	ixgbe_setup_hw_rsc(struct rx
 int
 ixgbe_legacy_start_locked(struct ifnet *ifp, struct tx_ring *txr)
 {
+	int rc;
 	struct mbuf*m_head;
 	struct adapter *adapter = txr->adapter;
-	int enqueued = 0;
-	int rc;
 
 	IXGBE_TX_LOCK_ASSERT(txr);
 
@@ -159,7 +158,6 @@ ixgbe_legacy_start_locked(struct ifnet *
 		if ((rc = ixgbe_xmit(txr, m_head)) == EAGAIN) {
 			break;
 		}
-		enqueued++;
 		IFQ_DEQUEUE(>if_snd, m_head);
 		if (rc != 0) {
 			m_freem(m_head);
@@ -170,11 +168,6 @@ ixgbe_legacy_start_locked(struct ifnet *
 		bpf_mtap(ifp, m_head);
 	}
 
-	if (enqueued) {
-		txr->lastsent = time_uptime;
-		txr->sending = true;
-	}
-
 	return IXGBE_SUCCESS;
 } /* ixgbe_legacy_start_locked */
 
@@ -323,11 +316,6 @@ ixgbe_mq_start_locked(struct ifnet *ifp,
 			break;
 	}
 
-	if (enqueued) {
-		txr->lastsent = time_uptime;
-		txr->sending = true;
-	}
-
 	if (txr->tx_avail < IXGBE_TX_CLEANUP_THRESHOLD(txr->adapter))
 		ixgbe_txeof(txr);
 
@@ -552,6 +540,10 @@ retry:
 	if (m_head->m_flags & M_MCAST)
 		ifp->if_omcasts++;
 
+	/* Mark queue as having work */
+	if (txr->busy == 0)
+		txr->busy = 1;
+
 	return (0);
 } /* ixgbe_xmit */
 
@@ -677,7 +669,6 @@ ixgbe_setup_transmit_ring(struct tx_ring
 	/* Free any existing tx buffers. */
 	txbuf = txr->tx_buffers;
 	for (int i = 0; i < txr->num_desc; i++, txbuf++) {
-		txr->sending = false;
 		if (txbuf->m_head != NULL) {
 			bus_dmamap_sync(txr->txtag->dt_dmat, txbuf->map,
 			0, txbuf->m_head->m_pkthdr.len,
@@ -1138,7 +1129,7 @@ ixgbe_txeof(struct tx_ring *txr)
 #endif /* DEV_NETMAP */
 
 	if (txr->tx_avail == txr->num_desc) {
-		txr->sending = false;
+		txr->busy = 0;
 		return false;
 	}
 
@@ -1220,8 +1211,25 @@ ixgbe_txeof(struct tx_ring *txr)
 	work += txr->num_desc;
 	txr->next_to_clean = work;
 
+	/*
+	 * Queue Hang detection, we know there's
+	 * work outstanding or the first return
+	 * would have been taken, so increment busy
+	 * if nothing managed to get cleaned, then
+	 * in local_timer it will be checked and
+	 * marked as HUNG if it exceeds a MAX attempt.
+	 */
+	if ((processed == 0) && (txr->busy != IXGBE_QUEUE_HUNG))
+		++txr->busy;
+	/*
+	 * If anything gets cleaned we reset state to 1,
+	 * note this will turn off HUNG if its set.
+	 */
+	if (processed)
+		txr->busy = 1;
+
 	if (txr->tx_avail == txr->num_desc)
-		txr->sending = false;
+		txr->busy = 0;
 
 	return ((limit > 0) ? false : true);
 } /* ixgbe_txeof */

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.152 src/sys/dev/pci/ixgbe/ixgbe.c:1.153
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.152	Tue May 15 09:30:56 2018
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Fri May 18 10:09:02 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.152 2018/05/15 09:30:56 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.153 2018/05/18 10:09:02 msaitoh Exp $ */
 
 /**
 
@@ -184,8 +184,6 @@ static void	ixgbe_free_pciintr_resources
 static void	ixgbe_free_pci_resources(struct adapter *);
 static void	ixgbe_local_timer(void *);
 static void	ixgbe_local_timer1(void *);
-static void	ixgbe_watchdog(struct ifnet *);
-static bool	ixgbe_watchdog_txq(struct ifnet *, struct tx_ring *, bool *);
 static int	ixgbe_setup_interface(device_t, struct adapter *);
 static void	ixgbe_config_gpie(struct adapter *);
 static void	ixgbe_config_dmac(struct adapter *);
@@ -4293,8 +4291,11 @@ static void
 ixgbe_local_timer1(void *arg)
 {
 	struct adapter	*adapter = arg;
+	device_t	dev = adapter->dev;
 	struct ix_queue *que = adapter->queues;
+	u64		queues = 0;
 	u64		v0, v1, v2, v3, v4, v5, v6, v7;
+	int		hung = 0;
 	int		i;
 
 	

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

2018-05-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May 18 10:09:02 UTC 2018

Modified Files:
src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixgbe.h ixv.c

Log Message:
 Revert new watchdog timer commits. The new watchdog timer made stability
worse than before. It seems unknown problems exists.

http://mail-index.netbsd.org/source-changes/2018/05/08/msg095020.html
http://mail-index.netbsd.org/source-changes/2018/05/16/msg095240.html


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.152 -r1.153 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/pci/ixgbe/ixv.c

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



CVS commit: src

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri May 18 06:39:59 UTC 2018

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/lib/libc/sys: Makefile
Added Files:
src/tests/lib/libc/sys: t_fork.c t_vfork.c

Log Message:
Add new ATF tests: t_fork and t_vfork

Test behavior of raise(signal) in either fork(2)ed or vfork(2)ed child.

Tests:
 - raise1 SIGKILL
 - raise2 SIGSTOP
 - raise3 SIGTSTP
 - raise4 SIGTTIN
 - raise5 SIGTTOU
 - raise6 SIGABRT
 - raise7 SIGHUP
 - raise8 SIGCONT

t_vfork:raise2 fails ignoring non-maskable SIGSTOP.

The remaining ones pass.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.248 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.782 -r1.783 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.50 -r1.51 src/tests/lib/libc/sys/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_fork.c \
src/tests/lib/libc/sys/t_vfork.c

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/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.247 src/distrib/sets/lists/debug/mi:1.248
--- src/distrib/sets/lists/debug/mi:1.247	Fri May  4 12:44:40 2018
+++ src/distrib/sets/lists/debug/mi	Fri May 18 06:39:58 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.247 2018/05/04 12:44:40 sevan Exp $
+# $NetBSD: mi,v 1.248 2018/05/18 06:39:58 kamil Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -2073,6 +2073,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_connect.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_context.debug		tests-obsolete		obsolete,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_dup.debug			tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/sys/t_fork.debug			tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_fsync.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_getcontext.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_getgroups.debug		tests-lib-debug		debug,atf,compattestfile
@@ -2133,6 +2134,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_ucontext.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_umask.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_unlink.debug		tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/sys/t_vfork.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_wait.debug			tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_wait_noproc.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_wait_noproc_wnohang.debug	tests-lib-debug		debug,atf,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.782 src/distrib/sets/lists/tests/mi:1.783
--- src/distrib/sets/lists/tests/mi:1.782	Wed May  2 18:46:05 2018
+++ src/distrib/sets/lists/tests/mi	Fri May 18 06:39:59 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.782 2018/05/02 18:46:05 kamil Exp $
+# $NetBSD: mi,v 1.783 2018/05/18 06:39:59 kamil Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2757,6 +2757,7 @@
 ./usr/tests/lib/libc/sys/t_connect		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_context		tests-obsolete		obsolete
 ./usr/tests/lib/libc/sys/t_dup			tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/sys/t_fork			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_fsync		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_getcontext		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_getgroups		tests-lib-tests		compattestfile,atf
@@ -2817,6 +2818,7 @@
 ./usr/tests/lib/libc/sys/t_ucontext		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_umask		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_unlink		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/sys/t_vfork		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_wait			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_wait_noproc		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_wait_noproc_wnohang	tests-lib-tests		compattestfile,atf

Index: src/tests/lib/libc/sys/Makefile
diff -u src/tests/lib/libc/sys/Makefile:1.50 src/tests/lib/libc/sys/Makefile:1.51
--- src/tests/lib/libc/sys/Makefile:1.50	Sun Feb 25 14:27:07 2018
+++ src/tests/lib/libc/sys/Makefile	Fri May 18 06:39:58 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.50 2018/02/25 14:27:07 kamil Exp $
+# $NetBSD: 

CVS commit: src

2018-05-18 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri May 18 06:39:59 UTC 2018

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/lib/libc/sys: Makefile
Added Files:
src/tests/lib/libc/sys: t_fork.c t_vfork.c

Log Message:
Add new ATF tests: t_fork and t_vfork

Test behavior of raise(signal) in either fork(2)ed or vfork(2)ed child.

Tests:
 - raise1 SIGKILL
 - raise2 SIGSTOP
 - raise3 SIGTSTP
 - raise4 SIGTTIN
 - raise5 SIGTTOU
 - raise6 SIGABRT
 - raise7 SIGHUP
 - raise8 SIGCONT

t_vfork:raise2 fails ignoring non-maskable SIGSTOP.

The remaining ones pass.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.248 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.782 -r1.783 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.50 -r1.51 src/tests/lib/libc/sys/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_fork.c \
src/tests/lib/libc/sys/t_vfork.c

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