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

2020-05-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri May 15 05:39:15 UTC 2020

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

Log Message:
Use __diagused


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/aarch64/aarch64/pmap.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/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.74 src/sys/arch/aarch64/aarch64/pmap.c:1.75
--- src/sys/arch/aarch64/aarch64/pmap.c:1.74	Fri May 15 01:43:47 2020
+++ src/sys/arch/aarch64/aarch64/pmap.c	Fri May 15 05:39:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.74 2020/05/15 01:43:47 tnn Exp $	*/
+/*	$NetBSD: pmap.c,v 1.75 2020/05/15 05:39:15 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.74 2020/05/15 01:43:47 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.75 2020/05/15 05:39:15 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -622,9 +622,7 @@ pmap_free_pdp(struct pmap *pm, struct vm
 	pg->flags |= PG_BUSY;
 	pg->wire_count = 0;
 
-#ifdef DIAGNOSTIC
-	struct pmap_page *pp = VM_PAGE_TO_PP(pg);
-#endif
+	struct pmap_page *pp __diagused = VM_PAGE_TO_PP(pg);
 	KASSERT(LIST_EMPTY(>pp_pvhead));
 
 	uvm_pagefree(pg);



CVS commit: src/sys/arch/aarch64

2020-05-14 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri May 15 04:55:40 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc.c genassym.cf locore.S
src/sys/arch/aarch64/include: cpufunc.h

Log Message:
SCTLR_EnIA should be enabled in the caller(locore).

For some reason, gcc make aarch64_pac_init() function non-leaf, and it uses 
paciasp/autiasp.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/aarch64/aarch64/cpufunc.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/aarch64/include/cpufunc.h

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpufunc.c
diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.17 src/sys/arch/aarch64/aarch64/cpufunc.c:1.18
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.17	Sun Apr 12 07:49:58 2020
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Fri May 15 04:55:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.17 2020/04/12 07:49:58 maxv Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.18 2020/05/15 04:55:40 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -30,7 +30,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.17 2020/04/12 07:49:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.18 2020/05/15 04:55:40 ryo Exp $");
 
 #include 
 #include 
@@ -443,14 +443,15 @@ set_cpufuncs(void)
 }
 
 /*
- * TODO: this function should have a "no-pac" attribute. Right now it
- * doesn't use PAC so that's fine.
+ * In order to avoid inconsistencies with pointer authentication
+ * in this function itself, the caller must enable PAC according
+ * to the return value.
  */
-void
+int
 aarch64_pac_init(int primary)
 {
 #ifdef ARMV83_PAC
-	uint64_t reg, sctlr;
+	uint64_t reg;
 
 	/* CPU0 does the detection. */
 	if (primary) {
@@ -470,15 +471,14 @@ aarch64_pac_init(int primary)
 	}
 
 	if (!aarch64_pac_enabled)
-		return;
-
-	/* Enable PAC on the CPU. */
-	sctlr = reg_sctlr_el1_read();
-	sctlr |= SCTLR_EnIA;
-	reg_sctlr_el1_write(sctlr);
+		return -1;
 
 	/* Set the key. Curlwp here is the CPU's idlelwp. */
 	reg_APIAKeyLo_EL1_write(curlwp->l_md.md_ia_kern_lo);
 	reg_APIAKeyHi_EL1_write(curlwp->l_md.md_ia_kern_hi);
+
+	return 0;
+#else
+	return -1;
 #endif
 }

Index: src/sys/arch/aarch64/aarch64/genassym.cf
diff -u src/sys/arch/aarch64/aarch64/genassym.cf:1.23 src/sys/arch/aarch64/aarch64/genassym.cf:1.24
--- src/sys/arch/aarch64/aarch64/genassym.cf:1.23	Sun Apr 12 07:49:58 2020
+++ src/sys/arch/aarch64/aarch64/genassym.cf	Fri May 15 04:55:40 2020
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.23 2020/04/12 07:49:58 maxv Exp $
+# $NetBSD: genassym.cf,v 1.24 2020/05/15 04:55:40 ryo Exp $
 #-
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -363,6 +363,7 @@ define	SCTLR_EE		SCTLR_EE
 define	SCTLR_UCI		SCTLR_UCI
 define	SCTLR_nTLSMD		SCTLR_nTLSMD
 define	SCTLR_LSMAOE		SCTLR_LSMAOE
+define	SCTLR_EnIA		SCTLR_EnIA
 
 define	ICC_SRE_EL2_EN		ICC_SRE_EL2_EN
 define	ICC_SRE_EL2_SRE		ICC_SRE_EL2_SRE

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.59 src/sys/arch/aarch64/aarch64/locore.S:1.60
--- src/sys/arch/aarch64/aarch64/locore.S:1.59	Sun Apr 12 07:49:58 2020
+++ src/sys/arch/aarch64/aarch64/locore.S	Fri May 15 04:55:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.59 2020/04/12 07:49:58 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.60 2020/05/15 04:55:40 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.59 2020/04/12 07:49:58 maxv Exp $")
+RCSID("$NetBSD: locore.S,v 1.60 2020/05/15 04:55:40 ryo Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
 #define	MAIR_DEVICE_MEM		MAIR_DEVICE_nGnRnE
@@ -181,6 +181,11 @@ vstart:
 	/* init PAC if supported */
 	mov	x0, #1
 	bl	aarch64_pac_init
+	cbnz	w0, 1f			/* if (aarch64_pac_init() == 0) */
+	mrs	x0, sctlr_el1
+	orr	x0, x0, #SCTLR_EnIA	/*  enable PAC */
+	msr	sctlr_el1, x0
+1:
 
 	/* set topology information */
 	mrs	x0, tpidr_el1		/* curcpu */
@@ -509,6 +514,11 @@ mp_vstart:
 	/* init PAC if supported */
 	mov	x0, #0
 	bl	aarch64_pac_init
+	cbnz	w0, 1f			/* if (aarch64_pac_init() == 0) */
+	mrs	x0, sctlr_el1
+	orr	x0, x0, #SCTLR_EnIA	/*  enable PAC */
+	msr	sctlr_el1, x0
+1:
 
 	mov	fp, xzr			/* trace back starts here */
 	mrs	x0, tpidr_el1		/* curcpu() */

Index: src/sys/arch/aarch64/include/cpufunc.h
diff -u src/sys/arch/aarch64/include/cpufunc.h:1.13 src/sys/arch/aarch64/include/cpufunc.h:1.14
--- src/sys/arch/aarch64/include/cpufunc.h:1.13	Wed May 13 06:08:51 2020
+++ src/sys/arch/aarch64/include/cpufunc.h	Fri May 15 04:55:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.13 2020/05/13 06:08:51 ryo Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.14 2020/05/15 04:55:40 ryo Exp $	*/
 
 /*

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

2020-05-14 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri May 15 01:43:47 UTC 2020

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

Log Message:
fix non-diag build


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/aarch64/aarch64/pmap.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/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.73 src/sys/arch/aarch64/aarch64/pmap.c:1.74
--- src/sys/arch/aarch64/aarch64/pmap.c:1.73	Thu May 14 07:59:03 2020
+++ src/sys/arch/aarch64/aarch64/pmap.c	Fri May 15 01:43:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.73 2020/05/14 07:59:03 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.74 2020/05/15 01:43:47 tnn Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.73 2020/05/14 07:59:03 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.74 2020/05/15 01:43:47 tnn Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -622,7 +622,9 @@ pmap_free_pdp(struct pmap *pm, struct vm
 	pg->flags |= PG_BUSY;
 	pg->wire_count = 0;
 
+#ifdef DIAGNOSTIC
 	struct pmap_page *pp = VM_PAGE_TO_PP(pg);
+#endif
 	KASSERT(LIST_EMPTY(>pp_pvhead));
 
 	uvm_pagefree(pg);



CVS commit: src/sys/rump/librump/rumpvfs

2020-05-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri May 15 00:04:02 UTC 2020

Modified Files:
src/sys/rump/librump/rumpvfs: rumpfs.c

Log Message:
Undo previous, need to fix differently (fifofs is needed by other fs's and
fifo brings in rumpnet)


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/rump/librump/rumpvfs/rumpfs.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/rump/librump/rumpvfs/rumpfs.c
diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.159 src/sys/rump/librump/rumpvfs/rumpfs.c:1.160
--- src/sys/rump/librump/rumpvfs/rumpfs.c:1.159	Thu May 14 16:10:34 2020
+++ src/sys/rump/librump/rumpvfs/rumpfs.c	Thu May 14 20:04:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfs.c,v 1.159 2020/05/14 20:10:34 christos Exp $	*/
+/*	$NetBSD: rumpfs.c,v 1.160 2020/05/15 00:04:02 christos Exp $	*/
 
 /*
  * Copyright (c) 2009, 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.159 2020/05/14 20:10:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.160 2020/05/15 00:04:02 christos Exp $");
 
 #include 
 #include 
@@ -88,6 +88,15 @@ static int rump_vop_advlock(void *);
 static int rump_vop_access(void *);
 static int rump_vop_fcntl(void *);
 
+int (**fifo_vnodeop_p)(void *);
+const struct vnodeopv_entry_desc fifo_vnodeop_entries[] = {
+	{ _default_desc, vn_default_error },
+	{ _putpages_desc, genfs_null_putpages },
+	{ NULL, NULL }
+};
+const struct vnodeopv_desc fifo_vnodeop_opv_desc =
+	{ _vnodeop_p, fifo_vnodeop_entries };
+
 int (**rump_vnodeop_p)(void *);
 const struct vnodeopv_entry_desc rump_vnodeop_entries[] = {
 	{ _default_desc, vn_default_error },



CVS commit: src/usr.sbin/rtadvd

2020-05-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May 14 23:42:18 UTC 2020

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

Log Message:
If we could not lock the pid file, don't continue as we end up with multiple
rtadvd's (thanks roy@)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 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.77 src/usr.sbin/rtadvd/rtadvd.c:1.78
--- src/usr.sbin/rtadvd/rtadvd.c:1.77	Sun May 10 18:38:51 2020
+++ src/usr.sbin/rtadvd/rtadvd.c	Thu May 14 19:42:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.77 2020/05/10 22:38:51 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.78 2020/05/14 23:42:18 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -224,12 +224,11 @@ main(int argc, char *argv[])
 	if ((pid = pidfile_lock(pidfilepath)) != 0) {
 		if (pid == -1) {
 			logit(LOG_ERR, "pidfile_lock: %m");
-			/* Continue */
 		} else {
 			logit(LOG_ERR, "Another instance of `%s' is running "
 			"(pid %d); exiting.", getprogname(), pid);
-			return EXIT_FAILURE;
 		}
+		return EXIT_FAILURE;
 	}
 
 	if (prog_init && prog_init() == -1)



CVS commit: src/sys/stand/efiboot

2020-05-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu May 14 23:09:29 UTC 2020

Modified Files:
src/sys/stand/efiboot: efirng.c

Log Message:
Make efi_rng_show return early if RNG protocol is not available. While
here, use efi_rng_available() consistently, prefix all show messages with
"RNG: ", and use sizeof(foo) instead of sizeof foo.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/efirng.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/stand/efiboot/efirng.c
diff -u src/sys/stand/efiboot/efirng.c:1.1 src/sys/stand/efiboot/efirng.c:1.2
--- src/sys/stand/efiboot/efirng.c:1.1	Thu May 14 19:19:08 2020
+++ src/sys/stand/efiboot/efirng.c	Thu May 14 23:09:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: efirng.c,v 1.1 2020/05/14 19:19:08 riastradh Exp $	*/
+/*	$NetBSD: efirng.c,v 1.2 2020/05/14 23:09:29 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -79,13 +79,16 @@ void
 efi_rng_show(void)
 {
 	EFI_RNG_ALGORITHM alglist[10];
-	UINTN i, j, alglistsz = sizeof alglist;
+	UINTN i, j, alglistsz = sizeof(alglist);
 	EFI_STATUS status;
 
+	if (!efi_rng_available())
+		return;
+
 	/* Query the list of supported algorithms.  */
 	status = uefi_call_wrapper(rng->GetInfo, 3, rng, , alglist);
 	if (EFI_ERROR(status)) {
-		Print(L"efirng: GetInfo: %r\n", status);
+		Print(L"RNG: GetInfo: %r\n", status);
 		return;
 	}
 
