CVS commit: src/common/lib/libc/arch/x86_64/atomic

2019-02-16 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Feb 17 07:34:44 UTC 2019

Modified Files:
src/common/lib/libc/arch/x86_64/atomic: atomic.S

Log Message:
Add missing export of atomic_or_64 (since rev1.1).


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/common/lib/libc/arch/x86_64/atomic/atomic.S

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

Modified files:

Index: src/common/lib/libc/arch/x86_64/atomic/atomic.S
diff -u src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.17 src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.18
--- src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.17	Thu May 22 15:23:11 2014
+++ src/common/lib/libc/arch/x86_64/atomic/atomic.S	Sun Feb 17 07:34:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic.S,v 1.17 2014/05/22 15:23:11 uebayasi Exp $	*/
+/*	$NetBSD: atomic.S,v 1.18 2019/02/17 07:34:44 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -345,6 +345,7 @@ ALIAS(atomic_inc_ulong_nv,_atomic_inc_64
 ALIAS(atomic_inc_ptr_nv,_atomic_inc_64_nv)
 
 ALIAS(atomic_or_32,_atomic_or_32)
+ALIAS(atomic_or_64,_atomic_or_64)
 ALIAS(atomic_or_uint,_atomic_or_32)
 ALIAS(atomic_or_ulong,_atomic_or_64)
 ALIAS(atomic_or_ptr,_atomic_or_64)



CVS commit: src/external/gpl3/gcc

2019-02-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Feb 17 06:22:58 UTC 2019

Modified Files:
src/external/gpl3/gcc: README.gcc7

Log Message:
various updates for reality.

- arm64, powerpc switched
- arm, hppa, sh3 is ready to switch
- vax dynamic binaries have a problem


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/gpl3/gcc/README.gcc7

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

Modified files:

Index: src/external/gpl3/gcc/README.gcc7
diff -u src/external/gpl3/gcc/README.gcc7:1.11 src/external/gpl3/gcc/README.gcc7:1.12
--- src/external/gpl3/gcc/README.gcc7:1.11	Sat Feb  9 01:29:38 2019
+++ src/external/gpl3/gcc/README.gcc7	Sun Feb 17 06:22:58 2019
@@ -1,4 +1,4 @@
-$NetBSD: README.gcc7,v 1.11 2019/02/09 01:29:38 mrg Exp $
+$NetBSD: README.gcc7,v 1.12 2019/02/17 06:22:58 mrg Exp $
 
 new stuff (from gcc 5):
 	cc1objcplus
@@ -6,7 +6,6 @@ new stuff (from gcc 5):
 	libmpx
 	liboffloadmic
 	libvtv
-	libitm
 
 arch/feature list.
 
@@ -22,40 +21,40 @@ switched:	has port switched?  y (yes), n
 
 architecture	tools	kernels	libgcc	native-gcc	make release	runs	atf	switched
 	-	---	--	--			---	
-aarch64		y	y	y	y		y		y	?	y
+aarch64		y	y	y	y		y		y	y	y
 alpha		y	y	y	y		y		y	?	y
 arm		y	y	y	y		y		y	?	n
 armeb		y	y	y	y		y		?	?	n
-earmv4		y	y	y	y		y		y	???	y
-earmv4eb	y	?	y	y		?		?	?	?
-earm		y	?	y	y		?		?	?	?
-earmeb		y	?	y	y		?		?	?	?
-earmhf		y	?	y	y		?		?	?	?
-earmhfeb	y	?	y	y		?		?	?	?
-earmv6		y	?	y	y		?		?	?	?
-earmv6eb	y	?	y	y		?		?	?	?
-earmv6hf	y	?	y	y		?		?	?	?
-earmv6hfeb	y	?	y	y		?		?	?	?
-earmv7		y	?	y	y		?		?	?	?
-earmv7eb	y	?	y	y		?		?	?	?
-earmv7hf	y	?	y	y		?		?	?	?
-earmv7hfeb	y	?	y	y		?		?	?	?
-hppa		y	y	y	y		y		?	?	y
-i386		y	y	y	y		y		y	?	y
+earmv4		y	y	y	y		y		y	???	n
+earmv4eb	y	?	y	y		?		?	?	n
+earm		y	?	y	y		?		?	?	n
+earmeb		y	?	y	y		?		?	?	n
+earmhf		y	?	y	y		?		?	?	n
+earmhfeb	y	?	y	y		?		?	?	n
+earmv6		y	?	y	y		?		?	?	n
+earmv6eb	y	?	y	y		?		?	?	n
+earmv6hf	y	?	y	y		?		?	?	n
+earmv6hfeb	y	?	y	y		?		?	?	n
+earmv7		y	?	y	y		?		?	?	n
+earmv7eb	y	?	y	y		?		?	?	n
+earmv7hf	y	?	y	y		?		?	?	n
+earmv7hfeb	y	?	y	y		?		?	?	n
+hppa		y	y	y	y		y		?	?	n
+i386		y	y	y	y		y		y	y	y
 ia64		y	?	?	y		n[2]		?	?	?
 m68000		y	y	y	y		y		?	?	?
-m68k		y	y	y	y		y[1]		?	?	?
+m68k		y	y	y	y		y[1]		y	?	?
 mipseb		y	y	y	y		y		?	?	y
 mipsel		y	y	y	y		y		?	?	y
-mips64eb	y	y	y	y		y		y	?	y
+mips64eb	y	y	y	y		y		y	y	y
 mips64el	y	y	y	y		y		?	?	y
-powerpc		y	y	y	y		y		y	?	n
+powerpc		y	y	y	y		y		y	?	y
 powerpc64	y	?	y	y		n[9]		?	?	?
 sh3eb		y	y	y	y		y		?	?	n
-sh3el		y	y	y	y		y		?	?	n
+sh3el		y	y	y	y		y		y	?	n
 sparc		y	y	y	y		y		y	?	y
 sparc64		y	y	y	y		y		y	?	y
-vax		y	y	y	y		y		?	?	?
+vax		y	y	y	y		y		n[3]	?	?
 x86_64		y	y	y	y		y		y	y	y
 --
 or1k		
@@ -67,6 +66,7 @@ architecture	tools	kernels	libgcc	native
 
 [1] - mac68k/intr.c has uncommited change.
 [2] - libgcc_s.so: undefined reference to `__netf2'
+[3] - vax dynamic seems busted, but /rescue works
 [9] - /usr/src6/external/gpl3/gcc/dist/libgcc/libgcc2.c:2036:1: error: unrecognizable insn:
 
 CPU vs platform test table (for CPUs with multiple ports).  this is "make release" or just kernels.



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

2019-02-16 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Feb 17 05:32:35 UTC 2019

Modified Files:
src/sys/arch/usermode/modules/syscallemu: Makefile

Log Message:
Set WARN=3 for sing-compare.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/usermode/modules/syscallemu/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/arch/usermode/modules/syscallemu/Makefile
diff -u src/sys/arch/usermode/modules/syscallemu/Makefile:1.5 src/sys/arch/usermode/modules/syscallemu/Makefile:1.6
--- src/sys/arch/usermode/modules/syscallemu/Makefile:1.5	Sun Nov 10 22:08:58 2013
+++ src/sys/arch/usermode/modules/syscallemu/Makefile	Sun Feb 17 05:32:35 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2013/11/10 22:08:58 jmcneill Exp $
+#	$NetBSD: Makefile,v 1.6 2019/02/17 05:32:35 rin Exp $
 
 .include 
 
@@ -19,4 +19,6 @@ SRCS+=	syscallemu_arm.c
 .error ${MACHINE_CPU} not implemented
 .endif
 
+WARNS=	3
+
 .include 



CVS commit: src

2019-02-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Feb 17 05:29:09 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: md.sparc64
src/etc/mtree: Makefile
Added Files:
src/etc/mtree: NetBSD.compat.mips64 NetBSD.dist.aarch64 NetBSD.dist.arm
NetBSD.dist.ia64 NetBSD.dist.mips NetBSD.dist.powerpc
NetBSD.dist.sh3 NetBSD.dist.sparc NetBSD.dist.sparc64
Removed Files:
src/etc/mtree: NetBSD.compat.mips64eb NetBSD.compat.mips64el

Log Message:
ensure that all include dirs are created before make includes runs.

separate the compat vs per-arch -ness of the mtree lists.  merge the
mips64 mtree files into a single file.


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/distrib/sets/lists/comp/md.sparc64
cvs rdiff -u -r1.39 -r1.40 src/etc/mtree/Makefile
cvs rdiff -u -r0 -r1.1 src/etc/mtree/NetBSD.compat.mips64 \
src/etc/mtree/NetBSD.dist.arm src/etc/mtree/NetBSD.dist.ia64 \
src/etc/mtree/NetBSD.dist.mips src/etc/mtree/NetBSD.dist.powerpc \
src/etc/mtree/NetBSD.dist.sh3 src/etc/mtree/NetBSD.dist.sparc
cvs rdiff -u -r1.1 -r0 src/etc/mtree/NetBSD.compat.mips64eb \
src/etc/mtree/NetBSD.compat.mips64el
cvs rdiff -u -r0 -r1.6 src/etc/mtree/NetBSD.dist.aarch64
cvs rdiff -u -r0 -r1.12 src/etc/mtree/NetBSD.dist.sparc64

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/comp/md.sparc64
diff -u src/distrib/sets/lists/comp/md.sparc64:1.207 src/distrib/sets/lists/comp/md.sparc64:1.208
--- src/distrib/sets/lists/comp/md.sparc64:1.207	Thu Feb 14 20:42:40 2019
+++ src/distrib/sets/lists/comp/md.sparc64	Sun Feb 17 05:29:08 2019
@@ -1,7 +1,8 @@
-# $NetBSD: md.sparc64,v 1.207 2019/02/14 20:42:40 christos Exp $
+# $NetBSD: md.sparc64,v 1.208 2019/02/17 05:29:08 mrg Exp $
 ./usr/include/g++/bits/sparc			comp-c-include
+./usr/include/g++/bits/sparc			comp-c-include		compat
 ./usr/include/g++/bits/sparc/c++config.h	comp-c-include		gcc,compat
-./usr/include/g++/bits/sparc64			comp-c-include
+./usr/include/g++/bits/sparc64			comp-c-include		compat
 ./usr/include/g++/bits/sparc64/c++config.h	comp-c-include		gcc,compat
 ./usr/include/gcc-4.5/tgmath.h			comp-obsolete		obsolete
 ./usr/include/gcc-4.8/tgmath.h			comp-obsolete		obsolete

Index: src/etc/mtree/Makefile
diff -u src/etc/mtree/Makefile:1.39 src/etc/mtree/Makefile:1.40
--- src/etc/mtree/Makefile:1.39	Sat Feb  9 21:43:23 2019
+++ src/etc/mtree/Makefile	Sun Feb 17 05:29:08 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.39 2019/02/09 21:43:23 mrg Exp $
+#	$NetBSD: Makefile,v 1.40 2019/02/17 05:29:08 mrg Exp $
 
 .include 
 
@@ -6,12 +6,15 @@
 EXTRA_DIST_FILES=	NetBSD.dist.Xorg
 .endif
 
-# XXX these are only used by compat currently, but they could be used
-# by something else; this may need to be fixed properly in the future.
+# Derived from MACHINE_CPU, but keeping 32/64bit for most.
+MTREE_MACHINE_ARCH=${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips64/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/arm.*/arm/:C/earm.*/arm/:S/earm/arm/:S/aarch64eb/aarch64/:S/or1knd/or1k/}
+
+# The compat specific files
+
 .if defined(MKCOMPAT) && ${MKCOMPAT} != "no"
 .include "${NETBSDSRCDIR}/compat/archdirs.mk"
