Re: CVS commit: src

2020-05-10 Thread Martin Husemann
On Sun, May 10, 2020 at 04:18:54PM +0200, Yorick Hardy wrote:
> I think it may be better in the Makefile, since the test for amd64 already
> happens there and because the libi386 directory could conceivably
> also contain i386/non-amd64 tests.
> 
> I successfully completed a build with MKCOMPAT=no, using the patch below.
> Is it okay to commit?

Looks good to me, thanks!

Martin


Re: CVS commit: src/sys/uvm

2020-05-10 Thread Alistair Crooks
On Sat, 9 May 2020 at 14:50, Taylor R Campbell  wrote:

> Module Name:src
> Committed By:   riastradh
> Date:   Sat May  9 21:50:39 UTC 2020
>
> Modified Files:
> src/sys/uvm: uvm_swap.c
>
> Log Message:
> Implement swap encryption.
>
> Enabled by sysctl -w vm.swap_encrypt=1.  Key is generated lazily when
> we first need to swap a page.  Key is chosen independently for each
> swap device.  The ith swap page is encrypted with AES256-CBC using
> AES256_k(le32enc(i) || 0^96) as the initialization vector.  Can be
> changed at any time; no need for compatibility with on-disk formats.
> Costs one bit of memory per page in each swapdev, plus a few hundred
> bytes per swapdev to store the expanded AES key.
>
> Shoulda done this decades ago!  Plan to enable this by default;
> performance impact is unlikely to matter because it only happens when
> you're already swapping anyway.  Much easier to set up than cgd, so
> we can rip out all the documentation about carefully setting up
> random-keyed cgd at the right time.
>
> Thanks, this is great - looking forward to it being default!

Best,
Alistair


CVS commit: src

2020-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 11 03:59:33 UTC 2020

Modified Files:
src/share/man/man9: condvar.9
src/sys/kern: kern_condvar.c subr_time.c
src/sys/sys: condvar.h timevar.h

Log Message:
Remove timedwaitclock.

This did not fix the bug I hoped it would fix in futex, and needs
more design thought.  Might redo it somewhat differently later.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/share/man/man9/condvar.9
cvs rdiff -u -r1.51 -r1.52 src/sys/kern/kern_condvar.c
cvs rdiff -u -r1.23 -r1.24 src/sys/kern/subr_time.c
cvs rdiff -u -r1.16 -r1.17 src/sys/sys/condvar.h
cvs rdiff -u -r1.43 -r1.44 src/sys/sys/timevar.h

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



CVS commit: src

2020-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 11 03:59:33 UTC 2020

Modified Files:
src/share/man/man9: condvar.9
src/sys/kern: kern_condvar.c subr_time.c
src/sys/sys: condvar.h timevar.h

Log Message:
Remove timedwaitclock.

This did not fix the bug I hoped it would fix in futex, and needs
more design thought.  Might redo it somewhat differently later.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/share/man/man9/condvar.9
cvs rdiff -u -r1.51 -r1.52 src/sys/kern/kern_condvar.c
cvs rdiff -u -r1.23 -r1.24 src/sys/kern/subr_time.c
cvs rdiff -u -r1.16 -r1.17 src/sys/sys/condvar.h
cvs rdiff -u -r1.43 -r1.44 src/sys/sys/timevar.h

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

Modified files:

Index: src/share/man/man9/condvar.9
diff -u src/share/man/man9/condvar.9:1.27 src/share/man/man9/condvar.9:1.28
--- src/share/man/man9/condvar.9:1.27	Sun May  3 04:06:15 2020
+++ src/share/man/man9/condvar.9	Mon May 11 03:59:33 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: condvar.9,v 1.27 2020/05/03 04:06:15 riastradh Exp $
+.\"	$NetBSD: condvar.9,v 1.28 2020/05/11 03:59:33 riastradh Exp $
 .\"
 .\" Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -65,13 +65,6 @@
 .Ft int
 .Fn cv_timedwaitbt_sig "kcondvar_t *cv" "kmutex_t *mtx" "struct bintime *bt" \
 "const struct bintime *epsilon"
-.Ft int
-.Fn cv_timedwaitclock "kcondvar_t *cv" "kmutex_t *mtx" \
-"struct timespec *timeout" "clockid_t clockid" "int flags" \
-"const struct bintime *epsilon"
-.Fn cv_timedwaitclock_sig "kcondvar_t *cv" "kmutex_t *mtx" \
-"struct timespec *timeout" "clockid_t clockid" "int flags" \
-"const struct bintime *epsilon"
 .Ft void
 .Fn cv_signal "kcondvar_t *cv"
 .Ft void
@@ -264,47 +257,6 @@ However, the system is still limited by 
 resolution and by scheduling competition, which may delay the wakeup by
 more than
 .Fa bt Li "+" Fa epsilon .
-.It Fn cv_timedwaitclock "cv" "lock" "timeout" "clockid" "flags" "epsilon"
-.It Fn cv_timedwaitclock_sig "cv" "lock" "timeout" "clockid" "flags" "epsilon"
-As per
-.Fn cv_wait
-and
-.Fn cv_wait_sig ,
-but will return early in case of timeout.
-The timeout is measured by the clock
-.Fa clockid ;
-see
-.Xr clock_settime 2
-for the supported options.
-The
-.Fa flags
-may be
-.Dv TIMER_RELTIME
-for a relative duration or
-.Dv TIMER_ABSTIME
-for an absolute time on the clock.
-For relative timeouts,
-.Fn cv_timedwaitclock
-and
-.Fn cv_timedwaitclock_sig
-subtract the elapsed time from
-.Fa timeout
-in place, or set it to zero if there is no time remaining.
-The hint
-.Fa epsilon
-requests a maximum delay after the timeout before wakeup.
-.Pp
-It is safe to pass in values of
-.Fa clockid
-and
-.Fa flags
-from userland, and timeouts copied in from userland; if anything is
-wrong with them,
-.Fn cv_timedwaitclock
-or
-.Fn cv_timedwaitclock_sig
-will return
-.Er EINVAL .
 .It Fn cv_signal "cv"
 .Pp
 Awaken one LWP waiting on the specified condition variable.
@@ -380,29 +332,6 @@ Consuming a resource:
 	consume(res);
 .Ed
 .Pp
-Consuming a resource using a timeout specified in a syscall by
-userland:
-.Bd -literal
-	struct timespec timeout;
-
-	error = copyin(SCARG(uap, timeout), , sizeof timeout);
-	if (error)
-		return error;
-
-	mutex_enter(>mutex);
-	while (res->state == BUSY) {
-		error = cv_timedwaitclock_sig(>condvar,
-		>mutex, , SCARG(uap, clock_id),
-		SCARG(uap, flags), DEFAULT_TIMEOUT_EPSILON);
-		if (error)
-			break;
-	}
-	mutex_exit(>mutex);
-	if (error)
-		return error;
-	consume(res);
-.Ed
-.Pp
 Releasing a resource for the next consumer to use:
 .Bd -literal
 	mutex_enter(>mutex);
@@ -442,9 +371,3 @@ and
 .Fn cv_timedwaitbt_sig
 primitives first appeared in
 .Nx 9.0 .
-The
-.Fn cv_timedwaitclock
-and
-.Fn cv_timedwaitclock_sig
-primitives first appeared in
-.Nx 10.0 .