@@ -115,7 +118,7 @@ efi_rng(void *buf, UINTN len)
 {
 	EFI_STATUS status;
 
-	if (rng == NULL)
+	if (!efi_rng_available())
 		return EIO;
 
 	status = uefi_call_wrapper(rng->GetRNG, 3, rng, ,



CVS commit: src/doc

2020-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 14 21:13:46 UTC 2020

Modified Files:
src/doc: CHANGES

Log Message:
Note some random number generation updates.

Also note swap encryption in uvm.


To generate a diff of this commit:
cvs rdiff -u -r1.2688 -r1.2689 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2688 src/doc/CHANGES:1.2689
--- src/doc/CHANGES:1.2688	Thu May 14 13:37:52 2020
+++ src/doc/CHANGES	Thu May 14 21:13:46 2020
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2688 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2689 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -85,6 +85,8 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	scheduler: Improve performance and interactivity. [ad 20191201]
 	vfs: Reduce false sharing and lock overhead during normal operation.
 		[ad 20191201]
+	evbarm: Added driver for Allwinner Crypto Engine random number
+		generator [riastradh 20191209]
 	ixl(4): Ported driver for Intel Ethernet 700 series
 		[yamaguchi 20191210]
 	acpi(4): Updated ACPICA to 20191213. [christos 20191214]
@@ -186,12 +188,19 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	tzdata updated to 2020a  [kre 20200425]
 	amd64, i386: Added support for Xen PV drivers under HVM guests.
 		[bouyer 20200425]
+	kernel: Overhauled entropy subsystem [riastradh 20200430]
 	xen: Added support for Xen PVH. [bouyer 20200502]
 	hp300: Add bitmap access ops support for EVRX framebuffer on
 		HP9000/425e. [tsutsui 20200504]
 	xennet(4): add support for feature-sg & jumbo frames [jdolecek 20200430]
 	xvif(4): add support for feature-sg & jumbo frames [jdolecek 20200503]
+	kernel: Added support for swap encryption with sysctl -w
+		vm.swap_encrypt=1 [riastradh 20200509]
 	xen: Support MSI for XenPV [jdolecek 20200504]
 	hppa: Enable modules in GENERIC by default.  [skrll 20200511]
+	aarch64: Added support for ARMv8.5-RNG RNDRRS CPU random number
+		generator instructions [riastradh 20200511]
 	xen: enable MULTIPROCESSOR for Xen dom0. [bouyer 20200513]
 	ptrace(2): Add PT_SET_SIGPASS and PT_GET_SIGPASS. [kamil 20200514]
+	evbarm: Added support for EFI RNG firwmare random number generator
+		[riastradh 20200514]



CVS commit: src/sys/rump/librump/rumpvfs

2020-05-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May 14 20:10:34 UTC 2020

Modified Files:
src/sys/rump/librump/rumpvfs: rumpfs.c

Log Message:
PR/55102: Kamil Rytarowski: Remove fifo stuff duplicated in fifo_vnops.c


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sys/rump/librump/rumpvfs/rumpfs.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/rump/librump/rumpvfs/rumpfs.c
diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.158 src/sys/rump/librump/rumpvfs/rumpfs.c:1.159
--- src/sys/rump/librump/rumpvfs/rumpfs.c:1.158	Sat Apr 25 11:42:15 2020
+++ src/sys/rump/librump/rumpvfs/rumpfs.c	Thu May 14 16:10:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpfs.c,v 1.158 2020/04/25 15:42:15 bouyer Exp $	*/
+/*	$NetBSD: rumpfs.c,v 1.159 2020/05/14 20:10:34 christos Exp $	*/
 
 /*
  * Copyright (c) 2009, 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.158 2020/04/25 15:42:15 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.159 2020/05/14 20:10:34 christos Exp $");
 
 #include 
 #include 
@@ -88,15 +88,6 @@ static int rump_vop_advlock(void *);
 static int rump_vop_access(void *);
 static int rump_vop_fcntl(void *);
 
-int (**fifo_vnodeop_p)(void *);
-const struct vnodeopv_entry_desc fifo_vnodeop_entries[] = {
-	{ _default_desc, vn_default_error },
-	{ _putpages_desc, genfs_null_putpages },
-	{ NULL, NULL }
-};
-const struct vnodeopv_desc fifo_vnodeop_opv_desc =
-	{ _vnodeop_p, fifo_vnodeop_entries };
-
 int (**rump_vnodeop_p)(void *);
 const struct vnodeopv_entry_desc rump_vnodeop_entries[] = {
 	{ _default_desc, vn_default_error },



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

2020-05-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu May 14 19:36:03 UTC 2020

Modified Files:
src/sys/arch/xen/include: intr.h

Log Message:
xen_vec_alloc() is no more


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/xen/include/intr.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/xen/include/intr.h
diff -u src/sys/arch/xen/include/intr.h:1.55 src/sys/arch/xen/include/intr.h:1.56
--- src/sys/arch/xen/include/intr.h:1.55	Sat Apr 25 15:26:17 2020
+++ src/sys/arch/xen/include/intr.h	Thu May 14 19:36:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.55 2020/04/25 15:26:17 bouyer Exp $	*/
+/*	$NetBSD: intr.h,v 1.56 2020/05/14 19:36:02 jdolecek Exp $	*/
 /*	NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp	*/
 
 /*-
@@ -71,7 +71,6 @@ int xen_intr_biglock_wrapper(void *);
 #endif
 
 #if defined(DOM0OPS) || NPCI > 0
-int xen_vec_alloc(int);
 int xen_pic_to_gsi(struct pic *, int);
 #endif /* defined(DOM0OPS) || NPCI > 0 */
 



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

2020-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 14 19:26:28 UTC 2020

Modified Files:
src/sys/arch/evbarm/fdt: fdt_machdep.c

Log Message:
Free kva for rndseed and efirng when done.

The physical pages remain forever reserved because it's not convenient
to unreserve them at the moment after we reserved them during
fdt_build_bootconifg, but it's just two pages so not that big a deal.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/evbarm/fdt/fdt_machdep.c

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

Modified files:

Index: src/sys/arch/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.70 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.71
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.70	Thu May 14 19:24:35 2020
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Thu May 14 19:26:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.70 2020/05/14 19:24:35 riastradh Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.71 2020/05/14 19:26:28 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.70 2020/05/14 19:24:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.71 2020/05/14 19:26:28 riastradh Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -396,6 +396,17 @@ fdt_map_range(uint64_t start, uint64_t e
 }
 
 static void
+fdt_unmap_range(void *ptr, uint64_t size)
+{
+	const char *start = ptr, *end = start + size;
+	const vaddr_t startva = trunc_page((vaddr_t)(uintptr_t)start);
+	const vaddr_t endva = round_page((vaddr_t)(uintptr_t)end);
+
+	pmap_kremove(startva, endva - startva);
+	pmap_update(pmap_kernel());
+}
+
+static void
 fdt_probe_initrd(uint64_t *pstart, uint64_t *pend)
 {
 	*pstart = *pend = 0;
@@ -439,6 +450,7 @@ fdt_setup_rndseed(void)
 	if (rndseed == NULL)
 		return;
 	rnd_seed(rndseed, rndseed_size);
+	fdt_unmap_range(rndseed, rndseed_size);
 }
 
 static void
@@ -466,6 +478,7 @@ fdt_setup_efirng(void)
 	RND_FLAG_DEFAULT);
 	rnd_add_data(_source, efirng, efirng_size, 0);
 	explicit_memset(efirng, 0, efirng_size);
+	fdt_unmap_range(efirng, efirng_size);
 }
 
 #ifdef EFI_RUNTIME



CVS commit: src/sys/stand/efiboot

2020-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 14 19:25:16 UTC 2020

Modified Files:
src/sys/stand/efiboot: version

Log Message:
Bump efiboot version to note EFI RNG support.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/stand/efiboot/version

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

Modified files:

Index: src/sys/stand/efiboot/version
diff -u src/sys/stand/efiboot/version:1.14 src/sys/stand/efiboot/version:1.15
--- src/sys/stand/efiboot/version:1.14	Wed Dec 18 21:46:03 2019
+++ src/sys/stand/efiboot/version	Thu May 14 19:25:16 2020
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.14 2019/12/18 21:46:03 riastradh Exp $
+$NetBSD: version,v 1.15 2020/05/14 19:25:16 riastradh Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -18,3 +18,4 @@ is taken as the current.
 1.11:	Add full UEFI memory map to /chosen node.
 1.12:	Derive ACPI model string from SMBIOS.
 1.13:	Add rndseed support.
+1.14:	Add EFI RNG support.



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

2020-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 14 19:24:35 UTC 2020

Modified Files:
src/sys/arch/evbarm/fdt: fdt_machdep.c

Log Message:
Deduplicate address-range querying/mapping logic.


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

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

Modified files:

Index: src/sys/arch/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.69 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.70
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.69	Thu May 14 19:21:06 2020
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Thu May 14 19:24:35 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.69 2020/05/14 19:21:06 riastradh Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.70 2020/05/14 19:24:35 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.69 2020/05/14 19:21:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.70 2020/05/14 19:24:35 riastradh Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -334,20 +334,20 @@ fdt_build_bootconfig(uint64_t mem_start,
 }
 
 static void
-fdt_probe_initrd(uint64_t *pstart, uint64_t *pend)
+fdt_probe_range(const char *startname, const char *endname,
+uint64_t *pstart, uint64_t *pend)
 {
+	int chosen, len;
+	const void *start_data, *end_data;
+
 	*pstart = *pend = 0;
 
-#ifdef MEMORY_DISK_DYNAMIC
-	const int chosen = OF_finddevice("/chosen");
+	chosen = OF_finddevice("/chosen");
 	if (chosen < 0)
 		return;
 
-	int len;
-	const void *start_data = fdtbus_get_prop(chosen,
-	"linux,initrd-start", );
-	const void *end_data = fdtbus_get_prop(chosen,
-	"linux,initrd-end", NULL);
+	start_data = fdtbus_get_prop(chosen, startname, );
+	end_data = fdtbus_get_prop(chosen, endname, NULL);
 	if (start_data == NULL || end_data == NULL)
 		return;
 
@@ -361,131 +361,92 @@ fdt_probe_initrd(uint64_t *pstart, uint6
 		*pend = be64dec(end_data);
 		break;
 	default:
-		printf("Unsupported len %d for /chosen/initrd-start\n", len);
+		printf("Unsupported len %d for /chosen `%s'\n",
+		len, startname);
 		return;
 	}
-#endif
 }
 
-static void
-fdt_setup_initrd(void)
+static void *
+fdt_map_range(uint64_t start, uint64_t end, uint64_t *psize,
+const char *purpose)
 {
-#ifdef MEMORY_DISK_DYNAMIC
-	const uint64_t initrd_size = initrd_end - initrd_start;
-	paddr_t startpa = trunc_page(initrd_start);
-	paddr_t endpa = round_page(initrd_end);
+	const paddr_t startpa = trunc_page(start);
+	const paddr_t endpa = round_page(end);
 	paddr_t pa;
 	vaddr_t va;
-	void *md_start;
+	void *ptr;
 
-	if (initrd_size == 0)
-		return;
+	*psize = end - start;
+	if (*psize == 0)
+		return NULL;
 
-	va = uvm_km_alloc(kernel_map, initrd_size, 0,
-	UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
+	va = uvm_km_alloc(kernel_map, *psize, 0, UVM_KMF_VAONLY|UVM_KMF_NOWAIT);
 	if (va == 0) {
-		printf("Failed to allocate VA for initrd\n");
-		return;
+		printf("Failed to allocate VA for %s\n", purpose);
+		return NULL;
 	}
-
-	md_start = (void *)va;
+	ptr = (void *)(va + (start & (PAGE_SIZE-1)));
 
 	for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE)
 		pmap_kenter_pa(va, pa, VM_PROT_READ|VM_PROT_WRITE, 0);
 	pmap_update(pmap_kernel());
 
-	md_root_setconf(md_start, initrd_size);
+	return ptr;
+}
+
+static void
+fdt_probe_initrd(uint64_t *pstart, uint64_t *pend)
+{
+	*pstart = *pend = 0;
+
+#ifdef MEMORY_DISK_DYNAMIC
+	fdt_probe_range("linux,initrd-start", "linux,initrd-end", pstart, pend);
 #endif
 }
 
 static void