-.if exists(NetBSD.compat.${MACHINE_ARCH})
-EXTRA_DIST_FILES+=	NetBSD.compat.${MACHINE_ARCH}
+.if exists(NetBSD.compat.${MTREE_MACHINE_ARCH})
+EXTRA_DIST_FILES+=	NetBSD.compat.${MTREE_MACHINE_ARCH}
 .endif
 EXTRA_DIST_FILES+=	NetBSD.dist.compat	# autogenerated
 .if defined(MKCOMPATX11) && ${MKCOMPATX11} != "no" && ${MKX11} != "no"
@@ -19,14 +22,32 @@ EXTRA_DIST_FILES+=	NetBSD.dist.xcompat	#
 .endif
 .endif
 
-.if exists(NetBSD.dist.${MACHINE_ARCH})
+
+# Platform specific files.
+# First we grab the mtree-specific, then either the MACHINE_ARCH or
+# MACHINE_CPU files, and finally the MACHINE files, as long as they
+# aren't the same files.
+
+.if exists(NetBSD.dist.${MTREE_MACHINE_ARCH})
+EXTRA_DIST_FILES+=	NetBSD.dist.${MTREE_MACHINE_ARCH}
+.endif
+
+.if empty(MTREE_MACHINE_ARCH:M${MACHINE_ARCH}) && \
+exists(NetBSD.dist.${MACHINE_ARCH})
 EXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE_ARCH}
+.elif empty(MTREE_MACHINE_ARCH:M${MACHINE_CPU}) && \
+exists(NetBSD.dist.${MACHINE_CPU})
+EXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE_CPU}
 .endif
 
-.if exists(NetBSD.dist.${MACHINE})
+.if empty(MTREE_MACHINE_ARCH:M${MACHINE}) && \
+exists(NetBSD.dist.${MACHINE})
 EXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE}
 .endif
 
+
+# The build specific files.
+
 .if ${MKATF} != "no"
 EXTRA_DIST_FILES+=	NetBSD.dist.tests
 .if defined(MKCOMPATTESTS) && ${MKCOMPATTESTS} != "no"

Added files:

Index: src/etc/mtree/NetBSD.compat.mips64
diff -u /dev/null src/etc/mtree/NetBSD.compat.mips64:1.1
--- /dev/null	Sun Feb 17 05:29:09 2019
+++ src/etc/mtree/NetBSD.compat.mips64	Sun Feb 17 05:29:08 2019
@@ -0,0 +1,5 @@
+#	$NetBSD: NetBSD.compat.mips64,v 1.1 2019/02/17 05:29:08 mrg Exp $
+
+./usr/include/g++/bits/mips64

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

2019-02-16 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Feb 17 05:21:49 UTC 2019

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

Log Message:
Remove redundant test from ATF t_ptrace_wait*

signal3 duplicates traceme_signalmasked_crash(SIGSEGV)


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 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.90 src/tests/lib/libc/sys/t_ptrace_wait.c:1.91
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.90	Sun Feb 17 04:57:09 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Sun Feb 17 05:21:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.90 2019/02/17 04:57:09 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.91 2019/02/17 05:21:49 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.90 2019/02/17 04:57:09 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.91 2019/02/17 05:21:49 kamil Exp $");
 
 #include 
 #include 
@@ -4417,74 +4417,6 @@ ATF_TC_BODY(signal_mask_unrelated, tc)
 
 /// 
 
-ATF_TC(signal3);
-ATF_TC_HEAD(signal3, tc)
-{
-	atf_tc_set_md_var(tc, "timeout", "5");
-	atf_tc_set_md_var(tc, "descr",
-	"Verify that masking SIGTRAP in tracee does not stop tracer from "
-	"catching software breakpoints");
-}
-
-ATF_TC_BODY(signal3, tc)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	const int sigmasked = SIGTRAP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	sigset_t intmask;
-
-	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);
-
-		sigemptyset();
-		sigaddset(, sigmasked);
-		sigprocmask(SIG_BLOCK, , NULL);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		DPRINTF("Before raising software breakpoint from child\n");
-		trigger_trap();
-
-		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("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\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigmasked);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_KILL, child, NULL, 0) != -1);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_signaled(status, SIGKILL, 0);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
-}
-
 #if defined(PT_STEP)
 ATF_TC(signal4);
 ATF_TC_HEAD(signal4, tc)
@@ -6012,7 +5944,6 @@ ATF_TP_ADD_TCS(tp)
 
 	ATF_TP_ADD_TC(tp, signal_mask_unrelated);
 
-	ATF_TP_ADD_TC(tp, signal3);
 	ATF_TP_ADD_TC_PT_STEP(tp, signal4);
 	ATF_TP_ADD_TC(tp, signal5);
 	ATF_TP_ADD_TC_HAVE_PID(tp, signal6);



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

2019-02-16 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sun Feb 17 05:06:16 UTC 2019

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

Log Message:
PR/53984: Partial revert of modify lapic_calibrate_timer() in lapic.c r1.69.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/x86/x86/lapic.c

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

Modified files:

Index: src/sys/arch/x86/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.69 src/sys/arch/x86/x86/lapic.c:1.70
--- src/sys/arch/x86/x86/lapic.c:1.69	Fri Feb 15 08:54:01 2019
+++ src/sys/arch/x86/x86/lapic.c	Sun Feb 17 05:06:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.69 2019/02/15 08:54:01 nonaka Exp $	*/
+/*	$NetBSD: lapic.c,v 1.70 2019/02/17 05:06:16 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.69 2019/02/15 08:54:01 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.70 2019/02/17 05:06:16 nonaka Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -604,11 +604,9 @@ extern void (*initclock_func)(void); /* 
 void
 lapic_calibrate_timer(struct cpu_info *ci)
 {
-	struct timecounter *tc;
-	timecounter_get_t *tick_func;
-	unsigned int tval, mask, delta, initial_counter, initial_lapic;
-	unsigned int cur_counter, cur_lapic;
-	uint64_t seen, end, tmp, freq;
+	unsigned int seen, delta, initial_i8254, initial_lapic;
+	unsigned int cur_i8254, cur_lapic;
+	uint64_t tmp;
 	int i;
 	char tbuf[9];
 
@@ -617,19 +615,6 @@ lapic_calibrate_timer(struct cpu_info *c
 
 	aprint_debug_dev(ci->ci_dev, "calibrating local timer\n");
 
-	tc = timecounter;
-	if (tc->tc_quality <= 0) {
-		tick_func = (timecounter_get_t *)gettick;
-		tval = rtclock_tval;
-		mask = ~0u;
-		freq = TIMER_FREQ;
-	} else {
-		tick_func = tc->tc_get_timecount;
-		tval = mask = tc->tc_counter_mask;
-		freq = tc->tc_frequency;
-	}
-	end = freq / 100;
-
 	/*
 	 * Configure timer to one-shot, interrupt masked,
 	 * large positive number.
@@ -641,22 +626,22 @@ lapic_calibrate_timer(struct cpu_info *c
 	x86_disable_intr();
 
 	initial_lapic = lapic_gettick();
-	initial_counter = tick_func(tc) & mask;
+	initial_i8254 = gettick();
 
-	for (seen = 0; seen < end; seen += delta) {
-		cur_counter = tick_func(tc) & mask;
-		if (cur_counter > initial_counter)
-			delta = tval - (cur_counter - initial_counter);
+	for (seen = 0; seen < TIMER_FREQ / 100; seen += delta) {
+		cur_i8254 = gettick();
+		if (cur_i8254 > initial_i8254)
+			delta = rtclock_tval - (cur_i8254 - initial_i8254);
 		else
-			delta = initial_counter - cur_counter;
-		initial_counter = cur_counter;
+			delta = initial_i8254 - cur_i8254;
+		initial_i8254 = cur_i8254;
 	}
 	cur_lapic = lapic_gettick();
 
 	x86_enable_intr();
 
 	tmp = initial_lapic - cur_lapic;
-	lapic_per_second = (tmp * freq + seen / 2) / seen;
+	lapic_per_second = (tmp * TIMER_FREQ + seen / 2) / seen;
 
 calibrate_done:
 	humanize_number(tbuf, sizeof(tbuf), lapic_per_second, "Hz", 1000);



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

2019-02-16 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Feb 17 04:57:09 UTC 2019

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

Log Message:
Add additional assert in traceme_signalignored_crash t_ptrace_wait* tests

Check whether sigignore is not reset on a trapsignal under a debugger.
The expected behavior is to not reset it. A side effect of resetting
signal mask is noticable especially with a software/hardware breakpoint
that changes state of a process.

Mark these tests as failing.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 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.89 src/tests/lib/libc/sys/t_ptrace_wait.c:1.90
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.89	Sun Feb 17 04:19:39 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Sun Feb 17 04:57:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.89 2019/02/17 04:19:39 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.90 2019/02/17 04:57:09 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.89 2019/02/17 04:19:39 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.90 2019/02/17 04:57:09 kamil Exp $");
 
 #include 
 #include 
@@ -692,18 +692,27 @@ TRACEME_SIGNALMASKED_CRASH(traceme_signa
 static void
 traceme_signalignored_crash(int sig)
 {
+	const int sigval = SIGSTOP;
 	pid_t child, wpid;
 #if defined(TWAIT_HAVE_STATUS)
 	int status;
 #endif
 	struct sigaction sa;
 	struct ptrace_siginfo info;
+	struct kinfo_proc2 kp;
+	size_t len = sizeof(kp);
+
+	int name[6];
+	const size_t namelen = __arraycount(name);
+	ki_sigset_t kp_sigignore;
 
 #ifndef PTRACE_ILLEGAL_ASM
 	if (sig == SIGILL)
 		atf_tc_skip("PTRACE_ILLEGAL_ASM not defined");
 #endif
 
+	atf_tc_expect_fail("Unexpected sigmask reset on crash under debugger");
+
 	memset(, 0, sizeof(info));
 
 	DPRINTF("Before forking process PID=%d\n", getpid());
@@ -718,6 +727,9 @@ traceme_signalignored_crash(int sig)
 
 		FORKEE_ASSERT(sigaction(sig, , NULL) != -1);
 
+		DPRINTF("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
 		DPRINTF("Before executing a trap\n");
 		switch (sig) {
 		case SIGTRAP:
@@ -748,6 +760,38 @@ traceme_signalignored_crash(int sig)
 	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
 	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
 
+	validate_status_stopped(status, sigval);
+
+	name[0] = CTL_KERN,
+	name[1] = KERN_PROC2,
+	name[2] = KERN_PROC_PID;
+	name[3] = child;
+	name[4] = sizeof(kp);
+	name[5] = 1;
+
+	ATF_REQUIRE_EQ(sysctl(name, namelen, , , NULL, 0), 0);
+
+	kp_sigignore = kp.p_sigignore;
+
+	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+	SYSCALL_REQUIRE(
+	ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
+
+	DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
+	DPRINTF("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+	info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+	info.psi_siginfo.si_errno);
+
+	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
+	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
+
+	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\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
 	validate_status_stopped(status, sig);
 
 	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child");
@@ -759,6 +803,20 @@ traceme_signalignored_crash(int sig)
 	info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
 	info.psi_siginfo.si_errno);
 
+	ATF_REQUIRE_EQ(sysctl(name, namelen, , , NULL, 0), 0);
+
+	DPRINTF("kp_sigignore="
+	"%#02" PRIx32 "%02" PRIx32 "%02" PRIx32 "%02" PRIx32"\n",
+	kp_sigignore.__bits[0], kp_sigignore.__bits[1],
+	kp_sigignore.__bits[2], kp_sigignore.__bits[3]);
+
+	DPRINTF("kp.p_sigignore="
+	"%#02" PRIx32 "%02" PRIx32 "%02" PRIx32 "%02" PRIx32"\n",
+	kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1],
+	kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]);
+
+	ATF_REQUIRE(!memcmp(_sigignore, _sigignore, sizeof(kp_sigignore)));
+
 	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sig);
 	switch (sig) {
 	case SIGTRAP:



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

2019-02-16 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Feb 17 04:19:39 UTC 2019

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

Log Message:
Add additional assert in traceme_signalmasked_crash t_ptrace_wait* tests

Check whether signal mask is not reset on a trapsignal under a debugger.
The expected behavior is to not reset it. A side effect of resetting
signal mask is noticable especially with a software/hardware breakpoint
that changes state of a process.

Mark these tests as failing.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 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.88 src/tests/lib/libc/sys/t_ptrace_wait.c:1.89
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.88	Fri Feb 15 05:06:38 2019
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Sun Feb 17 04:19:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.88 2019/02/15 05:06:38 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.89 2019/02/17 04:19:39 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.88 2019/02/15 05:06:38 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.89 2019/02/17 04:19:39 kamil Exp $");
 
 #include 
 #include 
@@ -513,12 +513,19 @@ TRACEME_CRASH(traceme_crash_bus, SIGBUS)
 static void
 traceme_signalmasked_crash(int sig)
 {
+	const int sigval = SIGSTOP;
 	pid_t child, wpid;
 #if defined(TWAIT_HAVE_STATUS)
 	int status;
 #endif
 	struct ptrace_siginfo info;
 	sigset_t intmask;
+	struct kinfo_proc2 kp;
+	size_t len = sizeof(kp);
+
+	int name[6];
+	const size_t namelen = __arraycount(name);
+	ki_sigset_t kp_sigmask;
 
 #ifndef PTRACE_ILLEGAL_ASM
 	if (sig == SIGILL)
@@ -527,6 +534,8 @@ traceme_signalmasked_crash(int sig)
 
 	memset(, 0, sizeof(info));
 
+	atf_tc_expect_fail("Unexpected sigmask reset on crash under debugger");
+
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -537,6 +546,9 @@ traceme_signalmasked_crash(int sig)
 		sigaddset(, sig);
 		sigprocmask(SIG_BLOCK, , NULL);
 
+		DPRINTF("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
 		DPRINTF("Before executing a trap\n");
 		switch (sig) {
 		case SIGTRAP:
@@ -567,6 +579,38 @@ traceme_signalmasked_crash(int sig)
 	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
 	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
 
+	validate_status_stopped(status, sigval);
+
+	name[0] = CTL_KERN,
+	name[1] = KERN_PROC2,
+	name[2] = KERN_PROC_PID;
+	name[3] = child;
+	name[4] = sizeof(kp);
+	name[5] = 1;
+
+	ATF_REQUIRE_EQ(sysctl(name, namelen, , , NULL, 0), 0);
+
+	kp_sigmask = kp.p_sigmask;
+
+	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+	SYSCALL_REQUIRE(
+	ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
+
+	DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
+	DPRINTF("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+	info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+	info.psi_siginfo.si_errno);
+
+	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
+	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
+
+	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\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
 	validate_status_stopped(status, sig);
 
 	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child");
@@ -578,6 +622,20 @@ traceme_signalmasked_crash(int sig)
 	info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
 	info.psi_siginfo.si_errno);
 
+	ATF_REQUIRE_EQ(sysctl(name, namelen, , , NULL, 0), 0);
+
+	DPRINTF("kp_sigmask="
+	"%#02" PRIx32 "%02" PRIx32 "%02" PRIx32 "%02" PRIx32"\n",
+	kp_sigmask.__bits[0], kp_sigmask.__bits[1], kp_sigmask.__bits[2],
+	kp_sigmask.__bits[3]);
+
+	DPRINTF("kp.p_sigmask="
+	"%#02" PRIx32 "%02" PRIx32 "%02" PRIx32 "%02" PRIx32"\n",
+	kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1],
+	kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]);
+
+	ATF_REQUIRE(!memcmp(_sigmask, _sigmask, sizeof(kp_sigmask)));
+
 	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sig);
 	switch (sig) {
 	case SIGTRAP:
@@ -597,8 +655,6 @@ traceme_signalmasked_crash(int sig)
 		break;
 	}
 
-
-
 	SYSCALL_REQUIRE(ptrace(PT_KILL, child, NULL, 0) != -1);
 
 	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);



CVS commit: src/sys

2019-02-16 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Feb 17 04:17:52 UTC 2019

Modified Files:
src/sys/arch/mips/adm5120/dev: ahci.c
src/sys/dev/ic: sl811hs.c
src/sys/dev/usb: ehci.c motg.c ohci.c uhci.c xhci.c
src/sys/external/bsd/dwc2: dwc2.c

Log Message:
Fix assertion failures triggered by usbdi.c,v 1.182, when devices
are detached.

This is because xfers of USBD_NOT_STARTED can be removed from queue
in an invisible way to host controller drivers.

Discussed on tech-kern.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/mips/adm5120/dev/ahci.c
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/ic/sl811hs.c
cvs rdiff -u -r1.265 -r1.266 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/usb/motg.c
cvs rdiff -u -r1.287 -r1.288 src/sys/dev/usb/ohci.c src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.105 -r1.106 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.57 -r1.58 src/sys/external/bsd/dwc2/dwc2.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/mips/adm5120/dev/ahci.c
diff -u src/sys/arch/mips/adm5120/dev/ahci.c:1.16 src/sys/arch/mips/adm5120/dev/ahci.c:1.17
--- src/sys/arch/mips/adm5120/dev/ahci.c:1.16	Mon Sep  3 16:29:25 2018
+++ src/sys/arch/mips/adm5120/dev/ahci.c	Sun Feb 17 04:17:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahci.c,v 1.16 2018/09/03 16:29:25 riastradh Exp $	*/
+/*	$NetBSD: ahci.c,v 1.17 2019/02/17 04:17:52 rin Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.16 2018/09/03 16:29:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.17 2019/02/17 04:17:52 rin Exp $");
 
 #include 
 #include 
@@ -491,7 +491,8 @@ ahci_freex(struct usbd_bus *bus, struct 
 	DPRINTF(D_MEM, ("SLfreex"));
 
 #ifdef DIAGNOSTIC
-	if (xfer->ux_state != XFER_BUSY) {
+	if (xfer->ux_state != XFER_BUSY &&
+	xfer->ux_status != USBD_NOT_STARTED) {
 		printf("ahci_freex: xfer=%p not busy, 0x%08x\n",
 			xfer, xfer->ux_state);
 		return;

Index: src/sys/dev/ic/sl811hs.c
diff -u src/sys/dev/ic/sl811hs.c:1.100 src/sys/dev/ic/sl811hs.c:1.101
--- src/sys/dev/ic/sl811hs.c:1.100	Mon Sep  3 16:29:31 2018
+++ src/sys/dev/ic/sl811hs.c	Sun Feb 17 04:17:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sl811hs.c,v 1.100 2018/09/03 16:29:31 riastradh Exp $	*/
+/*	$NetBSD: sl811hs.c,v 1.101 2019/02/17 04:17:52 rin Exp $	*/
 
 /*
  * Not (c) 2007 Matthew Orgass
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.100 2018/09/03 16:29:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.101 2019/02/17 04:17:52 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_slhci.h"
@@ -811,7 +811,8 @@ slhci_freex(struct usbd_bus *bus, struct
 	slhci_mem_use(bus, -1);
 #endif
 #ifdef DIAGNOSTIC
-	if (xfer->ux_state != XFER_BUSY) {
+	if (xfer->ux_state != XFER_BUSY &&
+	xfer->ux_status != USBD_NOT_STARTED) {
 		struct slhci_softc *sc = SLHCI_BUS2SC(bus);
 		printf("%s: slhci_freex: xfer=%p not busy, %#08x halted\n",
 		SC_NAME(sc), xfer, xfer->ux_state);

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.265 src/sys/dev/usb/ehci.c:1.266
--- src/sys/dev/usb/ehci.c:1.265	Tue Sep 18 02:00:06 2018
+++ src/sys/dev/usb/ehci.c	Sun Feb 17 04:17:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.265 2018/09/18 02:00:06 mrg Exp $ */
+/*	$NetBSD: ehci.c,v 1.266 2019/02/17 04:17:52 rin Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.265 2018/09/18 02:00:06 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.266 2019/02/17 04:17:52 rin Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -1562,9 +1562,10 @@ ehci_freex(struct usbd_bus *bus, struct 
 	struct ehci_softc *sc = EHCI_BUS2SC(bus);
 	struct ehci_xfer *ex __diagused = EHCI_XFER2EXFER(xfer);
 
-	KASSERTMSG(xfer->ux_state == XFER_BUSY, "xfer %p state %d\n", xfer,
-	xfer->ux_state);
-	KASSERT(ex->ex_isdone);
+	KASSERTMSG(xfer->ux_state == XFER_BUSY ||
+	xfer->ux_status == USBD_NOT_STARTED,
+	"xfer %p state %d\n", xfer, xfer->ux_state);
+	KASSERT(ex->ex_isdone || xfer->ux_status == USBD_NOT_STARTED);
 
 #ifdef DIAGNOSTIC
 	xfer->ux_state = XFER_FREE;

Index: src/sys/dev/usb/motg.c
diff -u src/sys/dev/usb/motg.c:1.24 src/sys/dev/usb/motg.c:1.25
--- src/sys/dev/usb/motg.c:1.24	Tue Jan 22 06:39:24 2019
+++ src/sys/dev/usb/motg.c	Sun Feb 17 04:17:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: motg.c,v 1.24 2019/01/22 06:39:24 skrll Exp $	*/
+/*	$NetBSD: motg.c,v 1.25 2019/02/17 04:17:52 rin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.24 2019/01/22 06:39:24 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.25 2019/02/17 04:17:52 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -760,7 

CVS commit: src/sys/dev/usb

2019-02-16 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Feb 17 04:17:31 UTC 2019

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

Log Message:
Fix system freeze when USB NICs with multiple outstanding transfers
are detached from xhci(4) or ehci(4), that enable up_serialise for
bulk transfers.

The cause of problem is that usbd_ar_pipe() waits xfers of
USBD_NOT_STARTED to be removed, although underlying upm_abort
functions do not remove such queues, as reported by "sc dying".

Therefore, remove xfers of USBD_NOT_STARTED when pipe is closed.

Patch provided by Nick Hudson.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/sys/dev/usb/usbdi.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/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.181 src/sys/dev/usb/usbdi.c:1.182
--- src/sys/dev/usb/usbdi.c:1.181	Thu Jan 10 22:13:07 2019
+++ src/sys/dev/usb/usbdi.c	Sun Feb 17 04:17:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.181 2019/01/10 22:13:07 skrll Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.182 2019/02/17 04:17:31 rin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.181 2019/01/10 22:13:07 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.182 2019/02/17 04:17:31 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -884,9 +884,13 @@ usbd_ar_pipe(struct usbd_pipe *pipe)
 		USBHIST_LOG(usbdebug, "pipe = %#jx xfer = %#jx "
 		"(methods = %#jx)", (uintptr_t)pipe, (uintptr_t)xfer,
 		(uintptr_t)pipe->up_methods, 0);
-		/* Make the HC abort it (and invoke the callback). */
-		pipe->up_methods->upm_abort(xfer);
-		/* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */
+		if (xfer->ux_status == USBD_NOT_STARTED) {
+			SIMPLEQ_REMOVE_HEAD(>up_queue, ux_next);
+		} else {
+			/* Make the HC abort it (and invoke the callback). */
+			pipe->up_methods->upm_abort(xfer);
+			/* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */
+		}
 	}
 	pipe->up_aborting = 0;
 	return USBD_NORMAL_COMPLETION;



