CVS commit: src/sys/kern

2020-06-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jun  2 02:04:35 UTC 2020

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

Log Message:
Appease clang -Wtentative-definition-incomplete-type.

Now, both kernel and crash(8) build with clang for amd64
(and certainly other ports also).

Pointed out by joerg.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/kern/kern_timeout.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_timeout.c
diff -u src/sys/kern/kern_timeout.c:1.64 src/sys/kern/kern_timeout.c:1.65
--- src/sys/kern/kern_timeout.c:1.64	Sun May 31 23:24:20 2020
+++ src/sys/kern/kern_timeout.c	Tue Jun  2 02:04:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_timeout.c,v 1.64 2020/05/31 23:24:20 rin Exp $	*/
+/*	$NetBSD: kern_timeout.c,v 1.65 2020/06/02 02:04:35 rin Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.64 2020/05/31 23:24:20 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.65 2020/06/02 02:04:35 rin Exp $");
 
 /*
  * Timeouts are kept in a hierarchical timing wheel.  The c_time is the
@@ -104,9 +104,6 @@ __KERNEL_RCSID(0, "$NetBSD: kern_timeout
 #include 
 #include 
 #include 
-
-static struct callout_cpu ccb;
-static struct cpu_info cib;
 #endif
 
 #define BUCKETS		1024
@@ -185,8 +182,12 @@ struct callout_cpu {
 	char		cc_name2[12];
 };
 
-#ifndef CRASH
+#ifdef DDB
+static struct callout_cpu ccb;
+static struct cpu_info cib;
+#endif
 
+#ifndef CRASH /* _KERNEL */
 static void	callout_softclock(void *);
 static void	callout_wait(callout_impl_t *, void *, kmutex_t *);
 



CVS commit: src/distrib/evbarm/installimage

2020-06-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jun  2 01:34:50 UTC 2020

Modified Files:
src/distrib/evbarm/installimage: Makefile

Log Message:
Exclude ramdisk images and empty instkernel directory


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/distrib/evbarm/installimage/Makefile

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

Modified files:

Index: src/distrib/evbarm/installimage/Makefile
diff -u src/distrib/evbarm/installimage/Makefile:1.3 src/distrib/evbarm/installimage/Makefile:1.4
--- src/distrib/evbarm/installimage/Makefile:1.3	Sat May 30 12:36:37 2020
+++ src/distrib/evbarm/installimage/Makefile	Tue Jun  2 01:34:50 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2020/05/30 12:36:37 jmcneill Exp $
+#	$NetBSD: Makefile,v 1.4 2020/06/02 01:34:50 jmcneill Exp $
 
 .include 
 
@@ -31,6 +31,7 @@ IMGFILE_EXTRA=\
 	${SYSINSTDIR}/sysinst		.
 
 MD_IMGDIR_EXCLUDE=	-s ',./binary/gzimg.*,,gp'
-MD_IMGDIR_EXCLUDE+=	-s ',./binary/instkernel.*,,gp'
+MD_IMGDIR_EXCLUDE+=	-s ',./installation/instkernel.*,,gp'
+MD_IMGDIR_EXCLUDE+=	-s ',./installation/ramdisk.*,,gp'
 
 .include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.installimage"



CVS commit: src/lib/libc

2020-06-01 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Jun  2 01:30:31 UTC 2020

Modified Files:
src/lib/libc/citrus: citrus_ctype_template.h
src/lib/libc/locale: multibyte.h

Log Message:
Don't overalign _RuneStatePriv, it must share the alignment of mbstate_t
it aliased with. Assert that the alignment actually used reflects the
alignment required by existing implementation and for newly build
modules assert that it is at most the guaranteed alignment.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/lib/libc/citrus/citrus_ctype_template.h
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/locale/multibyte.h

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

Modified files:

Index: src/lib/libc/citrus/citrus_ctype_template.h
diff -u src/lib/libc/citrus/citrus_ctype_template.h:1.37 src/lib/libc/citrus/citrus_ctype_template.h:1.38
--- src/lib/libc/citrus/citrus_ctype_template.h:1.37	Sun Jul 28 14:26:08 2019
+++ src/lib/libc/citrus/citrus_ctype_template.h	Tue Jun  2 01:30:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: citrus_ctype_template.h,v 1.37 2019/07/28 14:26:08 christos Exp $	*/
+/*	$NetBSD: citrus_ctype_template.h,v 1.38 2020/06/02 01:30:31 joerg Exp $	*/
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -118,6 +118,7 @@
  *
  */
 
+#include 
 
 /* prototypes */
 
@@ -506,6 +507,10 @@ _FUNCNAME(ctype_getops)(_citrus_ctype_op
 	return (0);
 }
 
+/* Ensure alignment matches guarantees from locale/multibyte.h */
+__CTASSERT(alignof(_ENCODING_STATE) <= alignof(int) ||
+   alignof(_ENCODING_STATE) <= alignof(void *));
+
 static int
 _FUNCNAME(ctype_init)(void ** __restrict cl,
 		  void * __restrict var, size_t lenvar, size_t lenps)

Index: src/lib/libc/locale/multibyte.h
diff -u src/lib/libc/locale/multibyte.h:1.6 src/lib/libc/locale/multibyte.h:1.7
--- src/lib/libc/locale/multibyte.h:1.6	Sun Aug 18 20:03:48 2013
+++ src/lib/libc/locale/multibyte.h	Tue Jun  2 01:30:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: multibyte.h,v 1.6 2013/08/18 20:03:48 joerg Exp $	*/
+/*	$NetBSD: multibyte.h,v 1.7 2020/06/02 01:30:31 joerg Exp $	*/
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -29,6 +29,8 @@
 #ifndef _MULTIBYTE_H_
 #define _MULTIBYTE_H_
 
+#include 
+
 /* mbstate_t private */
 
 #ifdef _BSD_MBSTATE_T_
@@ -38,9 +40,14 @@ typedef	_BSD_MBSTATE_T_	mbstate_t;
 
 typedef struct _RuneStatePriv {
 	_RuneLocale	*__runelocale;
-	char		__private __attribute__((__aligned__));
+	char		__private[];
 } _RuneStatePriv;
 
