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

2021-05-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 23 01:34:18 UTC 2021

Added Files:
src/sys/arch/alpha/conf: GENERIC.QEMU

Log Message:
Add a GENERIC.QEMU kernel config.  This just includes QEMU and then
sets some options specifically to make the Qemu experience a little
batter.

Currently, this just sets COPY_SYMTAB=1 (Qemu loads the kernel directly,
and does not load the symbol table).


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/alpha/conf/GENERIC.QEMU

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

Added files:

Index: src/sys/arch/alpha/conf/GENERIC.QEMU
diff -u /dev/null src/sys/arch/alpha/conf/GENERIC.QEMU:1.1
--- /dev/null	Sun May 23 01:34:18 2021
+++ src/sys/arch/alpha/conf/GENERIC.QEMU	Sun May 23 01:34:17 2021
@@ -0,0 +1,10 @@
+# $NetBSD: GENERIC.QEMU,v 1.1 2021/05/23 01:34:17 thorpej Exp $
+#
+# Generic Alpha kernel specifically configured for Qemu.
+
+include	"arch/alpha/conf/GENERIC"
+
+# reserve symbol space and copy the symbol table into it.  Needed
+# because Qemu does not load the symbol table when loading the
+# kernel.
+makeoptions	COPY_SYMTAB=1



CVS commit: src/sys/arch/alpha/alpha

2021-05-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 23 01:00:53 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: locore.s

Log Message:
Fix an error introduced in rev 1.130 where the previous pcb_onfault
handler was not restored properly in the kcopyerr case.  Also add a
comment explaining why it's save for these routines to be wrappers
around memcpy().

Fixes port-alpha/56197.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/arch/alpha/alpha/locore.s

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

Modified files:

Index: src/sys/arch/alpha/alpha/locore.s
diff -u src/sys/arch/alpha/alpha/locore.s:1.136 src/sys/arch/alpha/alpha/locore.s:1.137
--- src/sys/arch/alpha/alpha/locore.s:1.136	Sat Sep 19 01:32:16 2020
+++ src/sys/arch/alpha/alpha/locore.s	Sun May 23 01:00:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.136 2020/09/19 01:32:16 thorpej Exp $ */
+/* $NetBSD: locore.s,v 1.137 2021/05/23 01:00:53 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.136 2020/09/19 01:32:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.137 2021/05/23 01:00:53 thorpej Exp $");
 
 #include "assym.h"
 
@@ -987,6 +987,11 @@ NESTED(copyoutstr, 4, 16, ra, IM_RA|IM_S
  * kcopy() _must_ save and restore the old fault handler since it is
  * called by uiomove(), which may be in the path of servicing a non-fatal
  * page fault.
+ *
+ * N.B. This implementation is a wrapper around memcpy(), which is
+ * implemented in src/common/lib/libc/arch/alpha/string/bcopy.S.
+ * This is safe ONLY because we know that, as implemented, it is
+ * a LEAF function (and thus does not use any callee-saved registers).
  */
 NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_S1, 0)
 	LDGP(pv)
@@ -1016,10 +1021,7 @@ NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_
 
 LEAF(kcopyerr, 0)
 	LDGP(pv)
-	.set noat
-	ldq	at_reg, L_PCB(s1)		/* restore the old handler.  */
-	stq	s0, PCB_ONFAULT(at_reg)
-	.set at
+	stq	s0, PCB_ONFAULT(s1)		/* s1 == pcb (from above)*/
 	ldq	ra, (32-8)(sp)			/* restore ra.		 */
 	ldq	s0, (32-16)(sp)			/* restore s0.		 */
 	ldq	s1, (32-24)(sp)			/* restore s1.		 */



CVS commit: src/sys/uvm

2021-05-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun May 23 00:36:37 UTC 2021

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

Log Message:
avoid taking locks that aren't initialised.

fixes panic when typing 'reboot' at the askroot prompt.


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/sys/uvm/uvm_swap.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/uvm/uvm_swap.c
diff -u src/sys/uvm/uvm_swap.c:1.203 src/sys/uvm/uvm_swap.c:1.204
--- src/sys/uvm/uvm_swap.c:1.203	Sat Mar 13 15:29:55 2021
+++ src/sys/uvm/uvm_swap.c	Sun May 23 00:36:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_swap.c,v 1.203 2021/03/13 15:29:55 skrll Exp $	*/
+/*	$NetBSD: uvm_swap.c,v 1.204 2021/05/23 00:36:36 mrg Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.203 2021/03/13 15:29:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.204 2021/05/23 00:36:36 mrg Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_compat_netbsd.h"
@@ -202,6 +202,7 @@ static struct swap_priority swap_priorit
 /* locks */
 static kmutex_t uvm_swap_data_lock __cacheline_aligned;
 static krwlock_t swap_syscall_lock;