CVS commit: src/sys/modules

2019-02-16 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Feb 17 04:06:01 UTC 2019

Modified Files:
src/sys/modules: Makefile.inc
src/sys/modules/accf_httpready: Makefile
src/sys/modules/acpiacad: Makefile
src/sys/modules/acpibat: Makefile
src/sys/modules/acpibut: Makefile
src/sys/modules/acpicpu: Makefile
src/sys/modules/acpidalb: Makefile
src/sys/modules/acpifan: Makefile
src/sys/modules/acpilid: Makefile
src/sys/modules/acpipmtr: Makefile
src/sys/modules/acpitz: Makefile
src/sys/modules/acpiverbose: Makefile
src/sys/modules/acpivga: Makefile
src/sys/modules/acpiwdrt: Makefile
src/sys/modules/acpiwmi: Makefile
src/sys/modules/adosfs: Makefile
src/sys/modules/aibs: Makefile
src/sys/modules/aio: Makefile
src/sys/modules/amdsmn: Makefile
src/sys/modules/amdtemp: Makefile
src/sys/modules/amdzentemp: Makefile
src/sys/modules/apple_smc: Makefile
src/sys/modules/apple_smc_acpi: Makefile
src/sys/modules/apple_smc_fan: Makefile
src/sys/modules/apple_smc_temp: Makefile
src/sys/modules/asus: Makefile
src/sys/modules/ati_pcigart: Makefile
src/sys/modules/au8522: Makefile
src/sys/modules/audio: Makefile
src/sys/modules/autofs: Makefile
src/sys/modules/auvitek: Makefile
src/sys/modules/azalia: Makefile
src/sys/modules/bpf: Makefile
src/sys/modules/bpf_filter: Makefile
src/sys/modules/ccd: Makefile
src/sys/modules/cd9660: Makefile
src/sys/modules/cgd: Makefile
src/sys/modules/chfs: Makefile
src/sys/modules/cir: Makefile
src/sys/modules/coda: Makefile
src/sys/modules/coda5: Makefile
src/sys/modules/compat_20: Makefile
src/sys/modules/compat_30: Makefile
src/sys/modules/compat_43: Makefile
src/sys/modules/compat_50: Makefile
src/sys/modules/compat_freebsd: Makefile
src/sys/modules/compat_linux: Makefile
src/sys/modules/compat_linux32: Makefile
src/sys/modules/compat_netbsd32: Makefile
src/sys/modules/compat_netbsd32_43: Makefile
src/sys/modules/compat_netbsd32_50: Makefile
src/sys/modules/compat_ossaudio: Makefile
src/sys/modules/compat_raid_50: Makefile
src/sys/modules/compat_sysctl_09_43: Makefile
src/sys/modules/coram: Makefile
src/sys/modules/coredump: Makefile
src/sys/modules/coretemp: Makefile
src/sys/modules/crypto: Makefile
src/sys/modules/cx24227: Makefile
src/sys/modules/cxdtv: Makefile
src/sys/modules/dbcool: Makefile
src/sys/modules/dk_subr: Makefile
src/sys/modules/dm: Makefile
src/sys/modules/drm: Makefile
src/sys/modules/drmkms: Makefile
src/sys/modules/drmkms_agp: Makefile
src/sys/modules/drmkms_linux: Makefile
src/sys/modules/drmkms_pci: Makefile
src/sys/modules/drvctl: Makefile
src/sys/modules/dtrace/dtrace: Makefile
src/sys/modules/dtrace/fbt: Makefile
src/sys/modules/dtrace/linux32_syscall: Makefile
src/sys/modules/dtrace/linux_syscall: Makefile
src/sys/modules/dtrace/netbsd32_syscall: Makefile
src/sys/modules/dtrace/profile: Makefile
src/sys/modules/dtrace/syscall: Makefile
src/sys/modules/dtv: Makefile
src/sys/modules/dtv_math: Makefile
src/sys/modules/efs: Makefile
src/sys/modules/emdtv: Makefile
src/sys/modules/est: Makefile
src/sys/modules/examples/luareadhappy: Makefile
src/sys/modules/examples/readhappy: Makefile
src/sys/modules/examples/readhappy_mpsafe: Makefile
src/sys/modules/exec_elf64: Makefile
src/sys/modules/ext2fs: Makefile
src/sys/modules/ffs: Makefile
src/sys/modules/filecore: Makefile
src/sys/modules/finsio: Makefile
src/sys/modules/flash: Makefile
src/sys/modules/fss: Makefile
src/sys/modules/fujbp: Makefile
src/sys/modules/fujhk: Makefile
src/sys/modules/hdafg: Makefile
src/sys/modules/hdaudio: Makefile
src/sys/modules/hfs: Makefile
src/sys/modules/hpacel: Makefile
src/sys/modules/hpet: Makefile
src/sys/modules/hpqlb: Makefile
src/sys/modules/hythygtemp: Makefile
src/sys/modules/i915drm: Makefile
src/sys/modules/i915drmkms: Makefile
src/sys/modules/if_agr: Makefile
src/sys/modules/if_athn_usb: Makefile
src/sys/modules/if_axe: Makefile
src/sys/modules/if_axen: Makefile
src/sys/modules/if_gif: Makefile
src/sys/modules/if_gre: Makefile
src/sys/modules/if_l2tp: Makefile
src/sys/modules/if_mpls: Makefile
src/sys/modules/if_mue: Makefile
src/sys/modules/if_ppp: Makefile
src/sys/modules/if_pppoe: 