Index: src/sys/kern/kern_condvar.c
diff -u src/sys/kern/kern_condvar.c:1.51 src/sys/kern/kern_condvar.c:1.52
--- src/sys/kern/kern_condvar.c:1.51	Mon May  4 18:23:37 2020
+++ src/sys/kern/kern_condvar.c	Mon May 11 03:59:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_condvar.c,v 1.51 2020/05/04 18:23:37 riastradh Exp $	*/
+/*	$NetBSD: kern_condvar.c,v 1.52 2020/05/11 03:59:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.51 2020/05/04 18:23:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.52 2020/05/11 03:59:33 riastradh Exp $");
 
 #include 
 #include 
@@ -245,75 +245,6 @@ cv_timedwait_sig(kcondvar_t *cv, kmutex_
 }
 
 /*
- * cv_timedwaitclock:
- *
- *	Wait on a condition variable until awoken normally, or the
- *	specified timeout expires according to the provided clock.
- *	Returns zero if awoken normally or EWOULDBLOCK if the timeout
- *	expired.  For relative timeouts ((flags & TIMER_ABSTIME) == 0),
- *	

Re: CVS commit: src/sys/uvm

2020-05-10 Thread Taylor R Campbell
> Date: Sun, 10 May 2020 23:53:00 +0100
> From: Alexander Nasonov 
> 
> Taylor R Campbell wrote:
> > Log Message:
> > Implement swap encryption.
> > 
> > Enabled by sysctl -w vm.swap_encrypt=1.
> 
> If secmodel_securelevel(9) is still a thing, locking down this sysctl
> at high securelevel may improve our security. Prior to this change,
> swap devices were readable (even if enrypted with cgd).  With this
> sysctl set to 1, all new swap devices will be encrypted, the only
> thing to worry about is if it's set back to 0 on a compromised host.

This sounds entirely reasonable.  Would you like to draft an
implementation of that?

Presumably it would require writing a sysctl callback function for
vm.swap_encrypt, and would somehow involve kauth, but I'm not sure
offhand what needs to happen beyond that.  Perhaps vm.user_va0_disable
can be a source of inspiration.


CVS commit: src/sys/arch/aarch64

2020-05-10 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon May 11 03:00:57 UTC 2020

Modified Files:
src/sys/arch/aarch64/conf: Makefile.aarch64
src/sys/arch/aarch64/include: armreg.h asm.h

Log Message:
"options ARMV83_PAC" is now supported for gcc as well.

- add "-msign-return-address=all" to CFLAGS for gcc when specified options 
ARMV83_PAC
- AARCH64REG_{READ,WRITE}_INLINE3 macro can now use the APIAKey registers in 
both gcc and llvm.
  llvm requires asm(".arch armv8.3-a"), whereas gcc requires 
__attribute__((target("arch=armv8.3-a"))).
- use ".arch armv8.3-a" rather than ".arch armv8.3-a+pac" in *.S for llvm.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/aarch64/conf/Makefile.aarch64
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/aarch64/include/armreg.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/include/asm.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/aarch64/conf/Makefile.aarch64
diff -u src/sys/arch/aarch64/conf/Makefile.aarch64:1.20 src/sys/arch/aarch64/conf/Makefile.aarch64:1.21
--- src/sys/arch/aarch64/conf/Makefile.aarch64:1.20	Mon Apr 13 07:32:36 2020
+++ src/sys/arch/aarch64/conf/Makefile.aarch64	Mon May 11 03:00:57 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.aarch64,v 1.20 2020/04/13 07:32:36 maxv Exp $
+#	$NetBSD: Makefile.aarch64,v 1.21 2020/05/11 03:00:57 ryo Exp $
 
 # Makefile for NetBSD
 #
@@ -52,6 +52,15 @@ CFLAGS+=	-mbranch-protection=bti
 .endif
 .endif
 
+.if ${HAVE_GCC:U0} > 0
+.if ${ARMV83_PAC:U0} > 0
+CFLAGS+=	-msign-return-address=all
+.endif
+.if ${ARMV85_BTI:U0} > 0
+# XXX: notyet for gcc
+.endif
+.endif
+
 .if ${KASAN:U0} > 0 && ${HAVE_GCC:U0} > 0
 KASANFLAGS=	-fsanitize=kernel-address \
 		--param asan-globals=1 --param asan-stack=1 \

Index: src/sys/arch/aarch64/include/armreg.h
diff -u src/sys/arch/aarch64/include/armreg.h:1.41 src/sys/arch/aarch64/include/armreg.h:1.42
--- src/sys/arch/aarch64/include/armreg.h:1.41	Sun May 10 21:40:38 2020
+++ src/sys/arch/aarch64/include/armreg.h	Mon May 11 03:00:57 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: armreg.h,v 1.41 2020/05/10 21:40:38 riastradh Exp $ */
+/* $NetBSD: armreg.h,v 1.42 2020/05/11 03:00:57 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -35,23 +35,39 @@
 #include 
 #include 
 
-#define AARCH64REG_READ_INLINE3(regname, regdesc, fnattrs)	\
-static __inline uint64_t fnattrs\
+#ifdef __clang__
+#define ATTR_ARCH(arch)			".arch " arch ";"
+#define ATTR_TARGET_ARCH(x)
+#define ASM_ARCH(x)			x
+#else
+#define ATTR_ARCH(arch)			__attribute__((target("arch=" arch)))
+#define ATTR_TARGET_ARCH(x)		x
+#define ASM_ARCH(x)
+#endif
+
+#define AARCH64REG_READ_INLINE3(regname, regdesc, arch)		\
+static __inline uint64_t ATTR_TARGET_ARCH(arch)			\
 reg_##regname##_read(void)	\
 {\
 	uint64_t __rv;		\
-	__asm __volatile("mrs %0, " #regdesc : "=r"(__rv));	\
+	__asm __volatile(	\
+	ASM_ARCH(arch)	\
+	"mrs %0, " #regdesc : "=r"(__rv)			\
+	);			\
 	return __rv;		\
 }
 
 #define AARCH64REG_READ_INLINE2(regname, regdesc)		\
 	AARCH64REG_READ_INLINE3(regname, regdesc, )
 
-#define AARCH64REG_WRITE_INLINE3(regname, regdesc, fnattrs)	\
-static __inline void fnattrs	\
+#define AARCH64REG_WRITE_INLINE3(regname, regdesc, arch)	\
+static __inline void ATTR_TARGET_ARCH(arch)			\
 reg_##regname##_write(uint64_t __val)\
 {\
-	__asm __volatile("msr " #regdesc ", %0" :: "r"(__val));	\
+	__asm __volatile(	\
+	ASM_ARCH(arch)	\
+	"msr " #regdesc ", %0" :: "r"(__val)		\
+	);			\
 }
 
 #define AARCH64REG_WRITE_INLINE2(regname, regdesc)		\
@@ -380,7 +396,7 @@ AARCH64REG_READ_INLINE(id_aa64mmfr1_el1)
 #define	 ID_AA64MMFR1_EL1_HAFDBS_AD	 2
 
 AARCH64REG_READ_INLINE3(id_aa64mmfr2_el1, id_aa64mmfr2_el1,
-__attribute__((target("arch=armv8.2-a"
+ATTR_ARCH("armv8.2-a"))
 
 #define	ID_AA64MMFR2_EL1_E0PD		__BITS(63,60)
 #define	 ID_AA64MMFR2_EL1_E0PD_NONE	 0
@@ -548,6 +564,11 @@ AARCH64REG_READ_INLINE(revidr_el1)
 /*
  * These are read/write registers
  */
+AARCH64REG_READ_INLINE3(APIAKeyLo_EL1, apiakeylo_el1, ATTR_ARCH("armv8.3-a"))
+AARCH64REG_WRITE_INLINE3(APIAKeyLo_EL1, apiakeylo_el1, ATTR_ARCH("armv8.3-a"))
+AARCH64REG_READ_INLINE3(APIAKeyHi_EL1, apiakeyhi_el1, ATTR_ARCH("armv8.3-a"))
+AARCH64REG_WRITE_INLINE3(APIAKeyHi_EL1, apiakeyhi_el1, ATTR_ARCH("armv8.3-a"))
+
 AARCH64REG_READ_INLINE(cpacr_el1)	// Coprocessor Access Control Regiser
 AARCH64REG_WRITE_INLINE(cpacr_el1)
 
@@ -786,20 +807,6 @@ AARCH64REG_WRITE_INLINE(sctlr_el1)
 #define	SCTLR_ATA		__BIT(43)
 #define	SCTLR_DSSBS		__BIT(44)
 
-static __inline void
-reg_APIAKeyLo_EL1_write(uint64_t __val)
-{
-	__asm __volatile(".arch armv8.3-a+pac\n"
-	"msr APIAKeyLo_EL1, %0" :: "r"(__val));
-}
-
-static __inline void
-reg_APIAKeyHi_EL1_write(uint64_t __val)
-{
-	__asm __volatile(".arch armv8.3-a+pac\n"
-	"msr APIAKeyHi_EL1, %0" :: "r"(__val));
-}

CVS commit: src/sys/arch/aarch64

2020-05-10 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon May 11 03:00:57 UTC 2020

Modified Files:
src/sys/arch/aarch64/conf: Makefile.aarch64
src/sys/arch/aarch64/include: armreg.h asm.h

Log Message:
"options ARMV83_PAC" is now supported for gcc as well.

- add "-msign-return-address=all" to CFLAGS for gcc when specified options 
ARMV83_PAC
- AARCH64REG_{READ,WRITE}_INLINE3 macro can now use the APIAKey registers in 
both gcc and llvm.
  llvm requires asm(".arch armv8.3-a"), whereas gcc requires 
__attribute__((target("arch=armv8.3-a"))).
- use ".arch armv8.3-a" rather than ".arch armv8.3-a+pac" in *.S for llvm.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/aarch64/conf/Makefile.aarch64
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/aarch64/include/armreg.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/include/asm.h

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



Re: CVS commit: src/sys/uvm

2020-05-10 Thread Alexander Nasonov
Taylor R Campbell wrote:
> Log Message:
> Implement swap encryption.
> 
> Enabled by sysctl -w vm.swap_encrypt=1.

If secmodel_securelevel(9) is still a thing, locking down this sysctl
at high securelevel may improve our security. Prior to this change,
swap devices were readable (even if enrypted with cgd).  With this
sysctl set to 1, all new swap devices will be encrypted, the only
thing to worry about is if it's set back to 0 on a compromised host.

Not sure if this makes sense because all files on a compromised
host can be read and processes' memory can be probably dumped.

Alex


CVS commit: src/usr.sbin/rtadvd

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 22:38:51 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
warn only for > INFO level messages.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/usr.sbin/rtadvd/rtadvd.c

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



CVS commit: src/usr.sbin/rtadvd

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 22:38:51 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
warn only for > INFO level messages.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/usr.sbin/rtadvd/rtadvd.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/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.76 src/usr.sbin/rtadvd/rtadvd.c:1.77
--- src/usr.sbin/rtadvd/rtadvd.c:1.76	Sun May 10 18:33:09 2020
+++ src/usr.sbin/rtadvd/rtadvd.c	Sun May 10 18:38:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.76 2020/05/10 22:33:09 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.77 2020/05/10 22:38:51 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1808,6 +1808,8 @@ logit(int level, const char *fmt, ...)
 		va_end(ap);
 		return;
 	}
+	if (level >= LOG_INFO && !dflag)
+		return;
 
 	vwarnx(expandm(fmt, "\n", ), ap);
 	free(buf);



CVS commit: src/usr.sbin/rtadvd

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 22:33:09 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Print errors to stderr until we daemonize.
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/usr.sbin/rtadvd/rtadvd.c

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



CVS commit: src/usr.sbin/rtadvd

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 22:33:09 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Print errors to stderr until we daemonize.
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/usr.sbin/rtadvd/rtadvd.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/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.75 src/usr.sbin/rtadvd/rtadvd.c:1.76
--- src/usr.sbin/rtadvd/rtadvd.c:1.75	Tue Apr 21 08:23:13 2020
+++ src/usr.sbin/rtadvd/rtadvd.c	Sun May 10 18:33:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.75 2020/04/21 12:23:13 wiz Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.76 2020/05/10 22:33:09 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -54,6 +54,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #ifdef __NetBSD__
 #include 
@@ -87,6 +88,7 @@ static const char *dumpfilename = "/var/
 int sock;
 int rtsock = -1;
 int Cflag = 0, dflag = 0, sflag = 0, Dflag;
+static int after_daemon = 0;
 
 static char **if_argv;
 static int if_argc;