+bool uvm_swap_init_done = false;
 
 /* workqueue and use counter for swap to regular files */
 static int sw_reg_count = 0;
@@ -296,6 +297,8 @@ uvm_swap_init(void)
 	pool_init(_pool, sizeof(struct vndbuf), 0, 0, 0, "swp vnd",
 	NULL, IPL_BIO);
 
+	uvm_swap_init_done = true;
+
 	UVMHIST_LOG(pdhist, "<- done", 0, 0, 0, 0);
 }
 
@@ -1141,6 +1144,8 @@ uvm_swap_shutdown(struct lwp *l)
 	struct vnode *vp;
 	int error;
 
+	if (!uvm_swap_init_done)
+		return;
 	printf("turning off swap...");
 	rw_enter(_syscall_lock, RW_WRITER);
 	mutex_enter(_swap_data_lock);



CVS commit: src/doc

2021-05-22 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat May 22 17:20:01 UTC 2021

Modified Files:
src/doc: RESPONSIBLE

Log Message:
ossaudio too I guess


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/doc/RESPONSIBLE

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

Modified files:

Index: src/doc/RESPONSIBLE
diff -u src/doc/RESPONSIBLE:1.127 src/doc/RESPONSIBLE:1.128
--- src/doc/RESPONSIBLE:1.127	Sat May 22 17:18:57 2021
+++ src/doc/RESPONSIBLE	Sat May 22 17:20:01 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: RESPONSIBLE,v 1.127 2021/05/22 17:18:57 nia Exp $
+#	$NetBSD: RESPONSIBLE,v 1.128 2021/05/22 17:20:01 nia Exp $
 
 List of sections of the system, and who is responsible for them (or at
 least considered an expert on them).
@@ -85,6 +85,7 @@ curses		blymn, jdc
 edit		christos, jdolecek
 kerberos	lha*, joda*
 openssl		thorpej*, christos
+ossaudio	nia
 pcap		core
 pthread		nathanw*
 quota		dholland



CVS commit: src/doc

2021-05-22 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat May 22 17:18:57 UTC 2021

Modified Files:
src/doc: RESPONSIBLE

Log Message:
doc: allege responsibility


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/doc/RESPONSIBLE

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

Modified files:

Index: src/doc/RESPONSIBLE
diff -u src/doc/RESPONSIBLE:1.126 src/doc/RESPONSIBLE:1.127
--- src/doc/RESPONSIBLE:1.126	Thu Oct  1 18:34:06 2020
+++ src/doc/RESPONSIBLE	Sat May 22 17:18:57 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: RESPONSIBLE,v 1.126 2020/10/01 18:34:06 kamil Exp $
+#	$NetBSD: RESPONSIBLE,v 1.127 2021/05/22 17:18:57 nia Exp $
 
 List of sections of the system, and who is responsible for them (or at
 least considered an expert on them).
@@ -11,6 +11,7 @@ necessarily incomplete!
 
 Userland Programs:
 
+aiomixer	nia
 amd		christos
 atf		jmmv
 audioplay	mrg



CVS commit: src/sys/arch/hpcmips/vr

2021-05-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 22 16:00:42 UTC 2021

Modified Files:
src/sys/arch/hpcmips/vr: vrgiu.c

Log Message:
Be explicit about our interface attributes.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/hpcmips/vr/vrgiu.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/hpcmips/vr/vrgiu.c
diff -u src/sys/arch/hpcmips/vr/vrgiu.c:1.45 src/sys/arch/hpcmips/vr/vrgiu.c:1.46
--- src/sys/arch/hpcmips/vr/vrgiu.c:1.45	Sat Apr 24 23:36:38 2021
+++ src/sys/arch/hpcmips/vr/vrgiu.c	Sat May 22 16:00:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vrgiu.c,v 1.45 2021/04/24 23:36:38 thorpej Exp $	*/
+/*	$NetBSD: vrgiu.c,v 1.46 2021/05/22 16:00:42 thorpej Exp $	*/
 /*-
  * Copyright (c) 1999-2001
  * Shin Takemura and PocketBSD Project. All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vrgiu.c,v 1.45 2021/04/24 23:36:38 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vrgiu.c,v 1.46 2021/05/22 16:00:42 thorpej Exp $");
 
 #include 
 #include 
@@ -268,7 +268,9 @@ vrgiu_attach(device_t parent, device_t s
 	haa.haa_sc = sc;
 	haa.haa_getchip = vrgiu_getchip;
 	haa.haa_iot = sc->sc_iot;
-	while (config_found(self, , vrgiu_print, CFARG_EOL)) ;
+	while (config_found(self, , vrgiu_print,
+	CFARG_IATTR, "hpcioif",
+	CFARG_EOL)) ;
 	/*
 	 * GIU-ISA bridge
 	 */