CVS commit: src/sys/modules

2019-02-16 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Feb 17 03:57:31 UTC 2019

Modified Files:
src/sys/modules: Makefile.inc

Log Message:
Turn on DIAGNOSTIC by default for modules in HEAD.

Make us sure that it should be commented out for release branches in
a similar manner to kernel configuration files.

Discussed on tech-kern.


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

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

Modified files:

Index: src/sys/modules/Makefile.inc
diff -u src/sys/modules/Makefile.inc:1.6 src/sys/modules/Makefile.inc:1.7
--- src/sys/modules/Makefile.inc:1.6	Sun Sep 11 18:38:02 2011
+++ src/sys/modules/Makefile.inc	Sun Feb 17 03:57:31 2019
@@ -1,10 +1,14 @@
-#	$NetBSD: Makefile.inc,v 1.6 2011/09/11 18:38:02 mbalmer Exp $
+#	$NetBSD: Makefile.inc,v 1.7 2019/02/17 03:57:31 rin Exp $
 
 S!=		cd ${.PARSEDIR}/..;pwd
 CPPFLAGS+=	-I${NETBSDSRCDIR}/common/include
 USE_FORT=	no
 WARNS?=		3
 
+# inexpensive kernel consistency checks
+# XXX to be commented out on release branch
+CPPFLAGS+=	-DDIAGNOSTIC
+
 .if !empty(IOCONF)
 _BSD_IOCONF_MK_USER_=1
 .include 



CVS commit: src/tools/gcc

2019-02-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Feb 17 00:22:53 UTC 2019

Modified Files:
src/tools/gcc: Makefile

Log Message:
don't pass --disable-symver to mknative configure.  this turns off
the checking for gcc 4.6 and some exception handling routines which
we need on several platforms.

this should fix missing symbol issues seen on current-users.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/tools/gcc/Makefile

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

Modified files:

Index: src/tools/gcc/Makefile
diff -u src/tools/gcc/Makefile:1.90 src/tools/gcc/Makefile:1.91
--- src/tools/gcc/Makefile:1.90	Sun Feb  3 11:57:25 2019
+++ src/tools/gcc/Makefile	Sun Feb 17 00:22:53 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.90 2019/02/03 11:57:25 mrg Exp $
+#	$NetBSD: Makefile,v 1.91 2019/02/17 00:22:53 mrg Exp $
 
 .include 
 
@@ -187,7 +187,6 @@ EXTRA_GCC_TARGETS=	i386-builtin-types.in
 
 NATIVE_CONFIGURE_ARGS+=	\
 			--disable-multilib \