@@ -214,16 +216,16 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 	if (argc == 0) {
-		fprintf(stderr, "Ysage: %s [-CDdfs] [-c conffile]"
+		fprintf(stderr, "Usage: %s [-CDdfs] [-c conffile]"
 		" [-p pidfile] interface ...\n", getprogname());
 		return EXIT_FAILURE;
 	}
 
 	if ((pid = pidfile_lock(pidfilepath)) != 0) {
-		if (pid == -1)
+		if (pid == -1) {
 			logit(LOG_ERR, "pidfile_lock: %m");
 			/* Continue */
-		else {
+		} else {
 			logit(LOG_ERR, "Another instance of `%s' is running "
 			"(pid %d); exiting.", getprogname(), pid);
 			return EXIT_FAILURE;
@@ -265,6 +267,7 @@ main(int argc, char *argv[])
 
 	if (!fflag) {
 		prog_daemon(1, 0);
+		after_daemon = 1;
 		if (pidfile_lock(pidfilepath) != 0)
 			logit(LOG_ERR, " pidfile_lock: %m");
 	}
@@ -1800,13 +1803,13 @@ logit(int level, const char *fmt, ...)
 	char *buf;
 
 	va_start(ap, fmt);
-	if (!Dflag) {
+	if (!Dflag && after_daemon) {
 		vsyslog(level, fmt, ap);
 		va_end(ap);
 		return;
 	}
 
-	vfprintf(stderr, expandm(fmt, "\n", ), ap);
+	vwarnx(expandm(fmt, "\n", ), ap);
 	free(buf);
 	va_end(ap);
 }



CVS commit: src/sys/uvm

2020-05-10 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun May 10 22:28:09 UTC 2020

Modified Files:
src/sys/uvm: files.uvm

Log Message:
Add missing dependency.

Fixes builds with VM_SWAP but no other users of rijndael crypto code.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/uvm/files.uvm

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

Modified files:

Index: src/sys/uvm/files.uvm
diff -u src/sys/uvm/files.uvm:1.33 src/sys/uvm/files.uvm:1.34
--- src/sys/uvm/files.uvm:1.33	Wed Jan 15 17:55:45 2020
+++ src/sys/uvm/files.uvm	Sun May 10 22:28:09 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.uvm,v 1.33 2020/01/15 17:55:45 ad Exp $
+#	$NetBSD: files.uvm,v 1.34 2020/05/10 22:28:09 pgoyette Exp $
 
 #
 # UVM options
@@ -8,7 +8,7 @@ defflag opt_uvmhist.h		UVMHIST_PRINT: KE
 defparam opt_uvmhist.h		UVMHIST_MAPHIST_SIZE UVMHIST_PDHIST_SIZE
 defflag opt_uvm.h		USE_TOPDOWN_VM UVMMAP_COUNTERS
 defparam opt_uvm.h		UVM_RESERVED_PAGES_PER_CPU
-defflag opt_vmswap.h		VMSWAP
+defflag opt_vmswap.h		VMSWAP : rijndael
 defflag opt_readahead.h		READAHEAD_STATS
 defflag opt_ubc.h		UBC_STATS
 defparam opt_pagermap.h		PAGER_MAP_SIZE



CVS commit: src/sys/uvm

2020-05-10 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun May 10 22:28:09 UTC 2020

Modified Files:
src/sys/uvm: files.uvm

Log Message:
Add missing dependency.

Fixes builds with VM_SWAP but no other users of rijndael crypto code.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/uvm/files.uvm

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



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

2020-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 10 21:41:19 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Print RNDR support in verbose CPU feature identification.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/aarch64/aarch64/cpu.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/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.43 src/sys/arch/aarch64/aarch64/cpu.c:1.44
--- src/sys/arch/aarch64/aarch64/cpu.c:1.43	Sun Apr  5 22:54:51 2020
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sun May 10 21:41:19 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.43 2020/04/05 22:54:51 jmcneill Exp $ */
+/* $NetBSD: cpu.c,v 1.44 2020/05/10 21:41:19 riastradh Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.43 2020/04/05 22:54:51 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.44 2020/05/10 21:41:19 riastradh Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -375,6 +375,11 @@ cpu_identify2(device_t self, struct cpu_
 		aprint_verbose(", AES+PMULL");
 		break;
 	}
+	switch (__SHIFTOUT(id->ac_aa64isar0, ID_AA64ISAR0_EL1_RNDR)) {
+	case ID_AA64ISAR0_EL1_RNDR_RNDRRS:
+		aprint_verbose(", RNDRRS");
+		break;
+	}
 
 
 	/* PFR0:AdvSIMD */



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

2020-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 10 21:42:06 UTC 2020

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

Log Message:
Teach cpuctl(8) about ARMv8.5-RNG RNDR/RNDRRS support.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/cpuctl/arch/aarch64.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/aarch64.c
diff -u src/usr.sbin/cpuctl/arch/aarch64.c:1.8 src/usr.sbin/cpuctl/arch/aarch64.c:1.9
--- src/usr.sbin/cpuctl/arch/aarch64.c:1.8	Tue Jan 28 17:36:42 2020
+++ src/usr.sbin/cpuctl/arch/aarch64.c	Sun May 10 21:42:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aarch64.c,v 1.8 2020/01/28 17:36:42 maxv Exp $	*/
+/*	$NetBSD: aarch64.c,v 1.9 2020/05/10 21:42:05 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -29,7 +29,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: aarch64.c,v 1.8 2020/01/28 17:36:42 maxv Exp $");
+__RCSID("$NetBSD: aarch64.c,v 1.9 2020/05/10 21:42:05 riastradh Exp $");
 #endif /* no lint */
 
 #include 
@@ -225,6 +225,13 @@ struct fieldinfo id_aa64isar0_fieldinfo[
 			"/CRC32CB/CRC32CH/CRC32CW/CRC32CX"
 		}
 	},
+	{
+		.bitpos = 60, .bitwidth = 4, .name = "RNDR",
+		.info = (const char *[16]) { /* 16=4bit */
+			[0] = "No RNDR/RNDRRS",
+			[1] = "RNDR/RNDRRS",
+		},
+	},
 	{ .bitwidth = 0 }	/* end of table */
 };
 



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

2020-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 10 21:41:19 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Print RNDR support in verbose CPU feature identification.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/aarch64/aarch64/cpu.c

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



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

2020-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 10 21:42:06 UTC 2020

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

Log Message:
Teach cpuctl(8) about ARMv8.5-RNG RNDR/RNDRRS support.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/cpuctl/arch/aarch64.c

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



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

2020-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 10 21:40:38 UTC 2020

Modified Files:
src/sys/arch/aarch64/include: armreg.h

Log Message:
Fix ID_AA64ISAR0_EL1_RNDR field definition for RNDR support.

ARMv8.5 ARM, p. D13-3232


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/aarch64/include/armreg.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/aarch64/include/armreg.h
diff -u src/sys/arch/aarch64/include/armreg.h:1.40 src/sys/arch/aarch64/include/armreg.h:1.41
--- src/sys/arch/aarch64/include/armreg.h:1.40	Sun Apr 12 07:49:58 2020
+++ src/sys/arch/aarch64/include/armreg.h	Sun May 10 21:40:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: armreg.h,v 1.40 2020/04/12 07:49:58 maxv Exp $ */
+/* $NetBSD: armreg.h,v 1.41 2020/05/10 21:40:38 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -229,7 +229,7 @@ AARCH64REG_READ_INLINE(id_aa64dfr1_el1)
 
 AARCH64REG_READ_INLINE(id_aa64isar0_el1)
 
-#define	ID_AA64ISAR0_EL1_RNDR		__BITS(63,30)
+#define	ID_AA64ISAR0_EL1_RNDR		__BITS(63,60)
 #define	 ID_AA64ISAR0_EL1_RNDR_NONE	 0
 #define	 ID_AA64ISAR0_EL1_RNDR_RNDRRS	 1
 #define	ID_AA64ISAR0_EL1_TLB		__BITS(59,56)



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

2020-05-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 10 21:40:38 UTC 2020

Modified Files:
src/sys/arch/aarch64/include: armreg.h

Log Message:
Fix ID_AA64ISAR0_EL1_RNDR field definition for RNDR support.

ARMv8.5 ARM, p. D13-3232


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/aarch64/include/armreg.h

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



CVS commit: src/crypto/dist/ipsec-tools/src/setkey

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 19:54:49 UTC 2020

Modified Files:
src/crypto/dist/ipsec-tools/src/setkey: token.l

Log Message:
prefix errors with the program name and use stderr.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/crypto/dist/ipsec-tools/src/setkey/token.l

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

Modified files:

Index: src/crypto/dist/ipsec-tools/src/setkey/token.l
diff -u src/crypto/dist/ipsec-tools/src/setkey/token.l:1.23 src/crypto/dist/ipsec-tools/src/setkey/token.l:1.24
--- src/crypto/dist/ipsec-tools/src/setkey/token.l:1.23	Tue Jul 23 00:30:32 2019
+++ src/crypto/dist/ipsec-tools/src/setkey/token.l	Sun May 10 15:54:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: token.l,v 1.23 2019/07/23 04:30:32 ozaki-r Exp $	*/
+/*	$NetBSD: token.l,v 1.24 2020/05/10 19:54:49 christos Exp $	*/
 /*	$KAME: token.l,v 1.44 2003/10/21 07:20:58 itojun Exp $	*/
 
 /*
@@ -49,6 +49,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vchar.h"
 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || \
@@ -335,7 +336,7 @@ yyfatal(const char *s)
 void
 yyerror(const char *s)
 {
-	printf("line %d: %s at [%s]\n", lineno, s, yytext);
+	warnx("line %d: %s at [%s]", lineno, s, yytext);
 }
 
 int
@@ -347,7 +348,7 @@ parse(FILE **fp)
 	parse_init();
 
 	if (yyparse()) {
-		printf("parse failed, line %d.\n", lineno);
+		warnx("line %d: parse failed", lineno);
 		return(-1);
 	}
 



CVS commit: src/crypto/dist/ipsec-tools/src/setkey

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 19:54:49 UTC 2020

Modified Files:
src/crypto/dist/ipsec-tools/src/setkey: token.l

Log Message:
prefix errors with the program name and use stderr.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/crypto/dist/ipsec-tools/src/setkey/token.l

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



CVS commit: src/lib/libc/gen

2020-05-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sun May 10 19:36:49 UTC 2020

Modified Files:
src/lib/libc/gen: Makefile.inc

Log Message:
Don't add getentropy.c to the build (remove symbol from libc)

Still being discussed in tech-userlevel. If we wait any longer someone
is going to try the excuse that the discussion is entirely pointless, since
removing symbols is too hard.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/lib/libc/gen/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/lib/libc/gen/Makefile.inc
diff -u src/lib/libc/gen/Makefile.inc:1.202 src/lib/libc/gen/Makefile.inc:1.203
--- src/lib/libc/gen/Makefile.inc:1.202	Wed May  6 16:17:36 2020
+++ src/lib/libc/gen/Makefile.inc	Sun May 10 19:36:49 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.202 2020/05/06 16:17:36 nia Exp $
+#	$NetBSD: Makefile.inc,v 1.203 2020/05/10 19:36:49 maya Exp $
 #	from: @(#)Makefile.inc	8.6 (Berkeley) 5/4/95
 
 # gen sources
@@ -15,7 +15,7 @@ SRCS+=	alarm.c alphasort.c arc4random.c 
 	errc.c errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \
 	exect.c extattr.c fmtcheck.c fmtmsg.c fnmatch.c fstab.c ftok.c \
 	fts.c ftw.c getbsize.c getcap.c getcwd.c \
-	getdevmajor.c getdomainname.c getentropy.c getgrent.c \
+	getdevmajor.c getdomainname.c getgrent.c \
 	getgrouplist.c getgroupmembership.c gethostname.c \
 	getloadavg.c getlogin.c getmntinfo.c \
 	getnetgrent.c getpagesize.c \



CVS commit: src/lib/libc/gen

2020-05-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sun May 10 19:36:49 UTC 2020

Modified Files:
src/lib/libc/gen: Makefile.inc

Log Message:
Don't add getentropy.c to the build (remove symbol from libc)

Still being discussed in tech-userlevel. If we wait any longer someone
is going to try the excuse that the discussion is entirely pointless, since
removing symbols is too hard.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/lib/libc/gen/Makefile.inc

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



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

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 17:58:16 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c

Log Message:
Add SIGPIPE to the list of dhcpcd affected signals since we sigignore it.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/external/bsd/dhcpcd/dist/src/dhcpcd.c

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



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

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 17:58:16 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcpcd.c

Log Message:
Add SIGPIPE to the list of dhcpcd affected signals since we sigignore it.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/external/bsd/dhcpcd/dist/src/dhcpcd.c

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

Modified files:

Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.35 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.36
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.35	Tue Apr 21 05:55:33 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Sun May 10 13:58:16 2020
@@ -80,6 +80,7 @@ const int dhcpcd_signals[] = {
 	SIGTERM,
 	SIGINT,
 	SIGALRM,
+	SIGPIPE,
 	SIGHUP,
 	SIGUSR1,
 	SIGUSR2,



Re: CVS commit: src/sys

2020-05-10 Thread Christos Zoulas
In article <20200508220155.446eef...@cvs.netbsd.org>,
Andrew Doran  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  ad
>Date:  Fri May  8 22:01:55 UTC 2020
>
>Modified Files:
>   src/sys/arch/x86/include: cpu_counter.h
>   src/sys/arch/x86/x86: cpu.c tsc.c
>   src/sys/dev/ic: hpet.c hpetvar.h
>
>Log Message:
>Fix the TSC timecounter (on the systems I have access to):
>
>- Make the early i8254-based calculation of frequency a bit more accurate.
>
>- Keep track of how far the HPET & TSC advance between HPET attach and
>  secondary CPU boot, and use to compute an accurate value before attaching
>  the timecounter.  Initial idea from joerg@.
>
>- When determining skew and drift between CPUs, make each measurement 1000
>  times and pick the lowest observed value.  Increase the error threshold to
>  1000 clock cycles.
>
>- Use the frequency computed on the boot CPU for secondary CPUs too.
>
>- Remove cpu_counter_serializing().

The TSC is still faster than it is supposed to be so ntpd does not sync
(it diverges). It is better than before but not good enough to keep time.

christos



CVS commit: src/lib/libc/arch/hppa/sys

2020-05-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 10 14:34:31 UTC 2020

Modified Files:
src/lib/libc/arch/hppa/sys: brk.S sbrk.S

Log Message:
Rename curbrk to __curbrk, and make it and __minbrk hidden


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/arch/hppa/sys/brk.S
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/arch/hppa/sys/sbrk.S

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/arch/hppa/sys/brk.S
diff -u src/lib/libc/arch/hppa/sys/brk.S:1.8 src/lib/libc/arch/hppa/sys/brk.S:1.9
--- src/lib/libc/arch/hppa/sys/brk.S:1.8	Tue May  5 06:20:55 2020
+++ src/lib/libc/arch/hppa/sys/brk.S	Sun May 10 14:34:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: brk.S,v 1.8 2020/05/05 06:20:55 skrll Exp $	*/
+/*	$NetBSD: brk.S,v 1.9 2020/05/10 14:34:31 skrll Exp $	*/
 
 /*	$OpenBSD: brk.S,v 1.7 2001/06/04 23:14:04 mickey Exp $	*/
 
@@ -31,10 +31,11 @@
 #include "SYS.h"
 
 #if defined(LIBC_SCCS) && !defined(lint)
-	RCSID("$NetBSD: brk.S,v 1.8 2020/05/05 06:20:55 skrll Exp $")
+	RCSID("$NetBSD: brk.S,v 1.9 2020/05/10 14:34:31 skrll Exp $")
 #endif /* LIBC_SCCS and not lint */
 
-	.import	curbrk, data
+	.import	__curbrk, data
+	.hidden __curbrk
 	.global	_end
 
 #ifdef WEAK_ALIAS
@@ -43,6 +44,7 @@
 
 	.data
 	.export	__minbrk, data
+	.hidden __minbrk
 __minbrk:
 	.long	_end
 
@@ -63,14 +65,14 @@ ENTRY(_brk,0)
 
 	ldw	HPPA_FRAME_ARG(0)(%sp), %arg0
 #ifdef __PIC__
-	addil	LT%curbrk, %r19
-	ldw	RT%curbrk(%r1), %r1
+	addil	LT%__curbrk, %r19
+	ldw	RT%__curbrk(%r1), %r1
 	bv	%r0(%rp)
 	 stw	%arg0, 0(%r1)
 #else  /* !__PIC__ */
-	ldil	L%curbrk, %t1
+	ldil	L%__curbrk, %t1
 	bv	%r0(%rp)
-	 stw	%arg0, R%curbrk(%t1)
+	 stw	%arg0, R%__curbrk(%t1)
 #endif /* !__PIC__ */
 EXIT(brk)
 

Index: src/lib/libc/arch/hppa/sys/sbrk.S
diff -u src/lib/libc/arch/hppa/sys/sbrk.S:1.7 src/lib/libc/arch/hppa/sys/sbrk.S:1.8
--- src/lib/libc/arch/hppa/sys/sbrk.S:1.7	Tue May  5 06:20:55 2020
+++ src/lib/libc/arch/hppa/sys/sbrk.S	Sun May 10 14:34:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbrk.S,v 1.7 2020/05/05 06:20:55 skrll Exp $	*/
+/*	$NetBSD: sbrk.S,v 1.8 2020/05/10 14:34:31 skrll Exp $	*/
 
 /*	$OpenBSD: sbrk.S,v 1.7 2001/06/04 23:14:04 mickey Exp $	*/
 
@@ -31,7 +31,7 @@
 #include "SYS.h"
 
 #if defined(LIBC_SCCS) && !defined(lint)
-	RCSID("$NetBSD: sbrk.S,v 1.7 2020/05/05 06:20:55 skrll Exp $")
+	RCSID("$NetBSD: sbrk.S,v 1.8 2020/05/10 14:34:31 skrll Exp $")
 #endif /* LIBC_SCCS and not lint */
 
 	.global	_end
@@ -41,18 +41,19 @@
 #endif
 
 	.data
-	.export	curbrk, data
-curbrk:
+	.export	__curbrk, data
+	.hidden __curbrk
+__curbrk:
 	.long	_end
 
 ENTRY(_sbrk,0)
 #ifdef __PIC__
-	addil	LT%curbrk, %r19
-	ldw	RT%curbrk(%r1), %r1
+	addil	LT%__curbrk, %r19
+	ldw	RT%__curbrk(%r1), %r1
 	ldw	0(%r1), %t2
 #else  /* !__PIC__ */
-	ldil	L%curbrk, %t1
-	ldw	R%curbrk(%t1), %t2
+	ldil	L%__curbrk, %t1
+	ldw	R%__curbrk(%t1), %t2
 #endif /* !__PIC__ */
 	add	%arg0, %t2, %arg0
 	stw	%arg0, HPPA_FRAME_ARG(0)(%sp)
@@ -60,11 +61,11 @@ ENTRY(_sbrk,0)
 	SYSCALL(break)
 
 #ifdef __PIC__
-	addil	LT%curbrk, %r19
-	ldw	RT%curbrk(%r1), %r1
+	addil	LT%__curbrk, %r19
+	ldw	RT%__curbrk(%r1), %r1
 #else  /* !__PIC__ */
-	ldil	L%curbrk, %t1
-	ldo	R%curbrk(%t1), %r1
+	ldil	L%__curbrk, %t1
+	ldo	R%__curbrk(%t1), %r1
 #endif /* !__PIC__ */
 	ldw	0(%r1), %ret0
 	ldw	HPPA_FRAME_ARG(0)(%sp), %arg0



CVS commit: src/lib/libc/arch/hppa/sys

2020-05-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 10 14:34:31 UTC 2020

Modified Files:
src/lib/libc/arch/hppa/sys: brk.S sbrk.S

Log Message:
Rename curbrk to __curbrk, and make it and __minbrk hidden


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/arch/hppa/sys/brk.S
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/arch/hppa/sys/sbrk.S

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



Re: CVS commit: src

2020-05-10 Thread Yorick Hardy
Dear Martin,

On 2020-05-08, Martin Husemann wrote:
> On Thu, May 07, 2020 at 10:52:26PM +0200, Yorick Hardy wrote:
> > Thanks! It took a while for this to sink in ...
> > 
> > So I think the test should only be built if MKCOMPAT=yes ?
> > (It does fail to build for me, because I usually have MKCOMPAT=no).
> 
> Yes, either the Makefile needs a conditional, or the SUBDIR+= in the
> makefile above.
> 
> Martin

I think it may be better in the Makefile, since the test for amd64 already
happens there and because the libi386 directory could conceivably
also contain i386/non-amd64 tests.

I successfully completed a build with MKCOMPAT=no, using the patch below.
Is it okay to commit?

-- 
Kind regards,

Yorick Hardy


Index: distrib/sets/lists/debug/md.amd64
==
--- distrib/sets/lists/debug/md.amd64
+++ distrib/sets/lists/debug/md.amd64
@@ -23,9 +23,9 @@
 ./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait3.debug 
tests-obsolete  obsolete
 ./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait4.debug 
tests-obsolete  obsolete
 ./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait6.debug 
tests-obsolete  obsolete
 ./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_waitid.debug
tests-obsolete  obsolete
 ./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_waitpid.debug   
tests-obsolete  obsolete
-./usr/libdata/debug/usr/tests/lib/libi386/t_user_ldt.debug tests-lib-debug 
debug,atf
+./usr/libdata/debug/usr/tests/lib/libi386/t_user_ldt.debug tests-lib-debug 
debug,atf,compat
 ./usr/libdata/debug/usr/tests/lib/libnvmm/h_io_assist.debugtests-lib-debug 
debug,atf
 ./usr/libdata/debug/usr/tests/lib/libnvmm/h_mem_assist.debug   tests-lib-debug 
debug,atf
 ./usr/libdata/debug/usr/tests/modules/t_x86_pte.debug  tests-sys-debug 
debug,atf

Index: distrib/sets/lists/tests/md.amd64
==
--- distrib/sets/lists/tests/md.amd64
+++ distrib/sets/lists/tests/md.amd64
@@ -5,13 +5,13 @@
 ./usr/tests/kernel/arch/x86/t_ptrace_wait3 tests-obsolete  obsolete
 ./usr/tests/kernel/arch/x86/t_ptrace_wait4 tests-obsolete  obsolete
 ./usr/tests/kernel/arch/x86/t_ptrace_wait6 tests-obsolete  obsolete
 ./usr/tests/kernel/arch/x86/t_ptrace_waitidtests-obsolete  obsolete
 ./usr/tests/kernel/arch/x86/t_ptrace_waitpid   tests-obsolete  obsolete
-./usr/tests/lib/libi386/t_user_ldt tests-lib-tests 
compattestfile,atf
+./usr/tests/lib/libi386/t_user_ldt tests-lib-tests 
compattestfile,atf,compat
 ./usr/tests/lib/libnvmm/h_io_assisttests-lib-tests 
compattestfile,atf
 ./usr/tests/lib/libnvmm/t_io_assisttests-lib-tests 
compattestfile,atf
 ./usr/tests/lib/libnvmm/h_mem_assist   tests-lib-tests 
compattestfile,atf
 ./usr/tests/lib/libnvmm/t_mem_assist   tests-lib-tests 
compattestfile,atf
 ./usr/tests/modules/t_x86_pte  tests-sys-tests atf,kmod
 ./usr/tests/modules/x86_pte_tester tests-sys-tests atf,kmod
 ./usr/tests/modules/x86_pte_tester/x86_pte_tester.kmod tests-sys-tests atf,kmod

Index: tests/lib/libi386/Makefile
==
--- tests/lib/libi386/Makefile
+++ tests/lib/libi386/Makefile
@@ -2,14 +2,14 @@
 
 .include 
 
 TESTSDIR=  ${TESTSBASE}/lib/libi386
 
-.if ${MACHINE} == "amd64"
+.if ${MACHINE} == "amd64" && ${MKCOMPAT} == "yes"
 SHLIBINSTALLDIR=   /usr/lib/i386
 COPTS+=-m32
 LDFLAGS+=  -m32
 LDADD+=-li386
 TESTS_C+=  t_user_ldt
 .endif
 
 .include 



CVS commit: src

2020-05-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 10 14:05:59 UTC 2020

Modified Files:
src/lib/libc/arch/aarch64: genassym.cf
src/lib/libc/arch/aarch64/gen: _setjmp.S setjmp.S
src/sys/arch/aarch64/include: setjmp.h

Log Message:
Don't futz with tpidr_el0 in {set,long}jmp as it breaks TLS as seen in
qemu


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/arch/aarch64/genassym.cf
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/aarch64/gen/_setjmp.S
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/arch/aarch64/gen/setjmp.S
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/include/setjmp.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/arch/aarch64/genassym.cf
diff -u src/lib/libc/arch/aarch64/genassym.cf:1.1 src/lib/libc/arch/aarch64/genassym.cf:1.2
--- src/lib/libc/arch/aarch64/genassym.cf:1.1	Sun Aug 10 05:47:36 2014
+++ src/lib/libc/arch/aarch64/genassym.cf	Sun May 10 14:05:59 2020
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.1 2014/08/10 05:47:36 matt Exp $
+# $NetBSD: genassym.cf,v 1.2 2020/05/10 14:05:59 skrll Exp $
 
 #-
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -53,7 +53,6 @@ define _JB_X27		sizeof(_BSD_JBSLOT_T_ [_
 define _JB_X28		sizeof(_BSD_JBSLOT_T_ [_JB_X29])
 define _JB_X29		sizeof(_BSD_JBSLOT_T_ [_JB_X29])
 define _JB_X30		sizeof(_BSD_JBSLOT_T_ [_JB_X30])
-define _JB_TPIDR	sizeof(_BSD_JBSLOT_T_ [_JB_TPIDR])
 define _JB_D8		sizeof(_BSD_JBSLOT_T_ [_JB_D8])
 define _JB_D9		sizeof(_BSD_JBSLOT_T_ [_JB_D9])
 define _JB_D10		sizeof(_BSD_JBSLOT_T_ [_JB_D10])

Index: src/lib/libc/arch/aarch64/gen/_setjmp.S
diff -u src/lib/libc/arch/aarch64/gen/_setjmp.S:1.3 src/lib/libc/arch/aarch64/gen/_setjmp.S:1.4
--- src/lib/libc/arch/aarch64/gen/_setjmp.S:1.3	Tue Nov 28 13:09:05 2017
+++ src/lib/libc/arch/aarch64/gen/_setjmp.S	Sun May 10 14:05:59 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: _setjmp.S,v 1.3 2017/11/28 13:09:05 ryo Exp $ */
+/* $NetBSD: _setjmp.S,v 1.4 2020/05/10 14:05:59 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -63,9 +63,6 @@ ENTRY(_setjmp)
 	stp	x27, x28, [x0, #_JB_X27]
 	stp	x29, x30, [x0, #_JB_X29]
 
-	mrs	x5, tpidr_el0
-	str	x5, [x0, #_JB_TPIDR]
-
 	stp	d8,  d9,  [x0, #_JB_D8]
 	stp	d10, d11, [x0, #_JB_D10]
 	stp	d12, d13, [x0, #_JB_D12]
@@ -93,9 +90,6 @@ ENTRY(_longjmp)
 	ldp	x25, x26, [x0, #_JB_X25]
 	ldp	x27, x28, [x0, #_JB_X27]
 
-	ldr	x2, [x0, #_JB_TPIDR]
-	msr	tpidr_el0, x2
-
 	ldp	d8,  d9,  [x0, #_JB_D8]
 	ldp	d10, d11, [x0, #_JB_D10]
 	ldp	d12, d13, [x0, #_JB_D12]

Index: src/lib/libc/arch/aarch64/gen/setjmp.S
diff -u src/lib/libc/arch/aarch64/gen/setjmp.S:1.2 src/lib/libc/arch/aarch64/gen/setjmp.S:1.3
--- src/lib/libc/arch/aarch64/gen/setjmp.S:1.2	Tue Nov 28 13:09:05 2017
+++ src/lib/libc/arch/aarch64/gen/setjmp.S	Sun May 10 14:05:59 2020
@@ -1,4 +1,4 @@
-/*.$NetBSD: setjmp.S,v 1.2 2017/11/28 13:09:05 ryo Exp $.*/
+/*.$NetBSD: setjmp.S,v 1.3 2020/05/10 14:05:59 skrll Exp $.*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -61,9 +61,6 @@ ENTRY(__setjmp14)
 	stp	x27, x28, [x0, #_JB_X27]
 	stp	x29, x30, [x0, #_JB_X29]
 
-	mrs	x5, tpidr_el0
-	str	x5, [x0, #_JB_TPIDR]
-
 	stp	d8,  d9,  [x0, #_JB_D8]
 	stp	d10, d11, [x0, #_JB_D10]
 	stp	d12, d13, [x0, #_JB_D12]
@@ -100,9 +97,6 @@ ENTRY(__longjmp14)
 	ldp	x25, x26, [x0, #_JB_X25]
 	ldp	x27, x28, [x0, #_JB_X27]
 
-	ldr	x2, [x0, #_JB_TPIDR]
-	msr	tpidr_el0, x2
-
 	ldp	d8,  d9,  [x0, #_JB_D8]
 	ldp	d10, d11, [x0, #_JB_D10]
 	ldp	d12, d13, [x0, #_JB_D12]

Index: src/sys/arch/aarch64/include/setjmp.h
diff -u src/sys/arch/aarch64/include/setjmp.h:1.1 src/sys/arch/aarch64/include/setjmp.h:1.2
--- src/sys/arch/aarch64/include/setjmp.h:1.1	Sun Aug 10 05:47:38 2014
+++ src/sys/arch/aarch64/include/setjmp.h	Sun May 10 14:05:59 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: setjmp.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
+/* $NetBSD: setjmp.h,v 1.2 2020/05/10 14:05:59 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -50,7 +50,6 @@
 #define _JB_X28		11
 #define _JB_X29		12
 #define _JB_X30		13
-#define _JB_TPIDR	14
 #define _JB_D8		16
 #define _JB_D9		17
 #define _JB_D10		18



CVS commit: src

2020-05-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 10 14:05:59 UTC 2020

Modified Files:
src/lib/libc/arch/aarch64: genassym.cf
src/lib/libc/arch/aarch64/gen: _setjmp.S setjmp.S
src/sys/arch/aarch64/include: setjmp.h

Log Message:
Don't futz with tpidr_el0 in {set,long}jmp as it breaks TLS as seen in
qemu


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/arch/aarch64/genassym.cf
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/aarch64/gen/_setjmp.S
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/arch/aarch64/gen/setjmp.S
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/include/setjmp.h

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



CVS commit: src/usr.bin/make/unit-tests

2020-05-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 10 13:03:40 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: dollar.exp dollar.mk

Log Message:
usr.bin/make: fix typo in dollar test


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/dollar.exp \
src/usr.bin/make/unit-tests/dollar.mk

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/make/unit-tests/dollar.exp
diff -u src/usr.bin/make/unit-tests/dollar.exp:1.1 src/usr.bin/make/unit-tests/dollar.exp:1.2
--- src/usr.bin/make/unit-tests/dollar.exp:1.1	Sun May 10 12:34:01 2020
+++ src/usr.bin/make/unit-tests/dollar.exp	Sun May 10 13:03:40 2020
@@ -15,8 +15,8 @@ This works as expected.
   4 dollar variable => <$$>
 Some hungry part of make eats all the dollars after a :U modifier.
1 dollar var-default => <>
-   2 dollar var-default => <>
-   4 dollar var-default => <>
+   2 dollar var-default => <$>
+   4 dollar var-default => <$$>
 
 Dollar in :S pattern
 
Index: src/usr.bin/make/unit-tests/dollar.mk
diff -u src/usr.bin/make/unit-tests/dollar.mk:1.1 src/usr.bin/make/unit-tests/dollar.mk:1.2
--- src/usr.bin/make/unit-tests/dollar.mk:1.1	Sun May 10 12:34:01 2020
+++ src/usr.bin/make/unit-tests/dollar.mk	Sun May 10 13:03:40 2020
@@ -1,4 +1,4 @@
-# $NetBSD: dollar.mk,v 1.1 2020/05/10 12:34:01 rillig Exp $
+# $NetBSD: dollar.mk,v 1.2 2020/05/10 13:03:40 rillig Exp $
 #
 # Test the various places where a dollar character can appear and
 # see what happens.  There are lots of surprises here.
@@ -38,9 +38,9 @@ all:
 	$T	'4 dollar variable'	''${DOLLAR4:Q}
 
 	$C 'Some hungry part of make eats all the dollars after a :U modifier.'
-	$T	'1 dollar var-default'	''${U:${DOLLAR1}:Q}
-	$T	'2 dollar var-default'	''${U:${DOLLAR2}:Q}
-	$T	'4 dollar var-default'	''${U:${DOLLAR4}:Q}
+	$T	'1 dollar var-default'	''${:U${DOLLAR1}:Q}
+	$T	'2 dollar var-default'	''${:U${DOLLAR2}:Q}
+	$T	'4 dollar var-default'	''${:U${DOLLAR4}:Q}
 
 	$H 'Dollar in :S pattern'
 



CVS commit: src/usr.bin/make/unit-tests

2020-05-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 10 13:03:40 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: dollar.exp dollar.mk

Log Message:
usr.bin/make: fix typo in dollar test


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/dollar.exp \
src/usr.bin/make/unit-tests/dollar.mk

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



CVS commit: src/usr.bin/make/unit-tests

2020-05-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 10 12:42:11 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
usr.bin/make: sort test cases alphabetically


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/make/unit-tests/Makefile

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/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.56 src/usr.bin/make/unit-tests/Makefile:1.57
--- src/usr.bin/make/unit-tests/Makefile:1.56	Sun May 10 12:34:01 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun May 10 12:42:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.56 2020/05/10 12:34:01 rillig Exp $
+# $NetBSD: Makefile,v 1.57 2020/05/10 12:42:11 rillig Exp $
 #
 # Unit tests for make(1)
 # The main targets are:
@@ -26,12 +26,12 @@ TESTNAMES= \
 	cond1 \
 	cond2 \
 	dollar \
+	doterror \
+	dotwait \
 	error \
 	export \
 	export-all \
 	export-env \
-	doterror \
-	dotwait \
 	forloop \
 	forsubst \
 	hash \



CVS commit: src/usr.bin/make/unit-tests

2020-05-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 10 12:42:11 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
usr.bin/make: sort test cases alphabetically


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/make/unit-tests/Makefile

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



CVS commit: src

2020-05-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 10 12:34:01 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: dollar.exp dollar.mk

Log Message:
usr.bin/make: add tests for surprising dollar removal


To generate a diff of this commit:
cvs rdiff -u -r1.839 -r1.840 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/dollar.exp \
src/usr.bin/make/unit-tests/dollar.mk

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



CVS commit: src

2020-05-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 10 12:34:01 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: dollar.exp dollar.mk

Log Message:
usr.bin/make: add tests for surprising dollar removal


To generate a diff of this commit:
cvs rdiff -u -r1.839 -r1.840 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/dollar.exp \
src/usr.bin/make/unit-tests/dollar.mk

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/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.839 src/distrib/sets/lists/tests/mi:1.840
--- src/distrib/sets/lists/tests/mi:1.839	Thu Apr 30 11:03:29 2020
+++ src/distrib/sets/lists/tests/mi	Sun May 10 12:34:01 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.839 2020/04/30 11:03:29 ryo Exp $
+# $NetBSD: mi,v 1.840 2020/05/10 12:34:01 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4469,6 +4469,8 @@
 ./usr/tests/usr.bin/make/unit-tests/cond1.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond2.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cond2.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dollar.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dollar.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/doterror.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/doterror.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dotwait.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.55 src/usr.bin/make/unit-tests/Makefile:1.56
--- src/usr.bin/make/unit-tests/Makefile:1.55	Wed Apr 29 23:15:21 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun May 10 12:34:01 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.55 2020/04/29 23:15:21 rillig Exp $
+# $NetBSD: Makefile,v 1.56 2020/05/10 12:34:01 rillig Exp $
 #
 # Unit tests for make(1)
 # The main targets are:
@@ -25,6 +25,7 @@ TESTNAMES= \
 	cond-late \
 	cond1 \
 	cond2 \
+	dollar \
 	error \
 	export \
 	export-all \

Added files:

Index: src/usr.bin/make/unit-tests/dollar.exp
diff -u /dev/null src/usr.bin/make/unit-tests/dollar.exp:1.1
--- /dev/null	Sun May 10 12:34:01 2020
+++ src/usr.bin/make/unit-tests/dollar.exp	Sun May 10 12:34:01 2020
@@ -0,0 +1,50 @@
+
+Printing dollar from literals and variables
+
+To survive the parser, a dollar character must be doubled.
+   1 dollar literal => <\>
+   2 dollar literal => <$>
+   4 dollar literal => <$$>
+Some hungry part of make eats all the dollars after a :U modifier.
+   1 dollar default => <>
+   2 dollar default => <>
+   4 dollar default => <>
+This works as expected.
+  1 dollar variable => <>
+  2 dollar variable => <$>
+  4 dollar variable => <$$>
+Some hungry part of make eats all the dollars after a :U modifier.
+   1 dollar var-default => <>
+   2 dollar var-default => <>
+   4 dollar var-default => <>
+
+Dollar in :S pattern
+
+  S,$,word, => <$XYword>
+ S,$X,word, => <$XY>
+S,$$X,word, => <$XY>
+   S,$$$X,word, => <$XY>
+ S,$X,replaced, => 
+S,$$X,replaced, => 
+   S,$$$X,replaced, => 
+
+Dollar in :C character class
+
+The A is replaced because the $$ is reduced to a single $,
+which is then resolved to the variable X with the value VAR_X.
+The effective character class becomes [VAR_XY].
+  C,[$XY],<&>,g => <$>
+
+Dollar in :C pattern
+
+For some reason, multiple dollars are folded into one.
+  C,$,word, => <>
+ C,$$,word, => <>
+
+Dollar in :S replacement
+
+For some reason, multiple dollars are folded into one.
+   S,word,a$Xo, => 
+  S,word,a$$Xo, => 
+ S,word,a$$$Xo, => 
+exit status 0
Index: src/usr.bin/make/unit-tests/dollar.mk
diff -u /dev/null src/usr.bin/make/unit-tests/dollar.mk:1.1
--- /dev/null	Sun May 10 12:34:01 2020
+++ src/usr.bin/make/unit-tests/dollar.mk	Sun May 10 12:34:01 2020
@@ -0,0 +1,72 @@
+# $NetBSD: dollar.mk,v 1.1 2020/05/10 12:34:01 rillig Exp $
+#
+# Test the various places where a dollar character can appear and
+# see what happens.  There are lots of surprises here.
+#
+
+LIST=		plain 'single' "double" 'mix'"ed" back\ slashed
+WORD=		word
+
+DOLLAR1=	$
+DOLLAR2=	$$
+DOLLAR4=	
+
+X=		VAR_X
+DOLLAR_XY=	$$XY
+DOLLAR_AXY=	$$AXY
+
+H=	@header()	{ printf '\n%s\n\n' "$$*"; }; header
+T=	@testcase()	{ printf '%23s => <%s>\n' "$$@"; }; testcase
+C=	@comment()	{ printf '%s\n' "$$*"; }; comment
+
+all:
+	$H 'Printing dollar from literals and 

CVS commit: src/distrib/sets/lists/comp

2020-05-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 10 11:06:14 UTC 2020

Modified Files:
src/distrib/sets/lists/comp: ad.aarch64

Log Message:
Update for trap.h


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/distrib/sets/lists/comp/ad.aarch64

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/ad.aarch64
diff -u src/distrib/sets/lists/comp/ad.aarch64:1.39 src/distrib/sets/lists/comp/ad.aarch64:1.40
--- src/distrib/sets/lists/comp/ad.aarch64:1.39	Sun Apr 26 06:58:05 2020
+++ src/distrib/sets/lists/comp/ad.aarch64	Sun May 10 11:06:14 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ad.aarch64,v 1.39 2020/04/26 06:58:05 rin Exp $
+# $NetBSD: ad.aarch64,v 1.40 2020/05/10 11:06:14 skrll Exp $
 ./usr/include/aarch64comp-c-include
 ./usr/include/aarch64/ansi.h			comp-c-include
 ./usr/include/aarch64/aout_machdep.h		comp-c-include
@@ -44,7 +44,7 @@
 ./usr/include/aarch64/signal.h			comp-c-include
 ./usr/include/aarch64/sljit_machdep.h		comp-c-include
 ./usr/include/aarch64/sysarch.h			comp-c-include
-./usr/include/aarch64/trap.h			comp-obsolete		obsolete
+./usr/include/aarch64/trap.h			comp-c-include
 ./usr/include/aarch64/types.h			comp-c-include
 ./usr/include/aarch64/vmparam.h			comp-c-include
 ./usr/include/aarch64/wchar_limits.h		comp-c-include



CVS commit: src/distrib/sets/lists/comp

2020-05-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 10 11:06:14 UTC 2020

Modified Files:
src/distrib/sets/lists/comp: ad.aarch64

Log Message:
Update for trap.h


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/distrib/sets/lists/comp/ad.aarch64

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



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

2020-05-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 10 11:04:09 UTC 2020

Modified Files:
src/sys/arch/aarch64/include: Makefile
Added Files:
src/sys/arch/aarch64/include: trap.h

Log Message:
Provide a trap.h (currently empty)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/include/Makefile
cvs rdiff -u -r0 -r1.3 src/sys/arch/aarch64/include/trap.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/aarch64/include/Makefile
diff -u src/sys/arch/aarch64/include/Makefile:1.3 src/sys/arch/aarch64/include/Makefile:1.4
--- src/sys/arch/aarch64/include/Makefile:1.3	Sun Dec  9 15:08:05 2018
+++ src/sys/arch/aarch64/include/Makefile	Sun May 10 11:04:09 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2018/12/09 15:08:05 alnsn Exp $
+# $NetBSD: Makefile,v 1.4 2020/05/10 11:04:09 skrll Exp $
 
 INCSDIR= /usr/include/aarch64
 
@@ -17,7 +17,7 @@ INCS=	ansi.h aout_machdep.h armreg.h asm
 	proc.h profile.h pte.h ptrace.h \
 	reg.h rwlock.h \
 	setjmp.h signal.h sljit_machdep.h sysarch.h \
-	types.h \
+	trap.h types.h \
 	vmparam.h \
 	wchar_limits.h
 

Added files:

Index: src/sys/arch/aarch64/include/trap.h
diff -u /dev/null src/sys/arch/aarch64/include/trap.h:1.3
--- /dev/null	Sun May 10 11:04:09 2020
+++ src/sys/arch/aarch64/include/trap.h	Sun May 10 11:04:09 2020
@@ -0,0 +1,3 @@
+/*	$NetBSD: trap.h,v 1.3 2020/05/10 11:04:09 skrll Exp $	*/
+
+/* This file is intentionally empty */



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

2020-05-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 10 11:04:09 UTC 2020

Modified Files:
src/sys/arch/aarch64/include: Makefile
Added Files:
src/sys/arch/aarch64/include: trap.h

Log Message:
Provide a trap.h (currently empty)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/include/Makefile
cvs rdiff -u -r0 -r1.3 src/sys/arch/aarch64/include/trap.h

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



CVS commit: src/libexec/ld.elf_so/arch/hppa

2020-05-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 10 06:42:38 UTC 2020

Modified Files:
src/libexec/ld.elf_so/arch/hppa: hppa_reloc.c rtld_start.S

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c
cvs rdiff -u -r1.12 -r1.13 src/libexec/ld.elf_so/arch/hppa/rtld_start.S

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

Modified files:

Index: src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c
diff -u src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c:1.45 src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c:1.46
--- src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c:1.45	Thu Aug 10 19:03:26 2017
+++ src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c	Sun May 10 06:42:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hppa_reloc.c,v 1.45 2017/08/10 19:03:26 joerg Exp $	*/
+/*	$NetBSD: hppa_reloc.c,v 1.46 2020/05/10 06:42:38 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: hppa_reloc.c,v 1.45 2017/08/10 19:03:26 joerg Exp $");
+__RCSID("$NetBSD: hppa_reloc.c,v 1.46 2020/05/10 06:42:38 skrll Exp $");
 #endif /* not lint */
 
 #include 
@@ -89,10 +89,10 @@ fdc(void *addr)
 }
 
 static __inline void
-fic(void *addr) 
-{   
+fic(void *addr)
+{
 	__asm volatile("fic %%r0(%%sr0,%0)" : : "r" (addr));
-} 
+}
 
 static __inline void
 sync(void)
@@ -128,7 +128,7 @@ typedef struct _hppa_plabel {
 } hppa_plabel;
 
 /*
- * For now allocated PLABEL structures are tracked on a 
+ * For now allocated PLABEL structures are tracked on a
  * singly linked list.  This maybe should be revisited.
  */
 static SLIST_HEAD(hppa_plabel_head, _hppa_plabel) hppa_plabel_list
@@ -151,13 +151,13 @@ static inline int _rtld_relocate_plt_obj
  * This bootstraps the dynamic linker by relocating its GOT.
  * On the hppa, unlike on other architectures, static strings
  * are found through the GOT.  Static strings are essential
- * for RTLD_DEBUG, and I suspect they're used early even when 
+ * for RTLD_DEBUG, and I suspect they're used early even when
  * !defined(RTLD_DEBUG), making relocating the GOT essential.
  *
  * It gets worse.  Relocating the GOT doesn't mean just walking
  * it and adding the relocbase to all of the entries.  You must
- * find and use the GOT relocations, since those RELA relocations 
- * have the necessary addends - the GOT comes initialized as 
+ * find and use the GOT relocations, since those RELA relocations
+ * have the necessary addends - the GOT comes initialized as
  * zeroes.
  */
 void
@@ -176,7 +176,7 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
 
 	/*
 	 * Process the DYNAMIC section, looking for the non-PLT relocations.
-	 */ 
+	 */
 	relafirst = NULL;
 	relasz = 0;
 	symtab = NULL;
@@ -213,11 +213,11 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
 		switch (ELF_R_TYPE(rela->r_info)) {
 		case R_TYPE(DIR32):
 			if (symnum == 0)
-store_ptr(where, 
+store_ptr(where,
 relocbase + rela->r_addend);
 			else {
 sym = symtab + symnum;
-store_ptr(where, 
+store_ptr(where,
 relocbase + rela->r_addend + sym->st_value);
 			}
 			break;
@@ -235,7 +235,7 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
 			 * relocations have been done.
 			 */
 			if (symnum == 0)
-*((Elf_Addr *)where) = 
+*((Elf_Addr *)where) =
 relocbase + rela->r_addend;
 			else
 plabel_relocs[nplabel_relocs++] = rela;
@@ -251,7 +251,7 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
 		rela = plabel_relocs[i];
 		where = (void *)(relocbase + rela->r_offset);
 		sym = symtab + ELF_R_SYM(rela->r_info);
-		
+
 		plabel = _plabel_pre[hppa_plabel_pre_next++];
 
 		plabel->hppa_plabel_pc = (Elf_Addr)
@@ -261,7 +261,7 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
 		SLIST_INSERT_HEAD(_plabel_list, plabel, hppa_plabel_next);
 		*((Elf_Addr *)where) = (Elf_Addr)(RTLD_MAKE_PLABEL(plabel));
 	}
-	
+
 #if defined(RTLD_DEBUG_HPPA)
 	for (rela = relafirst; rela < relalim; rela++) {
 		where = (void *)(relocbase + rela->r_offset);
@@ -304,9 +304,9 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
 }
 
 /*
- * This allocates a PLABEL.  If called with a non-NULL def, the 
+ * This allocates a PLABEL.  If called with a non-NULL def, the
  * plabel is for the function associated with that definition
- * in the defining object defobj, plus the given addend.  If 
+ * in the defining object defobj, plus the given addend.  If
  * called with a NULL def, the plabel is for the function at
  * the (unrelocated) address in addend in the object defobj.
  */
@@ -318,7 +318,7 @@ _rtld_function_descriptor_alloc(const Ob
 	hppa_plabel	*plabel;
 
 	if (def != NULL) {
-	
+
 		/*
 		 * We assume that symbols of type STT_NOTYPE
 		 * are undefined.  Return NULL for these.
@@ -329,7 +329,7 @@ _rtld_function_descriptor_alloc(const Ob
 		/* Otherwise assert that this symbol must be a function. */
 		

CVS commit: src/libexec/ld.elf_so/arch/hppa

2020-05-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 10 06:42:38 UTC 2020

Modified Files:
src/libexec/ld.elf_so/arch/hppa: hppa_reloc.c rtld_start.S

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c
cvs rdiff -u -r1.12 -r1.13 src/libexec/ld.elf_so/arch/hppa/rtld_start.S

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



CVS commit: src

2020-05-10 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun May 10 06:38:24 UTC 2020

Modified Files:
src/doc: HACKS
src/share/mk: bsd.lib.mk

Log Message:
Pass -Wno-unused-command-line-argument for LLVM, discussed on
tech-toolchain@.


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/doc/HACKS
cvs rdiff -u -r1.380 -r1.381 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.



CVS commit: src

2020-05-10 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun May 10 06:38:24 UTC 2020

Modified Files:
src/doc: HACKS
src/share/mk: bsd.lib.mk

Log Message:
Pass -Wno-unused-command-line-argument for LLVM, discussed on
tech-toolchain@.


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/doc/HACKS
cvs rdiff -u -r1.380 -r1.381 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/doc/HACKS
diff -u src/doc/HACKS:1.206 src/doc/HACKS:1.207
--- src/doc/HACKS:1.206	Wed May  6 14:33:52 2020
+++ src/doc/HACKS	Sun May 10 06:38:24 2020
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.206 2020/05/06 14:33:52 snj Exp $
+# $NetBSD: HACKS,v 1.207 2020/05/10 06:38:24 maxv Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -27,6 +27,16 @@
 #
 # this is a comment.
 
+hack	llvm needs no-unused-command-line-argument
+mdate	10 May 2020
+who	maxv
+file	share/mk/bsd.lib.mk 1.380 -> 1.381
+descr
+	To avoid LLVM warnings when compiling the kernel with special
+	CFLAGS such as KASAN on amd64 or ARMV83_PAC on aarch64, pass
+	-Wno-unused-command-line-argument.
+kcah
+
 hack	static linking with libpthread
 mdate	7 May 2019
 who	maya

Index: src/share/mk/bsd.lib.mk
diff -u src/share/mk/bsd.lib.mk:1.380 src/share/mk/bsd.lib.mk:1.381
--- src/share/mk/bsd.lib.mk:1.380	Tue Aug 27 22:48:54 2019
+++ src/share/mk/bsd.lib.mk	Sun May 10 06:38:24 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.lib.mk,v 1.380 2019/08/27 22:48:54 kamil Exp $
+#	$NetBSD: bsd.lib.mk,v 1.381 2020/05/10 06:38:24 maxv Exp $
 #	@(#)bsd.lib.mk	8.3 (Berkeley) 4/22/94
 
 .include 
@@ -568,7 +568,7 @@ __archivesymlinkpic: .USE
 __buildstdlib: .USE
 	@echo building standard ${.TARGET:T:S/.o//:S/lib//} library
 	@rm -f ${.TARGET}
-	@${LINK.c:S/-nostdinc//} -nostdlib ${LDFLAGS} -r -o ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
+	@${LINK.c:S/-nostdinc//} -nostdlib ${LDFLAGS} -Wno-unused-command-line-argument -r -o ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
 .endif
 
 .if !target(__buildproflib)



CVS commit: src/sys/arch

2020-05-10 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun May 10 06:30:57 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/x86/include: cpu_rng.h
src/sys/arch/x86/x86: cpu_rng.c

Log Message:
Reintroduce cpu_rng_early_sample(), but this time with embedded detection
for RDRAND/RDSEED, because TSC is not very strong.


To generate a diff of this commit:
cvs rdiff -u -r1.354 -r1.355 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/include/cpu_rng.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/x86/cpu_rng.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/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.354 src/sys/arch/amd64/amd64/machdep.c:1.355
--- src/sys/arch/amd64/amd64/machdep.c:1.354	Fri May  8 00:52:29 2020
+++ src/sys/arch/amd64/amd64/machdep.c	Sun May 10 06:30:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.354 2020/05/08 00:52:29 riastradh Exp $	*/
+/*	$NetBSD: machdep.c,v 1.355 2020/05/10 06:30:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.354 2020/05/08 00:52:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.355 2020/05/10 06:30:57 maxv Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -1585,8 +1585,6 @@ init_slotspace(void)
 {
 	/*
 	 * XXX Too early to use cprng(9), or even entropy_extract.
-	 * Also too early to use rdrand/rdseed, since we haven't probed
-	 * cpu features yet.  This is a hack -- fix me!
 	 */
 	struct entpool pool;
 	size_t randhole;
@@ -1595,7 +1593,7 @@ init_slotspace(void)
 	vaddr_t va;
 
 	memset(, 0, sizeof pool);
-	sample = rdtsc();
+	cpu_rng_early_sample();
 	entpool_enter(, , sizeof sample);
 
 	memset(, 0, sizeof(slotspace));
@@ -1651,7 +1649,7 @@ init_slotspace(void)
 	slotspace.area[SLAREA_KERN].active = true;
 
 	/* Main. */
-	sample = rdtsc();
+	cpu_rng_early_sample();
 	entpool_enter(, , sizeof sample);
 	entpool_extract(, , sizeof randhole);
 	entpool_extract(, , sizeof randva);
@@ -1662,7 +1660,7 @@ init_slotspace(void)
 
 #ifndef XENPV
 	/* PTE. */
-	sample = rdtsc();
+	cpu_rng_early_sample();
 	entpool_enter(, , sizeof sample);
 	entpool_extract(, , sizeof randhole);
 	entpool_extract(, , sizeof randva);

Index: src/sys/arch/x86/include/cpu_rng.h
diff -u src/sys/arch/x86/include/cpu_rng.h:1.3 src/sys/arch/x86/include/cpu_rng.h:1.4
--- src/sys/arch/x86/include/cpu_rng.h:1.3	Thu Apr 30 03:29:19 2020
+++ src/sys/arch/x86/include/cpu_rng.h	Sun May 10 06:30:57 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_rng.h,v 1.3 2020/04/30 03:29:19 riastradh Exp $ */
+/* $NetBSD: cpu_rng.h,v 1.4 2020/05/10 06:30:57 maxv Exp $ */
 
 #ifndef _X86_CPU_RNG_H_
 #define _X86_CPU_RNG_H_
@@ -33,5 +33,6 @@
  */
 
 void cpu_rng_init(void);
+void cpu_rng_early_sample(uint64_t *);
 
 #endif /* _X86_CPU_RNG_H_ */

Index: src/sys/arch/x86/x86/cpu_rng.c
diff -u src/sys/arch/x86/x86/cpu_rng.c:1.13 src/sys/arch/x86/x86/cpu_rng.c:1.14
--- src/sys/arch/x86/x86/cpu_rng.c:1.13	Thu Apr 30 03:40:53 2020
+++ src/sys/arch/x86/x86/cpu_rng.c	Sun May 10 06:30:57 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_rng.c,v 1.13 2020/04/30 03:40:53 riastradh Exp $ */
+/* $NetBSD: cpu_rng.c,v 1.14 2020/05/10 06:30:57 maxv Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -283,3 +283,37 @@ cpu_rng_init(void)
 	rnd_attach_source(_rng_source, cpu_rng_name[cpu_rng_mode],
 	RND_TYPE_RNG, RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
 }
+
+/* -- */
+
+void
+cpu_rng_early_sample(uint64_t *sample)
+{
+	static bool has_rdseed = false;
+	static bool has_rdrand = false;
+	static bool inited = false;
+	u_int descs[4];
+	size_t n;
+
+	if (!inited) {
+		if (cpuid_level >= 7) {
+			x86_cpuid(0x07, descs);
+			has_rdseed = (descs[1] & CPUID_SEF_RDSEED) != 0;
+		}
+		if (cpuid_level >= 1) {
+			x86_cpuid(0x01, descs);
+			has_rdrand = (descs[2] & CPUID2_RDRAND) != 0;
+		}
+		inited = true;
+	}
+
+	n = 0;
+	if (has_rdseed && has_rdrand)
+		n = cpu_rng_rdseed_rdrand(sample);
+	else if (has_rdseed)
+		n = cpu_rng_rdseed(sample);
+	else if (has_rdrand)
+		n = cpu_rng_rdrand(sample);
+	if (n == 0)
+		*sample = rdtsc();
+}



CVS commit: src/sys/arch

2020-05-10 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun May 10 06:30:57 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/x86/include: cpu_rng.h
src/sys/arch/x86/x86: cpu_rng.c

Log Message:
Reintroduce cpu_rng_early_sample(), but this time with embedded detection
for RDRAND/RDSEED, because TSC is not very strong.


To generate a diff of this commit:
cvs rdiff -u -r1.354 -r1.355 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/include/cpu_rng.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/x86/cpu_rng.c

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



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

2020-05-10 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun May 10 06:24:16 UTC 2020

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

Log Message:
Respect the convention for the hypervisor information: return the highest
hypervisor leaf in 0x4000.EAX.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
cvs rdiff -u -r1.56 -r1.57 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.60 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.61
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.60	Sat May  9 16:18:57 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c	Sun May 10 06:24:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_svm.c,v 1.60 2020/05/09 16:18:57 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_svm.c,v 1.61 2020/05/10 06:24:16 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.60 2020/05/09 16:18:57 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.61 2020/05/10 06:24:16 maxv Exp $");
 
 #include 
 #include 
@@ -771,6 +771,8 @@ svm_inkernel_advance(struct vmcb *vmcb)
 	vmcb->ctrl.intr &= ~VMCB_CTRL_INTR_SHADOW;
 }
 
+#define SVM_CPUID_MAX_HYPERVISOR	0x4000
+
 static void
 svm_inkernel_handle_cpuid(struct nvmm_cpu *vcpu, uint64_t eax, uint64_t ecx)
 {
@@ -856,6 +858,7 @@ svm_inkernel_handle_cpuid(struct nvmm_cp
 		break;
 
 	case 0x4000: /* Hypervisor Information */
+		cpudata->vmcb->state.rax = SVM_CPUID_MAX_HYPERVISOR;
 		cpudata->gprs[NVMM_X64_GPR_RBX] = 0;
 		cpudata->gprs[NVMM_X64_GPR_RCX] = 0;
 		cpudata->gprs[NVMM_X64_GPR_RDX] = 0;

Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.56 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.57
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.56	Sat May  9 16:18:57 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Sun May 10 06:24:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.56 2020/05/09 16:18:57 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.57 2020/05/10 06:24:16 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.56 2020/05/09 16:18:57 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.57 2020/05/10 06:24:16 maxv Exp $");
 
 #include 
 #include 
@@ -1137,6 +1137,8 @@ error:
 	vmx_exit_invalid(exit, VMCS_EXITCODE_EXC_NMI);
 }
 
+#define VMX_CPUID_MAX_HYPERVISOR	0x4000
+
 static void
 vmx_inkernel_handle_cpuid(struct nvmm_machine *mach, struct nvmm_cpu *vcpu,
 uint64_t eax, uint64_t ecx)
@@ -1293,6 +1295,7 @@ vmx_inkernel_handle_cpuid(struct nvmm_ma
 		break;
 
 	case 0x4000: /* Hypervisor Information */
+		cpudata->gprs[NVMM_X64_GPR_RAX] = VMX_CPUID_MAX_HYPERVISOR;
 		cpudata->gprs[NVMM_X64_GPR_RBX] = 0;
 		cpudata->gprs[NVMM_X64_GPR_RCX] = 0;
 		cpudata->gprs[NVMM_X64_GPR_RDX] = 0;



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

2020-05-10 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun May 10 06:24:16 UTC 2020

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

Log Message:
Respect the convention for the hypervisor information: return the highest
hypervisor leaf in 0x4000.EAX.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
cvs rdiff -u -r1.56 -r1.57 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.