@@ -289,7 +291,9 @@ vrgiu_callback(device_t self)
 	haa.haa_sc = sc;
 	haa.haa_getchip = vrgiu_getchip;
 	haa.haa_iot = sc->sc_iot;
-	config_found(self, , vrgiu_print, CFARG_EOL);
+	config_found(self, , vrgiu_print,
+	CFARG_IATTR, "vrisabif",
+	CFARG_EOL);
 }
 
 int



CVS commit: src/sys/arch/alpha/alpha

2021-05-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 22 15:05:37 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: autoconf.c

Log Message:
Gah, fix cut-and-paste-o.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/alpha/alpha/autoconf.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/alpha/alpha/autoconf.c
diff -u src/sys/arch/alpha/alpha/autoconf.c:1.56 src/sys/arch/alpha/alpha/autoconf.c:1.57
--- src/sys/arch/alpha/alpha/autoconf.c:1.56	Sat May 22 15:04:33 2021
+++ src/sys/arch/alpha/alpha/autoconf.c	Sat May 22 15:05:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.56 2021/05/22 15:04:33 thorpej Exp $ */
+/* $NetBSD: autoconf.c,v 1.57 2021/05/22 15:05:36 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.56 2021/05/22 15:04:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.57 2021/05/22 15:05:36 thorpej Exp $");
 
 #include "pci.h"
 
@@ -116,13 +116,6 @@ qemu_find_rootdev(void)
 		}
 	}
 
-	if (prom_qemu_getenv("rootdev", buf, sizeof(buf))) {
-		snprintf(bootinfo.booted_dev, sizeof(bootinfo.booted_dev),
-		"rootdev=%s", buf);
-		booted_device = device_find_by_xname(buf);
-		return;
-	}
-
 	const size_t devlen = strlen("/dev/");
 	const char *cp = buf;
 	char *ecp = [sizeof(buf) - 1];



CVS commit: src/sys/arch/alpha/alpha

2021-05-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 22 15:04:34 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: autoconf.c

Log Message:
qemu_find_rootdev(): Zero the buffer that we use to fetch the Qemu
"prom" root device variable; junk past the trailing NUL would cause
the way we parse the string to fail.  Also parse rootdev= and root=
the same way ("be liberal in what you accept" approach).


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/alpha/alpha/autoconf.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/alpha/alpha/autoconf.c
diff -u src/sys/arch/alpha/alpha/autoconf.c:1.55 src/sys/arch/alpha/alpha/autoconf.c:1.56
--- src/sys/arch/alpha/alpha/autoconf.c:1.55	Sat Oct  3 17:31:46 2020
+++ src/sys/arch/alpha/alpha/autoconf.c	Sat May 22 15:04:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.55 2020/10/03 17:31:46 thorpej Exp $ */
+/* $NetBSD: autoconf.c,v 1.56 2021/05/22 15:04:33 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.55 2020/10/03 17:31:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.56 2021/05/22 15:04:33 thorpej Exp $");
 
 #include "pci.h"
 
@@ -100,11 +100,22 @@ cpu_configure(void)
 static void
 qemu_find_rootdev(void)
 {
-	char buf[32];
+	char buf[32] = { 0 };
 
 	/*
 	 * Check for "rootdev=wd0".
 	 */
+	if (! prom_qemu_getenv("rootdev", buf, sizeof(buf))) {
+		/*
+		 * Check "root=/dev/wd0a", "root=/dev/hda1", etc.
+		 */
+		if (! prom_qemu_getenv("root", buf, sizeof(buf))) {
+			printf("WARNING: no rootdev= or root= arguments "
+			   "provided by Qemu\n");
+			return;
+		}
+	}
+
 	if (prom_qemu_getenv("rootdev", buf, sizeof(buf))) {
 		snprintf(bootinfo.booted_dev, sizeof(bootinfo.booted_dev),
 		"rootdev=%s", buf);
@@ -112,35 +123,26 @@ qemu_find_rootdev(void)
 		return;
 	}
 