-fdt_probe_rndseed(uint64_t *pstart, uint64_t *pend)
+fdt_setup_initrd(void)
 {
-	int chosen, len;
-	const void *start_data, *end_data;
+#ifdef MEMORY_DISK_DYNAMIC
+	void *md_start;
+	uint64_t initrd_size;
 
-	*pstart = *pend = 0;
-	chosen = OF_finddevice("/chosen");
-	if (chosen < 0)
+	md_start = fdt_map_range(initrd_start, initrd_end, _size,
+	"initrd");
+	if (md_start == NULL)
 		return;
+	md_root_setconf(md_start, initrd_size);
+#endif
+}
 
-	start_data = fdtbus_get_prop(chosen, "netbsd,rndseed-start", );
-	end_data = fdtbus_get_prop(chosen, "netbsd,rndseed-end", NULL);
-	if (start_data == NULL || end_data == NULL)
-		return;
+static void
+fdt_probe_rndseed(uint64_t *pstart, uint64_t *pend)
+{
 
-	switch (len) {
-	case 4:
-		*pstart = be32dec(start_data);
-		*pend = be32dec(end_data);
-		break;
-	case 8:
-		*pstart = be64dec(start_data);
-		*pend = be64dec(end_data);
-		break;
-	default:
-		printf("Unsupported len %d for /chosen/rndseed-start\n", len);
-		return;
-	}
+	fdt_probe_range("netbsd,rndseed-start", "netbsd,rndseed-end",
+	pstart, pend);
 }
 
 static void
 fdt_setup_rndseed(void)
 {
-	const uint64_t rndseed_size = rndseed_end - rndseed_start;
-	const paddr_t startpa = trunc_page(rndseed_start);
-	const paddr_t endpa = round_page(rndseed_end);
-	paddr_t pa;
-	vaddr_t 

CVS commit: src/sys/stand/efiboot

2020-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 14 19:21:53 UTC 2020

Modified Files:
src/sys/stand/efiboot: efifdt.c

Log Message:
Deduplicate lazy /chosen node creation logic.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/efifdt.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/stand/efiboot/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.22 src/sys/stand/efiboot/efifdt.c:1.23
--- src/sys/stand/efiboot/efifdt.c:1.22	Thu May 14 19:20:08 2020
+++ src/sys/stand/efiboot/efifdt.c	Thu May 14 19:21:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.22 2020/05/14 19:20:08 riastradh Exp $ */
+/* $NetBSD: efifdt.c,v 1.23 2020/05/14 19:21:53 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -185,6 +185,22 @@ efi_fdt_show(void)
 	printf("]\n");
 }
 
+static int
+efi_fdt_chosen(void)
+{
+	int chosen;
+
+	chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH);
+	if (chosen < 0)
+		chosen = fdt_add_subnode(fdt_data,
+		fdt_path_offset(fdt_data, "/"),
+		FDT_CHOSEN_NODE_NAME);
+	if (chosen < 0)
+		panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node");
+
+	return chosen;
+}
+
 void
 efi_fdt_memory_map(void)
 {
@@ -200,11 +216,7 @@ efi_fdt_memory_map(void)
 	if (memory < 0)
 		panic("FDT: Failed to create " FDT_MEMORY_NODE_PATH " node");
 
-	chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH);
-	if (chosen < 0)
-		chosen = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/"), FDT_CHOSEN_NODE_NAME);
-	if (chosen < 0)
-		panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node");
+	chosen = efi_fdt_chosen();
 
 	fdt_delprop(fdt_data, memory, "reg");
 
@@ -335,11 +347,7 @@ efi_fdt_bootargs(const char *bootargs)
 	uint8_t macaddr[6];
 	int chosen;
 
-	chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH);
-	if (chosen < 0)
-		chosen = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/"), FDT_CHOSEN_NODE_NAME);
-	if (chosen < 0)
-		panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node");
+	chosen = efi_fdt_chosen();
 
 	if (*bootargs)
 		fdt_setprop_string(fdt_data, chosen, "bootargs", bootargs);
@@ -381,12 +389,7 @@ efi_fdt_initrd(u_long initrd_addr, u_lon
 	if (initrd_size == 0)
 		return;
 
-	chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH);
-	if (chosen < 0)
-		chosen = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/"), FDT_CHOSEN_NODE_NAME);
-	if (chosen < 0)
-		panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node");
-
+	chosen = efi_fdt_chosen();
 	fdt_setprop_u64(fdt_data, chosen, "linux,initrd-start", initrd_addr);
 	fdt_setprop_u64(fdt_data, chosen, "linux,initrd-end", initrd_addr + initrd_size);
 }
@@ -400,14 +403,7 @@ efi_fdt_rndseed(u_long rndseed_addr, u_l
 	if (rndseed_size == 0)
 		return;
 
-	chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH);
-	if (chosen < 0)
-		chosen = fdt_add_subnode(fdt_data,
-		fdt_path_offset(fdt_data, "/"),
-		FDT_CHOSEN_NODE_NAME);
-	if (chosen < 0)
-		panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node");
-
+	chosen = efi_fdt_chosen();
 	fdt_setprop_u64(fdt_data, chosen, "netbsd,rndseed-start",
 	rndseed_addr);
 	fdt_setprop_u64(fdt_data, chosen, "netbsd,rndseed-end",
@@ -423,14 +419,7 @@ efi_fdt_efirng(u_long efirng_addr, u_lon
 	if (efirng_size == 0)
 		return;
 
-	chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH);
-	if (chosen < 0)
-		chosen = fdt_add_subnode(fdt_data,
-		fdt_path_offset(fdt_data, "/"),
-		FDT_CHOSEN_NODE_NAME);
-	if (chosen < 0)
-		panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node");
-
+	chosen = efi_fdt_chosen();
 	fdt_setprop_u64(fdt_data, chosen, "netbsd,efirng-start",
 	efirng_addr);
 	fdt_setprop_u64(fdt_data, chosen, "netbsd,efirng-end",



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

2020-05-14 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May 14 19:21:35 UTC 2020

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

Log Message:
Ignore interception of the SIGCHLD signals.

SIGCHLD once blocked is discarded by the kernel as it has the
SA_IGNORE property. During the fork(2) operation all signals can be
shortly blocked and missed (unless there is a registered signal
handler in the traced child). This leads to a race in this test if
there would be an intention to catch SIGCHLD.

Fixes PR lib/55241 by Andreas Gustafsson


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

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

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_fork_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.3
--- src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.2	Mon May 11 20:58:48 2020
+++ src/tests/lib/libc/sys/t_ptrace_fork_wait.h	Thu May 14 19:21:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_fork_wait.h,v 1.2 2020/05/11 20:58:48 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_fork_wait.h,v 1.3 2020/05/14 19:21:35 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2020 The NetBSD Foundation, Inc.
@@ -38,6 +38,7 @@ fork_body(const char *fn, bool trackspaw
 #if defined(TWAIT_HAVE_STATUS)
 	int status;
 #endif
+	sigset_t set;
 	ptrace_state_t state;
 	const int slen = sizeof(state);
 	ptrace_event_t event;
@@ -98,6 +99,19 @@ fork_body(const char *fn, bool trackspaw
 		event.pe_set_event |= PTRACE_VFORK_DONE;
 	SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
 
+	/*
+	 * Ignore interception of the SIGCHLD signals.
+	 *
+	 * SIGCHLD once blocked is discarded by the kernel as it has the
+	 * SA_IGNORE property. During the fork(2) operation all signals can be
+	 * shortly blocked and missed (unless there is a registered signal
+	 * handler in the traced child). This leads to a race in this test if
+	 * there would be an intention to catch SIGCHLD.
+	 */
+	sigemptyset();
+	sigaddset(, SIGCHLD);
+	SYSCALL_REQUIRE(ptrace(PT_SET_SIGPASS, child, , sizeof(set)) != -1);
+
 	DPRINTF("Before resuming the child process where it left off and "
 	"without signal to be sent\n");
 	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -207,16 +221,6 @@ fork_body(const char *fn, bool trackspaw
 	}
 #endif
 
-	DPRINTF("Before calling %s() for the child - expected stopped "
-	"SIGCHLD\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, SIGCHLD);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
 	DPRINTF("Before calling %s() for the child - expected exited\n",
 	TWAIT_FNAME);
 	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);



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

2020-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 14 19:21:06 UTC 2020

Modified Files:
src/sys/arch/evbarm/fdt: fdt_machdep.c

Log Message:
Teach arm fdt kernel to use /chosen/netbsd,efirng data.

Feed it in as a separate random source, with zero entropy since this
is a best-effort fallback for devices we really don't know anything
about.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/evbarm/fdt/fdt_machdep.c

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

Modified files:

Index: src/sys/arch/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.68 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.69
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.68	Sun Mar  8 08:26:54 2020
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Thu May 14 19:21:06 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.68 2020/03/08 08:26:54 skrll Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.69 2020/05/14 19:21:06 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.68 2020/03/08 08:26:54 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.69 2020/05/14 19:21:06 riastradh Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -65,6 +65,7 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_machdep.
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -119,7 +120,8 @@ u_long uboot_args[4] __attribute__((__se
 const uint8_t *fdt_addr_r __attribute__((__section__(".data")));
 
 static uint64_t initrd_start, initrd_end;
-static uint64_t rndseed_start, rndseed_end;
+static uint64_t rndseed_start, rndseed_end; /* our on-disk seed */
+static uint64_t efirng_start, efirng_end;   /* firmware's EFI RNG output */
 
 #include 
 #include 
@@ -313,6 +315,10 @@ fdt_build_bootconfig(uint64_t mem_start,
 	if (rndseed_size > 0)
 		fdt_memory_remove_range(rndseed_start, rndseed_size);
 
+	const uint64_t efirng_size = efirng_end - efirng_start;
+	if (efirng_size > 0)
+		fdt_memory_remove_range(efirng_start, efirng_size);
+
 	const int framebuffer = OF_finddevice("/chosen/framebuffer");
 	if (framebuffer >= 0) {
 		for (index = 0;
@@ -451,6 +457,70 @@ fdt_setup_rndseed(void)
 	rnd_seed(rndseed, rndseed_size);
 }
 
+static void
+fdt_probe_efirng(uint64_t *pstart, uint64_t *pend)
+{
+	int chosen, len;
+	const void *start_data, *end_data;
+
+	*pstart = *pend = 0;
+	chosen = OF_finddevice("/chosen");
+	if (chosen < 0)
+		return;
+
+	start_data = fdtbus_get_prop(chosen, "netbsd,efirng-start", );
+	end_data = fdtbus_get_prop(chosen, "netbsd,efirng-end", NULL);
+	if (start_data == NULL || end_data == NULL)
+		return;
+
+	switch (len) {
+	case 4:
+		*pstart = be32dec(start_data);
+		*pend = be32dec(end_data);
+		break;
+	case 8:
+		*pstart = be64dec(start_data);
+		*pend = be64dec(end_data);
+		break;
+	default:
+		printf("Unsupported len %d for /chosen/efirng-start\n", len);
+		return;
+	}
+}
+
+static struct krndsource efirng_source;
+
+static void
+fdt_setup_efirng(void)
+{
+	const uint64_t efirng_size = efirng_end - efirng_start;
+	const paddr_t startpa = trunc_page(efirng_start);
+	const paddr_t endpa = round_page(efirng_end);
+	paddr_t pa;
+	vaddr_t va;
+	void *efirng;
+
+	if (efirng_size == 0)
+		return;
+
+	va = uvm_km_alloc(kernel_map, endpa - startpa, 0,
+	UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
+	if (va == 0) {
+		printf("Failed to allocate VA for efirng\n");
+		return;
+	}
+	efirng = (void *)va;
+
+	for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE)
+		pmap_kenter_pa(va, pa, VM_PROT_READ|VM_PROT_WRITE, 0);
+	pmap_update(pmap_kernel());
+
+	rnd_attach_source(_source, "efirng", RND_TYPE_RNG,
+	RND_FLAG_DEFAULT);
+	rnd_add_data(_source, efirng, efirng_size, 0);
+	explicit_memset(efirng, 0, efirng_size);
+}
+
 #ifdef EFI_RUNTIME
 static void
 fdt_map_efi_runtime(const char *prop, enum arm_efirt_mem_type type)
@@ -579,8 +649,9 @@ initarm(void *arg)
 	/* Parse ramdisk info */
 	fdt_probe_initrd(_start, _end);
 
-	/* Parse rndseed */
+	/* Parse our on-disk rndseed and the firmware's RNG from EFI */
 	fdt_probe_rndseed(_start, _end);
+	fdt_probe_efirng(_start, _end);
 
 	/*
 	 * Populate bootconfig structure for the benefit of
@@ -699,6 +770,7 @@ cpu_startup_hook(void)
 	fdtbus_intr_init();
 
 	fdt_setup_rndseed();
+	fdt_setup_efirng();
 }
 
 void



CVS commit: src/sys/stand/efiboot

2020-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 14 19:20:08 UTC 2020

Modified Files:
src/sys/stand/efiboot: efiboot.c efifdt.c efifdt.h exec.c

Log Message:
Pass EFI RNG output via /chosen/netbsd,efirng-{start,end}.

This is separate from /chosen/netbsd,rndseed-{start,end}, which
specifies NetBSD's persistent on-disk seed; efirng is the firmware's
RNG device.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiboot.c
cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/efifdt.h
cvs rdiff -u -r1.13 -r1.14 src/sys/stand/efiboot/exec.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/stand/efiboot/efiboot.c
diff -u src/sys/stand/efiboot/efiboot.c:1.17 src/sys/stand/efiboot/efiboot.c:1.18
--- src/sys/stand/efiboot/efiboot.c:1.17	Thu Sep 26 14:28:14 2019
+++ src/sys/stand/efiboot/efiboot.c	Thu May 14 19:20:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.c,v 1.17 2019/09/26 14:28:14 jmcneill Exp $ */
+/* $NetBSD: efiboot.c,v 1.18 2020/05/14 19:20:08 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -31,6 +31,7 @@
 #include "efiblock.h"
 #include "efifdt.h"
 #include "efiacpi.h"
+#include "efirng.h"
 
 #include 
 
@@ -99,6 +100,7 @@ efi_main(EFI_HANDLE imageHandle, EFI_SYS
 	efi_net_probe();
 	efi_file_system_probe();
 	efi_block_probe();
+	efi_rng_probe();
 
 	boot();
 

Index: src/sys/stand/efiboot/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.21 src/sys/stand/efiboot/efifdt.c:1.22
--- src/sys/stand/efiboot/efifdt.c:1.21	Fri Jan  3 14:14:56 2020
+++ src/sys/stand/efiboot/efifdt.c	Thu May 14 19:20:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.21 2020/01/03 14:14:56 skrll Exp $ */
+/* $NetBSD: efifdt.c,v 1.22 2020/05/14 19:20:08 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -391,6 +391,7 @@ efi_fdt_initrd(u_long initrd_addr, u_lon
 	fdt_setprop_u64(fdt_data, chosen, "linux,initrd-end", initrd_addr + initrd_size);
 }
 
+/* pass in the NetBSD on-disk random seed */
 void
 efi_fdt_rndseed(u_long rndseed_addr, u_long rndseed_size)
 {
@@ -412,3 +413,26 @@ efi_fdt_rndseed(u_long rndseed_addr, u_l
 	fdt_setprop_u64(fdt_data, chosen, "netbsd,rndseed-end",
 	rndseed_addr + rndseed_size);
 }
+
+/* pass in output from the EFI firmware's RNG from some unknown source */
+void
+efi_fdt_efirng(u_long efirng_addr, u_long efirng_size)
+{
+	int chosen;
+
+	if (efirng_size == 0)
+		return;
+
+	chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH);
+	if (chosen < 0)
+		chosen = fdt_add_subnode(fdt_data,
+		fdt_path_offset(fdt_data, "/"),
+		FDT_CHOSEN_NODE_NAME);
+	if (chosen < 0)
+		panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node");
+
+	fdt_setprop_u64(fdt_data, chosen, "netbsd,efirng-start",
+	efirng_addr);
+	fdt_setprop_u64(fdt_data, chosen, "netbsd,efirng-end",
+	efirng_addr + efirng_size);
+}

Index: src/sys/stand/efiboot/efifdt.h
diff -u src/sys/stand/efiboot/efifdt.h:1.7 src/sys/stand/efiboot/efifdt.h:1.8
--- src/sys/stand/efiboot/efifdt.h:1.7	Wed Dec 18 21:46:03 2019
+++ src/sys/stand/efiboot/efifdt.h	Thu May 14 19:20:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.h,v 1.7 2019/12/18 21:46:03 riastradh Exp $ */
+/* $NetBSD: efifdt.h,v 1.8 2020/05/14 19:20:08 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -38,5 +38,6 @@ void efi_fdt_show(void);
 void efi_fdt_bootargs(const char *);
 void efi_fdt_initrd(u_long, u_long);
 void efi_fdt_rndseed(u_long, u_long);
+void efi_fdt_efirng(u_long, u_long);
 void efi_fdt_init(u_long, u_long);
 void efi_fdt_fini(void);

Index: src/sys/stand/efiboot/exec.c
diff -u src/sys/stand/efiboot/exec.c:1.13 src/sys/stand/efiboot/exec.c:1.14
--- src/sys/stand/efiboot/exec.c:1.13	Sat Jan 25 10:53:13 2020
+++ src/sys/stand/efiboot/exec.c	Thu May 14 19:20:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.13 2020/01/25 10:53:13 jmcneill Exp $ */
+/* $NetBSD: exec.c,v 1.14 2020/05/14 19:20:08 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -31,6 +31,7 @@
 #include "efienv.h"
 #include "efifdt.h"
 #include "efiacpi.h"
+#include "efirng.h"
 
 #include 
 
@@ -41,8 +42,8 @@ u_long load_offset = 0;
 #define	FDT_SPACE	(4 * 1024 * 1024)
 #define	FDT_ALIGN	((2 * 1024 * 1024) - 1)
 
-static EFI_PHYSICAL_ADDRESS initrd_addr, dtb_addr, rndseed_addr;
-static u_long initrd_size = 0, dtb_size = 0, rndseed_size = 0;
+static EFI_PHYSICAL_ADDRESS initrd_addr, dtb_addr, rndseed_addr, efirng_addr;
+static u_long initrd_size = 0, dtb_size = 0, rndseed_size = 0, efirng_size = 0;
 
 static int
 load_file(const char *path, u_long extra, bool quiet_errors,
@@ -273,6 +274,47 @@ load_fdt_overlays(void)
 	prop_object_iterator_release(iter);
 }
 
+static void
+generate_efirng(void)
+{
+	EFI_PHYSICAL_ADDRESS addr;
+	u_long size = EFI_PAGE_SIZE;
+	EFI_STATUS status;
+
+	/* Check whether the RNG is available 

CVS commit: src/sys/stand/efiboot

2020-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May 14 19:19:08 UTC 2020

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot boot.c efiacpi.c
Added Files:
src/sys/stand/efiboot: efirng.c efirng.h

Log Message:
Draft logic to get at EFI RNG.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.20 -r1.21 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/efirng.c \
src/sys/stand/efiboot/efirng.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/stand/efiboot/Makefile.efiboot
diff -u src/sys/stand/efiboot/Makefile.efiboot:1.12 src/sys/stand/efiboot/Makefile.efiboot:1.13
--- src/sys/stand/efiboot/Makefile.efiboot:1.12	Sun Apr 26 06:51:35 2020
+++ src/sys/stand/efiboot/Makefile.efiboot	Thu May 14 19:19:08 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.12 2020/04/26 06:51:35 rin Exp $
+# $NetBSD: Makefile.efiboot,v 1.13 2020/05/14 19:19:08 riastradh Exp $
 
 S=		${.CURDIR}/../../..
 
@@ -22,7 +22,7 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang
 .PATH: ${EFIDIR}/gnuefi
 SOURCES=	crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c
 SOURCES+=	boot.c conf.c console.c dev_net.c devopen.c exec.c panic.c prompt.c
-SOURCES+=	efiboot.c efichar.c efidev.c efienv.c efigetsecs.c efifdt.c efifile.c efiblock.c efinet.c efipxe.c efiacpi.c smbios.c
+SOURCES+=	efiboot.c efichar.c efidev.c efienv.c efigetsecs.c efifdt.c efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c smbios.c
 
 .PATH: ${S}/external/bsd/libfdt/dist
 CPPFLAGS+=	-I${S}/external/bsd/libfdt/dist

Index: src/sys/stand/efiboot/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.20 src/sys/stand/efiboot/boot.c:1.21
--- src/sys/stand/efiboot/boot.c:1.20	Sat Jan 25 11:24:20 2020
+++ src/sys/stand/efiboot/boot.c	Thu May 14 19:19:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.20 2020/01/25 11:24:20 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.21 2020/05/14 19:19:08 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -32,6 +32,7 @@
 #include "efifdt.h"
 #include "efiacpi.h"
 #include "efienv.h"
+#include "efirng.h"
 
 #include 
 #include 
@@ -285,6 +286,7 @@ command_version(char *arg)
 
 	efi_fdt_show();
 	efi_acpi_show();
+	efi_rng_show();
 }
 
 void

Index: src/sys/stand/efiboot/efiacpi.c
diff -u src/sys/stand/efiboot/efiacpi.c:1.6 src/sys/stand/efiboot/efiacpi.c:1.7
--- src/sys/stand/efiboot/efiacpi.c:1.6	Sat Jan 25 11:24:20 2020
+++ src/sys/stand/efiboot/efiacpi.c	Thu May 14 19:19:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efiacpi.c,v 1.6 2020/01/25 11:24:20 jmcneill Exp $ */
+/* $NetBSD: efiacpi.c,v 1.7 2020/05/14 19:19:08 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@ efi_acpi_show(void)
 	rsdp->oemid[3], rsdp->oemid[4], rsdp->oemid[5]);
 
 	if (smbios3_table)
-		printf("SMBIOS: %s", efi_acpi_get_model());
+		printf("SMBIOS: %s\n", efi_acpi_get_model());
 }
 
 int

Added files:

Index: src/sys/stand/efiboot/efirng.c
diff -u /dev/null src/sys/stand/efiboot/efirng.c:1.1
--- /dev/null	Thu May 14 19:19:08 2020
+++ src/sys/stand/efiboot/efirng.c	Thu May 14 19:19:08 2020
@@ -0,0 +1,136 @@
+/*	$NetBSD: efirng.c,v 1.1 2020/05/14 19:19:08 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * UEFI Forum, Inc.: UEFI Specification, Version 2.8 Errata A, February
+ * 2020, Sec. 37.5 EFI Random Number Generator Protocol, pp. 2158--2162
+ * 

CVS commit: src/sys/kern

2020-05-14 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May 14 18:18:24 UTC 2020

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

Log Message:
Fix uninitialized memory access. Found by KMSAN.

Reported-by: syzbot+9f2a173d29d66c88f...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/sys/kern/kern_time.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_time.c
diff -u src/sys/kern/kern_time.c:1.203 src/sys/kern/kern_time.c:1.204
--- src/sys/kern/kern_time.c:1.203	Thu Jan  2 15:42:27 2020
+++ src/sys/kern/kern_time.c	Thu May 14 18:18:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.203 2020/01/02 15:42:27 thorpej Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.204 2020/05/14 18:18:24 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.203 2020/01/02 15:42:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.204 2020/05/14 18:18:24 maxv Exp $");
 
 #include 
 #include 
@@ -352,8 +352,12 @@ again:
 		struct timespec rmtend;
 		struct timespec t0;
 		struct timespec *t;
+		int err;
+
+		err = clock_gettime1(clock_id, );
+		if (err != 0)
+			return err;
 
-		(void)clock_gettime1(clock_id, );
 		t = (rmt != NULL) ? rmt : 
 		if (flags & TIMER_ABSTIME) {
 			timespecsub(rqt, , t);



CVS commit: src/sys/dev/pckbport

2020-05-14 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu May 14 18:06:58 UTC 2020

Modified Files:
src/sys/dev/pckbport: synaptics.c

Log Message:
synaptics: Don't reset the device multiple times in succession

Cherrypicked from a patch from an anonymous contributor.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/pckbport/synaptics.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/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.66 src/sys/dev/pckbport/synaptics.c:1.67
--- src/sys/dev/pckbport/synaptics.c:1.66	Tue Apr 28 19:22:58 2020
+++ src/sys/dev/pckbport/synaptics.c	Thu May 14 18:06:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.66 2020/04/28 19:22:58 jmcneill Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.67 2020/05/14 18:06:58 nia Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.66 2020/04/28 19:22:58 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.67 2020/05/14 18:06:58 nia Exp $");
 
 #include 
 #include 
@@ -1192,7 +1192,7 @@ pms_synaptics_input(void *vsc, int data)
 
 	getmicrouptime(>current);
 
-	if (psc->inputstate != 0) {
+	if (psc->inputstate > 0) {
 		timersub(>current, >last, );
 		if (diff.tv_sec > 0 || diff.tv_usec >= 4) {
 			aprint_debug_dev(psc->sc_dev,



CVS commit: src/sys/kern

2020-05-14 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May 14 17:01:34 UTC 2020

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

Log Message:
KASSERT -> panic


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/kern/subr_kmem.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/subr_kmem.c
diff -u src/sys/kern/subr_kmem.c:1.79 src/sys/kern/subr_kmem.c:1.80
--- src/sys/kern/subr_kmem.c:1.79	Sun Mar  8 00:31:19 2020
+++ src/sys/kern/subr_kmem.c	Thu May 14 17:01:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_kmem.c,v 1.79 2020/03/08 00:31:19 ad Exp $	*/
+/*	$NetBSD: subr_kmem.c,v 1.80 2020/05/14 17:01:34 maxv Exp $	*/
 
 /*
  * Copyright (c) 2009-2020 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.79 2020/03/08 00:31:19 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.80 2020/05/14 17:01:34 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kmem.h"
@@ -258,7 +258,9 @@ kmem_intr_free(void *p, size_t requested
 	pool_cache_t pc;
 
 	KASSERT(p != NULL);
-	KASSERT(requested_size > 0);
+	if (__predict_false(requested_size == 0)) {
+		panic("%s: zero size with pointer %p", __func__, p);
+	}
 
 	kasan_add_redzone(_size);
 	size = kmem_roundup_size(requested_size);



CVS commit: src/sys/arch/amd64/amd64

2020-05-14 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May 14 16:57:53 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: db_machdep.c

Log Message:
Don't even try to go past a syscall. Fixes severe panic recursions in
KUBSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/amd64/db_machdep.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/db_machdep.c
diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.6 src/sys/arch/amd64/amd64/db_machdep.c:1.7
--- src/sys/arch/amd64/amd64/db_machdep.c:1.6	Fri Mar 16 08:48:34 2018
+++ src/sys/arch/amd64/amd64/db_machdep.c	Thu May 14 16:57:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.6 2018/03/16 08:48:34 maxv Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.7 2020/05/14 16:57:53 maxv Exp $	*/
 
 /*
  * Mach Operating System
@@ -26,7 +26,7 @@
  * rights to redistribute these changes.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.6 2018/03/16 08:48:34 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.7 2020/05/14 16:57:53 maxv Exp $");
 
 #include 
 #include 
@@ -125,22 +125,23 @@ db_nextframe(long **nextframe, long **re
 		*arg0 = (long *)>f_arg0;
 		break;
 
-	case TRAP:
 	case SYSCALL:
+		tf = (struct trapframe *)argp;
+		(*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n",
+		db_get_value((long)>tf_rax, 8, false));
+		return 0;
+
+	case TRAP:
 	case INTERRUPT:
 	default:
 
-		/* The only argument to trap() or syscall() is the trapframe. */
+		/* The only argument to trap() is the trapframe. */
 		tf = (struct trapframe *)argp;
 		switch (is_trap) {
 		case TRAP:
 			(*pr)("--- trap (number %"DDB_EXPR_FMT"u) ---\n",
 db_get_value((long)>tf_trapno, 8, false));
 			break;
-		case SYSCALL:
-			(*pr)("--- syscall (number %"DDB_EXPR_FMT"u) ---\n",
-db_get_value((long)>tf_rax, 8, false));
-			break;
 		case INTERRUPT:
 			(*pr)("--- interrupt ---\n");
 			break;



CVS commit: src/share/man/man7

2020-05-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu May 14 16:32:57 UTC 2020

Modified Files:
src/share/man/man7: src.7

Log Message:
- prune src/gnu and src/sys/netsmb
- add src/sys/netcan
- remove bogus statement about location of reachover Makefiles
- tweak language


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/share/man/man7/src.7

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/man7/src.7
diff -u src/share/man/man7/src.7:1.15 src/share/man/man7/src.7:1.16
--- src/share/man/man7/src.7:1.15	Sun Sep 23 09:21:00 2018
+++ src/share/man/man7/src.7	Thu May 14 16:32:57 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: src.7,v 1.15 2018/09/23 09:21:00 maxv Exp $
+.\" $NetBSD: src.7,v 1.16 2020/05/14 16:32:57 snj Exp $
 .\"
 .\" Copyright (c) 2012, 2013 Mingzhe Wang and Elvira Khabirova.
 .\"	All rights reserved.
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 23, 2018
+.Dd May 14, 2020
 .Dt SRC 7
 .Os
 .Sh NAME
@@ -75,7 +75,7 @@ fragment for building an
 .Pa 
 compat libraries for
 .Pa  .
-E. g.,
+For example,
 .Pa compat/amd64/i386/
 is where the 32-bit compat libraries for the
 amd64 port are being built.
@@ -118,7 +118,7 @@ Tools and data-files for making distribu
 .It Pa /
 Architecture-specific files, grouped by
 image type.
-E. g.,
+For example,
 .Pa distrib//floppies/
 contains Makefiles for making images for
 various types of floppies;
@@ -157,10 +157,6 @@ Architecture-specific config files.
 .It Pa external/
 Unmodified sources from third parties,
 grouped by license.
-They are built with so-called "reachover"
-Makefiles which can be found in
-.Pa src/*bin/
-hierarchies.
 Every
 .Pa external///
 may contain:
@@ -173,7 +169,7 @@ Unmodified third party source for a give
 .It etc.
 Such subdirectories contain reachover Makefiles,
 README's and various import helper scripts.
-E. g.,
+For example,
 .Pa external/public-domain/
 contains
 sources licensed under Public Domain
@@ -196,19 +192,6 @@ Sources for utilities/files in
 .Pa /usr/games ;
 each utility has its own subdirectory, where
 its sources and Makefiles are located.
-.It Pa gnu/
-Sources licensed under GNU GPL.
-This is deprecated;
-.Pa external/gpl2/
-or
-.Pa external/gpl3/
-should be used instead.
-.Pa gnu/dists
-contains the original GNU sources plus changes that
-were submitted to maintainers and that are not
-yet published.
-Other folders contain files that are never expected
-to be submitted to the FSF (reachover Makefiles, etc.)
 .It Pa include/
 Files to be put into
 .Pa /usr/include .
@@ -294,6 +277,9 @@ Appletalk protocol stack
 .It Pa netbt/
 Bluetooth stack
 .Xr bluetooth 4 .
+.It Pa netcan/
+Controller Area Network stack
+.Xr can 4 .
 .It Pa netinet/
 IPv4 protocol stack
 .Xr ip 4 .
@@ -305,8 +291,6 @@ IPsec protocol stack
 .It Pa netmpls/
 MPLS protocol stack
 .Xr mpls 4 .
-.It Pa netsmb/
-SMB network protocol stack.
 .It Pa nfs/
 Network file system driver.
 .It Pa opencrypto/



CVS commit: src/lib/libc/sys

2020-05-14 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu May 14 13:40:49 UTC 2020

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

Log Message:
Use more markup.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/lib/libc/sys/ptrace.2

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

Modified files:

Index: src/lib/libc/sys/ptrace.2
diff -u src/lib/libc/sys/ptrace.2:1.84 src/lib/libc/sys/ptrace.2:1.85
--- src/lib/libc/sys/ptrace.2:1.84	Thu May 14 13:32:15 2020
+++ src/lib/libc/sys/ptrace.2	Thu May 14 13:40:49 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ptrace.2,v 1.84 2020/05/14 13:32:15 kamil Exp $
+.\"	$NetBSD: ptrace.2,v 1.85 2020/05/14 13:40:49 wiz Exp $
 .\"
 .\" This file is in the public domain.
 .Dd May 14, 2020
@@ -633,9 +633,12 @@ The
 argument should be set to
 .Li sizeof(sigset_t) .
 .Pp
-It is not permitted to mask SIGSTOP and SIGKILL.
+It is not permitted to mask
+.Dv SIGSTOP
+and
+.Dv SIGKILL .
 All debugger related signals
-(SIGTRAP, SIGILL, SIGSEGV, SIGBUS, SIGFPE)
+.Dv ( SIGTRAP , SIGILL , SIGSEGV , SIGBUS , SIGFPE )
 are reported to the tracer without interruption,
 unless they were emitted by a non-crash source.
 .It Dv PT_GET_SIGPASS



CVS commit: src/doc

2020-05-14 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May 14 13:37:52 UTC 2020

Modified Files:
src/doc: CHANGES

Log Message:
ptrace(2): Add PT_SET_SIGPASS and PT_GET_SIGPASS.


To generate a diff of this commit:
cvs rdiff -u -r1.2687 -r1.2688 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2687 src/doc/CHANGES:1.2688
--- src/doc/CHANGES:1.2687	Wed May 13 08:43:28 2020
+++ src/doc/CHANGES	Thu May 14 13:37:52 2020
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2687 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2688 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -194,3 +194,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	xen: Support MSI for XenPV [jdolecek 20200504]
 	hppa: Enable modules in GENERIC by default.  [skrll 20200511]
 	xen: enable MULTIPROCESSOR for Xen dom0. [bouyer 20200513]
+	ptrace(2): Add PT_SET_SIGPASS and PT_GET_SIGPASS. [kamil 20200514]



CVS commit: src/sys/sys

2020-05-14 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May 14 13:34:46 UTC 2020

Modified Files:
src/sys/sys: param.h

Log Message:
Welcome to 9.99.62

struct sigctx gained ps_sigpass member.


To generate a diff of this commit:
cvs rdiff -u -r1.664 -r1.665 src/sys/sys/param.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/sys/param.h
diff -u src/sys/sys/param.h:1.664 src/sys/sys/param.h:1.665
--- src/sys/sys/param.h:1.664	Tue May 12 23:18:52 2020
+++ src/sys/sys/param.h	Thu May 14 13:34:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.664 2020/05/12 23:18:52 ad Exp $	*/
+/*	$NetBSD: param.h,v 1.665 2020/05/14 13:34:46 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999006100	/* NetBSD 9.99.61 */
+#define	__NetBSD_Version__	999006200	/* NetBSD 9.99.62 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src

2020-05-14 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May 14 13:32:15 UTC 2020

Modified Files:
src/lib/libc/sys: ptrace.2
src/sys/kern: kern_sig.c sys_ptrace_common.c
src/sys/sys: ptrace.h signalvar.h

Log Message:
Introduce new ptrace(2) operations: PT_SET_SIGPASS and PT_GET_SIGPASS

They deliver the logic of bypassing selected signals directly to the
debuggee, without informing the debugger.

This can be used to implement the QPassSignals GDB/LLDB protocol.

This call can be useful to avoid signal races in ATF ptrace tests.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/lib/libc/sys/ptrace.2
cvs rdiff -u -r1.388 -r1.389 src/sys/kern/kern_sig.c
cvs rdiff -u -r1.79 -r1.80 src/sys/kern/sys_ptrace_common.c
cvs rdiff -u -r1.69 -r1.70 src/sys/sys/ptrace.h
cvs rdiff -u -r1.101 -r1.102 src/sys/sys/signalvar.h

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

Modified files:

Index: src/lib/libc/sys/ptrace.2
diff -u src/lib/libc/sys/ptrace.2:1.83 src/lib/libc/sys/ptrace.2:1.84
--- src/lib/libc/sys/ptrace.2:1.83	Sat Jan  4 04:40:17 2020
+++ src/lib/libc/sys/ptrace.2	Thu May 14 13:32:15 2020
@@ -1,7 +1,7 @@
-.\"	$NetBSD: ptrace.2,v 1.83 2020/01/04 04:40:17 kamil Exp $
+.\"	$NetBSD: ptrace.2,v 1.84 2020/05/14 13:32:15 kamil Exp $
 .\"
 .\" This file is in the public domain.
-.Dd January 4, 2019
+.Dd May 14, 2020
 .Dt PTRACE 2
 .Os
 .Sh NAME
@@ -623,6 +623,31 @@ The
 .Fa data
 argument should be set to
 .Li sizeof(struct ptrace_siginfo) .
+.It Dv PT_SET_SIGPASS
+This request can be used to specify mask of signals that should be passed
+directly to the debuggee, without reporting to the tracer.
+A pointer to sigset_t is passed in
+.Fa addr .
+The
+.Fa data
+argument should be set to
+.Li sizeof(sigset_t) .
+.Pp
+It is not permitted to mask SIGSTOP and SIGKILL.
+All debugger related signals
+(SIGTRAP, SIGILL, SIGSEGV, SIGBUS, SIGFPE)
+are reported to the tracer without interruption,
+unless they were emitted by a non-crash source.
+.It Dv PT_GET_SIGPASS
+This request can be used to determine mask of signals passed directly to the debuggee.
+A pointer to sigset_t is passed in
+.Fa addr .
+The
+.Fa data
+argument should be set to
+.Li sizeof(sigset_t) .
+.Pp
+Upon debugger attach the sigpass mask shall be empty.
 .It Dv PT_RESUME
 Allow execution of a specified thread,
 change its state from suspended to continued.

Index: src/sys/kern/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.388 src/sys/kern/kern_sig.c:1.389
--- src/sys/kern/kern_sig.c:1.388	Thu May  7 20:02:34 2020
+++ src/sys/kern/kern_sig.c	Thu May 14 13:32:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.388 2020/05/07 20:02:34 kamil Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.389 2020/05/14 13:32:15 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.388 2020/05/07 20:02:34 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.389 2020/05/14 13:32:15 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -1302,6 +1302,7 @@ kpsignal2(struct proc *p, ksiginfo_t *ks
 	lwpid_t lid;
 	sig_t action;
 	bool toall;
+	bool traced;
 	int error = 0;
 
 	KASSERT(!cpu_intr_p());
@@ -1329,11 +1330,13 @@ kpsignal2(struct proc *p, ksiginfo_t *ks
 	prop = sigprop[signo];
 	toall = ((prop & SA_TOALL) != 0);
 	lid = toall ? 0 : ksi->ksi_lid;
+	traced = ISSET(p->p_slflag, PSL_TRACED) &&
+	!sigismember(>p_sigctx.ps_sigpass, signo);
 
 	/*
 	 * If proc is traced, always give parent a chance.
 	 */
-	if (p->p_slflag & PSL_TRACED) {
+	if (traced) {
 		action = SIG_DFL;
 
 		if (lid == 0) {
@@ -1428,7 +1431,7 @@ kpsignal2(struct proc *p, ksiginfo_t *ks
 	 * or for an SA process.
 	 */
 	if (p->p_stat == SACTIVE && (p->p_sflag & PS_STOPPING) == 0) {
-		if ((p->p_slflag & PSL_TRACED) != 0)
+		if (traced)
 			goto deliver;
 
 		/*
@@ -1444,7 +1447,7 @@ kpsignal2(struct proc *p, ksiginfo_t *ks
 		 * - If traced, then no action is needed, unless killing.
 		 * - Run the process only if sending SIGCONT or SIGKILL.
 		 */
-		if ((p->p_slflag & PSL_TRACED) != 0 && signo != SIGKILL) {
+		if (traced && signo != SIGKILL) {
 			goto out;
 		}
 		if ((prop & SA_CONT) != 0 || signo == SIGKILL) {
@@ -1456,7 +1459,7 @@ kpsignal2(struct proc *p, ksiginfo_t *ks
 p->p_pptr->p_nstopchild--;
 			p->p_stat = SACTIVE;
 			p->p_sflag &= ~PS_STOPPING;
-			if (p->p_slflag & PSL_TRACED) {
+			if (traced) {
 KASSERT(signo == SIGKILL);
 goto deliver;
 			}
@@ -1487,7 +1490,7 @@ kpsignal2(struct proc *p, ksiginfo_t *ks
 	/*
 	 * Make signal pending.
 	 */
-	KASSERT((p->p_slflag & PSL_TRACED) == 0);
+	KASSERT(!traced);
 	if ((error = sigput(>p_sigpend, p, kp)) != 0)
 		goto out;
 deliver:
@@ -1844,6 +1847,7 @@ issignal(struct lwp *l)
 	int siglwp, signo, prop;
 	sigpend_t *sp;
 	sigset_t ss;
+	bool traced;
 
 	p = l->l_proc;
 	sp = NULL;
@@ -1910,6 

CVS commit: src/sys/arch/xen/xen

2020-05-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu May 14 13:25:40 UTC 2020

Modified Files:
src/sys/arch/xen/xen: if_xennet_xenbus.c

Log Message:
fix resume for xennet, now the network continues working after resume

we can't read feature-rx-copy in resume, at that time the new backend
device is not filled yet; convert it just to feature flag read on interface
attach, can assume any backend would support rx-copy anyway

fix compile with XENNET_DEBUG

part of PR port-xen/55207


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/arch/xen/xen/if_xennet_xenbus.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/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.125 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.126
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.125	Thu May 14 09:47:25 2020
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Thu May 14 13:25:40 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.125 2020/05/14 09:47:25 jdolecek Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.126 2020/05/14 13:25:40 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.125 2020/05/14 09:47:25 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.126 2020/05/14 13:25:40 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -198,7 +198,8 @@ struct xennet_xenbus_softc {
 	int sc_features;
 #define FEATURE_IPV6CSUM	0x01	/* IPv6 checksum offload */
 #define FEATURE_SG		0x02	/* scatter-gatter */
-#define FEATURE_BITS		"\20\1IPV6-CSUM\2SG"
+#define FEATURE_RX_COPY		0x04	/* RX-copy */
+#define FEATURE_BITS		"\20\1IPV6-CSUM\2SG\3RX-COPY"
 	krndsource_t sc_rnd_source;
 	struct evcnt sc_cnt_tx_defrag;
 	struct evcnt sc_cnt_tx_queue_full;
@@ -280,6 +281,10 @@ xennet_xenbus_attach(device_t parent, de
 
 	/* read feature support flags */
 	err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend,
+	"feature-rx-copy", , 10);
+	if (!err && uval == 1)
+		sc->sc_features |= FEATURE_RX_COPY;
+	err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend,
 	"feature-ipv6-csum-offload", , 10);
 	if (!err && uval == 1)
 		sc->sc_features |= FEATURE_IPV6CSUM;
@@ -601,19 +606,9 @@ static bool
 xennet_talk_to_backend(struct xennet_xenbus_softc *sc)
 {
 	int error;
-	unsigned long rx_copy;
 	struct xenbus_transaction *xbt;
 	const char *errmsg;
 
-	error = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend,
-	"feature-rx-copy", _copy, 10);
-	if (error || !rx_copy) {
-		xenbus_dev_fatal(sc->sc_xbusd, error,
-		"feature-rx-copy not supported");
-		return false;
-	}
-	aprint_normal_dev(sc->sc_dev, "using RX copy mode\n");
-
 again:
 	xbt = xenbus_transaction_start();
 	if (xbt == NULL)
@@ -637,7 +632,7 @@ again:
 		goto abort_transaction;
 	}
 	error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path,
-	"request-rx-copy", "%lu", rx_copy);
+	"request-rx-copy", "%u", 1);
 	if (error) {
 		errmsg = "writing request-rx-copy";
 		goto abort_transaction;
@@ -1232,9 +1227,8 @@ xennet_start(struct ifnet *ifp)
 		}
 
 		DPRINTFN(XEDB_MBUF, ("xennet_start id %d, "
-		"mbuf %p, buf %p/%p, size %d\n",
-		req->txreq_id, m, mtod(m, void *), (void *)ma,
-		m->m_pkthdr.len));
+		"mbuf %p, buf %p, size %d\n",
+		req->txreq_id, m, mtod(m, void *), m->m_pkthdr.len));
 
 #ifdef XENNET_DEBUG_DUMP
 		xennet_hex_dump(mtod(m, u_char *), m->m_pkthdr.len, "s",



CVS commit: src/sys/arch/xen/xenbus

2020-05-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu May 14 13:18:55 UTC 2020

Modified Files:
src/sys/arch/xen/xenbus: xenbus_probe.c

Log Message:
fix compile when DPRINK() is defined


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/xen/xenbus/xenbus_probe.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/xen/xenbus/xenbus_probe.c
diff -u src/sys/arch/xen/xenbus/xenbus_probe.c:1.53 src/sys/arch/xen/xenbus/xenbus_probe.c:1.54
--- src/sys/arch/xen/xenbus/xenbus_probe.c:1.53	Wed May 13 13:19:38 2020
+++ src/sys/arch/xen/xenbus/xenbus_probe.c	Thu May 14 13:18:55 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_probe.c,v 1.53 2020/05/13 13:19:38 jdolecek Exp $ */
+/* $NetBSD: xenbus_probe.c,v 1.54 2020/05/14 13:18:55 jdolecek Exp $ */
 /**
  * Talks to Xen Store to figure out what devices we have.
  *
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.53 2020/05/13 13:19:38 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.54 2020/05/14 13:18:55 jdolecek Exp $");
 
 #if 0
 #define DPRINTK(fmt, args...) \
@@ -195,7 +195,7 @@ read_otherend_details(struct xenbus_devi
 		return err;
 	}
 	DPRINTK("read_otherend_details: read %s/%s returned %s\n",
-	xendev->xbusd_path, path_node, val);
+	xendev->xbusd_path, path_node, xendev->xbusd_otherend);
 
 	if (strlen(xendev->xbusd_otherend) == 0 ||
 	!xenbus_exists(NULL, xendev->xbusd_otherend, "")) {
@@ -322,7 +322,7 @@ xenbus_probe_device_type(const char *pat
 
 	DPRINTK("probe %s type %s", path, type);
 	err = xenbus_directory(NULL, path, "", _dir_n, );
-	DPRINTK("directory err %d dir_n %d", err, dir_n);
+	DPRINTK("directory err %d dir_n %d", err, orig_dir_n);
 	if (err)
 		return err;
 	dir_n = orig_dir_n;



CVS commit: src/lib/libcurses

2020-05-14 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 14 11:50:05 UTC 2020

Modified Files:
src/lib/libcurses: getch.c

Log Message:
KNF nit.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/lib/libcurses/getch.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/libcurses/getch.c
diff -u src/lib/libcurses/getch.c:1.73 src/lib/libcurses/getch.c:1.74
--- src/lib/libcurses/getch.c:1.73	Sun Jun  9 07:40:14 2019
+++ src/lib/libcurses/getch.c	Thu May 14 11:50:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: getch.c,v 1.73 2019/06/09 07:40:14 blymn Exp $	*/
+/*	$NetBSD: getch.c,v 1.74 2020/05/14 11:50:04 simonb Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)getch.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: getch.c,v 1.73 2019/06/09 07:40:14 blymn Exp $");
+__RCSID("$NetBSD: getch.c,v 1.74 2020/05/14 11:50:04 simonb Exp $");
 #endif
 #endif	/* not lint */
 
@@ -876,8 +876,7 @@ wgetch(WINDOW *win)
 	__save_termios();
 
 	if (win->flags & __KEYPAD) {
-		switch (win->delay)
-		{
+		switch (win->delay) {
 		case -1:
 			inp = inkey (win->flags & __NOTIMEOUT ? 0 : 1, 0);
 			break;
@@ -891,8 +890,7 @@ wgetch(WINDOW *win)
 			break;
 		}
 	} else {
-		switch (win->delay)
-		{
+		switch (win->delay) {
 		case -1:
 			if (__delay() == ERR)
 return ERR;



CVS commit: src/sys/arch/xen/xen

2020-05-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu May 14 09:47:25 UTC 2020

Modified Files:
src/sys/arch/xen/xen: if_xennet_xenbus.c

Log Message:
rearrange so that suspend & resume doesn't cause panics, and interface
is more likely to work - particularly, don't try to xengnt_revoke_access()
after resume, move xen_intr_disestablish() call to resume, also
unmask the event channel on resume

XXX right now xennet device detaches immediately after resume, which is not
desirable and needs to be fixed

part of PR port-xen/55207


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/xen/xen/if_xennet_xenbus.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/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.124 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.125
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.124	Tue May  5 09:52:13 2020
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Thu May 14 09:47:25 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.124 2020/05/05 09:52:13 jdolecek Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.125 2020/05/14 09:47:25 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.124 2020/05/05 09:52:13 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.125 2020/05/14 09:47:25 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -218,7 +218,7 @@ static int  xennet_xenbus_detach(device_
 static void xennet_backend_changed(void *, XenbusState);
 
 static void xennet_alloc_rx_buffer(struct xennet_xenbus_softc *);
-static void xennet_free_rx_buffer(struct xennet_xenbus_softc *);
+static void xennet_free_rx_buffer(struct xennet_xenbus_softc *, bool);
 static void xennet_tx_complete(struct xennet_xenbus_softc *);
 static void xennet_rx_mbuf_free(struct mbuf *, void *, size_t, void *);
 static int  xennet_handler(void *);
@@ -233,7 +233,7 @@ static void xennet_start(struct ifnet *)
 static int  xennet_ioctl(struct ifnet *, u_long, void *);
 
 static bool xennet_xenbus_suspend(device_t dev, const pmf_qual_t *);
-static bool xennet_xenbus_resume (device_t dev, const pmf_qual_t *);
+static bool xennet_xenbus_resume(device_t dev, const pmf_qual_t *);
 
 CFATTACH_DECL3_NEW(xennet, sizeof(struct xennet_xenbus_softc),
xennet_xenbus_match, xennet_xenbus_attach, xennet_xenbus_detach, NULL,
@@ -412,15 +412,6 @@ xennet_xenbus_attach(device_t parent, de
 	sc->sc_tx_ring.sring = tx_ring;
 	sc->sc_rx_ring.sring = rx_ring;
 
-	/* resume shared structures and tell backend that we are ready */
-	if (xennet_xenbus_resume(self, PMF_Q_NONE) == false) {
-		uvm_km_free(kernel_map, (vaddr_t)tx_ring, PAGE_SIZE,
-		UVM_KMF_WIRED);
-		uvm_km_free(kernel_map, (vaddr_t)rx_ring, PAGE_SIZE,
-		UVM_KMF_WIRED);
-		return;
-	}
-
 	rnd_attach_source(>sc_rnd_source, device_xname(sc->sc_dev),
 	RND_TYPE_NET, RND_FLAG_DEFAULT);
 
@@ -444,6 +435,15 @@ xennet_xenbus_attach(device_t parent, de
 		aprint_error_dev(self, "couldn't establish power handler\n");
 	else
 		pmf_class_network_register(self, ifp);
+
+	/* resume shared structures and tell backend that we are ready */
+	if (xennet_xenbus_resume(self, PMF_Q_NONE) == false) {
+		uvm_km_free(kernel_map, (vaddr_t)tx_ring, PAGE_SIZE,
+		UVM_KMF_WIRED);
+		uvm_km_free(kernel_map, (vaddr_t)rx_ring, PAGE_SIZE,
+		UVM_KMF_WIRED);
+		return;
+	}
 }
 
 static int
@@ -451,7 +451,6 @@ xennet_xenbus_detach(device_t self, int 
 {
 	struct xennet_xenbus_softc *sc = device_private(self);
 	struct ifnet *ifp = >sc_ethercom.ec_if;
-	RING_IDX i;
 
 	if ((flags & (DETACH_SHUTDOWN | DETACH_FORCE)) == DETACH_SHUTDOWN) {
 		/* Trigger state transition with backend */
@@ -480,14 +479,7 @@ xennet_xenbus_detach(device_t self, int 
 	mutex_exit(>sc_tx_lock);
 
 	mutex_enter(>sc_rx_lock);
-	xennet_free_rx_buffer(sc);
-	for (i = 0; i < NET_RX_RING_SIZE; i++) {
-		struct xennet_rxreq *rxreq = >sc_rxreqs[i];
-		if (rxreq->rxreq_m != NULL) {
-			m_freem(rxreq->rxreq_m);
-			rxreq->rxreq_m = NULL;
-		}
-	}
+	xennet_free_rx_buffer(sc, true);
 	mutex_exit(>sc_rx_lock);
 
 	ether_ifdetach(ifp);
@@ -537,19 +529,16 @@ xennet_xenbus_resume(device_t dev, const
 	netif_rx_sring_t *rx_ring;
 	paddr_t ma;
 
-	/* invalidate the RX and TX rings */
-	if (sc->sc_backend_status == BEST_SUSPENDED) {
-		/*
-		 * Device was suspended, so ensure that access associated to
-		 * the previous RX and TX rings are revoked.
-		 */
-		xengnt_revoke_access(sc->sc_tx_ring_gntref);
-		xengnt_revoke_access(sc->sc_rx_ring_gntref);
-	}
-
+	/* All grants were removed during suspend */
 	sc->sc_tx_ring_gntref = GRANT_INVALID_REF;
 	sc->sc_rx_ring_gntref = GRANT_INVALID_REF;
 
+	mutex_enter(>sc_rx_lock);
+	/* Free but don't revoke, the grant is gone */
+	xennet_free_rx_buffer(sc, false);
+	

CVS commit: src

2020-05-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu May 14 08:34:20 UTC 2020

Modified Files:
src/bin/sh: eval.c parser.c
src/common/lib/libc/gen: radixtree.c
src/crypto/dist/ipsec-tools/src/racoon: ipsec_doi.c
src/crypto/external/bsd/netpgp/dist/src/libverify: libverify.c
src/games/snake/snake: snake.c
src/lib/libcrypt: crypt-argon2.c pw_gensalt.c
src/sbin/fsck_lfs: segwrite.c
src/sbin/gpt: restore.c
src/sbin/ifconfig: af_inet.c
src/sbin/mount_portal: pt_filter.c
src/sbin/newfs_udf: udf_create.c
src/sys/arch/arm/imx: if_enet.c imx7_usb.c
src/sys/arch/arm/marvell: armadaxp.c pci_machdep.c
src/sys/arch/arm/omap: ti_iic.c
src/sys/arch/arm/s3c2xx0: s3c2440_extint.c
src/sys/arch/arm/sunxi: sunxi_usbphy.c
src/sys/arch/arm/ti: ti_iic.c
src/sys/arch/i386/stand/lib: exec_multiboot2.c
src/sys/arch/mips/rmi: rmixl_firmware.h
src/sys/dev: md.c
src/sys/dev/pci: if_aq.c if_ixl.c mfii.c
src/sys/dev/usb: if_urtwreg.h
src/sys/stand/efiboot: efienv.c
src/tests/fs/vfs: t_rwtoro.c
src/tests/lib/libppath: t_ppath.c
src/tests/lib/libpthread: t_thrd.c
src/tests/lib/librt: t_sem.c
src/usr.sbin/bta2dpd/bta2dpd: avdtp.c
src/usr.sbin/installboot: evboards.c

Log Message:
Remove extra semicolon.


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/bin/sh/eval.c
cvs rdiff -u -r1.169 -r1.170 src/bin/sh/parser.c
cvs rdiff -u -r1.26 -r1.27 src/common/lib/libc/gen/radixtree.c
cvs rdiff -u -r1.51 -r1.52 src/crypto/dist/ipsec-tools/src/racoon/ipsec_doi.c
cvs rdiff -u -r1.9 -r1.10 \
src/crypto/external/bsd/netpgp/dist/src/libverify/libverify.c
cvs rdiff -u -r1.29 -r1.30 src/games/snake/snake/snake.c
cvs rdiff -u -r1.1 -r1.2 src/lib/libcrypt/crypt-argon2.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libcrypt/pw_gensalt.c
cvs rdiff -u -r1.47 -r1.48 src/sbin/fsck_lfs/segwrite.c
cvs rdiff -u -r1.18 -r1.19 src/sbin/gpt/restore.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/ifconfig/af_inet.c
cvs rdiff -u -r1.11 -r1.12 src/sbin/mount_portal/pt_filter.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/newfs_udf/udf_create.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/imx/if_enet.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/imx7_usb.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/marvell/armadaxp.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/marvell/pci_machdep.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/omap/ti_iic.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/s3c2xx0/s3c2440_extint.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sunxi_usbphy.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/ti_iic.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/lib/exec_multiboot2.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/rmi/rmixl_firmware.h
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/md.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/if_aq.c
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/pci/if_ixl.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/mfii.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/if_urtwreg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efienv.c
cvs rdiff -u -r1.1 -r1.2 src/tests/fs/vfs/t_rwtoro.c
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libppath/t_ppath.c
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libpthread/t_thrd.c
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/librt/t_sem.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/bta2dpd/bta2dpd/avdtp.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/installboot/evboards.c

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

Modified files:

Index: src/bin/sh/eval.c
diff -u src/bin/sh/eval.c:1.179 src/bin/sh/eval.c:1.180
--- src/bin/sh/eval.c:1.179	Thu Apr 23 09:01:33 2020
+++ src/bin/sh/eval.c	Thu May 14 08:34:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.c,v 1.179 2020/04/23 09:01:33 kre Exp $	*/
+/*	$NetBSD: eval.c,v 1.180 2020/05/14 08:34:17 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)eval.c	8.9 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: eval.c,v 1.179 2020/04/23 09:01:33 kre Exp $");
+__RCSID("$NetBSD: eval.c,v 1.180 2020/05/14 08:34:17 msaitoh Exp $");
 #endif
 #endif /* not lint */
 
@@ -1208,7 +1208,7 @@ evalcommand(union node *cmd, int flgs, s
 shellparam = saveparam;
 			}
 			if (saved)
-popredir();;
+popredir();
 			unreffunc(cmdentry.u.func);
 			poplocalvars();
 			localvars = savelocalvars;

Index: src/bin/sh/parser.c
diff -u src/bin/sh/parser.c:1.169 src/bin/sh/parser.c:1.170
--- src/bin/sh/parser.c:1.169	Tue Dec 10 09:18:37 2019
+++ src/bin/sh/parser.c	Thu May 14 08:34:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parser.c,v 1.169 2019/12/10 09:18:37 kre Exp $	*/
+/*	$NetBSD: parser.c,v 1.170 2020/05/14 08:34:17 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)parser.c	8.7 (Berkeley) 5/16/95";
 #else
-__RCSID("$NetBSD: 

CVS commit: src/sys/compat/linux/common

2020-05-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu May 14 08:26:29 UTC 2020

Modified Files:
src/sys/compat/linux/common: linux_sched.c

Log Message:
Fix previous; specify lwpid for curlpw in the case of pid == 0.

For linux_sys_sched_setaffinity, pid == 0 means the current thread.
On the other hand, for our native sys_sched_setaffinity, lid == 0
means all lwp's that belong to the process.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/compat/linux/common/linux_sched.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/compat/linux/common/linux_sched.c
diff -u src/sys/compat/linux/common/linux_sched.c:1.76 src/sys/compat/linux/common/linux_sched.c:1.77
--- src/sys/compat/linux/common/linux_sched.c:1.76	Wed Apr 29 01:55:18 2020
+++ src/sys/compat/linux/common/linux_sched.c	Thu May 14 08:26:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_sched.c,v 1.76 2020/04/29 01:55:18 thorpej Exp $	*/
+/*	$NetBSD: linux_sched.c,v 1.77 2020/05/14 08:26:29 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.76 2020/04/29 01:55:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.77 2020/05/14 08:26:29 rin Exp $");
 
 #include 
 #include 
@@ -671,12 +671,14 @@ linux_sys_sched_setaffinity(struct lwp *
 	struct sys__sched_setaffinity_args ssa;
 	size_t size;
 	pid_t pid;
+	lwpid_t lid;
 
 	size = LINUX_CPU_MASK_SIZE;
 	if (SCARG(uap, len) < size)
 		return EINVAL;
 
-	if (SCARG(uap, pid) != 0) {
+	lid = SCARG(uap, pid);
+	if (lid != 0) {
 		/* Get the canonical PID for the process. */
 		mutex_enter(proc_lock);
 		struct proc *p = proc_find_lwpid(SCARG(uap, pid));
@@ -687,11 +689,12 @@ linux_sys_sched_setaffinity(struct lwp *
 		pid = p->p_pid;
 		mutex_exit(proc_lock);
 	} else {
-		pid = 0;
+		pid = curproc->p_pid;
+		lid = curlwp->l_lid;
 	}
 
 	SCARG(, pid) = pid;
-	SCARG(, lid) = SCARG(uap, pid);
+	SCARG(, lid) = lid;
 	SCARG(, size) = size;
 	SCARG(, cpuset) = (cpuset_t *)SCARG(uap, mask);
 



CVS commit: src/sys/arch/aarch64

2020-05-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu May 14 07:59:03 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c
src/sys/arch/aarch64/include: pmap.h

Log Message:
Use MUTEX_NODEBUG for PV locks as is commonly done.  OK ryo.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/aarch64/include/pmap.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/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.72 src/sys/arch/aarch64/aarch64/pmap.c:1.73
--- src/sys/arch/aarch64/aarch64/pmap.c:1.72	Wed May 13 10:13:29 2020
+++ src/sys/arch/aarch64/aarch64/pmap.c	Thu May 14 07:59:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.72 2020/05/13 10:13:29 jmcneill Exp $	*/
+/*	$NetBSD: pmap.c,v 1.73 2020/05/14 07:59:03 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.72 2020/05/13 10:13:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.73 2020/05/14 07:59:03 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -503,32 +503,12 @@ _pmap_pv_ctor(void *arg, void *v, int fl
 void
 pmap_init(void)
 {
-	struct vm_page *pg;
-	struct vm_page_md *md;
-	uvm_physseg_t i;
-	paddr_t pfn;
 
 	pool_cache_bootstrap(&_pmap_cache, sizeof(struct pmap),
 	0, 0, 0, "pmappl", NULL, IPL_NONE, _pmap_pmap_ctor, NULL, NULL);
 	pool_cache_bootstrap(&_pmap_pv_pool, sizeof(struct pv_entry),
 	0, 0, 0, "pvpl", NULL, IPL_VM, _pmap_pv_ctor, NULL, NULL);
 
-	/*
-	 * initialize mutex in vm_page_md at this time.
-	 * When LOCKDEBUG, mutex_init() calls km_alloc,
-	 * but VM_MDPAGE_INIT() is called before initialized kmem_vm_arena.
-	 */
-	for (i = uvm_physseg_get_first();
-	 uvm_physseg_valid_p(i);
-	 i = uvm_physseg_get_next(i)) {
-		for (pfn = uvm_physseg_get_start(i);
-		 pfn < uvm_physseg_get_end(i);
-		 pfn++) {
-			pg = PHYS_TO_VM_PAGE(ptoa(pfn));
-			md = VM_PAGE_TO_MD(pg);
-			PMAP_PAGE_INIT(>mdpg_pp);
-		}
-	}
 }
 
 void
@@ -616,6 +596,9 @@ pmap_alloc_pdp(struct pmap *pm, struct v
 
 		VM_PAGE_TO_MD(pg)->mdpg_ptep_parent = NULL;
 
+		struct pmap_page *pp = VM_PAGE_TO_PP(pg);
+		pp->pp_flags = 0;
+
 	} else {
 		/* uvm_pageboot_alloc() returns AARCH64 KSEG address */
 		pg = NULL;
@@ -638,7 +621,9 @@ pmap_free_pdp(struct pmap *pm, struct vm
 	LIST_REMOVE(pg, mdpage.mdpg_vmlist);
 	pg->flags |= PG_BUSY;
 	pg->wire_count = 0;
-	VM_MDPAGE_INIT(pg);
+
+	struct pmap_page *pp = VM_PAGE_TO_PP(pg);
+	KASSERT(LIST_EMPTY(>pp_pvhead));
 
 	uvm_pagefree(pg);
 	PMAP_COUNT(pdp_free);

Index: src/sys/arch/aarch64/include/pmap.h
diff -u src/sys/arch/aarch64/include/pmap.h:1.38 src/sys/arch/aarch64/include/pmap.h:1.39
--- src/sys/arch/aarch64/include/pmap.h:1.38	Wed May 13 06:08:51 2020
+++ src/sys/arch/aarch64/include/pmap.h	Thu May 14 07:59:03 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.38 2020/05/13 06:08:51 ryo Exp $ */
+/* $NetBSD: pmap.h,v 1.39 2020/05/14 07:59:03 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -101,16 +101,17 @@ struct vm_page_md {
 	struct pmap_page mdpg_pp;
 };
 
-/* each mdpg_pp.pp_pvlock will be initialized in pmap_init() */
 #define VM_MDPAGE_INIT(pg)	\
 	do {			\
-		LIST_INIT(&(pg)->mdpage.mdpg_pp.pp_pvhead);	\
-		(pg)->mdpage.mdpg_pp.pp_flags = 0;		\
+		(pg)->mdpage.mdpg_ptep_parent = NULL;		\
+		PMAP_PAGE_INIT(&(pg)->mdpage.mdpg_pp);		\
 	} while (/*CONSTCOND*/ 0)
 
 #define PMAP_PAGE_INIT(pp)		\
 	do {\
-		mutex_init(&(pp)->pp_pvlock, MUTEX_SPIN, IPL_VM);	\
+		mutex_init(&(pp)->pp_pvlock, MUTEX_NODEBUG, IPL_VM);	\
+		LIST_INIT(&(pp)->pp_pvhead);\
+		(pp)->pp_flags = 0;	\
 	} while (/*CONSTCOND*/ 0)
 
 /* saved permission bit for referenced/modified emulation */



CVS commit: src/sys/arch/hppa/dev

2020-05-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu May 14 06:13:39 UTC 2020

Modified Files:
src/sys/arch/hppa/dev: asp.c dino.c lasi.c wax.c

Log Message:
Mask all interrupts before reading (and clearing) the interrupt request
register in attach.

Picked up by an assert in the qemu code.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hppa/dev/asp.c \
src/sys/arch/hppa/dev/wax.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/dev/dino.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hppa/dev/lasi.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/hppa/dev/asp.c
diff -u src/sys/arch/hppa/dev/asp.c:1.1 src/sys/arch/hppa/dev/asp.c:1.2
--- src/sys/arch/hppa/dev/asp.c:1.1	Mon Feb 24 07:23:42 2014
+++ src/sys/arch/hppa/dev/asp.c	Thu May 14 06:13:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: asp.c,v 1.1 2014/02/24 07:23:42 skrll Exp $	*/
+/*	$NetBSD: asp.c,v 1.2 2020/05/14 06:13:39 skrll Exp $	*/
 
 /*	$OpenBSD: asp.c,v 1.5 2000/02/09 05:04:22 mickey Exp $	*/
 
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: asp.c,v 1.1 2014/02/24 07:23:42 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: asp.c,v 1.2 2020/05/14 06:13:39 skrll Exp $");
 
 #include 
 #include 
@@ -243,9 +243,8 @@ aspattach(device_t parent, device_t self
 	s = splhigh();
 	viper_setintrwnd(1 << ca->ca_irq);
 
-	sc->sc_trs->asp_imr = ~0;
-	(void)sc->sc_trs->asp_irr;
 	sc->sc_trs->asp_imr = 0;
+	(void)sc->sc_trs->asp_irr;
 
 	/* Establish the interrupt register. */
 	hppa_interrupt_register_establish(ci, >sc_ir);
Index: src/sys/arch/hppa/dev/wax.c
diff -u src/sys/arch/hppa/dev/wax.c:1.1 src/sys/arch/hppa/dev/wax.c:1.2
--- src/sys/arch/hppa/dev/wax.c:1.1	Mon Feb 24 07:23:43 2014
+++ src/sys/arch/hppa/dev/wax.c	Thu May 14 06:13:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: wax.c,v 1.1 2014/02/24 07:23:43 skrll Exp $	*/
+/*	$NetBSD: wax.c,v 1.2 2020/05/14 06:13:39 skrll Exp $	*/
 
 /*	$OpenBSD: wax.c,v 1.1 1998/11/23 03:04:10 mickey Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wax.c,v 1.1 2014/02/24 07:23:43 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wax.c,v 1.2 2020/05/14 06:13:39 skrll Exp $");
 
 #include 
 #include 
@@ -139,9 +139,8 @@ waxattach(device_t parent, device_t self
 	s = splhigh();
 	sc->sc_regs->wax_iar = ci->ci_hpa | (31 - ca->ca_irq);
 	sc->sc_regs->wax_icr = 0;
-	sc->sc_regs->wax_imr = ~0U;
-	(void)sc->sc_regs->wax_irr;
 	sc->sc_regs->wax_imr = 0;
+	(void)sc->sc_regs->wax_irr;
 	splx(s);
 
 	/* Establish the interrupt register. */

Index: src/sys/arch/hppa/dev/dino.c
diff -u src/sys/arch/hppa/dev/dino.c:1.4 src/sys/arch/hppa/dev/dino.c:1.5
--- src/sys/arch/hppa/dev/dino.c:1.4	Tue Apr 16 06:45:04 2019
+++ src/sys/arch/hppa/dev/dino.c	Thu May 14 06:13:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dino.c,v 1.4 2019/04/16 06:45:04 skrll Exp $ */
+/*	$NetBSD: dino.c,v 1.5 2020/05/14 06:13:39 skrll Exp $ */
 
 /*	$OpenBSD: dino.c,v 1.5 2004/02/13 20:39:31 mickey Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.4 2019/04/16 06:45:04 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.5 2020/05/14 06:13:39 skrll Exp $");
 
 /* #include "cardbus.h" */
 
@@ -1655,9 +1655,8 @@ dinoattach(device_t parent, device_t sel
 	/* interrupts guts */
 	s = splhigh();
 	r->icr = 0;
-	r->imr = ~0;
-	(void)r->irr0;
 	r->imr = 0;
+	(void)r->irr0;
 	r->iar0 = ci->ci_hpa | (31 - ca->ca_irq);
 	splx(s);
 	/* Establish the interrupt register. */

Index: src/sys/arch/hppa/dev/lasi.c
diff -u src/sys/arch/hppa/dev/lasi.c:1.2 src/sys/arch/hppa/dev/lasi.c:1.3
--- src/sys/arch/hppa/dev/lasi.c:1.2	Mon Apr 15 20:40:37 2019
+++ src/sys/arch/hppa/dev/lasi.c	Thu May 14 06:13:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lasi.c,v 1.2 2019/04/15 20:40:37 skrll Exp $	*/
+/*	$NetBSD: lasi.c,v 1.3 2020/05/14 06:13:39 skrll Exp $	*/
 
 /*	$OpenBSD: lasi.c,v 1.4 2001/06/09 03:57:19 mickey Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lasi.c,v 1.2 2019/04/15 20:40:37 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lasi.c,v 1.3 2020/05/14 06:13:39 skrll Exp $");
 
 #undef LASIDEBUG
 
@@ -187,9 +187,8 @@ lasiattach(device_t parent, device_t sel
 	s = splhigh();
 	sc->sc_trs->lasi_iar = ci->ci_hpa | (31 - ca->ca_irq);
 	sc->sc_trs->lasi_icr = 0;
-	sc->sc_trs->lasi_imr = ~0U;
-	(void)sc->sc_trs->lasi_irr;
 	sc->sc_trs->lasi_imr = 0;
+	(void)sc->sc_trs->lasi_irr;
 
 	/* Establish the interrupt register. */
 	hppa_interrupt_register_establish(ci, >sc_ir);