Re: CVS commit: src/common/lib/libc/atomic

2022-05-13 Thread Nick Hudson

On 14/05/2022 06:35, Nick Hudson wrote:

Module Name:src
Committed By:   skrll
Date:   Sat May 14 05:35:55 UTC 2022

Modified Files:
src/common/lib/libc/atomic: atomic_c11_compare_exchange_cas_16.c
atomic_c11_compare_exchange_cas_32.c
atomic_c11_compare_exchange_cas_8.c



Commit message should have been

lib/56832: __atomic_compare_exchange[_n] is wrong on non-mainstream
platforms

Make the implementation match the documentation wrt 'expected'

This built-in function implements an atomic compare and exchange
operation.This compares the contents of *ptr with the contents of
*expected. If equal, the operation is a read-modify-write operation that
writes desired into *ptr. If they are not equal, the operation is a read
and the current contents of *ptr are written into *expected.



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

2022-05-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May 14 05:35:55 UTC 2022

Modified Files:
src/common/lib/libc/atomic: atomic_c11_compare_exchange_cas_16.c
atomic_c11_compare_exchange_cas_32.c
atomic_c11_compare_exchange_cas_8.c


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c \
src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c \
src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c

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

Modified files:

Index: src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c
diff -u src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c:1.3 src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c:1.4
--- src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c:1.3	Mon Sep  7 00:52:19 2020
+++ src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c	Sat May 14 05:35:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic_c11_compare_exchange_cas_16.c,v 1.3 2020/09/07 00:52:19 mrg Exp $	*/
+/*	$NetBSD: atomic_c11_compare_exchange_cas_16.c,v 1.4 2022/05/14 05:35:55 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -44,12 +44,17 @@ __atomic_compare_exchange_2(volatile voi
 void *expected, uint16_t desired,
 bool weak, int success, int failure)
 {
-	uint16_t old = *(uint16_t *)expected;
+	uint16_t * const ep = expected;
+	const uint16_t old = *ep;
 
 	/*
 	 * Ignore the details (weak, memory model on success and failure)
 	 * and just do the cas. If we get here the compiler couldn't
 	 * do better and it mostly will not matter at all.
 	 */
-	return atomic_cas_16(mem, old, desired) == old;
+	const uint16_t prev = atomic_cas_16(mem, old, desired);
+	if (prev == old)
+		return true;
+	*ep = prev;
+	return false;
 }
Index: src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c
diff -u src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c:1.3 src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c:1.4
--- src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c:1.3	Mon Sep  7 00:52:19 2020
+++ src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c	Sat May 14 05:35:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic_c11_compare_exchange_cas_32.c,v 1.3 2020/09/07 00:52:19 mrg Exp $	*/
+/*	$NetBSD: atomic_c11_compare_exchange_cas_32.c,v 1.4 2022/05/14 05:35:55 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -44,12 +44,17 @@ __atomic_compare_exchange_4(volatile voi
 void *expected, uint32_t desired,
 bool weak, int success, int failure)
 {
-	uint32_t old = *(uint32_t *)expected;
+	uint32_t * const ep = expected;
+	const uint32_t old = *ep;
 
 	/*
 	 * Ignore the details (weak, memory model on success and failure)
 	 * and just do the cas. If we get here the compiler couldn't
 	 * do better and it mostly will not matter at all.
 	 */
-	return atomic_cas_32(mem, old, desired) == old;
+	const uint32_t prev = atomic_cas_8(mem, old, desired);
+	if (prev == old)
+		return true;
+	*ep = prev;
+	return false;
 }
Index: src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c
diff -u src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c:1.3 src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c:1.4
--- src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c:1.3	Mon Sep  7 00:52:19 2020
+++ src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c	Sat May 14 05:35:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic_c11_compare_exchange_cas_8.c,v 1.3 2020/09/07 00:52:19 mrg Exp $	*/
+/*	$NetBSD: atomic_c11_compare_exchange_cas_8.c,v 1.4 2022/05/14 05:35:55 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -44,12 +44,17 @@ __atomic_compare_exchange_1(volatile voi
 void *expected, uint8_t desired,
 bool weak, int success, int failure)
 {
-	uint8_t old = *(uint8_t *)expected;
+	uint8_t * const ep = expected;
+	const uint8_t old = *ep;
 
 	/*
 	 * Ignore the details (weak, memory model on success and failure)
 	 * and just do the cas. If we get here the compiler couldn't
 	 * do better and it mostly will not matter at all.
 	 */
-	return atomic_cas_8(mem, old, desired) == old;
+	const uint8_t prev = atomic_cas_8(mem, old, desired);
+	if (prev == old)
+		return true;
+	*ep = prev;
+	return false;
 }



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

2022-05-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May 14 05:35:55 UTC 2022

Modified Files:
src/common/lib/libc/atomic: atomic_c11_compare_exchange_cas_16.c
atomic_c11_compare_exchange_cas_32.c
atomic_c11_compare_exchange_cas_8.c


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c \
src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c \
src/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c

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



CVS commit: src/sys/dev/pci

2022-05-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May 14 04:04:55 UTC 2022

Modified Files:
src/sys/dev/pci: ahcisata_pci.c

Log Message:
Apply extra-delay quirk to "Intel 9 Series SATA Controller (AHCI)";
without the quirk, the controller fails to probe some HDD models,
at least "Seagate ST2000DM008".

Info and patch provided by Tiago Seco, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/pci/ahcisata_pci.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/pci/ahcisata_pci.c
diff -u src/sys/dev/pci/ahcisata_pci.c:1.61 src/sys/dev/pci/ahcisata_pci.c:1.62
--- src/sys/dev/pci/ahcisata_pci.c:1.61	Fri Nov 19 23:46:55 2021
+++ src/sys/dev/pci/ahcisata_pci.c	Sat May 14 04:04:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_pci.c,v 1.61 2021/11/19 23:46:55 rin Exp $	*/
+/*	$NetBSD: ahcisata_pci.c,v 1.62 2022/05/14 04:04:55 rin Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.61 2021/11/19 23:46:55 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.62 2022/05/14 04:04:55 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ahcisata_pci.h"
@@ -206,6 +206,8 @@ static const struct ahci_pci_quirk ahci_
 	AHCI_QUIRK_BADPMP },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_AHCI,
 	AHCI_QUIRK_EXTRA_DELAY },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_9SERIES_SATA_AHCI,
+	AHCI_QUIRK_EXTRA_DELAY },
 #if 0
 	/*
 	 * XXX Non-reproducible failures reported. May need extra-delay quirk.



CVS commit: src/sys/dev/pci

2022-05-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May 14 04:04:55 UTC 2022

Modified Files:
src/sys/dev/pci: ahcisata_pci.c

Log Message:
Apply extra-delay quirk to "Intel 9 Series SATA Controller (AHCI)";
without the quirk, the controller fails to probe some HDD models,
at least "Seagate ST2000DM008".

Info and patch provided by Tiago Seco, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/pci/ahcisata_pci.c

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



CVS commit: src/sys/dev/adb

2022-05-13 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sat May 14 01:16:55 UTC 2022

Modified Files:
src/sys/dev/adb: adb_kbd.c adb_keymap.h adb_usb_map.c

Log Message:
Add ISO and JIS keyboard layouts for ADB to USB emulation

The layout is configurable using sysctl machdep.adbkbdX.emulate_usb:
0 = no emulation
1 = ANSI
2 = ISO (new with this change)
3 = JIS (new with this change)

Default value is detected using the ADB keyboard handler id. JIS
default is disabled until it is tested.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/adb/adb_kbd.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/adb/adb_keymap.h
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/adb/adb_usb_map.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/adb/adb_kbd.c
diff -u src/sys/dev/adb/adb_kbd.c:1.32 src/sys/dev/adb/adb_kbd.c:1.33
--- src/sys/dev/adb/adb_kbd.c:1.32	Sat Aug  7 16:19:09 2021
+++ src/sys/dev/adb/adb_kbd.c	Sat May 14 01:16:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: adb_kbd.c,v 1.32 2021/08/07 16:19:09 thorpej Exp $	*/
+/*	$NetBSD: adb_kbd.c,v 1.33 2022/05/14 01:16:55 manu Exp $	*/
 
 /*
  * Copyright (C) 1998	Colin Wood
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.32 2021/08/07 16:19:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.33 2022/05/14 01:16:55 manu Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -93,7 +93,7 @@ struct adbkbd_softc {
 #ifdef WSDISPLAY_COMPAT_RAWKBD
 	int sc_rawkbd;
 #endif
-	bool sc_emul_usb;
+	int sc_emul_usb;
 	bool sc_power_dbg;
 
 	uint32_t sc_power;
@@ -235,7 +235,7 @@ adbkbd_attach(device_t parent, device_t 
 	 */
 	sc->sc_power = 0x;
 	sc->sc_timestamp = 0;
