CVS commit: src

2019-05-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu May  2 02:51:01 UTC 2019

Modified Files:
src: build.sh

Log Message:
on netbsd when defaulting to the native system, also derived MACHINE_ARCH
from the uname -p value already fetched.

this means eg, build.sh on evbarm will build the native platform rather
than "earm" (armv5) -- which was the default even on arm64 hosts.


To generate a diff of this commit:
cvs rdiff -u -r1.331 -r1.332 src/build.sh

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

Modified files:

Index: src/build.sh
diff -u src/build.sh:1.331 src/build.sh:1.332
--- src/build.sh:1.331	Thu Apr 25 05:12:49 2019
+++ src/build.sh	Thu May  2 02:51:01 2019
@@ -1,5 +1,5 @@
 #! /usr/bin/env sh
-#	$NetBSD: build.sh,v 1.331 2019/04/25 05:12:49 pgoyette Exp $
+#	$NetBSD: build.sh,v 1.332 2019/05/02 02:51:01 mrg Exp $
 #
 # Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1416,6 +1416,7 @@ parseoptions()
 		[ "${uname_s}" = "NetBSD" ] ||
 		bomb "MACHINE must be set, or -m must be used, for cross builds."
 		MACHINE=${uname_m}
+		MACHINE_ARCH=${uname_p}
 	fi
 	if $opt_m && ! $opt_a; then
 		# Settings implied by the command line -m option
@@ -1936,7 +1937,7 @@ createmakewrapper()
 	eval cat <

CVS commit: src

2019-05-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu May  2 02:51:01 UTC 2019

Modified Files:
src: build.sh

Log Message:
on netbsd when defaulting to the native system, also derived MACHINE_ARCH
from the uname -p value already fetched.

this means eg, build.sh on evbarm will build the native platform rather
than "earm" (armv5) -- which was the default even on arm64 hosts.


To generate a diff of this commit:
cvs rdiff -u -r1.331 -r1.332 src/build.sh

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



Re: CVS commit: src/sys/kern

2019-05-01 Thread Kamil Rytarowski
On 02.05.2019 02:48, matthew green wrote:
> "Kamil Rytarowski" writes:
>> Module Name: src
>> Committed By:kamil
>> Date:Wed May  1 17:02:40 UTC 2019
>>
>> Modified Files:
>>  src/sys/kern: sys_ptrace_common.c
>>
>> Log Message:
>> Disallow resuming program with PC=0x0 in ptrace(2)
>>
>> If the address parameter is 0, report error.
>> It's a popular mistake to set Program Counter to 0x0.
>> In certain kernels this is allowable parameter and causes
>> portability issue.
>>
>> Disallow explicitly zeroed PC, instead of triggering
>> a harder to debug crash later.
> 
> VA 0 can be valid executable code on some platforms.
> 
> 
> .mrg.
> 

Is it used as executable for userspace programs for any current port and
any reasonable one?

We forbid NULL pointer dereference on modern ports. It was certainly
used by PDP-11 as there was a special zeroed mask in 0x0 and
dereferencing NULL pointer was returning zero.

There is a special case of PC=(void *)1 to resume in the previous
position and 1 is not much different special case to 0x0.

Setting PC to 0x0 generates harder to debug crashes.



signature.asc
Description: OpenPGP digital signature


re: CVS commit: src/sys/kern

2019-05-01 Thread matthew green
"Kamil Rytarowski" writes:
> Module Name:  src
> Committed By: kamil
> Date: Wed May  1 17:02:40 UTC 2019
> 
> Modified Files:
>   src/sys/kern: sys_ptrace_common.c
> 
> Log Message:
> Disallow resuming program with PC=0x0 in ptrace(2)
> 
> If the address parameter is 0, report error.
> It's a popular mistake to set Program Counter to 0x0.
> In certain kernels this is allowable parameter and causes
> portability issue.
> 
> Disallow explicitly zeroed PC, instead of triggering
> a harder to debug crash later.

VA 0 can be valid executable code on some platforms.


.mrg.


re: CVS commit: [isaki-audio2] src/sys/dev/usb

2019-05-01 Thread matthew green
"Tetsuya Isaki" writes:
> Module Name:  src
> Committed By: isaki
> Date: Wed May  1 13:09:34 UTC 2019
> 
> Modified Files:
>   src/sys/dev/usb [isaki-audio2]: uaudio.c
> 
> Log Message:
> Don't release sc_lock and sc_intr_lock in trigger_{input,output}.
> In the past, sc_lock was IPL_SCHED and (probably) it had conflicted
> with usb subroutines.  But at some point, sc_lock has changed to use
> IPL_SOFTUSB so such problems should been gone.

sc_lock was ever IPL_SCHED.  only sc_intr_lock has been
that in uaudio.

what are you trying to avoid here?  the problem this
solved was not always a problem, but eg:

- drop the audio thread lock when calling into usb when it may sleep,
  avoiding a deadlock between audiowrite and audioioctl.  this fixes
  mixerctl -a vs. playing hanging the system
  XXX probably need to check this in a bunch more places.

is the commit related to that change.  can you confirm
that you can be playing and run mixerctl -a at the same
time with your change in place?

thanks.


.mrg.


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

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May  2 00:34:06 UTC 2019

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

Log Message:
Rename and partially enable trace_thread ATF ptrace(2) tests

Rename trace_thrad[1234] to more meaningful names:

 - trace_thread_nolwpevents
 - trace_thread_lwpexit
 - trace_thread_lwpcreate
 - trace_thread_lwpcreate_and_exit

In my local tests LWP CREATE events work as expected.
LWP EXIT ones are still racy and keep them disabled racy.

PR kern/51995


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 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.118 src/tests/lib/libc/sys/t_ptrace_wait.c:1.119
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.118	Wed May  1 23:44:16 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Thu May  2 00:34:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.118 2019/05/01 23:44:16 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.119 2019/05/02 00:34:06 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.118 2019/05/01 23:44:16 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.119 2019/05/02 00:34:06 kamil Exp $");
 
 #include 
 #include 
@@ -5359,7 +5359,8 @@ trace_threads(bool trace_create, bool tr
 	/* Track created and exited threads */
 	bool traced_lwps[__arraycount(t)];
 
-	atf_tc_skip("PR kern/51995");
+	if (trace_exit)
+		atf_tc_skip("PR kern/51995");
 
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
@@ -5532,10 +5533,10 @@ ATF_TC_BODY(test, tc)			\
 trace_threads(trace_create, trace_exit);			\
 }
 
-TRACE_THREADS(trace_thread1, false, false)
-TRACE_THREADS(trace_thread2, false, true)
-TRACE_THREADS(trace_thread3, true, false)
-TRACE_THREADS(trace_thread4, true, true)
+TRACE_THREADS(trace_thread_nolwpevents, false, false)
+TRACE_THREADS(trace_thread_lwpexit, false, true)
+TRACE_THREADS(trace_thread_lwpcreate, true, false)
+TRACE_THREADS(trace_thread_lwpcreate_and_exit, true, true)
 
 /// 
 
@@ -7772,10 +7773,10 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, traceme_signalmasked_exec);
 	ATF_TP_ADD_TC(tp, traceme_signalignored_exec);
 
-	ATF_TP_ADD_TC(tp, trace_thread1);
-	ATF_TP_ADD_TC(tp, trace_thread2);
-	ATF_TP_ADD_TC(tp, trace_thread3);
-	ATF_TP_ADD_TC(tp, trace_thread4);
+	ATF_TP_ADD_TC(tp, trace_thread_nolwpevents);
+	ATF_TP_ADD_TC(tp, trace_thread_lwpexit);
+	ATF_TP_ADD_TC(tp, trace_thread_lwpcreate);
+	ATF_TP_ADD_TC(tp, trace_thread_lwpcreate_and_exit);
 
 	ATF_TP_ADD_TC(tp, signal_mask_unrelated);
 



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

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May  2 00:34:06 UTC 2019

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

Log Message:
Rename and partially enable trace_thread ATF ptrace(2) tests

Rename trace_thrad[1234] to more meaningful names:

 - trace_thread_nolwpevents
 - trace_thread_lwpexit
 - trace_thread_lwpcreate
 - trace_thread_lwpcreate_and_exit

In my local tests LWP CREATE events work as expected.
LWP EXIT ones are still racy and keep them disabled racy.

PR kern/51995


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 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/sys/kern

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May  2 00:23:01 UTC 2019

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

Log Message:
Allow cancelled byte transfer in ptrace(2) again

Current GDB depends on it on NetBSD (which is probably a GDB support bug).

In future GDB will be examined for this and this code revisited.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/kern/sys_ptrace_common.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/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.51 src/sys/kern/sys_ptrace_common.c:1.52
--- src/sys/kern/sys_ptrace_common.c:1.51	Wed May  1 17:02:40 2019
+++ src/sys/kern/sys_ptrace_common.c	Thu May  2 00:23:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_ptrace_common.c,v 1.51 2019/05/01 17:02:40 kamil Exp $	*/
+/*	$NetBSD: sys_ptrace_common.c,v 1.52 2019/05/02 00:23:01 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.51 2019/05/01 17:02:40 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.52 2019/05/02 00:23:01 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -1106,10 +1106,12 @@ do_ptrace(struct ptrace_methods *ptm, st
 		piod.piod_op = write ? PIOD_WRITE_D : PIOD_READ_D;
 		if ((error = ptrace_doio(l, t, lt, , addr, true)) != 0)
 			break;
+#if 0 // XXX: GDB depends on it
 		if (piod.piod_len < sizeof(tmp)) {
 			error = EIO;
 			break;
 		}
+#endif
 		if (!write)
 			*retval = tmp;
 		break;
@@ -1123,10 +1125,12 @@ do_ptrace(struct ptrace_methods *ptm, st
 		}
 		if ((error = ptrace_doio(l, t, lt, , addr, false)) != 0)
 			break;
+#if 0 // XXX: GDB depends on it
 		if (piod.piod_len < 1) {
 			error = EIO;
 			break;
 		}
+#endif
 		error = ptm->ptm_copyout_piod(, addr, data);
 		break;
 



CVS commit: src/sys/kern

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May  2 00:23:01 UTC 2019

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

Log Message:
Allow cancelled byte transfer in ptrace(2) again

Current GDB depends on it on NetBSD (which is probably a GDB support bug).

In future GDB will be examined for this and this code revisited.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/kern/sys_ptrace_common.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

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 23:44:16 UTC 2019

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

Log Message:
ATF ptrace(2) tests suspend1 and resume1 now pass

Verified on bare metal and in qemu.

PR kern/51995


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 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.117 src/tests/lib/libc/sys/t_ptrace_wait.c:1.118
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.117	Wed May  1 21:59:32 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Wed May  1 23:44:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.117 2019/05/01 21:59:32 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.118 2019/05/01 23:44:16 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.117 2019/05/01 21:59:32 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.118 2019/05/01 23:44:16 kamil Exp $");
 
 #include 
 #include 
@@ -6228,12 +6228,6 @@ ATF_TC_BODY(suspend1, tc)
 	struct ptrace_siginfo psi;
 	volatile int go = 0;
 
-	// Feature pending for refactoring
-	atf_tc_expect_fail("PR kern/51995");
-
-	// Hangs with qemu
-	ATF_REQUIRE(0 && "In order to get reliable failure, abort");
-
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -6355,12 +6349,6 @@ ATF_TC_BODY(suspend2, tc)
 #endif
 	struct ptrace_siginfo psi;
 
-	// Feature pending for refactoring
-	atf_tc_expect_fail("PR kern/51995");
-
-	// Hangs with qemu
-	ATF_REQUIRE(0 && "In order to get reliable failure, abort");
-
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -6412,7 +6400,6 @@ ATF_TC_BODY(suspend2, tc)
 ATF_TC(resume1);
 ATF_TC_HEAD(resume1, tc)
 {
-	atf_tc_set_md_var(tc, "timeout", "5");
 	atf_tc_set_md_var(tc, "descr",
 	"Verify that a thread can be suspended by a debugger and later "
 	"resumed by the debugger");
@@ -6435,12 +6422,6 @@ ATF_TC_BODY(resume1, tc)
 	struct ptrace_lwpinfo pl;
 	struct ptrace_siginfo psi;
 
-	// Feature pending for refactoring
-	atf_tc_expect_fail("PR kern/51995");
-
-	// Hangs with qemu
-	ATF_REQUIRE(0 && "In order to get reliable failure, abort");
-
 	SYSCALL_REQUIRE(msg_open() == 0);
 
 	DPRINTF("Before forking process PID=%d\n", getpid());
@@ -6543,9 +6524,6 @@ ATF_TC_BODY(resume1, tc)
 	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
 
 	msg_close();
-
-	DPRINTF("XXX: Test worked this time but for consistency timeout it\n");
-	sleep(10);
 }
 
 ATF_TC(syscall1);



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

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 23:44:16 UTC 2019

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

Log Message:
ATF ptrace(2) tests suspend1 and resume1 now pass

Verified on bare metal and in qemu.

PR kern/51995


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 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/sys/kern

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 22:55:55 UTC 2019

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

Log Message:
Call MD code in mi_startlwp() before MI check for debugger

This allows to get initialized mcontext.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/kern/sys_lwp.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/sys_lwp.c
diff -u src/sys/kern/sys_lwp.c:1.64 src/sys/kern/sys_lwp.c:1.65
--- src/sys/kern/sys_lwp.c:1.64	Wed May  1 21:57:34 2019
+++ src/sys/kern/sys_lwp.c	Wed May  1 22:55:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_lwp.c,v 1.64 2019/05/01 21:57:34 kamil Exp $	*/
+/*	$NetBSD: sys_lwp.c,v 1.65 2019/05/01 22:55:55 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.64 2019/05/01 21:57:34 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.65 2019/05/01 22:55:55 kamil Exp $");
 
 #include 
 #include 
@@ -75,6 +75,8 @@ mi_startlwp(void *arg)
 	struct lwp *l = curlwp;
 	struct proc *p = l->l_proc;
 
+	(p->p_emul->e_startlwp)(arg);
+
 	/* If the process is traced, report lwp creation to a debugger */
 	if ((p->p_slflag & (PSL_TRACED|PSL_TRACELWP_CREATE|PSL_SYSCALL)) ==
 	(PSL_TRACED|PSL_TRACELWP_CREATE)) {
@@ -83,7 +85,7 @@ mi_startlwp(void *arg)
 		if ((p->p_slflag & (PSL_TRACED|PSL_TRACELWP_CREATE|PSL_SYSCALL)) !=
 		(PSL_TRACED|PSL_TRACELWP_CREATE)) {
 			mutex_exit(proc_lock);
-			goto my_tracer_is_gone;
+			return;
 		}
 
 		mutex_enter(p->p_lock);
@@ -92,9 +94,6 @@ mi_startlwp(void *arg)
 		// XXX ktrpoint(KTR_PSIG)
 		mutex_exit(p->p_lock);
 	}
-
-my_tracer_is_gone:
-	(p->p_emul->e_startlwp)(arg);
 }
 
 int



CVS commit: src/sys/kern

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 22:55:55 UTC 2019

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

Log Message:
Call MD code in mi_startlwp() before MI check for debugger

This allows to get initialized mcontext.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/kern/sys_lwp.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

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 21:59:32 UTC 2019

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

Log Message:
ATF ptrace(2) tests signal9 and signal10 now pass

PR kern/51918


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 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.116 src/tests/lib/libc/sys/t_ptrace_wait.c:1.117
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.116	Wed May  1 18:20:23 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Wed May  1 21:59:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.116 2019/05/01 18:20:23 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.117 2019/05/01 21:59:32 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.116 2019/05/01 18:20:23 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.117 2019/05/01 21:59:32 kamil Exp $");
 
 #include 
 #include 
@@ -6017,8 +6017,6 @@ ATF_TC_BODY(signal9, tc)
 	static const size_t ssize = 16*1024;
 	void *stack;
 
-	atf_tc_expect_fail("PR kern/51918");
-
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -6121,8 +6119,6 @@ ATF_TC_BODY(signal10, tc)
 	static const size_t ssize = 16*1024;
 	void *stack;
 
-	atf_tc_expect_fail("PR kern/51918");
-
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
 	if (child == 0) {



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

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 21:59:32 UTC 2019

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

Log Message:
ATF ptrace(2) tests signal9 and signal10 now pass

PR kern/51918


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 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/sys/kern

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 21:57:35 UTC 2019

Modified Files:
src/sys/kern: kern_lwp.c sys_lwp.c

Log Message:
Correct passing debugger related events for LWP create and exit

Add MI toplevel startlwp function.

Switch all userland LWPs to go through lwp_create using a shared
mi_startlwp() function between all MD ABIs.

Add debugger related event handling in mi_startlwp() and continue with
standard p->p_emul->e_startlwp at the end of this routine.

Use eventswitch() to notify the event of LWP exit in lwp_exit().

ATF ptrace(2) tests signal9 and signal10 now pass.


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/sys/kern/kern_lwp.c
cvs rdiff -u -r1.63 -r1.64 src/sys/kern/sys_lwp.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_lwp.c
diff -u src/sys/kern/kern_lwp.c:1.197 src/sys/kern/kern_lwp.c:1.198
--- src/sys/kern/kern_lwp.c:1.197	Fri Apr 19 01:52:55 2019
+++ src/sys/kern/kern_lwp.c	Wed May  1 21:57:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lwp.c,v 1.197 2019/04/19 01:52:55 ozaki-r Exp $	*/
+/*	$NetBSD: kern_lwp.c,v 1.198 2019/05/01 21:57:34 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -211,7 +211,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.197 2019/04/19 01:52:55 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.198 2019/05/01 21:57:34 kamil Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -969,24 +969,6 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_
 	if (p2->p_emul->e_lwp_fork)
 		(*p2->p_emul->e_lwp_fork)(l1, l2);
 
-	/* If the process is traced, report lwp creation to a debugger */
-	if ((p2->p_slflag & (PSL_TRACED|PSL_TRACELWP_CREATE|PSL_SYSCALL)) ==
-	(PSL_TRACED|PSL_TRACELWP_CREATE)) {
-		ksiginfo_t ksi;
-
-		/* Tracing */
-		KASSERT((l2->l_flag & LW_SYSTEM) == 0);
-
-		p2->p_lwp_created = l2->l_lid;
-
-		KSI_INIT_EMPTY();
-		ksi.ksi_signo = SIGTRAP;
-		ksi.ksi_code = TRAP_LWP;
-		mutex_enter(proc_lock);
-		kpsignal(p2, , NULL);
-		mutex_exit(proc_lock);
-	}
-
 	return (0);
 }
 
@@ -1050,24 +1032,6 @@ lwp_exit(struct lwp *l)
 	 */
 	LOCKDEBUG_BARRIER(_lock, 0);
 
-	/* If the process is traced, report lwp termination to a debugger */
-	if ((p->p_slflag & (PSL_TRACED|PSL_TRACELWP_EXIT|PSL_SYSCALL)) ==
-	(PSL_TRACED|PSL_TRACELWP_EXIT)) {
-		ksiginfo_t ksi;
-
-		/* Tracing */
-		KASSERT((l->l_flag & LW_SYSTEM) == 0);
-
-		p->p_lwp_exited = l->l_lid;
-
-		KSI_INIT_EMPTY();
-		ksi.ksi_signo = SIGTRAP;
-		ksi.ksi_code = TRAP_LWP;
-		mutex_enter(proc_lock);
-		kpsignal(p, , NULL);
-		mutex_exit(proc_lock);
-	}
-
 	/*
 	 * If we are the last live LWP in a process, we need to exit the
 	 * entire process.  We do so with an exit status of zero, because
@@ -1108,10 +1072,23 @@ lwp_exit(struct lwp *l)
 	callout_destroy(>l_timeout_ch);
 
 	/*
+	 * If traced, report LWP exit event to the debugger.
+	 *
 	 * Remove the LWP from the global list.
 	 * Free its LID from the PID namespace if needed.
 	 */
 	mutex_enter(proc_lock);