+__CTASSERT(alignof(struct _RuneStatePriv) >= alignof(void *));
+__CTASSERT(sizeof(_RuneStatePriv) % alignof(void *) == 0);
+__CTASSERT(alignof(struct _RuneStatePriv) >= alignof(int));
+__CTASSERT(sizeof(_RuneStatePriv) % alignof(int) == 0);
+
 typedef union _RuneState {
 	mbstate_t		__pad;
 	struct _RuneStatePriv	__priv;
@@ -91,7 +98,7 @@ _ps_to_private(mbstate_t *ps)
 {
 	if (ps == NULL)
 		return NULL;
-	return (void *)&_ps_to_runestate(ps)->rs_private;
+	return _ps_to_runestate(ps)->rs_private;
 }
 
 static __inline void const *
@@ -99,7 +106,7 @@ _ps_to_private_const(mbstate_t const *ps
 {
 	if (ps == NULL)
 		return NULL;
-	return (void const *)&_ps_to_runestate_const(ps)->rs_private;
+	return _ps_to_runestate_const(ps)->rs_private;
 }
 
 static __inline void



CVS commit: src/lib/libpthread

2020-06-01 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Jun  2 00:29:53 UTC 2020

Modified Files:
src/lib/libpthread: pthread.c pthread_int.h pthread_rwlock.c

Log Message:
Pass down errno when calling pthread__errorfunc after a system call.
Allow format arguments for that reason and use (v)snprintf_ss in
pthread_errorfunc to avoid race conditions and the like.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/lib/libpthread/pthread.c
cvs rdiff -u -r1.105 -r1.106 src/lib/libpthread/pthread_int.h
cvs rdiff -u -r1.41 -r1.42 src/lib/libpthread/pthread_rwlock.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/libpthread/pthread.c
diff -u src/lib/libpthread/pthread.c:1.171 src/lib/libpthread/pthread.c:1.172
--- src/lib/libpthread/pthread.c:1.171	Mon Jun  1 11:44:59 2020
+++ src/lib/libpthread/pthread.c	Tue Jun  2 00:29:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread.c,v 1.171 2020/06/01 11:44:59 ad Exp $	*/
+/*	$NetBSD: pthread.c,v 1.172 2020/06/02 00:29:53 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: pthread.c,v 1.171 2020/06/01 11:44:59 ad Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.172 2020/06/02 00:29:53 joerg Exp $");
 
 #define	__EXPOSE_STACK	1
 
@@ -622,7 +622,7 @@ pthread__clear_waiters(pthread_t self)
 		self->pt_nwaiters = 0;
 		if (rv != 0) {
 			pthread__errorfunc(__FILE__, __LINE__, __func__,
-			"_lwp_unpark failed");
+			"_lwp_unpark failed: %d", errno);
 		}
 		break;
 	default:
@@ -631,7 +631,7 @@ pthread__clear_waiters(pthread_t self)
 		self->pt_nwaiters = 0;
 		if (rv != 0) {
 			pthread__errorfunc(__FILE__, __LINE__, __func__,
-			"_lwp_unpark_all failed");
+			"_lwp_unpark_all failed: %d", errno);
 		}
 		break;
 	}
@@ -1102,23 +1102,29 @@ pthread__assertfunc(const char *file, in
 
 void
 pthread__errorfunc(const char *file, int line, const char *function,
-		   const char *msg)
+		   const char *msg, ...)
 {
 	char buf[1024];
+	char buf2[1024];
 	size_t len;
+	va_list ap;
 
 	if (pthread__diagassert == 0)
 		return;
 
+	va_start(ap, msg);
+	vsnprintf_ss(buf2, sizeof(buf2), msg, ap);
+	va_end(ap);
+
 	/*
 	 * snprintf should not acquire any locks, or we could
 	 * end up deadlocked if the assert caller held locks.
 	 */
-	len = snprintf(buf, 1024,
+	len = snprintf_ss(buf, sizeof(buf),
 	"%s: Error detected by libpthread: %s.\n"
 	"Detected by file \"%s\", line %d%s%s%s.\n"
 	"See pthread(3) for information.\n",
-	getprogname(), msg, file, line,
+	getprogname(), buf2, file, line,
 	function ? ", function \"" : "",
 	function ? function : "",
 	function ? "\"" : "");
@@ -1195,7 +1201,7 @@ pthread__park(pthread_t self, pthread_mu
 break;
 			default:
 pthread__errorfunc(__FILE__, __LINE__,
-__func__, "_lwp_park failed");
+__func__, "_lwp_park failed: %d", errno);
 break;
 			}
 		}

Index: src/lib/libpthread/pthread_int.h
diff -u src/lib/libpthread/pthread_int.h:1.105 src/lib/libpthread/pthread_int.h:1.106
--- src/lib/libpthread/pthread_int.h:1.105	Mon Jun  1 11:44:59 2020
+++ src/lib/libpthread/pthread_int.h	Tue Jun  2 00:29:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread_int.h,v 1.105 2020/06/01 11:44:59 ad Exp $	*/
+/*	$NetBSD: pthread_int.h,v 1.106 2020/06/02 00:29:53 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020
@@ -300,8 +300,8 @@ void	pthread__copy_tsd(pthread_t) PTHREA
 
 __dead void	pthread__assertfunc(const char *, int, const char *, const char *)
 			PTHREAD_HIDE;
-void	pthread__errorfunc(const char *, int, const char *, const char *)
-			   PTHREAD_HIDE;
+void	pthread__errorfunc(const char *, int, const char *, const char *, ...)
+			__printflike(4, 5) PTHREAD_HIDE;
 char	*pthread__getenv(const char *) PTHREAD_HIDE;
 __dead void	pthread__cancelled(void) PTHREAD_HIDE;
 void	pthread__mutex_deferwake(pthread_t, pthread_mutex_t *) PTHREAD_HIDE;

Index: src/lib/libpthread/pthread_rwlock.c
diff -u src/lib/libpthread/pthread_rwlock.c:1.41 src/lib/libpthread/pthread_rwlock.c:1.42
--- src/lib/libpthread/pthread_rwlock.c:1.41	Mon Jun  1 11:44:59 2020
+++ src/lib/libpthread/pthread_rwlock.c	Tue Jun  2 00:29:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread_rwlock.c,v 1.41 2020/06/01 11:44:59 ad Exp $ */
+/*	$NetBSD: pthread_rwlock.c,v 1.42 2020/06/02 00:29:53 joerg Exp $ */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: pthread_rwlock.c,v 1.41 2020/06/01 11:44:59 ad Exp $");
+__RCSID("$NetBSD: pthread_rwlock.c,v 1.42 2020/06/02 00:29:53 joerg Exp $");
 
 #include 
 #include 
@@ -361,7 +361,7 @@ pthread__rwlock_wrlock(pthread_rwlock_t 
 			return error;
 
 		pthread__errorfunc(__FILE__, __LINE__, __func__,
-		"direct handoff failure");
+		"direct handoff failure: %d", 

CVS commit: src/sys/arch/amd64

2020-06-01 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Jun  1 22:58:06 UTC 2020

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

Log Message:
Reported-by: syzbot+6dd5a230d19f0cbc7...@syzkaller.appspotmail.com

Instrument STOS/MOVS for KMSAN to unbreak it.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/amd64/include/frameasm.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.58 src/sys/arch/amd64/amd64/cpufunc.S:1.59
--- src/sys/arch/amd64/amd64/cpufunc.S:1.58	Wed May 27 20:48:42 2020
+++ src/sys/arch/amd64/amd64/cpufunc.S	Mon Jun  1 22:58:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.58 2020/05/27 20:48:42 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.59 2020/06/01 22:58:06 ad Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -424,6 +424,7 @@ END(outl)
 ENTRY(x86_stos)
 	movq	%rsi,%rax
 	movq	%rdx,%rcx
+	KMSAN_REP_STOS(8)
 	rep
 	stosq
 	ret
@@ -431,6 +432,7 @@ END(x86_stos)
 
 ENTRY(x86_movs)
 	movq	%rdx,%rcx
+	KMSAN_REP_STOS(8)
 	rep
 	movsq
 	ret

Index: src/sys/arch/amd64/include/frameasm.h
diff -u src/sys/arch/amd64/include/frameasm.h:1.49 src/sys/arch/amd64/include/frameasm.h:1.50
--- src/sys/arch/amd64/include/frameasm.h:1.49	Sun Apr 26 14:49:17 2020
+++ src/sys/arch/amd64/include/frameasm.h	Mon Jun  1 22:58:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: frameasm.h,v 1.49 2020/04/26 14:49:17 maxv Exp $	*/
+/*	$NetBSD: frameasm.h,v 1.50 2020/06/01 22:58:06 ad Exp $	*/
 
 #ifndef _AMD64_MACHINE_FRAMEASM_H
 #define _AMD64_MACHINE_FRAMEASM_H
@@ -222,6 +222,7 @@
 #endif
 
 #ifdef KMSAN
+/* XXX this belongs somewhere else. */
 #define KMSAN_ENTER	\
 	movq	%rsp,%rdi		; \
 	movq	$TF_REGSIZE+16+40,%rsi	; \
@@ -275,11 +276,33 @@
 	popq	%rdx			; \
 	popq	%rcx			; \
 	popq	%rax
+#define KMSAN_REP_STOS(scale)	\
+	pushq	%rax			; \
+	pushq	%rcx			; \
+	pushq	%rdx			; \
+	pushq	%rsi			; \
+	pushq	%rdi			; \
+	pushq	%r8			; \
+	pushq	%r9			; \
+	pushq	%r10			; \
+	pushq	%r11			; \
+	leaq	(,%rcx,scale),%rsi	; \
+	callq	_C_LABEL(__msan_instrument_asm_store); \
+	popq	%r11			; \
+	popq	%r10			; \
+	popq	%r9			; \
+	popq	%r8			; \
+	popq	%rdi			; \
+	popq	%rsi			; \
+	popq	%rdx			; \
+	popq	%rcx			; \
+	popq	%rax
 #else
 #define KMSAN_ENTER		/* nothing */
 #define KMSAN_LEAVE		/* nothing */
 #define KMSAN_INIT_ARG(sz)	/* nothing */
 #define KMSAN_INIT_RET(sz)	/* nothing */
+#define	KMSAN_REP_STOS(scale)	/* nothing */
 #endif
 
 #ifdef KCOV



CVS commit: src/sys/dev/sysmon

2020-06-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jun  1 21:54:47 UTC 2020

Modified Files:
src/sys/dev/sysmon: sysmon_envsys.c

Log Message:
Don't queue sysmon refresh until the rndsource is attached.

Using the rndsource, as refreshing the sensors will do, is not
allowed until _after_ rnd_source_attach.

XXX pullup-7
XXX pullup-8
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/sys/dev/sysmon/sysmon_envsys.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/sysmon/sysmon_envsys.c
diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.144 src/sys/dev/sysmon/sysmon_envsys.c:1.145
--- src/sys/dev/sysmon/sysmon_envsys.c:1.144	Tue Mar 26 15:50:23 2019
+++ src/sys/dev/sysmon/sysmon_envsys.c	Mon Jun  1 21:54:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysmon_envsys.c,v 1.144 2019/03/26 15:50:23 bad Exp $	*/
+/*	$NetBSD: sysmon_envsys.c,v 1.145 2020/06/01 21:54:47 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.144 2019/03/26 15:50:23 bad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.145 2020/06/01 21:54:47 riastradh Exp $");
 
 #include 
 #include 
@@ -824,16 +824,6 @@ out:
 	if (error == 0) {
 		nevent = 0;
 
-		if (sme->sme_flags & SME_INIT_REFRESH) {
-			sysmon_task_queue_sched(0, sme_initial_refresh, sme);
-			DPRINTF(("%s: scheduled initial refresh for '%s'\n",
-__func__, sme->sme_name));
-		}
-		SLIST_FOREACH(evdv, _evdrv_list, evdrv_head) {
-			sysmon_task_queue_sched(0,
-			sme_event_drvadd, evdv->evdrv);
-			nevent++;
-		}
 		/*
 		 * Hook the sensor into rnd(4) entropy pool if requested
 		 */
@@ -889,6 +879,17 @@ out:
 rnd_type, rnd_flag);
 			}
 		}