-	sc->sc_emul_usb = FALSE;
+	sc->sc_emul_usb = ADB_EMUL_USB_NONE;
 #ifdef ADBKBD_POWER_DDB
 	sc->sc_power_dbg = TRUE;
 #else
@@ -386,8 +386,56 @@ adbkbd_attach(device_t parent, device_t 
 	sc->sc_wskbddev = config_found(self, , wskbddevprint,
 	CFARGS(.iattr = "wskbddev"));
 #ifdef ADBKBD_EMUL_USB
-	sc->sc_emul_usb = TRUE;
-	wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb, 128);
+	/* Values from Linux's drivers/macintosh/adbhud.c */
+switch (sc->sc_adbdev->handler_id) {
+	case ADB_ISOKBD:	/* FALLTHROUGH */
+	case ADB_EXTISOKBD:	/* FALLTHROUGH */
+	case 0x07:		/* FALLTHROUGH */
+	case ADB_ISOKBDII:	/* FALLTHROUGH */
+	case ADB_PBISOKBD:	/* FALLTHROUGH */
+	case ADB_ADJISOKBD:	/* FALLTHROUGH */
+	case ADB_PBEXTISOKBD:	/* FALLTHROUGH */
+	case 0x19:		/* FALLTHROUGH */
+	case 0x1d:		/* FALLTHROUGH */
+	case 0xc1:		/* FALLTHROUGH */
+	case ADB_IBOOKKBD:	/* FALLTHROUGH */
+	case 0xc7:
+		sc->sc_emul_usb = ADB_EMUL_USB_ISO;
+		wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb_iso, 128);
+		break;
+#ifdef notyet
+	case ADB_ADJJAPKBD:	/* FALLTHROUGH */
+	case ADB_PBEXTJAPKBD:	/* FALLTHROUGH */
+	case ADB_JPKBDII:	/* FALLTHROUGH */
+	case 0x17:		/* FALLTHROUGH */
+	case 0x1a:		/* FALLTHROUGH */
+	case ADB_PBJPKBD:	/* FALLTHROUGH */
+	case 0xc2:		/* FALLTHROUGH */
+	case 0xc5:		/* FALLTHROUGH */
+	case 0xc8:		/* FALLTHROUGH */
+	case 0xc9:
+		sc->sc_emul_usb = ADB_EMUL_USB_JIS;
+		wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb_jis, 128);
+		break;
+#endif
+	case ADB_STDKBD:	/* FALLTHROUGH */
+	case ADB_EXTKBD:	/* FALLTHROUGH */
+	case 0x03:		/* FALLTHROUGH */
+	case 0x06:		/* FALLTHROUGH */
+	case ADB_KBDII:		/* FALLTHROUGH */
+	case ADB_PBKBD:		/* FALLTHROUGH */
+	case ADB_ADJKBD:	/* FALLTHROUGH */
+	case ADB_PBEXTKBD:	/* FALLTHROUGH */
+	case ADB_DESIGNKBD:	/* FALLTHROUGH */
+	case 0x1c:		/* FALLTHROUGH */
+	case 0xc0:		/* FALLTHROUGH */
+	case ADB_PBG3KBD:	/* FALLTHROUGH */
+	case 0xc6:		/* FALLTHROUGH */
+	default:	/* default to ANSI for unknown values */
+		sc->sc_emul_usb = ADB_EMUL_USB_ANSI;
+		wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb_ansi, 128);
+		break;
+	}
 #endif /* ADBKBD_EMUL_USB */
 
 #if NWSMOUSE > 0