-			--disable-symvers \
 			--disable-libstdcxx-pch \
 			--build=`${GCCDIST}/config.guess` \
 			--host=${MACHINE_GNU_PLATFORM} \



CVS commit: src/external/gpl3/gcc/lib/libstdc++-v3

2019-02-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Feb 17 00:05:11 UTC 2019

Modified Files:
src/external/gpl3/gcc/lib/libstdc++-v3: Makefile

Log Message:
apply -std=gnu++98 to some more files.

state that some hard coded stuff here should be pulled out with mknative.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/external/gpl3/gcc/lib/libstdc++-v3/Makefile

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

Modified files:

Index: src/external/gpl3/gcc/lib/libstdc++-v3/Makefile
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/Makefile:1.42 src/external/gpl3/gcc/lib/libstdc++-v3/Makefile:1.43
--- src/external/gpl3/gcc/lib/libstdc++-v3/Makefile:1.42	Fri Feb  8 03:59:34 2019
+++ src/external/gpl3/gcc/lib/libstdc++-v3/Makefile	Sun Feb 17 00:05:11 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.42 2019/02/08 03:59:34 mrg Exp $
+#	$NetBSD: Makefile,v 1.43 2019/02/17 00:05:11 mrg Exp $
 
 REQUIRETOOLS=	yes
 NOLINT=		# defined
@@ -147,6 +147,7 @@ SRCS+=	c98-codecvt.cc c11-codecvt.cc
 .include "../Makefile.gthr"
 
 # XXX Make this either/or, not one, and maybe another
+# XXX pull out libstdc++/Makefile/cxx11_sources for many of these.
 CXX11_ALWAYS=	localename.cc \
 		locale_init.cc \
 		compatibility-c++0x.cc \
@@ -160,6 +161,15 @@ CXX11_ALWAYS=	localename.cc \
 COPTS.${_s}+= -std=gnu++11
 .endfor
 
+# XXX pull out libstdc++/Makefile/cxx98_sources for many of these.
+CXX98_ALWAYS=	compatibility.cc \
+		compatibility-debug_list.cc \
+		compatibility-debug_list-2.cc
+
+.for _s in ${CXX98_ALWAYS}
+COPTS.${_s}+= -std=gnu++98
+.endfor
+
 COPTS.cp-demangle.c += -Wno-unused-function
 
 COPTS.ext-inst.cc+= -Wno-error



CVS commit: src/sys/dev/acpi

2019-02-16 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Sat Feb 16 23:28:57 UTC 2019

Modified Files:
src/sys/dev/acpi: xhci_acpi.c

Log Message:
Fix cut & paste error in comment


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/acpi/xhci_acpi.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/acpi/xhci_acpi.c
diff -u src/sys/dev/acpi/xhci_acpi.c:1.2 src/sys/dev/acpi/xhci_acpi.c:1.3
--- src/sys/dev/acpi/xhci_acpi.c:1.2	Fri Nov 16 23:18:17 2018
+++ src/sys/dev/acpi/xhci_acpi.c	Sat Feb 16 23:28:56 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: xhci_acpi.c,v 1.2 2018/11/16 23:18:17 jmcneill Exp $ */
+/* $NetBSD: xhci_acpi.c,v 1.3 2019/02/16 23:28:56 tron Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_acpi.c,v 1.2 2018/11/16 23:18:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_acpi.c,v 1.3 2019/02/16 23:28:56 tron Exp $");
 
 #include 
 #include 
@@ -50,8 +50,8 @@ __KERNEL_RCSID(0, "$NetBSD: xhci_acpi.c,
 #include 
 
 static const char * const compatible[] = {
-	"PNP0D10",	/* EHCI-compliant USB controller without standard debug */
-	"PNP0D15",	/* EHCI-compliant USB controller with standard debug */
+	"PNP0D10",	/* XHCI-compliant USB controller without standard debug */
+	"PNP0D15",	/* XHCI-compliant USB controller with standard debug */
 	NULL
 };
 



CVS commit: src/usr.bin/menuc

2019-02-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 16 19:09:07 UTC 2019

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

Log Message:
Typo in member variable name


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/menuc/menuc.1

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

Modified files:

Index: src/usr.bin/menuc/menuc.1
diff -u src/usr.bin/menuc/menuc.1:1.35 src/usr.bin/menuc/menuc.1:1.36
--- src/usr.bin/menuc/menuc.1:1.35	Sat Feb 16 18:57:21 2019
+++ src/usr.bin/menuc/menuc.1	Sat Feb 16 19:09:07 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: menuc.1,v 1.35 2019/02/16 18:57:21 martin Exp $
+.\"	$NetBSD: menuc.1,v 1.36 2019/02/16 19:09:07 martin Exp $
 .\"
 .\" Copyright 1997 Piermont Information Systems Inc.
 .\" All rights reserved.
@@ -29,7 +29,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 .\" THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 20, 2018
+.Dd February 16, 2019
 .Dt MENUC 1
 .Os
 .Sh NAME
@@ -560,7 +560,7 @@ menu.
 This return value is used when actions modify the menu definition on the
 fly, e.g. adding or removing additional menu items.
 The action may set
-.Dq cur_sel
+.Dq cursel
 to jump to an arbitrary menu item (in the modified menu).
 .El
 .Sh MENU ITEM EXPANSION



CVS commit: src/usr.bin/menuc

2019-02-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 16 18:57:21 UTC 2019

Modified Files:
src/usr.bin/menuc: menu_sys.def menuc.1

Log Message:
Document return values from menu items opt_action functions, add a
new variant: -1 when functions have fundamentally changed the menu
definition on the fly and the processing functions needs to restart
without looking at the old state (or stale cached pointers).


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.bin/menuc/menu_sys.def
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/menuc/menuc.1

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

Modified files:

Index: src/usr.bin/menuc/menu_sys.def
diff -u src/usr.bin/menuc/menu_sys.def:1.65 src/usr.bin/menuc/menu_sys.def:1.66
--- src/usr.bin/menuc/menu_sys.def:1.65	Wed Feb  6 20:08:15 2019
+++ src/usr.bin/menuc/menu_sys.def	Sat Feb 16 18:57:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: menu_sys.def,v 1.65 2019/02/06 20:08:15 martin Exp $	*/
+/*	$NetBSD: menu_sys.def,v 1.66 2019/02/16 18:57:21 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -688,7 +688,7 @@ void
 process_menu(int num, void *arg)
 {
 	int sel = 0;
-	int req;
+	int req, rv;
 	menu_ent *opt;
 
 	menudesc *m;
@@ -754,8 +754,13 @@ process_menu(int num, void *arg)
 			continue;
 		if (opt->opt_flags & OPT_ENDWIN)
 			endwin();
-		if (opt->opt_action && (*opt->opt_action)(m, arg))
-			break;
+		if (opt->opt_action) {
+			rv = (*opt->opt_action)(m, arg);
+			if (rv == -1)
+continue;
+			else if (rv != 0)
+break;
+		}
 
 		if (opt->opt_menu != -1) {
 			if (!(opt->opt_flags & OPT_SUB)) {

Index: src/usr.bin/menuc/menuc.1
diff -u src/usr.bin/menuc/menuc.1:1.34 src/usr.bin/menuc/menuc.1:1.35
--- src/usr.bin/menuc/menuc.1:1.34	Fri Jan  4 15:27:19 2019
+++ src/usr.bin/menuc/menuc.1	Sat Feb 16 18:57:21 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: menuc.1,v 1.34 2019/01/04 15:27:19 martin Exp $
+.\"	$NetBSD: menuc.1,v 1.35 2019/02/16 18:57:21 martin Exp $
 .\"
 .\" Copyright 1997 Piermont Information Systems Inc.
 .\" All rights reserved.
@@ -539,6 +539,30 @@ is the text for the exit line of the men
 If it's null, string
 .Dq Exit
 is used.
+.Sh MENU ITEM ACTIONS
+When creating dynamic menus, the programer supplies function pointers
+for the menu items
+.Dv opt_action
+member.
+This functions return one of three possible values:
+.Bl -tag -width "-1" -compact
+.It 0
+process sub menu (if set) and continue with the current (or new) menu
+as usual.
+.It 1
+exit the current menu.
+This is equivalen to specifying
+.Dq exit
+in a non-dynamic menu specification.
+.It -1
+do not handle the current item any further and restart handling the (same)
+menu.
+This return value is used when actions modify the menu definition on the
+fly, e.g. adding or removing additional menu items.
+The action may set
+.Dq cur_sel
+to jump to an arbitrary menu item (in the modified menu).
+.El
 .Sh MENU ITEM EXPANSION
 With the
 .Ic enable expansion



CVS commit: src/usr.bin/at

2019-02-16 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Feb 16 17:56:57 UTC 2019

Modified Files:
src/usr.bin/at: parsetime.c

Log Message:
PR bin/53986 from Christian Weisgerber

Skip forward to tomorrow to run a command earlier in the current
hour than now (as well as during an earlier hour of the day).


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/at/parsetime.c

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

Modified files:

Index: src/usr.bin/at/parsetime.c
diff -u src/usr.bin/at/parsetime.c:1.19 src/usr.bin/at/parsetime.c:1.20
--- src/usr.bin/at/parsetime.c:1.19	Sun Jan 18 01:02:31 2009
+++ src/usr.bin/at/parsetime.c	Sat Feb 16 17:56:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: parsetime.c,v 1.19 2009/01/18 01:02:31 lukem Exp $	*/
+/*	$NetBSD: parsetime.c,v 1.20 2019/02/16 17:56:57 kre Exp $	*/
 
 /*
  * parsetime.c - parse time for at(1)
@@ -160,7 +160,7 @@ static bool sc_tokplur;	/* scanner - is 
 #if 0
 static char rcsid[] = "$OpenBSD: parsetime.c,v 1.4 1997/03/01 23:40:10 millert Exp $";
 #else
-__RCSID("$NetBSD: parsetime.c,v 1.19 2009/01/18 01:02:31 lukem Exp $");
+__RCSID("$NetBSD: parsetime.c,v 1.20 2019/02/16 17:56:57 kre Exp $");
 #endif
 #endif
 
@@ -405,7 +405,8 @@ tod(struct tm *tm)
 	 * if we've gone past that time - but if we're specifying a time plus
 	 * a relative offset, it's okay to bump things
 	 */
