Re: continuous ffs_blkfree_common panic

2024-05-04 Thread Michael van Elst
mar...@duskware.de (Martin Husemann) writes:

>Did you run a forced fsck on the file system?

I just got this panic running 10.99.10 in qemu.

[   4.0895156] panic: ffs_blkfree_common: freeing free frag: dev = 0x1300,
+block = 135894, fs = /

This happened after a clean reboot, after the rc message "Starting file
system checks:".

After another reboot (same qemu process), there was no more error.

If that's a hardware problem, it also affects virtualized hardware
(in this case virtio-block).



CVS commit: src/sys/arch/amiga/amiga

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 13:45:10 UTC 2024

Modified Files:
src/sys/arch/amiga/amiga: trap.c

Log Message:
Don't panic on NULL pointer dereference when done by copyin, ...


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sys/arch/amiga/amiga/trap.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/amiga/amiga/trap.c
diff -u src/sys/arch/amiga/amiga/trap.c:1.142 src/sys/arch/amiga/amiga/trap.c:1.143
--- src/sys/arch/amiga/amiga/trap.c:1.142	Sat Jan 20 00:15:30 2024
+++ src/sys/arch/amiga/amiga/trap.c	Sat May  4 13:45:10 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.142 2024/01/20 00:15:30 thorpej Exp $	*/
+/*	$NetBSD: trap.c,v 1.143 2024/05/04 13:45:10 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
 #include "opt_m68k_arch.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.142 2024/01/20 00:15:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.143 2024/05/04 13:45:10 mlelstv Exp $");
 
 #include 
 #include 
@@ -364,7 +364,7 @@ trapmmufault(int type, u_int code, u_int
 		ftype = VM_PROT_READ;
 	va = trunc_page((vaddr_t)v);
 #ifdef DEBUG
-	if (map == kernel_map && va == 0) {
+	if (map == kernel_map && va == 0 && onfault == 0) {
 		printf("trap: bad kernel access at %x pc %x\n", v, fp->f_pc);
 		panictrap(type, code, v, fp);
 	}



CVS commit: src/sys/arch/amiga/amiga

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 13:45:10 UTC 2024

Modified Files:
src/sys/arch/amiga/amiga: trap.c

Log Message:
Don't panic on NULL pointer dereference when done by copyin, ...


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sys/arch/amiga/amiga/trap.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

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 13:33:18 UTC 2024

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

Log Message:
Account for trailing NUL bytes when calculating userland buffer size.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/kern/subr_iostat.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_iostat.c
diff -u src/sys/kern/subr_iostat.c:1.25 src/sys/kern/subr_iostat.c:1.26
--- src/sys/kern/subr_iostat.c:1.25	Wed May 22 08:47:02 2019
+++ src/sys/kern/subr_iostat.c	Sat May  4 13:33:18 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_iostat.c,v 1.25 2019/05/22 08:47:02 hannken Exp $	*/
+/*	$NetBSD: subr_iostat.c,v 1.26 2024/05/04 13:33:18 mlelstv Exp $	*/
 /*	NetBSD: subr_disk.c,v 1.69 2005/05/29 22:24:15 christos Exp	*/
 
 /*-
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.25 2019/05/22 08:47:02 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.26 2024/05/04 13:33:18 mlelstv Exp $");
 
 #include 
 #include 
@@ -370,6 +370,8 @@ iostati_getnames(int disk_only, char *ol
 			memset(bf, 0, sizeof(bf));
 			if (first) {
 strncpy(bf, stats->io_name, sizeof(bf));
+/* account for trailing NUL byte */
+needed += 1;
 first = 0;
 			} else {
 bf[0] = ' ';



CVS commit: src/sys/kern

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 13:33:18 UTC 2024

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

Log Message:
Account for trailing NUL bytes when calculating userland buffer size.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/kern/subr_iostat.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/seq

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 13:29:41 UTC 2024

Modified Files:
src/usr.bin/seq: seq.c

Log Message:
Bail if increment is too small for the precision to avoid an infinite loop.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/seq/seq.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/seq/seq.c
diff -u src/usr.bin/seq/seq.c:1.13 src/usr.bin/seq/seq.c:1.14
--- src/usr.bin/seq/seq.c:1.13	Sat Feb 24 10:10:04 2024
+++ src/usr.bin/seq/seq.c	Sat May  4 13:29:41 2024
@@ -31,7 +31,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2005\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: seq.c,v 1.13 2024/02/24 10:10:04 mlelstv Exp $");
+__RCSID("$NetBSD: seq.c,v 1.14 2024/05/04 13:29:41 mlelstv Exp $");
 #endif /* not lint */
 
 #include 
@@ -105,6 +105,7 @@ main(int argc, char *argv[])
 	double first = 1.0;
 	double last = 0.0;
 	double incr = 0.0;
+	double prev;
 	struct lconv *locale;
 	char *fmt = NULL;
 	const char *sep = "\n";
@@ -208,15 +209,23 @@ main(int argc, char *argv[])
 
 	if (incr > 0) {
 		printf(fmt, first);
+		prev = first;
 		for (first += incr; first <= last; first += incr) {
+			if (first <= prev)
+errx(1, "increment too small\n");
 			fputs(sep, stdout);
 			printf(fmt, first);
+			prev = first;
 		}
 	} else {
 		printf(fmt, first);
+		prev = first;
 		for (first += incr; first >= last; first += incr) {
+			if (first >= prev)
+errx(1, "increment too small\n");
 			fputs(sep, stdout);
 			printf(fmt, first);
+			prev = first;
 		}
 	}
 	if (term != NULL)



CVS commit: src/usr.bin/seq

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 13:29:41 UTC 2024

Modified Files:
src/usr.bin/seq: seq.c

Log Message:
Bail if increment is too small for the precision to avoid an infinite loop.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/seq/seq.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/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:49:16 UTC 2024

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
Use device_printf instead of autoconf messages for errors.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/dev/usb/uhub.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/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:49:16 UTC 2024

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
Use device_printf instead of autoconf messages for errors.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/dev/usb/uhub.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/usb/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.161 src/sys/dev/usb/uhub.c:1.162
--- src/sys/dev/usb/uhub.c:1.161	Wed Apr  6 22:01:45 2022
+++ src/sys/dev/usb/uhub.c	Sat May  4 12:49:15 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.161 2022/04/06 22:01:45 mlelstv Exp $	*/
+/*	$NetBSD: uhub.c,v 1.162 2024/05/04 12:49:15 mlelstv Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 /*	$OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.161 2022/04/06 22:01:45 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.162 2024/05/04 12:49:15 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -864,7 +864,7 @@ uhub_explore(struct usbd_device *dev)
 			 * some other serious problem.  Since we cannot leave
 			 * at 0 we have to disable the port instead.
 			 */
-			aprint_error_dev(sc->sc_dev,
+			device_printf(sc->sc_dev,
 			"device problem, disabling port %d\n", port);
 			usbd_clear_port_feature(dev, port, UHF_PORT_ENABLE);
 		} else {



CVS commit: src/sys/dev/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:45:14 UTC 2024

Modified Files:
src/sys/dev/usb: usb_subr.c

Log Message:
Make usb address and hub topology available to drvctl.


To generate a diff of this commit:
cvs rdiff -u -r1.278 -r1.279 src/sys/dev/usb/usb_subr.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/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.278 src/sys/dev/usb/usb_subr.c:1.279
--- src/sys/dev/usb/usb_subr.c:1.278	Tue Apr 11 08:50:07 2023
+++ src/sys/dev/usb/usb_subr.c	Sat May  4 12:45:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.278 2023/04/11 08:50:07 riastradh Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.279 2024/05/04 12:45:13 mlelstv Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.278 2023/04/11 08:50:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.279 2024/05/04 12:45:13 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1083,6 +1083,24 @@ usbd_properties(device_t dv, struct usbd
 	vendor = UGETW(dd->idVendor);
 	product = UGETW(dd->idProduct);
 
+	prop_dictionary_set_uint8(dict, "address", dev->ud_addr);
+
+	if (dev->ud_myhub) {
+		struct usbd_device *hdev = dev->ud_myhub;
+		struct usbd_hub *hub = hdev->ud_hub;
+		int p;
+
+		KASSERT(hub != NULL);
+
+		prop_dictionary_set_uint8(dict, "hub-address", hdev->ud_addr);
+		for (p=1; p <= hub->uh_hubdesc.bNbrPorts; ++p) {
+			if (hub->uh_ports[p-1].up_dev == dev) {
+prop_dictionary_set_uint8(dict, "hub-port", p);
+break;
+			}
+		}
+	}
+
 	prop_dictionary_set_uint8(dict, "class", class);
 	prop_dictionary_set_uint8(dict, "subclass", subclass);
 	prop_dictionary_set_uint16(dict, "release", release);



CVS commit: src/sys/dev/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:45:14 UTC 2024

Modified Files:
src/sys/dev/usb: usb_subr.c

Log Message:
Make usb address and hub topology available to drvctl.


To generate a diff of this commit:
cvs rdiff -u -r1.278 -r1.279 src/sys/dev/usb/usb_subr.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/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:41:03 UTC 2024

Modified Files:
src/sys/dev/usb: usbnet.c

Log Message:
Use device_printf instead of autoconf messages for errors.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/usb/usbnet.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/usb/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.119 src/sys/dev/usb/usbnet.c:1.120
--- src/sys/dev/usb/usbnet.c:1.119	Fri Feb  2 22:00:33 2024
+++ src/sys/dev/usb/usbnet.c	Sat May  4 12:41:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.119 2024/02/02 22:00:33 andvar Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.120 2024/05/04 12:41:03 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.119 2024/02/02 22:00:33 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.120 2024/05/04 12:41:03 mlelstv Exp $");
 
 #include 
 #include 
@@ -377,7 +377,7 @@ usbnet_rxeof(struct usbd_xfer *xfer, voi
 	usbd_get_xfer_status(xfer, NULL, NULL, _len, NULL);
 
 	if (total_len > un->un_rx_bufsz) {
-		aprint_error_dev(un->un_dev,
+		device_printf(un->un_dev,
 		"rxeof: too large transfer (%u > %u)\n",
 		total_len, un->un_rx_bufsz);
 		goto done;
@@ -471,7 +471,7 @@ usbnet_pipe_intr(struct usbd_xfer *xfer,
 
 	if (status != USBD_NORMAL_COMPLETION) {
 		if (usbd_ratecheck(>unp_intr_notice)) {
-			aprint_error_dev(un->un_dev, "usb error on intr: %s\n",
+			device_printf(un->un_dev, "usb error on intr: %s\n",
 			usbd_errstr(status));
 		}
 		if (status == USBD_STALLED)



CVS commit: src/sys/dev/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:41:03 UTC 2024

Modified Files:
src/sys/dev/usb: usbnet.c

Log Message:
Use device_printf instead of autoconf messages for errors.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/usb/usbnet.c

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



CVS commit: src/sys/fs/msdosfs

2024-05-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 05:49:39 UTC 2024

Modified Files:
src/sys/fs/msdosfs: msdosfs_rename.c

Log Message:
>From genfs_rename.c:

 * XXX Want a better equality test.  `tcnp->cn_cred == cred'
 * hoses p2k because puffs transmits the creds separately and
 * allocates distinct but equivalent structures for them.

Fixes rename crash in rump_msdos.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/fs/msdosfs/msdosfs_rename.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/fs/msdosfs/msdosfs_rename.c
diff -u src/sys/fs/msdosfs/msdosfs_rename.c:1.3 src/sys/fs/msdosfs/msdosfs_rename.c:1.4
--- src/sys/fs/msdosfs/msdosfs_rename.c:1.3	Sat Oct 23 16:58:17 2021
+++ src/sys/fs/msdosfs/msdosfs_rename.c	Sat May  4 05:49:39 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_rename.c,v 1.3 2021/10/23 16:58:17 thorpej Exp $	*/
+/*	$NetBSD: msdosfs_rename.c,v 1.4 2024/05/04 05:49:39 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_rename.c,v 1.3 2021/10/23 16:58:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_rename.c,v 1.4 2024/05/04 05:49:39 mlelstv Exp $");
 
 #include 
 #include 
@@ -127,7 +127,7 @@ msdosfs_rename(void *v)
 	KASSERT(tdvp->v_type == VDIR);
 
 	cred = fcnp->cn_cred;
-	KASSERT(tcnp->cn_cred == cred);
+	KASSERT(kauth_cred_uidmatch(cred, tcnp->cn_cred));
 
 	/*
 	 * Sanitize our world from the VFS insanity.  Unlock the target



CVS commit: src/sys/fs/msdosfs

2024-05-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 05:49:39 UTC 2024

Modified Files:
src/sys/fs/msdosfs: msdosfs_rename.c

Log Message:
>From genfs_rename.c:

 * XXX Want a better equality test.  `tcnp->cn_cred == cred'
 * hoses p2k because puffs transmits the creds separately and
 * allocates distinct but equivalent structures for them.

Fixes rename crash in rump_msdos.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/fs/msdosfs/msdosfs_rename.c

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



Re: netbsd crashes when using fat filesys

2024-05-02 Thread Michael van Elst
rhia...@falu.nl (Rhialto) writes:

>$ sudo ./rump_msdos -o rw -o rump ./efi.img /tmp/t
>rump_msdos: "./efi.img" is a relative path.
>rump_msdos: using "/mnt/scratch/scratch/tmp/xcrash/efi.img" instead.
>[   1.000] entropy: ready

>terminal 2:

>$ cd /tmp/t
>$ ls -l
>total 4
>drwxr-xr-x  1 rhialto  wheel  4096 Apr 21  2021 efi/
>-rwxr-xr-x  1 rhialto  wheel 0 May  2 22:32 file*
>$ mv file file2
>mv: rename file to file2: Device not configured


I can repeat this with rump, but not with the kernel filesystem.
After my suggested change, rump no longer crashes.

N.B. the code change is in /usr/lib/librumpfs_msdos.so.0.0.



Re: netbsd crashes when using fat filesys

2024-05-02 Thread Michael van Elst
rhia...@falu.nl (Rhialto) writes:

>I had something similar recently when doing a rename of a file on a FAT
>file system (in this case my /efi file system). Fortunately I had it
>mounted with -o rump, because it was 100% repeatable.

>I filed http://gnats.netbsd.org/58146 for it.


Maybe that's rump.

msdosfs:
KASSERT(tcnp->cn_cred == cred);

genfs:  /*
 * XXX Want a better equality test.  `tcnp->cn_cred == cred'
 * hoses p2k because puffs transmits the creds separately and
 * allocates distinct but equivalent structures for them.
 */
KASSERT(kauth_cred_uidmatch(cred, tcnp->cn_cred));


Can you still repeat the crash when you change the assertion
to match the genfs check ?




CVS commit: src/sys/compat/netbsd32

2024-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 11:32:29 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_compat_16.c

Log Message:
Enable compat sigreturn system call.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/netbsd32/netbsd32_compat_16.c

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



CVS commit: src/sys/compat/netbsd32

2024-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 11:32:29 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_compat_16.c

Log Message:
Enable compat sigreturn system call.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/netbsd32/netbsd32_compat_16.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/netbsd32/netbsd32_compat_16.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_16.c:1.4 src/sys/compat/netbsd32/netbsd32_compat_16.c:1.5
--- src/sys/compat/netbsd32/netbsd32_compat_16.c:1.4	Fri Nov 26 08:06:11 2021
+++ src/sys/compat/netbsd32/netbsd32_compat_16.c	Wed May  1 11:32:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_compat_16.c,v 1.4 2021/11/26 08:06:11 ryo Exp $	*/
+/*	$NetBSD: netbsd32_compat_16.c,v 1.5 2024/05/01 11:32:29 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,13 +29,14 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_16.c,v 1.4 2021/11/26 08:06:11 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_16.c,v 1.5 2024/05/01 11:32:29 mlelstv Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -47,40 +48,87 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_com
 
 struct uvm_object *emul_netbsd32_object;
 
-MODULE(MODULE_CLASS_EXEC, compat_netbsd32_16, "compat_netbsd32_20,compat_16");
+static const struct syscall_package netbsd32_kern_sig_16_syscalls[] = {
+/* compat_16_netbs32___sigreturn14 is in MD code! */
+{ NETBSD32_SYS_compat_16_netbsd32___sigreturn14, 0,
+(sy_call_t *)compat_16_netbsd32___sigreturn14 },
+{ 0, 0, NULL }
+};
 
 static int
-compat_netbsd32_16_modcmd(modcmd_t cmd, void *arg)
+compat_netbsd32_16_init(void)
+{
+	int error;
+
+	error = syscall_establish(_netbsd32, netbsd32_kern_sig_16_syscalls);
+	if (error)
+		return error;
+
+	rw_enter(_lock, RW_WRITER);
+	emul_netbsd32.e_sigcode = netbsd32_sigcode;
+	emul_netbsd32.e_esigcode = netbsd32_esigcode;
+	emul_netbsd32.e_sigobject = _netbsd32_object;
+	error = exec_sigcode_alloc(_netbsd);
+	if (error) {
+		emul_netbsd32.e_sigcode = NULL;
+		emul_netbsd32.e_esigcode = NULL;
+		emul_netbsd32.e_sigobject = NULL;
+	}
+	rw_exit(_lock);
+	if (error)
+		return error;
+	netbsd32_machdep_md_16_init();
+	return 0;
+}
+
+static int
+compat_netbsd32_16_fini(void)
 {
+	proc_t *p;
 	int error;
 
+	error = syscall_disestablish(_netbsd32, netbsd32_kern_sig_16_syscalls);
+if (error)
+return error;
+/*
+ * Ensure sendsig_sigcontext() is not being used.
+ * module_lock prevents the flag being set on any
+ * further processes while we are here.  See
+ * sigaction1() for the opposing half.
+ */
+mutex_enter(_lock);
+PROCLIST_FOREACH(p, ) {
+if ((p->p_lflag & PL_SIGCOMPAT) != 0) {
+break;
+}
+}
+mutex_exit(_lock);
+if (p != NULL) {
+syscall_establish(_netbsd32, netbsd32_kern_sig_16_syscalls);
+return EBUSY;
+}
+
+	rw_enter(_lock, RW_WRITER);
+	exec_sigcode_free(_netbsd);
+	emul_netbsd32.e_sigcode = NULL;
+   	emul_netbsd32.e_esigcode = NULL;
+   	emul_netbsd32.e_sigobject = NULL;
+	rw_exit(_lock);
+	netbsd32_machdep_md_16_fini();
+	return 0;
+}
+
+MODULE(MODULE_CLASS_EXEC, compat_netbsd32_16, "compat_netbsd32_20,compat_16");
+
+static int
+compat_netbsd32_16_modcmd(modcmd_t cmd, void *arg)
+{
 	switch (cmd) {
 	case MODULE_CMD_INIT:
-		rw_enter(_lock, RW_WRITER);
-		emul_netbsd32.e_sigcode = netbsd32_sigcode;
-	emul_netbsd32.e_esigcode = netbsd32_esigcode;
-	emul_netbsd32.e_sigobject = _netbsd32_object;
-		error = exec_sigcode_alloc(_netbsd);
-		if (error) {
-			emul_netbsd32.e_sigcode = NULL;
-			emul_netbsd32.e_esigcode = NULL;
-			emul_netbsd32.e_sigobject = NULL;
-		}
-		rw_exit(_lock);
-		if (error)
-			return error;
-		netbsd32_machdep_md_16_init();
-		return 0;
+		return compat_netbsd32_16_init();
 
 	case MODULE_CMD_FINI:
-		rw_enter(_lock, RW_WRITER);
-		exec_sigcode_free(_netbsd);
-		emul_netbsd32.e_sigcode = NULL;
-	emul_netbsd32.e_esigcode = NULL;
-	emul_netbsd32.e_sigobject = NULL;
-		rw_exit(_lock);
-		netbsd32_machdep_md_16_fini();
-		return 0;
+		return compat_netbsd32_16_fini();
 
 	default:
 		return ENOTTY;



CVS commit: src/sys/compat/netbsd32

2024-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:22:43 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_sysent.c

Log Message:
Revert previous, the syscall needs to be enabled at runtime.

The compat_16 module just enables it for the "netbsd" emulation, but
nothing enables it yet for "netbsd32".


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/compat/netbsd32/netbsd32_sysent.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/netbsd32/netbsd32_sysent.c
diff -u src/sys/compat/netbsd32/netbsd32_sysent.c:1.159 src/sys/compat/netbsd32/netbsd32_sysent.c:1.160
--- src/sys/compat/netbsd32/netbsd32_sysent.c:1.159	Tue Apr 30 17:10:22 2024
+++ src/sys/compat/netbsd32/netbsd32_sysent.c	Wed May  1 07:22:43 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_sysent.c,v 1.159 2024/04/30 17:10:22 mlelstv Exp $ */
+/* $NetBSD: netbsd32_sysent.c,v 1.160 2024/05/01 07:22:43 mlelstv Exp $ */
 
 /*
  * System call switch table.
@@ -8,7 +8,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysent.c,v 1.159 2024/04/30 17:10:22 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysent.c,v 1.160 2024/05/01 07:22:43 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -1280,7 +1280,7 @@ struct sysent netbsd32_sysent[] = {
 	},		/* 294 = netbsd32___sigsuspend14 */
 	{
 		ns(struct compat_16_netbsd32___sigreturn14_args),
-		.sy_call = (sy_call_t *)compat_16_netbsd32___sigreturn14
+		.sy_call = (sy_call_t *)sys_nomodule
 	},		/* 295 = compat_16_netbsd32___sigreturn14 */
 	{
 		ns(struct netbsd32___getcwd_args),



CVS commit: src/sys/compat/netbsd32

2024-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:22:43 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_sysent.c

Log Message:
Revert previous, the syscall needs to be enabled at runtime.

The compat_16 module just enables it for the "netbsd" emulation, but
nothing enables it yet for "netbsd32".


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/compat/netbsd32/netbsd32_sysent.c

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



CVS commit: src/sys/compat/netbsd32

2024-04-30 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Apr 30 17:10:22 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_sysent.c

Log Message:
Enable compat sigreturn system call.

The previous bug in netbsd32___sigaction_sigtramp hid the problem,
as it failed all but the first installation of a signal handler.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sys/compat/netbsd32/netbsd32_sysent.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/netbsd32/netbsd32_sysent.c
diff -u src/sys/compat/netbsd32/netbsd32_sysent.c:1.158 src/sys/compat/netbsd32/netbsd32_sysent.c:1.159
--- src/sys/compat/netbsd32/netbsd32_sysent.c:1.158	Sun Jul 30 06:53:13 2023
+++ src/sys/compat/netbsd32/netbsd32_sysent.c	Tue Apr 30 17:10:22 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_sysent.c,v 1.158 2023/07/30 06:53:13 rin Exp $ */
+/* $NetBSD: netbsd32_sysent.c,v 1.159 2024/04/30 17:10:22 mlelstv Exp $ */
 
 /*
  * System call switch table.
@@ -8,7 +8,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysent.c,v 1.158 2023/07/30 06:53:13 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysent.c,v 1.159 2024/04/30 17:10:22 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -1280,7 +1280,7 @@ struct sysent netbsd32_sysent[] = {
 	},		/* 294 = netbsd32___sigsuspend14 */
 	{
 		ns(struct compat_16_netbsd32___sigreturn14_args),
-		.sy_call = (sy_call_t *)sys_nomodule
+		.sy_call = (sy_call_t *)compat_16_netbsd32___sigreturn14
 	},		/* 295 = compat_16_netbsd32___sigreturn14 */
 	{
 		ns(struct netbsd32___getcwd_args),



CVS commit: src/sys/compat/netbsd32

2024-04-30 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Apr 30 17:10:22 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_sysent.c

Log Message:
Enable compat sigreturn system call.

The previous bug in netbsd32___sigaction_sigtramp hid the problem,
as it failed all but the first installation of a signal handler.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sys/compat/netbsd32/netbsd32_sysent.c

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



CVS commit: src/sys/compat/netbsd32

2024-04-29 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Apr 29 14:56:01 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_signal.c

Log Message:
In netbsd32___sigaction_sigtramp continue to use the compat module when
already locked for this process.

Needs pullup to netbsd-10.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/compat/netbsd32/netbsd32_signal.c

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



CVS commit: src/sys/compat/netbsd32

2024-04-29 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Apr 29 14:56:01 UTC 2024

Modified Files:
src/sys/compat/netbsd32: netbsd32_signal.c

Log Message:
In netbsd32___sigaction_sigtramp continue to use the compat module when
already locked for this process.

Needs pullup to netbsd-10.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/compat/netbsd32/netbsd32_signal.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/netbsd32/netbsd32_signal.c
diff -u src/sys/compat/netbsd32/netbsd32_signal.c:1.53 src/sys/compat/netbsd32/netbsd32_signal.c:1.54
--- src/sys/compat/netbsd32/netbsd32_signal.c:1.53	Sat Nov  6 20:42:56 2021
+++ src/sys/compat/netbsd32/netbsd32_signal.c	Mon Apr 29 14:56:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_signal.c,v 1.53 2021/11/06 20:42:56 thorpej Exp $	*/
+/*	$NetBSD: netbsd32_signal.c,v 1.54 2024/04/29 14:56:01 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.53 2021/11/06 20:42:56 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.54 2024/04/29 14:56:01 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT) 
 #include "opt_ktrace.h"
@@ -184,7 +184,7 @@ netbsd32___sigaction_sigtramp(struct lwp
 		 */
 #ifdef __HAVE_STRUCT_SIGCONTEXT
 		struct proc *p = l->l_proc;
-		bool sigcontext_valid = false;
+		bool sigcontext_valid;
 
 		/*
 		 * We need to ensure the compat_netbsd32_16 module
@@ -196,9 +196,7 @@ netbsd32___sigaction_sigtramp(struct lwp
 			kernconfig_lock();
 			(void)module_autoload("compat_netbsd32_16",
 			MODULE_CLASS_ANY);
-			if (netbsd32_sendsig_sigcontext_16_hook.hooked) {
-sigcontext_valid = true;
-			}
+			sigcontext_valid = netbsd32_sendsig_sigcontext_16_hook.hooked;
 			mutex_enter(_lock);
 			/*
 			 * Prevent unload of compat module while
@@ -207,6 +205,11 @@ netbsd32___sigaction_sigtramp(struct lwp
 			p->p_lflag |= PL_SIGCOMPAT;
 			mutex_exit(_lock);
 			kernconfig_unlock();
+		} else {
+			/*
+			 * Module is already loaded and locked in memory
+			 */
+			sigcontext_valid = netbsd32_sendsig_sigcontext_16_hook.hooked;
 		}
 		if (!sigcontext_valid) {
 			return EINVAL;



Re: disklabel change?

2024-04-22 Thread Michael van Elst
pr...@welche.eu (Patrick Welche) writes:

>In fact, the difference is between "-t" and "-rt":

>I deem "-t" output to be correct (and matches what I had in /etc/diskpart)


The in-kernel disklabel gets the RAW_PART from by the disk geometry
and if RAW_PART == 3, it gets d_partitions[2] from the MBR partition
table.

That explains why 'disklabel -t' looks correct, it shows the in-kernel
disklabel.

It doesn't explain why the on-disk label has the entries swapped.
When you edit the disklabel, the kernel writes to the disk. When
that corrects the error, the bug is in the disklabel program,
otherwise it's in the kernel.



Re: RPi 4b Wifi Device

2024-04-21 Thread Michael van Elst
michael.chepo...@gmail.com (Michael Cheponis) writes:

>I use the built-in GigE adaptor on the RPi 4B, because it's convenient as I
>have wired ethernet most places.   So I can't help with WiFi.

Ethernet is also faster, even when the WiFi chip does 802.11ac.

For Wifi on a RPI4b:

With RPI-OS running iperf3 shows about 80Mbit/s.
NetBSD (-current, but -10 should be similar) gets me about 40MBit/s.

Wifi is connected to a SDHC controller, and handling I/O there generates
quite some overhead (while iperf3 is running):

  PID   LID USERNAME PRI STATE   TIME   WCPUCPU NAME  COMMAND
0   118 root 123 CPU/1   1:33 39.45% 39.45% sdmmc0[system]
 7467 12269 mlelstv   85 mutex/2 0:03  4.79%  4.79% - iperf3
0 3 root 222 IDLE/0  0:04  2.59%  2.59% softnet*0 [system]
0   101 root 222 IDLE/3  0:03  1.81%  1.81% softnet*3 [system]
030 root 222 IDLE/2  0:02  1.32%  1.32% softnet*2 [system]
024 root 222 IDLE/1  0:02  0.93%  0.93% softnet*1 [system]

That's about 80% of one core.



Re: RPi 4b Wifi Device

2024-04-20 Thread Michael van Elst
tomd...@wavecable.com ("Thomas D. Dean") writes:

># wpa_cli status
>Selected interface 'bwfm0'
>21:58:44.815: bssid=60:38:e0:db:a9:7a
>freq=0
>ssid=tddhome
>id=0
>mode=station
>pairwise_cipher=TKIP
>group_cipher=TKIP
>key_mgmt=WPA-PSK
>wpa_state=GROUP_HANDSHAKE
>ip_address=169.254.135.120
>address=e4:5f:01:da:eb:46

>I don't understand where the inet 169.254.135.120 comes from. The router 
>pool is 192.168.1.xxx.

169.254.x.x is a "link local" address. dhcpcd falls back to such an
address, if it doesn't get an answer from a dhcp server. Apparently
wpa_supplicant cannot connect to the network.

>wpa_state=GROUP_HANDSHAKE

says that it still tries to associate. When it's done this would
change to COMPLETED.



Re: RPi 4b Wifi Device

2024-04-19 Thread Michael van Elst
tomd...@wavecable.com ("Thomas D. Dean") writes:

>How do I setup wpa_supplicant?

That depends on what you want to do.

Here are some examples:
https://wiki.netbsd.org/tutorials/how_to_use_wpa_supplicant/


Greetings,


Re: RPi 4b Wifi Device

2024-04-19 Thread Michael van Elst
tomd...@wavecable.com ("Thomas D. Dean") writes:

>On 4/18/24 22:00, Michael van Elst wrote:
>> bwfm0: Firmware file default:brcmfmac43455-sdio.bin
>> bwfm0: Firmware file model-spec: brcmfmac43455-sdio.raspberrypi,4-model-b.bin
>> bwfm0: Found Firmware file: brcmfmac43455-sdio.raspberrypi,4-model-b.bin

>> bwfm0: NVRAM file default:brcmfmac43455-sdio.txt
>> bwfm0: NVRAM file model-spec: brcmfmac43455-sdio.raspberrypi,4-model-b.txt
>> bwfm0: Found NVRAM file: brcmfmac43455-sdio.raspberrypi,4-model-b.txt

>> bwfm0: CLM file default:brcmfmac43455-sdio.clm_blob
>> bwfm0: CLM file model-spec: brcmfmac43455-sdio.raspberrypi,4-model-b.clm_blob
>> bwfm0: Found CLM file: brcmfmac43455-sdio.raspberrypi,4-model-b.clm_blob


>I saw bwfm0: in /var/log/messages, from memory, similar to the ones listed.
>One error. autoconfiguration error: NVRAM file not available.
>The CHIPACTIVE line is missng.


This means, a firmware file isn't found, because it is searched under
a different name.

You should have:

-r--r--r--  1 root  wheel  1863 Mar 28 17:45 
libdata/firmware/if_bwfm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt

and need to create a symlink like:

cd /libdata/firmware/if_bwfm
ln -s brcmfmac43455-sdio.raspberrypi,4-model-b.txt 
"brcmfmac43455-sdio.Raspberry Pi 4 Model B.txt"

Reason is that the platform is canonically named "raspberrypi,4-model-b"
but UEFI chose "Raspberry Pi 4 Model B" instead.


Greetings,


Re: RPi 4b Wifi Device

2024-04-18 Thread Michael van Elst
tomd...@wavecable.com ("Thomas D. Dean") writes:

>What is the wifi device in the RPi 4b? Driver?

It's a chip similar to the one in the older RPIs:

bwfm0: chip 0x4345 rev 6
bwfm0: Firmware file default:brcmfmac43455-sdio.bin
bwfm0: Firmware file model-spec: brcmfmac43455-sdio.raspberrypi,4-model-b.bin
bwfm0: Found Firmware file: brcmfmac43455-sdio.raspberrypi,4-model-b.bin
bwfm0: NVRAM file default:brcmfmac43455-sdio.txt
bwfm0: NVRAM file model-spec: brcmfmac43455-sdio.raspberrypi,4-model-b.txt
bwfm0: Found NVRAM file: brcmfmac43455-sdio.raspberrypi,4-model-b.txt
bwfm0: CLM file default:brcmfmac43455-sdio.clm_blob
bwfm0: CLM file model-spec: brcmfmac43455-sdio.raspberrypi,4-model-b.clm_blob
bwfm0: Found CLM file: brcmfmac43455-sdio.raspberrypi,4-model-b.clm_blob
bwfm0: CHIPACTIVE

bwfm0: flags=0x8843 mtu 1500
ssid  nwkey *
powersave off
bssid ##:##:##:##:##:## chan 100
address: ##:##:##:##:##:##
media: IEEE802.11 autoselect (VHT mode 11ac)
status: active
inet6 fe80:::::%bwfm0/64 flags 0 scopeid 0x3




CVS commit: src/sys/dev/pckbport

2024-04-18 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Apr 18 17:35:53 UTC 2024

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

Log Message:
Renamed border/boundary variables to better describe their use.
Fix edge default values, factor out percentage calculation for more consistent
values. Use device_printf/DPRINTF to show errors instead of aprint variants.
Print raw input for debugging.

Correct capability parsing. Old devices were probed with nonexistent
commands and then used undefined boundary values that made them unusuable.

Fixes PR 57874.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 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.82 src/sys/dev/pckbport/synaptics.c:1.83
--- src/sys/dev/pckbport/synaptics.c:1.82	Tue Sep  5 05:55:12 2023
+++ src/sys/dev/pckbport/synaptics.c	Thu Apr 18 17:35:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.82 2023/09/05 05:55:12 mrg Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.83 2024/04/18 17:35:53 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.82 2023/09/05 05:55:12 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.83 2024/04/18 17:35:53 mlelstv Exp $");
 
 #include 
 #include 
@@ -112,10 +112,10 @@ static int synaptics_edge_bottom = SYNAP
 static int synaptics_edge_motion_delta = 32;
 static u_int synaptics_finger_high = SYNAPTICS_FINGER_LIGHT + 5;
 static u_int synaptics_finger_low = SYNAPTICS_FINGER_LIGHT - 10;
-static int synaptics_horiz_pct = 0;
-static int synaptics_vert_pct = 0;
-static int synaptics_button_pct = 30;
-static int synaptics_button_boundary;
+static int synaptics_hscroll_pct = 0;
+static int synaptics_vscroll_pct = 0;
+static int synaptics_button_pct = 0;
+static int synaptics_button_boundary = SYNAPTICS_EDGE_BOTTOM;
 static int synaptics_button2;
 static int synaptics_button3;
 static int synaptics_two_fingers_emul = 0;
@@ -166,23 +166,26 @@ static int synaptics_movement_threshold_
 static int synaptics_movement_enable_nodenum;
 static int synaptics_button_region_movement_nodenum;
 static int synaptics_aux_mid_button_scroll_nodenum;
-static int synaptics_horiz_pct_nodenum;
-static int synaptics_vert_pct_nodenum;
+static int synaptics_hscroll_pct_nodenum;
+static int synaptics_vscroll_pct_nodenum;
 static int synaptics_button_pct_nodenum;
 
 /*
  * copy of edges so we can recalculate edge limit if there is 
  * vertical scroll region
  */
-static int synaptics_actual_edge_right;
-static int synaptics_actual_edge_bottom;
+static int synaptics_true_edge_right;
+static int synaptics_true_edge_bottom;
 
-static int synaptics_old_vert_pct = 0;
-static int synaptics_old_horiz_pct = 0;
-static int synaptics_old_button_pct = 0;
-static int synaptics_old_button_boundary = SYNAPTICS_EDGE_BOTTOM;
-static int synaptics_old_horiz_edge = SYNAPTICS_EDGE_BOTTOM;
-static int synaptics_old_vert_edge = SYNAPTICS_EDGE_RIGHT;
+/*
+ * invalid old values, recalculate everything
+ */
+static int synaptics_old_vscroll_pct = -1;
+static int synaptics_old_hscroll_pct = -1;
+static int synaptics_old_button_pct = -1;
+static int synaptics_old_button_boundary = -1;
+static int synaptics_old_edge_right = -1;
+static int synaptics_old_edge_bottom = -1;
 
 /*
  * This holds the processed packet data, it is global because multiple
@@ -208,7 +211,7 @@ synaptics_poll_cmd(struct pms_softc *psc
 	int res = pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot, cmd, i, 0,
 	NULL, 0);
 	if (res)
-		aprint_error_dev(psc->sc_dev, "command error %#x\n", cmd[0]);
+		device_printf(psc->sc_dev, "command error %#x\n", cmd[0]);
 	return res;
 }
 
@@ -221,7 +224,7 @@ synaptics_poll_reset(struct pms_softc *p
 	u_char cmd[1] = { PMS_RESET };
 	res = pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot, cmd, 1, 2,
 	resp, 1);
-	aprint_debug_dev(psc->sc_dev, "reset %d 0x%02x 0x%02x\n",
+	DPRINTF(10, >u.synaptics, "reset %d 0x%02x 0x%02x\n",
 	res, resp[0], resp[1]);
 	return res;
 }
@@ -251,80 +254,90 @@ synaptics_special_write(struct pms_softc
 	return res;
 }
 
+static int
+synaptics_value(int pct, int low, int high)
+{
+	return low + pct * (high - low) / 100UL;
+}
+
+static int
+synaptics_percentage(int val, int low, int high)
+{
+	return ((val - low) * 100UL + high - low - 1) / (high - low);
+}
+
 static void
 pms_synaptics_set_boundaries(void)
 {
-	if (synaptics_vert_pct != synaptics_old_vert_pct ) {
-		synaptics_edge_right = synaptics_actual_edge_right -
-		((unsigned long) synaptics_vert_pct *
-		(synaptics_actual_edge_right - synaptics_edge_left)) / 100;
-		synaptics_old_vert_pct = synaptics_vert_pct;
-		synaptics_old_vert_edge = synaptics_edge_right;
+	if (synaptics_vscroll_pct != synaptics_old_vscroll_pct ) {
+		

CVS commit: src/sys/dev/pckbport

2024-04-18 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Apr 18 17:35:53 UTC 2024

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

Log Message:
Renamed border/boundary variables to better describe their use.
Fix edge default values, factor out percentage calculation for more consistent
values. Use device_printf/DPRINTF to show errors instead of aprint variants.
Print raw input for debugging.

Correct capability parsing. Old devices were probed with nonexistent
commands and then used undefined boundary values that made them unusuable.

Fixes PR 57874.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 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.



CVS commit: xsrc/external/mit/xf86-input-ws/dist/src

2024-04-14 Thread Michael van Elst
Module Name:xsrc
Committed By:   mlelstv
Date:   Sun Apr 14 20:10:29 UTC 2024

Modified Files:
xsrc/external/mit/xf86-input-ws/dist/src: ws.c

Log Message:
Only limit the scroll warning, but continue to send the scroll events.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 xsrc/external/mit/xf86-input-ws/dist/src/ws.c

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

Modified files:

Index: xsrc/external/mit/xf86-input-ws/dist/src/ws.c
diff -u xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.17 xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.18
--- xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.17	Wed Feb  7 18:01:48 2024
+++ xsrc/external/mit/xf86-input-ws/dist/src/ws.c	Sun Apr 14 20:10:29 2024
@@ -747,11 +747,13 @@ wsReadInput(InputInfoPtr pInfo)
 			dw = 0;
 		}
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 14
-		static int warned = 0;
-		if ((hscroll || vscroll) && !warned) {
-			warned = 1;
-			xf86Msg(X_WARNING, "%s: hscroll=%d, vscroll=%d\n",
-			pInfo->name, hscroll, vscroll);
+		if (hscroll || vscroll) {
+			static int warned = 0;
+			if (!warned) {
+warned = 1;
+xf86Msg(X_WARNING, "%s: hscroll=%d, vscroll=%d\n",
+pInfo->name, hscroll, vscroll);
+			}
 			valuator_mask_zero(priv->scroll_mask);
 			valuator_mask_set_double(priv->scroll_mask,
 			HSCROLL_AXIS, (double) hscroll);



CVS commit: xsrc/external/mit/xf86-input-ws/dist/src

2024-04-14 Thread Michael van Elst
Module Name:xsrc
Committed By:   mlelstv
Date:   Sun Apr 14 20:10:29 UTC 2024

Modified Files:
xsrc/external/mit/xf86-input-ws/dist/src: ws.c

Log Message:
Only limit the scroll warning, but continue to send the scroll events.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 xsrc/external/mit/xf86-input-ws/dist/src/ws.c

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



Re: hostapd

2024-04-04 Thread Michael van Elst
On Thu, Apr 04, 2024 at 11:28:41AM +0100, Patrick Welche wrote:
> 10:15:22.135344 IP (tos 0x0, ttl 64, id 12912, offset 0, flags [DF], proto 
> TCP (6), length 60)
> 192.168.100.3.60610 > 192.168.100.62.80: Flags [S], cksum 0x783f 
> (correct), seq 50981267, win 65535, options [mss 1460,sackOK,TS val 2022496 
> ecr 0,nop,wscale 6], length 0

> I assume
> 
> hostapd: urtwn0: interface state UNINITIALIZED->ENABLED
> hostapd: urtwn0: AP-ENABLED 
> 
> rules out a monitor mode? or ? The dhcpd response was fine...

dhcpd uses BPF to receive and transmit DHCP packets. So the symptoms would 
point to an issue in the ARP or IP layer.

-- 
        Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: hostapd

2024-04-03 Thread Michael van Elst
pr...@welche.eu (Patrick Welche) writes:

>The system httpd via inetd doesn't receive a web page request from the
>device.
>tcpdump shows the device requesting it, but no response.

If httpd wouldn't run, the request would be answered with
a TCP RST.

If httpd does run, the request (SYN) is answered with a 
TCP SYN/ACK.

Can you say what exactly is "no response" here?


>on the server, telnet localhost 80, GET /, works

Did you configure (in /etc/inetd.conf) http for tcp or tcp6 ?
A 'telnet localhost 80' would see either, but a pure IPv4 client
only sees the 'tcp' one.


Greetings,



Re: raidframe and gpt

2024-03-16 Thread Michael van Elst
p...@whooppee.com (Paul Goyette) writes:

>> Does anyone have an example of how to configure raid0 on a GPT disk?

For a manual setup, you can just reference the wedges like:

# raidctl config file for /dev/rraid0

START array
# numRow numCol numSpare
1 2 0

START disks
NAME=raid0.0
NAME=raid0.1

START layout
# sectPerSU SUsPerParityUnit SUsPerReconUnit RAID_level_1
128 1 1 1

START queue
fifo 100


Auto detection of a RAID works by collecting disks with valid
RAID labels into RAID sets. This also works with wedges, the
actual device or unit number is irrelevant, the RAID set is
identified by the unique serial number in the RAID label.
The serial number is specified with the -I option of raidctl.

Even booting from a RAID on GPT is possible with a recent bootloader
and an autoconfigured RAID set.


Here is more about RAID on GPT:

https://wiki.netbsd.org/users/spz/moderndisk/



>> I can easily set the partition type with gpt, but how do I reserve
>> space for the raid component label?  Do I need to reserve that space?

You don't, the components are the GPT partitions.


>> Also, does raidframe understand the NAME=gpt-label syntax in the
>> config file?  Or does it require me to specify the particular dk ?
>> (And what happens if something moves and  changes?)

I've added support for the NAME= Syntax some time ago.


>One more quuestion: the raidctl man page talks about partitioning the
>raid device using mbr partitions.  Is it possible to use GPT here?
>Will the resulting wedges show up automatically?

Whenever you create a raid device (raidN attaches), it will be
scanned for wedges like a regular disk device.

# dkctl dk4 getwedgeinfo
dk4 at raid2: tank
dk4: 4294967296 blocks at 128, type: ffs

# grep tank /etc/fstab
NAME=tank   /tank   ffs rw,log  1 2

This system configures a RAID1 of two RAID0 sets. That's not supported
by the RAID autoconfiguration, so it is created manually at boot time
and obviously the system can't boot from it.




Re: mbrlabel question

2024-03-15 Thread Michael van Elst
ea1...@gmail.com (Ramiro Aceves) writes:

> The following options are available:
> -f Force an update, even if there has been no change.
> -q Performs operations in a quiet fashion.
> -r In conjunction with -w, also update the on-disk label.
> -s sector  Specifies the logical sector number that has to be read from
>the disk in order to find the MBR.  Useful if the disk has
>remapping drivers on it and the MBR is located in a non-
>standard place.  Defaults to 0. 
> -w Update the in-core label if it has been changed.  See also -r.

>I do not know the difference between the in-core and on-disk options,
>what I should use and if I can break something with it.


The BSD partition information (aka "disklabel") exists in memory ("in-core")
and is also written to disk ("on-disk").

If you change only in-core, the change is temporary and volatile. When
the disk is no longer in use, or after a reboot, the changes are gone.

For permanent changes you need to write the on-disk label.

I.e. use

mbrlabel wd0

to show how the disklabel would look like, and use

mbrlabel -rw wd0

to actually change the disklabel permanently.



Re: dwiic errors

2024-03-14 Thread Michael van Elst
p...@whooppee.com (Paul Goyette) writes:

>as soon as you proceed past this point (including normal non-single-
>user boot), the dwiic starts spewing time-out messages.  These
>messages come every 0.5 second or so, and there's usually a hundred
>or more messages before they stop;  in some cases the messages have
>continued to stream by for several minutes (at which point I pressed
>the reset button).  The value for %d is always 0 or 1.

Probably result of

GENERIC:ihidev* at iic?

that is probing for a modern laptop touchpad.

Can you disable ihidev instead of dwiic and see what happens then ?



Re: Problem with umass/scsibus/wd0

2024-03-13 Thread Michael van Elst
On Tue, Mar 12, 2024 at 11:00:02PM -0700, Paul Goyette wrote:
> 
> ``scsictl sd0 start'' makes a little bit of progress, and claims
> to be "fabricating a geometry".  ``gpt show -a sd0'' shows two
> partitions (one for NetBSD backups, and one for Windoze backups)
> 
>   # gpt show sd0
>  startsize  index  contents
>  0   1 PMBR
>  1   1 Pri GPT header
>  2  32 Pri GPT table
> 342014 Unused
>   2048  4294967296  1  GPT part - NetBSD FFSv1/FFSv2
> 4294969344  3518951424  2  GPT part - Windows basic data
> 7813920768   49119 Unused
> 7813969887  32 Sec GPT table
> 7813969919   1 Sec GPT header

That looks fine.

> But it does not seem to progress to the discover-wedges process,
> and no wedges seem to exist:
> 
>   # dkctl sd0 listwedges
>   /dev/rsd0: no wedges configured

The wedge autodetection happens when the device attaches (and failed
since the disk was offline). This is different from disklabels that
are fetched by the first opener (and are usually dropped with
the last close, except traditionally for vnd).

You can manually trigger autodetection with

dkctl sd0 makewedges



Greetings,
-- 
Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: Problem with umass/scsibus/wd0

2024-03-12 Thread Michael van Elst
p...@whooppee.com (Paul Goyette) writes:


>[ 29641.773703] umass0 at uhub11 port 4 configuration 1 interface 0
>[ 29641.773703] umass0: Western Digital (0x1058) Elements 2621 (0x2621), rev 
>3.20/10.34, addr 4
>[ 29641.773703] umass0: using SCSI over Bulk-Only
>[ 29641.793714] scsibus0 at umass0: 2 targets, 1 lun per target
>[ 29641.793714] sd0 at scsibus0 target 0 lun 0:  disk 
>fixed
>[ 29641.793714] sd0(umass0:0:0:0):  Check Condition on CDB: 0x00 00 00 00 00 00
>[ 29641.793714] SENSE KEY:  Not Ready
>[ 29641.793714]  ASC/ASCQ:  Logical Unit Is In Process Of Becoming Ready
>[ 29641.793714] sd0: drive offline


Sounds like that drive isn't spinning up.

The "Elements" product doesn't exactly tell what it is, some units
either come with their own power supply or require non-standard
USB power.

Maybe 'scsictl sd0 start' helps to get the disk online. If that
has an effect you may need 'dkctl sd0 makewedges' if you use a GPT
label.



CVS commit: src/lib/libcrypt

2024-03-09 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  9 13:48:50 UTC 2024

Modified Files:
src/lib/libcrypt: crypt-argon2.c

Log Message:
Don't use uninitialized variable.
Fixes PR 57895.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libcrypt/crypt-argon2.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/libcrypt/crypt-argon2.c
diff -u src/lib/libcrypt/crypt-argon2.c:1.19 src/lib/libcrypt/crypt-argon2.c:1.20
--- src/lib/libcrypt/crypt-argon2.c:1.19	Sun May 29 12:15:00 2022
+++ src/lib/libcrypt/crypt-argon2.c	Sat Mar  9 13:48:50 2024
@@ -207,7 +207,7 @@ estimate_argon2_params(argon2_type atype
 
 		if (clock_gettime(CLOCK_MONOTONIC, ) == -1)
 			goto error;
-		for (; delta.tv_sec < 1 && time < ARGON2_MAX_TIME; ++time) {
+		for (; time < ARGON2_MAX_TIME; ++time) {
 			if (argon2_hash(time, memory, threads,
 			tmp_pwd, sizeof(tmp_pwd), 
 			tmp_salt, sizeof(tmp_salt), 
@@ -221,6 +221,8 @@ estimate_argon2_params(argon2_type atype
 			if (timespeccmp(, , >))
 break; /* broken system... */
 			timespecsub(, , );
+			if (delta.tv_sec >= 1)
+break;
 		}
 	} else {
 		time = *etime;



CVS commit: src/lib/libcrypt

2024-03-09 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  9 13:48:50 UTC 2024

Modified Files:
src/lib/libcrypt: crypt-argon2.c

Log Message:
Don't use uninitialized variable.
Fixes PR 57895.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libcrypt/crypt-argon2.c

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



Re: ccd error with two large components

2024-03-03 Thread Michael van Elst
roland.il...@gmx.de (Roland Illig) writes:

>That's this line:

>> unit =3D *(const int *)newp;

>I don't know at which point newp is validated; maybe that validation is
>missing in this case, although I'd expect it to be in the common sysctl
>infrastructure code.


newp is valid, it's a userland pointer that gets dereferenced by the
kernel. Without SMAP that probably even worked on x86.






CVS commit: src/sys/kern

2024-03-02 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  2 08:59:47 UTC 2024

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

Log Message:
Avoid overflow when computing kern.ipc.shmmax. Keep shmmax (bytes) and
shmall (pages) values aligned and use arithmetic everywhere instead
of shifts.
Should fix PR 57979


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/kern/sysv_shm.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/sysv_shm.c
diff -u src/sys/kern/sysv_shm.c:1.141 src/sys/kern/sysv_shm.c:1.142
--- src/sys/kern/sysv_shm.c:1.141	Wed Oct  9 17:47:13 2019
+++ src/sys/kern/sysv_shm.c	Sat Mar  2 08:59:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysv_shm.c,v 1.141 2019/10/09 17:47:13 chs Exp $	*/
+/*	$NetBSD: sysv_shm.c,v 1.142 2024/03/02 08:59:47 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.141 2019/10/09 17:47:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.142 2024/03/02 08:59:47 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sysv.h"
@@ -961,10 +961,10 @@ shminit(void)
 	ALIGN(shminfo.shmmni * sizeof(struct shmid_ds)));
 
 	if (shminfo.shmmax == 0)
-		shminfo.shmmax = uimax(physmem / 4, 1024) * PAGE_SIZE;
+		shminfo.shmall = uimax(physmem / 4, 1024);
 	else
-		shminfo.shmmax *= PAGE_SIZE;
-	shminfo.shmall = shminfo.shmmax / PAGE_SIZE;
+		shminfo.shmall = shminfo.shmmax / PAGE_SIZE;
+	shminfo.shmmax = (uint64_t)shminfo.shmall * PAGE_SIZE;
 
 	for (i = 0; i < shminfo.shmmni; i++) {
 		cv_init(_cv[i], "shmwait");
@@ -1083,7 +1083,7 @@ sysctl_ipc_shmmax(SYSCTLFN_ARGS)
 		return EINVAL;
 
 	shminfo.shmmax = round_page(newsize);
-	shminfo.shmall = shminfo.shmmax >> PAGE_SHIFT;
+	shminfo.shmall = shminfo.shmmax / PAGE_SIZE;
 
 	return 0;
 }



CVS commit: src/sys/kern

2024-03-02 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  2 08:59:47 UTC 2024

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

Log Message:
Avoid overflow when computing kern.ipc.shmmax. Keep shmmax (bytes) and
shmall (pages) values aligned and use arithmetic everywhere instead
of shifts.
Should fix PR 57979


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/kern/sysv_shm.c

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



Re: NetBSD and ECC RAM?

2024-02-29 Thread Michael van Elst
kevin.bowl...@kev009.com (Kevin Bowling) writes:

>Servers tend to have BMCs, so you can execute 'ipmitool sensors' and
>'ipmi sel elist' to get the information out.

ECC information is usually not provided by sensors. ECC errors may
be listed in the SEL, but even this usually occurs only when some
undocumented limit is reached. Often the messages also do not indicate
the memory module that produced the error.


>Linux has the 'EDAC' subsystem but I don't think it gains you so much
>if you have a BMC.

It gives you the data from the ECC circuits, immediately. So data is
no longer hidden by the BMC, you get precise information and you can
apply your own policies for e.g. replacing memory modules or migrating
services to other hardware.

The OS could be smart, lock out bad memory regions, recover some
errors by e.g. paging in text data again or even use mirrored RAM
(with motherboard support).


>A lot of fragile chipset specific code to get that.

Indeed.


Greetings,



CVS commit: src/sys/arch/virt68k/virt68k

2024-02-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Feb 25 14:35:31 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: trap.c

Log Message:
Don't crash in copyin/copyout when a NULL pointer is passed.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/virt68k/trap.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/virt68k/virt68k

2024-02-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Feb 25 14:35:31 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: trap.c

Log Message:
Don't crash in copyin/copyout when a NULL pointer is passed.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/virt68k/trap.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/virt68k/virt68k/trap.c
diff -u src/sys/arch/virt68k/virt68k/trap.c:1.2 src/sys/arch/virt68k/virt68k/trap.c:1.3
--- src/sys/arch/virt68k/virt68k/trap.c:1.2	Sat Jan 20 00:15:33 2024
+++ src/sys/arch/virt68k/virt68k/trap.c	Sun Feb 25 14:35:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.2 2024/01/20 00:15:33 thorpej Exp $	*/
+/*	$NetBSD: trap.c,v 1.3 2024/02/25 14:35:31 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.2 2024/01/20 00:15:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.3 2024/02/25 14:35:31 mlelstv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -554,7 +554,7 @@ trap(struct frame *fp, int type, unsigne
 
 		va = trunc_page((vaddr_t)v);
 
-		if (map == kernel_map && va == 0) {
+		if (map == kernel_map && va == 0 && onfault == 0) {
 			printf("trap: bad kernel %s access at 0x%x\n",
 			(ftype & VM_PROT_WRITE) ? "read/write" :
 			"read", v);



Re: Issues with lseek(2) on a block device

2024-02-24 Thread Michael van Elst
t...@panix.com (Thor Lancelot Simon) writes:

>Probably not a good idea to start with lseek() because if you _do_
>encounter a tape device, seeking to SEEK_END could take you an extremely
>long time.

lseek() doesn't move the tape. But the open() or close() may trigger
tape operations like loading or winding. Special files are special.



CVS commit: src/sys/dev/scsipi

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 22:06:50 UTC 2024

Modified Files:
src/sys/dev/scsipi: sd.c

Log Message:
Don't try to discover wedges when the unit isn't online.


To generate a diff of this commit:
cvs rdiff -u -r1.335 -r1.336 src/sys/dev/scsipi/sd.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/scsipi

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 22:06:50 UTC 2024

Modified Files:
src/sys/dev/scsipi: sd.c

Log Message:
Don't try to discover wedges when the unit isn't online.


To generate a diff of this commit:
cvs rdiff -u -r1.335 -r1.336 src/sys/dev/scsipi/sd.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/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.335 src/sys/dev/scsipi/sd.c:1.336
--- src/sys/dev/scsipi/sd.c:1.335	Sun Aug 28 10:26:37 2022
+++ src/sys/dev/scsipi/sd.c	Sat Feb 24 22:06:49 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.335 2022/08/28 10:26:37 mlelstv Exp $	*/
+/*	$NetBSD: sd.c,v 1.336 2024/02/24 22:06:49 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.335 2022/08/28 10:26:37 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.336 2024/02/24 22:06:49 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -351,8 +351,9 @@ sdattach(device_t parent, device_t self,
 	}
 	aprint_normal("\n");
 
-	/* Discover wedges on this disk. */
-	dkwedge_discover(>sc_dkdev);
+	/* Discover wedges on this disk if it is online */
+	if (result == SDGP_RESULT_OK)
+		dkwedge_discover(>sc_dkdev);
 
 	/*
 	 * Establish a shutdown hook so that we can ensure that



CVS commit: src/sys/netinet6

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 21:41:13 UTC 2024

Modified Files:
src/sys/netinet6: icmp6.c raw_ip6.c

Log Message:
Deliver timestamps also to raw sockets.
Fixes PR 57955


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.183 -r1.184 src/sys/netinet6/raw_ip6.c

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



CVS commit: src/sys/netinet6

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 21:41:13 UTC 2024

Modified Files:
src/sys/netinet6: icmp6.c raw_ip6.c

Log Message:
Deliver timestamps also to raw sockets.
Fixes PR 57955


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.183 -r1.184 src/sys/netinet6/raw_ip6.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/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.255 src/sys/netinet6/icmp6.c:1.256
--- src/sys/netinet6/icmp6.c:1.255	Sat Dec  9 15:21:02 2023
+++ src/sys/netinet6/icmp6.c	Sat Feb 24 21:41:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.255 2023/12/09 15:21:02 pgoyette Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.256 2024/02/24 21:41:13 mlelstv Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.255 2023/12/09 15:21:02 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.256 2024/02/24 21:41:13 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1987,7 +1987,8 @@ icmp6_rip6_input(struct mbuf **mp, int o
 		}
 #endif
 		else if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {
-			if (last->inp_flags & IN6P_CONTROLOPTS)
+			if (last->inp_flags & IN6P_CONTROLOPTS ||
+			SOOPT_TIMESTAMP(last->inp_socket->so_options))
 ip6_savecontrol(last, , ip6, n);
 			/* strip intermediate headers */
 			m_adj(n, off);
@@ -2014,7 +2015,8 @@ icmp6_rip6_input(struct mbuf **mp, int o
 	} else
 #endif
 	if (last) {
-		if (last->inp_flags & IN6P_CONTROLOPTS)
+		if (last->inp_flags & IN6P_CONTROLOPTS ||
+		SOOPT_TIMESTAMP(last->inp_socket->so_options))
 			ip6_savecontrol(last, , ip6, m);
 		/* strip intermediate headers */
 		m_adj(m, off);

Index: src/sys/netinet6/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.183 src/sys/netinet6/raw_ip6.c:1.184
--- src/sys/netinet6/raw_ip6.c:1.183	Wed Mar 22 03:17:18 2023
+++ src/sys/netinet6/raw_ip6.c	Sat Feb 24 21:41:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.183 2023/03/22 03:17:18 ozaki-r Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.184 2024/02/24 21:41:13 mlelstv Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.183 2023/03/22 03:17:18 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.184 2024/02/24 21:41:13 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -140,7 +140,8 @@ rip6_sbappendaddr(struct inpcb *last, st
 {
 	struct mbuf *opts = NULL;
 
-	if (last->inp_flags & IN6P_CONTROLOPTS)
+	if (last->inp_flags & IN6P_CONTROLOPTS ||
+	SOOPT_TIMESTAMP(last->inp_socket->so_options))
 		ip6_savecontrol(last, , ip6, n);
 
 	m_adj(n, hlen);



CVS commit: src/sys/netinet

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 21:39:05 UTC 2024

Modified Files:
src/sys/netinet: if_arp.c

Log Message:
Attribute debug message.
Fixes PR 57959


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/sys/netinet/if_arp.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/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.311 src/sys/netinet/if_arp.c:1.312
--- src/sys/netinet/if_arp.c:1.311	Tue Nov 15 10:47:39 2022
+++ src/sys/netinet/if_arp.c	Sat Feb 24 21:39:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.311 2022/11/15 10:47:39 roy Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.312 2024/02/24 21:39:05 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.311 2022/11/15 10:47:39 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.312 2024/02/24 21:39:05 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1355,8 +1355,8 @@ arp_llinfo_output(struct ifnet *ifp, __u
 		if (sip.s_addr == INADDR_ANY) {
 			char ipbuf[INET_ADDRSTRLEN];
 
-			log(LOG_DEBUG, "source can't be "
-			"determined: dst=%s\n",
+			log(LOG_DEBUG, "%s: source can't be "
+			"determined: dst=%s\n", __func__,
 			IN_PRINT(ipbuf, ));
 			return;
 		}



CVS commit: src/sys/netinet

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 21:39:05 UTC 2024

Modified Files:
src/sys/netinet: if_arp.c

Log Message:
Attribute debug message.
Fixes PR 57959


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/sys/netinet/if_arp.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/seq

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 10:10:05 UTC 2024

Modified Files:
src/usr.bin/seq: seq.c

Log Message:
Chose better number format.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/seq/seq.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/seq/seq.c
diff -u src/usr.bin/seq/seq.c:1.12 src/usr.bin/seq/seq.c:1.13
--- src/usr.bin/seq/seq.c:1.12	Sat Mar 20 22:10:17 2021
+++ src/usr.bin/seq/seq.c	Sat Feb 24 10:10:04 2024
@@ -31,7 +31,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2005\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: seq.c,v 1.12 2021/03/20 22:10:17 cheusov Exp $");
+__RCSID("$NetBSD: seq.c,v 1.13 2024/02/24 10:10:04 mlelstv Exp $");
 #endif /* not lint */
 
 #include 
@@ -56,6 +56,8 @@ __RCSID("$NetBSD: seq.c,v 1.12 2021/03/2
 
 const char *decimal_point = ".";	/* default */
 char default_format[] = { "%g" };	/* default */
+char default_format_fmt[] = { "%%.%uf" };
+#define MAXPRECISION 40
 
 /* Prototypes */
 
@@ -65,9 +67,29 @@ int decimal_places(const char *);
 int numeric(const char *);
 int valid_format(const char *);
 
-char *generate_format(double, double, double, int, char);
+unsigned get_precision(const char *, unsigned);
+char *generate_format(double, double, double, int, char, char *);
 char *unescape(char *);
 
+unsigned
+get_precision(const char *number, unsigned minprec)
+{
+	const char *p;
+	unsigned prec;
+
+	p = strstr(number, decimal_point);
+	if (p) {
+		prec = strlen(number) - (p - number);
+		if (prec > 0)
+			prec -= 1;
+		if (prec > MAXPRECISION)
+			prec = MAXPRECISION;
+	} else
+		prec = 0;
+
+	return prec < minprec ? minprec : prec;
+}
+
 /*
  * The seq command will print out a numeric sequence from 1, the default,
  * to a user specified upper limit by 1.  The lower bound and increment
@@ -79,6 +101,7 @@ main(int argc, char *argv[])
 {
 	int c = 0, errflg = 0;
 	int equalize = 0;
+	unsigned prec;
 	double first = 1.0;
 	double last = 0.0;
 	double incr = 0.0;
@@ -87,6 +110,8 @@ main(int argc, char *argv[])
 	const char *sep = "\n";
 	const char *term = "\n";
 	char pad = ZERO;
+	char buf[6]; /* %.MAXPRECISIONf */
+
 
 	/* Determine the locale's decimal point. */
 	locale = localeconv();
@@ -136,12 +161,16 @@ main(int argc, char *argv[])
 	}
 
 	last = e_atof(argv[argc - 1]);
+	prec = get_precision(argv[argc - 1], 0);
 
-	if (argc > 1)
+	if (argc > 1) {
 		first = e_atof(argv[0]);
+		prec = get_precision(argv[0], prec);
+	}
 	
 	if (argc > 2) {
 		incr = e_atof(argv[1]);
+		prec = get_precision(argv[1], prec);
 		/* Plan 9/GNU don't do zero */
 		if (incr == 0.0)
 			errx(1, "zero %screment", (first < last)? "in" : "de");
@@ -167,8 +196,15 @@ main(int argc, char *argv[])
 	 * XXX to be bug for bug compatible with Plan 9 add a
 		 * newline if none found at the end of the format string.
 		 */
-	} else
-		fmt = generate_format(first, incr, last, equalize, pad);
+	} else {
+		if (prec == 0)
+			fmt = default_format;
+		else {
+			sprintf(buf, default_format_fmt, prec);
+			fmt = buf;
+		}
+		fmt = generate_format(first, incr, last, equalize, pad, fmt);
+	}
 
 	if (incr > 0) {
 		printf(fmt, first);
@@ -428,14 +464,15 @@ decimal_places(const char *number)
  * when "%g" prints as "%e" (this way no width adjustments are made)
  */
 char *
-generate_format(double first, double incr, double last, int equalize, char pad)
+generate_format(double first, double incr, double last,
+int equalize, char pad, char *deffmt)
 {
 	static char buf[256];
 	char cc = '\0';
 	int precision, width1, width2, places;
 
 	if (equalize == 0)
-		return (default_format);
+		return deffmt;
 
 	/* figure out "last" value printed */
 	if (first > last)
@@ -443,12 +480,12 @@ generate_format(double first, double inc
 	else
 		last = first + incr * floor((last - first) / incr);
 
-	sprintf(buf, "%g", incr);
+	sprintf(buf, deffmt, incr);
 	if (strchr(buf, 'e'))
 		cc = 'e';
 	precision = decimal_places(buf);
 
-	width1 = sprintf(buf, "%g", first);
+	width1 = sprintf(buf, deffmt, first);
 	if (strchr(buf, 'e'))
 		cc = 'e';
 	if ((places = decimal_places(buf)))
@@ -456,7 +493,7 @@ generate_format(double first, double inc
 
 	precision = MAX(places, precision);
 
-	width2 = sprintf(buf, "%g", last);
+	width2 = sprintf(buf, deffmt, last);
 	if (strchr(buf, 'e'))
 		cc = 'e';
 	if ((places = decimal_places(buf)))



CVS commit: src/usr.bin/seq

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 10:10:05 UTC 2024

Modified Files:
src/usr.bin/seq: seq.c

Log Message:
Chose better number format.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/seq/seq.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/netstat

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 09:53:26 UTC 2024

Modified Files:
src/usr.bin/netstat: mbuf.c

Log Message:
Don't truncate mo_descr output and protect against missing terminating NUL.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/netstat/mbuf.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/netstat/mbuf.c
diff -u src/usr.bin/netstat/mbuf.c:1.35 src/usr.bin/netstat/mbuf.c:1.36
--- src/usr.bin/netstat/mbuf.c:1.35	Thu Sep  1 10:10:20 2022
+++ src/usr.bin/netstat/mbuf.c	Sat Feb 24 09:53:26 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.c,v 1.35 2022/09/01 10:10:20 msaitoh Exp $	*/
+/*	$NetBSD: mbuf.c,v 1.36 2024/02/24 09:53:26 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)mbuf.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: mbuf.c,v 1.35 2022/09/01 10:10:20 msaitoh Exp $");
+__RCSID("$NetBSD: mbuf.c,v 1.36 2024/02/24 09:53:26 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -225,7 +225,7 @@ dump_drain:
 
 	for (mo = (void *) data, lines = 0; len >= sizeof(*mo);
 	len -= sizeof(*mo), mo++) {
-		char buf[32];
+		char buf[34];
 		if (vflag == 1 &&
 		mo->mo_counter[MOWNER_COUNTER_CLAIMS] == 0 &&
 		mo->mo_counter[MOWNER_COUNTER_EXT_CLAIMS] == 0 &&
@@ -239,7 +239,7 @@ dump_drain:
 		mo->mo_counter[MOWNER_COUNTER_CLUSTER_CLAIMS] ==
 		mo->mo_counter[MOWNER_COUNTER_CLUSTER_RELEASES])
 			continue;
-		snprintf(buf, sizeof(buf), "%16.16s %-13s",
+		snprintf(buf, sizeof(buf), "%16.16s %-13.16s",
 		mo->mo_name, mo->mo_descr);
 		if ((lines % 24) == 0 || lines > 24) {
 			printf("%30s %-8s %10s %10s %10s\n",



CVS commit: src/usr.bin/netstat

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 09:53:26 UTC 2024

Modified Files:
src/usr.bin/netstat: mbuf.c

Log Message:
Don't truncate mo_descr output and protect against missing terminating NUL.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/netstat/mbuf.c

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



Re: Issues with lseek(2) on a block device

2024-02-22 Thread Michael van Elst
mlel...@serpens.de (Michael van Elst) writes:

>But it also does not work for wedges or device mapper volumes
>(zfs vol probably fail too) as these don't implement the
>used internal ioctl for disk devices. At least that part
>would be easy to fix, but of questionable value.



Like this:

Index: sys/miscfs/specfs/spec_vnops.c
===
RCS file: /cvsroot/src/sys/miscfs/specfs/spec_vnops.c,v
retrieving revision 1.218
diff -p -u -r1.218 spec_vnops.c
--- sys/miscfs/specfs/spec_vnops.c  22 Apr 2023 15:32:49 -  1.218
+++ sys/miscfs/specfs/spec_vnops.c  22 Feb 2024 08:54:16 -
@@ -727,11 +727,11 @@ spec_open(void *v)
enum kauth_device_req req;
specnode_t *sn, *sn1;
specdev_t *sd;
+   int dtype;
spec_ioctl_t ioctl;
u_int gen = 0;
const char *name = NULL;
bool needclose = false;
-   struct partinfo pi;
 
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
KASSERTMSG(vp->v_type == VBLK || vp->v_type == VCHR, "type=%d",
@@ -1038,11 +1038,23 @@ spec_open(void *v)
 * forbidden to devsw_detach until closed).  So it is safe to
 * query cdev_type unconditionally here.
 */
-   if (cdev_type(dev) == D_DISK) {
-   ioctl = vp->v_type == VCHR ? cdev_ioctl : bdev_ioctl;
-   if ((*ioctl)(dev, DIOCGPARTINFO, , FREAD, curlwp) == 0)
-   uvm_vnp_setsize(vp,
-   (voff_t)pi.pi_secsize * pi.pi_size);
+   switch (vp->v_type) {
+   case VCHR:
+   ioctl = bdev_ioctl;
+   dtype = cdev_type(dev);
+   break;
+   default:
+   ioctl = bdev_ioctl;
+   dtype = bdev_type(dev);
+   break;
+   }
+   if (dtype == D_DISK) {
+   off_t count;
+   u_int sz;
+
+   if ((*ioctl)(dev, DIOCGMEDIASIZE, , FREAD, curlwp) == 0
+   && (*ioctl)(dev, DIOCGSECTORSIZE, , FREAD, curlwp) == 0)
+   uvm_vnp_setsize(vp, (voff_t)count * sz);
}
 
/* Success!  */



Re: Issues with lseek(2) on a block device

2024-02-21 Thread Michael van Elst
cryintotheblue...@gmail.com (Sad Clouds) writes:

>Hello, for most operating systems determining the size of a block
>device can be done with:

>lseek(fd, 0, SEEK_END);

>However, on NetBSD this does not seem to work.


The disk size is only retrieved at open time and stored in the
cached vnode. stat() therefore only sees the information as
long as the vnode is in cache. Before open, the vnode stores
the bits from e.g. the UFS inode, for UFS that would be zero.

It also does not work for block devices as these aren't really
opened when you call open(). Character devices ("raw disk")
are better, the lseek() or fstat() methods do work for raw
disk devices.

But it also does not work for wedges or device mapper volumes
(zfs vol probably fail too) as these don't implement the
used internal ioctl for disk devices. At least that part
would be easy to fix, but of questionable value.


Currently the only reliable way is to use ioctls. You can use
DIOCGDISKINFO (with proplib) or you can use the two FreeBSD ioctls
DIOCGMEDIASIZE and DIOCGSECTORSIZE to retrieve block count and
size individually as numbers.

For compatibility with netbsd < 8 you may need to fall back to
various older ioctls. That's what is still being implemented
for tools like fsck.




Re: NetBSD and ECC RAM?

2024-02-18 Thread Michael van Elst
michael.chepo...@gmail.com (Michael Cheponis) writes:

>I've been running ECC in the Windows box for years, it seems like a 'no
>brainer' for servers. Servers usually run for years, and Stuff Happens over
>the years [1].
>But I'd prefer a reliable, unhackable, trustable compute fabric.  ECC is
>part of the 'reliable' part.

I agree, but the "box" will run with ECC, even when the OS doesn't
know about it. OS support is needed to get information about errors
and for better fault tolerance.


>I would also like to see per /dev entry ACLs.  I would like to see better
>security than owner-group-everbody permissions.

I have rarely seen ACLs being used for "better security". Even when that
was possible, the complexity usually outweighed any gain in control.

Systems that implied access control through simple rules worked much
better. It's still not a feature that you had to enable or a switch
you toggled, it requires constant effort, in particular on systems
that don't just perform a fixed set of functions.



Re: bug in ftp(1)?

2024-02-18 Thread Michael van Elst
w...@netbsd.org (Thomas Klausner) writes:

>ftp: Receiving HTTP reply: Input line is too long

#define   FTPBUFLEN   (4 * MAXPATHLEN)
char buf[FTPBUFLEN];

That's 4kB.

>curl -v https://sourceforge.net/projects/courier/files/courier-unicode/2.3.=
>0/courier-unicode-2.3.0.tar.bz2

This returns a 5kB HTTP header "content-security-policy".

There is no protocol limit, but common server implementations do limit header
lines to something between 4k (some nginx versions) to 48k (tomcat).



CVS commit: src/sys/ufs/lfs

2024-02-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 17 09:08:21 UTC 2024

Modified Files:
src/sys/ufs/lfs: ulfs_inode.h

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/ulfs_inode.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/ufs/lfs/ulfs_inode.h
diff -u src/sys/ufs/lfs/ulfs_inode.h:1.24 src/sys/ufs/lfs/ulfs_inode.h:1.25
--- src/sys/ufs/lfs/ulfs_inode.h:1.24	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/ulfs_inode.h	Sat Feb 17 09:08:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_inode.h,v 1.24 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: ulfs_inode.h,v 1.25 2024/02/17 09:08:21 mlelstv Exp $	*/
 /*  from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp  */
 
 /*
@@ -147,7 +147,7 @@ struct ulfs_ufid {
 	uint16_t ufid_len;	/* Length of structure. */
 	uint16_t ufid_pad;	/* Force 32-bit alignment. */
 	uint32_t ufid_ino;	/* File number (ino). XXX should be 64 */
-	int32_t	  ufid_gen;	/* Generation number. */
+	int32_t  ufid_gen;	/* Generation number. */
 };
 /* Filehandle structure for exported LFSes */
 struct lfid {



CVS commit: src/sys/ufs/lfs

2024-02-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 17 09:08:21 UTC 2024

Modified Files:
src/sys/ufs/lfs: ulfs_inode.h

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/ulfs_inode.h

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



Re: NetBSD and ECC RAM?

2024-02-15 Thread Michael van Elst
h...@spg.tu-darmstadt.de ("Hauke Fath (SPG)") writes:

>one my favourite blogs is sporting a page on AMD ECC RAM support
>,

>Is this of any relevance to NetBSD, or do we just not bother?


We should have EDAC drivers that should at least report events,
but so far there is nothing...




CVS commit: src/distrib/utils/embedded

2024-02-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Feb 12 11:30:33 UTC 2024

Modified Files:
src/distrib/utils/embedded: mkimage

Log Message:
Quote argument to -n as required. [ -n ] is not a syntax error but
evaluates to true.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/distrib/utils/embedded/mkimage

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

Modified files:

Index: src/distrib/utils/embedded/mkimage
diff -u src/distrib/utils/embedded/mkimage:1.80 src/distrib/utils/embedded/mkimage:1.81
--- src/distrib/utils/embedded/mkimage:1.80	Sun Feb 11 17:29:50 2024
+++ src/distrib/utils/embedded/mkimage	Mon Feb 12 11:30:33 2024
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: mkimage,v 1.80 2024/02/11 17:29:50 christos Exp $
+# $NetBSD: mkimage,v 1.81 2024/02/12 11:30:33 mlelstv Exp $
 #
 # Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -190,7 +190,7 @@ do
 	*)	usage;;
 	esac
 done
-if [ -n ${MKREPRO_TIMESTAMP} ]; then
+if [ -n "${MKREPRO_TIMESTAMP}" ]; then
 	timestamp_opt="-T ${MKREPRO_TIMESTAMP}"
 	volume_opt=",volume_id=$((${MKREPRO_TIMESTAMP} & 0x))"
 fi



CVS commit: src/distrib/utils/embedded

2024-02-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Feb 12 11:30:33 UTC 2024

Modified Files:
src/distrib/utils/embedded: mkimage

Log Message:
Quote argument to -n as required. [ -n ] is not a syntax error but
evaluates to true.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/distrib/utils/embedded/mkimage

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



Re: Raspberry Pi Zero W almost useless

2024-02-09 Thread Michael van Elst
ea1...@gmail.com (Ramiro Aceves) writes:

>Oh yes, that would be a right technical fix for the problem but it's a 
>bit of an aberration in terms of cost and size to use a powered HUB with 
>its own power supply to fix a little thing like the ZeroW, you know ;-)

RPI0-3 models all have issues with power.

Especially on the original RPI1 and RPI0 variants you shouldn't
consider USB as being "hot pluggable". For the other models
hot-plugging low power USB devices (i.e. using 100mA or less)
should be fine. Unfortunately that might rule out things like
many gaming keyboards and also some WLAN dongles.



CVS commit: src/sys/dev/pci

2024-02-08 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Feb  9 06:01:03 UTC 2024

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

Log Message:
Fix DMA sync sizes.
Don't panic for inconsistent queue counter, just print an error to console.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/dev/pci/if_iwm.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/if_iwm.c
diff -u src/sys/dev/pci/if_iwm.c:1.88 src/sys/dev/pci/if_iwm.c:1.89
--- src/sys/dev/pci/if_iwm.c:1.88	Thu Sep 21 09:31:50 2023
+++ src/sys/dev/pci/if_iwm.c	Fri Feb  9 06:01:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwm.c,v 1.88 2023/09/21 09:31:50 msaitoh Exp $	*/
+/*	$NetBSD: if_iwm.c,v 1.89 2024/02/09 06:01:03 mlelstv Exp $	*/
 /*	OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp	*/
 #define IEEE80211_NO_HT
 /*
@@ -106,7 +106,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.88 2023/09/21 09:31:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.89 2024/02/09 06:01:03 mlelstv Exp $");
 
 #include 
 #include 
@@ -1262,8 +1262,9 @@ iwm_free_rx_ring(struct iwm_softc *sc, s
 		struct iwm_rx_data *data = >data[i];
 
 		if (data->m != NULL) {
+			bus_size_t sz = data->m->m_pkthdr.len;
 			bus_dmamap_sync(sc->sc_dmat, data->map, 0,
-			data->map->dm_mapsize, BUS_DMASYNC_POSTREAD);
+			sz, BUS_DMASYNC_POSTREAD);
 			bus_dmamap_unload(sc->sc_dmat, data->map);
 			m_freem(data->m);
 			data->m = NULL;
@@ -1405,8 +1406,9 @@ iwm_reset_tx_ring(struct iwm_softc *sc, 
 		struct iwm_tx_data *data = >data[i];
 
 		if (data->m != NULL) {
+			bus_size_t sz = data->m->m_pkthdr.len;
 			bus_dmamap_sync(sc->sc_dmat, data->map, 0,
-			data->map->dm_mapsize, BUS_DMASYNC_POSTWRITE);
+			sz, BUS_DMASYNC_POSTWRITE);
 			bus_dmamap_unload(sc->sc_dmat, data->map);
 			m_freem(data->m);
 			data->m = NULL;
@@ -1436,8 +1438,9 @@ iwm_free_tx_ring(struct iwm_softc *sc, s
 		struct iwm_tx_data *data = >data[i];
 
 		if (data->m != NULL) {
+			bus_size_t sz = data->m->m_pkthdr.len;
 			bus_dmamap_sync(sc->sc_dmat, data->map, 0,
-			data->map->dm_mapsize, BUS_DMASYNC_POSTWRITE);
+			sz, BUS_DMASYNC_POSTWRITE);
 			bus_dmamap_unload(sc->sc_dmat, data->map);
 			m_freem(data->m);
 			data->m = NULL;
@@ -1517,7 +1520,7 @@ iwm_ict_reset(struct iwm_softc *sc)
 	iwm_disable_interrupts(sc);
 
 	memset(sc->ict_dma.vaddr, 0, IWM_ICT_SIZE);
-	bus_dmamap_sync(sc->sc_dmat, sc->ict_dma.map, 0, IWM_ICT_SIZE,
+	bus_dmamap_sync(sc->sc_dmat, sc->ict_dma.map, 0, sc->ict_dma.size,
 	BUS_DMASYNC_PREWRITE);
 	sc->ict_cur = 0;
 
@@ -3766,7 +3769,7 @@ iwm_rx_addbuf(struct iwm_softc *sc, int 
 	if (size <= MCLBYTES) {
 		MCLGET(m, M_DONTWAIT);
 	} else {
-		MEXTMALLOC(m, IWM_RBUF_SIZE, M_DONTWAIT);
+		MEXTMALLOC(m, size, M_DONTWAIT);
 	}
 	if ((m->m_flags & M_EXT) == 0) {
 		m_freem(m);
@@ -3778,7 +3781,7 @@ iwm_rx_addbuf(struct iwm_softc *sc, int 
 		fatal = 1;
 	}
 
-	m->m_len = m->m_pkthdr.len = m->m_ext.ext_size;
+	m->m_len = m->m_pkthdr.len = size;
 	err = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m,
 	BUS_DMA_READ|BUS_DMA_NOWAIT);
 	if (err) {
@@ -4452,12 +4455,17 @@ iwm_cmd_done(struct iwm_softc *sc, int q
 	wakeup(>desc[idx]);
 
 	if (((idx + ring->queued) % IWM_TX_RING_COUNT) != ring->cur) {
-		aprint_error_dev(sc->sc_dev,
+		device_printf(sc->sc_dev,
 		"Some HCMDs skipped?: idx=%d queued=%d cur=%d\n",
 		idx, ring->queued, ring->cur);
 	}
 
-	KASSERT(ring->queued > 0);
+	if (ring->queued == 0) {
+		splx(s);
+		device_printf(sc->sc_dev, "cmd_done with empty ring\n");
+		return;
+	}
+
 	if (--ring->queued == 0)
 		iwm_clear_cmd_in_flight(sc);
 
@@ -4785,7 +4793,7 @@ iwm_tx(struct iwm_softc *sc, struct mbuf
 		| ((seg->ds_len) << 4);
 	}
 
-	bus_dmamap_sync(sc->sc_dmat, data->map, 0, data->map->dm_mapsize,
+	bus_dmamap_sync(sc->sc_dmat, data->map, 0, m->m_pkthdr.len,
 	BUS_DMASYNC_PREWRITE);
 	bus_dmamap_sync(sc->sc_dmat, ring->cmd_dma.map,
 	(uint8_t *)cmd - (uint8_t *)ring->cmd, sizeof(*cmd),



CVS commit: src/sys/dev/pci

2024-02-08 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Feb  9 06:01:03 UTC 2024

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

Log Message:
Fix DMA sync sizes.
Don't panic for inconsistent queue counter, just print an error to console.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/dev/pci/if_iwm.c

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



Re: NetBSD 10.0 RC_3 GENERIC amd64 home built kernel doesn't boot

2024-02-04 Thread Michael van Elst
fekete.zol...@minux.hu (=?UTF-8?Q?Fekete_Zolt=C3=A1n?=) writes:

>Hi There,

Hi,

maybe you can provide more information.


>I have a laptop from 2013, and I'm playing around with it.
>I've just compiled a kernel with the command:

>./build.sh -T ../tools -O ../obj -U -N1 -j2 kernel=GENERIC

is that from netbsd-10 sources? Did you change the GENERIC
configuration?


>... boot device: wd0
>... root on wd0c dumps on wd0b
>... vfs_mountroot: can't open root device

wd0c wouldn't be a standard installation. Usually you write a disklabel
that uses wd0a as the root partition.


>... cannot mount root, error = 6

error 6 could mean that the wd0 disk doesn't exist or that partition
wd0c doesn't contain a valid filesystem or that you have a stripped
kernel that lacks the filesystem code.


>I've checked, and as expected, DKWEDGE options are set properly as 
>mentioned in 'man dk(4)'.

What DKWEDGE options did you set?



>The system just boots fine with the kernel bundled in the installation 
>image.

Then you could show your disk layout as seen by the bundled kernel,
also what that kernel prints for 'boot device' and 'root on' and
what filesystem you used.




Re: MNT Reform2 USB LCP flash

2024-02-04 Thread Michael van Elst
staf...@shangtai.net (=?UTF-8?B?U3RhZmZhbiBUaG9tw6lu?=) writes:

>While I was fiddling around with it, I booted a FreeBSD-14 thumbdrive 
>and there it does work as well, and their driver helpfully tells you 
>what quirks it uses. This is what I found:

>umass quirks: 0xc104
>0x0004 - NO_START_STOP, "The drive does not support START STOP"
>0x0100 - NO_GETMAXLUN, "No GetMaxLun call"
>0x4000 - NO_SYNCHRONIZE_CACHE, "Deice cannot handle a SCSI synchronize 
>cache command."
>0x8000 - NO_PREVENT_ALLOW, "Device does not support PREVENT/ALLOW MEDIUM 
>REMOVAL"

>da: quirks: 0x2
>0x2 NO_6_BYTE - use SBC (10-byte) commands instead of RBC (6-byte) commands


There is sys/dev/usb/umass_quirks.c.

These quirks exist:

PQUIRK_NOSYNCCACHE (like NO_SYNCHRONIZE_CACHE)
PQUIRK_NODOORLOCK (like NO_PREVENT_ALLOW)
PQUIRK_ONLYBIG (like NO_6_BYTE)

We don't do GetMaxLun.

There seems to be nothing yet for NO_START_STOP. There is

PQUIRK_START

that forces a start at attach time. But at open time when
the unit still does not report ready, we issue the comamnd
again (and fail if it doesn't succeed). We probably need
another quirk PQUIRK_NOSTART and check it in scsipi_start()
similar to the PQUIRK_NODOORLOCK in scsipi_prevent().



Re: MNT Reform2 USB LCP flash

2024-02-04 Thread Michael van Elst
On Sun, Feb 04, 2024 at 10:37:59AM +0200, Staffan Thomen wrote:

> [ 214.0188739] umass0: NXP (0x1fc9) LPC1XXX IFLASH (0x000b), rev 2.00/7.04,

> [ 214.0288745] sd0(umass0:0:0:0):  sense debug information:
> [ 214.0288745] code 0x70 valid 0
> [ 214.0288745] seg 0x0 key 0x2 ili 0x0 eom 0x0 fmark 0x0
> 
> [ 214.0288745] info: 0x0 0x0 0x0 0x0 followed by 10 extra bytes
> [ 214.0288745] extra (up to 10 bytes): 0x0 0x0 0x0 0x0 0x30 0x1 0x0 0x0
> 0x0 0x0

That's what the device answers, but I cannot tell why. Maybe
the device is not (yet) in the correct mode to accept USB
access.

The product code 0x1fc9:0x000b seems to be a LPC11U24,
there is an application note AN11305 from NXP for
"USB In-System Programming with th LPC11U3X/LPC1U2X",
but I didn't find any hints in that document.


Greetings,
-- 
        Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: MNT Reform2 USB LCP flash

2024-02-04 Thread Michael van Elst
On Sun, Feb 04, 2024 at 09:58:39AM +0200, Staffan Thomén wrote:
> 
> The man page for scsictl(8) says that SCSIPI_DEBUG is the required option...

SCSIPI_DEBUG is it.

It should also set the default debug flags (that the ioctl may
change).

Greetings,
-- 
    Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: MNT Reform2 USB LCP flash

2024-02-03 Thread Michael van Elst
On Sat, Feb 03, 2024 at 09:55:47PM +0200, Staffan Thomén wrote:
> Staffan Thomen wrote:
> > [ 188.679957] sd0: 34816, 1 cyl, 64 head, 32 sec, 512 bytes/sect x 68
> > sectors
> > [ 188.689958] autoconfiguration error: sd0: unable to open device,
> > error = 5
> 
> Any thoughts of how to continue debugging this?


A kernel compiled with SCSI_DEBUG can show which commands to the
device actually fail and how. This should be the initial TEST_UNIT_READY
and possibly the START command. No idea why, it's possible that
these are not implemented and errors need to be ignored.


Greetings,
-- 
        Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: shrinking a filesystem using resize_ffs(8)

2024-02-01 Thread Michael van Elst
jscha...@netmeister.org (Jan Schaumann) writes:

>Hi,

Hi,

>$ sudo newfs -C 2 /dev/rvnd0a

There is no '-C'. Maybe -O 2 ?

But resize_ffs doesn't support shrinking FFS2 and should
complain when you try.


>[ back to two '1048576' sized partitions ]

>$ sudo fsck_ffs -y -f /dev/rvnd0b
>[ all ok ]

The 'b' filesystem was probably never changed but maybe trashed in
a way that fsck doesn't understand.


>$ sudo resize_ffs -v /dev/rvnd0b
>No change requested: already 524288 blocks

The superblock and partition agree. Nothing
to do and nothing to check.


>$ sudo fsck_ffs -y -f /dev/rvnd0a
>** /dev/rvnd0a

>CANNOT READ: BLK 2010160
>CONTINUE? yes

The 'a' filesystem still thinks it is 1GB and you try to shrink
it. But the disklabel already restricts access to the lower half.
Any attempt to access data from the upper half fails.


>$ sudo resize_ffs -v /dev/rvnd0a
>resize_ffs: read failed: Invalid argument

Dito. Shrinking requires access to all the data.


>So... how do I shrink a filesystem?

You tell resize_fsck the new size with -s and then
reduce the partition size accordingly.






Re: MNT Reform2 USB LCP flash

2024-01-26 Thread Michael van Elst
k...@munnari.oz.au (Robert Elz) writes:

>I have been meaning to suggest for ages that we remove all the
>geometry nonsense from everywhere in the kernel, except those
>drivers that actually need it.

We use that nonsense without actually knowing.

The "cylinder" value is used to sort disk accesses.
The "sector" value was used to optimize filesystem allocation.

Neither takes the values as is (the values are mostly fake
anyway), but as a hint.

Newer technologies may not use C/H/S coordinates, but every HDD
still uses cylinders and every SSD has a topology based on erase
blocks where "cylinder" could be a hint to optimize accesses.

So, such information should not be removed but needs to be exposed.
Better if it were exposed 1:1 from the underlying technology, but
it still needs to be compatible with the abstractions that use
it.

Doesn't mean that you could not find a better abstraction for a
storage medium in the future. For now, pretending everything is
a rotational disk from 50 years ago doesn't hurt but helps.



Re: MNT Reform2 USB LCP flash

2024-01-26 Thread Michael van Elst
k...@munnari.oz.au (Robert Elz) writes:

>If you are able, try building a kernel with the patch below.

>I suspect this should probably apply without too many problems
>to any reasonably modern NetBSD kernel version, patch is to
>src/sys/dev/scsipi/sd.c

>+  if (dp->cyls == 0)  /* very small devices */
>+  dp->cyls = 1;   /* round up # cyls */


People using the cylinder count assume that a disk is made of cylinders,
heads (surfaces) and sectors and that cyls * heads * sectors is the capacity.

For modern disks that's not true.

The values are intentionally truncated so that such people cannot access
blocks beyond the end of the device and software that (still) uses C/H/S
coordinates has a chance to use modern devices.

An alternative handling would be round up the values so that you can reach
all blocks using C/H/S coordinates and non-existent blocks return errors.
But what purpose would such fictious C/H/S coordinates serve and would
software relying on C/H/S be able to handle the errors ?

Rounding up only for disks with less than one full cylinder only helps
people that suffer from oudenophobia.



Re: MNT Reform2 USB LCP flash

2024-01-26 Thread Michael van Elst
staf...@shangtai.net (=?UTF-8?B?U3RhZmZhbiBUaG9tw6lu?=) writes:

>[21.611880] scsibus1 at umass1: 2 targets, 1 lun per target
>[21.611880] sd1 at scsibus1 target 0 lun 0: 1.0> disk removable
>[21.611880] sd1: fabricating a geometry
>[21.611880] sd1: 34816, 0 cyl, 64 head, 32 sec, 512 bytes/sect x 68 
>sectors
>[21.611880] autoconfiguration error: sd1: unable to open device, 
>error = 5

>It seems a bit interesting that it reports 2 targets, but only creates 
>an sd for one,

The '2 targets' is a parameter of 'scsibus1', it tells the SCSI layer
that it may look for up to 2 targets. USB mass storage usually only
has a single 'sd' target, but some also provide an extra 'ses'
enclosure target.


>and 0 cylinders seems a bit suspicous but I don't know if 
>that's ok or not.

When the drive doesn't return a valid geometry, the driver uses
a fake one, based on 64 heads and 32 sectors per head. In your
case the drive is smaller than a single cylinder (64*32), so
you get zero (full) cylinders.

Fortunately the drive geometry isn't really used anywhere. All
accesses just use the logical block addresses.


The EIO (5) error probably occurs because the drive is reported
as 'offline'. This is like a drive with a removable medium but
no medium has been loaded.

It is possible that there needs to be some action to 'load'
the 'medium', or it might just take some time to appear online.
You may use

   scsictl sd1 start

to attempt another access.

The LPC1xxx manual didn't reveal anything obvious about
this problem. It just claims that you can copy the firmware
to the storage. It also doesn't say how, with just 68 sectors
that's not a fake filesystem, you probably need to write
the firmware image to the raw device.



CVS commit: src/bin/dd

2024-01-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jan 26 07:10:04 UTC 2024

Modified Files:
src/bin/dd: args.c

Log Message:
Don't use the signal handler to terminate when nothing is to do (count=0, 
files=0).

The signal handler tries to raise the signal again, so that a parent can 
retrieve
the signal from the exit code. Calling the terminate handler with signal code 0
doesn't raise a signal and dd continues with exit(127) making this case an 
error.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/bin/dd/args.c

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



CVS commit: src/bin/dd

2024-01-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jan 26 07:10:04 UTC 2024

Modified Files:
src/bin/dd: args.c

Log Message:
Don't use the signal handler to terminate when nothing is to do (count=0, 
files=0).

The signal handler tries to raise the signal again, so that a parent can 
retrieve
the signal from the exit code. Calling the terminate handler with signal code 0
doesn't raise a signal and dd continues with exit(127) making this case an 
error.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/bin/dd/args.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/dd/args.c
diff -u src/bin/dd/args.c:1.42 src/bin/dd/args.c:1.43
--- src/bin/dd/args.c:1.42	Fri Jan 14 23:55:16 2022
+++ src/bin/dd/args.c	Fri Jan 26 07:10:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.42 2022/01/14 23:55:16 christos Exp $	*/
+/*	$NetBSD: args.c,v 1.43 2024/01/26 07:10:04 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)args.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: args.c,v 1.42 2022/01/14 23:55:16 christos Exp $");
+__RCSID("$NetBSD: args.c,v 1.43 2024/01/26 07:10:04 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -248,8 +248,10 @@ f_count(char *arg)
 {
 
 	cpy_cnt = strsuftoll("block count", arg, 0, LLONG_MAX);
-	if (!cpy_cnt)
-		terminate(0);
+	if (!cpy_cnt) {
+		summary();
+		exit(0);
+	}
 }
 
 static void
@@ -257,8 +259,10 @@ f_files(char *arg)
 {
 
 	files_cnt = (u_int)strsuftoll("file count", arg, 0, UINT_MAX);
-	if (!files_cnt)
-		terminate(0);
+	if (!files_cnt) {
+		summary();
+		exit(0);
+	}
 }
 
 static void



CVS commit: src/sys/dev/stbi

2024-01-20 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jan 20 13:33:03 UTC 2024

Modified Files:
src/sys/dev/stbi: stb_image.c

Log Message:
Don't put big structures on stack.
Should fix PR 57859.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/stbi/stb_image.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/stbi/stb_image.c
diff -u src/sys/dev/stbi/stb_image.c:1.11 src/sys/dev/stbi/stb_image.c:1.12
--- src/sys/dev/stbi/stb_image.c:1.11	Sat Aug 26 21:03:53 2023
+++ src/sys/dev/stbi/stb_image.c	Sat Jan 20 13:33:03 2024
@@ -430,7 +430,7 @@ extern int  stbi_gif_info_from_file 
 #endif
 #ifdef _KERNEL
 #include 
-__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.11 2023/08/26 21:03:53 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.12 2024/01/20 13:33:03 mlelstv Exp $");
 #include 
 #include 
 #include 
@@ -2144,16 +2144,28 @@ int stbi_jpeg_info(char const *filename,
 
 int stbi_jpeg_test_memory(stbi_uc const *buffer, int len)
 {
-   jpeg j;
-   start_mem(, buffer,len);
-   return decode_jpeg_header(, SCAN_type);
+jpeg *j;
+int res;
+
+j = MALLOC(sizeof(*j));
+if (j == NULL) return 0;
+start_mem(>s, buffer,len);
+res = decode_jpeg_header(j, SCAN_type);
+FREE(j);
+return res;
 }
 
 int stbi_jpeg_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp)
 {
-jpeg j;
-start_mem(, buffer, len);
-return stbi_jpeg_info_raw(, x, y, comp);
+jpeg *j;
+int res;
+
+j = MALLOC(sizeof(*j));
+if (j == NULL) return 0;
+start_mem(>s, buffer, len);
+res = stbi_jpeg_info_raw(j, x, y, comp);
+FREE(j);
+return res;
 }
 
 #ifndef STBI_NO_STDIO
@@ -2523,18 +2535,25 @@ static int do_zlib(zbuf *a, char *obuf, 
 
 char *stbi_zlib_decode_malloc_guesssize(const char * buffer, int len, int initial_size, int *outlen)
 {
-   zbuf a;
-   char *p = MALLOC(initial_size);
-   if (p == NULL) return NULL;
-   a.zbuffer = (uint8 const *) buffer;
-   a.zbuffer_end = (uint8 const *) buffer + len;
-   if (do_zlib(, p, initial_size, 1, 1)) {
-  if (outlen) *outlen = (int) (a.zout - a.zout_start);
-  return a.zout_start;
+   zbuf *a;
+   char *p;
+   char *res = NULL;
+
+   a = MALLOC(sizeof(*a));
+   if (a == NULL) return NULL;
+   p = MALLOC(initial_size);
+   if (p == NULL) goto fail;
+   a->zbuffer = (uint8 const *) buffer;
+   a->zbuffer_end = (uint8 const *) buffer + len;
+   if (do_zlib(a, p, initial_size, 1, 1)) {
+  if (outlen) *outlen = (int) (a->zout - a->zout_start);
+  res = a->zout_start;
} else {
-  FREE(a.zout_start);
-  return NULL;
+  FREE(a->zout_start);
}
+fail:
+   FREE(a);
+   return res;
 }
 
 char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen)
@@ -2544,56 +2563,81 @@ char *stbi_zlib_decode_malloc(char const
 
 char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header)
 {
-   zbuf a;
-   char *p = MALLOC(initial_size);
-   if (p == NULL) return NULL;
-   a.zbuffer = (uint8 const *) buffer;
-   a.zbuffer_end = (uint8 const *) buffer + len;
-   if (do_zlib(, p, initial_size, 1, parse_header)) {
-  if (outlen) *outlen = (int) (a.zout - a.zout_start);
-  return a.zout_start;
+   zbuf *a;
+   char *p;
+   char *res = NULL;
+
+   a = MALLOC(sizeof(*a));
+   if (a == NULL) return NULL;
+   p = MALLOC(initial_size);
+   if (p == NULL) goto fail;
+   a->zbuffer = (uint8 const *) buffer;
+   a->zbuffer_end = (uint8 const *) buffer + len;
+   if (do_zlib(a, p, initial_size, 1, parse_header)) {
+  if (outlen) *outlen = (int) (a->zout - a->zout_start);
+  res = a->zout_start;
} else {
-  FREE(a.zout_start);
-  return NULL;
+  FREE(a->zout_start);
}
+fail:
+   FREE(a);
+   return res;
 }
 
 int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen)
 {
-   zbuf a;
-   a.zbuffer = (uint8 const *) ibuffer;
-   a.zbuffer_end = (uint8 const *) ibuffer + ilen;
-   if (do_zlib(, obuffer, olen, 0, 1))
-  return (int) (a.zout - a.zout_start);
+   zbuf *a;
+   int res;
+
+   a = MALLOC(sizeof(*a));
+   if (a == NULL) return -1;
+   a->zbuffer = (uint8 const *) ibuffer;
+   a->zbuffer_end = (uint8 const *) ibuffer + ilen;
+   if (do_zlib(a, obuffer, olen, 0, 1))
+  res = (int) (a->zout - a->zout_start);
else
-  return -1;
+  res = -1;
+   FREE(a);
+   return res;
 }
 
 char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen)
 {
-   zbuf a;
-   char *p = MALLOC(16384);
-   if (p == NULL) return NULL;
-   a.zbuffer = (uint8 const *) buffer;
-   a.zbuffer_end = (uint8 const *) buffer+len;
-   if (do_zlib(, p, 16384, 1, 0)) {
-  if (outlen) *outlen = (int) (a.zout - a.zout_start);
-  return a.zout_start;
-   } else {
-  FREE(a.zout_start);
-  return NULL;
-   }
+   

CVS commit: src/sys/dev/stbi

2024-01-20 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jan 20 13:33:03 UTC 2024

Modified Files:
src/sys/dev/stbi: stb_image.c

Log Message:
Don't put big structures on stack.
Should fix PR 57859.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/stbi/stb_image.c

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



Re: *oldlenp comes back with wrong value in helper sysctl_createv() function

2024-01-20 Thread Michael van Elst
On Sat, Jan 20, 2024 at 10:48:12AM +0100, Emile 'iMil' Heitor wrote:


Hi,

that's from sysctl.c:

case CTLTYPE_STRING: {
unsigned char buf[1024], *tbuf;
tbuf = buf;
sz = sizeof(buf); 
rc = prog_sysctl([0], namelen, tbuf, , NULL, 0);

The sysctl command first tries with a buffer of 1024 bytes
and retries with the right size when that was too small.

Compared to "probing" with a NULL buffer this saves a round trip
to the kernel for most sysctls.

A simple helper function would always return the needed size and only
copy out when oldp was set. sysctl will check the returned *oldlenp 
against the value passed by the caller and return ENOMEM as appropriate.


Greetings,
-- 
        Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: *oldlenp comes back with wrong value in helper sysctl_createv() function

2024-01-20 Thread Michael van Elst
i...@home.imil.net (Emile 'iMil' Heitor) writes:

>Except it does not, the first time it calls back the helper function,
>*oldlenp value is 1024 no matter what I set it to before.
>But if I return once again (either with ENOMEM or 0, doesn't matter),
>the helper function will now be called with the right *oldlenp value.

The helper function produces the value that is returned in *oldlenp.

If you happen to use CTL_DESCRIBE (e.g. running sysctl -d), it's
not your helper function being called but the sysctl_describe helper
that returns a value of 1024.

Maybe you can show your helper routine and how you call sysctl ?





Re: WireGuard setup in NetBSD 10

2024-01-18 Thread Michael van Elst
k...@krot.org (Kirill Miazine) writes:

>> Maybe he still has auto_ifconfig=NO ?

>no, he didn't... but issue was if_wg not being loaded upon boot -- but
>loaded when ifconfig wg0 create was called.

The perils of the module autoloader.



Re: WireGuard setup in NetBSD 10

2024-01-18 Thread Michael van Elst
mar...@duskware.de (Martin Husemann) writes:

>On Thu, Jan 18, 2024 at 10:23:11AM +0100, Kirill Miazine wrote:
>> Does your custom kernel provide some wg devices initially?

>No, but "ifconfig -C" lists wg as a clonable device, so /etc/ifconfig.wg0
>is loaded.

Maybe he still has auto_ifconfig=NO ?



CVS commit: src/sys/dev/dm

2024-01-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 14 07:56:53 UTC 2024

Modified Files:
src/sys/dev/dm: dm_ioctl.c

Log Message:
Avoid leaving a configured device without resources.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/dm/dm_ioctl.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/dm/dm_ioctl.c
diff -u src/sys/dev/dm/dm_ioctl.c:1.56 src/sys/dev/dm/dm_ioctl.c:1.57
--- src/sys/dev/dm/dm_ioctl.c:1.56	Thu Oct 13 06:10:48 2022
+++ src/sys/dev/dm/dm_ioctl.c	Sun Jan 14 07:56:53 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_ioctl.c,v 1.56 2022/10/13 06:10:48 andvar Exp $  */
+/* $NetBSD: dm_ioctl.c,v 1.57 2024/01/14 07:56:53 mlelstv Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.56 2022/10/13 06:10:48 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.57 2024/01/14 07:56:53 mlelstv Exp $");
 
 /*
  * Locking is used to synchronise between ioctl calls and between dm_table's
@@ -209,18 +209,21 @@ dm_dev_create_ioctl(prop_dictionary_t dm
 		dm_dev_unbusy(dmv);
 		return EEXIST;
 	}
+
+	if ((dmv = dm_dev_alloc()) == NULL)
+		return ENOMEM;
+
 	cf = kmem_alloc(sizeof(*cf), KM_SLEEP);
 	cf->cf_name = dm_cd.cd_name;
 	cf->cf_atname = dm_ca.ca_name;
 	cf->cf_unit = atomic_inc_32_nv(_minor_num);
 	cf->cf_fstate = FSTATE_NOTFOUND;
 	if ((devt = config_attach_pseudo(cf)) == NULL) {
+		dm_dev_free(dmv);
 		kmem_free(cf, sizeof(*cf));
 		aprint_error("Unable to attach pseudo device dm/%s\n", name);
 		return (ENOMEM);
 	}
-	if ((dmv = dm_dev_alloc()) == NULL)
-		return ENOMEM;
 
 	if (uuid)
 		strncpy(dmv->uuid, uuid, DM_UUID_LEN);
@@ -247,7 +250,7 @@ dm_dev_create_ioctl(prop_dictionary_t dm
 
 	prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
 
-	disk_init(dmv->diskp, dmv->name, );
+	disk_init(dmv->diskp, device_xname(devt), );
 	disk_attach(dmv->diskp);
 
 	dmv->diskp->dk_info = NULL;



CVS commit: src/sys/dev/dm

2024-01-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 14 07:56:53 UTC 2024

Modified Files:
src/sys/dev/dm: dm_ioctl.c

Log Message:
Avoid leaving a configured device without resources.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/dm/dm_ioctl.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/fdt

2024-01-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 14 07:53:38 UTC 2024

Modified Files:
src/sys/dev/fdt: fdt_memory.c

Log Message:
Handle multiple memory nodes by type, but still allow an untyped
(non-standard) node named /memory.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/fdt_memory.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/fdt

2024-01-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 14 07:53:38 UTC 2024

Modified Files:
src/sys/dev/fdt: fdt_memory.c

Log Message:
Handle multiple memory nodes by type, but still allow an untyped
(non-standard) node named /memory.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/fdt_memory.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/fdt/fdt_memory.c
diff -u src/sys/dev/fdt/fdt_memory.c:1.9 src/sys/dev/fdt/fdt_memory.c:1.10
--- src/sys/dev/fdt/fdt_memory.c:1.9	Fri Jan 12 18:06:18 2024
+++ src/sys/dev/fdt/fdt_memory.c	Sun Jan 14 07:53:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_memory.c,v 1.9 2024/01/12 18:06:18 skrll Exp $ */
+/* $NetBSD: fdt_memory.c,v 1.10 2024/01/14 07:53:38 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "opt_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.9 2024/01/12 18:06:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.10 2024/01/14 07:53:38 mlelstv Exp $");
 
 #include 
 #include 
@@ -77,26 +77,43 @@ fdt_memory_range_free(struct fdt_memory_
 void
 fdt_memory_get(uint64_t *pstart, uint64_t *pend)
 {
-	const int memory = OF_finddevice("/memory");
+	const void *fdt_data = fdtbus_get_data();
 	uint64_t cur_addr, cur_size;
-	int index, nadd;
+	int index, nadd = 0, off, memory;
 
-	for (index = 0, nadd = 0;
-	 fdtbus_get_reg64(memory, index, _addr, _size) == 0;
-	 index++) {
-		if (cur_size == 0)
-			continue;
-		fdt_memory_add_range(cur_addr, cur_size);
+	off = fdt_node_offset_by_prop_value(fdt_data, -1,
+	"device_type", "memory", sizeof("memory"));
 
-		if (nadd++ == 0) {
-			*pstart = cur_addr;
-			*pend = cur_addr + cur_size;
-			continue;
+	/*
+	 * Device Tree Specification 3.2 says that memory
+	 * nodes are named "memory" and have device_type
+	 * "memory", but if the device_type is missing, try
+	 * to find the (then single) node by name.
+	 */
+	if (off == -FDT_ERR_NOTFOUND)
+		off = fdt_path_offset(fdt_data, "/memory");
+
+	while (off != -FDT_ERR_NOTFOUND) {
+		memory = fdtbus_offset2phandle(off);
+		for (index = 0;
+		 fdtbus_get_reg64(memory, index, _addr, _size) == 0;
+		 index++) {
+			if (cur_size == 0)
+continue;
+			fdt_memory_add_range(cur_addr, cur_size);
+
+			if (nadd++ == 0) {
+*pstart = cur_addr;
+*pend = cur_addr + cur_size;
+continue;
+			}
+			if (cur_addr < *pstart)
+*pstart = cur_addr;
+			if (cur_addr + cur_size > *pend)
+*pend = cur_addr + cur_size;
 		}
-		if (cur_addr < *pstart)
-			*pstart = cur_addr;
-		if (cur_addr + cur_size > *pend)
-			*pend = cur_addr + cur_size;
+		off = fdt_node_offset_by_prop_value(fdt_data, off,
+		"device_type", "memory", sizeof("memory"));
 	}
 	if (nadd == 0)
 		panic("Cannot determine memory size");



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

2024-01-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jan 12 06:23:20 UTC 2024

Modified Files:
src/sys/arch/virt68k/dev: gfrtc_mainbus.c

Log Message:
The interrupt handler needs to clear the interrupt condition
before re-arming the timer. Otherwise the timer could expire
again before clearing the interrupt, the interrupt gets lost
and the clock stops.

On real hardware that could only occur if the timer interval
is extremely short or if there is a higher-than-clock interrupt
that delays processing. In the emulated world however, time
can progress non-continously and this happens often under load.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/dev/gfrtc_mainbus.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/virt68k/dev/gfrtc_mainbus.c
diff -u src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.1 src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.2
--- src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.1	Tue Jan  2 07:40:59 2024
+++ src/sys/arch/virt68k/dev/gfrtc_mainbus.c	Fri Jan 12 06:23:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gfrtc_mainbus.c,v 1.1 2024/01/02 07:40:59 thorpej Exp $	*/
+/*	$NetBSD: gfrtc_mainbus.c,v 1.2 2024/01/12 06:23:20 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2023, 2024 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gfrtc_mainbus.c,v 1.1 2024/01/02 07:40:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gfrtc_mainbus.c,v 1.2 2024/01/12 06:23:20 mlelstv Exp $");
 
 #include 
 #include 
@@ -65,12 +65,12 @@ struct gfrtc_mainbus_softc {
 
 #define	CLOCK_HANDLER()			\
 do {	\
-	/* Get the next alarm set ASAP. */\
-	gfrtc_set_alarm(>sc_gfrtc, sc->sc_interval_ns);		\
-	\
 	/* Clear the interrupt condition. */\
 	gfrtc_clear_interrupt(>sc_gfrtc);\
 	\
+	/* Get the next alarm set ASAP. */\
+	gfrtc_set_alarm(>sc_gfrtc, sc->sc_interval_ns);		\
+	\
 	/* Increment the counter and call the handler. */		\
 	sc->sc_evcnt->ev_count++;	\
 	sc->sc_handler((struct clockframe *)v);\



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

2024-01-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jan 12 06:23:20 UTC 2024

Modified Files:
src/sys/arch/virt68k/dev: gfrtc_mainbus.c

Log Message:
The interrupt handler needs to clear the interrupt condition
before re-arming the timer. Otherwise the timer could expire
again before clearing the interrupt, the interrupt gets lost
and the clock stops.

On real hardware that could only occur if the timer interval
is extremely short or if there is a higher-than-clock interrupt
that delays processing. In the emulated world however, time
can progress non-continously and this happens often under load.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/dev/gfrtc_mainbus.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/i386/stand

2024-01-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jan  6 21:26:43 UTC 2024

Modified Files:
src/sys/arch/i386/stand/efiboot: efidisk.c efidisk.h
src/sys/arch/i386/stand/lib: biosdisk.c exec.c

Log Message:
In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
  hard drives (with geom) and CD-ROM (without).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/efidisk.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/efidisk.h
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/i386/stand/lib/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/arch/i386/stand/efiboot/efidisk.c
diff -u src/sys/arch/i386/stand/efiboot/efidisk.c:1.10 src/sys/arch/i386/stand/efiboot/efidisk.c:1.11
--- src/sys/arch/i386/stand/efiboot/efidisk.c:1.10	Sun May 14 09:07:54 2023
+++ src/sys/arch/i386/stand/efiboot/efidisk.c	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.c,v 1.10 2023/05/14 09:07:54 riastradh Exp $	*/
+/*	$NetBSD: efidisk.c,v 1.11 2024/01/06 21:26:43 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -38,9 +38,12 @@
 #include "biosdisk_ll.h"
 #include "devopen.h"
 #include "efidisk.h"
+#include "bootinfo.h"
 
 static struct efidiskinfo_lh efi_disklist;
 static int nefidisks;
+static struct btinfo_biosgeom *bibg;
+static size_t bibg_len;
 
 #define MAXDEVNAME 39 /* "NAME=" + 34 char part_name */
 
@@ -158,6 +161,23 @@ next:
 		if (edi->bootdev)
 			boot_biosdev = edi->dev;
 	}
+
+	bibg_len = sizeof(*bibg) + nefidisks * sizeof(struct bi_biosgeom_entry);
+	bibg = alloc(bibg_len);
+	if (bibg == NULL)
+		return;
+
+	bibg->num = nefidisks;
+
+	i = 0;
+	TAILQ_FOREACH(edi, _disklist, list) {
+		if (edi->type == BIOSDISK_TYPE_HD) {
+			memset(>disk[i], 0, sizeof(bibg->disk[i]));
+			bibg->disk[i].dev = edi->dev;
+			bibg->disk[i].flags = BI_GEOM_INVALID;
+		}
+		++i;
+	}
 }
 
 static void
@@ -383,3 +403,10 @@ efidisk_get_efi_system_partition(int dev
 	*partition = i;
 	return 0;
 }
+
+void
+efidisk_getbiosgeom()
+{
+	BI_ADD(bibg, BTINFO_BIOSGEOM, bibg_len);
+}
+

Index: src/sys/arch/i386/stand/efiboot/efidisk.h
diff -u src/sys/arch/i386/stand/efiboot/efidisk.h:1.3 src/sys/arch/i386/stand/efiboot/efidisk.h:1.4
--- src/sys/arch/i386/stand/efiboot/efidisk.h:1.3	Mon Apr  2 09:44:18 2018
+++ src/sys/arch/i386/stand/efiboot/efidisk.h	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.h,v 1.3 2018/04/02 09:44:18 nonaka Exp $	*/
+/*	$NetBSD: efidisk.h,v 1.4 2024/01/06 21:26:43 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -41,3 +41,4 @@ TAILQ_HEAD(efidiskinfo_lh, efidiskinfo);
 
 const struct efidiskinfo *efidisk_getinfo(int);
 int efidisk_get_efi_system_partition(int, int *);
+void efidisk_getbiosgeom(void);

Index: src/sys/arch/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.60 src/sys/arch/i386/stand/lib/biosdisk.c:1.61
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.60	Mon Oct  2 00:02:33 2023
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.60 2023/10/02 00:02:33 manu Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.61 2024/01/06 21:26:43 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -1198,11 +1198,13 @@ out:
 static void
 add_biosdisk_bootinfo(void)
 {
+#ifndef EFIBOOT
 	if (bootinfo == NULL) {
 		return;
 	}
 	BI_ADD(_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
 	BI_ADD(_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
+#endif
 	return;
 }
 #endif

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.79 src/sys/arch/i386/stand/lib/exec.c:1.80
--- src/sys/arch/i386/stand/lib/exec.c:1.79	Thu Apr 20 00:42:24 2023
+++ src/sys/arch/i386/stand/lib/exec.c	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.79 2023/04/20 00:42:24 manu Exp $	 */
+/*	$NetBSD: exec.c,v 1.80 2024/01/06 21:26:43 mlelstv Exp $	 */
 
 /*
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -108,6 +108,8 @@
 #endif
 #ifdef EFIBOOT
 #include "efiboot.h"
+#include "biosdisk.h"
+#include "efidisk.h"
 #undef DEBUG	/* XXX */
 #endif
 
@@ -498,6 +500,10 @@ exec_netbsd(const char *file, physaddr_t
 		goto out;
 	}
 #ifdef EFIBOOT
+	BI_ADD(_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
+	BI_ADD(_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
+	efidisk_getbiosgeom();
+
 	efi_load_start = marks[MARK_START];
 
 	/* adjust to the real load address */



CVS commit: src/sys/arch/i386/stand

2024-01-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jan  6 21:26:43 UTC 2024

Modified Files:
src/sys/arch/i386/stand/efiboot: efidisk.c efidisk.h
src/sys/arch/i386/stand/lib: biosdisk.c exec.c

Log Message:
In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
  hard drives (with geom) and CD-ROM (without).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/efidisk.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/efidisk.h
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/i386/stand/lib/exec.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

2024-01-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jan  4 11:18:20 UTC 2024

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

Log Message:
dump topology information with aprint_debug instead of requiring to build
a DEBUG kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/kern/subr_cpu.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

2024-01-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jan  4 11:18:20 UTC 2024

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

Log Message:
dump topology information with aprint_debug instead of requiring to build
a DEBUG kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/kern/subr_cpu.c

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

Modified files:

Index: src/sys/kern/subr_cpu.c
diff -u src/sys/kern/subr_cpu.c:1.19 src/sys/kern/subr_cpu.c:1.20
--- src/sys/kern/subr_cpu.c:1.19	Sat Jul  8 13:59:05 2023
+++ src/sys/kern/subr_cpu.c	Thu Jan  4 11:18:19 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cpu.c,v 1.19 2023/07/08 13:59:05 riastradh Exp $	*/
+/*	$NetBSD: subr_cpu.c,v 1.20 2024/01/04 11:18:19 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019, 2020
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.19 2023/07/08 13:59:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.20 2024/01/04 11:18:19 mlelstv Exp $");
 
 #include 
 #include 
@@ -223,7 +223,6 @@ cpu_topology_link(struct cpu_info *ci, s
 static void
 cpu_topology_dump(void)
 {
-#ifdef DEBUG
 	CPU_INFO_ITERATOR cii;
 	struct cpu_info *ci, *ci2;
 	const char *names[] = { "core", "pkg", "1st" };
@@ -237,25 +236,24 @@ cpu_topology_dump(void)
 
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		if (cpu_topology_haveslow)
-			printf("%s ", ci->ci_is_slow ? "slow" : "fast");
+			aprint_debug("%s ", ci->ci_is_slow ? "slow" : "fast");
 		for (rel = 0; rel < __arraycount(ci->ci_sibling); rel++) {
-			printf("%s has %d %s siblings:", cpu_name(ci),
+			aprint_debug("%s has %d %s siblings:", cpu_name(ci),
 			ci->ci_nsibling[rel], names[rel]);
 			ci2 = ci->ci_sibling[rel];
 			i = 0;
 			do {
-printf(" %s", cpu_name(ci2));
+aprint_debug(" %s", cpu_name(ci2));
 ci2 = ci2->ci_sibling[rel];
 			} while (++i < 64 && ci2 != ci->ci_sibling[rel]);
 			if (i == 64) {
-printf(" GAVE UP");
+aprint_debug(" GAVE UP");
 			}
-			printf("\n");
+			aprint_debug("\n");
 		}
-		printf("%s first in package: %s\n", cpu_name(ci),
+		aprint_debug("%s first in package: %s\n", cpu_name(ci),
 		cpu_name(ci->ci_package1st));
 	}
-#endif	/* DEBUG */
 }
 
 /*



  1   2   3   4   5   6   7   8   9   10   >