@@ -633,7 +681,7 @@ adbkbd_ioctl(void *v, u_long cmd, void *
 	switch (cmd) {
 
 	case WSKBDIO_GTYPE:
-		if (sc->sc_emul_usb) {
+		if (sc->sc_emul_usb != ADB_EMUL_USB_NONE) {
 			*(int *)data = WSKBD_TYPE_USB;
 		} else {
 			*(int *)data = WSKBD_TYPE_ADB;
@@ -798,7 +846,7 @@ adbkbd_sysctl_usb(SYSCTLFN_ARGS)
 	struct sysctlnode node = *rnode;
 	struct adbkbd_softc *sc=(struct adbkbd_softc *)node.sysctl_data;
 	const int *np = newp;
-	bool reg;
+	int reg;
 
 	DPRINTF("%s\n", __func__);
 	reg = sc->sc_emul_usb;
@@ -807,12 +855,26 @@ adbkbd_sysctl_usb(SYSCTLFN_ARGS)
 		node.sysctl_data = 
 		if (sysctl_lookup(SYSCTLFN_CALL()) == 0) {
 			
-			sc->sc_emul_usb = *(bool *)node.sysctl_data;
-			if (sc->sc_emul_usb) {
-wskbd_set_evtrans(sc->sc_wskbddev,
-adb_to_usb, 128);
-			} else {
+			sc->sc_emul_usb = *(int *)node.sysctl_data;
+			switch (sc->sc_emul_usb) {
+			case ADB_EMUL_USB_NONE:
 wskbd_set_evtrans(sc->sc_wskbddev, NULL, 0);
+break;
+			case ADB_EMUL_USB_ANSI:
+wskbd_set_evtrans(sc->sc_wskbddev,
+adb_to_usb_ansi, 128);
+	

CVS commit: src/sys/dev/adb

2022-05-13 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Sat May 14 01:16:55 UTC 2022

Modified Files:
src/sys/dev/adb: adb_kbd.c adb_keymap.h adb_usb_map.c

Log Message:
Add ISO and JIS keyboard layouts for ADB to USB emulation

The layout is configurable using sysctl machdep.adbkbdX.emulate_usb:
0 = no emulation
1 = ANSI
2 = ISO (new with this change)
3 = JIS (new with this change)

Default value is detected using the ADB keyboard handler id. JIS
default is disabled until it is tested.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/adb/adb_kbd.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/adb/adb_keymap.h
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/adb/adb_usb_map.c

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



CVS commit: src/usr.bin/make

2022-05-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri May 13 21:42:30 UTC 2022

Modified Files:
src/usr.bin/make: str.c

Log Message:
make: document platform dependency in string pattern matching

No unit test for this edge case since all other unit tests are platform-
independent.

To reproduce:
$ make clean
$ make -s PROG=s-make NOMAN=yes USER_CFLAGS=-fsigned-char
$ make clean
$ make -s PROG=u-make NOMAN=yes USER_CFLAGS=-funsigned-char
$ make clean
$ range=$(lua -e 'print(("[%c-%c]"):format(0xe4, 0x61))')
$ ./s-make -V "\${:UM:M$range}\${:UN:N$range}"
M
$ ./u-make -V "\${:UM:M$range}\${:UN:N$range}"
N


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/make/str.c

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

Modified files:

Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.90 src/usr.bin/make/str.c:1.91
--- src/usr.bin/make/str.c:1.90	Fri May 13 20:37:01 2022
+++ src/usr.bin/make/str.c	Fri May 13 21:42:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.90 2022/05/13 20:37:01 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.91 2022/05/13 21:42:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
 #include "make.h"
 
 /*	"@(#)str.c	5.8 (Berkeley) 6/1/90"	*/
-MAKE_RCSID("$NetBSD: str.c,v 1.90 2022/05/13 20:37:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.91 2022/05/13 21:42:30 rillig Exp $");
 
 
 static HashTable interned_strings;
@@ -293,6 +293,26 @@ Str_Words(const char *str, bool expand)
 }
 
 /*
+ * XXX: In the extreme edge case that one of the characters is from the basic
+ * execution character set and the other isn't, the result of the comparison
+ * differs depending on whether plain char is signed or unsigned.
+ *
+ * An example is the character range from \xE4 to 'a', where \xE4 may come
+ * from U+00E4 'Latin small letter A with diaeresis'.
+ *
+ * If char is signed, \xE4 evaluates to -28, the first half of the condition
+ * becomes -28 <= '0' && '0' <= 'a', which evaluates to true.
+ *
+ * If char is unsigned, \xE4 evaluates to 228, the second half of the
+ * condition becomes 'a' <= '0' && '0' <= 228, which evaluates to false.
+ */
+static bool
+in_range(char e1, char c, char e2)
+{
+	return (e1 <= c && c <= e2) || (e2 <= c && c <= e1);
+}
+
+/*
  * Str_Match -- Test if a string matches a pattern like "*.[ch]".
  * The following special characters are known *?\[] (as in fnmatch(3)).
  *
@@ -355,9 +375,7 @@ Str_Match(const char *str, const char *p
 if (pat[1] == '-') {
 	if (pat[2] == '\0')
 		return neg;
-	if (pat[0] <= *str && *str <= pat[2])
-		break;
-	if (pat[2] <= *str && *str <= pat[0])
+	if (in_range(pat[0], *str, pat[2]))
 		break;
 	pat += 2;
 }



CVS commit: src/usr.bin/make

2022-05-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri May 13 21:42:30 UTC 2022

Modified Files:
src/usr.bin/make: str.c

Log Message:
make: document platform dependency in string pattern matching

No unit test for this edge case since all other unit tests are platform-
independent.

To reproduce:
$ make clean
$ make -s PROG=s-make NOMAN=yes USER_CFLAGS=-fsigned-char
$ make clean
$ make -s PROG=u-make NOMAN=yes USER_CFLAGS=-funsigned-char
$ make clean
$ range=$(lua -e 'print(("[%c-%c]"):format(0xe4, 0x61))')
$ ./s-make -V "\${:UM:M$range}\${:UN:N$range}"
M
$ ./u-make -V "\${:UM:M$range}\${:UN:N$range}"
N


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/make/str.c

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



CVS commit: src/usr.bin/make

2022-05-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri May 13 20:37:01 UTC 2022

Modified Files:
src/usr.bin/make: str.c

Log Message:
make: clean up low-level comments, eliminate common subexpression

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/make/str.c

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

Modified files:

Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.89 src/usr.bin/make/str.c:1.90
--- src/usr.bin/make/str.c:1.89	Thu Mar  3 19:50:01 2022
+++ src/usr.bin/make/str.c	Fri May 13 20:37:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.89 2022/03/03 19:50:01 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.90 2022/05/13 20:37:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
 #include "make.h"
 
 /*	"@(#)str.c	5.8 (Berkeley) 6/1/90"	*/
-MAKE_RCSID("$NetBSD: str.c,v 1.89 2022/03/03 19:50:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.90 2022/05/13 20:37:01 rillig Exp $");
 
 
 static HashTable interned_strings;
@@ -302,34 +302,25 @@ bool
 Str_Match(const char *str, const char *pat)
 {
 	for (;;) {
-		/*
-		 * See if we're at the end of both the pattern and the
-		 * string. If so, we succeeded.  If we're at the end of the
-		 * pattern but not at the end of the string, we failed.
-		 */
 		if (*pat == '\0')
 			return *str == '\0';
-		if (*str == '\0' && *pat != '*')
-			return false;
 
-		/*
-		 * A '*' in the pattern matches any substring.  We handle this
-		 * by calling ourselves for each suffix of the string.
-		 */
+		/* A '*' in the pattern matches any substring. */
 		if (*pat == '*') {
 			pat++;
 			while (*pat == '*')
 pat++;
 			if (*pat == '\0')
 return true;
-			while (*str != '\0') {
+			for (; *str != '\0'; str++)
 if (Str_Match(str, pat))
 	return true;
-str++;
-			}
 			return false;
 		}
 
+		if (*str == '\0')
+			return false;
+
 		/* A '?' in the pattern matches any single character. */
 		if (*pat == '?')
 			goto thisCharOK;



CVS commit: src/usr.bin/make

2022-05-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri May 13 20:37:01 UTC 2022

Modified Files:
src/usr.bin/make: str.c

Log Message:
make: clean up low-level comments, eliminate common subexpression

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/make/str.c

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



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

2022-05-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri May 13 19:34:47 UTC 2022

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

Log Message:
nvmm_x86_vmx.c: remove an #ifdef DIAGNOSTIC, it is wrong since r1.66


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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

Modified files:

Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.82 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.83
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.82	Fri Mar 26 15:59:53 2021
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Fri May 13 19:34:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.82 2021/03/26 15:59:53 reinoud Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.83 2022/05/13 19:34:47 tnn Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.82 2021/03/26 15:59:53 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.83 2022/05/13 19:34:47 tnn Exp $");
 
 #include 
 #include 
@@ -134,7 +134,6 @@ vmx_vmwrite(uint64_t field, uint64_t val
 	);
 }
 
-#ifdef DIAGNOSTIC
 static inline paddr_t
 vmx_vmptrst(void)
 {
@@ -149,7 +148,6 @@ vmx_vmptrst(void)
 
 	return pa;
 }
-#endif
 
 static inline void
 vmx_vmptrld(paddr_t *pa)



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

2022-05-13 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri May 13 19:34:47 UTC 2022

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

Log Message:
nvmm_x86_vmx.c: remove an #ifdef DIAGNOSTIC, it is wrong since r1.66


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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



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

2022-05-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri May 13 18:40:03 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa: hppa_machdep.c

Log Message:
port-hppa/56830: RAS support is slightly incorrect on hppa

When searching for RAS use tf_iioq_head without the HPPA_PC_PRIV_MASK bits
set.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/hppa/hppa/hppa_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/hppa/hppa/hppa_machdep.c
diff -u src/sys/arch/hppa/hppa/hppa_machdep.c:1.32 src/sys/arch/hppa/hppa/hppa_machdep.c:1.33
--- src/sys/arch/hppa/hppa/hppa_machdep.c:1.32	Sun Aug 22 20:18:39 2021
+++ src/sys/arch/hppa/hppa/hppa_machdep.c	Fri May 13 18:40:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hppa_machdep.c,v 1.32 2021/08/22 20:18:39 andvar Exp $	*/
+/*	$NetBSD: hppa_machdep.c,v 1.33 2022/05/13 18:40:02 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.32 2021/08/22 20:18:39 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.33 2022/05/13 18:40:02 skrll Exp $");
 
 #include 
 #include 
@@ -279,7 +279,9 @@ hppa_ras(struct lwp *l)
 
 	p = l->l_proc;
 	tf = l->l_md.md_regs;
-	rasaddr = (intptr_t)ras_lookup(p, (void *)tf->tf_iioq_head);
+
+	rasaddr = (intptr_t)ras_lookup(p,
+	(void *)(tf->tf_iioq_head & ~HPPA_PC_PRIV_MASK));
 	if (rasaddr != -1) {
 		rasaddr |= HPPA_PC_PRIV_USER;
 		tf->tf_iioq_head = rasaddr;



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

2022-05-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri May 13 18:40:03 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa: hppa_machdep.c

Log Message:
port-hppa/56830: RAS support is slightly incorrect on hppa

When searching for RAS use tf_iioq_head without the HPPA_PC_PRIV_MASK bits
set.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/hppa/hppa/hppa_machdep.c

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



CVS commit: src

2022-05-13 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Fri May 13 16:39:33 UTC 2022

Modified Files:
src/distrib/sets/lists/base: mi
src/distrib/sets/lists/man: mi
src/external/mpl/bind/bin/confgen/ddns-confgen: Makefile

Log Message:
Add LINKS and MLINKS to the ddns-confgen Makefile to provide
tsig-keygen.  This helps to allow pkgsrc/security/acmesh to function
and should be provided in all BIND >= 9.13 installs anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.1294 -r1.1295 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.1738 -r1.1739 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.1 -r1.2 \
src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile

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



CVS commit: src

2022-05-13 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Fri May 13 16:39:33 UTC 2022

Modified Files:
src/distrib/sets/lists/base: mi
src/distrib/sets/lists/man: mi
src/external/mpl/bind/bin/confgen/ddns-confgen: Makefile

Log Message:
Add LINKS and MLINKS to the ddns-confgen Makefile to provide
tsig-keygen.  This helps to allow pkgsrc/security/acmesh to function
and should be provided in all BIND >= 9.13 installs anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.1294 -r1.1295 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.1738 -r1.1739 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.1 -r1.2 \
src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile

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

Modified files:

Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.1294 src/distrib/sets/lists/base/mi:1.1295
--- src/distrib/sets/lists/base/mi:1.1294	Mon Apr 25 02:29:13 2022
+++ src/distrib/sets/lists/base/mi	Fri May 13 16:39:32 2022
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1294 2022/04/25 02:29:13 gutteridge Exp $
+# $NetBSD: mi,v 1.1295 2022/05/13 16:39:32 brad Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -1955,6 +1955,7 @@
 ./usr/sbin/traceroute6base-netutil-bin	use_inet6
 ./usr/sbin/trpt	base-netutil-bin
 ./usr/sbin/trsp	base-obsolete		obsolete
+./usr/sbin/tsig-keygenbase-bind-bin
 ./usr/sbin/unboundbase-netutil-bin	unbound
 ./usr/sbin/unbound-anchor			base-netutil-bin	unbound
 ./usr/sbin/unbound-checkconf			base-netutil-bin	unbound

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1738 src/distrib/sets/lists/man/mi:1.1739
--- src/distrib/sets/lists/man/mi:1.1738	Wed Apr  6 14:20:07 2022
+++ src/distrib/sets/lists/man/mi	Fri May 13 16:39:33 2022
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1738 2022/04/06 14:20:07 reinoud Exp $
+# $NetBSD: mi,v 1.1739 2022/05/13 16:39:33 brad Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3255,6 +3255,7 @@
 ./usr/share/man/cat8/trivial-rewrite.0	man-postfix-catman	postfix,.cat
 ./usr/share/man/cat8/trpt.0			man-netutil-catman	.cat
 ./usr/share/man/cat8/trsp.0			man-obsolete		obsolete
+./usr/share/man/cat8/tsig-keygen.0		man-bind-catman		.cat
 ./usr/share/man/cat8/ttyflags.0			man-sysutil-catman	.cat
 ./usr/share/man/cat8/tunefs.0			man-sysutil-catman	.cat
 ./usr/share/man/cat8/umbctl.0			man-netutil-catman	.cat
@@ -6222,6 +6223,7 @@
 ./usr/share/man/html8/traceroute6.html		man-netutil-htmlman	use_inet6,html
 ./usr/share/man/html8/trivial-rewrite.html	man-postfix-htmlman	postfix,html
 ./usr/share/man/html8/trpt.html			man-netutil-htmlman	html
+./usr/share/man/html8/tsig-keygen.html		man-bind-htmlman	html
 ./usr/share/man/html8/ttyflags.html		man-sysutil-htmlman	html
 ./usr/share/man/html8/tunefs.html		man-sysutil-htmlman	html
 ./usr/share/man/html8/umbctl.html		man-netutil-htmlman	html
@@ -9536,6 +9538,7 @@
 ./usr/share/man/man8/trivial-rewrite.8		man-postfix-man		postfix,.man
 ./usr/share/man/man8/trpt.8			man-netutil-man		.man
 ./usr/share/man/man8/trsp.8			man-obsolete		obsolete
+./usr/share/man/man8/tsig-keygen.8		man-bind-man		.man
 ./usr/share/man/man8/ttyflags.8			man-sysutil-man		.man
 ./usr/share/man/man8/tunefs.8			man-sysutil-man		.man
 ./usr/share/man/man8/umbctl.8			man-netutil-man		.man

Index: src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile
diff -u src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile:1.1 src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile:1.2
--- src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile:1.1	Sun Aug 12 13:02:24 2018
+++ src/external/mpl/bind/bin/confgen/ddns-confgen/Makefile	Fri May 13 16:39:32 2022
@@ -1,5 +1,8 @@
-#	$NetBSD: Makefile,v 1.1 2018/08/12 13:02:24 christos Exp $
+#	$NetBSD: Makefile,v 1.2 2022/05/13 16:39:32 brad Exp $
 
 .include "${.PARSEDIR}/../Makefile.inc"
 
+LINKS=	${BINDIR}/ddns-confgen ${BINDIR}/tsig-keygen
+MLINKS=	ddns-confgen.8 tsig-keygen.8
+
 .include 



CVS commit: src/sys/ufs/ffs

2022-05-13 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 13 15:02:34 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
Fix typo dallocate -> deallocate


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/ufs/ffs/ffs_wapbl.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/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.46 src/sys/ufs/ffs/ffs_wapbl.c:1.47
--- src/sys/ufs/ffs/ffs_wapbl.c:1.46	Sat Apr 11 17:43:54 2020
+++ src/sys/ufs/ffs/ffs_wapbl.c	Fri May 13 15:02:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.46 2020/04/11 17:43:54 jdolecek Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.47 2022/05/13 15:02:34 reinoud Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.46 2020/04/11 17:43:54 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.47 2022/05/13 15:02:34 reinoud Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -146,7 +146,7 @@ ffs_wapbl_replay_finish(struct mount *mp
 		 * The journal may have left partially allocated inodes in mode
 		 * zero.  This may occur if a crash occurs betweeen the node
 		 * allocation in ffs_nodeallocg and when the node is properly
-		 * initialized in ufs_makeinode.  If so, just dallocate them.
+		 * initialized in ufs_makeinode.  If so, just deallocate them.
 		 */
 		if (ip->i_mode == 0) {
 			error = UFS_WAPBL_BEGIN(mp);



CVS commit: src/sys/ufs/ffs

2022-05-13 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 13 15:02:34 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
Fix typo dallocate -> deallocate


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/ufs/ffs/ffs_wapbl.c

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



CVS commit: [netbsd-9] src/doc

2022-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 13 11:20:04 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Tickets #1443 - #1445


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.89 -r1.1.2.90 src/doc/CHANGES-9.3

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-9.3
diff -u src/doc/CHANGES-9.3:1.1.2.89 src/doc/CHANGES-9.3:1.1.2.90
--- src/doc/CHANGES-9.3:1.1.2.89	Wed May  4 17:52:41 2022
+++ src/doc/CHANGES-9.3	Fri May 13 11:20:04 2022
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.3,v 1.1.2.89 2022/05/04 17:52:41 martin Exp $
+# $NetBSD: CHANGES-9.3,v 1.1.2.90 2022/05/13 11:20:04 martin Exp $
 
 A complete list of changes from the NetBSD 9.2 release to the NetBSD 9.3
 release:
@@ -1572,3 +1572,21 @@ sys/nfs/nfs_vfsops.c1.243
 	nfs: fix file size limit.
 	[gavan, ticket #1441]
 
+sys/arch/x86/x86/pmap.c1.414
+
+	Xen performance improvement for zeroing pages.
+	[bouyer, ticket #1443]
+
+sys/arch/xen/x86/x86_xpmap.c			1.91
+
+	Xen: in bootstrap, after switching to a new page table make sure that
+	now-unused memory is unmapped.
+	[bouyer, ticket #1444]
+
+sys/dev/pci/ixgbe/ix_txrx.c			1.98
+
+	ixg(4): fix dma memory unmap/free error that could cause
+	kernel panics, like "panic: HYPERVISOR_mmu_update failed"
+	as seen on Xen.
+	[bouyer, ticket #1445]
+



CVS commit: [netbsd-9] src/doc

2022-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 13 11:20:04 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Tickets #1443 - #1445


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.89 -r1.1.2.90 src/doc/CHANGES-9.3

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



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2022-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 13 11:18:40 UTC 2022

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ix_txrx.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1445):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.98

bus_dmamem_unmap() before bus_dmamem_free(), otherwise we may give back meomry
which is still (and will stay) mapped.

Fixes one instance of "panic: HYPERVISOR_mmu_update failed" on Xen.
There may be others.


To generate a diff of this commit:
cvs rdiff -u -r1.54.2.8 -r1.54.2.9 src/sys/dev/pci/ixgbe/ix_txrx.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/pci/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.8 src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.9
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.8	Wed Feb  2 14:25:49 2022
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Fri May 13 11:18:40 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.54.2.8 2022/02/02 14:25:49 martin Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.54.2.9 2022/05/13 11:18:40 martin Exp $ */
 
 /**
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.54.2.8 2022/02/02 14:25:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.54.2.9 2022/05/13 11:18:40 martin Exp $");
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -2321,6 +2321,7 @@ ixgbe_dma_free(struct adapter *adapter, 
 	bus_dmamap_sync(dma->dma_tag->dt_dmat, dma->dma_map, 0, dma->dma_size,
 	BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 	ixgbe_dmamap_unload(dma->dma_tag, dma->dma_map);
+	bus_dmamem_unmap(dma->dma_tag->dt_dmat, dma->dma_vaddr, dma->dma_size);
 	bus_dmamem_free(dma->dma_tag->dt_dmat, >dma_seg, 1);
 	ixgbe_dma_tag_destroy(dma->dma_tag);
 } /* ixgbe_dma_free */



CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe

2022-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 13 11:18:40 UTC 2022

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-9]: ix_txrx.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1445):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.98

bus_dmamem_unmap() before bus_dmamem_free(), otherwise we may give back meomry
which is still (and will stay) mapped.

Fixes one instance of "panic: HYPERVISOR_mmu_update failed" on Xen.
There may be others.


To generate a diff of this commit:
cvs rdiff -u -r1.54.2.8 -r1.54.2.9 src/sys/dev/pci/ixgbe/ix_txrx.c

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



CVS commit: [netbsd-9] src/sys/arch/xen/x86

2022-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 13 11:12:49 UTC 2022

Modified Files:
src/sys/arch/xen/x86 [netbsd-9]: x86_xpmap.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1444):

sys/arch/xen/x86/x86_xpmap.c: revision 1.91

In bootstrap, after switching to a new page table make sure that
now-unused memory is unmapped.


To generate a diff of this commit:
cvs rdiff -u -r1.84.4.1 -r1.84.4.2 src/sys/arch/xen/x86/x86_xpmap.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/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.84.4.1 src/sys/arch/xen/x86/x86_xpmap.c:1.84.4.2
--- src/sys/arch/xen/x86/x86_xpmap.c:1.84.4.1	Sun May 31 10:39:34 2020
+++ src/sys/arch/xen/x86/x86_xpmap.c	Fri May 13 11:12:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.84.4.1 2020/05/31 10:39:34 martin Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.84.4.2 2022/05/13 11:12:49 martin Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.84.4.1 2020/05/31 10:39:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.84.4.2 2022/05/13 11:12:49 martin Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -909,7 +909,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 	/* Unpin old PGD */
 	xpq_queue_unpin_table(xpmap_ptom_masked(old_pgd - KERNBASE));
 
-	/* Mark old tables RW */
+	/* Mark old tables RW if used, unmap otherwise */
 	page = old_pgd;
 	addr = xpmap_mtop((paddr_t)L2[pl2_pi(page)] & PG_FRAME);
 	pte = (pd_entry_t *)((u_long)addr + KERNBASE);
@@ -923,6 +923,12 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 		 */
 		pte++;
 	}
+	while (page < old_pgd + (old_count * PAGE_SIZE)) {
+		addr = xpmap_ptom(((u_long)pte) - KERNBASE);
+		xpq_queue_pte_update(addr, 0);
+		page += PAGE_SIZE;
+		pte++;
+	}
 	xpq_flush_queue();
 }
 



CVS commit: [netbsd-9] src/sys/arch/xen/x86

2022-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 13 11:12:49 UTC 2022

Modified Files:
src/sys/arch/xen/x86 [netbsd-9]: x86_xpmap.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1444):

sys/arch/xen/x86/x86_xpmap.c: revision 1.91

In bootstrap, after switching to a new page table make sure that
now-unused memory is unmapped.


To generate a diff of this commit:
cvs rdiff -u -r1.84.4.1 -r1.84.4.2 src/sys/arch/xen/x86/x86_xpmap.c

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



CVS commit: [netbsd-9] src/sys/arch/x86/x86

2022-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 13 11:10:38 UTC 2022

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: pmap.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1443):

sys/arch/x86/x86/pmap.c: revision 1.414

return after calling xen_pagezero(), don't fall back to the legacy
pmap_zero_page() method.

This should only affect performances.


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.6 -r1.334.2.7 src/sys/arch/x86/x86/pmap.c

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



CVS commit: [netbsd-9] src/sys/arch/x86/x86

2022-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 13 11:10:38 UTC 2022

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: pmap.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1443):

sys/arch/x86/x86/pmap.c: revision 1.414

return after calling xen_pagezero(), don't fall back to the legacy
pmap_zero_page() method.

This should only affect performances.


To generate a diff of this commit:
cvs rdiff -u -r1.334.2.6 -r1.334.2.7 src/sys/arch/x86/x86/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/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.334.2.6 src/sys/arch/x86/x86/pmap.c:1.334.2.7
--- src/sys/arch/x86/x86/pmap.c:1.334.2.6	Fri Sep  3 10:27:33 2021
+++ src/sys/arch/x86/x86/pmap.c	Fri May 13 11:10:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.334.2.6 2021/09/03 10:27:33 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.334.2.7 2022/05/13 11:10:38 martin Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.6 2021/09/03 10:27:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.334.2.7 2022/05/13 11:10:38 martin Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -3187,8 +3187,10 @@ pmap_zero_page(paddr_t pa)
 	pagezero(PMAP_DIRECT_MAP(pa));
 #else
 #if defined(XENPV)
-	if (XEN_VERSION_SUPPORTED(3, 4))
+	if (XEN_VERSION_SUPPORTED(3, 4)) {
 		xen_pagezero(pa);
+		return;
+	}
 #endif
 	struct cpu_info *ci;
 	pt_entry_t *zpte;



CVS commit: src/sys/arch

2022-05-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May 13 10:45:24 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: ALL
src/sys/arch/i386/conf: ALL

Log Message:
Add MFI_DEBUG and MFII_DEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.500 -r1.501 src/sys/arch/i386/conf/ALL

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/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.170 src/sys/arch/amd64/conf/ALL:1.171
--- src/sys/arch/amd64/conf/ALL:1.170	Sat May  7 04:32:29 2022
+++ src/sys/arch/amd64/conf/ALL	Fri May 13 10:45:24 2022
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.170 2022/05/07 04:32:29 rin Exp $
+# $NetBSD: ALL,v 1.171 2022/05/13 10:45:24 msaitoh Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.170 $"
+#ident		"ALL-$Revision: 1.171 $"
 
 maxusers	64		# estimated number of users
 
@@ -2026,6 +2026,8 @@ options MEC_DEBUG
 options MEDIABAY_DEBUG
 options MEMORY_MAP_DEBUG
 options MESH_DEBUG
+options MFI_DEBUG
+options MFII_DEBUG
 options MIDI_DEBUG
 options MLYDEBUG
 options MMEYEPCMCIADEBUG

Index: src/sys/arch/i386/conf/ALL
diff -u src/sys/arch/i386/conf/ALL:1.500 src/sys/arch/i386/conf/ALL:1.501
--- src/sys/arch/i386/conf/ALL:1.500	Thu Dec 23 17:13:13 2021
+++ src/sys/arch/i386/conf/ALL	Fri May 13 10:45:24 2022
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.500 2021/12/23 17:13:13 hannken Exp $
+# $NetBSD: ALL,v 1.501 2022/05/13 10:45:24 msaitoh Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/i386/conf/std.i386"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.500 $"
+#ident		"ALL-$Revision: 1.501 $"
 
 maxusers	64		# estimated number of users
 
@@ -2133,6 +2133,8 @@ options MEC_DEBUG
 options MEDIABAY_DEBUG
 options MEMORY_MAP_DEBUG
 options MESH_DEBUG
+options MFI_DEBUG
+options MFII_DEBUG
 options MIDI_DEBUG
 options MLYDEBUG
 options MMEYEPCMCIADEBUG



CVS commit: src/sys/arch

2022-05-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May 13 10:45:24 UTC 2022

Modified Files:
src/sys/arch/amd64/conf: ALL
src/sys/arch/i386/conf: ALL

Log Message:
Add MFI_DEBUG and MFII_DEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.500 -r1.501 src/sys/arch/i386/conf/ALL

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



CVS commit: src/sys/dev/pci

2022-05-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May 13 10:44:39 UTC 2022

Modified Files:
src/sys/dev/pci: mfii.c

Log Message:
Fix compile error when MFII_DEBUG is set. Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/mfii.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/pci/mfii.c
diff -u src/sys/dev/pci/mfii.c:1.14 src/sys/dev/pci/mfii.c:1.15
--- src/sys/dev/pci/mfii.c:1.14	Thu May 12 12:04:09 2022
+++ src/sys/dev/pci/mfii.c	Fri May 13 10:44:38 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mfii.c,v 1.14 2022/05/12 12:04:09 msaitoh Exp $ */
+/* $NetBSD: mfii.c,v 1.15 2022/05/13 10:44:38 msaitoh Exp $ */
 /* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.14 2022/05/12 12:04:09 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.15 2022/05/13 10:44:38 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -339,8 +339,8 @@ struct mfii_softc {
 	int			sc_target_lds[MFI_MAX_LD];
 
 	/* bio */
-	struct mfi_conf	 *sc_cfg;
-	struct mfi_ctrl_infosc_info;
+	struct mfi_conf		*sc_cfg;
+	struct mfi_ctrl_info	sc_info;
 	struct mfi_ld_list	sc_ld_list;
 	struct mfi_ld_details	*sc_ld_details; /* array to all logical disks */
 	int			sc_no_pd; /* used physical disks */
@@ -1033,7 +1033,7 @@ mfii_shutdown(device_t dev, int how)
 	memset(, 0, sizeof(mbox));
 
 	mutex_enter(>sc_lock);
-	DNPRINTF(MFI_D_MISC, "%s: mfii_shutdown\n", DEVNAME(sc));
+	DNPRINTF(MFII_D_MISC, "%s: mfii_shutdown\n", DEVNAME(sc));
 	ccb = mfii_get_ccb(sc);
 	if (ccb == NULL)
 		return false;



CVS commit: src/sys/dev/pci

2022-05-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May 13 10:44:39 UTC 2022

Modified Files:
src/sys/dev/pci: mfii.c

Log Message:
Fix compile error when MFII_DEBUG is set. Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/mfii.c

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



CVS commit: src/sys/dev/ic

2022-05-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May 13 10:41:42 UTC 2022

Modified Files:
src/sys/dev/ic: mfi.c

Log Message:
Improve DNPRINTF. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/ic/mfi.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/ic/mfi.c
diff -u src/sys/dev/ic/mfi.c:1.76 src/sys/dev/ic/mfi.c:1.77
--- src/sys/dev/ic/mfi.c:1.76	Thu May 12 11:56:29 2022
+++ src/sys/dev/ic/mfi.c	Fri May 13 10:41:42 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mfi.c,v 1.76 2022/05/12 11:56:29 msaitoh Exp $ */
+/* $NetBSD: mfi.c,v 1.77 2022/05/13 10:41:42 msaitoh Exp $ */
 /* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
 
 /*
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.76 2022/05/12 11:56:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.77 2022/05/13 10:41:42 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -441,11 +441,11 @@ mfi_init_ccb(struct mfi_softc *sc)
 		}
 
 		DNPRINTF(MFI_D_CCB,
-		"ccb(%d): %p frame: %#lx (%#lx) sense: %#lx (%#lx) map: %#lx\n",
+		"ccb(%d): %p frame: %p (%#lx) sense: %p (%#lx) map: %p\n",
 		ccb->ccb_frame->mfr_header.mfh_context, ccb,
-		(u_long)ccb->ccb_frame, (u_long)ccb->ccb_pframe,
-		(u_long)ccb->ccb_sense, (u_long)ccb->ccb_psense,
-		(u_long)ccb->ccb_dmamap);
+		ccb->ccb_frame, (u_long)ccb->ccb_pframe,
+		ccb->ccb_sense, (u_long)ccb->ccb_psense,
+		ccb->ccb_dmamap);
 
 		/* add ccb to queue */
 		mfi_put_ccb(ccb);
@@ -474,14 +474,14 @@ mfi_read(struct mfi_softc *sc, bus_size_
 	BUS_SPACE_BARRIER_READ);
 	rv = bus_space_read_4(sc->sc_iot, sc->sc_ioh, r);
 
-	DNPRINTF(MFI_D_RW, "%s: mr 0x%lx 0x08%x ", DEVNAME(sc), (u_long)r, rv);
+	DNPRINTF(MFI_D_RW, "%s: mr %#zx 0x08%x ", DEVNAME(sc), r, rv);
 	return rv;
 }
 
 static void
 mfi_write(struct mfi_softc *sc, bus_size_t r, uint32_t v)
 {
-	DNPRINTF(MFI_D_RW, "%s: mw 0x%lx 0x%08x", DEVNAME(sc), (u_long)r, v);
+	DNPRINTF(MFI_D_RW, "%s: mw %#zx 0x%08x", DEVNAME(sc), r, v);
 
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, r, v);
 	bus_space_barrier(sc->sc_iot, sc->sc_ioh, r, 4,
@@ -494,8 +494,8 @@ mfi_allocmem(struct mfi_softc *sc, size_
 	struct mfi_mem		*mm;
 	int			nsegs;
 
-	DNPRINTF(MFI_D_MEM, "%s: mfi_allocmem: %ld\n", DEVNAME(sc),
-	(long)size);
+	DNPRINTF(MFI_D_MEM, "%s: mfi_allocmem: %zu\n", DEVNAME(sc),
+	size);
 
 	mm = malloc(sizeof(struct mfi_mem), M_DEVBUF, M_WAITOK|M_ZERO);
 	mm->am_size = size;
@@ -1373,8 +1373,7 @@ mfi_intr(void *arg)
 
 	pcq = MFIMEM_KVA(sc->sc_pcq);
 
-	DNPRINTF(MFI_D_INTR, "%s: mfi_intr %#lx %#lx\n", DEVNAME(sc),
-	(u_long)sc, (u_long)pcq);
+	DNPRINTF(MFI_D_INTR, "%s: mfi_intr %p %p\n", DEVNAME(sc), sc, pcq);
 
 	bus_dmamap_sync(sc->sc_dmat, MFIMEM_MAP(sc->sc_pcq), 0,
 	sizeof(uint32_t) * sc->sc_max_cmds + sizeof(struct mfi_prod_cons),
@@ -1478,8 +1477,8 @@ mfi_scsi_xs_done(struct mfi_ccb *ccb, in
 	struct scsipi_xfer	*xs = ccb->ccb_xs;
 	struct mfi_softc	*sc = ccb->ccb_sc;
 
-	DNPRINTF(MFI_D_INTR, "%s: mfi_scsi_xs_done %#lx %#lx\n",
-	DEVNAME(sc), (u_long)ccb, (u_long)ccb->ccb_frame);
+	DNPRINTF(MFI_D_INTR, "%s: mfi_scsi_xs_done %p %p\n",
+	DEVNAME(sc), ccb, ccb->ccb_frame);
 
 	if (xs->data != NULL) {
 		DNPRINTF(MFI_D_INTR, "%s: mfi_scsi_xs_done sync\n",
@@ -1502,9 +1501,9 @@ mfi_scsi_xs_done(struct mfi_ccb *ccb, in
 			ccb->ccb_psense - MFIMEM_DVA(sc->sc_sense),
 			MFI_SENSE_SIZE, BUS_DMASYNC_POSTREAD);
 			DNPRINTF(MFI_D_INTR,
-			"%s: mfi_scsi_xs_done sense %#x %lx %lx\n",
+			"%s: mfi_scsi_xs_done sense %#x %p %p\n",
 			DEVNAME(sc), scsi_status,
-			(u_long)>sense, (u_long)ccb->ccb_sense);
+			>sense, ccb->ccb_sense);
 			memset(>sense, 0, sizeof(xs->sense));
 			memcpy(>sense, ccb->ccb_sense,
 			sizeof(struct scsi_sense_data));
@@ -1761,8 +1760,8 @@ mfi_create_sgl(struct mfi_ccb *ccb, int 
 	union mfi_sgl		*sgl;
 	int			error, i;
 
-	DNPRINTF(MFI_D_DMA, "%s: mfi_create_sgl %#lx\n", DEVNAME(sc),
-	(u_long)ccb->ccb_data);
+	DNPRINTF(MFI_D_DMA, "%s: mfi_create_sgl %p\n", DEVNAME(sc),
+	ccb->ccb_data);
 
 	if (!ccb->ccb_data)
 		return 1;
@@ -3292,8 +3291,8 @@ mfi_tbolt_create_sgl(struct mfi_ccb *ccb
 		/* One element to store the chain info */
 		sge_idx = MEGASAS_THUNDERBOLT_MAX_SGE_IN_MAINMSG - 1;
 		DNPRINTF(MFI_D_DMA,
-		"mfi sge_idx %d sge_count %d io_req paddr 0x%" PRIx64 "\n",
-		sge_idx, sge_count, ccb->ccb_tb_pio_request);
+		"mfi sge_idx %d sge_count %d io_req paddr %jx\n",
+		sge_idx, sge_count, (uintmax_t)ccb->ccb_tb_pio_request);
 	} else {
 		sge_idx = sge_count;
 	}



CVS commit: src/sys/dev/ic

2022-05-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May 13 10:41:42 UTC 2022

Modified Files:
src/sys/dev/ic: mfi.c

Log Message:
Improve DNPRINTF. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/ic/mfi.c

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



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

2022-05-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 13 09:49:44 UTC 2022

Modified Files:
src/sys/arch/arm/rockchip: rk_v1crypto.c

Log Message:
rkv1crypto(4): Fix units in RNG repeated-output health test.

This code was intended to check whether the two 4-word halves of an
8-word, 32-byte, 256-bit sample were repeated.

Instead, it accidentally checked whether the first 4 _bytes_ of the
two halves were repeated.

The effect was a false alarm rate of 1/2^32, instead of a false alarm
rate of 1/2^128, with no change on the true alarm rate in the event
of an RNG wedged producing all-zero or all-one bits.  1/2^128 is an
acceptable false alarm rate; 1/2^32, not so much.

(The false alarm right might be higher if the samples are not
perfectly uniformly distributed, which they most likey aren't,
although the documentation doesn't give any details other than
suggesting it's a ring oscillator under the hood, which provides
entropy from jitter induced by thermal noise.  This driver records
half a bit of entropy per bit of sample to be reasonably
conservative.)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/rockchip/rk_v1crypto.c

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

Modified files:

Index: src/sys/arch/arm/rockchip/rk_v1crypto.c
diff -u src/sys/arch/arm/rockchip/rk_v1crypto.c:1.9 src/sys/arch/arm/rockchip/rk_v1crypto.c:1.10
--- src/sys/arch/arm/rockchip/rk_v1crypto.c:1.9	Fri Apr  8 23:14:21 2022
+++ src/sys/arch/arm/rockchip/rk_v1crypto.c	Fri May 13 09:49:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rk_v1crypto.c,v 1.9 2022/04/08 23:14:21 riastradh Exp $	*/
+/*	$NetBSD: rk_v1crypto.c,v 1.10 2022/05/13 09:49:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: rk_v1crypto.c,v 1.9 2022/04/08 23:14:21 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk_v1crypto.c,v 1.10 2022/05/13 09:49:44 riastradh Exp $");
 
 #include 
 
@@ -268,7 +268,7 @@ rk_v1crypto_rng_get(size_t nbytes, void 
 			device_printf(self, "timed out\n");
 			break;
 		}
-		if (consttime_memequal(buf, buf + n/2, n/2)) {
+		if (consttime_memequal(buf, buf + n/2, sizeof(buf[0]) * n/2)) {
 			device_printf(self, "failed repeated output test\n");
 			break;
 		}



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

2022-05-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 13 09:49:44 UTC 2022

Modified Files:
src/sys/arch/arm/rockchip: rk_v1crypto.c

Log Message:
rkv1crypto(4): Fix units in RNG repeated-output health test.

This code was intended to check whether the two 4-word halves of an
8-word, 32-byte, 256-bit sample were repeated.

Instead, it accidentally checked whether the first 4 _bytes_ of the
two halves were repeated.

The effect was a false alarm rate of 1/2^32, instead of a false alarm
rate of 1/2^128, with no change on the true alarm rate in the event
of an RNG wedged producing all-zero or all-one bits.  1/2^128 is an
acceptable false alarm rate; 1/2^32, not so much.

(The false alarm right might be higher if the samples are not
perfectly uniformly distributed, which they most likey aren't,
although the documentation doesn't give any details other than
suggesting it's a ring oscillator under the hood, which provides
entropy from jitter induced by thermal noise.  This driver records
half a bit of entropy per bit of sample to be reasonably
conservative.)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/rockchip/rk_v1crypto.c

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



CVS commit: src/sys/kern

2022-05-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 13 09:40:25 UTC 2022

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

Log Message:
cprng(9): Fix accidental 4x seed size.

With SHA-256, NIST Hash_DRBG takes an preferred 440-bit/55-byte seed.
It's a weird number, and I'm not sure where it comes from (a quick
skim of SP800-90A doesn't turn anything up), but it's certainly
sufficient (256-bit/32-byte seed is almost certainly enough) so it's
not a problem to use something larger; Hash_DRBG can absorb seeds of
arbitrary lengths and larger seeds can't really hurt security (with
minor caveats like HMAC RO quirks that don't apply here).

Except -- owing to a typo, we actually used a 1760-bit/220-byte seed,
because I wrote `uint32_t seed[...]' instead of `uint8_t seed[...]'.
Again: not a problem to use a seed larger than needed.  But let's
draw no more than we need out of the entropy pool!

Verified with CTASSERT(sizeof(seed) == 55).  (Assertion omitted from
this commit because we might swap out Hash_DRBG for something else
with a different seed size like 32 bytes.)


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/subr_cprng.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_cprng.c
diff -u src/sys/kern/subr_cprng.c:1.42 src/sys/kern/subr_cprng.c:1.43
--- src/sys/kern/subr_cprng.c:1.42	Wed Mar 16 23:56:33 2022
+++ src/sys/kern/subr_cprng.c	Fri May 13 09:40:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cprng.c,v 1.42 2022/03/16 23:56:33 riastradh Exp $	*/
+/*	$NetBSD: subr_cprng.c,v 1.43 2022/05/13 09:40:25 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.42 2022/03/16 23:56:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.43 2022/05/13 09:40:25 riastradh Exp $");
 
 #include 
 #include 
@@ -268,7 +268,7 @@ cprng_fini_cpu(void *ptr, void *cookie, 
 size_t
 cprng_strong(struct cprng_strong *cprng, void *buf, size_t len, int flags)
 {
-	uint32_t seed[NIST_HASH_DRBG_SEEDLEN_BYTES];
+	uint8_t seed[NIST_HASH_DRBG_SEEDLEN_BYTES];
 	struct cprng_cpu *cc;
 	unsigned epoch;
 	int s;



CVS commit: src/sys/kern

2022-05-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 13 09:40:25 UTC 2022

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

Log Message:
cprng(9): Fix accidental 4x seed size.

With SHA-256, NIST Hash_DRBG takes an preferred 440-bit/55-byte seed.
It's a weird number, and I'm not sure where it comes from (a quick
skim of SP800-90A doesn't turn anything up), but it's certainly
sufficient (256-bit/32-byte seed is almost certainly enough) so it's
not a problem to use something larger; Hash_DRBG can absorb seeds of
arbitrary lengths and larger seeds can't really hurt security (with
minor caveats like HMAC RO quirks that don't apply here).

Except -- owing to a typo, we actually used a 1760-bit/220-byte seed,
because I wrote `uint32_t seed[...]' instead of `uint8_t seed[...]'.
Again: not a problem to use a seed larger than needed.  But let's
draw no more than we need out of the entropy pool!

Verified with CTASSERT(sizeof(seed) == 55).  (Assertion omitted from
this commit because we might swap out Hash_DRBG for something else
with a different seed size like 32 bytes.)


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/subr_cprng.c

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



CVS commit: src/sys/kern

2022-05-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 13 09:40:02 UTC 2022

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

Log Message:
entropy(9): Update comment about where entropy_extract is allowed.

As of last month, it is forbidden in all hard interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/kern/kern_entropy.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_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.55 src/sys/kern/kern_entropy.c:1.56
--- src/sys/kern/kern_entropy.c:1.55	Fri May 13 09:39:52 2022
+++ src/sys/kern/kern_entropy.c	Fri May 13 09:40:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.55 2022/05/13 09:39:52 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.56 2022/05/13 09:40:02 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.55 2022/05/13 09:39:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.56 2022/05/13 09:40:02 riastradh Exp $");
 
 #include 
 #include 
@@ -1364,9 +1364,8 @@ sysctl_entropy_gather(SYSCTLFN_ARGS)
  *		EINTR/ERESTART	No entropy, ENTROPY_SIG set, and interrupted.
  *
  *	If ENTROPY_WAIT is set, allowed only in thread context.  If
- *	ENTROPY_WAIT is not set, allowed up to IPL_VM.  (XXX That's
- *	awfully high...  Do we really need it in hard interrupts?  This
- *	arises from use of cprng_strong(9).)
+ *	ENTROPY_WAIT is not set, allowed also in softint context.
+ *	Forbidden in hard interrupt context.
  */
 int
 entropy_extract(void *buf, size_t len, int flags)



CVS commit: src/sys/kern

2022-05-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 13 09:40:02 UTC 2022

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

Log Message:
entropy(9): Update comment about where entropy_extract is allowed.

As of last month, it is forbidden in all hard interrupt context.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/kern/kern_entropy.c

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



CVS commit: src/sys/kern

2022-05-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 13 09:39:52 UTC 2022

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

Log Message:
entropy(9): Note rules about how to use entropy_extract output.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/kern/kern_entropy.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_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.54 src/sys/kern/kern_entropy.c:1.55
--- src/sys/kern/kern_entropy.c:1.54	Thu Mar 24 12:58:56 2022
+++ src/sys/kern/kern_entropy.c	Fri May 13 09:39:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.54 2022/03/24 12:58:56 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.55 2022/05/13 09:39:52 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.54 2022/03/24 12:58:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.55 2022/05/13 09:39:52 riastradh Exp $");
 
 #include 
 #include 
@@ -1341,6 +1341,16 @@ sysctl_entropy_gather(SYSCTLFN_ARGS)
  *
  *	Extract len bytes from the global entropy pool into buf.
  *
+ *	Caller MUST NOT expose these bytes directly -- must use them
+ *	ONLY to seed a cryptographic pseudorandom number generator
+ *	(`CPRNG'), a.k.a. deterministic random bit generator (`DRBG'),
+ *	and then erase them.  entropy_extract does not, on its own,
+ *	provide backtracking resistance -- it must be combined with a
+ *	PRNG/DRBG that does.
+ *
+ *	You generally shouldn't use this directly -- use cprng(9)
+ *	instead.
+ *
  *	Flags may have:
  *
  *		ENTROPY_WAIT	Wait for entropy if not available yet.



CVS commit: src/sys/kern

2022-05-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 13 09:39:52 UTC 2022

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

Log Message:
entropy(9): Note rules about how to use entropy_extract output.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/kern/kern_entropy.c

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



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

2022-05-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 13 09:39:40 UTC 2022

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

Log Message:
x86/pmap: Feed entropy_extract output through nist_hash_drbg.

The entropy pool algorithm is NOT designed to provide backtracking
resistance on its own -- it MUST be combined with a PRNG/DRBG that
provides that.

The only reason we use entropy_extract here is that cprng(9) is not
available yet (which in turn is because kmem and other basic kernel
facilities aren't available yet), but nist_hash_drbg doesn't have any
initialization order requirements, so we'll just use it directly.


To generate a diff of this commit:
cvs rdiff -u -r1.414 -r1.415 src/sys/arch/x86/x86/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/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.414 src/sys/arch/x86/x86/pmap.c:1.415
--- src/sys/arch/x86/x86/pmap.c:1.414	Sat May  7 14:59:25 2022
+++ src/sys/arch/x86/x86/pmap.c	Fri May 13 09:39:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.414 2022/05/07 14:59:25 bouyer Exp $	*/
+/*	$NetBSD: pmap.c,v 1.415 2022/05/13 09:39:40 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.414 2022/05/07 14:59:25 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.415 2022/05/13 09:39:40 riastradh Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -178,6 +178,10 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.4
 #include 
 #endif
 
+#ifdef __HAVE_DIRECT_MAP
+#include 
+#endif
+
 /*
  * general info:
  *
@@ -1602,6 +1606,33 @@ pmap_init_pcpu(void)
 #endif
 
 #ifdef __HAVE_DIRECT_MAP
+static void
+randomize_hole(size_t *randholep, vaddr_t *randvap)
+{
+	struct nist_hash_drbg drbg;
+	uint8_t seed[NIST_HASH_DRBG_SEEDLEN_BYTES];
+	const char p[] = "x86/directmap";
+	int error;
+
+	entropy_extract(seed, sizeof(seed), 0);
+
+	error = nist_hash_drbg_instantiate(, seed, sizeof(seed),
+	/*nonce*/NULL, 0,
+	/*personalization*/p, strlen(p));
+	KASSERTMSG(error == 0, "error=%d", error);
+
+	error = nist_hash_drbg_generate(, randholep, sizeof(*randholep),
+	/*additional*/NULL, 0);
+	KASSERTMSG(error == 0, "error=%d", error);
+
+	error = nist_hash_drbg_generate(, randvap, sizeof(*randvap),
+	/*additional*/NULL, 0);
+	KASSERTMSG(error == 0, "error=%d", error);
+
+	explicit_memset(seed, 0, sizeof(seed));
+	explicit_memset(, 0, sizeof(drbg));
+}
+
 /*
  * Create the amd64 direct map. Called only once at boot time. We map all of
  * the physical memory contiguously using 2MB large pages, with RW permissions.
@@ -1648,8 +1679,7 @@ pmap_init_directmap(struct pmap *kpm)
 		panic("pmap_init_directmap: lastpa incorrect");
 	}
 
-	entropy_extract(, sizeof randhole, 0);
-	entropy_extract(, sizeof randva, 0);
+	randomize_hole(, );
 	startva = slotspace_rand(SLAREA_DMAP, lastpa, NBPD_L2,
 	randhole, randva);
 	endva = startva + lastpa;



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

2022-05-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May 13 09:39:40 UTC 2022

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

Log Message:
x86/pmap: Feed entropy_extract output through nist_hash_drbg.

The entropy pool algorithm is NOT designed to provide backtracking
resistance on its own -- it MUST be combined with a PRNG/DRBG that
provides that.

The only reason we use entropy_extract here is that cprng(9) is not
available yet (which in turn is because kmem and other basic kernel
facilities aren't available yet), but nist_hash_drbg doesn't have any
initialization order requirements, so we'll just use it directly.


To generate a diff of this commit:
cvs rdiff -u -r1.414 -r1.415 src/sys/arch/x86/x86/pmap.c

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