+
+		if (sme->sme_flags & SME_INIT_REFRESH) {
+			sysmon_task_queue_sched(0, sme_initial_refresh, sme);
+			DPRINTF(("%s: scheduled initial refresh for '%s'\n",
+__func__, sme->sme_name));
+		}
+		SLIST_FOREACH(evdv, _evdrv_list, evdrv_head) {
+			sysmon_task_queue_sched(0,
+			sme_event_drvadd, evdv->evdrv);
+			nevent++;
+		}
 		DPRINTF(("%s: driver '%s' registered (nsens=%d nevent=%d)\n",
 		__func__, sme->sme_name, sme->sme_nsensors, nevent));
 	}



CVS commit: src/external/mpl/bind/dist/lib/isc/unix

2020-06-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun  1 18:55:37 UTC 2020

Modified Files:
src/external/mpl/bind/dist/lib/isc/unix: socket.c

Log Message:
Locking protocol changed; the internal routines are now called with the
socket locked. Adjust for that.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/external/mpl/bind/dist/lib/isc/unix/socket.c

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

Modified files:

Index: src/external/mpl/bind/dist/lib/isc/unix/socket.c
diff -u src/external/mpl/bind/dist/lib/isc/unix/socket.c:1.15 src/external/mpl/bind/dist/lib/isc/unix/socket.c:1.16
--- src/external/mpl/bind/dist/lib/isc/unix/socket.c:1.15	Sun May 31 13:45:02 2020
+++ src/external/mpl/bind/dist/lib/isc/unix/socket.c	Mon Jun  1 14:55:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: socket.c,v 1.15 2020/05/31 17:45:02 christos Exp $	*/
+/*	$NetBSD: socket.c,v 1.16 2020/06/01 18:55:37 christos Exp $	*/
 
 /*
  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -3174,7 +3174,6 @@ internal_fdwatch_write(isc__socket_t *so
 
 	INSIST(VALID_SOCKET(sock));
 
-	LOCK(>lock);
 	isc_refcount_increment(>references);
 	UNLOCK(>lock);
 
@@ -3192,8 +3191,6 @@ internal_fdwatch_write(isc__socket_t *so
 	if (more_data)
 		select_poke(sock->manager, sock->threadid, sock->fd,
 		SELECT_POKE_WRITE);
-
-	UNLOCK(>lock);
 }
 
 static void
@@ -3203,7 +3200,6 @@ internal_fdwatch_read(isc__socket_t *soc
 
 	INSIST(VALID_SOCKET(sock));
 
-	LOCK(>lock);
 	isc_refcount_increment(>references);
 	UNLOCK(>lock);
 
@@ -3221,8 +3217,6 @@ internal_fdwatch_read(isc__socket_t *soc
 	if (more_data)
 		select_poke(sock->manager, sock->threadid, sock->fd,
 		SELECT_POKE_READ);
-
-	UNLOCK(>lock);
 }
 
 /*



CVS commit: src

2020-06-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun  1 14:46:04 UTC 2020

Modified Files:
src: UPDATING

Log Message:
Mention cleaning needed in LIBISPRIVATE directories


To generate a diff of this commit:
cvs rdiff -u -r1.307 -r1.308 src/UPDATING

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

Modified files:

Index: src/UPDATING
diff -u src/UPDATING:1.307 src/UPDATING:1.308
--- src/UPDATING:1.307	Wed Mar 11 17:07:40 2020
+++ src/UPDATING	Mon Jun  1 10:46:04 2020
@@ -1,4 +1,4 @@
-$NetBSD: UPDATING,v 1.307 2020/03/11 21:07:40 mrg Exp $
+$NetBSD: UPDATING,v 1.308 2020/06/01 14:46:04 christos Exp $
 
 This file (UPDATING) is intended to be a brief reference to recent
 changes that might cause problems in the build process, and a guide for
@@ -19,6 +19,10 @@ See also: BUILDING, build.sh, Makefile.
 Recent changes:
 ^^^
 
+20200601:
+	Due to a mistake in LIBISPRIVATE handling, .so libraries were
+	created in the build directories and need cleaning.
+
 20200311:
 	GCC 8 ports will need cleaning in src/tools/gcc and
 	src/external/gpl3/gcc due to GCC 8.4 update.



CVS commit: src/tests/dev/scsipi/libscsitest

2020-06-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun  1 14:42:53 UTC 2020

Modified Files:
src/tests/dev/scsipi/libscsitest: Makefile

Log Message:
LIBISPRIVATE=yes


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/dev/scsipi/libscsitest/Makefile

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

Modified files:

Index: src/tests/dev/scsipi/libscsitest/Makefile
diff -u src/tests/dev/scsipi/libscsitest/Makefile:1.3 src/tests/dev/scsipi/libscsitest/Makefile:1.4
--- src/tests/dev/scsipi/libscsitest/Makefile:1.3	Sat Apr 26 14:53:21 2014
+++ src/tests/dev/scsipi/libscsitest/Makefile	Mon Jun  1 10:42:53 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2014/04/26 18:53:21 christos Exp $
+#	$NetBSD: Makefile,v 1.4 2020/06/01 14:42:53 christos Exp $
 #
 
 .include 
@@ -7,7 +7,7 @@ RUMPTOP= ${NETBSDSRCDIR}/sys/rump
 
 LIB=	rumpdev_scsitest
 IOCONF=	SCSITEST.ioconf
-LIBISPRIVATE= #defined
+LIBISPRIVATE=	yes
 
 SRCS=	scsitest.c
 SRCS+=	scsitest_component.c



CVS commit: src/tests/fs/common

2020-06-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun  1 14:42:03 UTC 2020

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

Log Message:
LIBISPRIVATE=yes


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/fs/common/Makefile

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

Modified files:

Index: src/tests/fs/common/Makefile
diff -u src/tests/fs/common/Makefile:1.13 src/tests/fs/common/Makefile:1.14
--- src/tests/fs/common/Makefile:1.13	Sun Oct 13 03:28:14 2019
+++ src/tests/fs/common/Makefile	Mon Jun  1 10:42:03 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.13 2019/10/13 07:28:14 mrg Exp $
+#	$NetBSD: Makefile,v 1.14 2020/06/01 14:42:03 christos Exp $
 #
 
 .include 
@@ -27,7 +27,7 @@ CPPFLAGS+=	-DDEBUG -DLIBWRAP -DRUMP_RPC
 CPPFLAGS+=	-I${LIBC}/include -I${LIBC}/rpc
 
 
-LIBISPRIVATE=	# yup
+LIBISPRIVATE=	yes
 
 # NFS client stuff
 .PATH:	${NETBSDSRCDIR}/sbin/mount_nfs ${NETBSDSRCDIR}/sbin/mount



CVS commit: src/tests/dev/usb/libhid

2020-06-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun  1 14:41:25 UTC 2020

Modified Files:
src/tests/dev/usb/libhid: Makefile

Log Message:
Set LIBISPRIVATE=yes


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/dev/usb/libhid/Makefile

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

Modified files:

Index: src/tests/dev/usb/libhid/Makefile
diff -u src/tests/dev/usb/libhid/Makefile:1.2 src/tests/dev/usb/libhid/Makefile:1.3
--- src/tests/dev/usb/libhid/Makefile:1.2	Sun Dec 10 15:38:14 2017
+++ src/tests/dev/usb/libhid/Makefile	Mon Jun  1 10:41:25 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2017/12/10 20:38:14 bouyer Exp $
+#	$NetBSD: Makefile,v 1.3 2020/06/01 14:41:25 christos Exp $
 #
 
 .include 
@@ -7,7 +7,7 @@ RUMPTOP= ${NETBSDSRCDIR}/sys/rump
 .PATH:	${.CURDIR}/../../../../sys/dev/hid
 
 LIB=	rumpdev_hid
-LIBISPRIVATE= #defined
+LIBISPRIVATE= yes
 
 SRCS=	hid.c
 



CVS commit: src/external/mit/libuv/lib

2020-06-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun  1 14:39:42 UTC 2020

Modified Files:
src/external/mit/libuv/lib: Makefile

Log Message:
Arrange to create an _pic.a library too.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/mit/libuv/lib/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/mit/libuv/lib/Makefile
diff -u src/external/mit/libuv/lib/Makefile:1.3 src/external/mit/libuv/lib/Makefile:1.4
--- src/external/mit/libuv/lib/Makefile:1.3	Sat May 30 16:54:46 2020
+++ src/external/mit/libuv/lib/Makefile	Mon Jun  1 10:39:42 2020
@@ -1,9 +1,6 @@
-# $NetBSD: Makefile,v 1.3 2020/05/30 20:54:46 christos Exp $
+# $NetBSD: Makefile,v 1.4 2020/06/01 14:39:42 christos Exp $
 
-LIBISPRIVATE=yes
-
-LIBISPRIVATE=yes
-MKPICLIB=yes
+LIBISPRIVATE=pic
 
 .include 
 



CVS commit: src/share/mk

2020-06-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun  1 14:39:14 UTC 2020

Modified Files:
src/share/mk: bsd.README bsd.lib.mk

Log Message:
1. if ${LIBISPRIVATE} == "pic", create _pic.a so that we can embed the library
   to another shared object
2. Don't compare ${LIBISPRIVATE} to "yes", because there are 3 places in
   Makefiles which set it to empty (this was a bug)
3. For private libraries, don't create .so* files


To generate a diff of this commit:
cvs rdiff -u -r1.405 -r1.406 src/share/mk/bsd.README
cvs rdiff -u -r1.382 -r1.383 src/share/mk/bsd.lib.mk

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

Modified files:

Index: src/share/mk/bsd.README
diff -u src/share/mk/bsd.README:1.405 src/share/mk/bsd.README:1.406
--- src/share/mk/bsd.README:1.405	Sat May 30 16:47:59 2020
+++ src/share/mk/bsd.README	Mon Jun  1 10:39:14 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.README,v 1.405 2020/05/30 20:47:59 christos Exp $
+#	$NetBSD: bsd.README,v 1.406 2020/06/01 14:39:14 christos Exp $
 #	@(#)bsd.README	8.2 (Berkeley) 4/2/94
 
 This is the README file for the make "include" files for the NetBSD
@@ -1342,6 +1342,8 @@ LIBISMODULE	If not "no", install as ${LI
 LIBISPRIVATE	If not "no", act as "MKDEBUGLIB=no MKLINT=no MKPIC=no
 		MKPROFILE=no", and don't install the (.a) library.
 		This is useful for "build only" helper libraries.
+		If set to "pic", then a _pic.a library is also produced,
+		so that it can be incorporated into other shared objects.
 		Default: no
 
 LIBISCXX	If not "no", Use ${CXX} instead of ${CC} to link

Index: src/share/mk/bsd.lib.mk
diff -u src/share/mk/bsd.lib.mk:1.382 src/share/mk/bsd.lib.mk:1.383
--- src/share/mk/bsd.lib.mk:1.382	Sat May 30 15:51:32 2020
+++ src/share/mk/bsd.lib.mk	Mon Jun  1 10:39:14 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.lib.mk,v 1.382 2020/05/30 19:51:32 christos Exp $
+#	$NetBSD: bsd.lib.mk,v 1.383 2020/06/01 14:39:14 christos Exp $
 #	@(#)bsd.lib.mk	8.3 (Berkeley) 4/22/94
 
 .include 
@@ -30,7 +30,7 @@ MKLINT:=	no
 MKPICINSTALL:=	no
 . if defined(NOSTATICLIB) && ${MKPICLIB} != "no"
 MKSTATICLIB:=	no
-. elif ${MKPICLIB} == "no"
+. elif ${LIBISPRIVATE} != "pic"
 MKPIC:=		no
 . endif
 MKPROFILE:=	no
@@ -118,6 +118,7 @@ print-shlib-teeny:
 	@false
 .endif
 
+.if ${LIBISPRIVATE} == "no"
 .if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR)# {
 .if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
 .if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
@@ -129,6 +130,7 @@ SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB
 SHLIB_FULLVERSION=${SHLIB_MAJOR}
 .endif
 .endif	# }
+.endif
 
 # add additional suffixes not exported.
 # .po is used for profiling object files.
@@ -170,7 +172,7 @@ MKSHLIBOBJS= no
 # We only add -g to the shared library objects
 # because we don't currently split .a archives.
 CSHLIBFLAGS+=	-g
-.if ${LIBISPRIVATE} == "yes"
+.if ${LIBISPRIVATE} != "no"
 CFLAGS+=	-g
 .endif
 .endif



CVS commit: src/sys/kern

2020-06-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jun  1 13:58:14 UTC 2020

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

Log Message:
lwp_thread_cleanup(): Remove overly-aggressive assertion.


To generate a diff of this commit:
cvs rdiff -u -r1.239 -r1.240 src/sys/kern/kern_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.239 src/sys/kern/kern_lwp.c:1.240
--- src/sys/kern/kern_lwp.c:1.239	Sat May 23 23:42:43 2020
+++ src/sys/kern/kern_lwp.c	Mon Jun  1 13:58:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lwp.c,v 1.239 2020/05/23 23:42:43 ad Exp $	*/
+/*	$NetBSD: kern_lwp.c,v 1.240 2020/06/01 13:58:14 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020
@@ -217,7 +217,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.239 2020/05/23 23:42:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.240 2020/06/01 13:58:14 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -2060,7 +2060,6 @@ lwp_setprivate(struct lwp *l, void *ptr)
 void
 lwp_thread_cleanup(struct lwp *l)
 {
-	KASSERT(l == curlwp);
 	const lwpid_t tid = l->l_lid;
 
 	KASSERT((tid & FUTEX_TID_MASK) == tid);



CVS commit: src/usr.sbin/puffs/mount_9p

2020-06-01 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Jun  1 13:30:52 UTC 2020

Modified Files:
src/usr.sbin/puffs/mount_9p: node.c

Log Message:
Fix extra whitespace added by accident.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/puffs/mount_9p/node.c

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

Modified files:

Index: src/usr.sbin/puffs/mount_9p/node.c
diff -u src/usr.sbin/puffs/mount_9p/node.c:1.28 src/usr.sbin/puffs/mount_9p/node.c:1.29
--- src/usr.sbin/puffs/mount_9p/node.c:1.28	Wed May 27 03:25:13 2020
+++ src/usr.sbin/puffs/mount_9p/node.c	Mon Jun  1 13:30:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: node.c,v 1.28 2020/05/27 03:25:13 uwe Exp $	*/
+/*	$NetBSD: node.c,v 1.29 2020/06/01 13:30:52 uwe Exp $	*/
 
 /*
  * Copyright (c) 2007  Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: node.c,v 1.28 2020/05/27 03:25:13 uwe Exp $");
+__RCSID("$NetBSD: node.c,v 1.29 2020/06/01 13:30:52 uwe Exp $");
 #endif /* !lint */
 
 #include 