+
+	if ((p->p_slflag & (PSL_TRACED|PSL_TRACELWP_EXIT|PSL_SYSCALL)) ==
+	(PSL_TRACED|PSL_TRACELWP_EXIT)) {
+		mutex_enter(p->p_lock);
+		p->p_lwp_exited = l->l_lid;
+		eventswitch(SIGTRAP, TRAP_LWP);
+		// XXX ktrpoint(KTR_PSIG)
+		mutex_exit(p->p_lock);
+		mutex_enter(proc_lock);
+	}
+
 	LIST_REMOVE(l, l_list);
 	if ((l->l_pflag & LP_PIDLID) != 0 && l->l_lid != p->p_pid) {
 		proc_free_pid(l->l_lid);

Index: src/sys/kern/sys_lwp.c
diff -u src/sys/kern/sys_lwp.c:1.63 src/sys/kern/sys_lwp.c:1.64
--- src/sys/kern/sys_lwp.c:1.63	Tue Jan 30 07:52:23 2018
+++ src/sys/kern/sys_lwp.c	Wed May  1 21:57:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_lwp.c,v 1.63 2018/01/30 07:52:23 ozaki-r Exp $	*/
+/*	$NetBSD: sys_lwp.c,v 1.64 2019/05/01 21:57:34 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.63 2018/01/30 07:52:23 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.64 2019/05/01 21:57:34 kamil Exp $");
 
 #include 
 #include 
@@ -69,6 +69,34 @@ lwp_sys_init(void)
 	sleeptab_init(_park_tab);
 }
 
+static void
+mi_startlwp(void *arg)
+{
+	struct lwp *l = curlwp;
+	struct proc *p = l->l_proc;
+
+	/* If the process is traced, report lwp creation to a debugger */
+	if ((p->p_slflag & (PSL_TRACED|PSL_TRACELWP_CREATE|PSL_SYSCALL)) ==
+	(PSL_TRACED|PSL_TRACELWP_CREATE)) {
+		/* Paranoid check */
+		mutex_enter(proc_lock);
+		if ((p->p_slflag & (PSL_TRACED|PSL_TRACELWP_CREATE|PSL_SYSCALL)) !=
+		(PSL_TRACED|PSL_TRACELWP_CREATE)) {
+			mutex_exit(proc_lock);
+			goto my_tracer_is_gone;
+		}
+
+		mutex_enter(p->p_lock);
+		p->p_lwp_created = l->l_lid;
+		eventswitch(SIGTRAP, TRAP_LWP);
+		// XXX ktrpoint(KTR_PSIG)
+		mutex_exit(p->p_lock);
+	}
+
+my_tracer_is_gone:
+	

CVS commit: src/sys/kern

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 21:57:35 UTC 2019

Modified Files:
src/sys/kern: kern_lwp.c sys_lwp.c

Log Message:
Correct passing debugger related events for LWP create and exit

Add MI toplevel startlwp function.

Switch all userland LWPs to go through lwp_create using a shared
mi_startlwp() function between all MD ABIs.

Add debugger related event handling in mi_startlwp() and continue with
standard p->p_emul->e_startlwp at the end of this routine.

Use eventswitch() to notify the event of LWP exit in lwp_exit().

ATF ptrace(2) tests signal9 and signal10 now pass.


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/sys/kern/kern_lwp.c
cvs rdiff -u -r1.63 -r1.64 src/sys/kern/sys_lwp.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

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 21:52:35 UTC 2019

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

Log Message:
Assert that debugger event is triggered only for userland LWP

All passing ATF ptrace(2) tests still pass.


To generate a diff of this commit:
cvs rdiff -u -r1.354 -r1.355 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.354 src/sys/kern/kern_sig.c:1.355
--- src/sys/kern/kern_sig.c:1.354	Wed May  1 18:01:54 2019
+++ src/sys/kern/kern_sig.c	Wed May  1 21:52:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.354 2019/05/01 18:01:54 kamil Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.355 2019/05/01 21:52:35 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.354 2019/05/01 18:01:54 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.355 2019/05/01 21:52:35 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -1542,6 +1542,7 @@ eventswitch(int signo, int code)
 	KASSERT(mutex_owned(proc_lock));
 	KASSERT(mutex_owned(p->p_lock));
 	KASSERT(l->l_stat == LSONPROC);
+	KASSERT((l->l_flag & LW_SYSTEM) == 0);
 	KASSERT(p->p_nrlwps > 0);
 
 	/*



CVS commit: src/sys/kern

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 21:52:35 UTC 2019

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

Log Message:
Assert that debugger event is triggered only for userland LWP

All passing ATF ptrace(2) tests still pass.


To generate a diff of this commit:
cvs rdiff -u -r1.354 -r1.355 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/tests/lib/libc/sys

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 18:20:23 UTC 2019

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

Log Message:
Add new fork/vfork ATF trests in t_ptrace_wait*

Add new tests:

 - fork_detach_forker
 - vfork_detach_vforker
 - vfork_detach_vforkerdone
 - fork_kill_forker
 - vfork_kill_vforker
 - vfork_kill_vforkerdone

All tests pass with recent kernel changes.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 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

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 18:20:23 UTC 2019

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

Log Message:
Add new fork/vfork ATF trests in t_ptrace_wait*

Add new tests:

 - fork_detach_forker
 - vfork_detach_vforker
 - vfork_detach_vforkerdone
 - fork_kill_forker
 - vfork_kill_vforker
 - vfork_kill_vforkerdone

All tests pass with recent kernel changes.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 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.115 src/tests/lib/libc/sys/t_ptrace_wait.c:1.116
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.115	Tue Apr 30 22:39:31 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Wed May  1 18:20:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.115 2019/04/30 22:39:31 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.116 2019/05/01 18:20:23 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.115 2019/04/30 22:39:31 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.116 2019/05/01 18:20:23 kamil Exp $");
 
 #include 
 #include 
@@ -3199,6 +3199,187 @@ FORK_TEST(vfork8, vfork, true, true, tru
 
 /// 
 
+#if defined(TWAIT_HAVE_PID)
+static void
+fork_detach_forker_body(bool detachfork, bool detachvfork,
+bool detachvforkdone, bool kill_process)
+{
+	const int exitval = 5;
+	const int exitval2 = 15;
+	const int sigval = SIGSTOP;
+	pid_t child, child2 = 0, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
+#endif
+	ptrace_state_t state;
+	const int slen = sizeof(state);
+	ptrace_event_t event;
+	const int elen = sizeof(event);
+
+	pid_t (*fn)(void);
+	int op;
+
+	ATF_REQUIRE((detachfork && !detachvfork && !detachvforkdone) ||
+	(!detachfork && detachvfork && !detachvforkdone) ||
+	(!detachfork && !detachvfork && detachvforkdone));
+
+	if (detachfork)
+		fn = fork;
+	else
+		fn = vfork;
+
+	DPRINTF("Before forking process PID=%d\n", getpid());
+	SYSCALL_REQUIRE((child = fork()) != -1);
+	if (child == 0) {
+		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		DPRINTF("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		FORKEE_ASSERT((child2 = (fn)()) != -1);
+
+		if (child2 == 0)
+			_exit(exitval2);
+
+		FORKEE_REQUIRE_SUCCESS
+		(wpid = TWAIT_GENERIC(child2, , 0), child2);
+
+		forkee_status_exited(status, exitval2);
+
+		DPRINTF("Before exiting of the child process\n");
+		_exit(exitval);
+	}
+	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	DPRINTF("Set EVENT_MASK for the child %d\n", child);
+	event.pe_set_event = PTRACE_FORK | PTRACE_VFORK | PTRACE_VFORK_DONE;
+	SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
+
+	DPRINTF("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	DPRINTF("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	SYSCALL_REQUIRE(
+	ptrace(PT_GET_PROCESS_STATE, child, , slen) != -1);
+	op = (fn == fork) ? PTRACE_FORK : PTRACE_VFORK;
+	ATF_REQUIRE_EQ(state.pe_report_event & op, op);
+
+	child2 = state.pe_other_pid;
+	DPRINTF("Reported ptrace event with forkee %d\n", child2);
+
+	if (detachfork || detachvfork)
+		op = kill_process ? PT_KILL : PT_DETACH;
+	else
+		op = PT_CONTINUE;
+	SYSCALL_REQUIRE(ptrace(op, child, (void *)1, 0) != -1);
+
+	DPRINTF("Before calling %s() for the forkee %d of the child %d\n",
+	TWAIT_FNAME, child2, child);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, , 0), child2);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	SYSCALL_REQUIRE(
+	ptrace(PT_GET_PROCESS_STATE, child2, , slen) != -1);
+	op = (fn == fork) ? PTRACE_FORK : PTRACE_VFORK;
+	ATF_REQUIRE_EQ(state.pe_report_event & op, op);
+	ATF_REQUIRE_EQ(state.pe_other_pid, child);
+
+	DPRINTF("Before resuming the forkee process where it left off "
+	"and without signal to be sent\n");
+ 	SYSCALL_REQUIRE(
+	ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1);
+
+	if (detachvforkdone && fn == vfork) {
+		DPRINTF("Before calling %s() for the child %d\n", TWAIT_FNAME,
+		child);
+		TWAIT_REQUIRE_SUCCESS(
+		wpid = TWAIT_GENERIC(child, , 0), child);
+
+		

CVS commit: src/sys/kern

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 18:01:54 UTC 2019

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

Log Message:
Correct handling of corner cases in fork1(9) code under a debugger

Correct detaching and SIGKILLing forker and vforker in the middle of its
operation.


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/sys/kern/kern_fork.c
cvs rdiff -u -r1.353 -r1.354 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_fork.c
diff -u src/sys/kern/kern_fork.c:1.210 src/sys/kern/kern_fork.c:1.211
--- src/sys/kern/kern_fork.c:1.210	Wed May  1 17:21:55 2019
+++ src/sys/kern/kern_fork.c	Wed May  1 18:01:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_fork.c,v 1.210 2019/05/01 17:21:55 kamil Exp $	*/
+/*	$NetBSD: kern_fork.c,v 1.211 2019/05/01 18:01:54 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.210 2019/05/01 17:21:55 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.211 2019/05/01 18:01:54 kamil Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -203,6 +203,30 @@ sys___clone(struct lwp *l, const struct 
  */
 static struct timeval fork_tfmrate = { 10, 0 };
 
+static inline bool
+tracefork(struct proc *p, int flags)
+{
+
+	return (p->p_slflag & (PSL_TRACEFORK|PSL_TRACED)) ==
+	(PSL_TRACEFORK|PSL_TRACED) && (flags & FORK_PPWAIT) == 0;
+}
+
+static inline bool
+tracevfork(struct proc *p, int flags)
+{
+
+	return (p->p_slflag & (PSL_TRACEVFORK|PSL_TRACED)) ==
+	(PSL_TRACEVFORK|PSL_TRACED) && (flags & FORK_PPWAIT) != 0;
+}
+
+static inline bool
+tracevforkdone(struct proc *p, int flags)
+{
+
+	return (p->p_slflag & (PSL_TRACEVFORK_DONE|PSL_TRACED)) ==
+	(PSL_TRACEVFORK_DONE|PSL_TRACED) && (flags & FORK_PPWAIT);
+}
+
 /*
  * General fork call.  Note that another LWP in the process may call exec()
  * or exit() while we are forking.  It's safe to continue here, because
@@ -219,7 +243,7 @@ fork1(struct lwp *l1, int flags, int exi
 	int		count;
 	vaddr_t		uaddr;
 	int		tnprocs;
-	int		tracefork, tracevfork, tracevforkdone;
+	bool		trace_fork, trace_vfork;
 	int		error = 0;
 
 	p1 = l1->l_proc;
@@ -477,19 +501,15 @@ fork1(struct lwp *l1, int flags, int exi
 	/*
 	 * Trace fork(2) and vfork(2)-like events on demand in a debugger.
 	 */
-	tracefork = (p1->p_slflag & (PSL_TRACEFORK|PSL_TRACED)) ==
-	(PSL_TRACEFORK|PSL_TRACED) && (flags & FORK_PPWAIT) == 0;
-	tracevfork = (p1->p_slflag & (PSL_TRACEVFORK|PSL_TRACED)) ==
-	(PSL_TRACEVFORK|PSL_TRACED) && (flags & FORK_PPWAIT) != 0;
-	tracevforkdone = (p1->p_slflag & (PSL_TRACEVFORK_DONE|PSL_TRACED)) ==
-	(PSL_TRACEVFORK_DONE|PSL_TRACED) && (flags & FORK_PPWAIT);
-	if (tracefork || tracevfork)
+	trace_fork = tracefork(p1, flags);
+	trace_vfork = tracevfork(p1, flags);
+	if (trace_fork || trace_vfork)
 		proc_changeparent(p2, p1->p_pptr);
-	if (tracefork) {
+	if (trace_fork) {
 		p1->p_fpid = p2->p_pid;
 		p2->p_fpid = p1->p_pid;
 	}
-	if (tracevfork) {
+	if (trace_vfork) {
 		p1->p_vfpid = p2->p_pid;
 		p2->p_vfpid = p1->p_pid;
 	}
@@ -573,7 +593,7 @@ fork1(struct lwp *l1, int flags, int exi
 	/*
 	 * Let the parent know that we are tracing its child.
 	 */
-	if (tracefork || tracevfork) {
+	if (tracefork(p1, flags) || tracevfork(p1, flags)) {
 		mutex_enter(p1->p_lock);
 		eventswitch(SIGTRAP, TRAP_CHLD);
 		// XXX ktrpoint(KTR_PSIG)
@@ -591,7 +611,7 @@ fork1(struct lwp *l1, int flags, int exi
 	/*
 	 * Let the parent know that we are tracing its child.
 	 */
-	if (tracevforkdone) {
+	if (tracevforkdone(p1, flags)) {
 		mutex_enter(p1->p_lock);
 		p1->p_vfpid_done = retval[0];
 		eventswitch(SIGTRAP, TRAP_CHLD);

Index: src/sys/kern/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.353 src/sys/kern/kern_sig.c:1.354
--- src/sys/kern/kern_sig.c:1.353	Wed May  1 17:21:55 2019
+++ src/sys/kern/kern_sig.c	Wed May  1 18:01:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.353 2019/05/01 17:21:55 kamil Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.354 2019/05/01 18:01:54 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.353 2019/05/01 17:21:55 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.354 2019/05/01 18:01:54 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -1544,6 +1544,15 @@ eventswitch(int signo, int code)
 	KASSERT(l->l_stat == LSONPROC);
 	KASSERT(p->p_nrlwps > 0);
 
+	/*
+	 * If there's a pending SIGKILL process it immediately.
+	 */
+	if (p->p_xsig == SIGKILL ||
+	sigismember(>p_sigpend.sp_set, SIGKILL)) {
+		mutex_exit(proc_lock);
+		return;
+	}
+
 	p->p_xsig = signo;
 	p->p_sigctx.ps_faked = true;
 	p->p_sigctx.ps_info._signo = signo;



CVS commit: src/sys/kern

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 18:01:54 UTC 2019

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

Log Message:
Correct handling of corner cases in fork1(9) code under a debugger

Correct detaching and SIGKILLing forker and vforker in the middle of its
operation.


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/sys/kern/kern_fork.c
cvs rdiff -u -r1.353 -r1.354 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

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 17:21:55 UTC 2019

Modified Files:
src/sys/kern: kern_exec.c kern_fork.c kern_sig.c
src/sys/sys: signalvar.h

Log Message:
Add eventswitch() in signal code

Route all crash and debugger related signal through eventswitch(), that
calls sigswitch() with preprocessed arguments.

This code avoids code duplication and allows to introduce changes that
will affect all callers of sigswitch() in debugger-related events.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.462 -r1.463 src/sys/kern/kern_exec.c
cvs rdiff -u -r1.209 -r1.210 src/sys/kern/kern_fork.c
cvs rdiff -u -r1.352 -r1.353 src/sys/kern/kern_sig.c
cvs rdiff -u -r1.91 -r1.92 src/sys/sys/signalvar.h

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

Modified files:

Index: src/sys/kern/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.462 src/sys/kern/kern_exec.c:1.463
--- src/sys/kern/kern_exec.c:1.462	Sun Nov 11 10:55:58 2018
+++ src/sys/kern/kern_exec.c	Wed May  1 17:21:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.462 2018/11/11 10:55:58 maxv Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.463 2019/05/01 17:21:55 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.462 2018/11/11 10:55:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.463 2019/05/01 17:21:55 kamil Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -1271,11 +1271,7 @@ execve_runproc(struct lwp *l, struct exe
 
 	if ((p->p_slflag & (PSL_TRACED|PSL_SYSCALL)) == PSL_TRACED) {
 		mutex_enter(p->p_lock);
-		p->p_xsig = SIGTRAP;
-		p->p_sigctx.ps_faked = true; // XXX
-		p->p_sigctx.ps_info._signo = p->p_xsig;
-		p->p_sigctx.ps_info._code = TRAP_EXEC;
-		sigswitch(0, SIGTRAP, false);
+		eventswitch(SIGTRAP, TRAP_EXEC);
 		// XXX ktrpoint(KTR_PSIG)
 		mutex_exit(p->p_lock);
 		mutex_enter(proc_lock);

Index: src/sys/kern/kern_fork.c
diff -u src/sys/kern/kern_fork.c:1.209 src/sys/kern/kern_fork.c:1.210
--- src/sys/kern/kern_fork.c:1.209	Sun Apr  7 14:50:41 2019
+++ src/sys/kern/kern_fork.c	Wed May  1 17:21:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_fork.c,v 1.209 2019/04/07 14:50:41 kamil Exp $	*/
+/*	$NetBSD: kern_fork.c,v 1.210 2019/05/01 17:21:55 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.209 2019/04/07 14:50:41 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.210 2019/05/01 17:21:55 kamil Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -575,11 +575,7 @@ fork1(struct lwp *l1, int flags, int exi
 	 */
 	if (tracefork || tracevfork) {
 		mutex_enter(p1->p_lock);
-		p1->p_xsig = SIGTRAP;
-		p1->p_sigctx.ps_faked = true; // XXX
-		p1->p_sigctx.ps_info._signo = p1->p_xsig;
-		p1->p_sigctx.ps_info._code = TRAP_CHLD;
-		sigswitch(0, SIGTRAP, false);
+		eventswitch(SIGTRAP, TRAP_CHLD);
 		// XXX ktrpoint(KTR_PSIG)
 		mutex_exit(p1->p_lock);
 		mutex_enter(proc_lock);
@@ -597,12 +593,8 @@ fork1(struct lwp *l1, int flags, int exi
 	 */
 	if (tracevforkdone) {
 		mutex_enter(p1->p_lock);
-		p1->p_xsig = SIGTRAP;
-		p1->p_sigctx.ps_faked = true; // XXX
-		p1->p_sigctx.ps_info._signo = p1->p_xsig;
-		p1->p_sigctx.ps_info._code = TRAP_CHLD;
 		p1->p_vfpid_done = retval[0];
-		sigswitch(0, SIGTRAP, false);
+		eventswitch(SIGTRAP, TRAP_CHLD);
 		// XXX ktrpoint(KTR_PSIG)
 		mutex_exit(p1->p_lock);
 		// proc_lock unlocked
@@ -627,11 +619,7 @@ child_return(void *arg)
 		}
 
 		mutex_enter(p->p_lock);
-		p->p_xsig = SIGTRAP;
-		p->p_sigctx.ps_faked = true; // XXX
-		p->p_sigctx.ps_info._signo = p->p_xsig;
-		p->p_sigctx.ps_info._code = TRAP_CHLD;
-		sigswitch(0, SIGTRAP, false);
+		eventswitch(SIGTRAP, TRAP_CHLD);
 		// XXX ktrpoint(KTR_PSIG)
 		mutex_exit(p->p_lock);
 	}

Index: src/sys/kern/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.352 src/sys/kern/kern_sig.c:1.353
--- src/sys/kern/kern_sig.c:1.352	Wed Apr  3 08:34:33 2019
+++ src/sys/kern/kern_sig.c	Wed May  1 17:21:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.352 2019/04/03 08:34:33 kamil Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.353 2019/05/01 17:21:55 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.352 2019/04/03 08:34:33 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.353 2019/05/01 17:21:55 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -914,11 +914,7 @@ trapsignal(struct lwp *l, ksiginfo_t *ks
 
 	if (ISSET(p->p_slflag, PSL_TRACED) &&
 	!(p->p_pptr == p->p_opptr && ISSET(p->p_lflag, PL_PPWAIT))) {
-		p->p_xsig = signo;
-		p->p_sigctx.ps_faked = true; // XXX
-		p->p_sigctx.ps_info._signo = signo;
-		p->p_sigctx.ps_info._code = 

CVS commit: src/sys

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 17:21:55 UTC 2019

Modified Files:
src/sys/kern: kern_exec.c kern_fork.c kern_sig.c
src/sys/sys: signalvar.h

Log Message:
Add eventswitch() in signal code

Route all crash and debugger related signal through eventswitch(), that
calls sigswitch() with preprocessed arguments.

This code avoids code duplication and allows to introduce changes that
will affect all callers of sigswitch() in debugger-related events.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.462 -r1.463 src/sys/kern/kern_exec.c
cvs rdiff -u -r1.209 -r1.210 src/sys/kern/kern_fork.c
cvs rdiff -u -r1.352 -r1.353 src/sys/kern/kern_sig.c
cvs rdiff -u -r1.91 -r1.92 src/sys/sys/signalvar.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

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 17:02:40 UTC 2019

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

Log Message:
Disallow resuming program with PC=0x0 in ptrace(2)

If the address parameter is 0, report error.
It's a popular mistake to set Program Counter to 0x0.
In certain kernels this is allowable parameter and causes
portability issue.

Disallow explicitly zeroed PC, instead of triggering
a harder to debug crash later.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/kern/sys_ptrace_common.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/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.50 src/sys/kern/sys_ptrace_common.c:1.51
--- src/sys/kern/sys_ptrace_common.c:1.50	Tue Apr 30 22:32:01 2019
+++ src/sys/kern/sys_ptrace_common.c	Wed May  1 17:02:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_ptrace_common.c,v 1.50 2019/04/30 22:32:01 kamil Exp $	*/
+/*	$NetBSD: sys_ptrace_common.c,v 1.51 2019/05/01 17:02:40 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.50 2019/04/30 22:32:01 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.51 2019/05/01 17:02:40 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -1246,6 +1246,21 @@ do_ptrace(struct ptrace_methods *ptm, st
 			}
 		}
 
+		/*
+		 * If the address parameter is 0, report error.
+		 *
+		 * It's a popular mistake to set Program Counter to 0x0.
+		 * In certain kernels this is allowable parameter and causes
+		 * portability issue.
+		 *
+		 * Disallow explicitly zeroed PC, instead of triggering
+		 * a harder to debug crash later.
+		 */
+		if (addr == 0) {
+			error = EINVAL;
+			break;
+		}
+
 		/* If the address parameter is not (int *)1, set the pc. */
 		if ((int *)addr != (int *)1) {
 			error = process_set_pc(lt, addr);



CVS commit: src/sys/kern

2019-05-01 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May  1 17:02:40 UTC 2019

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

Log Message:
Disallow resuming program with PC=0x0 in ptrace(2)

If the address parameter is 0, report error.
It's a popular mistake to set Program Counter to 0x0.
In certain kernels this is allowable parameter and causes
portability issue.

Disallow explicitly zeroed PC, instead of triggering
a harder to debug crash later.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/kern/sys_ptrace_common.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

2019-05-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May  1 15:17:49 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/i386/i386: cpufunc.S
src/sys/arch/x86/include: cpufunc.h

Log Message:
Start converting the x86 CPU functions to inlined ASM. Matters for NVMM,
where some are invoked millions of times.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/i386/i386/cpufunc.S
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/x86/include/cpufunc.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

2019-05-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May  1 15:17:49 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/i386/i386: cpufunc.S
src/sys/arch/x86/include: cpufunc.h

Log Message:
Start converting the x86 CPU functions to inlined ASM. Matters for NVMM,
where some are invoked millions of times.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/i386/i386/cpufunc.S
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/x86/include/cpufunc.h

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

Modified files:

Index: src/sys/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.37 src/sys/arch/amd64/amd64/cpufunc.S:1.38
--- src/sys/arch/amd64/amd64/cpufunc.S:1.37	Wed May  1 14:29:15 2019
+++ src/sys/arch/amd64/amd64/cpufunc.S	Wed May  1 15:17:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.37 2019/05/01 14:29:15 maxv Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.38 2019/05/01 15:17:49 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -264,24 +264,6 @@ END(x86_write_flags)
 STRONG_ALIAS(x86_write_psl,x86_write_flags)
 #endif /* XENPV */
 
-ENTRY(rdmsr)
-	movq	%rdi, %rcx
-	xorq	%rax, %rax
-	rdmsr
-	shlq	$32, %rdx
-	orq	%rdx, %rax
-	ret
-END(rdmsr)
-
-ENTRY(wrmsr)
-	movq	%rdi, %rcx
-	movq	%rsi, %rax
-	movq	%rsi, %rdx
-	shrq	$32, %rdx
-	wrmsr
-	ret
-END(wrmsr)
-
 ENTRY(rdmsr_locked)
 	movq	%rdi, %rcx
 	xorq	%rax, %rax
@@ -324,23 +306,6 @@ ENTRY(rdmsr_safe)
 	ret
 END(rdmsr_safe)
 
-ENTRY(rdxcr)
-	movq	%rdi, %rcx
-	xgetbv
-	shlq	$32, %rdx
-	orq	%rdx, %rax
-	ret
-END(rdxcr)
-
-ENTRY(wrxcr)
-	movq	%rdi, %rcx
-	movq	%rsi, %rax
-	movq	%rsi, %rdx
-	shrq	$32, %rdx
-	xsetbv
-	ret
-END(wrxcr)
-
 /*
  * MSR operations fault handler
  */
@@ -374,14 +339,6 @@ ENTRY(cpu_counter32)
 	ret
 END(cpu_counter32)
 
-ENTRY(rdtsc)
-	xorq	%rax,%rax
-	rdtsc
-	shlq	$32,%rdx
-	orq	%rdx,%rax
-	ret
-END(rdtsc)
-
 ENTRY(breakpoint)
 	pushq	%rbp
 	movq	%rsp, %rbp
@@ -498,11 +455,6 @@ ENTRY(x86_mwait)
 	ret
 END(x86_mwait)
 
-ENTRY(x86_pause)
-	pause
-	ret
-END(x86_pause)
-
 ENTRY(x86_cpuid2)
 	movq	%rbx, %r8
 	movq	%rdi, %rax

Index: src/sys/arch/i386/i386/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.29 src/sys/arch/i386/i386/cpufunc.S:1.30
--- src/sys/arch/i386/i386/cpufunc.S:1.29	Wed May  1 14:29:15 2019
+++ src/sys/arch/i386/i386/cpufunc.S	Wed May  1 15:17:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.29 2019/05/01 14:29:15 maxv Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.30 2019/05/01 15:17:49 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.29 2019/05/01 14:29:15 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.30 2019/05/01 15:17:49 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -107,20 +107,6 @@ STRONG_ALIAS(x86_write_psl,x86_write_fla
 STRONG_ALIAS(x86_read_psl,x86_read_flags)
 #endif	/* XENPV */
 
-ENTRY(rdmsr)
-	movl	4(%esp), %ecx
-	rdmsr
-	ret
-END(rdmsr)
-
-ENTRY(wrmsr)
-	movl	4(%esp), %ecx
-	movl	8(%esp), %eax
-	movl	12(%esp), %edx
-	wrmsr
-	ret
-END(wrmsr)
-
 ENTRY(rdmsr_locked)
 	movl	4(%esp), %ecx
 	pushl	%edi
@@ -164,23 +150,6 @@ ENTRY(rdmsr_safe)
 	ret
 END(rdmsr_safe)
 
-/* uint64_t rdxcr(uint32_t) */
-ENTRY(rdxcr)
-	movl	4(%esp), %ecx	/* extended control reg number */
-	xgetbv			/* Read to %edx:%eax */
-	ret
-END(rdxcr)
-
-/* void wrxcr(uint32_t, uint64_t) */
-ENTRY(wrxcr)
-	movl	4(%esp), %ecx	/* extended control reg number */
-	movl	8(%esp), %eax	/* feature mask bits */
-	movl	12(%esp), %edx
-	xsetbv
-	ret
-END(wrxcr)
-	
-
 /*
  * MSR operations fault handler
  */
@@ -205,11 +174,6 @@ ENTRY(cpu_counter32)
 	ret
 END(cpu_counter32)
 
-ENTRY(rdtsc)
-	rdtsc
-	ret
-END(rdtsc)
-
 ENTRY(breakpoint)
 	pushl	%ebp
 	movl	%esp, %ebp
@@ -296,11 +260,6 @@ ENTRY(x86_mwait)  
 	ret
 END(x86_mwait)  
 
-ENTRY(x86_pause)
-	pause
-	ret
-END(x86_pause)
-
 ENTRY(x86_cpuid2)
 	pushl	%ebx
 	pushl	%edi

Index: src/sys/arch/x86/include/cpufunc.h
diff -u src/sys/arch/x86/include/cpufunc.h:1.25 src/sys/arch/x86/include/cpufunc.h:1.26
--- src/sys/arch/x86/include/cpufunc.h:1.25	Wed May  1 14:29:15 2019
+++ src/sys/arch/x86/include/cpufunc.h	Wed May  1 15:17:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.25 2019/05/01 14:29:15 maxv Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.26 2019/05/01 15:17:49 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2019 The NetBSD Foundation, Inc.
@@ -44,7 +44,12 @@
 
 #ifdef _KERNEL
 
-void	x86_pause(void);
+static inline void
+x86_pause(void)
+{
+	asm volatile ("pause");
+}
+
 void	x86_lfence(void);
 void	x86_sfence(void);
 void	x86_mfence(void);
@@ -56,7 +61,21 @@ void	tlbflushg(void);
 void	invlpg(vaddr_t);
 void	wbinvd(void);
 void	breakpoint(void);
-uint64_t rdtsc(void);
+
+static inline uint64_t
+rdtsc(void)
+{
+	uint32_t low, high;
+
+	asm volatile 

CVS commit: [netbsd-8] src/sys/kern

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 14:51:17 UTC 2019

Modified Files:
src/sys/kern [netbsd-8]: sys_pipe.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1253):

sys/kern/sys_pipe.c: revision 1.147
sys/kern/sys_pipe.c: revision 1.148

Clean up pipe structure before recycling it.

Handle half-closed pipes in FIONWRITE and FIONSPACE.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.140.12.1 src/sys/kern/sys_pipe.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/sys_pipe.c
diff -u src/sys/kern/sys_pipe.c:1.140 src/sys/kern/sys_pipe.c:1.140.12.1
--- src/sys/kern/sys_pipe.c:1.140	Fri Sep  5 09:20:59 2014
+++ src/sys/kern/sys_pipe.c	Wed May  1 14:51:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_pipe.c,v 1.140 2014/09/05 09:20:59 matt Exp $	*/
+/*	$NetBSD: sys_pipe.c,v 1.140.12.1 2019/05/01 14:51:17 martin Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.140 2014/09/05 09:20:59 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.140.12.1 2019/05/01 14:51:17 martin Exp $");
 
 #include 
 #include 
@@ -1107,10 +1107,12 @@ pipe_ioctl(file_t *fp, u_long cmd, void 
 
 	case FIONWRITE:
 		/* Look at other side */
-		pipe = pipe->pipe_peer;
 		mutex_enter(lock);
+		pipe = pipe->pipe_peer;
+		if (pipe == NULL)
+			*(int *)data = 0;
 #ifndef PIPE_NODIRECT
-		if (pipe->pipe_state & PIPE_DIRECTW)
+		else if (pipe->pipe_state & PIPE_DIRECTW)
 			*(int *)data = pipe->pipe_map.cnt;
 		else
 #endif
@@ -1120,8 +1122,11 @@ pipe_ioctl(file_t *fp, u_long cmd, void 
 
 	case FIONSPACE:
 		/* Look at other side */
-		pipe = pipe->pipe_peer;
 		mutex_enter(lock);
+		pipe = pipe->pipe_peer;
+		if (pipe == NULL)
+			*(int *)data = 0;
+		else
 #ifndef PIPE_NODIRECT
 		/*
 		 * If we're in direct-mode, we don't really have a
@@ -1346,6 +1351,8 @@ pipeclose(struct pipe *pipe)
 free_resources:
 	pipe->pipe_pgid = 0;
 	pipe->pipe_state = PIPE_SIGNALR;
+	pipe->pipe_peer = NULL;
+	pipe->pipe_lock = NULL;
 	pipe_free_kmem(pipe);
 	if (pipe->pipe_kmem != 0) {
 		pool_cache_put(pipe_rd_cache, pipe);



CVS commit: [netbsd-8] src/sys/kern

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 14:51:17 UTC 2019

Modified Files:
src/sys/kern [netbsd-8]: sys_pipe.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1253):

sys/kern/sys_pipe.c: revision 1.147
sys/kern/sys_pipe.c: revision 1.148

Clean up pipe structure before recycling it.

Handle half-closed pipes in FIONWRITE and FIONSPACE.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.140.12.1 src/sys/kern/sys_pipe.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

2019-05-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May  1 14:29:15 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/i386/i386: cpufunc.S
src/sys/arch/x86/include: cpufunc.h

Log Message:
Remove unused functions and reorder a little.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/i386/i386/cpufunc.S
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x86/include/cpufunc.h

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

Modified files:

Index: src/sys/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.36 src/sys/arch/amd64/amd64/cpufunc.S:1.37
--- src/sys/arch/amd64/amd64/cpufunc.S:1.36	Mon Feb 11 14:59:32 2019
+++ src/sys/arch/amd64/amd64/cpufunc.S	Wed May  1 14:29:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.36 2019/02/11 14:59:32 cherry Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.37 2019/05/01 14:29:15 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -374,15 +374,6 @@ ENTRY(cpu_counter32)
 	ret
 END(cpu_counter32)
 
-ENTRY(rdpmc)
-	movq	%rdi, %rcx
-	xorq	%rax, %rax
-	rdpmc
-	shlq	$32, %rdx
-	orq	%rdx, %rax
-	ret
-END(rdpmc)
-
 ENTRY(rdtsc)
 	xorq	%rax,%rax
 	rdtsc
@@ -531,11 +522,6 @@ ENTRY(x86_getss)
 	ret
 END(x86_getss)
 
-ENTRY(fldcw)
-	fldcw	(%rdi)
-	ret
-END(fldcw)
-
 ENTRY(fnclex)
 	fnclex
 	ret
@@ -566,24 +552,11 @@ ENTRY(fnstsw)
 	ret
 END(fnstsw)
 
-ENTRY(fp_divide_by_0)
-	fldz
-	fld1
-	fdiv	%st, %st(1)
-	fwait
-	ret
-END(fp_divide_by_0)
-
 ENTRY(frstor)
 	frstor	(%rdi)
 	ret
 END(frstor)
 
-ENTRY(fwait)
-	fwait
-	ret
-END(fwait)
-
 ENTRY(clts)
 	clts
 	ret

Index: src/sys/arch/i386/i386/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.28 src/sys/arch/i386/i386/cpufunc.S:1.29
--- src/sys/arch/i386/i386/cpufunc.S:1.28	Mon Feb 11 14:59:32 2019
+++ src/sys/arch/i386/i386/cpufunc.S	Wed May  1 14:29:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.28 2019/02/11 14:59:32 cherry Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.29 2019/05/01 14:29:15 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.28 2019/02/11 14:59:32 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.29 2019/05/01 14:29:15 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -205,12 +205,6 @@ ENTRY(cpu_counter32)
 	ret
 END(cpu_counter32)
 
-ENTRY(rdpmc)
-	movl	4(%esp), %ecx
-	rdpmc
-	ret
-END(rdpmc)
-
 ENTRY(rdtsc)
 	rdtsc
 	ret
@@ -328,12 +322,6 @@ ENTRY(x86_getss)
 	ret
 END(x86_getss)
 
-ENTRY(fldcw)
-	movl	4(%esp), %eax
-	fldcw	(%eax)
-	ret
-END(fldcw)
-
 ENTRY(fnclex)	
 	fnclex
 	ret
@@ -367,25 +355,12 @@ ENTRY(fnstsw)
 	ret
 END(fnstsw)
 
-ENTRY(fp_divide_by_0)
-	fldz
-	fld1
-	fdiv	%st, %st(1)
-	fwait
-	ret
-END(fp_divide_by_0)
-
 ENTRY(frstor)
 	movl	4(%esp), %eax
 	frstor	(%eax)
 	ret
 END(frstor)
 
-ENTRY(fwait)
-	fwait
-	ret
-END(fwait)
-
 ENTRY(clts)
 	clts
 	ret

Index: src/sys/arch/x86/include/cpufunc.h
diff -u src/sys/arch/x86/include/cpufunc.h:1.24 src/sys/arch/x86/include/cpufunc.h:1.25
--- src/sys/arch/x86/include/cpufunc.h:1.24	Thu Feb 22 09:41:06 2018
+++ src/sys/arch/x86/include/cpufunc.h	Wed May  1 14:29:15 2019
@@ -1,7 +1,7 @@
-/*	$NetBSD: cpufunc.h,v 1.24 2018/02/22 09:41:06 maxv Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.25 2019/05/01 14:29:15 maxv Exp $	*/
 
-/*-
- * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
+/*
+ * Copyright (c) 1998, 2007, 2019 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -49,16 +49,33 @@ void	x86_lfence(void);
 void	x86_sfence(void);
 void	x86_mfence(void);
 void	x86_flush(void);
+void	x86_hlt(void);
+void	x86_stihlt(void);
+void	tlbflush(void);
+void	tlbflushg(void);
+void	invlpg(vaddr_t);
+void	wbinvd(void);
+void	breakpoint(void);
+uint64_t rdtsc(void);
 #ifndef XEN
 void	x86_hotpatch(uint32_t, const uint8_t *, size_t);
 void	x86_patch_window_open(u_long *, u_long *);
 void	x86_patch_window_close(u_long, u_long);
 void	x86_patch(bool);
 #endif
-void	invlpg(vaddr_t);
+
+void	x86_monitor(const void *, uint32_t, uint32_t);
+void	x86_mwait(uint32_t, uint32_t);
+/* x86_cpuid2() writes four 32bit values, %eax, %ebx, %ecx and %edx */
+#define	x86_cpuid(a,b)	x86_cpuid2((a),0,(b))
+void	x86_cpuid2(uint32_t, uint32_t, uint32_t *);
+
+/* -- */
+
 void	lidt(struct region_descriptor *);
 void	lldt(u_short);
 void	ltr(u_short);
+
 void	lcr0(u_long);
 u_long	rcr0(void);
 void	lcr2(vaddr_t);
@@ -69,8 +86,7 @@ void	lcr4(vaddr_t);
 vaddr_t	rcr4(void);
 void	lcr8(vaddr_t);
 vaddr_t	rcr8(void);
-void	tlbflush(void);
-void	tlbflushg(void);
+
 register_t	rdr0(void);
 void		ldr0(register_t);
 register_t	rdr1(void);
@@ -83,15 +99,16 @@ register_t	rdr6(void);
 void		ldr6(register_t);
 

CVS commit: src/sys/arch

2019-05-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May  1 14:29:15 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/i386/i386: cpufunc.S
src/sys/arch/x86/include: cpufunc.h

Log Message:
Remove unused functions and reorder a little.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/i386/i386/cpufunc.S
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x86/include/cpufunc.h

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



CVS commit: src/sys/dev/pci

2019-05-01 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May  1 14:10:26 UTC 2019

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

Log Message:
 Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/if_alc.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/if_alc.c
diff -u src/sys/dev/pci/if_alc.c:1.33 src/sys/dev/pci/if_alc.c:1.34
--- src/sys/dev/pci/if_alc.c:1.33	Wed May  1 12:31:51 2019
+++ src/sys/dev/pci/if_alc.c	Wed May  1 14:10:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_alc.c,v 1.33 2019/05/01 12:31:51 msaitoh Exp $	*/
+/*	$NetBSD: if_alc.c,v 1.34 2019/05/01 14:10:26 msaitoh Exp $	*/
 /*	$OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $	*/
 /*-
  * Copyright (c) 2009, Pyun YongHyeon 
@@ -2056,12 +2056,14 @@ alc_ioctl(struct ifnet *ifp, u_long cmd,
 
 	switch (cmd) {
 	case SIOCSIFADDR:
+		error = ether_ioctl(ifp, cmd, data);
 		ifp->if_flags |= IFF_UP;
 		if (!(ifp->if_flags & IFF_RUNNING))
 			alc_init(ifp);
 		break;
- 
+
 	case SIOCSIFFLAGS:
+		error = ether_ioctl(ifp, cmd, data);
 		if (ifp->if_flags & IFF_UP) {
 			if (ifp->if_flags & IFF_RUNNING)
 error = ENETRESET;
@@ -2072,7 +2074,7 @@ alc_ioctl(struct ifnet *ifp, u_long cmd,
 alc_stop(ifp, 0);
 		}
 		break;
- 
+
 	default:
 		error = ether_ioctl(ifp, cmd, data);
 		break;



CVS commit: src/sys/dev/pci

2019-05-01 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May  1 14:10:26 UTC 2019

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

Log Message:
 Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/if_alc.c

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



CVS commit: [isaki-audio2] src/sys

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 13:45:52 UTC 2019

Modified Files:
src/sys/arch/evbarm/mini2440 [isaki-audio2]: audio_mini2440.c
src/sys/dev/usb [isaki-audio2]: uaudio.c

Log Message:
set_params -> set_format in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.2.2.1 -r1.2.2.2 \
src/sys/arch/evbarm/mini2440/audio_mini2440.c
cvs rdiff -u -r1.158.2.2 -r1.158.2.3 src/sys/dev/usb/uaudio.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/evbarm/mini2440/audio_mini2440.c
diff -u src/sys/arch/evbarm/mini2440/audio_mini2440.c:1.2.2.1 src/sys/arch/evbarm/mini2440/audio_mini2440.c:1.2.2.2
--- src/sys/arch/evbarm/mini2440/audio_mini2440.c:1.2.2.1	Thu Apr 25 13:49:39 2019
+++ src/sys/arch/evbarm/mini2440/audio_mini2440.c	Wed May  1 13:45:52 2019
@@ -285,7 +285,7 @@ uda_ssio_set_format(void *handle, int se
 	s3c2440_i2s_set_sample_width(sc->sc_i2s_handle, 16);
 
 	/* It is vital that sc_system_clock is set PRIOR to calling
-	   uda1341_set_params. */
+	   uda1341_set_format. */
 	switch (s3c2440_i2s_get_master_clock(sc->sc_i2s_handle)) {
 	case 384:
 		uc->sc_system_clock = UDA1341_CLOCK_384;

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.158.2.2 src/sys/dev/usb/uaudio.c:1.158.2.3
--- src/sys/dev/usb/uaudio.c:1.158.2.2	Wed May  1 13:09:33 2019
+++ src/sys/dev/usb/uaudio.c	Wed May  1 13:45:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.158.2.2 2019/05/01 13:09:33 isaki Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.158.2.3 2019/05/01 13:45:52 isaki Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158.2.2 2019/05/01 13:09:33 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158.2.3 2019/05/01 13:45:52 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2240,7 +2240,7 @@ uaudio_round_blocksize(void *addr, int b
 	} else {
 		/*
 		 * use wMaxPacketSize in bytes_per_frame.
-		 * See uaudio_set_params() and uaudio_chan_init()
+		 * See uaudio_set_format() and uaudio_chan_init()
 		 */
 		b = sc->sc_recchan.bytes_per_frame
 		* UAUDIO_NFRAMES * UAUDIO_NCHANBUFS;



CVS commit: [isaki-audio2] src/sys

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 13:45:52 UTC 2019

Modified Files:
src/sys/arch/evbarm/mini2440 [isaki-audio2]: audio_mini2440.c
src/sys/dev/usb [isaki-audio2]: uaudio.c

Log Message:
set_params -> set_format in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.2.2.1 -r1.2.2.2 \
src/sys/arch/evbarm/mini2440/audio_mini2440.c
cvs rdiff -u -r1.158.2.2 -r1.158.2.3 src/sys/dev/usb/uaudio.c

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



CVS commit: [isaki-audio2] src/sys/dev/usb

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 13:09:34 UTC 2019

Modified Files:
src/sys/dev/usb [isaki-audio2]: uaudio.c

Log Message:
Don't release sc_lock and sc_intr_lock in trigger_{input,output}.
In the past, sc_lock was IPL_SCHED and (probably) it had conflicted
with usb subroutines.  But at some point, sc_lock has changed to use
IPL_SOFTUSB so such problems should been gone.


To generate a diff of this commit:
cvs rdiff -u -r1.158.2.1 -r1.158.2.2 src/sys/dev/usb/uaudio.c

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

Modified files:

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.158.2.1 src/sys/dev/usb/uaudio.c:1.158.2.2
--- src/sys/dev/usb/uaudio.c:1.158.2.1	Wed May  1 12:42:14 2019
+++ src/sys/dev/usb/uaudio.c	Wed May  1 13:09:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.158.2.1 2019/05/01 12:42:14 isaki Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.158.2.2 2019/05/01 13:09:33 isaki Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158.2.1 2019/05/01 12:42:14 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158.2.2 2019/05/01 13:09:33 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2535,20 +2535,14 @@ uaudio_trigger_input(void *addr, void *s
 		"fraction=0.%03d\n", ch->sample_size, ch->bytes_per_frame,
 		ch->fraction);
 
-	mutex_exit(>sc_intr_lock);
-	mutex_exit(>sc_lock);
 	err = uaudio_chan_open(sc, ch);
 	if (err) {
-		mutex_enter(>sc_lock);
-		mutex_enter(>sc_intr_lock);
 		return EIO;
 	}
 
 	err = uaudio_chan_alloc_buffers(sc, ch);
 	if (err) {
 		uaudio_chan_close(sc, ch);
-		mutex_enter(>sc_lock);
-		mutex_enter(>sc_intr_lock);
 		return EIO;
 	}
 
@@ -2564,9 +2558,6 @@ uaudio_trigger_input(void *addr, void *s
 		uaudio_chan_rtransfer(ch);
 	}
 
-	mutex_enter(>sc_lock);
-	mutex_enter(>sc_intr_lock);
-
 	return 0;
 }
 
@@ -2592,20 +2583,14 @@ uaudio_trigger_output(void *addr, void *
 		"fraction=0.%03d\n", ch->sample_size, ch->bytes_per_frame,
 		ch->fraction);
 
-	mutex_exit(>sc_intr_lock);
-	mutex_exit(>sc_lock);
 	err = uaudio_chan_open(sc, ch);
 	if (err) {
-		mutex_enter(>sc_lock);
-		mutex_enter(>sc_intr_lock);
 		return EIO;
 	}
 
 	err = uaudio_chan_alloc_buffers(sc, ch);
 	if (err) {
 		uaudio_chan_close(sc, ch);
-		mutex_enter(>sc_lock);
-		mutex_enter(>sc_intr_lock);
 		return EIO;
 	}
 
@@ -2614,8 +2599,6 @@ uaudio_trigger_output(void *addr, void *
 
 	for (i = 0; i < UAUDIO_NCHANBUFS; i++)
 		uaudio_chan_ptransfer(ch);
-	mutex_enter(>sc_lock);
-	mutex_enter(>sc_intr_lock);
 
 	return 0;
 }



CVS commit: [isaki-audio2] src/sys/dev/usb

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 13:09:34 UTC 2019

Modified Files:
src/sys/dev/usb [isaki-audio2]: uaudio.c

Log Message:
Don't release sc_lock and sc_intr_lock in trigger_{input,output}.
In the past, sc_lock was IPL_SCHED and (probably) it had conflicted
with usb subroutines.  But at some point, sc_lock has changed to use
IPL_SOFTUSB so such problems should been gone.


To generate a diff of this commit:
cvs rdiff -u -r1.158.2.1 -r1.158.2.2 src/sys/dev/usb/uaudio.c

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



CVS commit: [isaki-audio2] src/sys/dev/usb

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 12:42:14 UTC 2019

Modified Files:
src/sys/dev/usb [isaki-audio2]: uaudio.c

Log Message:
Adapt to audio2.
- Remove obsoleted or empty methods.
- Remove AUFMT_VALIDATE()/INVALIDATE().  At first, this flag is
  set/cleared but no one in the driver seems to refer at least now.
  And second, don't use such flag for other purpose.  If you need
  to do such thing, use .driver_data instead.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.158.2.1 src/sys/dev/usb/uaudio.c

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



CVS commit: [isaki-audio2] src/sys/dev/usb

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 12:42:14 UTC 2019

Modified Files:
src/sys/dev/usb [isaki-audio2]: uaudio.c

Log Message:
Adapt to audio2.
- Remove obsoleted or empty methods.
- Remove AUFMT_VALIDATE()/INVALIDATE().  At first, this flag is
  set/cleared but no one in the driver seems to refer at least now.
  And second, don't use such flag for other purpose.  If you need
  to do such thing, use .driver_data instead.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.158.2.1 src/sys/dev/usb/uaudio.c

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

Modified files:

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.158 src/sys/dev/usb/uaudio.c:1.158.2.1
--- src/sys/dev/usb/uaudio.c:1.158	Sat Mar 16 12:09:58 2019
+++ src/sys/dev/usb/uaudio.c	Wed May  1 12:42:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.158 2019/03/16 12:09:58 isaki Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.158.2.1 2019/05/01 12:42:14 isaki Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158.2.1 2019/05/01 12:42:14 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -62,9 +62,6 @@ __KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1
 
 #include 
 #include 
-#include 
-#include 
-#include 
 
 #include 
 #include 
@@ -207,7 +204,6 @@ struct uaudio_softc {
 	device_t	sc_audiodev;
 	struct audio_format *sc_formats;
 	int		sc_nformats;
-	struct audio_encoding_set *sc_encodings;
 	u_int		sc_channel_config;
 	char		sc_dying;
 	struct audio_device sc_adev;
@@ -334,12 +330,10 @@ Static void	uaudio_chan_rintr
 	(struct usbd_xfer *, void *, usbd_status);
 
 Static int	uaudio_open(void *, int);
-Static void	uaudio_close(void *);
-Static int	uaudio_drain(void *);
-Static int	uaudio_query_encoding(void *, struct audio_encoding *);
-Static int	uaudio_set_params
-	(void *, int, int, struct audio_params *, struct audio_params *,
-	 stream_filter_list_t *, stream_filter_list_t *);
+Static int	uaudio_query_format(void *, audio_format_query_t *);
+Static int	uaudio_set_format
+ (void *, int, const audio_params_t *, const audio_params_t *,
+	 audio_filter_reg_t *, audio_filter_reg_t *);
 Static int	uaudio_round_blocksize(void *, int, int, const audio_params_t *);
 Static int	uaudio_trigger_output
 	(void *, void *, void *, int, void (*)(void *), void *,
@@ -358,10 +352,8 @@ Static void	uaudio_get_locks(void *, kmu
 
 Static const struct audio_hw_if uaudio_hw_if = {
 	.open			= uaudio_open,
-	.close			= uaudio_close,
-	.drain			= uaudio_drain,
-	.query_encoding		= uaudio_query_encoding,
-	.set_params		= uaudio_set_params,
+	.query_format		= uaudio_query_format,
+	.set_format		= uaudio_set_format,
 	.round_blocksize	= uaudio_round_blocksize,
 	.halt_output		= uaudio_halt_out_dma,
 	.halt_input		= uaudio_halt_in_dma,
@@ -540,7 +532,6 @@ uaudio_detach(device_t self, int flags)
 	if (sc->sc_formats != NULL)
 		kmem_free(sc->sc_formats,
 		sizeof(struct audio_format) * sc->sc_nformats);
-	auconv_delete_encodings(sc->sc_encodings);
 
 	mutex_destroy(>sc_lock);
 	mutex_destroy(>sc_intr_lock);
@@ -549,20 +540,12 @@ uaudio_detach(device_t self, int flags)
 }
 
 Static int
-uaudio_query_encoding(void *addr, struct audio_encoding *fp)
+uaudio_query_format(void *addr, audio_format_query_t *afp)
 {
 	struct uaudio_softc *sc;
-	int flags;
 
 	sc = addr;
-	flags = sc->sc_altflags;
-	if (sc->sc_dying)
-		return EIO;
-
-	if (sc->sc_nalts == 0 || flags == 0)
-		return ENXIO;
-
-	return auconv_query_encoding(sc->sc_encodings, fp);
+	return audio_query_format(sc->sc_formats, sc->sc_nformats, afp);
 }
 
 Static const usb_interface_descriptor_t *
@@ -1848,14 +1831,6 @@ uaudio_identify_as(struct uaudio_softc *
 		sc->sc_alts[i].aformat = auf;
 	}
 
-	if (0 != auconv_create_encodings(sc->sc_formats, sc->sc_nformats,
-	 >sc_encodings)) {
-		kmem_free(sc->sc_formats,
-		sizeof(struct audio_format) * sc->sc_nformats);
-		sc->sc_formats = NULL;
-		return ENOMEM;
-	}
-
 	return USBD_NORMAL_COMPLETION;
 }
 
@@ -2185,27 +2160,6 @@ uaudio_open(void *addr, int flags)
 	return 0;
 }
 
-/*
- * Close function is called at splaudio().
- */
-Static void
-uaudio_close(void *addr)
-{
-}
-
-Static int
-uaudio_drain(void *addr)
-{
-	struct uaudio_softc *sc = addr;
-
-	KASSERT(mutex_owned(>sc_intr_lock));
-
-	kpause("uaudiodr", false,
-	mstohz(UAUDIO_NCHANBUFS * UAUDIO_NFRAMES), >sc_intr_lock);
-
-	return 0;
-}
-
 Static int
 uaudio_halt_out_dma(void *addr)
 {
@@ -2718,7 +2672,6 @@ uaudio_chan_abort(struct uaudio_softc *s
 
 	as = >sc_alts[ch->altidx];
 	as->sc_busy = 0;
-	AUFMT_VALIDATE(as->aformat);
 	if (sc->sc_nullalt >= 0) {
 		DPRINTF("set null alt=%d\n", sc->sc_nullalt);
 		usbd_set_interface(as->ifaceh, sc->sc_nullalt);
@@ -3021,15 +2974,12 @@ 

CVS commit: src/sys/dev/pci

2019-05-01 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May  1 12:31:51 UTC 2019

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

Log Message:
 Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/pci/if_alc.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/if_alc.c
diff -u src/sys/dev/pci/if_alc.c:1.32 src/sys/dev/pci/if_alc.c:1.33
--- src/sys/dev/pci/if_alc.c:1.32	Mon Apr 22 09:08:14 2019
+++ src/sys/dev/pci/if_alc.c	Wed May  1 12:31:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_alc.c,v 1.32 2019/04/22 09:08:14 msaitoh Exp $	*/
+/*	$NetBSD: if_alc.c,v 1.33 2019/05/01 12:31:51 msaitoh Exp $	*/
 /*	$OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $	*/
 /*-
  * Copyright (c) 2009, Pyun YongHyeon 
@@ -2054,7 +2054,6 @@ alc_ioctl(struct ifnet *ifp, u_long cmd,
 
 	s = splnet();
 
-	error = ether_ioctl(ifp, cmd, data);
 	switch (cmd) {
 	case SIOCSIFADDR:
 		ifp->if_flags |= IFF_UP;



CVS commit: src/sys/dev/pci

2019-05-01 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May  1 12:31:51 UTC 2019

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

Log Message:
 Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/pci/if_alc.c

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



CVS commit: [isaki-audio2] src/sys

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 12:18:59 UTC 2019

Modified Files:
src/sys/arch/sparc/conf [isaki-audio2]: GENERIC TADPOLE3GX
src/sys/dev/sbus [isaki-audio2]: dbri.c dbrivar.h files.sbus

Log Message:
Adapt dbri to audio2.
- Add some mutex_enter/exit.
- Remove DBRI_BIG_BUFFER option.  Such big buffer will not necessary
  in audio2.
Thank you, macallan@.


To generate a diff of this commit:
cvs rdiff -u -r1.265 -r1.265.2.1 src/sys/arch/sparc/conf/GENERIC
cvs rdiff -u -r1.77 -r1.77.2.1 src/sys/arch/sparc/conf/TADPOLE3GX
cvs rdiff -u -r1.39.2.1 -r1.39.2.2 src/sys/dev/sbus/dbri.c
cvs rdiff -u -r1.15 -r1.15.8.1 src/sys/dev/sbus/dbrivar.h
cvs rdiff -u -r1.43 -r1.43.2.1 src/sys/dev/sbus/files.sbus

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/sparc/conf/GENERIC
diff -u src/sys/arch/sparc/conf/GENERIC:1.265 src/sys/arch/sparc/conf/GENERIC:1.265.2.1
--- src/sys/arch/sparc/conf/GENERIC:1.265	Sat Apr 13 08:23:00 2019
+++ src/sys/arch/sparc/conf/GENERIC	Wed May  1 12:18:59 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.265 2019/04/13 08:23:00 isaki Exp $
+# $NetBSD: GENERIC,v 1.265.2.1 2019/05/01 12:18:59 isaki Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include 	"arch/sparc/conf/std.sparc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.265 $"
+#ident 		"GENERIC-$Revision: 1.265.2.1 $"
 
 maxusers	32
 
@@ -609,7 +609,6 @@ audioamd0	at sbus0 slot ? offset ?		# su
 audiocs0	at sbus0 slot ? offset ?		# SUNW,CS4231
 
 #options 	DBRI_DEBUG	# noisy debug output from the dbri driver
-#options 	DBRI_BIG_BUFFER	# use bigger DMA buffers, for slow CPUs
 dbri*		at sbus? slot ? offset ?		# SUNW,DBRI[s3|e]
 
 audio*		at audiobus?

Index: src/sys/arch/sparc/conf/TADPOLE3GX
diff -u src/sys/arch/sparc/conf/TADPOLE3GX:1.77 src/sys/arch/sparc/conf/TADPOLE3GX:1.77.2.1
--- src/sys/arch/sparc/conf/TADPOLE3GX:1.77	Sat Apr 13 08:23:00 2019
+++ src/sys/arch/sparc/conf/TADPOLE3GX	Wed May  1 12:18:59 2019
@@ -1,4 +1,4 @@
-# 	$NetBSD: TADPOLE3GX,v 1.77 2019/04/13 08:23:00 isaki Exp $
+# 	$NetBSD: TADPOLE3GX,v 1.77.2.1 2019/05/01 12:18:59 isaki Exp $
 
 include "arch/sparc/conf/std.sparc"
 
@@ -317,7 +317,6 @@ pseudo-device	npf			# NPF packet filter
 ## /dev/audio support
 
 #options 	DBRI_DEBUG	# noisy debug output from the dbri driver
-options 	DBRI_BIG_BUFFER	# use bigger DMA buffers, for slow CPUs
 dbri0		at sbus0 slot ? offset ?		# SUNW,DBRI[s3|e]
 audio*		at audiobus?
 

Index: src/sys/dev/sbus/dbri.c
diff -u src/sys/dev/sbus/dbri.c:1.39.2.1 src/sys/dev/sbus/dbri.c:1.39.2.2
--- src/sys/dev/sbus/dbri.c:1.39.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/sbus/dbri.c	Wed May  1 12:18:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: dbri.c,v 1.39.2.1 2019/04/21 05:11:22 isaki Exp $	*/
+/*	$NetBSD: dbri.c,v 1.39.2.2 2019/05/01 12:18:59 isaki Exp $	*/
 
 /*
  * Copyright (C) 1997 Rudolf Koenig (rfkoe...@immd4.informatik.uni-erlangen.de)
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.39.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.39.2.2 2019/05/01 12:18:59 isaki Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -55,7 +55,6 @@ __KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.3
 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -132,9 +131,10 @@ static void	pipe_ts_link(struct dbri_sof
 static int	pipe_active(struct dbri_softc *, int);
 
 /* audio(9) stuff */
-static int	dbri_query_encoding(void *, struct audio_encoding *);
-static int	dbri_set_params(void *, int, int, struct audio_params *,
-struct audio_params *,stream_filter_list_t *, stream_filter_list_t *);
+static int	dbri_query_format(void *, audio_format_query_t *);
+static int	dbri_set_format(void *, int,
+const audio_params_t *, const audio_params_t *,
+audio_filter_reg_t *, audio_filter_reg_t *);
 static int	dbri_round_blocksize(void *, int, int, const audio_params_t *);
 static int	dbri_halt_output(void *);
 static int	dbri_halt_input(void *);
@@ -142,7 +142,6 @@ static int	dbri_getdev(void *, struct au
 static int	dbri_set_port(void *, mixer_ctrl_t *);
 static int	dbri_get_port(void *, mixer_ctrl_t *);
 static int	dbri_query_devinfo(void *, mixer_devinfo_t *);
-static size_t	dbri_round_buffersize(void *, int, size_t);
 static int	dbri_get_props(void *);
 static int	dbri_open(void *, int);
 static void	dbri_close(void *);
@@ -160,7 +159,6 @@ static void	dbri_get_locks(void *, kmute
 
 static void	*dbri_malloc(void *, int, size_t);
 static void	dbri_free(void *, void *, size_t);
-static paddr_t	dbri_mappage(void *, void *, off_t, int);
 static void	dbri_set_power(struct dbri_softc *, int);
 static void	dbri_bring_up(struct dbri_softc *);
 static bool	dbri_suspend(device_t, const pmf_qual_t *);
@@ -179,8 +177,8 @@ struct audio_device dbri_device = {
 struct audio_hw_if dbri_hw_if = {
 	.open			= 

CVS commit: [isaki-audio2] src/sys

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 12:18:59 UTC 2019

Modified Files:
src/sys/arch/sparc/conf [isaki-audio2]: GENERIC TADPOLE3GX
src/sys/dev/sbus [isaki-audio2]: dbri.c dbrivar.h files.sbus

Log Message:
Adapt dbri to audio2.
- Add some mutex_enter/exit.
- Remove DBRI_BIG_BUFFER option.  Such big buffer will not necessary
  in audio2.
Thank you, macallan@.


To generate a diff of this commit:
cvs rdiff -u -r1.265 -r1.265.2.1 src/sys/arch/sparc/conf/GENERIC
cvs rdiff -u -r1.77 -r1.77.2.1 src/sys/arch/sparc/conf/TADPOLE3GX
cvs rdiff -u -r1.39.2.1 -r1.39.2.2 src/sys/dev/sbus/dbri.c
cvs rdiff -u -r1.15 -r1.15.8.1 src/sys/dev/sbus/dbrivar.h
cvs rdiff -u -r1.43 -r1.43.2.1 src/sys/dev/sbus/files.sbus

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



CVS commit: src/sys/arch/arm/dts

2019-05-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed May  1 10:43:55 UTC 2019

Added Files:
src/sys/arch/arm/dts: rk3399-rockpro64.dts

Log Message:
Enable pwm1 and add a pwm-fan node to enable the +FAN- header on ROCKPro64


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.5 src/sys/arch/arm/dts/rk3399-rockpro64.dts

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/arm/dts/rk3399-rockpro64.dts
diff -u /dev/null src/sys/arch/arm/dts/rk3399-rockpro64.dts:1.5
--- /dev/null	Wed May  1 10:43:55 2019
+++ src/sys/arch/arm/dts/rk3399-rockpro64.dts	Wed May  1 10:43:55 2019
@@ -0,0 +1,42 @@
+/* $NetBSD: rk3399-rockpro64.dts,v 1.5 2019/05/01 10:43:55 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2019 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "../../../external/gpl2/dts/dist/arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dts"
+
+/ {
+	pwm-fan {
+		compatible = "pwm-fan";
+		status = "okay";
+		pwms = < 0 4 0>;
+		cooling-levels = <0 150 195 240>;
+	};
+};
+
+ {
+	status = "okay";
+};



CVS commit: src/sys/arch/arm/dts

2019-05-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed May  1 10:43:55 UTC 2019

Added Files:
src/sys/arch/arm/dts: rk3399-rockpro64.dts

Log Message:
Enable pwm1 and add a pwm-fan node to enable the +FAN- header on ROCKPro64


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.5 src/sys/arch/arm/dts/rk3399-rockpro64.dts

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



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

2019-05-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed May  1 10:41:54 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
Add rkpwm and pwmfan


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/evbarm/conf/GENERIC64

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



CVS commit: src/sys/arch/arm/rockchip

2019-05-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed May  1 10:41:33 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: files.rockchip rk3399_pmucru.c
Added Files:
src/sys/arch/arm/rockchip: rk_pwm.c

Log Message:
Add support for RK3399 PWM controller.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/rockchip/files.rockchip
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/rockchip/rk3399_pmucru.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/rockchip/rk_pwm.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/evbarm/conf

2019-05-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed May  1 10:41:54 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
Add rkpwm and pwmfan


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/evbarm/conf/GENERIC64

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/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.91 src/sys/arch/evbarm/conf/GENERIC64:1.92
--- src/sys/arch/evbarm/conf/GENERIC64:1.91	Fri Apr 26 08:28:11 2019
+++ src/sys/arch/evbarm/conf/GENERIC64	Wed May  1 10:41:54 2019
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.91 2019/04/26 08:28:11 mrg Exp $
+#	$NetBSD: GENERIC64,v 1.92 2019/05/01 10:41:54 jmcneill Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -245,6 +245,7 @@ rkgpio*		at rkiomux?		# Rockchip GPIO
 gpio*		at gpiobus?
 
 # PWM controller
+rkpwm*		at fdt? pass 3		# Rockchip PWM
 sunxipwm*	at fdt? pass 3		# Allwinner PWM
 
 # MPIO / Pinmux
@@ -437,6 +438,9 @@ options 	FONT_BOLD16x32
 # Backlight
 pwmbacklight*	at fdt?			# PWM Backlight controls
 
+# Fan
+pwmfan*		at fdt?			# PWM Fan controls
+
 # Thermal throttling controller
 sunxithermal*	at fdt?			# Allwinner thermal sensor controller
 tegrasoctherm*	at fdt?			# NVIDIA Tegra SOC_THERM



CVS commit: src/sys/arch/arm/rockchip

2019-05-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed May  1 10:41:33 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: files.rockchip rk3399_pmucru.c
Added Files:
src/sys/arch/arm/rockchip: rk_pwm.c

Log Message:
Add support for RK3399 PWM controller.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/rockchip/files.rockchip
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/rockchip/rk3399_pmucru.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/rockchip/rk_pwm.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/arm/rockchip/files.rockchip
diff -u src/sys/arch/arm/rockchip/files.rockchip:1.18 src/sys/arch/arm/rockchip/files.rockchip:1.19
--- src/sys/arch/arm/rockchip/files.rockchip:1.18	Fri Apr 26 08:28:11 2019
+++ src/sys/arch/arm/rockchip/files.rockchip	Wed May  1 10:41:33 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.rockchip,v 1.18 2019/04/26 08:28:11 mrg Exp $
+#	$NetBSD: files.rockchip,v 1.19 2019/05/01 10:41:33 jmcneill Exp $
 #
 # Configuration info for Rockchip family SoCs
 #
@@ -73,6 +73,11 @@ device	rktsadc: sysmon_envsys
 attach	rktsadc at fdt with rk_tsadc
 file	arch/arm/rockchip/rk_tsadc.c		rk_tsadc
 
+# PWM
+device	rkpwm: pwm
+attach	rkpwm at fdt with rk_pwm
+file	arch/arm/rockchip/rk_pwm.c		rk_pwm
+
 # SOC parameters
 defflag	opt_soc.h			SOC_ROCKCHIP
 defflag	opt_soc.h			SOC_RK3328: SOC_ROCKCHIP

Index: src/sys/arch/arm/rockchip/rk3399_pmucru.c
diff -u src/sys/arch/arm/rockchip/rk3399_pmucru.c:1.2 src/sys/arch/arm/rockchip/rk3399_pmucru.c:1.3
--- src/sys/arch/arm/rockchip/rk3399_pmucru.c:1.2	Sun Aug 12 19:28:41 2018
+++ src/sys/arch/arm/rockchip/rk3399_pmucru.c	Wed May  1 10:41:33 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_pmucru.c,v 1.2 2018/08/12 19:28:41 jmcneill Exp $ */
+/* $NetBSD: rk3399_pmucru.c,v 1.3 2019/05/01 10:41:33 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_pmucru.c,v 1.2 2018/08/12 19:28:41 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_pmucru.c,v 1.3 2019/05/01 10:41:33 jmcneill Exp $");
 
 #include 
 #include 
@@ -320,6 +320,7 @@ static struct rk_cru_clk rk3399_pmucru_c
 	RK_GATE(RK3399_PCLK_I2C0_PMU, "pclk_i2c0_pmu", "pclk_pmu_src", CLKGATE_CON(1), 7),
 	RK_GATE(RK3399_PCLK_I2C4_PMU, "pclk_i2c4_pmu", "pclk_pmu_src", CLKGATE_CON(1), 8),
 	RK_GATE(RK3399_PCLK_I2C8_PMU, "pclk_i2c8_pmu", "pclk_pmu_src", CLKGATE_CON(1), 9),
+	RK_GATE(RK3399_PCLK_RKPWM_PMU, "pclk_rkpwm_pmu", "pclk_pmu_src", CLKGATE_CON(1), 10),
 };
 
 static int

Added files:

Index: src/sys/arch/arm/rockchip/rk_pwm.c
diff -u /dev/null src/sys/arch/arm/rockchip/rk_pwm.c:1.1
--- /dev/null	Wed May  1 10:41:33 2019
+++ src/sys/arch/arm/rockchip/rk_pwm.c	Wed May  1 10:41:33 2019
@@ -0,0 +1,242 @@
+/* $NetBSD: rk_pwm.c,v 1.1 2019/05/01 10:41:33 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2019 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+__KERNEL_RCSID(1, "$NetBSD: rk_pwm.c,v 1.1 2019/05/01 10:41:33 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#define	PWM0_CNT		0x00
+#define	PWM0_PERIOD_HPR		0x04
+#define	PWM0_DUTY_LPR		0x08
+#define	PWM0_CTRL		0x0c
+#define	 CTRL_RPT		__BITS(31,24)
+#define	 CTRL_SCALE		__BITS(23,16)
+#define	 CTRL_PRESCALE		__BITS(14,12)
+#define	 CTRL_CLK_SEL		__BIT(9)
+#define	 CTRL_LP_EN		__BIT(8)
+#define	 CTRL_OUTPUT_MODE	__BIT(5)
+#define	 CTRL_INACTIVE_POL	__BIT(4)
+#define	 CTRL_DUTY_POL		__BIT(3)
+#define	 CTRL_PWM_MODE		__BITS(2,1)
+#define	  CTRL_PWM_MODE_ONESHOT		0

CVS commit: [netbsd-7] src/doc

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:50:53 UTC 2019

Modified Files:
src/doc [netbsd-7]: CHANGES-7.3

Log Message:
Tickets #1691 and #1692


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.49 -r1.1.2.50 src/doc/CHANGES-7.3

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



CVS commit: [netbsd-7] src/doc

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:50:53 UTC 2019

Modified Files:
src/doc [netbsd-7]: CHANGES-7.3

Log Message:
Tickets #1691 and #1692


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.49 -r1.1.2.50 src/doc/CHANGES-7.3

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

Modified files:

Index: src/doc/CHANGES-7.3
diff -u src/doc/CHANGES-7.3:1.1.2.49 src/doc/CHANGES-7.3:1.1.2.50
--- src/doc/CHANGES-7.3:1.1.2.49	Fri Apr 26 19:48:00 2019
+++ src/doc/CHANGES-7.3	Wed May  1 09:50:53 2019
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.3,v 1.1.2.49 2019/04/26 19:48:00 martin Exp $
+# $NetBSD: CHANGES-7.3,v 1.1.2.50 2019/05/01 09:50:53 martin Exp $
 
 A complete list of changes from the NetBSD 7.2 release to the NetBSD 7.3
 release:
@@ -543,3 +543,17 @@ external/bsd/dhcpcd/dist/compat/consttim
 	Fix a potential 1 byte read overflow with DHO_OPTSOVERLOADED.
 	Use consttime_memequal(3) to compare hashes.
 	[roy, ticket #1690]
+
+sys/dev/veriexec.config1.1 (patch)
+
+	Add a configuration file for enabling Veriexec in kernel config(5)
+	files.
+	[sevan, ticket #1691]
+
+sys/kern/sys_pipe.c1.147,1.148
+
+	Clean up pipe structure before recycling it.
+	Handle half-closed pipes in FIONWRITE and FIONSPACE.
+	[mlelstv, ticket #1692]
+
+



CVS commit: [netbsd-7] src/sys/kern

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:48:56 UTC 2019

Modified Files:
src/sys/kern [netbsd-7]: sys_pipe.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1692):

sys/kern/sys_pipe.c: revision 1.147
sys/kern/sys_pipe.c: revision 1.148

Clean up pipe structure before recycling it.

Handle half-closed pipes in FIONWRITE and FIONSPACE.


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.138.4.1 src/sys/kern/sys_pipe.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/sys_pipe.c
diff -u src/sys/kern/sys_pipe.c:1.138 src/sys/kern/sys_pipe.c:1.138.4.1
--- src/sys/kern/sys_pipe.c:1.138	Tue Feb 25 18:30:11 2014
+++ src/sys/kern/sys_pipe.c	Wed May  1 09:48:56 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_pipe.c,v 1.138 2014/02/25 18:30:11 pooka Exp $	*/
+/*	$NetBSD: sys_pipe.c,v 1.138.4.1 2019/05/01 09:48:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.138 2014/02/25 18:30:11 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.138.4.1 2019/05/01 09:48:56 martin Exp $");
 
 #include 
 #include 
@@ -1107,10 +1107,12 @@ pipe_ioctl(file_t *fp, u_long cmd, void 
 
 	case FIONWRITE:
 		/* Look at other side */
-		pipe = pipe->pipe_peer;
 		mutex_enter(lock);
+		pipe = pipe->pipe_peer;
+		if (pipe == NULL)
+			*(int *)data = 0;
 #ifndef PIPE_NODIRECT
-		if (pipe->pipe_state & PIPE_DIRECTW)
+		else if (pipe->pipe_state & PIPE_DIRECTW)
 			*(int *)data = pipe->pipe_map.cnt;
 		else
 #endif
@@ -1120,8 +1122,11 @@ pipe_ioctl(file_t *fp, u_long cmd, void 
 
 	case FIONSPACE:
 		/* Look at other side */
-		pipe = pipe->pipe_peer;
 		mutex_enter(lock);
+		pipe = pipe->pipe_peer;
+		if (pipe == NULL)
+			*(int *)data = 0;
+		else
 #ifndef PIPE_NODIRECT
 		/*
 		 * If we're in direct-mode, we don't really have a
@@ -1346,6 +1351,8 @@ pipeclose(struct pipe *pipe)
 free_resources:
 	pipe->pipe_pgid = 0;
 	pipe->pipe_state = PIPE_SIGNALR;
+	pipe->pipe_peer = NULL;
+	pipe->pipe_lock = NULL;
 	pipe_free_kmem(pipe);
 	if (pipe->pipe_kmem != 0) {
 		pool_cache_put(pipe_rd_cache, pipe);



CVS commit: [netbsd-7] src/sys/kern

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:48:56 UTC 2019

Modified Files:
src/sys/kern [netbsd-7]: sys_pipe.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1692):

sys/kern/sys_pipe.c: revision 1.147
sys/kern/sys_pipe.c: revision 1.148

Clean up pipe structure before recycling it.

Handle half-closed pipes in FIONWRITE and FIONSPACE.


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.138.4.1 src/sys/kern/sys_pipe.c

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



CVS commit: [netbsd-7] src/sys/dev

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:47:05 UTC 2019

Added Files:
src/sys/dev [netbsd-7]: veriexec.config

Log Message:
Pull up following revision(s), via patch as options
differ on the branch (requested by sevan in ticket #1691):

sys/dev/veriexec.config: revision 1.1

Add a configuration file for enabling Veriexec in kernel config(5) files.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.4.2 src/sys/dev/veriexec.config

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

Added files:

Index: src/sys/dev/veriexec.config
diff -u /dev/null src/sys/dev/veriexec.config:1.1.4.2
--- /dev/null	Wed May  1 09:47:05 2019
+++ src/sys/dev/veriexec.config	Wed May  1 09:47:05 2019
@@ -0,0 +1,21 @@
+# $NetBSD: veriexec.config,v 1.1.4.2 2019/05/01 09:47:05 martin Exp $
+#
+# This file contains all Veriexec related configuration.
+# It is suitable for inclusion in a kernel config(5) file.
+#
+
+options 	FILEASSOC		# fileassoc(9) - needed by Veriexec
+	# and PAX_SEGVGUARD
+
+# a pseudo device needed for veriexec
+pseudo-device	veriexec
+#
+# Note that removing fingerprint methods will have almost no impact on the
+# kernel code size.
+#
+options VERIFIED_EXEC_FP_MD5
+options VERIFIED_EXEC_FP_RMD160
+options VERIFIED_EXEC_FP_SHA1
+options VERIFIED_EXEC_FP_SHA256
+options VERIFIED_EXEC_FP_SHA384
+options VERIFIED_EXEC_FP_SHA512



CVS commit: [netbsd-7] src/sys/dev

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:47:05 UTC 2019

Added Files:
src/sys/dev [netbsd-7]: veriexec.config

Log Message:
Pull up following revision(s), via patch as options
differ on the branch (requested by sevan in ticket #1691):

sys/dev/veriexec.config: revision 1.1

Add a configuration file for enabling Veriexec in kernel config(5) files.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.4.2 src/sys/dev/veriexec.config

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



CVS commit: [netbsd-7-1] src/doc

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:43:22 UTC 2019

Modified Files:
src/doc [netbsd-7-1]: CHANGES-7.1.3

Log Message:
Ticket #1690


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.47 -r1.1.2.48 src/doc/CHANGES-7.1.3

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

Modified files:

Index: src/doc/CHANGES-7.1.3
diff -u src/doc/CHANGES-7.1.3:1.1.2.47 src/doc/CHANGES-7.1.3:1.1.2.48
--- src/doc/CHANGES-7.1.3:1.1.2.47	Fri Apr 19 16:02:50 2019
+++ src/doc/CHANGES-7.1.3	Wed May  1 09:43:22 2019
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.3,v 1.1.2.47 2019/04/19 16:02:50 martin Exp $
+# $NetBSD: CHANGES-7.1.3,v 1.1.2.48 2019/05/01 09:43:22 martin Exp $
 
 A complete list of changes from the NetBSD 7.1.2 release to the NetBSD 7.1.3
 release:
@@ -480,3 +480,13 @@ sys/net/if.c	1.449 (patch)
 	of stack disclosure.
 	[christos, ticket #1689]
 
+external/bsd/dhcpcd/dist/src/auth.c			(apply patch)
+external/bsd/dhcpcd/dist/src/dhcp.c			(apply patch)
+external/bsd/dhcpcd/dist/src/dhcpcd.h			(apply patch) 
+  
+	Security fixes for dhcpcd:
+	Fix a potential 1 byte read overflow with DHO_OPTSOVERLOADED.
+	Use consttime_memequal(3) to compare hashes.
+	[roy, ticket #1690]
+
+



CVS commit: [netbsd-7-0] src/doc

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:43:37 UTC 2019

Modified Files:
src/doc [netbsd-7-0]: CHANGES-7.0.3

Log Message:
Ticket #1690


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.140 -r1.1.2.141 src/doc/CHANGES-7.0.3

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

Modified files:

Index: src/doc/CHANGES-7.0.3
diff -u src/doc/CHANGES-7.0.3:1.1.2.140 src/doc/CHANGES-7.0.3:1.1.2.141
--- src/doc/CHANGES-7.0.3:1.1.2.140	Fri Apr 19 16:05:05 2019
+++ src/doc/CHANGES-7.0.3	Wed May  1 09:43:37 2019
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.140 2019/04/19 16:05:05 martin Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.141 2019/05/01 09:43:37 martin Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -5788,3 +5788,12 @@ sys/net/if.c	1.449 (patch)
 	of stack disclosure.
 	[christos, ticket #1689]
 
+external/bsd/dhcpcd/dist/src/auth.c			(apply patch)
+external/bsd/dhcpcd/dist/src/dhcp.c			(apply patch)   
+external/bsd/dhcpcd/dist/src/dhcpcd.h			(apply patch)
+
+	Security fixes for dhcpcd:
+	Fix a potential 1 byte read overflow with DHO_OPTSOVERLOADED.
+	Use consttime_memequal(3) to compare hashes.
+	[roy, ticket #1690]
+



CVS commit: [netbsd-7-0] src/doc

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:43:37 UTC 2019

Modified Files:
src/doc [netbsd-7-0]: CHANGES-7.0.3

Log Message:
Ticket #1690


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.140 -r1.1.2.141 src/doc/CHANGES-7.0.3

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



CVS commit: [netbsd-7-1] src/doc

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:43:22 UTC 2019

Modified Files:
src/doc [netbsd-7-1]: CHANGES-7.1.3

Log Message:
Ticket #1690


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.47 -r1.1.2.48 src/doc/CHANGES-7.1.3

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



CVS commit: [isaki-audio2] src/sys/dev/pci

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 09:41:50 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: emuxki.c

Log Message:
Use __nothing macro.


To generate a diff of this commit:
cvs rdiff -u -r1.67.2.4 -r1.67.2.5 src/sys/dev/pci/emuxki.c

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



CVS commit: [isaki-audio2] src/sys/dev/pci

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 09:41:50 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: emuxki.c

Log Message:
Use __nothing macro.


To generate a diff of this commit:
cvs rdiff -u -r1.67.2.4 -r1.67.2.5 src/sys/dev/pci/emuxki.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/emuxki.c
diff -u src/sys/dev/pci/emuxki.c:1.67.2.4 src/sys/dev/pci/emuxki.c:1.67.2.5
--- src/sys/dev/pci/emuxki.c:1.67.2.4	Wed May  1 06:34:46 2019
+++ src/sys/dev/pci/emuxki.c	Wed May  1 09:41:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: emuxki.c,v 1.67.2.4 2019/05/01 06:34:46 isaki Exp $	*/
+/*	$NetBSD: emuxki.c,v 1.67.2.5 2019/05/01 09:41:50 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.4 2019/05/01 06:34:46 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.5 2019/05/01 09:41:50 isaki Exp $");
 
 #include 
 #include 
@@ -71,8 +71,8 @@ __KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1
 # define DPRINTF(fmt...)	do { if (emudebug) printf(fmt); } while (0)
 # define DPRINTFN(n,fmt...)	do { if (emudebug>=(n)) printf(fmt); } while (0)
 #else
-# define DPRINTF(fmt...)	do { } while (0)
-# define DPRINTFN(n,fmt...)	do { } while (0)
+# define DPRINTF(fmt...)	__nothing
+# define DPRINTFN(n,fmt...)	__nothing
 #endif
 
 /*



CVS commit: [netbsd-7-0] src/external/bsd/dhcpcd/dist

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:26:23 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist [netbsd-7-0]: auth.c dhcp.c dhcpcd.h

Log Message:
Apply patch, requested by roy in ticket #1690:

external/bsd/dhcpcd/dist/configure
external/bsd/dhcpcd/dist/src/auth.c
external/bsd/dhcpcd/dist/src/dhcp.c
external/bsd/dhcpcd/dist/src/dhcp6.c
external/bsd/dhcpcd/dist/compat/consttime_memequal.h

Security fixes for dhcpcd:
Fix a potential 1 byte read overflow with DHO_OPTSOVERLOADED.
Use consttime_memequal(3) to compare hashes.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.4.2.2 -r1.1.1.4.2.2.2.1 \
src/external/bsd/dhcpcd/dist/auth.c
cvs rdiff -u -r1.15.2.2 -r1.15.2.2.2.1 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.1.1.19.2.2 -r1.1.1.19.2.2.2.1 \
src/external/bsd/dhcpcd/dist/dhcpcd.h

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/dhcpcd/dist/auth.c
diff -u src/external/bsd/dhcpcd/dist/auth.c:1.1.1.4.2.2 src/external/bsd/dhcpcd/dist/auth.c:1.1.1.4.2.2.2.1
--- src/external/bsd/dhcpcd/dist/auth.c:1.1.1.4.2.2	Thu Feb  5 15:13:12 2015
+++ src/external/bsd/dhcpcd/dist/auth.c	Wed May  1 09:26:23 2019
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: auth.c,v 1.1.1.4.2.2 2015/02/05 15:13:12 martin Exp $");
+ __RCSID("$NetBSD: auth.c,v 1.1.1.4.2.2.2.1 2019/05/01 09:26:23 martin Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -340,7 +340,7 @@ gottoken:
 	}
 
 	free(mm);
-	if (memcmp(d, , dlen)) {
+	if (!consttime_memequal(d, , dlen)) {
 		errno = EPERM;
 		return NULL;
 	}

Index: src/external/bsd/dhcpcd/dist/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.15.2.2 src/external/bsd/dhcpcd/dist/dhcp.c:1.15.2.2.2.1
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.15.2.2	Thu Feb  5 15:13:12 2015
+++ src/external/bsd/dhcpcd/dist/dhcp.c	Wed May  1 09:26:23 2019
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: dhcp.c,v 1.15.2.2 2015/02/05 15:13:12 martin Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.15.2.2.2.1 2019/05/01 09:26:23 martin Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -166,28 +166,6 @@ get_option(struct dhcpcd_ctx *ctx,
 
 	while (p < e) {
 		o = *p++;
-		if (o == opt) {
-			if (op) {
-if (!ctx->opt_buffer) {
-	ctx->opt_buffer =
-	malloc(DHCP_OPTION_LEN +
-	BOOTFILE_LEN + SERVERNAME_LEN);
-	if (ctx->opt_buffer == NULL)
-		return NULL;
-}
-if (!bp)
-	bp = ctx->opt_buffer;
-memcpy(bp, op, ol);
-bp += ol;
-			}
-			ol = *p;
-			if (p + ol > e) {
-errno = EINVAL;
-return NULL;
-			}
-			op = p + 1;
-			bl += ol;
-		}
 		switch (o) {
 		case DHO_PAD:
 			continue;
@@ -205,16 +183,58 @@ get_option(struct dhcpcd_ctx *ctx,
 			} else
 goto exit;
 			break;
-		case DHO_OPTIONSOVERLOADED:
+		}
+
+		/* Check we can read the length */
+		if (p == e) {
+			errno = EINVAL;
+			return NULL;
+		}
+		l = *p++;
+
+		/* Check we can read the option data, if present */
+		if (p + l > e) {
+			errno = EINVAL;
+			return NULL;
+		}
+
+		if (o == DHO_OPTIONSOVERLOADED) {
 			/* Ensure we only get this option once by setting
 			 * the last bit as well as the value.
 			 * This is valid because only the first two bits
 			 * actually mean anything in RFC2132 Section 9.3 */
-			if (!overl)
-overl = 0x80 | p[1];
-			break;
+			if (l == 1 && !overl)
+overl = 0x80 | p[0];
+		}
+
+		if (o == opt) {
+			if (op) {
+/* We must concatonate the options. */
+if (bl + l > ctx->opt_buffer_len) {
+	size_t pos;
+	uint8_t *nb;
+
+	if (bp)
+		pos = (size_t)
+		(bp - ctx->opt_buffer);
+	else
+		pos = 0;
+	nb = realloc(ctx->opt_buffer, bl + l);
+	if (nb == NULL)
+		return NULL;
+	ctx->opt_buffer = nb;
+	ctx->opt_buffer_len = bl + l;
+	bp = ctx->opt_buffer + pos;
+}
+if (bp == NULL)
+	bp = ctx->opt_buffer;
+memcpy(bp, op, ol);
+bp += ol;
+			}
+			ol = l;
+			op = p;
+			bl += ol;
 		}
-		l = *p++;
 		p += l;
 	}
 

Index: src/external/bsd/dhcpcd/dist/dhcpcd.h
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.h:1.1.1.19.2.2 src/external/bsd/dhcpcd/dist/dhcpcd.h:1.1.1.19.2.2.2.1
--- src/external/bsd/dhcpcd/dist/dhcpcd.h:1.1.1.19.2.2	Thu Feb  5 15:13:12 2015
+++ src/external/bsd/dhcpcd/dist/dhcpcd.h	Wed May  1 09:26:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcpcd.h,v 1.1.1.19.2.2 2015/02/05 15:13:12 martin Exp $ */
+/* $NetBSD: dhcpcd.h,v 1.1.1.19.2.2.2.1 2019/05/01 09:26:23 martin Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -131,6 +131,7 @@ struct dhcpcd_ctx {
 	 * We ONLY use this when options are split, which for most purposes is
 	 * practically never. See RFC3396 for details. */
 	uint8_t *opt_buffer;
+	size_t opt_buffer_len;
 #endif
 #ifdef INET6
 	unsigned char secret[SECRET_LEN];



CVS commit: [netbsd-7-0] src/external/bsd/dhcpcd/dist

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:26:23 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist [netbsd-7-0]: auth.c dhcp.c dhcpcd.h

Log Message:
Apply patch, requested by roy in ticket #1690:

external/bsd/dhcpcd/dist/configure
external/bsd/dhcpcd/dist/src/auth.c
external/bsd/dhcpcd/dist/src/dhcp.c
external/bsd/dhcpcd/dist/src/dhcp6.c
external/bsd/dhcpcd/dist/compat/consttime_memequal.h

Security fixes for dhcpcd:
Fix a potential 1 byte read overflow with DHO_OPTSOVERLOADED.
Use consttime_memequal(3) to compare hashes.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.4.2.2 -r1.1.1.4.2.2.2.1 \
src/external/bsd/dhcpcd/dist/auth.c
cvs rdiff -u -r1.15.2.2 -r1.15.2.2.2.1 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.1.1.19.2.2 -r1.1.1.19.2.2.2.1 \
src/external/bsd/dhcpcd/dist/dhcpcd.h

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



CVS commit: [netbsd-7-1] src/external/bsd/dhcpcd/dist

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:25:16 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist [netbsd-7-1]: auth.c dhcp.c dhcpcd.h

Log Message:
Apply patch, requested by roy in ticket #1690:

external/bsd/dhcpcd/dist/configure
external/bsd/dhcpcd/dist/src/auth.c
external/bsd/dhcpcd/dist/src/dhcp.c
external/bsd/dhcpcd/dist/src/dhcp6.c
external/bsd/dhcpcd/dist/compat/consttime_memequal.h

Security fixes for dhcpcd:
Fix a potential 1 byte read overflow with DHO_OPTSOVERLOADED.
Use consttime_memequal(3) to compare hashes.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.4.2.2 -r1.1.1.4.2.2.6.1 \
src/external/bsd/dhcpcd/dist/auth.c
cvs rdiff -u -r1.15.2.2 -r1.15.2.2.6.1 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.1.1.19.2.2 -r1.1.1.19.2.2.6.1 \
src/external/bsd/dhcpcd/dist/dhcpcd.h

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/dhcpcd/dist/auth.c
diff -u src/external/bsd/dhcpcd/dist/auth.c:1.1.1.4.2.2 src/external/bsd/dhcpcd/dist/auth.c:1.1.1.4.2.2.6.1
--- src/external/bsd/dhcpcd/dist/auth.c:1.1.1.4.2.2	Thu Feb  5 15:13:12 2015
+++ src/external/bsd/dhcpcd/dist/auth.c	Wed May  1 09:25:16 2019
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: auth.c,v 1.1.1.4.2.2 2015/02/05 15:13:12 martin Exp $");
+ __RCSID("$NetBSD: auth.c,v 1.1.1.4.2.2.6.1 2019/05/01 09:25:16 martin Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -340,7 +340,7 @@ gottoken:
 	}
 
 	free(mm);
-	if (memcmp(d, , dlen)) {
+	if (!consttime_memequal(d, , dlen)) {
 		errno = EPERM;
 		return NULL;
 	}

Index: src/external/bsd/dhcpcd/dist/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.15.2.2 src/external/bsd/dhcpcd/dist/dhcp.c:1.15.2.2.6.1
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.15.2.2	Thu Feb  5 15:13:12 2015
+++ src/external/bsd/dhcpcd/dist/dhcp.c	Wed May  1 09:25:16 2019
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: dhcp.c,v 1.15.2.2 2015/02/05 15:13:12 martin Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.15.2.2.6.1 2019/05/01 09:25:16 martin Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -166,28 +166,6 @@ get_option(struct dhcpcd_ctx *ctx,
 
 	while (p < e) {
 		o = *p++;
-		if (o == opt) {
-			if (op) {
-if (!ctx->opt_buffer) {
-	ctx->opt_buffer =
-	malloc(DHCP_OPTION_LEN +
-	BOOTFILE_LEN + SERVERNAME_LEN);
-	if (ctx->opt_buffer == NULL)
-		return NULL;
-}
-if (!bp)
-	bp = ctx->opt_buffer;
-memcpy(bp, op, ol);
-bp += ol;
-			}
-			ol = *p;
-			if (p + ol > e) {
-errno = EINVAL;
-return NULL;
-			}
-			op = p + 1;
-			bl += ol;
-		}
 		switch (o) {
 		case DHO_PAD:
 			continue;
@@ -205,16 +183,58 @@ get_option(struct dhcpcd_ctx *ctx,
 			} else
 goto exit;
 			break;
-		case DHO_OPTIONSOVERLOADED:
+		}
+
+		/* Check we can read the length */
+		if (p == e) {
+			errno = EINVAL;
+			return NULL;
+		}
+		l = *p++;
+
+		/* Check we can read the option data, if present */
+		if (p + l > e) {
+			errno = EINVAL;
+			return NULL;
+		}
+
+		if (o == DHO_OPTIONSOVERLOADED) {
 			/* Ensure we only get this option once by setting
 			 * the last bit as well as the value.
 			 * This is valid because only the first two bits
 			 * actually mean anything in RFC2132 Section 9.3 */
-			if (!overl)
-overl = 0x80 | p[1];
-			break;
+			if (l == 1 && !overl)
+overl = 0x80 | p[0];
+		}
+
+		if (o == opt) {
+			if (op) {
+/* We must concatonate the options. */
+if (bl + l > ctx->opt_buffer_len) {
+	size_t pos;
+	uint8_t *nb;
+
+	if (bp)
+		pos = (size_t)
+		(bp - ctx->opt_buffer);
+	else
+		pos = 0;
+	nb = realloc(ctx->opt_buffer, bl + l);
+	if (nb == NULL)
+		return NULL;
+	ctx->opt_buffer = nb;
+	ctx->opt_buffer_len = bl + l;
+	bp = ctx->opt_buffer + pos;
+}
+if (bp == NULL)
+	bp = ctx->opt_buffer;
+memcpy(bp, op, ol);
+bp += ol;
+			}
+			ol = l;
+			op = p;
+			bl += ol;
 		}
-		l = *p++;
 		p += l;
 	}
 

Index: src/external/bsd/dhcpcd/dist/dhcpcd.h
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.h:1.1.1.19.2.2 src/external/bsd/dhcpcd/dist/dhcpcd.h:1.1.1.19.2.2.6.1
--- src/external/bsd/dhcpcd/dist/dhcpcd.h:1.1.1.19.2.2	Thu Feb  5 15:13:12 2015
+++ src/external/bsd/dhcpcd/dist/dhcpcd.h	Wed May  1 09:25:16 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcpcd.h,v 1.1.1.19.2.2 2015/02/05 15:13:12 martin Exp $ */
+/* $NetBSD: dhcpcd.h,v 1.1.1.19.2.2.6.1 2019/05/01 09:25:16 martin Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -131,6 +131,7 @@ struct dhcpcd_ctx {
 	 * We ONLY use this when options are split, which for most purposes is
 	 * practically never. See RFC3396 for details. */
 	uint8_t *opt_buffer;
+	size_t opt_buffer_len;
 #endif
 #ifdef INET6
 	unsigned char secret[SECRET_LEN];



CVS commit: [netbsd-7-1] src/external/bsd/dhcpcd/dist

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:25:16 UTC 2019

Modified Files:
src/external/bsd/dhcpcd/dist [netbsd-7-1]: auth.c dhcp.c dhcpcd.h

Log Message:
Apply patch, requested by roy in ticket #1690:

external/bsd/dhcpcd/dist/configure
external/bsd/dhcpcd/dist/src/auth.c
external/bsd/dhcpcd/dist/src/dhcp.c
external/bsd/dhcpcd/dist/src/dhcp6.c
external/bsd/dhcpcd/dist/compat/consttime_memequal.h

Security fixes for dhcpcd:
Fix a potential 1 byte read overflow with DHO_OPTSOVERLOADED.
Use consttime_memequal(3) to compare hashes.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.4.2.2 -r1.1.1.4.2.2.6.1 \
src/external/bsd/dhcpcd/dist/auth.c
cvs rdiff -u -r1.15.2.2 -r1.15.2.2.6.1 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.1.1.19.2.2 -r1.1.1.19.2.2.6.1 \
src/external/bsd/dhcpcd/dist/dhcpcd.h

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



CVS commit: src

2019-05-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May  1 09:20:21 UTC 2019

Modified Files:
src/lib/libnvmm: libnvmm.c
src/sys/dev/nvmm: nvmm.c nvmm.h nvmm_internal.h nvmm_ioctl.h
src/sys/dev/nvmm/x86: nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c

Log Message:
Use the comm page to inject events, rather than ioctls, and commit them in
vcpu_run. This saves a few syscalls and copyins.

For example on Windows 10, moving the mouse from the left to right sides of
the screen generates ~500 events, which now don't result in syscalls.

The error handling is done in vcpu_run and it is less precise, but this
doesn't matter a lot, and will be solved with future NVMM error codes.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libnvmm/libnvmm.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/nvmm/nvmm.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/nvmm/nvmm.h
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/nvmm/nvmm_internal.h
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/nvmm/nvmm_ioctl.h
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/nvmm/x86/nvmm_x86.h
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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

Modified files:

Index: src/lib/libnvmm/libnvmm.c
diff -u src/lib/libnvmm/libnvmm.c:1.11 src/lib/libnvmm/libnvmm.c:1.12
--- src/lib/libnvmm/libnvmm.c:1.11	Mon Apr 29 17:27:57 2019
+++ src/lib/libnvmm/libnvmm.c	Wed May  1 09:20:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: libnvmm.c,v 1.11 2019/04/29 17:27:57 maxv Exp $	*/
+/*	$NetBSD: libnvmm.c,v 1.12 2019/05/01 09:20:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -362,16 +362,15 @@ int
 nvmm_vcpu_inject(struct nvmm_machine *mach, nvmm_cpuid_t cpuid,
 struct nvmm_event *event)
 {
-	struct nvmm_ioc_vcpu_inject args;
-	int ret;
-
-	args.machid = mach->machid;
-	args.cpuid = cpuid;
-	memcpy(, event, sizeof(args.event));
+	struct nvmm_comm_page *comm;
 
-	ret = ioctl(nvmm_fd, NVMM_IOC_VCPU_INJECT, );
-	if (ret == -1)
+	if (__predict_false(cpuid >= mach->npages)) {
 		return -1;
+	}
+	comm = mach->pages[cpuid];
+
+	memcpy(>event, event, sizeof(comm->event));
+	comm->event_commit = true;
 
 	return 0;
 }

Index: src/sys/dev/nvmm/nvmm.c
diff -u src/sys/dev/nvmm/nvmm.c:1.19 src/sys/dev/nvmm/nvmm.c:1.20
--- src/sys/dev/nvmm/nvmm.c:1.19	Sun Apr 28 14:22:13 2019
+++ src/sys/dev/nvmm/nvmm.c	Wed May  1 09:20:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm.c,v 1.19 2019/04/28 14:22:13 maxv Exp $	*/
+/*	$NetBSD: nvmm.c,v 1.20 2019/05/01 09:20:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.19 2019/04/28 14:22:13 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.20 2019/05/01 09:20:21 maxv Exp $");
 
 #include 
 #include 
@@ -503,7 +503,7 @@ nvmm_vcpu_inject(struct nvmm_owner *owne
 	if (error)
 		goto out;
 
-	error = (*nvmm_impl->vcpu_inject)(mach, vcpu, >event);
+	error = (*nvmm_impl->vcpu_inject)(vcpu);
 	nvmm_vcpu_put(vcpu);
 
 out:

Index: src/sys/dev/nvmm/nvmm.h
diff -u src/sys/dev/nvmm/nvmm.h:1.8 src/sys/dev/nvmm/nvmm.h:1.9
--- src/sys/dev/nvmm/nvmm.h:1.8	Sun Apr 28 14:22:13 2019
+++ src/sys/dev/nvmm/nvmm.h	Wed May  1 09:20:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm.h,v 1.8 2019/04/28 14:22:13 maxv Exp $	*/
+/*	$NetBSD: nvmm.h,v 1.9 2019/05/01 09:20:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -94,6 +94,18 @@ struct nvmm_capability {
 	struct nvmm_cap_md arch;
 };
 
+struct nvmm_comm_page {
+	/* State. */
+	uint64_t state_wanted;
+	uint64_t state_cached;
+	uint64_t state_commit;
+	struct nvmm_vcpu_state state;
+
+	/* Event. */
+	bool event_commit;
+	struct nvmm_event event;
+};
+
 /*
  * Bits 20:27 -> machid
  * Bits 12:19 -> cpuid

Index: src/sys/dev/nvmm/nvmm_internal.h
diff -u src/sys/dev/nvmm/nvmm_internal.h:1.10 src/sys/dev/nvmm/nvmm_internal.h:1.11
--- src/sys/dev/nvmm/nvmm_internal.h:1.10	Sun Apr 28 14:22:13 2019
+++ src/sys/dev/nvmm/nvmm_internal.h	Wed May  1 09:20:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_internal.h,v 1.10 2019/04/28 14:22:13 maxv Exp $	*/
+/*	$NetBSD: nvmm_internal.h,v 1.11 2019/05/01 09:20:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -107,8 +107,7 @@ struct nvmm_impl {
 	void (*vcpu_destroy)(struct nvmm_machine *, struct nvmm_cpu *);
 	void (*vcpu_setstate)(struct nvmm_cpu *);
 	void (*vcpu_getstate)(struct nvmm_cpu *);
-	int (*vcpu_inject)(struct nvmm_machine *, struct nvmm_cpu *,
-	struct nvmm_event *);
+	int (*vcpu_inject)(struct nvmm_cpu *);
 	int (*vcpu_run)(struct nvmm_machine *, struct nvmm_cpu *,
 	struct nvmm_exit *);
 };

Index: src/sys/dev/nvmm/nvmm_ioctl.h
diff -u src/sys/dev/nvmm/nvmm_ioctl.h:1.6 src/sys/dev/nvmm/nvmm_ioctl.h:1.7
--- src/sys/dev/nvmm/nvmm_ioctl.h:1.6	Sun Apr 28 14:22:13 2019
+++ src/sys/dev/nvmm/nvmm_ioctl.h	Wed May  1 

CVS commit: src

2019-05-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May  1 09:20:21 UTC 2019

Modified Files:
src/lib/libnvmm: libnvmm.c
src/sys/dev/nvmm: nvmm.c nvmm.h nvmm_internal.h nvmm_ioctl.h
src/sys/dev/nvmm/x86: nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c

Log Message:
Use the comm page to inject events, rather than ioctls, and commit them in
vcpu_run. This saves a few syscalls and copyins.

For example on Windows 10, moving the mouse from the left to right sides of
the screen generates ~500 events, which now don't result in syscalls.

The error handling is done in vcpu_run and it is less precise, but this
doesn't matter a lot, and will be solved with future NVMM error codes.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libnvmm/libnvmm.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/nvmm/nvmm.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/nvmm/nvmm.h
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/nvmm/nvmm_internal.h
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/nvmm/nvmm_ioctl.h
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/nvmm/x86/nvmm_x86.h
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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



CVS commit: [netbsd-8] src/doc

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:13:31 UTC 2019

Modified Files:
src/doc [netbsd-8]: CHANGES-8.1

Log Message:
Tickets #1251 - #1253


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.137 -r1.1.2.138 src/doc/CHANGES-8.1

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

Modified files:

Index: src/doc/CHANGES-8.1
diff -u src/doc/CHANGES-8.1:1.1.2.137 src/doc/CHANGES-8.1:1.1.2.138
--- src/doc/CHANGES-8.1:1.1.2.137	Sun Apr 28 08:46:17 2019
+++ src/doc/CHANGES-8.1	Wed May  1 09:13:31 2019
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.1,v 1.1.2.137 2019/04/28 08:46:17 martin Exp $
+# $NetBSD: CHANGES-8.1,v 1.1.2.138 2019/05/01 09:13:31 martin Exp $
 
 A complete list of changes from the NetBSD 8.0 release to the NetBSD 8.1
 release:
@@ -3046,3 +3046,21 @@ external/bsd/dhcpcd/sbin/dhcpcd/Makefile
 	Import dhcpcd-7.2.1.
 	[roy, ticket #1250]
 
+sys/dev/veriexec.config1.1 (patch)
+
+	Add a configuration file for enabling Veriexec in kernel config(5)
+	files.
+	[sevan, ticket #1251]
+
+distrib/amd64/ramdisks/ramdisk-cgdroot/list	1.2
+distrib/i386/ramdisks/ramdisk-cgdroot/list	1.2
+
+	Add a symlink to /altroot/stand to help the kernel find modules.
+	[alnsn, ticket #1252]
+
+sys/kern/sys_pipe.c1.147,1.148
+
+	Clean up pipe structure before recycling it.
+	Handle half-closed pipes in FIONWRITE and FIONSPACE.
+	[mlelstv, ticket #1253]
+



CVS commit: [netbsd-8] src/doc

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:13:31 UTC 2019

Modified Files:
src/doc [netbsd-8]: CHANGES-8.1

Log Message:
Tickets #1251 - #1253


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.137 -r1.1.2.138 src/doc/CHANGES-8.1

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



CVS commit: [netbsd-8] src/distrib

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:09:33 UTC 2019

Modified Files:
src/distrib/amd64/ramdisks/ramdisk-cgdroot [netbsd-8]: list
src/distrib/i386/ramdisks/ramdisk-cgdroot [netbsd-8]: list

Log Message:
Pull up following revision(s) (requested by alnsn in ticket #1252):

distrib/amd64/ramdisks/ramdisk-cgdroot/list: revision 1.2
distrib/i386/ramdisks/ramdisk-cgdroot/list: revision 1.2

Add a symlink to /altroot/stand to help the kernel find modules.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.24.1 src/distrib/amd64/ramdisks/ramdisk-cgdroot/list
cvs rdiff -u -r1.1 -r1.1.24.1 src/distrib/i386/ramdisks/ramdisk-cgdroot/list

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

Modified files:

Index: src/distrib/amd64/ramdisks/ramdisk-cgdroot/list
diff -u src/distrib/amd64/ramdisks/ramdisk-cgdroot/list:1.1 src/distrib/amd64/ramdisks/ramdisk-cgdroot/list:1.1.24.1
--- src/distrib/amd64/ramdisks/ramdisk-cgdroot/list:1.1	Mon Jul 15 00:22:10 2013
+++ src/distrib/amd64/ramdisks/ramdisk-cgdroot/list	Wed May  1 09:09:33 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: list,v 1.1 2013/07/15 00:22:10 khorben Exp $
+#	$NetBSD: list,v 1.1.24.1 2019/05/01 09:09:33 martin Exp $
 
 PROG	bin/chio
 PROG	bin/dd
@@ -30,3 +30,5 @@ PROG	usr/bin/tip
 PROG	usr/sbin/installboot
 
 PROG	usr/sbin/wiconfig
+
+SYMLINK	/altroot/stand	stand

Index: src/distrib/i386/ramdisks/ramdisk-cgdroot/list
diff -u src/distrib/i386/ramdisks/ramdisk-cgdroot/list:1.1 src/distrib/i386/ramdisks/ramdisk-cgdroot/list:1.1.24.1
--- src/distrib/i386/ramdisks/ramdisk-cgdroot/list:1.1	Tue Jul 16 02:10:43 2013
+++ src/distrib/i386/ramdisks/ramdisk-cgdroot/list	Wed May  1 09:09:33 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: list,v 1.1 2013/07/16 02:10:43 khorben Exp $
+#	$NetBSD: list,v 1.1.24.1 2019/05/01 09:09:33 martin Exp $
 
 PROG	bin/chio
 PROG	bin/dd
@@ -30,3 +30,5 @@ PROG	usr/bin/tip
 PROG	usr/sbin/installboot
 
 PROG	usr/sbin/wiconfig
+
+SYMLINK	/altroot/stand	stand



CVS commit: [netbsd-8] src/distrib

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:09:33 UTC 2019

Modified Files:
src/distrib/amd64/ramdisks/ramdisk-cgdroot [netbsd-8]: list
src/distrib/i386/ramdisks/ramdisk-cgdroot [netbsd-8]: list

Log Message:
Pull up following revision(s) (requested by alnsn in ticket #1252):

distrib/amd64/ramdisks/ramdisk-cgdroot/list: revision 1.2
distrib/i386/ramdisks/ramdisk-cgdroot/list: revision 1.2

Add a symlink to /altroot/stand to help the kernel find modules.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.24.1 src/distrib/amd64/ramdisks/ramdisk-cgdroot/list
cvs rdiff -u -r1.1 -r1.1.24.1 src/distrib/i386/ramdisks/ramdisk-cgdroot/list

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



CVS commit: [netbsd-8] src/sys/dev

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:04:24 UTC 2019

Added Files:
src/sys/dev [netbsd-8]: veriexec.config

Log Message:
Pull up following revision(s) via patch, as options differ between
current and this branch (requested by sevan in ticket #1251):

sys/dev/veriexec.config: revision 1.1

Add a configuration file for enabling Veriexec in kernel config(5) files.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.2 src/sys/dev/veriexec.config

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

Added files:

Index: src/sys/dev/veriexec.config
diff -u /dev/null src/sys/dev/veriexec.config:1.1.2.2
--- /dev/null	Wed May  1 09:04:24 2019
+++ src/sys/dev/veriexec.config	Wed May  1 09:04:24 2019
@@ -0,0 +1,21 @@
+# $NetBSD: veriexec.config,v 1.1.2.2 2019/05/01 09:04:24 martin Exp $
+#
+# This file contains all Veriexec related configuration.
+# It is suitable for inclusion in a kernel config(5) file.
+#
+
+options 	FILEASSOC		# fileassoc(9) - needed by Veriexec
+	# and PAX_SEGVGUARD
+
+# a pseudo device needed for veriexec
+pseudo-device	veriexec
+#
+# Note that removing fingerprint methods will have almost no impact on the
+# kernel code size.
+#
+options VERIFIED_EXEC_FP_MD5
+options VERIFIED_EXEC_FP_RMD160
+options VERIFIED_EXEC_FP_SHA1
+options VERIFIED_EXEC_FP_SHA256
+options VERIFIED_EXEC_FP_SHA384
+options VERIFIED_EXEC_FP_SHA512



CVS commit: [netbsd-8] src/sys/dev

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:04:24 UTC 2019

Added Files:
src/sys/dev [netbsd-8]: veriexec.config

Log Message:
Pull up following revision(s) via patch, as options differ between
current and this branch (requested by sevan in ticket #1251):

sys/dev/veriexec.config: revision 1.1

Add a configuration file for enabling Veriexec in kernel config(5) files.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.2 src/sys/dev/veriexec.config

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



CVS commit: src/sys/modules/vnd

2019-05-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May  1 08:53:00 UTC 2019

Modified Files:
src/sys/modules/vnd: Makefile

Log Message:
No need to define COMPAT_50 any longer.  All the compat decisions are
made with HOOKs.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/modules/vnd/Makefile

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

Modified files:

Index: src/sys/modules/vnd/Makefile
diff -u src/sys/modules/vnd/Makefile:1.5 src/sys/modules/vnd/Makefile:1.6
--- src/sys/modules/vnd/Makefile:1.5	Sun Feb 17 04:06:00 2019
+++ src/sys/modules/vnd/Makefile	Wed May  1 08:53:00 2019
@@ -1,8 +1,8 @@
-#	$NetBSD: Makefile,v 1.5 2019/02/17 04:06:00 rin Exp $
+#	$NetBSD: Makefile,v 1.6 2019/05/01 08:53:00 pgoyette Exp $
 
 .include "../Makefile.inc"
 
-CPPFLAGS+= -DVND_COMPRESSION -DCOMPAT_50
+CPPFLAGS+= -DVND_COMPRESSION
 
 .PATH:	${S}/dev
 



CVS commit: src/sys/modules/vnd

2019-05-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May  1 08:53:00 UTC 2019

Modified Files:
src/sys/modules/vnd: Makefile

Log Message:
No need to define COMPAT_50 any longer.  All the compat decisions are
made with HOOKs.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/modules/vnd/Makefile

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



CVS commit: src/share/man/man4/man4.amiga

2019-05-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed May  1 07:40:53 UTC 2019

Modified Files:
src/share/man/man4/man4.amiga: a2kbbc.4

Log Message:
Fix casing in Dt. Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/man4.amiga/a2kbbc.4

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



CVS commit: src/share/man/man4/man4.amiga

2019-05-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed May  1 07:40:53 UTC 2019

Modified Files:
src/share/man/man4/man4.amiga: a2kbbc.4

Log Message:
Fix casing in Dt. Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/man4.amiga/a2kbbc.4

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

Modified files:

Index: src/share/man/man4/man4.amiga/a2kbbc.4
diff -u src/share/man/man4/man4.amiga/a2kbbc.4:1.1 src/share/man/man4/man4.amiga/a2kbbc.4:1.2
--- src/share/man/man4/man4.amiga/a2kbbc.4:1.1	Wed May  1 06:47:45 2019
+++ src/share/man/man4/man4.amiga/a2kbbc.4	Wed May  1 07:40:52 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: a2kbbc.4,v 1.1 2019/05/01 06:47:45 mlelstv Exp $
+.\" $NetBSD: a2kbbc.4,v 1.2 2019/05/01 07:40:52 wiz Exp $
 .\"
 .\" Copyright (c) 2019 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .Dd April 7, 2019
-.Dt a2kbbc 4 amiga
+.Dt A2KBBC 4 amiga
 .Os
 .Sh NAME
 .Nm a2kbbc
@@ -35,7 +35,7 @@
 .Sh DESCRIPTION
 The
 .Nm
-real-time clock driver provides support for the OKI M6264 chip fond
+real-time clock driver provides support for the OKI M6264 chip found
 in A500/A2000 class machines.
 .Sh SEE ALSO
 .Xr todr 9



CVS commit: src/share/man/man4/man4.amiga

2019-05-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed May  1 07:40:20 UTC 2019

Modified Files:
src/share/man/man4/man4.amiga: drbbc.4

Log Message:
Fix casing in Dt.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/man4.amiga/drbbc.4

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

Modified files:

Index: src/share/man/man4/man4.amiga/drbbc.4
diff -u src/share/man/man4/man4.amiga/drbbc.4:1.1 src/share/man/man4/man4.amiga/drbbc.4:1.2
--- src/share/man/man4/man4.amiga/drbbc.4:1.1	Wed May  1 06:47:45 2019
+++ src/share/man/man4/man4.amiga/drbbc.4	Wed May  1 07:40:20 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: drbbc.4,v 1.1 2019/05/01 06:47:45 mlelstv Exp $
+.\" $NetBSD: drbbc.4,v 1.2 2019/05/01 07:40:20 wiz Exp $
 .\"
 .\" Copyright (c) 2019 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .Dd April 7, 2019
-.Dt drbbc 4 amiga
+.Dt DRBBC 4 amiga
 .Os
 .Sh NAME
 .Nm drbbc



CVS commit: src/share/man/man4/man4.amiga

2019-05-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed May  1 07:40:39 UTC 2019

Modified Files:
src/share/man/man4/man4.amiga: a34kbbc.4

Log Message:
Fix casing in Dt. Fix SYNOPSIS. Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/man4.amiga/a34kbbc.4

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



CVS commit: src/share/man/man4/man4.amiga

2019-05-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed May  1 07:40:39 UTC 2019

Modified Files:
src/share/man/man4/man4.amiga: a34kbbc.4

Log Message:
Fix casing in Dt. Fix SYNOPSIS. Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/man4.amiga/a34kbbc.4

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

Modified files:

Index: src/share/man/man4/man4.amiga/a34kbbc.4
diff -u src/share/man/man4/man4.amiga/a34kbbc.4:1.1 src/share/man/man4/man4.amiga/a34kbbc.4:1.2
--- src/share/man/man4/man4.amiga/a34kbbc.4:1.1	Wed May  1 06:47:45 2019
+++ src/share/man/man4/man4.amiga/a34kbbc.4	Wed May  1 07:40:39 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: a34kbbc.4,v 1.1 2019/05/01 06:47:45 mlelstv Exp $
+.\" $NetBSD: a34kbbc.4,v 1.2 2019/05/01 07:40:39 wiz Exp $
 .\"
 .\" Copyright (c) 2019 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -25,18 +25,17 @@
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .Dd April 7, 2019
-.Dt a34kbbc 4 amiga
+.Dt A34KBBC 4 amiga
 .Os
 .Sh NAME
-.Nm
-.Nd Amiga 3000/4000 on-board real-time clock
 .Nm a34kbbc
+.Nd Amiga 3000/4000 on-board real-time clock
 .Sh SYNOPSIS
 .Cd "a34kbbc at mainbus0"
 .Sh DESCRIPTION
 The
 .Nm
-real-time clock driver provides support for the Ricoh RP5C01 chip fond
+real-time clock driver provides support for the Ricoh RP5C01 chip found
 in A3000/A4000 class machines.
 .Sh SEE ALSO
 .Xr todr 9



CVS commit: src/share/man/man4/man4.amiga

2019-05-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed May  1 07:40:20 UTC 2019

Modified Files:
src/share/man/man4/man4.amiga: drbbc.4

Log Message:
Fix casing in Dt.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/man4.amiga/drbbc.4

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



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

2019-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:26:28 UTC 2019

Modified Files:
src/sys/arch/x86/acpi: acpi_machdep.c

Log Message:
Handle ISA/EISA interrupts like isa_machdep.c.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/x86/acpi/acpi_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/x86/acpi/acpi_machdep.c
diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.25 src/sys/arch/x86/acpi/acpi_machdep.c:1.26
--- src/sys/arch/x86/acpi/acpi_machdep.c:1.25	Sat Mar  9 10:04:41 2019
+++ src/sys/arch/x86/acpi/acpi_machdep.c	Wed May  1 07:26:28 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.25 2019/03/09 10:04:41 kre Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.26 2019/05/01 07:26:28 mlelstv Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.25 2019/03/09 10:04:41 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.26 2019/05/01 07:26:28 mlelstv Exp $");
 
 #include 
 #include 
@@ -174,11 +174,12 @@ acpi_md_intr_establish(uint32_t Interrup
 {
 	void *ih;
 	struct pic *pic;
-	int irq, pin;
+	int irq = InterruptNumber, pin;
 #if NIOAPIC > 0
-	struct ioapic_softc *sc;
+	struct ioapic_softc *ioapic;
 	struct acpi_md_override ovr;
 	struct mp_intr_map tmpmap, *mip, **mipp = NULL;
+	intr_handle_t mpih;
 	int redir, mpflags;
 
 	/*
@@ -188,12 +189,11 @@ acpi_md_intr_establish(uint32_t Interrup
 	mpflags = (MPS_INTTR_LEVEL << 2) | MPS_INTPO_ACTLO;
 	redir = IOAPIC_REDLO_LEVEL | IOAPIC_REDLO_ACTLO;
 
-
 	/*
 	 * Apply any MADT override setting.
 	 */
 
-	ovr.irq = InterruptNumber;
+	ovr.irq = irq;
 	ovr.pin = -1;
 	if (acpi_madt_map() == AE_OK) {
 		acpi_madt_walk(acpi_md_findoverride, );
@@ -203,11 +203,11 @@ acpi_md_intr_establish(uint32_t Interrup
 	}
 
 	if (ovr.pin != -1) {
-		bool sci = InterruptNumber == AcpiGbl_FADT.SciInterrupt;
+		bool sci = irq == AcpiGbl_FADT.SciInterrupt;
 		int polarity = ovr.flags & ACPI_MADT_POLARITY_MASK;
 		int trigger = ovr.flags & ACPI_MADT_TRIGGER_MASK;
 
-		InterruptNumber = ovr.pin;
+		irq = ovr.pin;
 		if (polarity == ACPI_MADT_POLARITY_ACTIVE_HIGH ||
 		(!sci && polarity == ACPI_MADT_POLARITY_CONFORMS)) {
 			mpflags &= ~MPS_INTPO_ACTLO;
@@ -223,40 +223,63 @@ acpi_md_intr_establish(uint32_t Interrup
 		}
 	}
 
+	pic = NULL;
+	pin = irq;
+
 	/*
 	 * If the interrupt is handled via IOAPIC, update the map.
 	 * If the map isn't set up yet, install a temporary one.
+	 * Identify ISA & EISA interrupts
 	 */
-
-	sc = ioapic_find_bybase(InterruptNumber);
-	if (sc != NULL) {
-		pic = >sc_pic;
-
-		if (pic->pic_type == PIC_IOAPIC) {
-			pin = (int)InterruptNumber - pic->pic_vecbase;
-			irq = -1;
-		} else {
-			irq = pin = (int)InterruptNumber;
+	if (mp_busses != NULL) {
+		if (intr_find_mpmapping(mp_isa_bus, irq, ) == 0 ||
+		intr_find_mpmapping(mp_eisa_bus, irq, ) == 0) {
+			if (!APIC_IRQ_ISLEGACY(mpih)) {
+pin = APIC_IRQ_PIN(mpih);
+ioapic = ioapic_find(APIC_IRQ_APIC(mpih));
+if (ioapic != NULL)
+	pic = >sc_pic;
+			}
 		}
+	}
 
-		mip = sc->sc_pins[pin].ip_map;
-		if (mip) {
-			mip->flags &= ~0xf;
-			mip->flags |= mpflags;
-			mip->redir &= ~(IOAPIC_REDLO_LEVEL |
-	IOAPIC_REDLO_ACTLO);
-			mip->redir |= redir;
-		} else {
-			mipp = >sc_pins[pin].ip_map;
-			*mipp = 
-			tmpmap.redir = redir;
-			tmpmap.flags = mpflags;
+	if (pic == NULL) {
+		/*
+		 * If the interrupt is handled via IOAPIC, update the map.
+		 * If the map isn't set up yet, install a temporary one.
+		 */
+		ioapic = ioapic_find_bybase(irq);
+		if (ioapic != NULL) {
+			pic = >sc_pic;
+ 
+			if (pic->pic_type == PIC_IOAPIC) {
+pin = irq - pic->pic_vecbase;
+irq = -1;
+			} else {
+pin = irq;
+			}
+ 
+			mip = ioapic->sc_pins[pin].ip_map;
+			if (mip) {
+mip->flags &= ~0xf;
+mip->flags |= mpflags;
+mip->redir &= ~(IOAPIC_REDLO_LEVEL |
+		IOAPIC_REDLO_ACTLO);
+mip->redir |= redir;
+			} else {
+mipp = >sc_pins[pin].ip_map;
+*mipp = 
+tmpmap.redir = redir;
+tmpmap.flags = mpflags;
+			}
 		}
-	} else
+	}
+ 
+	if (pic == NULL)
 #endif
 	{
 		pic = _pic;
-		irq = pin = (int)InterruptNumber;
+		pin = irq;
 	}
 
 	ih = intr_establish_xname(irq, pic, pin, type, ipl,



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

2019-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:26:28 UTC 2019

Modified Files:
src/sys/arch/x86/acpi: acpi_machdep.c

Log Message:
Handle ISA/EISA interrupts like isa_machdep.c.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/x86/acpi/acpi_machdep.c

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



CVS commit: src/sys/dev/ic

2019-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:23:22 UTC 2019

Modified Files:
src/sys/dev/ic: pckbc.c

Log Message:
slotdata might not be attached, don't use it then.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/dev/ic/pckbc.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/ic/pckbc.c
diff -u src/sys/dev/ic/pckbc.c:1.59 src/sys/dev/ic/pckbc.c:1.60
--- src/sys/dev/ic/pckbc.c:1.59	Thu Jul 14 10:19:06 2016
+++ src/sys/dev/ic/pckbc.c	Wed May  1 07:23:22 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: pckbc.c,v 1.59 2016/07/14 10:19:06 msaitoh Exp $ */
+/* $NetBSD: pckbc.c,v 1.60 2019/05/01 07:23:22 mlelstv Exp $ */
 
 /*
  * Copyright (c) 2004 Ben Harris.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.59 2016/07/14 10:19:06 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.60 2019/05/01 07:23:22 mlelstv Exp $");
 
 #include 
 #include 
@@ -608,7 +608,8 @@ pckbcintr(void *vsc)
 		KBD_DELAY;
 		data = bus_space_read_1(t->t_iot, t->t_ioh_d, 0);
 
-		rnd_add_uint32(>rnd_source, (stat<<8)|data);
+		if (q != NULL)
+			rnd_add_uint32(>rnd_source, (stat<<8)|data);
 
 		pckbportintr(t->t_pt, slot, data);
 	}



CVS commit: src/sys/dev/ic

2019-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:23:22 UTC 2019

Modified Files:
src/sys/dev/ic: pckbc.c

Log Message:
slotdata might not be attached, don't use it then.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/dev/ic/pckbc.c

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



CVS commit: src/sys/uvm

2019-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:17:18 UTC 2019

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

Log Message:
allow NONE build


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/uvm/uvm_swap.h

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

Modified files:

Index: src/sys/uvm/uvm_swap.h
diff -u src/sys/uvm/uvm_swap.h:1.24 src/sys/uvm/uvm_swap.h:1.25
--- src/sys/uvm/uvm_swap.h:1.24	Thu Mar 15 03:21:58 2018
+++ src/sys/uvm/uvm_swap.h	Wed May  1 07:17:18 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_swap.h,v 1.24 2018/03/15 03:21:58 christos Exp $	*/
+/*	$NetBSD: uvm_swap.h,v 1.25 2019/05/01 07:17:18 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1997 Matthew R. Green
@@ -57,7 +57,7 @@ int	uvm_swap_stats(char *, int,
 
 #else /* defined(VMSWAP) */
 #define	uvm_swapisfull()	true
-#define uvm_swap_stats(c, l, f, count, retval) (*retval = 0, ENOSYS)
+#define uvm_swap_stats(c, l, f, count, retval) (__used f, *retval = 0, ENOSYS)
 #endif /* defined(VMSWAP) */
 
 void	uvm_swap_shutdown(struct lwp *);



CVS commit: src/sys/uvm

2019-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:17:18 UTC 2019

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

Log Message:
allow NONE build


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/uvm/uvm_swap.h

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



CVS commit: src

2019-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 06:47:45 UTC 2019

Modified Files:
src/distrib/sets/lists/man: mi
src/share/man/man4/man4.amiga: Makefile
Added Files:
src/share/man/man4/man4.amiga: a2kbbc.4 a34kbbc.4 drbbc.4

Log Message:
Add man pages for Amiga clock chips


To generate a diff of this commit:
cvs rdiff -u -r1.1643 -r1.1644 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.31 -r1.32 src/share/man/man4/man4.amiga/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/man4.amiga/a2kbbc.4 \
src/share/man/man4/man4.amiga/a34kbbc.4 \
src/share/man/man4/man4.amiga/drbbc.4

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/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1643 src/distrib/sets/lists/man/mi:1.1644
--- src/distrib/sets/lists/man/mi:1.1643	Mon Apr 22 21:58:56 2019
+++ src/distrib/sets/lists/man/mi	Wed May  1 06:47:45 2019
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1643 2019/04/22 21:58:56 maya Exp $
+# $NetBSD: mi,v 1.1644 2019/05/01 06:47:45 mlelstv Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -800,6 +800,8 @@
 ./usr/share/man/cat4/amdtemp.0			man-sys-catman		.cat
 ./usr/share/man/cat4/amhphy.0			man-sys-catman		.cat
 ./usr/share/man/cat4/amiga/a1k2cp.0		man-sys-catman		.cat
+./usr/share/man/cat4/amiga/a2kbbc.0		man-sys-catman		.cat
+./usr/share/man/cat4/amiga/a34kbbc.0		man-sys-catman		.cat
 ./usr/share/man/cat4/amiga/acafh.0		man-sys-catman		.cat
 ./usr/share/man/cat4/amiga/afsc.0		man-sys-catman		.cat
 ./usr/share/man/cat4/amiga/ahsc.0		man-sys-catman		.cat
@@ -811,6 +813,7 @@
 ./usr/share/man/cat4/amiga/clockport.0		man-sys-catman		.cat
 ./usr/share/man/cat4/amiga/console.0		man-sys-catman		.cat
 ./usr/share/man/cat4/amiga/cv3dpb.0		man-sys-catman		.cat
+./usr/share/man/cat4/amiga/drbbc.0		man-sys-catman		.cat
 ./usr/share/man/cat4/amiga/ed.0			man-sys-catman		.cat
 ./usr/share/man/cat4/amiga/efa.0		man-sys-catman		.cat
 ./usr/share/man/cat4/amiga/em4k.0		man-sys-catman		.cat
@@ -4001,6 +4004,8 @@
 ./usr/share/man/html4/amdtemp.html		man-sys-htmlman		html
 ./usr/share/man/html4/amhphy.html		man-sys-htmlman		html
 ./usr/share/man/html4/amiga/a1k2cp.html		man-sys-htmlman		html
+./usr/share/man/html4/amiga/a2kbbc.html		man-sys-htmlman		html
+./usr/share/man/html4/amiga/a34kbbc.html	man-sys-htmlman		html
 ./usr/share/man/html4/amiga/acafh.html		man-sys-htmlman		html
 ./usr/share/man/html4/amiga/afsc.html		man-sys-htmlman		html
 ./usr/share/man/html4/amiga/ahsc.html		man-sys-htmlman		html
@@ -4012,6 +4017,7 @@
 ./usr/share/man/html4/amiga/clockport.html	man-sys-htmlman		html
 ./usr/share/man/html4/amiga/console.html	man-sys-htmlman		html
 ./usr/share/man/html4/amiga/cv3dpb.html		man-sys-htmlman		html
+./usr/share/man/html4/amiga/drbbc.html		man-sys-htmlman		html
 ./usr/share/man/html4/amiga/ed.html		man-sys-htmlman		html
 ./usr/share/man/html4/amiga/efa.html		man-sys-htmlman		html
 ./usr/share/man/html4/amiga/em4k.html		man-sys-htmlman		html
@@ -6896,6 +6902,8 @@
 ./usr/share/man/man4/amdtemp.4			man-sys-man		.man
 ./usr/share/man/man4/amhphy.4			man-sys-man		.man
 ./usr/share/man/man4/amiga/a1k2cp.4		man-sys-man		.man
+./usr/share/man/man4/amiga/a2kbbc.4		man-sys-man		.man
+./usr/share/man/man4/amiga/a34kbbc.4		man-sys-man		.man
 ./usr/share/man/man4/amiga/acafh.4		man-sys-man		.man
 ./usr/share/man/man4/amiga/afsc.4		man-sys-man		.man
 ./usr/share/man/man4/amiga/ahsc.4		man-sys-man		.man
@@ -6907,6 +6915,7 @@
 ./usr/share/man/man4/amiga/clockport.4		man-sys-man		.man
 ./usr/share/man/man4/amiga/console.4		man-sys-man		.man
 ./usr/share/man/man4/amiga/cv3dpb.4		man-sys-man		.man
+./usr/share/man/man4/amiga/drbbc.4		man-sys-man		.man
 ./usr/share/man/man4/amiga/ed.4			man-sys-man		.man
 ./usr/share/man/man4/amiga/efa.4		man-sys-man		.man
 ./usr/share/man/man4/amiga/em4k.4		man-sys-man		.man

Index: src/share/man/man4/man4.amiga/Makefile
diff -u src/share/man/man4/man4.amiga/Makefile:1.31 src/share/man/man4/man4.amiga/Makefile:1.32
--- src/share/man/man4/man4.amiga/Makefile:1.31	Mon Oct  3 18:57:54 2016
+++ src/share/man/man4/man4.amiga/Makefile	Wed May  1 06:47:45 2019
@@ -1,9 +1,9 @@
 # 	from: @(#)Makefile	8.2 (Berkeley) 2/16/94
-#	$NetBSD: Makefile,v 1.31 2016/10/03 18:57:54 rkujawa Exp $
+#	$NetBSD: Makefile,v 1.32 2019/05/01 06:47:45 mlelstv Exp $
 
-MAN=	a1k2cp.4 acafh.4 afsc.4 ahsc.4 amidisplaycc.4 atzsc.4 autoconf.4 \
-	console.4 bah.4 bppcsc.4 clockport.4 cv3dpb.4 ed.4 efa.4 em4k.4 empb.4 \
-	es.4 fdc.4 grf.4 \
+MAN=a1k2cp.4 a2kbbc.4 a34kbbc.4 acafh.4 afsc.4 ahsc.4 amidisplaycc.4 \
+	atzsc.4 autoconf.4 console.4 bah.4 bppcsc.4 clockport.4 cv3dpb.4 \
+	drbbc.4 ed.4 efa.4 em4k.4 empb.4 es.4 fdc.4 grf.4 \
 	grfcl.4 grfcv.4 grfcv3d.4 grfet.4 grfrh.4 grfrt.4 grful.4 \
 	gtsc.4 intro.4 ite.4 mem.4 mfcs.4 mgnsc.4 mntva.4 mppb.4 p5membar.4 \
 	p5pb.4 qn.4 ser.4 wesc.4 xsh.4 xsurf.4 

CVS commit: src

2019-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 06:47:45 UTC 2019

Modified Files:
src/distrib/sets/lists/man: mi
src/share/man/man4/man4.amiga: Makefile
Added Files:
src/share/man/man4/man4.amiga: a2kbbc.4 a34kbbc.4 drbbc.4

Log Message:
Add man pages for Amiga clock chips


To generate a diff of this commit:
cvs rdiff -u -r1.1643 -r1.1644 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.31 -r1.32 src/share/man/man4/man4.amiga/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/man4.amiga/a2kbbc.4 \
src/share/man/man4/man4.amiga/a34kbbc.4 \
src/share/man/man4/man4.amiga/drbbc.4

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



CVS commit: [isaki-audio2] src/sys/dev/pci

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 06:34:46 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: emuxki.c
Removed Files:
src/sys/dev/pci [isaki-audio2]: emuxkivar.h

Log Message:
Reimplement emuxki driver.
- Use single voice per playback and per recording.
- Use fixed format, 2ch/48kHz, to simplify.
- Fix several problems in previous driver.
  And now it works even on alpha!
The driver is written by Y.Sugahara.  Thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.67.2.3 -r1.67.2.4 src/sys/dev/pci/emuxki.c
cvs rdiff -u -r1.13 -r0 src/sys/dev/pci/emuxkivar.h

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



CVS commit: [isaki-audio2] src/sys/dev/pci

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 06:34:46 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: emuxki.c
Removed Files:
src/sys/dev/pci [isaki-audio2]: emuxkivar.h

Log Message:
Reimplement emuxki driver.
- Use single voice per playback and per recording.
- Use fixed format, 2ch/48kHz, to simplify.
- Fix several problems in previous driver.
  And now it works even on alpha!
The driver is written by Y.Sugahara.  Thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.67.2.3 -r1.67.2.4 src/sys/dev/pci/emuxki.c
cvs rdiff -u -r1.13 -r0 src/sys/dev/pci/emuxkivar.h

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

Modified files:

Index: src/sys/dev/pci/emuxki.c
diff -u src/sys/dev/pci/emuxki.c:1.67.2.3 src/sys/dev/pci/emuxki.c:1.67.2.4
--- src/sys/dev/pci/emuxki.c:1.67.2.3	Wed May  1 06:03:14 2019
+++ src/sys/dev/pci/emuxki.c	Wed May  1 06:34:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: emuxki.c,v 1.67.2.3 2019/05/01 06:03:14 isaki Exp $	*/
+/*	$NetBSD: emuxki.c,v 1.67.2.4 2019/05/01 06:34:46 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -30,147 +30,227 @@
  */
 
 /*
- * Driver for Creative Labs SBLive! series and probably PCI512.
- *
- * Known bugs:
- * - inversed stereo at ac97 codec level
- *   (XXX jdolecek - don't see the problem? maybe because auvia(4) has
- *it swapped too?)
- * - bass disappear when you plug rear jack-in on Cambridge FPS2000 speakers
- *   (and presumably all speakers that support front and rear jack-in)
- *
- * TODO:
- * - Digital Outputs
- * - (midi/mpu),joystick support
- * - Multiple voices play (problem with /dev/audio architecture)
- * - Multiple sources recording (Pb with audio(4))
- * - Independent modification of each channel's parameters (via mixer ?)
- * - DSP FX patches (to make fx like chipmunk)
+ * EMU10K1 single voice driver
+ * o. only 1 voice playback, 1 recording
+ * o. only s16le 2ch 48k
+ * This makes it simple to control buffers and interrupts
+ * while satisfying playback and recording quality.
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.3 2019/05/01 06:03:14 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.4 2019/05/01 06:34:46 isaki Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 
 #include 
 #include 
 
+#include 
 #include 
 #include 
-#include 
+
 #include 
-#include 
 
-/* autoconf goo */
-static int	emuxki_match(device_t, cfdata_t, void *);
-static void	emuxki_attach(device_t, device_t, void *);
-static int	emuxki_detach(device_t, int);
+/* #define EMUXKI_DEBUG 1 */
+#ifdef EMUXKI_DEBUG
+#define emudebug EMUXKI_DEBUG
+# define DPRINTF(fmt...)	do { if (emudebug) printf(fmt); } while (0)
+# define DPRINTFN(n,fmt...)	do { if (emudebug>=(n)) printf(fmt); } while (0)
+#else
+# define DPRINTF(fmt...)	do { } while (0)
+# define DPRINTFN(n,fmt...)	do { } while (0)
+#endif
 
-/* DMA mem mgmt */
-static struct dmamem *dmamem_alloc(bus_dma_tag_t, size_t, bus_size_t,
-		int);
-static void	dmamem_free(struct dmamem *);
+/*
+ * PCI
+ * Note: emuxki's page table entry uses only 31bit addressing.
+ *   (Maybe, later chip has 32bit mode, but it isn't used now.)
+ */
 
-/* Emu10k1 init & shutdown */
-static int	emuxki_init(struct emuxki_softc *);
-static void	emuxki_shutdown(struct emuxki_softc *);
+#define EMU_PCI_CBIO		(0x10)
+#define EMU_SUBSYS_APS		(0x40011102)
 
-/* Emu10k1 mem mgmt */
-static void	*emuxki_pmem_alloc(struct emuxki_softc *, size_t);
-static void	*emuxki_rmem_alloc(struct emuxki_softc *, size_t);
+#define EMU_PTESIZE		(4096)
+#define EMU_MINPTE		(3)
+/*
+ * Hardware limit of PTE is 4096 entry but it's too big for single voice.
+ * Reasonable candidate is:
+ *  48kHz * 2ch * 2byte * 1sec * 3buf/EMU_PTESIZE = 141
+ * and then round it up to 2^n.
+ */
+#define EMU_MAXPTE		(256)
+#define EMU_NUMCHAN		(64)
+
+/*
+ * Internal recording DMA buffer
+ */
+/* Recommend the same size as EMU_PTESIZE to be symmetrical for play/rec */
+#define EMU_REC_DMABLKSIZE	(4096)
+/* must be EMU_REC_DMABLKSIZE * 2 */
+#define EMU_REC_DMASIZE		(8192)
+/* must be EMU_RECBS_BUFSIZE_(EMU_REC_DMASIZE) */
+#define EMU_REC_BUFSIZE_RECBS	EMU_RECBS_BUFSIZE_8192
 
 /*
- * Emu10k1 channels funcs : There is no direct access to channels, everything
- * is done through voices I will at least provide channel based fx params
- * modification, later...
+ * DMA memory management
  */
 
-/* Emu10k1 voice mgmt */
-static struct emuxki_voice *emuxki_voice_new(struct emuxki_softc *,
-		uint8_t);
-static void	emuxki_voice_delete(struct emuxki_voice *);
-static int	emuxki_voice_set_audioparms(struct emuxki_softc *,
-	struct emuxki_voice *, uint8_t,
-	uint8_t, uint32_t);
-/* emuxki_voice_set_fxparms will come later, it'll need channel distinction */
-static int	

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 06:03:14 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: emuxki.c

Log Message:
Adapt to audio2.
- XXX New set_format is not implemented at this point.
  This implementation can not adapt to audio2 (and it also has not
  worked since netbsd-8).
  The driver supports multiple hardware stream which is named 'voice'.
  This voice was allocated at open() and was deallocated at close().
  However, in order to support mixing, some interfaces such as
  set_params() (or set_format in audio2) has to be called before open().


To generate a diff of this commit:
cvs rdiff -u -r1.67.2.2 -r1.67.2.3 src/sys/dev/pci/emuxki.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/emuxki.c
diff -u src/sys/dev/pci/emuxki.c:1.67.2.2 src/sys/dev/pci/emuxki.c:1.67.2.3
--- src/sys/dev/pci/emuxki.c:1.67.2.2	Sun Apr 21 07:59:01 2019
+++ src/sys/dev/pci/emuxki.c	Wed May  1 06:03:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: emuxki.c,v 1.67.2.2 2019/04/21 07:59:01 isaki Exp $	*/
+/*	$NetBSD: emuxki.c,v 1.67.2.3 2019/05/01 06:03:14 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.2 2019/04/21 07:59:01 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.3 2019/05/01 06:03:14 isaki Exp $");
 
 #include 
 #include 
@@ -64,8 +64,6 @@ __KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1
 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -134,10 +132,10 @@ static void	emuxki_stream_halt(struct em
 static int	emuxki_open(void *, int);
 static void	emuxki_close(void *);
 
-static int	emuxki_query_encoding(void *, struct audio_encoding *);
-static int	emuxki_set_params(void *, int, int, audio_params_t *,
-		audio_params_t *, stream_filter_list_t *,
-		stream_filter_list_t *);
+static int	emuxki_query_format(void *, audio_format_query_t *);
+static int	emuxki_set_format(void *, int,
+		const audio_params_t *, const audio_params_t *,
+		audio_filter_reg_t *, audio_filter_reg_t *);
 
 static int	emuxki_round_blocksize(void *, int, int, const audio_params_t *);
 static size_t	emuxki_round_buffersize(void *, int, size_t);
@@ -157,7 +155,6 @@ static int	emuxki_query_devinfo(void *, 
 static void*emuxki_allocm(void *, int, size_t);
 static void	emuxki_freem(void *, void *, size_t);
 
-static paddr_t	emuxki_mappage(void *, void *, off_t, int);
 static int	emuxki_get_props(void *);
 static void	emuxki_get_locks(void *, kmutex_t **, kmutex_t **);
 
@@ -180,8 +177,8 @@ CFATTACH_DECL_NEW(emuxki, sizeof(struct 
 static const struct audio_hw_if emuxki_hw_if = {
 	.open			= emuxki_open,
 	.close			= emuxki_close,
-	.query_encoding		= emuxki_query_encoding,
-	.set_params		= emuxki_set_params,
+	.query_format		= emuxki_query_format,
+	.set_format		= emuxki_set_format,
 	.round_blocksize	= emuxki_round_blocksize,
 	.halt_output		= emuxki_halt_output,
 	.halt_input		= emuxki_halt_input,
@@ -192,7 +189,6 @@ static const struct audio_hw_if emuxki_h
 	.allocm			= emuxki_allocm,
 	.freem			= emuxki_freem,
 	.round_buffersize	= emuxki_round_buffersize,
-	.mappage		= emuxki_mappage,
 	.get_props		= emuxki_get_props,
 	.trigger_output		= emuxki_trigger_output,
 	.trigger_input		= emuxki_trigger_input,
@@ -2089,124 +2085,20 @@ emuxki_close(void *addr)
 }
 
 static int
-emuxki_query_encoding(void *addr, struct audio_encoding *fp)
+emuxki_query_format(void *addr, audio_format_query_t *afp)
 {
-#ifdef EMUXKI_DEBUG
-	struct emuxki_softc *sc;
-
-	sc = addr;
-	printf("%s: emuxki_query_encoding called\n", device_xname(sc->sc_dev));
-#endif
-
-	switch (fp->index) {
-	case 0:
-		strcpy(fp->name, AudioEulinear);
-		fp->encoding = AUDIO_ENCODING_ULINEAR;
-		fp->precision = 8;
-		fp->flags = 0;
-		break;
-	case 1:
-		strcpy(fp->name, AudioEmulaw);
-		fp->encoding = AUDIO_ENCODING_ULAW;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 2:
-		strcpy(fp->name, AudioEalaw);
-		fp->encoding = AUDIO_ENCODING_ALAW;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 3:
-		strcpy(fp->name, AudioEslinear);
-		fp->encoding = AUDIO_ENCODING_SLINEAR;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 4:
-		strcpy(fp->name, AudioEslinear_le);
-		fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
-		fp->precision = 16;
-		fp->flags = 0;
-		break;
-	case 5:
-		strcpy(fp->name, AudioEulinear_le);
-		fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
-		fp->precision = 16;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 6:
-		strcpy(fp->name, AudioEslinear_be);
-		fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
-		fp->precision = 16;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 7:
-		strcpy(fp->name, AudioEulinear_be);
-		fp->encoding = AUDIO_ENCODING_ULINEAR_BE;
-		fp->precision = 

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 06:03:14 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: emuxki.c

Log Message:
Adapt to audio2.
- XXX New set_format is not implemented at this point.
  This implementation can not adapt to audio2 (and it also has not
  worked since netbsd-8).
  The driver supports multiple hardware stream which is named 'voice'.
  This voice was allocated at open() and was deallocated at close().
  However, in order to support mixing, some interfaces such as
  set_params() (or set_format in audio2) has to be called before open().


To generate a diff of this commit:
cvs rdiff -u -r1.67.2.2 -r1.67.2.3 src/sys/dev/pci/emuxki.c

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



CVS commit: src/sys/dev/usb

2019-05-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed May  1 06:01:01 UTC 2019

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

Log Message:
fix a locking botch in ucomhwiflow():

tty.c always calls t_hwiflow() with tty_lock held, and the caller
of this for ucom always holds sc->sc_lock when calling down into
the tty layer.

don't try to re-take the sc_lock in ucomhwiflow() (locking against
myself is triggered here currently), but instead assert that the
lock is already held _and_ that tty_lock is held.

in ucom_detach(), when closing pipes set sc_bulkin_pipe and
sc_bulkout_pipe to NULL.  fixes bug noticed by code inspection:
a failed detach would attempt to close them a second time.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/dev/usb/ucom.c

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



CVS commit: src/sys/dev/usb

2019-05-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed May  1 06:01:01 UTC 2019

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

Log Message:
fix a locking botch in ucomhwiflow():

tty.c always calls t_hwiflow() with tty_lock held, and the caller
of this for ucom always holds sc->sc_lock when calling down into
the tty layer.

don't try to re-take the sc_lock in ucomhwiflow() (locking against
myself is triggered here currently), but instead assert that the
lock is already held _and_ that tty_lock is held.

in ucom_detach(), when closing pipes set sc_bulkin_pipe and
sc_bulkout_pipe to NULL.  fixes bug noticed by code inspection:
a failed detach would attempt to close them a second time.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/dev/usb/ucom.c

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

Modified files:

Index: src/sys/dev/usb/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.122 src/sys/dev/usb/ucom.c:1.123
--- src/sys/dev/usb/ucom.c:1.122	Sat Apr 20 05:53:18 2019
+++ src/sys/dev/usb/ucom.c	Wed May  1 06:01:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.122 2019/04/20 05:53:18 mrg Exp $	*/
+/*	$NetBSD: ucom.c,v 1.123 2019/05/01 06:01:01 mrg Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.122 2019/04/20 05:53:18 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.123 2019/05/01 06:01:01 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -413,10 +413,14 @@ ucom_detach(device_t self, int flags)
 
 	pmf_device_deregister(self);
 
-	if (sc->sc_bulkin_pipe != NULL)
+	if (sc->sc_bulkin_pipe != NULL) {
 		usbd_abort_pipe(sc->sc_bulkin_pipe);
-	if (sc->sc_bulkout_pipe != NULL)
+		sc->sc_bulkin_pipe = NULL;
+	}
+	if (sc->sc_bulkout_pipe != NULL) {
 		usbd_abort_pipe(sc->sc_bulkout_pipe);
+		sc->sc_bulkout_pipe = NULL;
+	}
 
 	mutex_enter(>sc_lock);
 
@@ -1263,7 +1267,9 @@ ucomhwiflow(struct tty *tp, int block)
 	if (sc == NULL)
 		return 0;
 
-	mutex_enter(>sc_lock);
+	KASSERT(>sc_lock);
+	KASSERT(mutex_owned(_lock));
+
 	old = sc->sc_rx_stopped;
 	sc->sc_rx_stopped = (u_char)block;
 
@@ -1273,7 +1279,6 @@ ucomhwiflow(struct tty *tp, int block)
 		softint_schedule(sc->sc_si);
 		kpreempt_enable();
 	}
-	mutex_exit(>sc_lock);
 
 	return 1;
 }