-	/*
-	 * Check for "root=/dev/wd0a", "root=/dev/hda1", etc.
-	 */
-	if (prom_qemu_getenv("root", buf, sizeof(buf))) {
-		const size_t devlen = strlen("/dev/");
-		const char *cp = buf;
-		char *ecp = [sizeof(buf) - 1];
-
-		snprintf(bootinfo.booted_dev, sizeof(bootinfo.booted_dev),
-		"root=%s", buf);
-
-		/* Find the start of the device xname. */
-		if (strlen(cp) > devlen && strncmp(cp, "/dev/", devlen) == 0) {
-			cp += devlen;
-		}
+	const size_t devlen = strlen("/dev/");
+	const char *cp = buf;
+	char *ecp = [sizeof(buf) - 1];
+
+	/* Find the start of the device xname. */
+	if (strlen(cp) > devlen && strncmp(cp, "/dev/", devlen) == 0) {
+		cp += devlen;
+	}
 
-		/* Now strip any partition letter off the end. */
-		while (ecp != cp) {
-			if (*ecp >= '0' && *ecp <= '9') {
-break;
-			}
-			*ecp-- = '\0';
+	/* Now strip any partition letter off the end. */
+	while (ecp != cp) {
+		if (*ecp >= '0' && *ecp <= '9') {
+			break;
 		}
-
-		booted_device = device_find_by_xname(cp);
-		return;
+		*ecp-- = '\0';
 	}
 
-	printf("WARNING: no rootdev= or root= arguments provided by Qemu\n");
+	snprintf(bootinfo.booted_dev, sizeof(bootinfo.booted_dev),
+	"root=%s", cp);
+	booted_device = device_find_by_xname(cp);
 }
 
 void



CVS commit: src/sys/dev/dkwedge

2021-05-22 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May 22 13:43:50 UTC 2021

Modified Files:
src/sys/dev/dkwedge: dk.c

Log Message:
Handle read-only parent devices.

Currently this only affects xbd(4). Other disk drivers succeed opening
read-only disks as read-write and only fail subsequent write requests.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/dkwedge/dk.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/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.102 src/sys/dev/dkwedge/dk.c:1.103
--- src/sys/dev/dkwedge/dk.c:1.102	Tue Oct  6 15:05:54 2020
+++ src/sys/dev/dkwedge/dk.c	Sat May 22 13:43:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dk.c,v 1.102 2020/10/06 15:05:54 mlelstv Exp $	*/
+/*	$NetBSD: dk.c,v 1.103 2021/05/22 13:43:50 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.102 2020/10/06 15:05:54 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.103 2021/05/22 13:43:50 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -90,6 +90,7 @@ struct dkwedge_softc {
 	kcondvar_t	sc_dkdrn;
 	u_int		sc_iopend;	/* I/Os pending */
 	int		sc_flags;	/* flags (sc_iolock) */
+	int		sc_mode;	/* parent open mode */
 };
 
 #define	DK_F_WAIT_DRAIN		0x0001	/* waiting for I/O to drain */
@@ -1138,6 +1139,7 @@ dkopen(dev_t dev, int flags, int fmt, st
 	struct dkwedge_softc *sc = dkwedge_lookup(dev);
 	struct vnode *vp;
 	int error = 0;
+	int mode;
 
 	if (sc == NULL)
 		return (ENODEV);
@@ -1155,12 +1157,27 @@ dkopen(dev_t dev, int flags, int fmt, st
 	if (sc->sc_dk.dk_openmask == 0) {
 		if (sc->sc_parent->dk_rawopens == 0) {
 			KASSERT(sc->sc_parent->dk_rawvp == NULL);
-			error = dk_open_parent(sc->sc_pdev, FREAD | FWRITE, );
+			/*
+			 * Try open read-write. If this fails for EROFS
+			 * and wedge is read-only, retry to open read-only.
+			 */
+			mode = FREAD | FWRITE;
+			error = dk_open_parent(sc->sc_pdev, mode, );
+			if (error == EROFS && (flags & FWRITE) == 0) {
+mode &= ~FWRITE;
+error = dk_open_parent(sc->sc_pdev, mode, );
+			}
 			if (error)
 goto popen_fail;
+			/* remember open mode */
+			sc->sc_mode = mode;
 			sc->sc_parent->dk_rawvp = vp;
 		}
 		sc->sc_parent->dk_rawopens++;
+	} else if (flags & ~sc->sc_mode & FWRITE) {
+		/* parent is opened read-only, cannot open read-write */
+		error = EROFS;
+		goto popen_fail;
 	}
 	if (fmt == S_IFCHR)
 		sc->sc_dk.dk_copenmask |= 1;
@@ -1197,7 +1214,7 @@ dklastclose(struct dkwedge_softc *sc)
 	mutex_exit(>sc_dk.dk_openlock);
 
 	if (vp) {
-		dk_close_parent(vp, FREAD | FWRITE);
+		dk_close_parent(vp, sc->sc_mode);
 	}
 
 	return error;