@@ -595,7 +595,7 @@ puffs9p_node_rename(struct puffs_usermou
 	if (targ) {
 		struct puffs_node *pn_targ = targ;
 
-		rv = noderemove(pu,  pn_targ);
+		rv = noderemove(pu, pn_targ);
 		if (rv)
 			goto out;
 	}



CVS commit: src/lib/libpthread

2020-06-01 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Jun  1 11:44:59 UTC 2020

Modified Files:
src/lib/libpthread: pthread.c pthread_cond.c pthread_int.h
pthread_mutex.c pthread_rwlock.c pthread_types.h

Log Message:
In the interests of reliability simplify waiter handling more and redo
condvars to manage the list of waiters with atomic ops.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/lib/libpthread/pthread.c
cvs rdiff -u -r1.69 -r1.70 src/lib/libpthread/pthread_cond.c
cvs rdiff -u -r1.104 -r1.105 src/lib/libpthread/pthread_int.h
cvs rdiff -u -r1.77 -r1.78 src/lib/libpthread/pthread_mutex.c
cvs rdiff -u -r1.40 -r1.41 src/lib/libpthread/pthread_rwlock.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libpthread/pthread_types.h

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

Modified files:

Index: src/lib/libpthread/pthread.c
diff -u src/lib/libpthread/pthread.c:1.170 src/lib/libpthread/pthread.c:1.171
--- src/lib/libpthread/pthread.c:1.170	Sat May 16 22:53:37 2020
+++ src/lib/libpthread/pthread.c	Mon Jun  1 11:44:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread.c,v 1.170 2020/05/16 22:53:37 ad Exp $	*/
+/*	$NetBSD: pthread.c,v 1.171 2020/06/01 11:44:59 ad Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: pthread.c,v 1.170 2020/05/16 22:53:37 ad Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.171 2020/06/01 11:44:59 ad Exp $");
 
 #define	__EXPOSE_STACK	1
 
@@ -294,12 +294,11 @@ pthread__initthread(pthread_t t)
 	t->pt_self = t;
 	t->pt_magic = PT_MAGIC;
 	t->pt_willpark = 0;
-	t->pt_unpark = 0;
+	t->pt_waiters[0] = 0;
 	t->pt_nwaiters = 0;
 	t->pt_sleepobj = NULL;
 	t->pt_signalled = 0;
 	t->pt_havespecific = 0;
-	t->pt_early = NULL;
 	t->pt_lwpctl = __dummy_lwpctl;
 
 	memcpy(>pt_lockops, pthread__lock_ops, sizeof(t->pt_lockops));
@@ -609,51 +608,32 @@ pthread__clear_waiters(pthread_t self)
 {
 	int rv;
 
-	/* Zero waiters or one waiter in error case (pthread_exit()). */
-	if (self->pt_nwaiters == 0) {
-		if (self->pt_unpark != 0 && self->pt_willpark == 0) {
-			rv = (ssize_t)_lwp_unpark(self->pt_unpark, NULL);
-			self->pt_unpark = 0;
-			if (rv != 0 && errno != EALREADY && errno != EINTR &&
-			errno != ESRCH) {
-pthread__errorfunc(__FILE__, __LINE__, __func__,
-"_lwp_unpark failed");
-			}
-		}
-		return;
-	}
+	pthread__smt_wake();
 
-	/* One waiter or two waiters (the second being a deferred wakeup). */
-	if (self->pt_nwaiters == 1) {
-		if (self->pt_unpark != 0) {
-			/* Fall through to multiple waiters case. */
-			self->pt_waiters[1] = self->pt_unpark;
-			self->pt_nwaiters = 2;
-			self->pt_unpark = 0;
-		} else if (self->pt_willpark) {
-			/* Defer to _lwp_park(). */
-			self->pt_unpark = self->pt_waiters[0];
-			self->pt_nwaiters = 0;
-			return;
-		} else {
-			/* Wake one now. */
-			rv = (ssize_t)_lwp_unpark(self->pt_waiters[0], NULL);
-			self->pt_nwaiters = 0;
-			if (rv != 0 && errno != EALREADY && errno != EINTR &&
-			errno != ESRCH) {
-pthread__errorfunc(__FILE__, __LINE__, __func__,
-"_lwp_unpark failed");
-			}
-			return;
+	switch (self->pt_nwaiters) {
+	case 0:
+		break;
+	case 1:
+		if (self->pt_willpark) {
+			break;
 		}
-	}
-
-	/* Multiple waiters. */
-	rv = _lwp_unpark_all(self->pt_waiters, self->pt_nwaiters, NULL);
-	self->pt_nwaiters = 0;
-	if (rv != 0 && errno != EINTR) {
-		pthread__errorfunc(__FILE__, __LINE__, __func__,
-		"_lwp_unpark_all failed");
+		rv = _lwp_unpark(self->pt_waiters[0], NULL);
+		self->pt_waiters[0] = 0;
+		self->pt_nwaiters = 0;
+		if (rv != 0) {
+			pthread__errorfunc(__FILE__, __LINE__, __func__,
+			"_lwp_unpark failed");
+		}
+		break;
+	default:
+		rv = _lwp_unpark_all(self->pt_waiters, self->pt_nwaiters, NULL);
+		self->pt_waiters[0] = 0;
+		self->pt_nwaiters = 0;
+		if (rv != 0) {
+			pthread__errorfunc(__FILE__, __LINE__, __func__,
+			"_lwp_unpark_all failed");
+		}
+		break;
 	}
 }
 
@@ -1115,7 +1095,7 @@ pthread__assertfunc(const char *file, in
 	function ? "\"" : "");
 
 	_sys_write(STDERR_FILENO, buf, (size_t)len);
-	(void)_lwp_kill(_lwp_self(), SIGABRT);
+	(void)raise(SIGABRT);
 	_exit(1);
 }
 
@@ -1163,16 +1143,12 @@ pthread__errorfunc(const char *file, int
  * http://www.sun.com/software/whitepapers/solaris9/multithread.pdf
  */
 
-#define	OOPS(msg)			\
-pthread__errorfunc(__FILE__, __LINE__, __func__, msg)
-
 int
 pthread__park(pthread_t self, pthread_mutex_t *lock,
 	  pthread_queue_t *queue, const struct timespec *abstime,
 	  int cancelpt)
 {
 	int rv, error;
-	void *obj;
 
 	self->pt_willpark = 1;
 	pthread_mutex_unlock(lock);
@@ -1186,26 +1162,15 @@ pthread__park(pthread_t self, pthread_mu
 	 * It is fine to test the value of pt_sleepobj without
 	 * holding any locks, because:
 	 *
-	 * o Only the blocking thread (this thread) ever sets them
+	 * o Only the blocking thread (this thread) ever sets 

CVS commit: src/tests/net/npf

2020-06-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun  1 11:08:57 UTC 2020

Modified Files:
src/tests/net/npf: t_npf.sh

Log Message:
Adjust to "npfctl debug" command line changes, from rmind@.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/net/npf/t_npf.sh

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

Modified files:

Index: src/tests/net/npf/t_npf.sh
diff -u src/tests/net/npf/t_npf.sh:1.3 src/tests/net/npf/t_npf.sh:1.4
--- src/tests/net/npf/t_npf.sh:1.3	Thu Aug  3 03:16:27 2017
+++ src/tests/net/npf/t_npf.sh	Mon Jun  1 11:08:57 2020
@@ -1,4 +1,4 @@
-# $NetBSD: t_npf.sh,v 1.3 2017/08/03 03:16:27 ozaki-r Exp $
+# $NetBSD: t_npf.sh,v 1.4 2020/06/01 11:08:57 martin Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -29,7 +29,7 @@ run_test()
 {
 	local name="${1}"
 
-	atf_check -o ignore -e ignore npfctl debug "$(atf_get_srcdir)/npftest.conf" ./npf.plist
+	atf_check -o ignore -e ignore npfctl debug -c "$(atf_get_srcdir)/npftest.conf" -o ./npf.plist
 	atf_check -o ignore npftest -c npf.plist -T "${name}"
 }
 



CVS commit: src/sys/dev/usb

2020-06-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jun  1 10:25:01 UTC 2020

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

Log Message:
Remove some unnecessary bit shifts by using appropriate read size


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/usb/xhcireg.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/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.129 src/sys/dev/usb/xhci.c:1.130
--- src/sys/dev/usb/xhci.c:1.129	Thu May 21 15:28:35 2020
+++ src/sys/dev/usb/xhci.c	Mon Jun  1 10:25:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.129 2020/05/21 15:28:35 jakllsch Exp $	*/
+/*	$NetBSD: xhci.c,v 1.130 2020/06/01 10:25:00 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.129 2020/05/21 15:28:35 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.130 2020/06/01 10:25:00 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -272,6 +272,12 @@ xhci_read_1(const struct xhci_softc * co
 }
 
 static inline uint32_t
+xhci_read_2(const struct xhci_softc * const sc, bus_size_t offset)
+{
+	return bus_space_read_2(sc->sc_iot, sc->sc_ioh, offset);
+}
+
+static inline uint32_t
 xhci_read_4(const struct xhci_softc * const sc, bus_size_t offset)
 {
 	return bus_space_read_4(sc->sc_iot, sc->sc_ioh, offset);
@@ -938,7 +944,7 @@ int
 xhci_init(struct xhci_softc *sc)
 {
 	bus_size_t bsz;
-	uint32_t cap, hcs1, hcs2, hcs3, hcc, dboff, rtsoff, hcc2;
+	uint32_t hcs1, hcs2, hcs3, hcc, dboff, rtsoff, hcc2;
 	uint32_t pagesize, config;
 	int i = 0;
 	uint16_t hciversion;
@@ -959,9 +965,8 @@ xhci_init(struct xhci_softc *sc)
 	sc->sc_bus2.ub_hcpriv = sc;
 	sc->sc_bus2.ub_dmatag = sc->sc_bus.ub_dmatag;
 
-	cap = xhci_read_4(sc, XHCI_CAPLENGTH);
-	caplength = XHCI_CAP_CAPLENGTH(cap);
-	hciversion = XHCI_CAP_HCIVERSION(cap);
+	caplength = xhci_read_1(sc, XHCI_CAPLENGTH);
+	hciversion = xhci_read_2(sc, XHCI_HCIVERSION);
 
 	if (hciversion < XHCI_HCIVERSION_0_96 ||
 	hciversion >= 0x0200) {

Index: src/sys/dev/usb/xhcireg.h
diff -u src/sys/dev/usb/xhcireg.h:1.14 src/sys/dev/usb/xhcireg.h:1.15
--- src/sys/dev/usb/xhcireg.h:1.14	Fri May 29 06:53:40 2020
+++ src/sys/dev/usb/xhcireg.h	Mon Jun  1 10:25:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: xhcireg.h,v 1.14 2020/05/29 06:53:40 skrll Exp $ */
+/* $NetBSD: xhcireg.h,v 1.15 2020/06/01 10:25:00 skrll Exp $ */
 
 /*-
  * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
@@ -45,9 +45,8 @@
 #define	PCI_XHCI_INTEL_USB3PRM	0xdc/* Intel USB3 Port Routing Mask */
 
 /* XHCI capability registers */
-#define	XHCI_CAPLENGTH		0x00	/* RO capability */
-#define	 XHCI_CAP_CAPLENGTH(x)	((x) & 0xFF)
-#define	 XHCI_CAP_HCIVERSION(x)	(((x) >> 16) & 0x)	/* RO Interface version number */
+#define	XHCI_CAPLENGTH		0x00	/* RO capability - 1 byte */
+#define	XHCI_HCIVERSION		0x02	/* RO version - 2 bytes */
 #define	 XHCI_HCIVERSION_0_9	0x0090	/* xHCI version 0.9 */
 #define	 XHCI_HCIVERSION_0_96	0x0096	/* xHCI version 0.96 */
 #define	 XHCI_HCIVERSION_1_0	0x0100	/* xHCI version 1.0 */



CVS commit: src/sys/arch/aarch64/aarch64

2020-06-01 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jun  1 08:59:00 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc_asm_armv8.S

Log Message:
even if the line size of Icache and Dcache is different, it was fixed to work 
correctly.

- MAX(IcacheShift,DcacheShift) is wrong and should be 
MIN(IcacheShift,DcacheShift).
  Dcache and Icache are now done in independent loops instead of in the same 
loop.
- simplify the handling of cache_handle_range() macro arguments.
- cache_handle_range macro doesn't include "ret" anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S
diff -u src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S:1.4 src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S:1.5
--- src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S:1.4	Thu Sep 12 06:12:56 2019
+++ src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S	Mon Jun  1 08:59:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc_asm_armv8.S,v 1.4 2019/09/12 06:12:56 ryo Exp $	*/
+/*	$NetBSD: cpufunc_asm_armv8.S,v 1.5 2020/06/01 08:59:00 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2014 Robin Randhawa
@@ -41,43 +41,44 @@
 
 /*
  * Macro to handle the cache. This takes the start address in x0, length
- * in x1. It will corrupt x0, x1, x2, and x3.
+ * in x1. It will corrupt x2-x5.
  */
-.macro cache_handle_range dcop = 0, ic = 0, icop = 0
-.if \ic == 0
-	mrs	x3, ctr_el0
-	ubfx	x3, x3, #16, #4		/* x3 = D cache shift */
-	mov	x2, #4			/* size of word */
-	lsl	x3, x2, x3		/* x3 = D cache line size */
-.else
+.macro cache_handle_range dcop = 0, icop = 0
 	mrs	x3, ctr_el0
+	mov	x4, #4			/* size of word */
+.if \dcop != 0
 	ubfx	x2, x3, #16, #4		/* x2 = D cache shift */
+	lsl	x2, x4, x2		/* x2 = D cache line size */
+.endif
+.if \icop != 0
 	and	x3, x3, #15		/* x3 = I cache shift */
-	cmp	x3, x2
-	bcs	1f
-	mov	x3, x2
-1:	/* x3 = MAX(IcacheShift,DcacheShift) */
-	mov	x2, #4			/* size of word */
-	lsl	x3, x2, x3		/* x3 = cache line size */
+	lsl	x3, x4, x3		/* x3 = I cache line size */
 .endif
-	sub	x4, x3, #1		/* Get the address mask */
-	and	x2, x0, x4		/* Get the low bits of the address */
-	add	x1, x1, x2		/* Add these to the size */
-	bic	x0, x0, x4		/* Clear the low bit of the address */
+.if \dcop != 0
+	sub	x4, x2, #1		/* Get the address mask */
+	and	x4, x0, x4		/* Get the low bits of the address */
+	add	x5, x1, x4		/* Add these to the size */
+	bic	x4, x0, x4		/* Clear the low bit of the address */
 1:
-	dc	\dcop, x0
-	dsb	ish
-.if \ic != 0
-	ic	\icop, x0
+	dc	\dcop, x4
+	add	x4, x4, x2		/* Move to the next line */
+	subs	x5, x5, x2		/* Reduce the size */
+	b.hi	1b			/* Check if we are done */
 	dsb	ish
 .endif
-	add	x0, x0, x3		/* Move to the next line */
-	subs	x1, x1, x3		/* Reduce the size */
+.if \icop != 0
+	sub	x4, x3, #1		/* Get the address mask */
+	and	x4, x0, x4		/* Get the low bits of the address */
+	add	x5, x1, x4		/* Add these to the size */
+	bic	x4, x0, x4		/* Clear the low bit of the address */
+1:
+	ic	\icop, x4
+	add	x4, x4, x3		/* Move to the next line */
+	subs	x5, x5, x3		/* Reduce the size */
 	b.hi	1b			/* Check if we are done */
-.if \ic != 0
+	dsb	ish
 	isb
 .endif
-	ret
 .endm
 
 
@@ -95,6 +96,7 @@ END(aarch64_cpuid)
  */
 ENTRY(aarch64_dcache_wb_range)
 	cache_handle_range	dcop = cvac
+	ret
 END(aarch64_dcache_wb_range)
 
 /*
@@ -102,6 +104,7 @@ END(aarch64_dcache_wb_range)
  */
 ENTRY(aarch64_dcache_wbinv_range)
 	cache_handle_range	dcop = civac
+	ret
 END(aarch64_dcache_wbinv_range)
 
 /*
@@ -112,20 +115,23 @@ END(aarch64_dcache_wbinv_range)
  */
 ENTRY(aarch64_dcache_inv_range)
 	cache_handle_range	dcop = ivac
+	ret
 END(aarch64_dcache_inv_range)
 
 /*
  * void aarch64_idcache_wbinv_range(vaddr_t, vsize_t)
  */
 ENTRY(aarch64_idcache_wbinv_range)
-	cache_handle_range	dcop = civac, ic = 1, icop = ivau
+	cache_handle_range	dcop = civac, icop = ivau
+	ret
 END(aarch64_idcache_wbinv_range)
 
 /*
  * void aarch64_icache_sync_range(vaddr_t, vsize_t)
  */
 ENTRY(aarch64_icache_sync_range)
-	cache_handle_range	dcop = cvau, ic = 1, icop = ivau
+	cache_handle_range	dcop = cvau, icop = ivau
+	ret
 END(aarch64_icache_sync_range)
 
 /*



CVS commit: src/usr.sbin/cpuctl/arch

2020-06-01 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jun  1 08:33:40 UTC 2020

Modified Files:
src/usr.sbin/cpuctl/arch: i386.c

Log Message:
 Add 0xa5 and 0xa6 for Comet Lake.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/usr.sbin/cpuctl/arch/i386.c

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

Modified files:

Index: src/usr.sbin/cpuctl/arch/i386.c
diff -u src/usr.sbin/cpuctl/arch/i386.c:1.112 src/usr.sbin/cpuctl/arch/i386.c:1.113
--- src/usr.sbin/cpuctl/arch/i386.c:1.112	Tue Apr 21 02:56:37 2020
+++ src/usr.sbin/cpuctl/arch/i386.c	Mon Jun  1 08:33:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386.c,v 1.112 2020/04/21 02:56:37 msaitoh Exp $	*/
+/*	$NetBSD: i386.c,v 1.113 2020/06/01 08:33:40 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: i386.c,v 1.112 2020/04/21 02:56:37 msaitoh Exp $");
+__RCSID("$NetBSD: i386.c,v 1.113 2020/06/01 08:33:40 msaitoh Exp $");
 #endif /* not lint */
 
 #include 
@@ -353,6 +353,8 @@ const struct cpu_cpuid_nameclass i386_cp
 [0x86] = "Atom (Tremont)",
 [0x8e] = "7th or 8th gen Core (Kaby Lake, Coffee Lake) or Xeon E (Coffee Lake)",
 [0x9e] = "7th or 8th gen Core (Kaby Lake, Coffee Lake) or Xeon E (Coffee Lake)",
+[0xa5] = "10th gen Core (Comet Lake)",
+[0xa6] = "10th gen Core (Comet Lake)",
 			},
 			"Pentium Pro, II or III",	/* Default */
 			NULL,



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

2020-06-01 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jun  1 08:32:39 UTC 2020

Modified Files:
src/sys/arch/x86/include: specialreg.h

Log Message:
Add some definitions from the latest Intel SDM plus small fix:

 - Add CPUID leaf 6 %eax bit 19 for HW_FEEDBACK* and IA32_PACKAGE_TERM* MSRs.
 - Add CPUID leaf 7 %ecx bit 31 for Protection Keys.
 - Add definition of Load only TLB and Store only TLB.
 - Add IF_PSCHANGE_MC_NO bit of IA32_ARCH_CAPABILITIES
 - Fix HWP_IGNIDL.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/arch/x86/include/specialreg.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/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.165 src/sys/arch/x86/include/specialreg.h:1.166
--- src/sys/arch/x86/include/specialreg.h:1.165	Thu May 28 07:59:38 2020
+++ src/sys/arch/x86/include/specialreg.h	Mon Jun  1 08:32:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.165 2020/05/28 07:59:38 msaitoh Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.166 2020/06/01 08:32:39 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2014-2019 The NetBSD Foundation, Inc.
@@ -367,6 +367,7 @@
 #define CPUID_DSPM_HWP_PECI   __BIT(16)	/* HWP PECI override */
 #define CPUID_DSPM_HWP_FLEX   __BIT(17)	/* Flexible HWP */
 #define CPUID_DSPM_HWP_FAST   __BIT(18)	/* Fast access for IA32_HWP_REQUEST */
+#define CPUID_DSPM_HW_FEEDBACK __BIT(19) /* HW_FEEDBACK*, IA32_PACKAGE_TERM* */
 #define CPUID_DSPM_HWP_IGNIDL __BIT(20)	/* Ignore Idle Logical Processor HWP */
 
 #define CPUID_DSPM_FLAGS	"\20" \
@@ -374,8 +375,8 @@
 	"\5" "PLN"	"\6" "ECMD"	"\7" "PTM"	"\10" "HWP"	\
 	"\11" "HWP_NOTIFY" "\12" "HWP_ACTWIN" "\13" "HWP_EPP" "\14" "HWP_PLR" \
 			"\16" "HDC"	"\17" "TBM3"	"\20" "HWP_CAP" \
-	"\21" "HWP_PECI" "\22" "HWP_FLEX" "\23" "HWP_FAST"		\
-	"25" "HWP_IGNIDL"
+	"\21" "HWP_PECI" "\22" "HWP_FLEX" "\23" "HWP_FAST" "\24HW_FEEDBACK"   \
+	"\25" "HWP_IGNIDL"
 
 /*
  * Intel/AMD Digital Thermal Sensor and
@@ -460,6 +461,7 @@
 #define CPUID_SEF_MOVDIRI	__BIT(27) /* MOVDIRI instruction */
 #define CPUID_SEF_MOVDIR64B	__BIT(28) /* MOVDIR64B instruction */
 #define CPUID_SEF_SGXLC		__BIT(30) /* SGX Launch Configuration */
+#define CPUID_SEF_PKS		__BIT(31) /* Protection Keys */
 
 #define CPUID_SEF_FLAGS1	"\177\20" \
 	"b\0PREFETCHWT1\0" "b\1AVX512_VBMI\0" "b\2UMIP\0" "b\3PKU\0"	\
@@ -469,7 +471,7 @@
 	"f\21\5MAWAU\0"			\
 	"b\26RDPID\0"			\
 			"b\31CLDEMOTE\0"		"b\33MOVDIRI\0"	\
-	"b\34MOVDIR64B\0"		"b\36SGXLC\0"
+	"b\34MOVDIR64B\0"		"b\36SGXLC\0"	"b\37PKS\0"
 
 /* %edx */
 #define CPUID_SEF_AVX512_4VNNIW	__BIT(2)
@@ -608,6 +610,8 @@
 #define CPUID_DATP_TCTYPE_D	1		/*   Data TLB */
 #define CPUID_DATP_TCTYPE_I	2		/*   Instruction TLB */
 #define CPUID_DATP_TCTYPE_U	3		/*   Unified TLB */
+#define CPUID_DATP_TCTYPE_L	4		/*   Load only TLB */
+#define CPUID_DATP_TCTYPE_S	5		/*   Store only TLB */
 #define CPUID_DATP_TCLEVEL	__BITS(7, 5)	/* TLB level (start at 1) */
 #define CPUID_DATP_FULLASSOC	__BIT(8)	/* Full associative */
 #define CPUID_DATP_SHAREING	__BITS(25, 14)	/* shareing */
@@ -882,6 +886,7 @@
 #define 	IA32_ARCH_SKIP_L1DFL_VMENTRY 0x08
 #define 	IA32_ARCH_SSB_NO	0x10
 #define 	IA32_ARCH_MDS_NO	0x20
+#define 	IA32_ARCH_IF_PSCHANGE_MC_NO 0x40
 #define 	IA32_ARCH_TSX_CTRL	0x80
 #define 	IA32_ARCH_TAA_NO	0x100
 #define MSR_IA32_FLUSH_CMD	0x10b