-	if ((sc_tokid == TOKEOF || sc_tokid == PLUS) && tm->tm_hour > hour) {
+	if ((sc_tokid == TOKEOF || sc_tokid == PLUS) && (tm->tm_hour > hour ||
+	(tm->tm_hour == hour && tm->tm_min > minute))) {
 		tm->tm_mday++;
 		tm->tm_wday++;
 	}



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

2019-02-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 16 16:20:50 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi: sunxi_mixer.c

Log Message:
Fix HDMI output; only install cursor_set/cursor_move funcs if hardware cursor 
is available.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_mixer.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/sunxi/sunxi_mixer.c
diff -u src/sys/arch/arm/sunxi/sunxi_mixer.c:1.6 src/sys/arch/arm/sunxi/sunxi_mixer.c:1.7
--- src/sys/arch/arm/sunxi/sunxi_mixer.c:1.6	Wed Feb  6 03:07:08 2019
+++ src/sys/arch/arm/sunxi/sunxi_mixer.c	Sat Feb 16 16:20:50 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_mixer.c,v 1.6 2019/02/06 03:07:08 jmcneill Exp $ */
+/* $NetBSD: sunxi_mixer.c,v 1.7 2019/02/16 16:20:50 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.6 2019/02/06 03:07:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.7 2019/02/16 16:20:50 jmcneill Exp $");
 
 #include 
 #include 
@@ -420,7 +420,7 @@ sunxi_mixer_cursor_move(struct drm_crtc 
 	return 0;
 }
 
-static const struct drm_crtc_funcs sunxi_mixer_crtc_funcs = {
+static const struct drm_crtc_funcs sunxi_mixer0_crtc_funcs = {
 	.set_config = drm_crtc_helper_set_config,
 	.destroy = sunxi_mixer_destroy,
 	.page_flip = sunxi_mixer_page_flip,
@@ -428,6 +428,12 @@ static const struct drm_crtc_funcs sunxi
 	.cursor_move = sunxi_mixer_cursor_move,
 };
 
+static const struct drm_crtc_funcs sunxi_mixer1_crtc_funcs = {
+	.set_config = drm_crtc_helper_set_config,
+	.destroy = sunxi_mixer_destroy,
+	.page_flip = sunxi_mixer_page_flip,
+};
+
 static void
 sunxi_mixer_dpms(struct drm_crtc *crtc, int mode)
 {
@@ -1184,7 +1190,10 @@ sunxi_mixer_ep_activate(device_t dev, st
 	BLD_WRITE(sc, BLD_CTL(2), 0x03010301);
 	BLD_WRITE(sc, BLD_CTL(3), 0x03010301);
 
-	drm_crtc_init(ddev, >sc_crtc.base, _mixer_crtc_funcs);
+	if (sc->sc_ovl_ui_count > 1)
+		drm_crtc_init(ddev, >sc_crtc.base, _mixer0_crtc_funcs);
+	else
+		drm_crtc_init(ddev, >sc_crtc.base, _mixer1_crtc_funcs);
 	drm_crtc_helper_add(>sc_crtc.base, _mixer_crtc_helper_funcs);
 
 	drm_universal_plane_init(ddev, >sc_overlay.base,



CVS commit: src/sys/dev/nvmm/x86

2019-02-16 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb 16 12:58:14 UTC 2019

Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_svm.c

Log Message:
Ah no, adapt previous, on AMD RAX is in the VMCB.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/nvmm/x86/nvmm_x86_svm.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/nvmm/x86/nvmm_x86_svm.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.25 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.26
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.25	Sat Feb 16 12:40:31 2019
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c	Sat Feb 16 12:58:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_svm.c,v 1.25 2019/02/16 12:40:31 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_svm.c,v 1.26 2019/02/16 12:58:13 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.25 2019/02/16 12:40:31 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.26 2019/02/16 12:58:13 maxv Exp $");
 
 #include 
 #include 
@@ -772,7 +772,7 @@ svm_inkernel_handle_cpuid(struct nvmm_cp
 		}
 		switch (ecx) {
 		case 0:
-			cpudata->gprs[NVMM_X64_GPR_RAX] = svm_xcr0_mask & 0x;
+			cpudata->vmcb->state.rax = svm_xcr0_mask & 0x;
 			if (cpudata->gxcr0 & XCR0_SSE) {
 cpudata->gprs[NVMM_X64_GPR_RBX] = sizeof(struct fxsave);
 			} else {
@@ -783,7 +783,7 @@ svm_inkernel_handle_cpuid(struct nvmm_cp
 			cpudata->gprs[NVMM_X64_GPR_RDX] = svm_xcr0_mask >> 32;
 			break;
 		case 1:
-			cpudata->gprs[NVMM_X64_GPR_RAX] &= ~CPUID_PES1_XSAVES;
+			cpudata->vmcb->state.rax &= ~CPUID_PES1_XSAVES;
 			break;
 		}
 		break;



CVS commit: src/sys/dev/nvmm/x86

2019-02-16 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb 16 12:40:31 UTC 2019

Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c

Log Message:
Improve the FPU detection: hide XSAVES because we're not allowing it, and
don't set CPUID2_OSXSAVE if the guest didn't first set CR4_OSXSAVE.

With these changes in place, I can boot Windows 10 on NVMM.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
cvs rdiff -u -r1.5 -r1.6 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/sys/dev/nvmm/x86/nvmm_x86_svm.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.24 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.25
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.24	Fri Feb 15 13:17:05 2019
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c	Sat Feb 16 12:40:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_svm.c,v 1.24 2019/02/15 13:17:05 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_svm.c,v 1.25 2019/02/16 12:40:31 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.24 2019/02/15 13:17:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.25 2019/02/16 12:40:31 maxv Exp $");
 
 #include 
 #include 
@@ -752,26 +752,40 @@ static void
 svm_inkernel_handle_cpuid(struct nvmm_cpu *vcpu, uint64_t eax, uint64_t ecx)
 {
 	struct svm_cpudata *cpudata = vcpu->cpudata;
+	uint64_t cr4;
 
 	switch (eax) {
-	case 0x0001: /* APIC number in RBX. The rest is tunable. */
+	case 0x0001:
 		cpudata->gprs[NVMM_X64_GPR_RBX] &= ~CPUID_LOCAL_APIC_ID;
 		cpudata->gprs[NVMM_X64_GPR_RBX] |= __SHIFTIN(vcpu->cpuid,
 		CPUID_LOCAL_APIC_ID);
+
+		/* CPUID2_OSXSAVE depends on CR4. */
+		cr4 = cpudata->vmcb->state.cr4;
+		if (!(cr4 & CR4_OSXSAVE)) {
+			cpudata->gprs[NVMM_X64_GPR_RCX] &= ~CPUID2_OSXSAVE;
+		}
 		break;
-	case 0x000D: /* FPU description. Not tunable. */
-		if (ecx != 0 || svm_xcr0_mask == 0) {
+	case 0x000D:
+		if (svm_xcr0_mask == 0) {
 			break;
 		}
-		cpudata->vmcb->state.rax = svm_xcr0_mask & 0x;
-		if (cpudata->gxcr0 & XCR0_SSE) {
-			cpudata->gprs[NVMM_X64_GPR_RBX] = sizeof(struct fxsave);
-		} else {
-			cpudata->gprs[NVMM_X64_GPR_RBX] = sizeof(struct save87);
+		switch (ecx) {
+		case 0:
+			cpudata->gprs[NVMM_X64_GPR_RAX] = svm_xcr0_mask & 0x;
+			if (cpudata->gxcr0 & XCR0_SSE) {
+cpudata->gprs[NVMM_X64_GPR_RBX] = sizeof(struct fxsave);
+			} else {
+cpudata->gprs[NVMM_X64_GPR_RBX] = sizeof(struct save87);
+			}
+			cpudata->gprs[NVMM_X64_GPR_RBX] += 64; /* XSAVE header */
+			cpudata->gprs[NVMM_X64_GPR_RCX] = sizeof(struct fxsave);
+			cpudata->gprs[NVMM_X64_GPR_RDX] = svm_xcr0_mask >> 32;
+			break;
+		case 1:
+			cpudata->gprs[NVMM_X64_GPR_RAX] &= ~CPUID_PES1_XSAVES;
+			break;
 		}
-		cpudata->gprs[NVMM_X64_GPR_RBX] += 64; /* XSAVE header */
-		cpudata->gprs[NVMM_X64_GPR_RCX] = sizeof(struct fxsave);
-		cpudata->gprs[NVMM_X64_GPR_RDX] = svm_xcr0_mask >> 32;
 		break;
 	case 0x4000:
 		cpudata->gprs[NVMM_X64_GPR_RBX] = 0;
@@ -781,7 +795,7 @@ svm_inkernel_handle_cpuid(struct nvmm_cp
 		memcpy(>gprs[NVMM_X64_GPR_RCX], "NVMM", 4);
 		memcpy(>gprs[NVMM_X64_GPR_RDX], " ___", 4);
 		break;
-	case 0x8001: /* No SVM, no RDTSCP. The rest is tunable. */
+	case 0x8001:
 		cpudata->gprs[NVMM_X64_GPR_RCX] &= ~CPUID_SVM;
 		cpudata->gprs[NVMM_X64_GPR_RDX] &= ~CPUID_RDTSCP;
 		break;

Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.5 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.6
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.5	Sat Feb 16 12:05:30 2019
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Sat Feb 16 12:40:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.5 2019/02/16 12:05:30 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.6 2019/02/16 12:40:31 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.5 2019/02/16 12:05:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.6 2019/02/16 12:40:31 maxv Exp $");
 
 #include 
 #include 
@@ -984,6 +984,7 @@ static void
 vmx_inkernel_handle_cpuid(struct nvmm_cpu *vcpu, uint64_t eax, uint64_t ecx)
 {
 	struct vmx_cpudata *cpudata = vcpu->cpudata;
+	uint64_t cr4;
 
 	switch (eax) {
 	case 0x0001:
@@ -995,6 +996,12 @@ vmx_inkernel_handle_cpuid(struct nvmm_cp
 		  CPUID2_PCID|CPUID2_DEADLINE);
 		cpudata->gprs[NVMM_X64_GPR_RDX] &=
 		~(CPUID_DS|CPUID_ACPI|CPUID_TM);
+
+		/* CPUID2_OSXSAVE depends on CR4. */
+		vmx_vmread(VMCS_GUEST_CR4, );
+		if (!(cr4 & CR4_OSXSAVE)) {
+			cpudata->gprs[NVMM_X64_GPR_RCX] &= ~CPUID2_OSXSAVE;
+		}
 		break;
 	case 0x0005:
 	case 0x0006:
@@ -1010,18 +1017,25 @@ vmx_inkernel_handle_cpuid(struct nvmm_cp
 		  CPUID_SEF_SSBD);
 		break;
 	case 0x000D:
-		if (ecx != 0 || 

CVS commit: src/sys

2019-02-16 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb 16 12:05:30 UTC 2019

Modified Files:
src/sys/arch/x86/include: specialreg.h
src/sys/dev/nvmm/x86: nvmm_x86_vmx.c

Log Message:
Handle MSR_MISC_ENABLE on NVMM-Intel (Intel-specific).


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/arch/x86/include/specialreg.h
cvs rdiff -u -r1.4 -r1.5 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/sys/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.140 src/sys/arch/x86/include/specialreg.h:1.141
--- src/sys/arch/x86/include/specialreg.h:1.140	Mon Feb 11 14:59:32 2019
+++ src/sys/arch/x86/include/specialreg.h	Sat Feb 16 12:05:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.140 2019/02/11 14:59:32 cherry Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.141 2019/02/16 12:05:30 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -768,7 +768,16 @@
 #define MSR_THERM_STATUS	0x19c
 #define MSR_THERM2_CTL		0x19d	/* Pentium M */
 #define MSR_MISC_ENABLE		0x1a0
-#define 	IA32_MISC_MWAIT_EN	0x4
+#define 	IA32_MISC_FAST_STR_EN	__BIT(0)
+#define 	IA32_MISC_ATCC_EN	__BIT(3)
+#define 	IA32_MISC_PERFMON_EN	__BIT(7)
+#define 	IA32_MISC_BTS_UNAVAIL	__BIT(11)
+#define 	IA32_MISC_PEBS_UNAVAIL	__BIT(12)
+#define 	IA32_MISC_EISST_EN	__BIT(16)
+#define 	IA32_MISC_MWAIT_EN	__BIT(18)
+#define 	IA32_MISC_LIMIT_CPUID	__BIT(22)
+#define 	IA32_MISC_XTPR_DIS	__BIT(23)
+#define 	IA32_MISC_XD_DIS	__BIT(34)
 #define MSR_TEMPERATURE_TARGET	0x1a2
 #define MSR_DEBUGCTLMSR		0x1d9
 #define MSR_LASTBRANCHFROMIP	0x1db

Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.4 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.5
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.4	Fri Feb 15 13:17:05 2019
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Sat Feb 16 12:05:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.4 2019/02/15 13:17:05 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.5 2019/02/16 12:05:30 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.4 2019/02/15 13:17:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.5 2019/02/16 12:05:30 maxv Exp $");
 
 #include 
 #include 
@@ -665,6 +665,7 @@ struct vmx_cpudata {
 	/* Guest state */
 	struct msr_entry *gmsr;
 	paddr_t gmsr_pa;
+	uint64_t gmsr_misc_enable;
 	uint64_t gcr2;
 	uint64_t gcr8;
 	uint64_t gxcr0;
@@ -1361,6 +1362,12 @@ vmx_inkernel_handle_msr(struct nvmm_mach
 			cpudata->gprs[NVMM_X64_GPR_RDX] = (val >> 32);
 			goto handled;
 		}
+		if (exit->u.msr.msr == MSR_MISC_ENABLE) {
+			val = cpudata->gmsr_misc_enable;
+			cpudata->gprs[NVMM_X64_GPR_RAX] = (val & 0x);
+			cpudata->gprs[NVMM_X64_GPR_RDX] = (val >> 32);
+			goto handled;
+		}
 		for (i = 0; i < __arraycount(msr_ignore_list); i++) {
 			if (msr_ignore_list[i] != exit->u.msr.msr)
 continue;
@@ -1381,6 +1388,10 @@ vmx_inkernel_handle_msr(struct nvmm_mach
 			vmx_vmwrite(VMCS_GUEST_IA32_PAT, exit->u.msr.val);
 			goto handled;
 		}
+		if (exit->u.msr.msr == MSR_MISC_ENABLE) {
+			/* Don't care. */
+			goto handled;
+		}
 		for (i = 0; i < __arraycount(msr_ignore_list); i++) {
 			if (msr_ignore_list[i] != exit->u.msr.msr)
 continue;
@@ -2007,6 +2018,13 @@ vmx_vcpu_init(struct nvmm_machine *mach,
 	mach->vm->vm_map.pmap->pm_pdirpa[0];
 	vmx_vmwrite(VMCS_EPTP, eptp);
 
+	/* Init IA32_MISC_ENABLE. */
+	cpudata->gmsr_misc_enable = rdmsr(MSR_MISC_ENABLE);
+	cpudata->gmsr_misc_enable &=
+	~(IA32_MISC_PERFMON_EN|IA32_MISC_EISST_EN|IA32_MISC_MWAIT_EN);
+	cpudata->gmsr_misc_enable |=
+	(IA32_MISC_BTS_UNAVAIL|IA32_MISC_PEBS_UNAVAIL);
+
 	/* Must always be set. */
 	vmx_vmwrite(VMCS_GUEST_CR4, CR4_VMXE);
 	vmx_vmwrite(VMCS_GUEST_CR0, CR0_NE);