CVS commit: [netbsd-10] src/sys/arch/i386/i386

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:37:02 UTC 2024

Modified Files:
src/sys/arch/i386/i386 [netbsd-10]: vector.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #908):

sys/arch/i386/i386/vector.S: revision 1.90

PR/58653: me: Revert btsl of negative value to orl


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.89.4.1 src/sys/arch/i386/i386/vector.S

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



CVS commit: [netbsd-10] src/sys/arch/i386/i386

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:37:02 UTC 2024

Modified Files:
src/sys/arch/i386/i386 [netbsd-10]: vector.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #908):

sys/arch/i386/i386/vector.S: revision 1.90

PR/58653: me: Revert btsl of negative value to orl


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.89.4.1 src/sys/arch/i386/i386/vector.S

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

Modified files:

Index: src/sys/arch/i386/i386/vector.S
diff -u src/sys/arch/i386/i386/vector.S:1.89 src/sys/arch/i386/i386/vector.S:1.89.4.1
--- src/sys/arch/i386/i386/vector.S:1.89	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/i386/i386/vector.S	Sat Sep 21 12:37:02 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.89 2022/09/07 00:40:18 knakahara Exp $	*/
+/*	$NetBSD: vector.S,v 1.89.4.1 2024/09/21 12:37:02 martin Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.89 2022/09/07 00:40:18 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.89.4.1 2024/09/21 12:37:02 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -354,7 +354,7 @@ IDTVEC(resume_hyperv_hypercall)
 	cli
 	jmp	_C_LABEL(Xdoreti)
 2:
-	btsl	$(LIR_HV - 32),CPUVAR(IPENDING)+4
+	orl	$(1 << LIR_HV),CPUVAR(IPENDING)
 	INTRFASTEXIT
 IDTVEC_END(resume_hyperv_hypercall)
 #endif	/* NHYPERV > 0 */



CVS commit: [netbsd-10] src/sys/kern

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:32:39 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: subr_xcall.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #905):

sys/kern/subr_xcall.c: revision 1.36

xcall(9): If !mp_online, raise spl or set LP_BOUND to call func.

High-priority xcalls may reasonably assume that the spl is raised to
splsoftserial, so make sure to do that in xc_broadcast.

Low-priority xcalls may reasonably enter paths that assume the lwp is
bound to a CPU, so let's make it assertable even if it doesn't have
any other consequences when !mp_online.


To generate a diff of this commit:
cvs rdiff -u -r1.34.18.1 -r1.34.18.2 src/sys/kern/subr_xcall.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_xcall.c
diff -u src/sys/kern/subr_xcall.c:1.34.18.1 src/sys/kern/subr_xcall.c:1.34.18.2
--- src/sys/kern/subr_xcall.c:1.34.18.1	Wed Sep 11 10:09:19 2024
+++ src/sys/kern/subr_xcall.c	Sat Sep 21 12:32:39 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_xcall.c,v 1.34.18.1 2024/09/11 10:09:19 martin Exp $	*/
+/*	$NetBSD: subr_xcall.c,v 1.34.18.2 2024/09/21 12:32:39 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007-2010, 2019 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.34.18.1 2024/09/11 10:09:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.34.18.2 2024/09/21 12:32:39 martin Exp $");
 
 #include 
 #include 
@@ -261,7 +261,17 @@ xc_broadcast(unsigned int flags, xcfunc_
 	ASSERT_SLEEPABLE();
 
 	if (__predict_false(!mp_online)) {
+		int s, bound;
+
+		if (flags & XC_HIGHPRI)
+			s = splsoftserial();
+		else
+			bound = curlwp_bind();
 		(*func)(arg1, arg2);
+		if (flags & XC_HIGHPRI)
+			splx(s);
+		else
+			curlwp_bindx(bound);
 		return 0;
 	}
 
@@ -301,19 +311,28 @@ xc_barrier(unsigned int flags)
  */
 uint64_t
 xc_unicast(unsigned int flags, xcfunc_t func, void *arg1, void *arg2,
-	   struct cpu_info *ci)
+struct cpu_info *ci)
 {
-	int s;
 
 	KASSERT(ci != NULL);
 	KASSERT(!cpu_intr_p() && !cpu_softintr_p());
 	ASSERT_SLEEPABLE();
 
 	if (__predict_false(!mp_online)) {
+		int s, bound;
+
 		KASSERT(ci == curcpu());
-		s = splsoftserial();
+
+		if (flags & XC_HIGHPRI)
+			s = splsoftserial();
+		else
+			bound = curlwp_bind();
 		(*func)(arg1, arg2);
-		splx(s);
+		if (flags & XC_HIGHPRI)
+			splx(s);
+		else
+			curlwp_bindx(bound);
+
 		return 0;
 	}
 



CVS commit: [netbsd-10] src/sys/kern

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:32:39 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: subr_xcall.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #905):

sys/kern/subr_xcall.c: revision 1.36

xcall(9): If !mp_online, raise spl or set LP_BOUND to call func.

High-priority xcalls may reasonably assume that the spl is raised to
splsoftserial, so make sure to do that in xc_broadcast.

Low-priority xcalls may reasonably enter paths that assume the lwp is
bound to a CPU, so let's make it assertable even if it doesn't have
any other consequences when !mp_online.


To generate a diff of this commit:
cvs rdiff -u -r1.34.18.1 -r1.34.18.2 src/sys/kern/subr_xcall.c

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



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

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:30:43 UTC 2024

Modified Files:
src/sys/dev/pci [netbsd-10]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #904):

sys/dev/pci/if_vmx.c: revision 1.12

vmxnet(4): Fix various MP bugs.
- Defer reset to workqueue.
   => vmxnet3_stop_locked is forbidden in softint.
   => XXX Problem: We still take the core lock in softint, and we
  still take the core lock around vmxnet3_stop_locked.  TBD.
- Touch if_flags only under IFNET_LOCK.
   => Cache ifp->if_flags & IFF_PROMISC in vmxnet3_ifflags_cb.
   => Don't call vmxnet3_set_rxfilter unless up and running; cache
  this as vmx_mcastactive.  Use ENETRESET in vmxnet3_ifflags_cb
  instead of calling vmxnet3_set_rxfilter directly.
  . (The cache is currently serialized by the core lock, but it
might reasonably be serialized by an independent lock like in
usbnet(9).)
- Fix vmxnet3_stop_rendezvous so it actually does something.
   => New vxtxq_stopping, vxrxq_stopping variables synchronize with
  Rx/Tx interrupt handlers.
- Sprinkle IFNET_LOCK and core lock assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.11.4.1 -r1.11.4.2 src/sys/dev/pci/if_vmx.c

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

Modified files:

Index: src/sys/dev/pci/if_vmx.c
diff -u src/sys/dev/pci/if_vmx.c:1.11.4.1 src/sys/dev/pci/if_vmx.c:1.11.4.2
--- src/sys/dev/pci/if_vmx.c:1.11.4.1	Sat May 11 14:49:51 2024
+++ src/sys/dev/pci/if_vmx.c	Sat Sep 21 12:30:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.11.4.1 2024/05/11 14:49:51 martin Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.11.4.2 2024/09/21 12:30:43 martin Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.11.4.1 2024/05/11 14:49:51 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.11.4.2 2024/09/21 12:30:43 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_if_vmx.h"
@@ -212,6 +212,8 @@ struct vmxnet3_txqueue {
 	struct evcnt vxtxq_watchdogto;
 	struct evcnt vxtxq_defragged;
 	struct evcnt vxtxq_defrag_failed;
+
+	bool vxtxq_stopping;
 };
 
 
@@ -230,6 +232,8 @@ struct vmxnet3_rxqueue {
 	struct evcnt vxrxq_deferreq;
 	struct evcnt vxrxq_mgetcl_failed;
 	struct evcnt vxrxq_mbuf_load_failed;
+
+	bool vxrxq_stopping;
 };
 
 struct vmxnet3_queue {
@@ -291,6 +295,9 @@ struct vmxnet3_softc {
 
 	kmutex_t *vmx_mtx;
 
+	int vmx_if_flags;
+	bool vmx_promisc;
+	bool vmx_mcastactive;
 	uint8_t *vmx_mcast;
 	void *vmx_qs;
 	struct vmxnet3_rss_shared *vmx_rss;
@@ -311,6 +318,10 @@ struct vmxnet3_softc {
 
 	bool vmx_txrx_workqueue;
 	struct workqueue *vmx_queue_wq;
+
+	struct workqueue *vmx_reset_wq;
+	struct work vmx_reset_work;
+	bool vmx_reset_pending;
 };
 
 #define VMXNET3_STAT
@@ -435,6 +446,7 @@ static int vmxnet3_ifflags_cb(struct eth
 static int vmxnet3_watchdog(struct vmxnet3_txqueue *);
 static void vmxnet3_refresh_host_stats(struct vmxnet3_softc *);
 static void vmxnet3_tick(void *);
+static void vmxnet3_reset_work(struct work *, void *);
 static void vmxnet3_if_link_status(struct vmxnet3_softc *);
 static bool vmxnet3_cmd_link_status(struct ifnet *);
 static void vmxnet3_ifmedia_status(struct ifnet *, struct ifmediareq *);
@@ -633,6 +645,18 @@ vmxnet3_attach(device_t parent, device_t
 	if (error)
 		return;
 
+	char buf[128];
+	snprintf(buf, sizeof(buf), "%s_reset", device_xname(sc->vmx_dev));
+	error = workqueue_create(&sc->vmx_reset_wq, "%s_reset",
+	vmxnet3_reset_work, sc, VMXNET3_WORKQUEUE_PRI, IPL_SOFTCLOCK,
+	WQ_MPSAFE);
+	if (error) {
+		aprint_error_dev(sc->vmx_dev,
+		"failed to create reset workqueue: %d\n",
+		error);
+		return;
+	}
+
 	sc->vmx_flags |= VMXNET3_FLAG_ATTACHED;
 }
 
@@ -1124,6 +1148,8 @@ vmxnet3_init_rxq(struct vmxnet3_softc *s
 		rxq->vxrxq_comp_ring.vxcr_ndesc += sc->vmx_nrxdescs;
 	}
 
+	rxq->vxrxq_stopping = true;
+
 	return (0);
 }
 
@@ -1159,6 +1185,8 @@ vmxnet3_init_txq(struct vmxnet3_softc *s
 
 	txq->vxtxq_interq = pcq_create(sc->vmx_ntxdescs, KM_SLEEP);
 
+	txq->vxtxq_stopping = true;
+
 	return (0);
 }
 
@@ -2336,7 +2364,7 @@ vmxnet3_rxq_eof(struct vmxnet3_rxqueue *
 
 	VMXNET3_RXQ_LOCK_ASSERT(rxq);
 
-	if ((ifp->if_flags & IFF_RUNNING) == 0)
+	if (rxq->vxrxq_stopping)
 		return more;
 
 	m_head = rxq->vxrxq_mhead;
@@ -2442,7 +2470,7 @@ vmxnet3_rxq_eof(struct vmxnet3_rxqueue *
 			m_head = m_tail = NULL;
 
 			/* Must recheck after dropping the Rx lock. */
-			if ((ifp->if_flags & IFF_RUNNING) == 0)
+			if (rxq->vxrxq_stopping)
 break;
 		}
 
@@ -2711,11 +2739,13 @@ vmxnet3_stop_rendezvous(struct vmxnet3_s
 	for (i = 0; i < sc->vmx_nrxqueues; i++) {
 		rxq = &sc->vmx_queue[i].vxq_rxqueue;
 		VMXNET3_RXQ_LOCK(rxq);
+		rxq->vxrxq_stopping = true;
 		VMXNET3_RXQ_UNLOCK(rxq);
 	}
 	for (i = 0; i < sc->vmx_ntxqueues; i++) {
 		txq = &sc->vmx_queue[i]

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

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:30:43 UTC 2024

Modified Files:
src/sys/dev/pci [netbsd-10]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #904):

sys/dev/pci/if_vmx.c: revision 1.12

vmxnet(4): Fix various MP bugs.
- Defer reset to workqueue.
   => vmxnet3_stop_locked is forbidden in softint.
   => XXX Problem: We still take the core lock in softint, and we
  still take the core lock around vmxnet3_stop_locked.  TBD.
- Touch if_flags only under IFNET_LOCK.
   => Cache ifp->if_flags & IFF_PROMISC in vmxnet3_ifflags_cb.
   => Don't call vmxnet3_set_rxfilter unless up and running; cache
  this as vmx_mcastactive.  Use ENETRESET in vmxnet3_ifflags_cb
  instead of calling vmxnet3_set_rxfilter directly.
  . (The cache is currently serialized by the core lock, but it
might reasonably be serialized by an independent lock like in
usbnet(9).)
- Fix vmxnet3_stop_rendezvous so it actually does something.
   => New vxtxq_stopping, vxrxq_stopping variables synchronize with
  Rx/Tx interrupt handlers.
- Sprinkle IFNET_LOCK and core lock assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.11.4.1 -r1.11.4.2 src/sys/dev/pci/if_vmx.c

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



CVS commit: [netbsd-10] src/sys/netinet

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:28:46 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: ip_output.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #903):

sys/netinet/ip_output.c: revision 1.326

Again allow multicast packets to be sent from unnumbered interfaces.


To generate a diff of this commit:
cvs rdiff -u -r1.324.2.1 -r1.324.2.2 src/sys/netinet/ip_output.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/ip_output.c
diff -u src/sys/netinet/ip_output.c:1.324.2.1 src/sys/netinet/ip_output.c:1.324.2.2
--- src/sys/netinet/ip_output.c:1.324.2.1	Tue Apr 25 16:15:14 2023
+++ src/sys/netinet/ip_output.c	Sat Sep 21 12:28:46 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_output.c,v 1.324.2.1 2023/04/25 16:15:14 martin Exp $	*/
+/*	$NetBSD: ip_output.c,v 1.324.2.2 2024/09/21 12:28:46 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.324.2.1 2023/04/25 16:15:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.324.2.2 2024/09/21 12:28:46 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -348,11 +348,6 @@ ip_output(struct mbuf *m0, struct mbuf *
 		}
 		mtu = ifp->if_mtu;
 		ia = in_get_ia_from_ifp_psref(ifp, &psref_ia);
-		if (ia == NULL) {
-			IP_STATINC(IP_STAT_IFNOADDR);
-			error = EADDRNOTAVAIL;
-			goto bad;
-		}
 		if (IN_MULTICAST(ip->ip_dst.s_addr) ||
 		ip->ip_dst.s_addr == INADDR_BROADCAST) {
 			isbroadcast = 0;



CVS commit: [netbsd-10] src/sys/netinet

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:28:46 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: ip_output.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #903):

sys/netinet/ip_output.c: revision 1.326

Again allow multicast packets to be sent from unnumbered interfaces.


To generate a diff of this commit:
cvs rdiff -u -r1.324.2.1 -r1.324.2.2 src/sys/netinet/ip_output.c

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



CVS commit: [netbsd-10] src/sys/net

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:22:36 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: if_gif.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #901):

sys/net/if_gif.c: revision 1.159

Drop locks before freeing unreferenced memory in gif_set_tunnel


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.157.4.1 src/sys/net/if_gif.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/net/if_gif.c
diff -u src/sys/net/if_gif.c:1.157 src/sys/net/if_gif.c:1.157.4.1
--- src/sys/net/if_gif.c:1.157	Sat Sep  3 02:47:59 2022
+++ src/sys/net/if_gif.c	Sat Sep 21 12:22:36 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gif.c,v 1.157 2022/09/03 02:47:59 thorpej Exp $	*/
+/*	$NetBSD: if_gif.c,v 1.157.4.1 2024/09/21 12:22:36 martin Exp $	*/
 /*	$KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.157 2022/09/03 02:47:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.157.4.1 2024/09/21 12:22:36 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1160,12 +1160,13 @@ gif_set_tunnel(struct ifnet *ifp, struct
 	return 0;
 
  out:
+	mutex_exit(&sc->gif_lock);
+	encap_lock_exit();
+
 	sockaddr_free(nsrc);
 	sockaddr_free(ndst);
 	kmem_free(nvar, sizeof(*nvar));
 
-	mutex_exit(&sc->gif_lock);
-	encap_lock_exit();
 #ifndef GIF_MPSAFE
 	splx(s);
 #endif



CVS commit: [netbsd-10] src/sys/net

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:22:36 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: if_gif.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #901):

sys/net/if_gif.c: revision 1.159

Drop locks before freeing unreferenced memory in gif_set_tunnel


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.157.4.1 src/sys/net/if_gif.c

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



CVS commit: [netbsd-10] src/sys/arch

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:20:23 UTC 2024

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-10]: db_interface.c
src/sys/arch/i386/i386 [netbsd-10]: db_interface.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #900):

sys/arch/amd64/amd64/db_interface.c: revision 1.42
sys/arch/i386/i386/db_interface.c: revision 1.89

when cpus are paused (spinning) in DDB, call x86_pause() in the loop,
hopefully this can reduce power usage while doing nothing.

ok chs@
XXX: apply to i386

i386: DDB: Call x86_pause() (`pause` insn) when CPUs are paused
as already done for amd64:
https://mail-index.netbsd.org/source-changes/2023/07/31/msg146423.html

`pause` insn has been introduced to Pentium 4. However, its opcode is
consisted of `nop` (0x90) followed by `rep` prefix (0xf3), and therefore
interpreted as `nop` for older processors. Intel assured this behavior [1].

Also note that we already use `pause` unconditionally for i386.

Briefly tested on QEMU.

[1] Intel, ``AP-949 Using Spin-Loops on Intel Pentium 4 Processor and
Intel Xeon Processor'', Version 2.1, Sec 2.1.1. (2001)


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.2.1 src/sys/arch/amd64/amd64/db_interface.c
cvs rdiff -u -r1.88 -r1.88.2.1 src/sys/arch/i386/i386/db_interface.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/db_interface.c
diff -u src/sys/arch/amd64/amd64/db_interface.c:1.41 src/sys/arch/amd64/amd64/db_interface.c:1.41.2.1
--- src/sys/arch/amd64/amd64/db_interface.c:1.41	Wed Oct 26 23:38:06 2022
+++ src/sys/arch/amd64/amd64/db_interface.c	Sat Sep 21 12:20:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.41 2022/10/26 23:38:06 riastradh Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.41.2.1 2024/09/21 12:20:22 martin Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.41 2022/10/26 23:38:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.41.2.1 2024/09/21 12:20:22 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -303,7 +303,7 @@ ddb_suspend(struct trapframe *frame)
 	atomic_or_32(&ci->ci_flags, CPUF_PAUSE);
 
 	while (ci->ci_flags & CPUF_PAUSE)
-		;
+		x86_pause();
 	ci->ci_ddb_regs = 0;
 	tlbflushg();
 }

Index: src/sys/arch/i386/i386/db_interface.c
diff -u src/sys/arch/i386/i386/db_interface.c:1.88 src/sys/arch/i386/i386/db_interface.c:1.88.2.1
--- src/sys/arch/i386/i386/db_interface.c:1.88	Wed Oct 26 23:38:07 2022
+++ src/sys/arch/i386/i386/db_interface.c	Sat Sep 21 12:20:23 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.88 2022/10/26 23:38:07 riastradh Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.88.2.1 2024/09/21 12:20:23 martin Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.88 2022/10/26 23:38:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.88.2.1 2024/09/21 12:20:23 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -369,7 +369,7 @@ ddb_suspend(struct trapframe *frame)
 	atomic_or_32(&ci->ci_flags, CPUF_PAUSE);
 
 	while (ci->ci_flags & CPUF_PAUSE)
-		;
+		x86_pause();
 	ci->ci_ddb_regs = 0;
 	tlbflushg();
 }



CVS commit: [netbsd-10] src/sys/arch

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:20:23 UTC 2024

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-10]: db_interface.c
src/sys/arch/i386/i386 [netbsd-10]: db_interface.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #900):

sys/arch/amd64/amd64/db_interface.c: revision 1.42
sys/arch/i386/i386/db_interface.c: revision 1.89

when cpus are paused (spinning) in DDB, call x86_pause() in the loop,
hopefully this can reduce power usage while doing nothing.

ok chs@
XXX: apply to i386

i386: DDB: Call x86_pause() (`pause` insn) when CPUs are paused
as already done for amd64:
https://mail-index.netbsd.org/source-changes/2023/07/31/msg146423.html

`pause` insn has been introduced to Pentium 4. However, its opcode is
consisted of `nop` (0x90) followed by `rep` prefix (0xf3), and therefore
interpreted as `nop` for older processors. Intel assured this behavior [1].

Also note that we already use `pause` unconditionally for i386.

Briefly tested on QEMU.

[1] Intel, ``AP-949 Using Spin-Loops on Intel Pentium 4 Processor and
Intel Xeon Processor'', Version 2.1, Sec 2.1.1. (2001)


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.2.1 src/sys/arch/amd64/amd64/db_interface.c
cvs rdiff -u -r1.88 -r1.88.2.1 src/sys/arch/i386/i386/db_interface.c

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



CVS commit: [netbsd-10] src/sys/net

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:17:27 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: if_tun.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #899):

sys/net/if_tun.c: revision 1.177

tun(4): Mark tunread_filtops `FILTEROP_MPSAFE`

Filter handlers have already been MP-safe since 2018:
https://mail-index.netbsd.org/source-changes/2018/08/06/msg097317.html

Note that we do not expect deadlocks similar to bpf(4) (PR kern/58531),
b/w KERNEL_LOCK and spin mutex for TX queue.

For tun(4), filt_tunread() acquires adaptive mutex. This is forbidden
when spin mutex is already held.

Such a path must have already been detected if present.

Thanks ozaki-r@ for discussion.


To generate a diff of this commit:
cvs rdiff -u -r1.173.4.2 -r1.173.4.3 src/sys/net/if_tun.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/net/if_tun.c
diff -u src/sys/net/if_tun.c:1.173.4.2 src/sys/net/if_tun.c:1.173.4.3
--- src/sys/net/if_tun.c:1.173.4.2	Mon Mar 11 19:28:45 2024
+++ src/sys/net/if_tun.c	Sat Sep 21 12:17:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tun.c,v 1.173.4.2 2024/03/11 19:28:45 martin Exp $	*/
+/*	$NetBSD: if_tun.c,v 1.173.4.3 2024/09/21 12:17:27 martin Exp $	*/
 
 /*
  * Copyright (c) 1988, Julian Onions 
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.173.4.2 2024/03/11 19:28:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.173.4.3 2024/09/21 12:17:27 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1098,7 +1098,7 @@ filt_tunread(struct knote *kn, long hint
 }
 
 static const struct filterops tunread_filtops = {
-	.f_flags = FILTEROP_ISFD,
+	.f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
 	.f_attach = NULL,
 	.f_detach = filt_tunrdetach,
 	.f_event = filt_tunread,



CVS commit: [netbsd-10] src/sys/net

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:17:27 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: if_tun.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #899):

sys/net/if_tun.c: revision 1.177

tun(4): Mark tunread_filtops `FILTEROP_MPSAFE`

Filter handlers have already been MP-safe since 2018:
https://mail-index.netbsd.org/source-changes/2018/08/06/msg097317.html

Note that we do not expect deadlocks similar to bpf(4) (PR kern/58531),
b/w KERNEL_LOCK and spin mutex for TX queue.

For tun(4), filt_tunread() acquires adaptive mutex. This is forbidden
when spin mutex is already held.

Such a path must have already been detected if present.

Thanks ozaki-r@ for discussion.


To generate a diff of this commit:
cvs rdiff -u -r1.173.4.2 -r1.173.4.3 src/sys/net/if_tun.c

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



CVS commit: [netbsd-10] src/sys/stand/efiboot

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:13:05 UTC 2024

Modified Files:
src/sys/stand/efiboot [netbsd-10]: exec.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #898):

sys/stand/efiboot/exec.c: revision 1.26

When freeing pages, pass page count instead of byte count.


To generate a diff of this commit:
cvs rdiff -u -r1.23.4.1 -r1.23.4.2 src/sys/stand/efiboot/exec.c

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

Modified files:

Index: src/sys/stand/efiboot/exec.c
diff -u src/sys/stand/efiboot/exec.c:1.23.4.1 src/sys/stand/efiboot/exec.c:1.23.4.2
--- src/sys/stand/efiboot/exec.c:1.23.4.1	Fri Nov  3 09:59:04 2023
+++ src/sys/stand/efiboot/exec.c	Sat Sep 21 12:13:05 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.23.4.1 2023/11/03 09:59:04 martin Exp $ */
+/* $NetBSD: exec.c,v 1.23.4.2 2024/09/21 12:13:05 martin Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -154,7 +154,8 @@ generate_efirng(void)
 
 	/* Fill the page with whatever the EFI RNG will do.  */
 	if (efi_rng((void *)(uintptr_t)addr, size)) {
-		uefi_call_wrapper(BS->FreePages, 2, addr, size);
+		uefi_call_wrapper(BS->FreePages, 2, addr,
+		EFI_SIZE_TO_PAGES(size));
 		return;
 	}
 



CVS commit: [netbsd-10] src/sys/stand/efiboot

2024-09-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 21 12:13:05 UTC 2024

Modified Files:
src/sys/stand/efiboot [netbsd-10]: exec.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #898):

sys/stand/efiboot/exec.c: revision 1.26

When freeing pages, pass page count instead of byte count.


To generate a diff of this commit:
cvs rdiff -u -r1.23.4.1 -r1.23.4.2 src/sys/stand/efiboot/exec.c

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



CVS commit: [netbsd-10] src/sys/nfs

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:44:58 UTC 2024

Modified Files:
src/sys/nfs [netbsd-10]: nfs_clntsubs.c nfs_iod.c nfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #880):

sys/nfs/nfs_iod.c: revision 1.9
sys/nfs/nfs_vfsops.c: revision 1.245
sys/nfs/nfs_clntsubs.c: revision 1.7

PR/57279: Izumi Tsutsui: Fix some {int,long} -> time_t. Still things will
break eventually because parts of the nfs protocol assume time_t will fit
in 32 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.4.1 src/sys/nfs/nfs_clntsubs.c
cvs rdiff -u -r1.8 -r1.8.30.1 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.243.10.1 -r1.243.10.2 src/sys/nfs/nfs_vfsops.c

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



CVS commit: [netbsd-10] src/sys/nfs

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:44:58 UTC 2024

Modified Files:
src/sys/nfs [netbsd-10]: nfs_clntsubs.c nfs_iod.c nfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #880):

sys/nfs/nfs_iod.c: revision 1.9
sys/nfs/nfs_vfsops.c: revision 1.245
sys/nfs/nfs_clntsubs.c: revision 1.7

PR/57279: Izumi Tsutsui: Fix some {int,long} -> time_t. Still things will
break eventually because parts of the nfs protocol assume time_t will fit
in 32 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.4.1 src/sys/nfs/nfs_clntsubs.c
cvs rdiff -u -r1.8 -r1.8.30.1 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.243.10.1 -r1.243.10.2 src/sys/nfs/nfs_vfsops.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/nfs/nfs_clntsubs.c
diff -u src/sys/nfs/nfs_clntsubs.c:1.6 src/sys/nfs/nfs_clntsubs.c:1.6.4.1
--- src/sys/nfs/nfs_clntsubs.c:1.6	Mon Feb 28 08:45:36 2022
+++ src/sys/nfs/nfs_clntsubs.c	Fri Sep 20 11:44:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $	*/
+/*	$NetBSD: nfs_clntsubs.c,v 1.6.4.1 2024/09/20 11:44:58 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.6.4.1 2024/09/20 11:44:58 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -390,7 +390,7 @@ nfs_check_wccdata(struct nfsnode *np, co
 	if (docheck) {
 		struct vnode *vp = NFSTOV(np);
 		struct nfsmount *nmp;
-		long now = time_second;
+		time_t now = time_second;
 		const struct timespec *omtime = &np->n_vattr->va_mtime;
 		const struct timespec *octime = &np->n_vattr->va_ctime;
 		const char *reason = NULL; /* XXX: gcc */

Index: src/sys/nfs/nfs_iod.c
diff -u src/sys/nfs/nfs_iod.c:1.8 src/sys/nfs/nfs_iod.c:1.8.30.1
--- src/sys/nfs/nfs_iod.c:1.8	Mon Sep  3 16:29:36 2018
+++ src/sys/nfs/nfs_iod.c	Fri Sep 20 11:44:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_iod.c,v 1.8 2018/09/03 16:29:36 riastradh Exp $	*/
+/*	$NetBSD: nfs_iod.c,v 1.8.30.1 2024/09/20 11:44:58 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_iod.c,v 1.8 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_iod.c,v 1.8.30.1 2024/09/20 11:44:58 martin Exp $");
 
 #include 
 #include 
@@ -409,7 +409,8 @@ nfs_savenickauth(struct nfsmount *nmp, k
 	struct timeval ktvin, ktvout;
 	u_int32_t nick;
 	char *dpos = *dposp, *cp2;
-	int deltasec, error = 0;
+	time_t deltasec;
+	int error = 0;
 
 	memset(&ktvout, 0, sizeof ktvout);	 /* XXX gcc */
 

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.243.10.1 src/sys/nfs/nfs_vfsops.c:1.243.10.2
--- src/sys/nfs/nfs_vfsops.c:1.243.10.1	Fri Sep 20 10:29:41 2024
+++ src/sys/nfs/nfs_vfsops.c	Fri Sep 20 11:44:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.243.10.1 2024/09/20 10:29:41 martin Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.243.10.2 2024/09/20 11:44:58 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243.10.1 2024/09/20 10:29:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243.10.2 2024/09/20 11:44:58 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -323,7 +323,7 @@ nfs_mountroot(void)
 	struct mount *mp;
 	struct vnode *vp;
 	struct lwp *l;
-	long n;
+	time_t n;
 	int error;
 
 	l = curlwp; /* XXX */
@@ -378,7 +378,7 @@ nfs_mountroot(void)
 		panic("nfs_mountroot: getattr for root");
 	n = attr.va_atime.tv_sec;
 #ifdef	DEBUG
-	printf("root time: 0x%lx\n", n);
+	printf("root time: 0x%jx\n", (intmax_t)n);
 #endif
 	setrootfstime(n);
 



CVS commit: [netbsd-10] src/sys/arch/evbppc/conf

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:33:52 UTC 2024

Modified Files:
src/sys/arch/evbppc/conf [netbsd-10]: WII

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #897):

sys/arch/evbppc/conf/WII: revision 1.5

Add DKWEDGE_AUTODISCOVER and DKWEDGE_METHOD_GPT to WII
>From Guilherme Janczak in PR 58676


To generate a diff of this commit:
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/arch/evbppc/conf/WII

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



CVS commit: [netbsd-10] src/sys/arch/evbppc/conf

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:33:52 UTC 2024

Modified Files:
src/sys/arch/evbppc/conf [netbsd-10]: WII

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #897):

sys/arch/evbppc/conf/WII: revision 1.5

Add DKWEDGE_AUTODISCOVER and DKWEDGE_METHOD_GPT to WII
>From Guilherme Janczak in PR 58676


To generate a diff of this commit:
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/arch/evbppc/conf/WII

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/evbppc/conf/WII
diff -u src/sys/arch/evbppc/conf/WII:1.4.2.2 src/sys/arch/evbppc/conf/WII:1.4.2.3
--- src/sys/arch/evbppc/conf/WII:1.4.2.2	Sat Feb  3 11:47:06 2024
+++ src/sys/arch/evbppc/conf/WII	Fri Sep 20 11:33:51 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: WII,v 1.4.2.2 2024/02/03 11:47:06 martin Exp $
+#	$NetBSD: WII,v 1.4.2.3 2024/09/20 11:33:51 martin Exp $
 #
 #	Nintendo Wii
 #
@@ -46,6 +46,10 @@ makeoptions DEBUG="-g"	# compile full sy
 include 	"conf/compat_netbsd50.config"
 #options 	COMPAT_386BSD_MBRPART # recognize old partition ID
 
+# Wedge support
+options 	DKWEDGE_AUTODISCOVER	# Automatically add dk(4) instances
+options 	DKWEDGE_METHOD_GPT	# Supports GPT partitions as wedges
+
 # File systems
 file-system 	FFS		# UFS
 file-system 	EXT2FS		# second extended file system (linux)



CVS commit: [netbsd-10] src/sys

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:31:32 UTC 2024

Modified Files:
src/sys/arch/i386/stand [netbsd-10]: Makefile.booters
src/sys/arch/i386/stand/efiboot [netbsd-10]: Makefile.efiboot
src/sys/arch/i386/stand/pxeboot [netbsd-10]: Makefile
src/sys/lib/libsa [netbsd-10]: nfs.c nfsv2.h rpcv2.h
Added Files:
src/sys/lib/libsa [netbsd-10]: nfsv3.h
Removed Files:
src/sys/arch/i386/stand/libsa [netbsd-10]: nfs.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC


To generate a diff of this commit:
cvs rdiff -u -r1.94.20.1 -r1.94.20.2 src/sys/arch/i386/stand/Makefile.booters
cvs rdiff -u -r1.19.4.1 -r1.19.4.2 \
src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.19 -r0 src/sys/arch/i386/stand/libsa/nfs.c
cvs rdiff -u -r1.28 -r1.28.26.1 src/sys/arch/i386/stand/pxeboot/Makefile
cvs rdiff -u -r1.50 -r1.50.24.1 src/sys/lib/libsa/nfs.c
cvs rdiff -u -r1.4 -r1.4.194.1 src/sys/lib/libsa/nfsv2.h
cvs rdiff -u -r0 -r1.1.4.2 src/sys/lib/libsa/nfsv3.h
cvs rdiff -u -r1.3 -r1.3.194.1 src/sys/lib/libsa/rpcv2.h

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

Modified files:

Index: src/sys/arch/i386/stand/Makefile.booters
diff -u src/sys/arch/i386/stand/Makefile.booters:1.94.20.1 src/sys/arch/i386/stand/Makefile.booters:1.94.20.2
--- src/sys/arch/i386/stand/Makefile.booters:1.94.20.1	Thu Dec 14 17:56:08 2023
+++ src/sys/arch/i386/stand/Makefile.booters	Fri Sep 20 11:31:31 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.booters,v 1.94.20.1 2023/12/14 17:56:08 martin Exp $
+#	$NetBSD: Makefile.booters,v 1.94.20.2 2024/09/20 11:31:31 martin Exp $
 
 NOLIBCSANITIZER=
 NOSANITIZER=
@@ -64,6 +64,7 @@ LIBZ=		${ZLIB}
 ### find out what to use for libsa
 SA_AS=		library
 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
+SAMISCCPPFLAGS+=-DLIBSA_NFS_IMPLICIT_MOUNT
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA=		${SALIB}
 

Index: src/sys/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.19.4.1 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.19.4.2
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.19.4.1	Mon Sep 11 13:25:42 2023
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Fri Sep 20 11:31:32 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.19.4.1 2023/09/11 13:25:42 martin Exp $
+# $NetBSD: Makefile.efiboot,v 1.19.4.2 2024/09/20 11:31:32 martin Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -21,9 +21,7 @@ LIBI386SRCS= biosdisk.c bootinfo.c booti
 LIBI386SRCS+= comio_direct.c
 LIBI386SRCS+= diskbuf.c exec.c menuutils.c parseutils.c pread.c
 LIBI386SRCS+= exec_multiboot1.c exec_multiboot2.c
-# use our own nfs implementation
-LIBSASRCS+= nfs.c
-SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS} ${LIBSASRCS}
+SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
 
 .include 
 
@@ -86,6 +84,7 @@ GNUEFIARCH?= ${MACHINE_CPU}
 CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH}
 CPPFLAGS+= -I${EFIDIR}/inc/protocol
 
+SAMISCCPPFLAGS+= -DLIBSA_NFS_IMPLICIT_MOUNT
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
 SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)"

Index: src/sys/arch/i386/stand/pxeboot/Makefile
diff -u src/sys/arch/i386/stand/pxeboot/Makefile:1.28 src/sys/arch/i386/stand/pxeboot/Makefile:1.28.26.1
--- src/sys/arch/i386/stand/pxeboot/Makefile:1.28	Fri Sep 27 08:57:10 2019
+++ src/sys/arch/i386/stand/pxeboot/Makefile	Fri Sep 20 11:31:32 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.28 2019/09/27 08:57:10 gson Exp $
+#	$NetBSD: Makefile,v 1.28.26.1 2024/09/20 11:31:32 marti

CVS commit: [netbsd-10] src/sys

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:31:32 UTC 2024

Modified Files:
src/sys/arch/i386/stand [netbsd-10]: Makefile.booters
src/sys/arch/i386/stand/efiboot [netbsd-10]: Makefile.efiboot
src/sys/arch/i386/stand/pxeboot [netbsd-10]: Makefile
src/sys/lib/libsa [netbsd-10]: nfs.c nfsv2.h rpcv2.h
Added Files:
src/sys/lib/libsa [netbsd-10]: nfsv3.h
Removed Files:
src/sys/arch/i386/stand/libsa [netbsd-10]: nfs.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC


To generate a diff of this commit:
cvs rdiff -u -r1.94.20.1 -r1.94.20.2 src/sys/arch/i386/stand/Makefile.booters
cvs rdiff -u -r1.19.4.1 -r1.19.4.2 \
src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.19 -r0 src/sys/arch/i386/stand/libsa/nfs.c
cvs rdiff -u -r1.28 -r1.28.26.1 src/sys/arch/i386/stand/pxeboot/Makefile
cvs rdiff -u -r1.50 -r1.50.24.1 src/sys/lib/libsa/nfs.c
cvs rdiff -u -r1.4 -r1.4.194.1 src/sys/lib/libsa/nfsv2.h
cvs rdiff -u -r0 -r1.1.4.2 src/sys/lib/libsa/nfsv3.h
cvs rdiff -u -r1.3 -r1.3.194.1 src/sys/lib/libsa/rpcv2.h

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



CVS commit: [netbsd-10] src/sys/dev/wscons

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:24:59 UTC 2024

Modified Files:
src/sys/dev/wscons [netbsd-10]: wsmouse.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #892):

sys/dev/wscons/wsmouse.c: revision 1.73

wsmouse(4): Make wsmouse_input safe to call from MP-safe interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.72.4.1 src/sys/dev/wscons/wsmouse.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/wscons/wsmouse.c
diff -u src/sys/dev/wscons/wsmouse.c:1.72 src/sys/dev/wscons/wsmouse.c:1.72.4.1
--- src/sys/dev/wscons/wsmouse.c:1.72	Sun Jul 17 11:44:30 2022
+++ src/sys/dev/wscons/wsmouse.c	Fri Sep 20 11:24:59 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmouse.c,v 1.72 2022/07/17 11:44:30 riastradh Exp $ */
+/* $NetBSD: wsmouse.c,v 1.72.4.1 2024/09/20 11:24:59 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -104,7 +104,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.72 2022/07/17 11:44:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.72.4.1 2024/09/20 11:24:59 martin Exp $");
 
 #include "wsmouse.h"
 #include "wsdisplay.h"
@@ -372,17 +372,19 @@ wsmouse_input(device_t wsmousedev, u_int
 	/* one for each dimension (4) + a bit for each button */
 	struct wscons_event events[4 + sizeof(d) * 8];
 
+	KERNEL_LOCK(1, NULL);
+
 /*
  * Discard input if not open.
  */
 	evar = sc->sc_base.me_evp;
 	if (evar == NULL)
-		return;
+		goto out;
 
 #ifdef DIAGNOSTIC
 	if (evar->q == NULL) {
 		printf("wsmouse_input: evar->q=NULL\n");
-		return;
+		goto out;
 	}
 #endif
 
@@ -528,6 +530,8 @@ wsmouse_input(device_t wsmousedev, u_int
 			device_xname(sc->sc_base.me_dv), evar));
 #endif
 	}
+
+out:	KERNEL_UNLOCK_ONE(NULL);
 }
 
 void



CVS commit: [netbsd-10] src/sys/dev/wscons

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:24:59 UTC 2024

Modified Files:
src/sys/dev/wscons [netbsd-10]: wsmouse.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #892):

sys/dev/wscons/wsmouse.c: revision 1.73

wsmouse(4): Make wsmouse_input safe to call from MP-safe interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.72.4.1 src/sys/dev/wscons/wsmouse.c

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



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

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:08:25 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: fpu.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #890):

sys/arch/x86/x86/fpu.c: revision 1.87

x86/fpu: In kernel mode fpu traps, print the instruction pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.79.4.3 -r1.79.4.4 src/sys/arch/x86/x86/fpu.c

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



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

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:08:25 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: fpu.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #890):

sys/arch/x86/x86/fpu.c: revision 1.87

x86/fpu: In kernel mode fpu traps, print the instruction pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.79.4.3 -r1.79.4.4 src/sys/arch/x86/x86/fpu.c

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

Modified files:

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.79.4.3 src/sys/arch/x86/x86/fpu.c:1.79.4.4
--- src/sys/arch/x86/x86/fpu.c:1.79.4.3	Thu Jun 20 11:02:16 2024
+++ src/sys/arch/x86/x86/fpu.c	Fri Sep 20 11:08:25 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.79.4.3 2024/06/20 11:02:16 martin Exp $	*/
+/*	$NetBSD: fpu.c,v 1.79.4.4 2024/09/20 11:08:25 martin Exp $	*/
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,8 +96,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.79.4.3 2024/06/20 11:02:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.79.4.4 2024/09/20 11:08:25 martin Exp $");
 
+#include "opt_ddb.h"
 #include "opt_multiprocessor.h"
 
 #include 
@@ -121,6 +122,10 @@ __KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.79
 #include 
 #include 
 
+#ifdef DDB
+#include 
+#endif
+
 #ifdef XENPV
 #define clts() HYPERVISOR_fpu_taskswitch(0)
 #define stts() HYPERVISOR_fpu_taskswitch(1)
@@ -560,7 +565,16 @@ fputrap(struct trapframe *frame)
 	ksiginfo_t ksi;
 
 	if (__predict_false(!USERMODE(frame->tf_cs))) {
-		panic("fpu trap from kernel, trapframe %p\n", frame);
+		register_t ip = X86_TF_RIP(frame);
+		char where[128];
+
+#ifdef DDB
+		db_symstr(where, sizeof(where), (db_expr_t)ip, DB_STGY_PROC);
+#else
+		snprintf(where, sizeof(where), "%p", (void *)ip);
+#endif
+		panic("fpu trap from kernel at %s, trapframe %p\n", where,
+		frame);
 	}
 
 	KASSERT(curlwp->l_md.md_flags & MDL_FPU_IN_CPU);



CVS commit: [netbsd-10] src/sys/dev

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:02:23 UTC 2024

Modified Files:
src/sys/dev [netbsd-10]: dksubr.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #888):

sys/dev/dksubr.c: revision 1.114

Move the rnd_add_uint32 outside the lock and get rid of dk_done1() suggested
by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.113.16.1 src/sys/dev/dksubr.c

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



CVS commit: [netbsd-10] src/sys/dev

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 11:02:23 UTC 2024

Modified Files:
src/sys/dev [netbsd-10]: dksubr.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #888):

sys/dev/dksubr.c: revision 1.114

Move the rnd_add_uint32 outside the lock and get rid of dk_done1() suggested
by riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.113.16.1 src/sys/dev/dksubr.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/dksubr.c
diff -u src/sys/dev/dksubr.c:1.113 src/sys/dev/dksubr.c:1.113.16.1
--- src/sys/dev/dksubr.c:1.113	Thu Apr 15 00:32:50 2021
+++ src/sys/dev/dksubr.c	Fri Sep 20 11:02:23 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.113 2021/04/15 00:32:50 rin Exp $ */
+/* $NetBSD: dksubr.c,v 1.113.16.1 2024/09/20 11:02:23 martin Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.113 2021/04/15 00:32:50 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.113.16.1 2024/09/20 11:02:23 martin Exp $");
 
 #include 
 #include 
@@ -77,7 +77,6 @@ static int dk_subr_modcmd(modcmd_t, void
 
 static void	dk_makedisklabel(struct dk_softc *);
 static int	dk_translate(struct dk_softc *, struct buf *);
-static void	dk_done1(struct dk_softc *, struct buf *, bool);
 
 void
 dk_init(struct dk_softc *dksc, device_t dev, int dtype)
@@ -442,7 +441,9 @@ dk_start(struct dk_softc *dksc, struct b
 			if (error != 0) {
 bp->b_error = error;
 bp->b_resid = bp->b_bcount;
-dk_done1(dksc, bp, false);
+mutex_exit(&dksc->sc_iolock);
+dk_done(dksc, bp);
+mutex_enter(&dksc->sc_iolock);
 			}
 
 			bp = bufq_get(dksc->sc_bufq);
@@ -454,8 +455,8 @@ done:
 	mutex_exit(&dksc->sc_iolock);
 }
 
-static void
-dk_done1(struct dk_softc *dksc, struct buf *bp, bool lock)
+void
+dk_done(struct dk_softc *dksc, struct buf *bp)
 {
 	struct disk *dk = &dksc->sc_dkdev;
 
@@ -467,25 +468,17 @@ dk_done1(struct dk_softc *dksc, struct b
 		printf("\n");
 	}
 
-	if (lock)
-		mutex_enter(&dksc->sc_iolock);
+	mutex_enter(&dksc->sc_iolock);
 	disk_unbusy(dk, bp->b_bcount - bp->b_resid, (bp->b_flags & B_READ));
+	mutex_exit(&dksc->sc_iolock);
 
 	if ((dksc->sc_flags & DKF_NO_RND) == 0)
 		rnd_add_uint32(&dksc->sc_rnd_source, bp->b_rawblkno);
-	if (lock)
-		mutex_exit(&dksc->sc_iolock);
 
 	biodone(bp);
 }
 
 void
-dk_done(struct dk_softc *dksc, struct buf *bp)
-{
-	dk_done1(dksc, bp, true);
-}
-
-void
 dk_drain(struct dk_softc *dksc)
 {
 	struct buf *bp;



CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:52:21 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: xhci.c xhcireg.h

Log Message:
Pull up following revision(s) (requested by rin in ticket #885):

sys/dev/usb/xhcireg.h: revision 1.23
sys/dev/usb/xhci.c: revision 1.178
sys/dev/usb/xhci.c: revision 1.179

Remove an unnecessary cast in a KASSERTMSG
- Fix clearing of EINT and other transient flags.

Patches from sc.dying in kern/56115:
- Set proper Max ESIT Payload value for interrupt/isoc endpoint context.
- Set proper Average TRB Length value.
- Not tested on superspeed/superspeedplus isochronous device.
- Add handling of some error paths for isochronous transfers.


To generate a diff of this commit:
cvs rdiff -u -r1.175.2.2 -r1.175.2.3 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.22 -r1.22.4.1 src/sys/dev/usb/xhcireg.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/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.175.2.2 src/sys/dev/usb/xhci.c:1.175.2.3
--- src/sys/dev/usb/xhci.c:1.175.2.2	Tue Aug  1 16:49:54 2023
+++ src/sys/dev/usb/xhci.c	Fri Sep 20 10:52:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.175.2.2 2023/08/01 16:49:54 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.175.2.3 2024/09/20 10:52:21 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.175.2.2 2023/08/01 16:49:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.175.2.3 2024/09/20 10:52:21 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -192,7 +192,7 @@ static void xhci_setup_ctx(struct usbd_p
 static void xhci_setup_route(struct usbd_pipe *, uint32_t *);
 static void xhci_setup_tthub(struct usbd_pipe *, uint32_t *);
 static void xhci_setup_maxburst(struct usbd_pipe *, uint32_t *);
-static uint32_t xhci_bival2ival(uint32_t, uint32_t);
+static uint32_t xhci_bival2ival(uint32_t, uint32_t, uint32_t);
 
 static void xhci_noop(struct usbd_pipe *);
 
@@ -1764,7 +1764,7 @@ xhci_intr1(struct xhci_softc * const sc)
 	 * next shared interrupt. Also, to avoid race, EINT must be cleared
 	 * before XHCI_IMAN_INTR_PEND is cleared.
 	 */
-	xhci_op_write_4(sc, XHCI_USBSTS, usbsts & XHCI_STS_RSVDP0);
+	xhci_op_write_4(sc, XHCI_USBSTS, usbsts & ~XHCI_STS_RSVDP0);
 
 #ifdef XHCI_DEBUG
 	usbsts = xhci_op_read_4(sc, XHCI_USBSTS);
@@ -2496,8 +2496,6 @@ xhci_event_transfer(struct xhci_softc * 
 			xfer->ux_frlengths[xx->xx_isoc_done] -=
 			XHCI_TRB_2_REM_GET(trb_2);
 			xfer->ux_actlen += xfer->ux_frlengths[xx->xx_isoc_done];
-			if (++xx->xx_isoc_done < xfer->ux_nframes)
-return;
 		} else
 		if ((trb_3 & XHCI_TRB_3_ED_BIT) == 0) {
 			if (xfer->ux_actlen == 0)
@@ -2529,6 +2527,22 @@ xhci_event_transfer(struct xhci_softc * 
 		break;
 	}
 
+	if (xfertype == UE_ISOCHRONOUS) {
+		switch (trbcode) {
+		case XHCI_TRB_ERROR_SHORT_PKT:
+		case XHCI_TRB_ERROR_SUCCESS:
+			break;
+		case XHCI_TRB_ERROR_MISSED_SERVICE:
+		case XHCI_TRB_ERROR_RING_UNDERRUN:
+		case XHCI_TRB_ERROR_RING_OVERRUN:
+		default:
+			xfer->ux_frlengths[xx->xx_isoc_done] = 0;
+			break;
+		}
+		if (++xx->xx_isoc_done < xfer->ux_nframes)
+			return;
+	}
+
 	if ((trb_3 & XHCI_TRB_3_ED_BIT) == 0 ||
 	(trb_0 & 0x3) == 0x0) {
 		/*
@@ -3551,9 +3565,7 @@ xhci_setup_ctx(struct usbd_pipe *pipe)
 	const u_int dci = xhci_ep_get_dci(ed);
 	const uint8_t xfertype = UE_GET_XFERTYPE(ed->bmAttributes);
 	uint32_t *cp;
-	uint16_t mps = UGETW(ed->wMaxPacketSize);
 	uint8_t speed = dev->ud_speed;
-	uint8_t ival = ed->bInterval;
 
 	XHCIHIST_FUNC();
 	XHCIHIST_CALLARGS("pipe %#jx: slot %ju dci %ju speed %ju",
@@ -3598,43 +3610,16 @@ xhci_setup_ctx(struct usbd_pipe *pipe)
 	if (xfertype != UE_ISOCHRONOUS)
 		cp[1] |= XHCI_EPCTX_1_CERR_SET(3);
 
-	if (xfertype == UE_CONTROL)
-		cp[4] = XHCI_EPCTX_4_AVG_TRB_LEN_SET(8); /* 6.2.3 */
-	else if (USB_IS_SS(speed))
-		cp[4] = XHCI_EPCTX_4_AVG_TRB_LEN_SET(mps);
-	else
-		cp[4] = XHCI_EPCTX_4_AVG_TRB_LEN_SET(UE_GET_SIZE(mps));
-
 	xhci_setup_maxburst(pipe, cp);
 
-	switch (xfertype) {
-	case UE_CONTROL:
-		break;
-	case UE_BULK:
-		/* XXX Set MaxPStreams, HID, and LSA if streams enabled */
-		break;
-	case UE_INTERRUPT:
-		if (pipe->up_interval != USBD_DEFAULT_INTERVAL)
-			ival = pipe->up_interval;
-
-		ival = xhci_bival2ival(ival, speed);
-		cp[0] |= XHCI_EPCTX_0_IVAL_SET(ival);
-		break;
-	case UE_ISOCHRONOUS:
-		if (pipe->up_interval != USBD_DEFAULT_INTERVAL)
-			ival = pipe->up_interval;
-
-		/* xHCI 6.2.3.6 Table 65, USB 2.0 9.6.6 */
-		if (speed == USB_SPEED_FULL)
-			ival += 3; /* 1ms -> 125us */
-		ival--;
-		cp[0] |= XHCI_EPCTX_0_IVAL_SET(ival);
-		break;
-	default:
-		break;
-	}
-	DPRINTFN(4, "setting ival %ju MaxBurst %#jx",
-	XHCI_EPCTX_0_IVAL_GET(cp[0]), XHCI_EPCTX_1_MAXB_GET(cp[1]), 0, 0);
+	DPRINTFN(4, "setting on dci %ju ival %ju mult %ju mps %#jx",
+	dci, XHCI_EPCTX_0_IVAL_GE

CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:52:21 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: xhci.c xhcireg.h

Log Message:
Pull up following revision(s) (requested by rin in ticket #885):

sys/dev/usb/xhcireg.h: revision 1.23
sys/dev/usb/xhci.c: revision 1.178
sys/dev/usb/xhci.c: revision 1.179

Remove an unnecessary cast in a KASSERTMSG
- Fix clearing of EINT and other transient flags.

Patches from sc.dying in kern/56115:
- Set proper Max ESIT Payload value for interrupt/isoc endpoint context.
- Set proper Average TRB Length value.
- Not tested on superspeed/superspeedplus isochronous device.
- Add handling of some error paths for isochronous transfers.


To generate a diff of this commit:
cvs rdiff -u -r1.175.2.2 -r1.175.2.3 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.22 -r1.22.4.1 src/sys/dev/usb/xhcireg.h

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



CVS commit: [netbsd-10] src/sys/kern

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:50:00 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: uipc_mbuf.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #882):

sys/kern/uipc_mbuf.c: revision 1.250
sys/kern/uipc_mbuf.c: revision 1.249

mbuf(9): Sprinkle KASSERTMSG.
No functional change intended.

0x%p -> %p in KASSERTMSGs


To generate a diff of this commit:
cvs rdiff -u -r1.247.2.1 -r1.247.2.2 src/sys/kern/uipc_mbuf.c

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



CVS commit: [netbsd-10] src/sys/kern

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:50:00 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: uipc_mbuf.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #882):

sys/kern/uipc_mbuf.c: revision 1.250
sys/kern/uipc_mbuf.c: revision 1.249

mbuf(9): Sprinkle KASSERTMSG.
No functional change intended.

0x%p -> %p in KASSERTMSGs


To generate a diff of this commit:
cvs rdiff -u -r1.247.2.1 -r1.247.2.2 src/sys/kern/uipc_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/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.247.2.1 src/sys/kern/uipc_mbuf.c:1.247.2.2
--- src/sys/kern/uipc_mbuf.c:1.247.2.1	Mon Nov 27 20:00:17 2023
+++ src/sys/kern/uipc_mbuf.c	Fri Sep 20 10:50:00 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.247.2.1 2023/11/27 20:00:17 martin Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.247.2.2 2024/09/20 10:50:00 martin Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.247.2.1 2023/11/27 20:00:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.247.2.2 2024/09/20 10:50:00 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -539,7 +539,11 @@ m_get(int how, int type)
 	how == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : PR_NOWAIT);
 	if (m == NULL)
 		return NULL;
-	KASSERT(((vaddr_t)m->m_dat & PAGE_MASK) + MLEN <= PAGE_SIZE);
+	KASSERTMSG(((vaddr_t)m->m_dat & PAGE_MASK) + MLEN <= PAGE_SIZE,
+	"m=%p m->m_dat=%p"
+	" MLEN=%u PAGE_MASK=0x%x PAGE_SIZE=%u",
+	m, m->m_dat,
+	(unsigned)MLEN, (unsigned)PAGE_MASK, (unsigned)PAGE_SIZE);
 
 	mbstat_type_add(type, 1);
 
@@ -593,8 +597,12 @@ m_clget(struct mbuf *m, int how)
 	if (m->m_ext_storage.ext_buf == NULL)
 		return;
 
-	KASSERT(((vaddr_t)m->m_ext_storage.ext_buf & PAGE_MASK) + mclbytes
-	<= PAGE_SIZE);
+	KASSERTMSGvaddr_t)m->m_ext_storage.ext_buf & PAGE_MASK) + mclbytes
+		<= PAGE_SIZE),
+	"m=%p m->m_ext_storage.ext_buf=%p"
+	" mclbytes=%u PAGE_MASK=0x%x PAGE_SIZE=%u",
+	m, m->m_dat,
+	(unsigned)mclbytes, (unsigned)PAGE_MASK, (unsigned)PAGE_SIZE);
 
 	MCLINITREFERENCE(m);
 	m->m_data = m->m_ext.ext_buf;
@@ -691,6 +699,8 @@ m_copylen(int len, int copylen)
 static struct mbuf *
 m_copy_internal(struct mbuf *m, int off0, int len, int wait, bool deep)
 {
+	struct mbuf *m0 __diagused = m;
+	int len0 __diagused = len;
 	struct mbuf *n, **np;
 	int off = off0;
 	struct mbuf *top;
@@ -761,7 +771,9 @@ m_copy_internal(struct mbuf *m, int off0
 			len -= n->m_len;
 		off += n->m_len;
 
-		KASSERT(off <= m->m_len);
+		KASSERTMSG(off <= m->m_len,
+		"m=%p m->m_len=%d off=%d len=%d m0=%p off0=%d len0=%d",
+		m, m->m_len, off, len, m0, off0, len0);
 
 		if (off == m->m_len) {
 			m = m->m_next;
@@ -1117,7 +1129,8 @@ m_pulldown(struct mbuf *m, int off, int 
 			m_freem(m);
 			return NULL;	/* ENOBUFS */
 		}
-		KASSERT(o->m_len >= len);
+		KASSERTMSG(o->m_len >= len, "o=%p o->m_len=%d len=%d",
+		o, o->m_len, len);
 		for (mlast = o; mlast->m_next != NULL; mlast = mlast->m_next)
 			;
 		n->m_len = off;
@@ -1700,7 +1713,9 @@ m_defrag(struct mbuf *m, int how)
 			m0 = m_get(how, MT_DATA);
 			if (m0 == NULL)
 return NULL;
-			KASSERT(m->m_len <= MHLEN);
+			KASSERTMSG(m->m_len <= MHLEN,
+			"m=%p m->m_len=%d MHLEN=%u",
+			m, m->m_len, (unsigned)MHLEN);
 			m_copydata(m, 0, m->m_len, mtod(m0, void *));
 
 			MCLGET(m, how);
@@ -1711,7 +1726,10 @@ m_defrag(struct mbuf *m, int how)
 			memcpy(m->m_data, mtod(m0, void *), m->m_len);
 			m_free(m0);
 		}
-		KASSERT(M_TRAILINGSPACE(m) >= (m->m_pkthdr.len - m->m_len));
+		KASSERTMSG(M_TRAILINGSPACE(m) >= (m->m_pkthdr.len - m->m_len),
+		"m=%p M_TRAILINGSPACE(m)=%zd m->m_pkthdr.len=%d"
+		" m->m_len=%d",
+		m, M_TRAILINGSPACE(m), m->m_pkthdr.len, m->m_len);
 		m_copydata(m->m_next, 0, m->m_pkthdr.len - m->m_len,
 			mtod(m, char *) + m->m_len);
 		m->m_len = m->m_pkthdr.len;
@@ -1814,11 +1832,12 @@ m_align(struct mbuf *m, int len)
 	int buflen, adjust;
 
 	KASSERT(len != M_COPYALL);
-	KASSERT(M_LEADINGSPACE(m) == 0);
+	KASSERTMSG(M_LEADINGSPACE(m) == 0, "m=%p M_LEADINGSPACE(m)=%zd",
+	m, M_LEADINGSPACE(m));
 
 	buflen = M_BUFSIZE(m);
 
-	KASSERT(len <= buflen);
+	KASSERTMSG(len <= buflen, "m=%p len=%d buflen=%d", m, len, buflen);
 	adjust = buflen - len;
 	m->m_data += adjust &~ (sizeof(long)-1);
 }



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

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:47:52 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: bus_dma.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #881):

sys/arch/x86/x86/bus_dma.c: revision 1.90

x86/bus_dma.c: Sprinkle KASSERTMSG.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.89.4.1 src/sys/arch/x86/x86/bus_dma.c

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

Modified files:

Index: src/sys/arch/x86/x86/bus_dma.c
diff -u src/sys/arch/x86/x86/bus_dma.c:1.89 src/sys/arch/x86/x86/bus_dma.c:1.89.4.1
--- src/sys/arch/x86/x86/bus_dma.c:1.89	Sat Aug 20 23:48:51 2022
+++ src/sys/arch/x86/x86/bus_dma.c	Fri Sep 20 10:47:52 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.89 2022/08/20 23:48:51 riastradh Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.89.4.1 2024/09/20 10:47:52 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2007, 2020 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.89 2022/08/20 23:48:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.89.4.1 2024/09/20 10:47:52 martin Exp $");
 
 /*
  * The following is included because _bus_dma_uiomove is derived from
@@ -207,7 +207,8 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t,
 	/* Always round the size. */
 	size = round_page(size);
 
-	KASSERT(boundary >= PAGE_SIZE || boundary == 0);
+	KASSERTMSG(boundary >= PAGE_SIZE || boundary == 0,
+	"boundary=0x%"PRIxBUSSIZE, boundary);
 
 	/*
 	 * Allocate pages from the VM system.
@@ -389,7 +390,9 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dm
 	 */
 	map->dm_mapsize = 0;
 	map->dm_nsegs = 0;
-	KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
+	KASSERTMSG(map->dm_maxsegsz <= map->_dm_maxmaxsegsz,
+	"maxsegsz=0x%"PRIxBUSSIZE", maxmaxsegsz=0x%"PRIxBUSSIZE,
+	map->dm_maxsegsz, map->_dm_maxmaxsegsz);
 
 	if (buflen > map->_dm_size)
 		return EINVAL;
@@ -517,9 +520,12 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, b
 	 */
 	map->dm_mapsize = 0;
 	map->dm_nsegs = 0;
-	KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
+	KASSERTMSG(map->dm_maxsegsz <= map->_dm_maxmaxsegsz,
+	"maxsegsz=0x%"PRIxBUSSIZE", maxmaxsegsz=0x%"PRIxBUSSIZE,
+	map->dm_maxsegsz, map->_dm_maxmaxsegsz);
 
-	KASSERT(m0->m_flags & M_PKTHDR);
+	KASSERTMSG(m0->m_flags & M_PKTHDR, "m0=%p m_flags=0x%x", m0,
+	m0->m_flags);
 	if (m0->m_pkthdr.len > map->_dm_size)
 		return (EINVAL);
 
@@ -545,9 +551,15 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, b
 			break;
 
 		case M_EXT|M_EXT_PAGES:
-			KASSERT(m->m_ext.ext_buf <= m->m_data);
-			KASSERT(m->m_data <=
-			m->m_ext.ext_buf + m->m_ext.ext_size);
+			KASSERTMSG(m->m_ext.ext_buf <= m->m_data,
+			"m=%p m_ext.ext_buf=%p m_ext.ext_size=%zu"
+			" m_data=%p",
+			m, m->m_ext.ext_buf, m->m_ext.ext_size, m->m_data);
+			KASSERTMSG((m->m_data <=
+m->m_ext.ext_buf + m->m_ext.ext_size),
+			"m=%p m_ext.ext_buf=%p m_ext.ext_size=%zu"
+			" m_data=%p",
+			m, m->m_ext.ext_buf, m->m_ext.ext_size, m->m_data);
 
 			offset = (vaddr_t)m->m_data -
 			trunc_page((vaddr_t)m->m_ext.ext_buf);
@@ -655,7 +667,9 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bu
 	 */
 	map->dm_mapsize = 0;
 	map->dm_nsegs = 0;
-	KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
+	KASSERTMSG(map->dm_maxsegsz <= map->_dm_maxmaxsegsz,
+	"maxsegsz=0x%"PRIxBUSSIZE", maxmaxsegsz=0x%"PRIxBUSSIZE,
+	map->dm_maxsegsz, map->_dm_maxmaxsegsz);
 
 	resid = uio->uio_resid;
 	iov = uio->uio_iov;
@@ -732,7 +746,9 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bu
 	 */
 	map->dm_mapsize = 0;
 	map->dm_nsegs = 0;
-	KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
+	KASSERTMSG(map->dm_maxsegsz <= map->_dm_maxmaxsegsz,
+	"maxsegsz=0x%"PRIxBUSSIZE", maxmaxsegsz=0x%"PRIxBUSSIZE,
+	map->dm_maxsegsz, map->_dm_maxmaxsegsz);
 
 	if (size0 > map->_dm_size)
 		return EINVAL;
@@ -811,8 +827,8 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 		"bad offset 0x%"PRIxBUSADDR" >= 0x%"PRIxBUSSIZE,
 		offset, map->dm_mapsize);
 		KASSERTMSG(len <= map->dm_mapsize - offset,
-		"bad length 0x%"PRIxBUSADDR" + %"PRIxBUSSIZE
-		" > %"PRIxBUSSIZE,
+		"bad length 0x%"PRIxBUSADDR" + 0x%"PRIxBUSSIZE
+		" > 0x%"PRIxBUSSIZE,
 		offset, len, map->dm_mapsize);
 	}
 



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

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:47:52 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: bus_dma.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #881):

sys/arch/x86/x86/bus_dma.c: revision 1.90

x86/bus_dma.c: Sprinkle KASSERTMSG.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.89.4.1 src/sys/arch/x86/x86/bus_dma.c

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



CVS commit: [netbsd-10] src/sys/nfs

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:29:41 UTC 2024

Modified Files:
src/sys/nfs [netbsd-10]: nfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #879):

sys/nfs/nfs_vfsops.c: revision 1.244

Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.243.10.1 src/sys/nfs/nfs_vfsops.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/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.243 src/sys/nfs/nfs_vfsops.c:1.243.10.1
--- src/sys/nfs/nfs_vfsops.c:1.243	Sun Jun 13 10:25:11 2021
+++ src/sys/nfs/nfs_vfsops.c	Fri Sep 20 10:29:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.243 2021/06/13 10:25:11 mlelstv Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.243.10.1 2024/09/20 10:29:41 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243 2021/06/13 10:25:11 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243.10.1 2024/09/20 10:29:41 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -1135,6 +1135,7 @@ nfs_start(struct mount *mp, int flags)
 void
 nfs_vfs_init(void)
 {
+	unsigned scale;
 
 	/* Initialize NFS server / client shared data. */
 	nfs_init();
@@ -1145,7 +1146,8 @@ nfs_vfs_init(void)
 	/* Initialize the iod structures */
 	nfs_iodinit();
 
-	nfs_commitsize = uvmexp.npages << (PAGE_SHIFT - 4);
+	scale = PAGE_SHIFT - 4;
+	nfs_commitsize = uimin(uvmexp.npages, INT_MAX >> scale) << scale;
 }
 
 void



CVS commit: [netbsd-10] src/sys/nfs

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:29:41 UTC 2024

Modified Files:
src/sys/nfs [netbsd-10]: nfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #879):

sys/nfs/nfs_vfsops.c: revision 1.244

Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.243.10.1 src/sys/nfs/nfs_vfsops.c

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



CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:20:56 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: ucom.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #877):

sys/dev/usb/ucom.c: revision 1.138

ucom(4): Simplify logic fixing PR kern/57259.
cv_timedwait only ever returns 0 or EWOULDBLOCK, so this would always
return ERESTART anyway.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.134.2.2 -r1.134.2.3 src/sys/dev/usb/ucom.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.134.2.2 src/sys/dev/usb/ucom.c:1.134.2.3
--- src/sys/dev/usb/ucom.c:1.134.2.2	Tue Mar  7 19:52:01 2023
+++ src/sys/dev/usb/ucom.c	Fri Sep 20 10:20:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.134.2.2 2023/03/07 19:52:01 martin Exp $	*/
+/*	$NetBSD: ucom.c,v 1.134.2.3 2024/09/20 10:20:56 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.134.2.2 2023/03/07 19:52:01 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.134.2.3 2024/09/20 10:20:56 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -552,14 +552,10 @@ ucomopen(dev_t dev, int flag, int mode, 
 			ms = MIN(INT_MAX - 1000, delta.tv_sec*1000);
 			ms += howmany(delta.tv_usec, 1000);
 			ticks = MAX(1, MIN(INT_MAX, mstohz(ms)));
-			error = cv_timedwait(&sc->sc_statecv, &sc->sc_lock,
+			(void)cv_timedwait(&sc->sc_statecv, &sc->sc_lock,
 			ticks);
 			mutex_exit(&sc->sc_lock);
-			/* The successful passage of time is not an error. */
-			if (error == EWOULDBLOCK) {
-error = 0;
-			}
-			return error ? error : ERESTART;
+			return ERESTART;
 		}
 		timerclear(&sc->sc_hup_time);
 	}



CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:20:56 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: ucom.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #877):

sys/dev/usb/ucom.c: revision 1.138

ucom(4): Simplify logic fixing PR kern/57259.
cv_timedwait only ever returns 0 or EWOULDBLOCK, so this would always
return ERESTART anyway.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.134.2.2 -r1.134.2.3 src/sys/dev/usb/ucom.c

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



CVS commit: [netbsd-10] src/sys/arch/amd64/amd64

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:17:22 UTC 2024

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-10]: amd64_trap.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #876):

sys/arch/amd64/amd64/amd64_trap.S: revision 1.55

amd64_trap.S: Annotate trap vectors with their mnemonics.

Derived from Intel and AMD manuals.
Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3
(3A, 3B, 3C, & 3D: System Programming Guide, Order Number:
325384-077US, April 2022.
https://cdrdv2.intel.com/v1/dl/getContent/671447

AMD64 Technology: AMD64 Architecture Programmers' Manual, Volume 2:
System Programming, Publication No. 24953, Revision 3.40, January 2023.
https://www.amd.com/system/files/TechDocs/24593.pdf

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.54.4.1 src/sys/arch/amd64/amd64/amd64_trap.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/amd64_trap.S
diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.54 src/sys/arch/amd64/amd64/amd64_trap.S:1.54.4.1
--- src/sys/arch/amd64/amd64/amd64_trap.S:1.54	Wed Sep  7 00:40:18 2022
+++ src/sys/arch/amd64/amd64/amd64_trap.S	Fri Sep 20 10:17:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: amd64_trap.S,v 1.54 2022/09/07 00:40:18 knakahara Exp $	*/
+/*	$NetBSD: amd64_trap.S,v 1.54.4.1 2024/09/20 10:17:22 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc.
@@ -159,7 +159,7 @@
 
 	TEXT_USER_BEGIN
 
-IDTVEC(trap00)
+IDTVEC(trap00)		/* #DE - Divide-by-zero error */
 	ZTRAP(T_DIVIDE)
 IDTVEC_END(trap00)
 
@@ -178,7 +178,7 @@ IDTVEC_END(trap00)
  * not a problem, because in this particular case, the frame is known not
  * to contain secrets.
  */
-IDTVEC(trap01)
+IDTVEC(trap01)		/* #DB - Debug */
 #ifndef XENPV
 	subq	$(TF_REGSIZE+16),%rsp
 
@@ -247,7 +247,7 @@ IDTVEC_END(trap01)
  * We need to be careful about %gs too, because it is possible that we were
  * running in kernel mode with a userland %gs.
  */
-IDTVEC(trap02)
+IDTVEC(trap02)		/* NMI - Non-maskable interrupt */
 #if defined(XENPV)
 	ZTRAP(T_NMI)
 #else /* XENPV */
@@ -302,7 +302,7 @@ IDTVEC(trap02)
 #endif /* XENPV */
 IDTVEC_END(trap02)
 
-IDTVEC(trap03)
+IDTVEC(trap03)		/* #BP - Breakpoint */
 #ifndef KDTRACE_HOOKS
 	ZTRAP(T_BPTFLT)
 #else
@@ -331,19 +331,19 @@ IDTVEC(trap03)
 #endif
 IDTVEC_END(trap03)
 
-IDTVEC(trap04)
+IDTVEC(trap04)		/* #OF - Overflow */
 	ZTRAP(T_OFLOW)
 IDTVEC_END(trap04)
 
-IDTVEC(trap05)
+IDTVEC(trap05)		/* #BR - BOUND range exceeded */
 	ZTRAP(T_BOUND)
 IDTVEC_END(trap05)
 
-IDTVEC(trap06)
+IDTVEC(trap06)		/* #UD - Invalid opcode */
 	ZTRAP(T_PRIVINFLT)
 IDTVEC_END(trap06)
 
-IDTVEC(trap07)
+IDTVEC(trap07)		/* #NM - Device not available (x87) */
 	ZTRAP_NJ(T_DNA)
 	INTRENTRY
 #ifdef DIAGNOSTIC
@@ -358,7 +358,7 @@ IDTVEC_END(trap07)
  * Double faults execute on a particular stack, and we must not jump out
  * of it. So don't enable interrupts.
  */
-IDTVEC(trap08)
+IDTVEC(trap08)		/* #DF - Double fault */
 #if defined(XENPV)
 	TRAP(T_DOUBLEFLT)
 #else /* XENPV */
@@ -399,11 +399,11 @@ IDTVEC(trap08)
 #endif /* XENPV */
 IDTVEC_END(trap08)
 
-IDTVEC(trap09)
+IDTVEC(trap09)		/* Coprocessor segment overrun (legacy x87) */
 	ZTRAP(T_FPOPFLT)
 IDTVEC_END(trap09)
 
-IDTVEC(trap10)
+IDTVEC(trap10)		/* #TS - Invalid TSS */
 	TRAP(T_TSSFLT)
 IDTVEC_END(trap10)
 
@@ -416,26 +416,26 @@ IDTVEC_END(trap10)
 #define kernuser_reenter alltraps
 #endif /* XENPV */
 
-IDTVEC(trap11)		/* #NP() Segment not present */
+IDTVEC(trap11)		/* #NP - Segment not present */
 	TRAP_NJ(T_SEGNPFLT)
 	jmp	kernuser_reenter
 IDTVEC_END(trap11)
 
-IDTVEC(trap12)		/* #SS() Stack exception */
+IDTVEC(trap12)		/* #SS - Stack fault */
 	TRAP_NJ(T_STKFLT)
 	jmp	kernuser_reenter
 IDTVEC_END(trap12)
 
-IDTVEC(trap13)		/* #GP() General protection */
+IDTVEC(trap13)		/* #GP - General protection */
 	TRAP_NJ(T_PROTFLT)
 	jmp	kernuser_reenter
 IDTVEC_END(trap13)
 
-IDTVEC(trap14)
+IDTVEC(trap14)		/* #PF - Page fault */
 	TRAP(T_PAGEFLT)
 IDTVEC_END(trap14)
 
-IDTVEC(trap15)
+IDTVEC(trap15)		/* XXX ??? */
 	ZTRAP_NJ(T_ASTFLT)
 	INTRENTRY
 #ifdef DIAGNOSTIC
@@ -444,7 +444,7 @@ IDTVEC(trap15)
 	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap15)
 
-IDTVEC(trap16)
+IDTVEC(trap16)		/* #MF - x87 floating-point exception */
 	ZTRAP_NJ(T_ARITHTRAP)
 .Ldo_fputrap:
 	INTRENTRY
@@ -464,30 +464,30 @@ IDTVEC(trap16)
 	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap16)
 
-IDTVEC(trap17)
+IDTVEC(trap17)		/* #AC - Alignment check */
 	TRAP(T_ALIGNFLT)
 IDTVEC_END(trap17)
 
-IDTVEC(trap18)
+IDTVEC(trap18)		/* #MC - Machine check */
 	ZTRAP(T_MCA)
 IDTVEC_END(trap18)
 
-IDTVEC(trap19)
+IDTVEC(trap19)		/* #XM - SIMD floating-point exception */
 	ZTRAP_NJ(T_XMM)
 	jmp	.Ldo_fputrap
 IDTVEC_END(trap19)
 
-IDTVEC(trap20)
-IDTVEC(trap21)
+IDTVEC(trap20)		/* #VE - Virtualization (Intel) */
+IDTVEC(trap21)		/*

CVS commit: [netbsd-10] src/sys/arch/amd64/amd64

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:17:22 UTC 2024

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-10]: amd64_trap.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #876):

sys/arch/amd64/amd64/amd64_trap.S: revision 1.55

amd64_trap.S: Annotate trap vectors with their mnemonics.

Derived from Intel and AMD manuals.
Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3
(3A, 3B, 3C, & 3D: System Programming Guide, Order Number:
325384-077US, April 2022.
https://cdrdv2.intel.com/v1/dl/getContent/671447

AMD64 Technology: AMD64 Architecture Programmers' Manual, Volume 2:
System Programming, Publication No. 24953, Revision 3.40, January 2023.
https://www.amd.com/system/files/TechDocs/24593.pdf

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.54.4.1 src/sys/arch/amd64/amd64/amd64_trap.S

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



CVS commit: [netbsd-10] src/sys/arch/i386/i386

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:00:14 UTC 2024

Modified Files:
src/sys/arch/i386/i386 [netbsd-10]: bioscall.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #875):

sys/arch/i386/i386/bioscall.S: revision 1.11

i386/bioscall: Disable preemption while we load the kernel pmap.

Fixes crash on boot in new KASSERT(kpreempt_disabled()) in
cpu_load_pmap.

We could do KASSERT(kpreempt_disabled() || cold), but I don't know if
bioscall is ever reachable after warm boot; this way is safer.

XXX Would be nice if bioscall were a C function, not asm -- I don't
see any reason why we need it to be asm?


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.30.1 src/sys/arch/i386/i386/bioscall.S

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

Modified files:

Index: src/sys/arch/i386/i386/bioscall.S
diff -u src/sys/arch/i386/i386/bioscall.S:1.10 src/sys/arch/i386/i386/bioscall.S:1.10.30.1
--- src/sys/arch/i386/i386/bioscall.S:1.10	Sat Jul 14 14:29:40 2018
+++ src/sys/arch/i386/i386/bioscall.S	Fri Sep 20 10:00:14 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bioscall.S,v 1.10 2018/07/14 14:29:40 maxv Exp $ */
+/*	$NetBSD: bioscall.S,v 1.10.30.1 2024/09/20 10:00:14 martin Exp $ */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bioscall.S,v 1.10 2018/07/14 14:29:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bioscall.S,v 1.10.30.1 2024/09/20 10:00:14 martin Exp $");
 
 #include 
 
@@ -67,6 +67,8 @@ ENTRY(bioscall)
 	pushl	%ebp
 	movl	%esp,%ebp		/* set up frame ptr */
 
+	call	_C_LABEL(kpreempt_disable)
+
 	/* install lwp0 pmap */
 	movl	_C_LABEL(kernel_pmap_ptr),%eax
 	pushl	%eax
@@ -85,5 +87,7 @@ ENTRY(bioscall)
 	call	_C_LABEL(cpu_load_pmap)
 	addl	$4,%esp
 
+	call	_C_LABEL(kpreempt_enable)
+
 	leave
 	ret



CVS commit: [netbsd-10] src/sys/arch/i386/i386

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 10:00:14 UTC 2024

Modified Files:
src/sys/arch/i386/i386 [netbsd-10]: bioscall.S

Log Message:
Pull up following revision(s) (requested by rin in ticket #875):

sys/arch/i386/i386/bioscall.S: revision 1.11

i386/bioscall: Disable preemption while we load the kernel pmap.

Fixes crash on boot in new KASSERT(kpreempt_disabled()) in
cpu_load_pmap.

We could do KASSERT(kpreempt_disabled() || cold), but I don't know if
bioscall is ever reachable after warm boot; this way is safer.

XXX Would be nice if bioscall were a C function, not asm -- I don't
see any reason why we need it to be asm?


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.30.1 src/sys/arch/i386/i386/bioscall.S

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



CVS commit: [netbsd-10] src/sys/arch/sparc64/sparc64

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:58:19 UTC 2024

Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-10]: lock_stubs.s

Log Message:
Pull up following revision(s) (requested by rin in ticket #874):

sys/arch/sparc64/sparc64/lock_stubs.s: revision 1.12

sparc64: Add missing LoadStore ordering for mutex_enter stub.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.4.1 src/sys/arch/sparc64/sparc64/lock_stubs.s

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



CVS commit: [netbsd-10] src/sys/arch/sparc64/sparc64

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:58:19 UTC 2024

Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-10]: lock_stubs.s

Log Message:
Pull up following revision(s) (requested by rin in ticket #874):

sys/arch/sparc64/sparc64/lock_stubs.s: revision 1.12

sparc64: Add missing LoadStore ordering for mutex_enter stub.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.4.1 src/sys/arch/sparc64/sparc64/lock_stubs.s

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

Modified files:

Index: src/sys/arch/sparc64/sparc64/lock_stubs.s
diff -u src/sys/arch/sparc64/sparc64/lock_stubs.s:1.11 src/sys/arch/sparc64/sparc64/lock_stubs.s:1.11.4.1
--- src/sys/arch/sparc64/sparc64/lock_stubs.s:1.11	Wed Apr  6 22:47:57 2022
+++ src/sys/arch/sparc64/sparc64/lock_stubs.s	Fri Sep 20 09:58:19 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.s,v 1.11 2022/04/06 22:47:57 riastradh Exp $	*/
+/*	$NetBSD: lock_stubs.s,v 1.11.4.1 2024/09/20 09:58:19 martin Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 #define	CURLWP	(CPUINFO_VA+CI_CURLWP)
 
 #if defined(MULTIPROCESSOR)
-#define	MB_READ	membar #LoadLoad
+#define	MB_READ	membar #LoadLoad | #LoadStore
 #define	MB_MEM	membar #LoadStore | #StoreStore
 #else
 #define	MB_READ	/* nothing */



CVS commit: [netbsd-10] src/sys/fs/union

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:51:40 UTC 2024

Modified Files:
src/sys/fs/union [netbsd-10]: union_vfsops.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #873):

sys/fs/union/union_vfsops.c: revision 1.87

When mounting a union file system set its lower mount only on success.


To generate a diff of this commit:
cvs rdiff -u -r1.85.2.1 -r1.85.2.2 src/sys/fs/union/union_vfsops.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/union/union_vfsops.c
diff -u src/sys/fs/union/union_vfsops.c:1.85.2.1 src/sys/fs/union/union_vfsops.c:1.85.2.2
--- src/sys/fs/union/union_vfsops.c:1.85.2.1	Mon Feb  6 16:57:24 2023
+++ src/sys/fs/union/union_vfsops.c	Fri Sep 20 09:51:40 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: union_vfsops.c,v 1.85.2.1 2023/02/06 16:57:24 martin Exp $	*/
+/*	$NetBSD: union_vfsops.c,v 1.85.2.2 2024/09/20 09:51:40 martin Exp $	*/
 
 /*
  * Copyright (c) 1994 The Regents of the University of California.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.85.2.1 2023/02/06 16:57:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.85.2.2 2024/09/20 09:51:40 martin Exp $");
 
 #include 
 #include 
@@ -255,15 +255,16 @@ union_mount(struct mount *mp, const char
 
 	mp->mnt_data = um;
 	vfs_getnewfsid(mp);
-	error = vfs_set_lowermount(mp, um->um_uppervp->v_mount);
-	if (error)
-		goto bad;
 
 	error = set_statvfs_info(path, UIO_USERSPACE, NULL, UIO_USERSPACE,
 	mp->mnt_op->vfs_name, mp, l);
 	if (error)
 		goto bad;
 
+	error = vfs_set_lowermount(mp, um->um_uppervp->v_mount);
+	if (error)
+		goto bad;
+
 	switch (um->um_op) {
 	case UNMNT_ABOVE:
 		cp = ":";



CVS commit: [netbsd-10] src/sys/fs/union

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:51:40 UTC 2024

Modified Files:
src/sys/fs/union [netbsd-10]: union_vfsops.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #873):

sys/fs/union/union_vfsops.c: revision 1.87

When mounting a union file system set its lower mount only on success.


To generate a diff of this commit:
cvs rdiff -u -r1.85.2.1 -r1.85.2.2 src/sys/fs/union/union_vfsops.c

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



CVS commit: [netbsd-10] src/sys/kern

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:46:54 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: subr_pool.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #871):

sys/kern/subr_pool.c: revision 1.286

Avoid undefined behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.285 -r1.285.4.1 src/sys/kern/subr_pool.c

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



CVS commit: [netbsd-10] src/sys/kern

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:46:54 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: subr_pool.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #871):

sys/kern/subr_pool.c: revision 1.286

Avoid undefined behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.285 -r1.285.4.1 src/sys/kern/subr_pool.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_pool.c
diff -u src/sys/kern/subr_pool.c:1.285 src/sys/kern/subr_pool.c:1.285.4.1
--- src/sys/kern/subr_pool.c:1.285	Sat Jul 16 10:20:21 2022
+++ src/sys/kern/subr_pool.c	Fri Sep 20 09:46:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pool.c,v 1.285 2022/07/16 10:20:21 simonb Exp $	*/
+/*	$NetBSD: subr_pool.c,v 1.285.4.1 2024/09/20 09:46:54 martin Exp $	*/
 
 /*
  * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015, 2018,
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.285 2022/07/16 10:20:21 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.285.4.1 2024/09/20 09:46:54 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -3317,7 +3317,7 @@ pool_allocated(struct pool *pp, struct p
 		unsigned int idx = pr_item_bitmap_index(pp, ph, (void *)addr);
 		pool_item_bitmap_t *bitmap =
 		ph->ph_bitmap + (idx / BITMAP_SIZE);
-		pool_item_bitmap_t mask = 1 << (idx & BITMAP_MASK);
+		pool_item_bitmap_t mask = 1U << (idx & BITMAP_MASK);
 
 		return (*bitmap & mask) == 0;
 	} else {



CVS commit: [netbsd-10] src/sys/kern

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:36:13 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: kern_sysctl.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #870):

sys/kern/kern_sysctl.c: revision 1.267
sys/kern/kern_sysctl.c: revision 1.268

Trailing whitespace

Fix SYSCTL_DEBUG_CREATE for non-x86 by using copyin


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.266.20.1 src/sys/kern/kern_sysctl.c

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

Modified files:

Index: src/sys/kern/kern_sysctl.c
diff -u src/sys/kern/kern_sysctl.c:1.266 src/sys/kern/kern_sysctl.c:1.266.20.1
--- src/sys/kern/kern_sysctl.c:1.266	Thu Aug 27 14:11:57 2020
+++ src/sys/kern/kern_sysctl.c	Fri Sep 20 09:36:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sysctl.c,v 1.266 2020/08/27 14:11:57 riastradh Exp $	*/
+/*	$NetBSD: kern_sysctl.c,v 1.266.20.1 2024/09/20 09:36:13 martin Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
 #define __COMPAT_SYSCTL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.266 2020/08/27 14:11:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.266.20.1 2024/09/20 09:36:13 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_defcorename.h"
@@ -203,7 +203,7 @@ sysctl_copyout(struct lwp *l, const void
 	} else {
 		error = kcopy(kaddr, uaddr, len);
 	}
-	
+
 	return error;
 }
 
@@ -1228,9 +1228,16 @@ int
 sysctl_create(SYSCTLFN_ARGS)
 {
 	const struct sysctlnode *node;
-	int k, rc, ni, nl = namelen + (name - oname);
+	int k, v, rc, ni, nl = namelen + (name - oname);
+	struct sysctlnode nnode;
+
+	if (newp == NULL)
+		return EINVAL;
+	int error = sysctl_cvt_in(l, &v, newp, newlen, &nnode);
+	if (error)
+		return error;
 
-	node = newp;
+	node = &nnode;
 
 	printf("namelen %d (", nl);
 	for (ni = 0; ni < nl - 1; ni++)
@@ -2147,7 +2154,7 @@ sysctl_createv(struct sysctllog **log, i
 /*
  * allow first caller to *set* a
  * description actually to set it
- * 
+ *
  * discard const here so we can attach
  * the description
  */



CVS commit: [netbsd-10] src/sys/kern

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:36:13 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: kern_sysctl.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #870):

sys/kern/kern_sysctl.c: revision 1.267
sys/kern/kern_sysctl.c: revision 1.268

Trailing whitespace

Fix SYSCTL_DEBUG_CREATE for non-x86 by using copyin


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.266.20.1 src/sys/kern/kern_sysctl.c

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



CVS commit: [netbsd-10] src/sys/arch/sparc64/sparc64

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:30:52 UTC 2024

Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-10]: db_trace.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #883):

sys/arch/sparc64/sparc64/db_trace.c: revision 1.56
sys/arch/sparc64/sparc64/db_trace.c: revision 1.57

sparc64/db_trace.c: Nix trailing whitespace.
No functional change intended.

sparc64/db_trace.c: Don't dereference; use db_read_bytes.

Makes crash(8) and ddb match, and avoids crashing in ddb when you
feed in a bad lwp pointer!


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.20.1 src/sys/arch/sparc64/sparc64/db_trace.c

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



CVS commit: [netbsd-10] src/sys/arch/sparc64/sparc64

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:30:52 UTC 2024

Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-10]: db_trace.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #883):

sys/arch/sparc64/sparc64/db_trace.c: revision 1.56
sys/arch/sparc64/sparc64/db_trace.c: revision 1.57

sparc64/db_trace.c: Nix trailing whitespace.
No functional change intended.

sparc64/db_trace.c: Don't dereference; use db_read_bytes.

Makes crash(8) and ddb match, and avoids crashing in ddb when you
feed in a bad lwp pointer!


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.20.1 src/sys/arch/sparc64/sparc64/db_trace.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/sparc64/sparc64/db_trace.c
diff -u src/sys/arch/sparc64/sparc64/db_trace.c:1.55 src/sys/arch/sparc64/sparc64/db_trace.c:1.55.20.1
--- src/sys/arch/sparc64/sparc64/db_trace.c:1.55	Sun May 31 11:28:52 2020
+++ src/sys/arch/sparc64/sparc64/db_trace.c	Fri Sep 20 09:30:52 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.55 2020/05/31 11:28:52 martin Exp $ */
+/*	$NetBSD: db_trace.c,v 1.55.20.1 2024/09/20 09:30:52 martin Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.55 2020/05/31 11:28:52 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.55.20.1 2024/09/20 09:30:52 martin Exp $");
 
 #include 
 #include 
@@ -57,7 +57,7 @@ void db_print_window(uint64_t);
 #endif
 
 #ifdef _KERNEL
-#define	KLOAD(x)	probeget((paddr_t)(u_long)&(x), ASI_PRIMARY, sizeof(x))	
+#define	KLOAD(x)	probeget((paddr_t)(u_long)&(x), ASI_PRIMARY, sizeof(x))
 #else
 static long
 kload(db_addr_t addr)
@@ -127,12 +127,8 @@ db_stack_trace_print(db_expr_t addr, boo
 			}
 			(*pr)("lid %d ", l.l_lid);
 			pcb = lwp_getpcb(&l);
-#ifndef _KERNEL
 			db_read_bytes((db_addr_t)&pcb->pcb_sp,
 			sizeof(frame), (char *)&frame);
-#else
-			frame = (vaddr_t)pcb->pcb_sp;
-#endif
 			(*pr)("at %p\n", frame);
 		} else {
 			frame = (vaddr_t)addr;
@@ -153,12 +149,12 @@ db_stack_trace_print(db_expr_t addr, boo
 		if (frame & 1) {
 			f64 = (struct frame64 *)(frame + BIAS);
 			pc = (db_addr_t)KLOAD(f64->fr_pc);
-		
+
 			frame = KLOAD(f64->fr_fp);
 		} else {
 			f32 = (struct frame32 *)(frame);
 			pc = (db_addr_t)KLOAD(f32->fr_pc);
-		
+
 			frame = (long)KLOAD(f32->fr_fp);
 		}
 
@@ -175,13 +171,13 @@ db_stack_trace_print(db_expr_t addr, boo
 		if (!INKERNEL(frame))
 			break;
 #endif
-		
+
 		db_find_sym_and_offset(pc, &name, &offset);
 		if (name == NULL)
 			name = "?";
-		
+
 		(*pr)("%s(", name);
-		
+
 		/*
 		 * Print %i0..%i5; hope these still reflect the
 		 * actual arguments somewhat...
@@ -216,7 +212,7 @@ db_dump_window(db_expr_t addr, bool have
 
 	/* Traverse window stack */
 	for (i=0; ifr_fp;
 		else frame = (uint64_t)((struct frame32 *)(u_long)frame)->fr_fp;
 	}
@@ -226,13 +222,13 @@ db_dump_window(db_expr_t addr, bool have
 }
 #endif
 
-void 
+void
 db_print_window(uint64_t frame)
 {
 	if (frame & 1) {
 		struct frame64* f = (struct frame64*)(u_long)(frame + BIAS);
 
-		db_printf("frame64 %p locals, ins:\n", f);		
+		db_printf("frame64 %p locals, ins:\n", f);
 		if (INKERNEL(f)) {
 			db_printf("%llx %llx %llx %llx ",
   (unsigned long long)f->fr_local[0],
@@ -245,12 +241,12 @@ db_print_window(uint64_t frame)
   (unsigned long long)f->fr_local[6],
   (unsigned long long)f->fr_local[7]);
 			db_printf("%llx %llx %llx %llx ",
-  (unsigned long long)f->fr_arg[0],	
+  (unsigned long long)f->fr_arg[0],
   (unsigned long long)f->fr_arg[1],
   (unsigned long long)f->fr_arg[2],
   (unsigned long long)f->fr_arg[3]);
 			db_printf("%llx %llx %llx=sp %llx=pc:",
-  (unsigned long long)f->fr_arg[4],	
+  (unsigned long long)f->fr_arg[4],
   (unsigned long long)f->fr_arg[5],
   (unsigned long long)f->fr_fp,
   (unsigned long long)f->fr_pc);
@@ -276,7 +272,7 @@ db_print_window(uint64_t frame)
   (unsigned long long)f->fr_arg[5],
   (unsigned long long)f->fr_fp,
   (unsigned long long)f->fr_pc);
-			db_printf("\n");	 
+			db_printf("\n");
 		}
 	} else {
 		struct frame32* f = (struct frame32*)(u_long)frame;
@@ -297,14 +293,14 @@ db_print_window(uint64_t frame)
 			if (copyin(f, &fr, sizeof(fr))) return;
 			f = &fr;
 			db_printf("%8x %8x %8x %8x %8x %8x %8x %8x\n",
-  f->fr_local[0], f->fr_local[1], 
+  f->fr_local[0], f->fr_local[1],
   f->fr_local[2], f->fr_local[3],
-  f->fr_local[4], f->fr_local[5], 
+  f->fr_local[4], f->fr_local[5],
   f->fr_local[6], f->fr_local[7]);
 			db_printf("%8x %8x %8x %8x %8x %8x %8x=sp %8x=pc\n",
-  f->fr_arg[0], f->fr_arg[1], 
+  f->fr_arg[0], f->fr_arg[1],
   f->fr_arg[2], f->fr_arg[3],
-  f->fr_arg[4], f->fr_arg[5], 
+  f->fr_arg[4], f->fr_arg[5],
 	

CVS commit: [netbsd-10] src/sys/dev

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:24:12 UTC 2024

Modified Files:
src/sys/dev [netbsd-10]: md.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #884):

sys/dev/md.c: revision 1.87

It is not sufficient to have a comment /* Sanity check the size. */,
also check the size is greater than zero and a multiple of DEV_BSIZE.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.86.4.1 src/sys/dev/md.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/md.c
diff -u src/sys/dev/md.c:1.86 src/sys/dev/md.c:1.86.4.1
--- src/sys/dev/md.c:1.86	Sat Sep 24 23:20:13 2022
+++ src/sys/dev/md.c	Fri Sep 20 09:24:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.86 2022/09/24 23:20:13 thorpej Exp $	*/
+/*	$NetBSD: md.c,v 1.86.4.1 2024/09/20 09:24:12 martin Exp $	*/
 
 /*
  * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.86 2022/09/24 23:20:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.86.4.1 2024/09/20 09:24:12 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_md.h"
@@ -589,10 +589,13 @@ md_ioctl_kalloc(struct md_softc *sc, str
 	vaddr_t addr;
 	vsize_t size;
 
-	mutex_exit(&sc->sc_lock);
-
 	/* Sanity check the size. */
 	size = umd->md_size;
+	if (size < DEV_BSIZE || (size % DEV_BSIZE) != 0)
+		return EINVAL;
+
+	mutex_exit(&sc->sc_lock);
+
 	addr = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
 
 	mutex_enter(&sc->sc_lock);



CVS commit: [netbsd-10] src/sys/dev

2024-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 20 09:24:12 UTC 2024

Modified Files:
src/sys/dev [netbsd-10]: md.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #884):

sys/dev/md.c: revision 1.87

It is not sufficient to have a comment /* Sanity check the size. */,
also check the size is greater than zero and a multiple of DEV_BSIZE.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.86.4.1 src/sys/dev/md.c

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



CVS commit: [netbsd-10] src/sys/miscfs/procfs

2024-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep 16 08:42:20 UTC 2024

Modified Files:
src/sys/miscfs/procfs [netbsd-10]: procfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #868):

sys/miscfs/procfs/procfs_vfsops.c: revision 1.120 (via patch)

Define dependencies based on build options.


To generate a diff of this commit:
cvs rdiff -u -r1.111.4.2 -r1.111.4.3 src/sys/miscfs/procfs/procfs_vfsops.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/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.111.4.2 src/sys/miscfs/procfs/procfs_vfsops.c:1.111.4.3
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.111.4.2	Fri Sep 13 14:09:51 2024
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Mon Sep 16 08:42:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.111.4.2 2024/09/13 14:09:51 martin Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.111.4.3 2024/09/16 08:42:20 martin Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,10 +76,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.111.4.2 2024/09/13 14:09:51 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.111.4.3 2024/09/16 08:42:20 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
+#include "opt_sysv_ipc.h"
 #endif
 
 #include 
@@ -107,7 +108,11 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_vfsop
 
 #include 			/* for PAGE_SIZE */
 
-MODULE(MODULE_CLASS_VFS, procfs, "ptrace_common,mqueue,sysv_ipc");
+MODULE(MODULE_CLASS_VFS, procfs, "ptrace_common"
+#if defined(SYSVSHM) || defined(SYSVSEM) || defined(SYSVMSG)
+",sysv_ipc"
+#endif
+);
 
 VFS_PROTOS(procfs);
 



CVS commit: [netbsd-10] src/sys/miscfs/procfs

2024-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep 16 08:42:20 UTC 2024

Modified Files:
src/sys/miscfs/procfs [netbsd-10]: procfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #868):

sys/miscfs/procfs/procfs_vfsops.c: revision 1.120 (via patch)

Define dependencies based on build options.


To generate a diff of this commit:
cvs rdiff -u -r1.111.4.2 -r1.111.4.3 src/sys/miscfs/procfs/procfs_vfsops.c

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



CVS commit: [netbsd-10] src/sys/netinet6

2024-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 14:42:16 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-10]: frag6.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #865):

sys/netinet6/frag6.c: revision 1.77

Add a check for FreeBSD-SA-23:06.ipv6, although it is not reproducible for us.
factor out code copied 3 times (and now would have been a 4th)


To generate a diff of this commit:
cvs rdiff -u -r1.76.2.1 -r1.76.2.2 src/sys/netinet6/frag6.c

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



CVS commit: [netbsd-10] src/sys/netinet6

2024-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 14:42:16 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-10]: frag6.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #865):

sys/netinet6/frag6.c: revision 1.77

Add a check for FreeBSD-SA-23:06.ipv6, although it is not reproducible for us.
factor out code copied 3 times (and now would have been a 4th)


To generate a diff of this commit:
cvs rdiff -u -r1.76.2.1 -r1.76.2.2 src/sys/netinet6/frag6.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/frag6.c
diff -u src/sys/netinet6/frag6.c:1.76.2.1 src/sys/netinet6/frag6.c:1.76.2.2
--- src/sys/netinet6/frag6.c:1.76.2.1	Sun Apr 28 10:07:03 2024
+++ src/sys/netinet6/frag6.c	Fri Sep 13 14:42:16 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: frag6.c,v 1.76.2.1 2024/04/28 10:07:03 martin Exp $	*/
+/*	$NetBSD: frag6.c,v 1.76.2.2 2024/09/13 14:42:16 martin Exp $	*/
 /*	$KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.76.2.1 2024/04/28 10:07:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.76.2.2 2024/09/13 14:42:16 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -120,6 +120,15 @@ frag6_init(void)
 	mutex_init(&frag6_lock, MUTEX_DEFAULT, IPL_NONE);
 }
 
+static void
+frag6_dropfrag(struct ip6q *q6)
+{
+	frag6_remque(q6);
+	frag6_nfrags -= q6->ip6q_nfrag;
+	kmem_intr_free(q6, sizeof(*q6));
+	frag6_nfragpackets--;
+}
+
 /*
  * IPv6 fragment input.
  *
@@ -456,8 +465,13 @@ insert:
 	/* adjust offset to point where the original next header starts */
 	offset = ip6af->ip6af_offset - sizeof(struct ip6_frag);
 	kmem_intr_free(ip6af, sizeof(struct ip6asfrag));
+	next += offset - sizeof(struct ip6_hdr);
+	if ((u_int)next > IPV6_MAXPACKET) {
+		frag6_dropfrag(q6);
+		goto dropfrag;
+	}
 	ip6 = mtod(m, struct ip6_hdr *);
-	ip6->ip6_plen = htons(next + offset - sizeof(struct ip6_hdr));
+	ip6->ip6_plen = htons(next);
 	ip6->ip6_src = q6->ip6q_src;
 	ip6->ip6_dst = q6->ip6q_dst;
 	nxt = q6->ip6q_nxt;
@@ -472,20 +486,14 @@ insert:
 	} else {
 		/* this comes with no copy if the boundary is on cluster */
 		if ((t = m_split(m, offset, M_DONTWAIT)) == NULL) {
-			frag6_remque(q6);
-			frag6_nfrags -= q6->ip6q_nfrag;
-			kmem_intr_free(q6, sizeof(struct ip6q));
-			frag6_nfragpackets--;
+			frag6_dropfrag(q6);
 			goto dropfrag;
 		}
 		m_adj(t, sizeof(struct ip6_frag));
 		m_cat(m, t);
 	}
 
-	frag6_remque(q6);
-	frag6_nfrags -= q6->ip6q_nfrag;
-	kmem_intr_free(q6, sizeof(struct ip6q));
-	frag6_nfragpackets--;
+	frag6_dropfrag(q6);
 
 	{
 		KASSERT(m->m_flags & M_PKTHDR);
@@ -585,10 +593,7 @@ frag6_freef(struct ip6q *q6)
 		kmem_intr_free(af6, sizeof(struct ip6asfrag));
 	}
 
-	frag6_remque(q6);
-	frag6_nfrags -= q6->ip6q_nfrag;
-	kmem_intr_free(q6, sizeof(struct ip6q));
-	frag6_nfragpackets--;
+	frag6_dropfrag(q6);
 }
 
 /*



CVS commit: [netbsd-10] src/sys/netinet

2024-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 14:23:15 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: sctp_output.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #863):

sys/netinet/sctp_output.c: revision 1.34

handle EHOSTDOWN the same way as EHOSTUNREACH in sctp_med_chunk_output().

Compile-tested only (I don't have a sctp setup); proposed in
http://mail-index.netbsd.org/tech-net/2023/09/11/msg008611.html

LGTM from Greg Troxel and Robert Swindells


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.2.1 src/sys/netinet/sctp_output.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/sctp_output.c
diff -u src/sys/netinet/sctp_output.c:1.33 src/sys/netinet/sctp_output.c:1.33.2.1
--- src/sys/netinet/sctp_output.c:1.33	Fri Nov  4 09:01:53 2022
+++ src/sys/netinet/sctp_output.c	Fri Sep 13 14:23:15 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sctp_output.c,v 1.33 2022/11/04 09:01:53 ozaki-r Exp $ */
+/*	$NetBSD: sctp_output.c,v 1.33.2.1 2024/09/13 14:23:15 martin Exp $ */
 /*	$KAME: sctp_output.c,v 1.48 2005/06/16 18:29:24 jinmei Exp $	*/
 
 /*
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sctp_output.c,v 1.33 2022/11/04 09:01:53 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctp_output.c,v 1.33.2.1 2024/09/13 14:23:15 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -5643,7 +5643,8 @@ sctp_med_chunk_output(struct sctp_inpcb 
 			}
 			hbflag = 0;
 		}
-		if (error == EHOSTUNREACH) {
+		if (error == EHOSTUNREACH ||
+		error == EHOSTDOWN) {
 			/*
 			 * Destination went
 			 * unreachable during
@@ -5921,7 +5922,8 @@ sctp_med_chunk_output(struct sctp_inpcb 
 	}
 	hbflag = 0;
 }
-if (error == EHOSTUNREACH) {
+if (error == EHOSTUNREACH ||
+error == EHOSTDOWN) {
 	/*
 	 * Destination went unreachable during
 	 * this send



CVS commit: [netbsd-10] src/sys/netinet

2024-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 14:23:15 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: sctp_output.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #863):

sys/netinet/sctp_output.c: revision 1.34

handle EHOSTDOWN the same way as EHOSTUNREACH in sctp_med_chunk_output().

Compile-tested only (I don't have a sctp setup); proposed in
http://mail-index.netbsd.org/tech-net/2023/09/11/msg008611.html

LGTM from Greg Troxel and Robert Swindells


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.2.1 src/sys/netinet/sctp_output.c

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



CVS commit: [netbsd-10] src/sys/netinet

2024-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 14:21:32 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: dccp_tfrc.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #862):

sys/netinet/dccp_tfrc.c: revision 1.11

avoid uninitialised variable use.
found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/netinet/dccp_tfrc.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/dccp_tfrc.c
diff -u src/sys/netinet/dccp_tfrc.c:1.9 src/sys/netinet/dccp_tfrc.c:1.9.4.1
--- src/sys/netinet/dccp_tfrc.c:1.9	Fri Dec 10 20:36:04 2021
+++ src/sys/netinet/dccp_tfrc.c	Fri Sep 13 14:21:32 2024
@@ -1,5 +1,5 @@
 /*	$KAME: dccp_tfrc.c,v 1.16 2006/03/01 17:34:08 nishida Exp $	*/
-/*	$NetBSD: dccp_tfrc.c,v 1.9 2021/12/10 20:36:04 andvar Exp $ */
+/*	$NetBSD: dccp_tfrc.c,v 1.9.4.1 2024/09/13 14:21:32 martin Exp $ */
 
 /*
  * Copyright (c) 2003  Nils-Erik Mattsson
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dccp_tfrc.c,v 1.9 2021/12/10 20:36:04 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dccp_tfrc.c,v 1.9.4.1 2024/09/13 14:21:32 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dccp.h"
@@ -384,7 +384,7 @@ tfrc_time_no_feedback(void *ccb)
 		/* half send rate */
 		cb->x.denom *= 2;
 		v.num = cb->s;
-		v.denom *= TFRC_MAX_BACK_OFF_TIME;
+		v.denom = TFRC_MAX_BACK_OFF_TIME;
 		if (fixpoint_cmp(&cb->x, &v) < 0)
 			cb->x = v;
 
@@ -414,7 +414,7 @@ tfrc_time_no_feedback(void *ccb)
 
 		v.num = cb->s;
 		v.num *= 4;
-		v.denom *= cb->rtt;
+		v.denom = cb->rtt;
 		v.num *= 100;
 		normalize(&v.num, &v.denom);
 		if (!cb->idle || fixpoint_cmp(&cb->x_recv, &v) >= 0) {



CVS commit: [netbsd-10] src/sys/netinet

2024-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 14:21:32 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: dccp_tfrc.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #862):

sys/netinet/dccp_tfrc.c: revision 1.11

avoid uninitialised variable use.
found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/netinet/dccp_tfrc.c

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



CVS commit: [netbsd-10] src/sys/net

2024-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 14:13:06 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: bpf.c bpfdesc.h

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #858):

sys/net/bpfdesc.h: revision 1.49
sys/net/bpf.c: revision 1.256
sys/net/bpf.c: revision 1.257
sys/net/bpfdesc.h: revision 1.50

bpf: restore wakeup softint

This change fixes the issue that fownsignal which can take an
adaptive mutex is called inside a pserialize read section in
bpf_deliver.

Fix issue #4 (only the latter of two) in PR#58596
bpf: protect selnotify and selrecord with bd_buf_mtx

We have to make updates and checks of buffers and calls of
selnotify/selrecord atomic to satisfy constraints of sel* API.

Also, bd_state and bd_cv are protected by bd_buf_mtx now.

Fix issue #3 of PR#58596

Part of the fix is inspired by riastradh's patch.


To generate a diff of this commit:
cvs rdiff -u -r1.249.2.2 -r1.249.2.3 src/sys/net/bpf.c
cvs rdiff -u -r1.48 -r1.48.10.1 src/sys/net/bpfdesc.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/net/bpf.c
diff -u src/sys/net/bpf.c:1.249.2.2 src/sys/net/bpf.c:1.249.2.3
--- src/sys/net/bpf.c:1.249.2.2	Thu Aug 22 19:31:08 2024
+++ src/sys/net/bpf.c	Fri Sep 13 14:13:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.249.2.2 2024/08/22 19:31:08 martin Exp $	*/
+/*	$NetBSD: bpf.c,v 1.249.2.3 2024/09/13 14:13:05 martin Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.249.2.2 2024/08/22 19:31:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.249.2.3 2024/09/13 14:13:05 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -271,6 +271,7 @@ static int	bpf_poll(struct file *, int);
 static int	bpf_stat(struct file *, struct stat *);
 static int	bpf_close(struct file *);
 static int	bpf_kqfilter(struct file *, struct knote *);
+static void	bpf_softintr(void *);
 
 static const struct fileops bpf_fileops = {
 	.fo_name = "bpf",
@@ -605,6 +606,7 @@ bpfopen(dev_t dev, int flag, int mode, s
 	d->bd_atime = d->bd_mtime = d->bd_btime;
 	callout_init(&d->bd_callout, CALLOUT_MPSAFE);
 	selinit(&d->bd_sel);
+	d->bd_sih = softint_establish(SOFTINT_CLOCK, bpf_softintr, d);
 	d->bd_jitcode = NULL;
 	d->bd_rfilter = NULL;
 	d->bd_wfilter = NULL;
@@ -644,10 +646,12 @@ bpf_close(struct file *fp)
 	 */
 	d->bd_pid = curproc->p_pid;
 
-	mutex_enter(d->bd_mtx);
+	mutex_enter(d->bd_buf_mtx);
 	if (d->bd_state == BPF_WAITING)
-		callout_halt(&d->bd_callout, d->bd_mtx);
+		callout_halt(&d->bd_callout, d->bd_buf_mtx);
 	d->bd_state = BPF_IDLE;
+	mutex_exit(d->bd_buf_mtx);
+	mutex_enter(d->bd_mtx);
 	if (d->bd_bif)
 		bpf_detachd(d);
 	mutex_exit(d->bd_mtx);
@@ -663,6 +667,7 @@ bpf_close(struct file *fp)
 	bpf_freed(d);
 	callout_destroy(&d->bd_callout);
 	seldestroy(&d->bd_sel);
+	softint_disestablish(d->bd_sih);
 	mutex_obj_free(d->bd_mtx);
 	mutex_obj_free(d->bd_buf_mtx);
 	cv_destroy(&d->bd_cv);
@@ -707,12 +712,12 @@ bpf_read(struct file *fp, off_t *offp, s
 	if (uio->uio_resid != d->bd_bufsize)
 		return (EINVAL);
 
-	mutex_enter(d->bd_mtx);
+	mutex_enter(d->bd_buf_mtx);
 	if (d->bd_state == BPF_WAITING)
-		callout_halt(&d->bd_callout, d->bd_mtx);
+		callout_halt(&d->bd_callout, d->bd_buf_mtx);
 	timed_out = (d->bd_state == BPF_TIMED_OUT);
 	d->bd_state = BPF_IDLE;
-	mutex_exit(d->bd_mtx);
+	mutex_exit(d->bd_buf_mtx);
 	/*
 	 * If the hold buffer is empty, then do a timed sleep, which
 	 * ends when the timeout expires or when enough packets
@@ -797,13 +802,23 @@ static inline void
 bpf_wakeup(struct bpf_d *d)
 {
 
-	mutex_enter(d->bd_buf_mtx);
+	KASSERT(mutex_owned(d->bd_buf_mtx));
+
 	cv_broadcast(&d->bd_cv);
-	mutex_exit(d->bd_buf_mtx);
 
 	if (d->bd_async)
+		softint_schedule(d->bd_sih);
+	selnotify(&d->bd_sel, 0, NOTE_SUBMIT);
+}
+
+static void
+bpf_softintr(void *cookie)
+{
+	struct bpf_d *d;
+
+	d = cookie;
+	if (d->bd_async)
 		fownsignal(d->bd_pgid, SIGIO, 0, 0, NULL);
-	selnotify(&d->bd_sel, 0, 0);
 }
 
 static void
@@ -811,13 +826,13 @@ bpf_timed_out(void *arg)
 {
 	struct bpf_d *d = arg;
 
-	mutex_enter(d->bd_mtx);
+	mutex_enter(d->bd_buf_mtx);
 	if (d->bd_state == BPF_WAITING) {
 		d->bd_state = BPF_TIMED_OUT;
 		if (d->bd_slen != 0)
 			bpf_wakeup(d);
 	}
-	mutex_exit(d->bd_mtx);
+	mutex_exit(d->bd_buf_mtx);
 }
 
 
@@ -979,11 +994,11 @@ bpf_ioctl(struct file *fp, u_long cmd, v
 		d->bd_compat32 = 0;
 #endif
 
-	mutex_enter(d->bd_mtx);
+	mutex_enter(d->bd_buf_mtx);
 	if (d->bd_state == BPF_WAITING)
-		callout_halt(&d->bd_callout, d->bd_mtx);
+		callout_halt(&d->bd_callout, d->bd_buf_mtx);
 	d->bd_state = BPF_IDLE;
-	mutex_exit(d->bd_mtx);
+	mutex_exit(d->bd_buf_mtx);
 
 	if (d->bd_locked) {
 		switch (cmd) {
@@ -1560,6 +1575,7 @@ bpf_poll(struct file *fp, int events)
 		 * An imitation of the FIONREAD ioctl code.
 		 */
 		mutex

CVS commit: [netbsd-10] src/sys/net

2024-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 14:13:06 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: bpf.c bpfdesc.h

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #858):

sys/net/bpfdesc.h: revision 1.49
sys/net/bpf.c: revision 1.256
sys/net/bpf.c: revision 1.257
sys/net/bpfdesc.h: revision 1.50

bpf: restore wakeup softint

This change fixes the issue that fownsignal which can take an
adaptive mutex is called inside a pserialize read section in
bpf_deliver.

Fix issue #4 (only the latter of two) in PR#58596
bpf: protect selnotify and selrecord with bd_buf_mtx

We have to make updates and checks of buffers and calls of
selnotify/selrecord atomic to satisfy constraints of sel* API.

Also, bd_state and bd_cv are protected by bd_buf_mtx now.

Fix issue #3 of PR#58596

Part of the fix is inspired by riastradh's patch.


To generate a diff of this commit:
cvs rdiff -u -r1.249.2.2 -r1.249.2.3 src/sys/net/bpf.c
cvs rdiff -u -r1.48 -r1.48.10.1 src/sys/net/bpfdesc.h

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



CVS commit: [netbsd-10] src/sys

2024-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 14:09:51 UTC 2024

Modified Files:
src/sys/miscfs/procfs [netbsd-10]: procfs_vfsops.c
src/sys/modules/procfs [netbsd-10]: Makefile

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #857):

sys/modules/procfs/Makefile: revision 1.8
sys/miscfs/procfs/procfs_vfsops.c: revision 1.118
sys/miscfs/procfs/procfs_vfsops.c: revision 1.119

procfs grew a new dependency

Include the SYSV_* entries for modular procfs

Now we have another dependency for the SYSV_* stuff.


To generate a diff of this commit:
cvs rdiff -u -r1.111.4.1 -r1.111.4.2 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.7 -r1.7.26.1 src/sys/modules/procfs/Makefile

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

Modified files:

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.111.4.1 src/sys/miscfs/procfs/procfs_vfsops.c:1.111.4.2
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.111.4.1	Thu Apr 18 18:22:10 2024
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Fri Sep 13 14:09:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.111.4.1 2024/04/18 18:22:10 martin Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.111.4.2 2024/09/13 14:09:51 martin Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.111.4.1 2024/04/18 18:22:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.111.4.2 2024/09/13 14:09:51 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -107,7 +107,7 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_vfsop
 
 #include 			/* for PAGE_SIZE */
 
-MODULE(MODULE_CLASS_VFS, procfs, "ptrace_common");
+MODULE(MODULE_CLASS_VFS, procfs, "ptrace_common,mqueue,sysv_ipc");
 
 VFS_PROTOS(procfs);
 

Index: src/sys/modules/procfs/Makefile
diff -u src/sys/modules/procfs/Makefile:1.7 src/sys/modules/procfs/Makefile:1.7.26.1
--- src/sys/modules/procfs/Makefile:1.7	Thu Sep 26 17:34:56 2019
+++ src/sys/modules/procfs/Makefile	Fri Sep 13 14:09:51 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.7 2019/09/26 17:34:56 christos Exp $
+#	$NetBSD: Makefile,v 1.7.26.1 2024/09/13 14:09:51 martin Exp $
 
 .include "../Makefile.inc"
 
@@ -9,6 +9,9 @@
 .PATH:  ${S}/arch/x86/x86
 .endif
 
+# enable the SYSV linux nodes
+COPTS+=	-D SYSVSHM -D SYSVSEM -D SYSVMSG
+
 KMOD=	procfs
 SRCS=	procfs_note.c procfs_status.c procfs_subr.c \
 	procfs_vfsops.c procfs_vnops.c procfs_cmdline.c procfs_limit.c \



CVS commit: [netbsd-10] src/sys

2024-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 14:09:51 UTC 2024

Modified Files:
src/sys/miscfs/procfs [netbsd-10]: procfs_vfsops.c
src/sys/modules/procfs [netbsd-10]: Makefile

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #857):

sys/modules/procfs/Makefile: revision 1.8
sys/miscfs/procfs/procfs_vfsops.c: revision 1.118
sys/miscfs/procfs/procfs_vfsops.c: revision 1.119

procfs grew a new dependency

Include the SYSV_* entries for modular procfs

Now we have another dependency for the SYSV_* stuff.


To generate a diff of this commit:
cvs rdiff -u -r1.111.4.1 -r1.111.4.2 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.7 -r1.7.26.1 src/sys/modules/procfs/Makefile

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



CVS commit: [netbsd-10] src/sys/net

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 20:08:52 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: if_tap.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #852):

sys/net/if_tap.c: revision 1.134

if_tap: Explicitly include "opt_net_mpsafe.h", NFC
because it was included via  anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.127.4.2 -r1.127.4.3 src/sys/net/if_tap.c

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



CVS commit: [netbsd-10] src/sys/net

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 20:08:52 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: if_tap.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #852):

sys/net/if_tap.c: revision 1.134

if_tap: Explicitly include "opt_net_mpsafe.h", NFC
because it was included via  anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.127.4.2 -r1.127.4.3 src/sys/net/if_tap.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/net/if_tap.c
diff -u src/sys/net/if_tap.c:1.127.4.2 src/sys/net/if_tap.c:1.127.4.3
--- src/sys/net/if_tap.c:1.127.4.2	Wed Sep 11 16:12:49 2024
+++ src/sys/net/if_tap.c	Thu Sep 12 20:08:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tap.c,v 1.127.4.2 2024/09/11 16:12:49 martin Exp $	*/
+/*	$NetBSD: if_tap.c,v 1.127.4.3 2024/09/12 20:08:51 martin Exp $	*/
 
 /*
  *  Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@@ -33,11 +33,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.127.4.2 2024/09/11 16:12:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.127.4.3 2024/09/12 20:08:51 martin Exp $");
 
 #if defined(_KERNEL_OPT)
-
 #include "opt_modular.h"
+#include "opt_net_mpsafe.h"
 #endif
 
 #include 



CVS commit: [netbsd-10] src/sys/dev

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 20:07:05 UTC 2024

Modified Files:
src/sys/dev [netbsd-10]: vnd.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #851):

sys/dev/vnd.c: revision 1.290

Avoid division by zero when the backing file is revoked (e.g. from
umount -f).


To generate a diff of this commit:
cvs rdiff -u -r1.287.4.2 -r1.287.4.3 src/sys/dev/vnd.c

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



CVS commit: [netbsd-10] src/sys/dev

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 20:07:05 UTC 2024

Modified Files:
src/sys/dev [netbsd-10]: vnd.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #851):

sys/dev/vnd.c: revision 1.290

Avoid division by zero when the backing file is revoked (e.g. from
umount -f).


To generate a diff of this commit:
cvs rdiff -u -r1.287.4.2 -r1.287.4.3 src/sys/dev/vnd.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/vnd.c
diff -u src/sys/dev/vnd.c:1.287.4.2 src/sys/dev/vnd.c:1.287.4.3
--- src/sys/dev/vnd.c:1.287.4.2	Thu Aug 17 10:00:01 2023
+++ src/sys/dev/vnd.c	Thu Sep 12 20:07:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.287.4.2 2023/08/17 10:00:01 martin Exp $	*/
+/*	$NetBSD: vnd.c,v 1.287.4.3 2024/09/12 20:07:05 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008, 2020 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.287.4.2 2023/08/17 10:00:01 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.287.4.3 2024/09/12 20:07:05 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -875,6 +875,9 @@ handle_with_strategy(struct vnd_softc *v
 	bn = obp->b_rawblkno * vnd->sc_dkdev.dk_label->d_secsize;
 
 	bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize;
+	/* use default if the filesystem didn't specify a block size */
+	if (bsize <= 0)
+		bsize = BLKDEV_IOSIZE;
 	skipped = 0;
 
 	/*



CVS commit: [netbsd-10] src/sys/arch/amiga/amiga

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:50:47 UTC 2024

Modified Files:
src/sys/arch/amiga/amiga [netbsd-10]: trap.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #845):

sys/arch/amiga/amiga/trap.c: revision 1.143

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


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.139.20.1 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.139 src/sys/arch/amiga/amiga/trap.c:1.139.20.1
--- src/sys/arch/amiga/amiga/trap.c:1.139	Mon Aug 10 10:51:21 2020
+++ src/sys/arch/amiga/amiga/trap.c	Thu Sep 12 19:50:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.139 2020/08/10 10:51:21 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.139.20.1 2024/09/12 19:50:47 martin 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.139 2020/08/10 10:51:21 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.139.20.1 2024/09/12 19:50:47 martin Exp $");
 
 #include 
 #include 
@@ -363,7 +363,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: [netbsd-10] src/sys/arch/macppc/macppc

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:56:08 UTC 2024

Modified Files:
src/sys/arch/macppc/macppc [netbsd-10]: machdep.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #847):

sys/arch/macppc/macppc/machdep.c: revision 1.177

macppc/machdep: Correctly disable have_backlight for ofw_quiesce
instead of have_palette (copy-paste bug by myself).


To generate a diff of this commit:
cvs rdiff -u -r1.175 -r1.175.4.1 src/sys/arch/macppc/macppc/machdep.c

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

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.175 src/sys/arch/macppc/macppc/machdep.c:1.175.4.1
--- src/sys/arch/macppc/macppc/machdep.c:1.175	Sun Jun 26 09:23:32 2022
+++ src/sys/arch/macppc/macppc/machdep.c	Thu Sep 12 19:56:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.175 2022/06/26 09:23:32 martin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.175.4.1 2024/09/12 19:56:08 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175 2022/06/26 09:23:32 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175.4.1 2024/09/12 19:56:08 martin Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -421,7 +421,7 @@ copy_disp_props(device_t dev, int node, 
 	if (have_backlight && ofw_quiesce) {
 		aprint_debug(
 		"OFW has been quiesced - disabling backlight callbacks\n");
-		have_palette = 0;
+		have_backlight = 0;
 	}
 
 	if (have_backlight) {



CVS commit: [netbsd-10] src/sys/arch/macppc/macppc

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:56:08 UTC 2024

Modified Files:
src/sys/arch/macppc/macppc [netbsd-10]: machdep.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #847):

sys/arch/macppc/macppc/machdep.c: revision 1.177

macppc/machdep: Correctly disable have_backlight for ofw_quiesce
instead of have_palette (copy-paste bug by myself).


To generate a diff of this commit:
cvs rdiff -u -r1.175 -r1.175.4.1 src/sys/arch/macppc/macppc/machdep.c

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



CVS commit: [netbsd-10] src/sys/arch/amiga/amiga

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:50:47 UTC 2024

Modified Files:
src/sys/arch/amiga/amiga [netbsd-10]: trap.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #845):

sys/arch/amiga/amiga/trap.c: revision 1.143

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


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.139.20.1 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: [netbsd-10] src/sys/dev/acpi

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:49:00 UTC 2024

Modified Files:
src/sys/dev/acpi [netbsd-10]: acpi_bat.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #844):

sys/dev/acpi/acpi_bat.c: revision 1.122
sys/dev/acpi/acpi_bat.c: revision 1.123

PR/58201: Malte Dehling: re-order sysmon initialization before acpi
registration, to avoid needing to call to acpi_deregister_notify on sysmon
failure.

Remove 0 initializations (since the softc is zalloc'ed) and the initial
refresh which will have no data.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.121.4.1 src/sys/dev/acpi/acpi_bat.c

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



CVS commit: [netbsd-10] src/sys/dev/acpi

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:49:00 UTC 2024

Modified Files:
src/sys/dev/acpi [netbsd-10]: acpi_bat.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #844):

sys/dev/acpi/acpi_bat.c: revision 1.122
sys/dev/acpi/acpi_bat.c: revision 1.123

PR/58201: Malte Dehling: re-order sysmon initialization before acpi
registration, to avoid needing to call to acpi_deregister_notify on sysmon
failure.

Remove 0 initializations (since the softc is zalloc'ed) and the initial
refresh which will have no data.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.121.4.1 src/sys/dev/acpi/acpi_bat.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/acpi/acpi_bat.c
diff -u src/sys/dev/acpi/acpi_bat.c:1.121 src/sys/dev/acpi/acpi_bat.c:1.121.4.1
--- src/sys/dev/acpi/acpi_bat.c:1.121	Fri Jan  7 01:10:57 2022
+++ src/sys/dev/acpi/acpi_bat.c	Thu Sep 12 19:49:00 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_bat.c,v 1.121 2022/01/07 01:10:57 riastradh Exp $	*/
+/*	$NetBSD: acpi_bat.c,v 1.121.4.1 2024/09/12 19:49:00 martin Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.121 2022/01/07 01:10:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.121.4.1 2024/09/12 19:49:00 martin Exp $");
 
 #include 
 #include 
@@ -229,14 +229,6 @@ acpibat_attach(device_t parent, device_t
 
 	sc->sc_node = aa->aa_node;
 
-	sc->sc_present = 0;
-	sc->sc_dvoltage = 0;
-	sc->sc_dcapacity = 0;
-	sc->sc_lcapacity = 0;
-	sc->sc_wcapacity = 0;
-
-	sc->sc_sme = NULL;
-
 	mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(&sc->sc_condvar, device_xname(self));
 
@@ -759,20 +751,19 @@ acpibat_init_envsys(device_t dv)
 	sc->sc_sme->sme_cookie = dv;
 	sc->sc_sme->sme_refresh = acpibat_refresh;
 	sc->sc_sme->sme_class = SME_CLASS_BATTERY;
-	sc->sc_sme->sme_flags = SME_POLL_ONLY | SME_INIT_REFRESH;
+	sc->sc_sme->sme_flags = SME_POLL_ONLY;
 	sc->sc_sme->sme_get_limits = acpibat_get_limits;
 
+	if (sysmon_envsys_register(sc->sc_sme))
+		goto fail;
+
 	(void)acpi_register_notify(sc->sc_node, acpibat_notify_handler);
 	acpibat_update_info(dv);
 	acpibat_update_status(dv);
 
-	if (sysmon_envsys_register(sc->sc_sme))
-		goto fail;
-
 	(void)pmf_device_register(dv, NULL, acpibat_resume);
 
 	return;
-
 fail:
 	aprint_error_dev(dv, "failed to initialize sysmon\n");
 



CVS commit: [netbsd-10] src/sys/kern

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:47:13 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: vfs_mount.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #843):

sys/kern/vfs_mount.c: revision 1.105

dounmount: Avoid &((struct vnode_impl *)NULL)->vi_vnode.

Member access of a null pointer is undefined, even if the result
should also be null because vi_vnode is at the start of vnode_impl.


To generate a diff of this commit:
cvs rdiff -u -r1.101.2.1 -r1.101.2.2 src/sys/kern/vfs_mount.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/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.101.2.1 src/sys/kern/vfs_mount.c:1.101.2.2
--- src/sys/kern/vfs_mount.c:1.101.2.1	Thu Apr 18 18:22:10 2024
+++ src/sys/kern/vfs_mount.c	Thu Sep 12 19:47:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.101.2.1 2024/04/18 18:22:10 martin Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.101.2.2 2024/09/12 19:47:13 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.101.2.1 2024/04/18 18:22:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.101.2.2 2024/09/12 19:47:13 martin Exp $");
 
 #include 
 #include 
@@ -937,7 +937,8 @@ err_mounted:
 int
 dounmount(struct mount *mp, int flags, struct lwp *l)
 {
-	vnode_t *coveredvp, *vp;
+	struct vnode *coveredvp, *vp;
+	struct vnode_impl *vip;
 	int error, async, used_syncer, used_extattr;
 	const bool was_suspended = fstrans_is_owner(mp);
 
@@ -1004,7 +1005,9 @@ dounmount(struct mount *mp, int flags, s
 		vfs_resume(mp);
 
 	mountlist_remove(mp);
-	if ((vp = VIMPL_TO_VNODE(TAILQ_FIRST(&mp->mnt_vnodelist))) != NULL) {
+
+	if ((vip = TAILQ_FIRST(&mp->mnt_vnodelist)) != NULL) {
+		vp = VIMPL_TO_VNODE(vip);
 		vprint("dangling", vp);
 		panic("unmount: dangling vnode");
 	}



CVS commit: [netbsd-10] src/sys/kern

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:47:13 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: vfs_mount.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #843):

sys/kern/vfs_mount.c: revision 1.105

dounmount: Avoid &((struct vnode_impl *)NULL)->vi_vnode.

Member access of a null pointer is undefined, even if the result
should also be null because vi_vnode is at the start of vnode_impl.


To generate a diff of this commit:
cvs rdiff -u -r1.101.2.1 -r1.101.2.2 src/sys/kern/vfs_mount.c

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



CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:39:35 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: ucycom.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #841):

sys/dev/usb/ucycom.c: revision 1.57

Prevent errant ucycom-presenting device from causing up to 225
bytes of kernel memory following input buffer to leak to tty
application.

Probably not practically expolitable, but you never know.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.56.2.1 src/sys/dev/usb/ucycom.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/ucycom.c
diff -u src/sys/dev/usb/ucycom.c:1.56 src/sys/dev/usb/ucycom.c:1.56.2.1
--- src/sys/dev/usb/ucycom.c:1.56	Wed Oct 26 23:50:28 2022
+++ src/sys/dev/usb/ucycom.c	Thu Sep 12 19:39:35 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucycom.c,v 1.56 2022/10/26 23:50:28 riastradh Exp $	*/
+/*	$NetBSD: ucycom.c,v 1.56.2.1 2024/09/12 19:39:35 martin Exp $	*/
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucycom.c,v 1.56 2022/10/26 23:50:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucycom.c,v 1.56.2.1 2024/09/12 19:39:35 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -978,6 +978,7 @@ ucycom_intr(void *cookie, void *ibuf, u_
 		st = cp[0];
 		n = cp[1];
 		cp += 2;
+		n = uimin(n, 30);
 		break;
 
 	default:



CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:39:35 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: ucycom.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #841):

sys/dev/usb/ucycom.c: revision 1.57

Prevent errant ucycom-presenting device from causing up to 225
bytes of kernel memory following input buffer to leak to tty
application.

Probably not practically expolitable, but you never know.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.56.2.1 src/sys/dev/usb/ucycom.c

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



CVS commit: [netbsd-10] src/sys/modules

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:36:22 UTC 2024

Modified Files:
src/sys/modules [netbsd-10]: Makefile

Log Message:
Pull up following revision(s) (requested by rin in ticket #840):

sys/modules/Makefile: revision 1.282

skip this subdir for "make includes".
it's excessively slow and does nothing (nor should it.)


To generate a diff of this commit:
cvs rdiff -u -r1.274.2.4 -r1.274.2.5 src/sys/modules/Makefile

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

Modified files:

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.274.2.4 src/sys/modules/Makefile:1.274.2.5
--- src/sys/modules/Makefile:1.274.2.4	Sat Jul 20 16:03:23 2024
+++ src/sys/modules/Makefile	Thu Sep 12 19:36:21 2024
@@ -1,7 +1,8 @@
-#	$NetBSD: Makefile,v 1.274.2.4 2024/07/20 16:03:23 martin Exp $
+#	$NetBSD: Makefile,v 1.274.2.5 2024/09/12 19:36:21 martin Exp $
 
 .include 
 
+.if !make(includes)
 # For all platforms
 
 # Modules for compatibility with earlier versions of NetBSD
@@ -498,4 +499,6 @@ SUBDIR+=	vioscsi
 
 SUBDIR+=	examples	# build these regularly to avoid bit-rot
 
+.endif
+
 .include 



CVS commit: [netbsd-10] src/sys/modules

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:36:22 UTC 2024

Modified Files:
src/sys/modules [netbsd-10]: Makefile

Log Message:
Pull up following revision(s) (requested by rin in ticket #840):

sys/modules/Makefile: revision 1.282

skip this subdir for "make includes".
it's excessively slow and does nothing (nor should it.)


To generate a diff of this commit:
cvs rdiff -u -r1.274.2.4 -r1.274.2.5 src/sys/modules/Makefile

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



CVS commit: [netbsd-10] src/sys/dev/dkwedge

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:33:47 UTC 2024

Modified Files:
src/sys/dev/dkwedge [netbsd-10]: dkwedge_mbr.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #839):

sys/dev/dkwedge/dkwedge_mbr.c: revision 1.13

In case of trouble reading an MBR, make sure error field is set before
reporting it


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.20.1 src/sys/dev/dkwedge/dkwedge_mbr.c

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



CVS commit: [netbsd-10] src/sys/dev/dkwedge

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:33:47 UTC 2024

Modified Files:
src/sys/dev/dkwedge [netbsd-10]: dkwedge_mbr.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #839):

sys/dev/dkwedge/dkwedge_mbr.c: revision 1.13

In case of trouble reading an MBR, make sure error field is set before
reporting it


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.20.1 src/sys/dev/dkwedge/dkwedge_mbr.c

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

Modified files:

Index: src/sys/dev/dkwedge/dkwedge_mbr.c
diff -u src/sys/dev/dkwedge/dkwedge_mbr.c:1.12 src/sys/dev/dkwedge/dkwedge_mbr.c:1.12.20.1
--- src/sys/dev/dkwedge/dkwedge_mbr.c:1.12	Sat Apr 11 16:00:34 2020
+++ src/sys/dev/dkwedge/dkwedge_mbr.c	Thu Sep 12 19:33:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: dkwedge_mbr.c,v 1.12 2020/04/11 16:00:34 jdolecek Exp $	*/
+/*	$NetBSD: dkwedge_mbr.c,v 1.12.20.1 2024/09/12 19:33:47 martin Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_mbr.c,v 1.12 2020/04/11 16:00:34 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_mbr.c,v 1.12.20.1 2024/09/12 19:33:47 martin Exp $");
 
 #include 
 #include 
@@ -90,9 +90,9 @@ getparts(mbr_args_t *a, uint32_t off, ui
 
 	error = dkwedge_read(a->pdk, a->vp, off, a->bp->b_data, a->secsize);
 	if (error) {
+		a->error = error;
 		aprint_error("%s: unable to read MBR @ %u/%u, "
 		"error = %d\n", a->pdk->dk_name, off, a->secsize, a->error);
-		a->error = error;
 		return;
 	}
 



CVS commit: [netbsd-10] src/sys/dev/scsipi

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:31:53 UTC 2024

Modified Files:
src/sys/dev/scsipi [netbsd-10]: sd.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #838):

sys/dev/scsipi/sd.c: revision 1.336

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.335.4.1 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: [netbsd-10] src/sys/dev/scsipi

2024-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 12 19:31:53 UTC 2024

Modified Files:
src/sys/dev/scsipi [netbsd-10]: sd.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #838):

sys/dev/scsipi/sd.c: revision 1.336

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.335.4.1 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.335.4.1
--- src/sys/dev/scsipi/sd.c:1.335	Sun Aug 28 10:26:37 2022
+++ src/sys/dev/scsipi/sd.c	Thu Sep 12 19:31:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.335 2022/08/28 10:26:37 mlelstv Exp $	*/
+/*	$NetBSD: sd.c,v 1.335.4.1 2024/09/12 19:31:53 martin 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.335.4.1 2024/09/12 19:31:53 martin 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(&dksc->sc_dkdev);
+	/* Discover wedges on this disk if it is online */
+	if (result == SDGP_RESULT_OK)
+		dkwedge_discover(&dksc->sc_dkdev);
 
 	/*
 	 * Establish a shutdown hook so that we can ensure that



CVS commit: [netbsd-10] src/sys/dev/spi

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:42:34 UTC 2024

Modified Files:
src/sys/dev/spi [netbsd-10]: spivar.h

Log Message:
Pull up following revision(s) (requested by rin in ticket #836):

sys/dev/spi/spivar.h: revision 1.13

Define mode macros for CPOL and CPHA, and define SPI_MODE_* in terms
of CPOL and CPHA.  Add SPI_FREQ_*() helper macros to make setting the
transfer frequency less error prone.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.4.1 src/sys/dev/spi/spivar.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/dev/spi/spivar.h
diff -u src/sys/dev/spi/spivar.h:1.12 src/sys/dev/spi/spivar.h:1.12.4.1
--- src/sys/dev/spi/spivar.h:1.12	Wed Jan 19 13:33:11 2022
+++ src/sys/dev/spi/spivar.h	Wed Sep 11 16:42:34 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: spivar.h,v 1.12 2022/01/19 13:33:11 thorpej Exp $ */
+/* $NetBSD: spivar.h,v 1.12.4.1 2024/09/11 16:42:34 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -55,16 +55,24 @@
 struct spi_handle;
 struct spi_transfer;
 
+#define	SPI_MODE_CPHA	__BIT(0)
+#define	SPI_MODE_CPOL	__BIT(1)
+
 /*
  * De facto standard latching modes.
  */
-#define	SPI_MODE_0	0	/* CPOL = 0, CPHA = 0 */
-#define	SPI_MODE_1	1	/* CPOL = 0, CPHA = 1 */
-#define	SPI_MODE_2	2	/* CPOL = 1, CPHA = 0 */
-#define	SPI_MODE_3	3	/* CPOL = 1, CPHA = 1 */
+#define	SPI_MODE_0	0
+#define	SPI_MODE_1	SPI_MODE_CPHA
+#define	SPI_MODE_2	SPI_MODE_CPOL
+#define	SPI_MODE_3	(SPI_MODE_CPHA | SPI_MODE_CPOL)
+
 /* Philips' Microwire is just Mode 0 */
 #define	SPI_MODE_MICROWIRE	SPI_MODE_0
 
+/* SPI transfer speed helper macros -- converts to Hz for spi_configure(). */
+#define	SPI_FREQ_kHz(x)	((x) * 1000)
+#define	SPI_FREQ_MHz(x)	((x) * 100)
+
 struct spi_controller {
 	void	*sct_cookie;	/* controller private data */
 	int	sct_nslaves;



CVS commit: [netbsd-10] src/sys/dev/spi

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:42:34 UTC 2024

Modified Files:
src/sys/dev/spi [netbsd-10]: spivar.h

Log Message:
Pull up following revision(s) (requested by rin in ticket #836):

sys/dev/spi/spivar.h: revision 1.13

Define mode macros for CPOL and CPHA, and define SPI_MODE_* in terms
of CPOL and CPHA.  Add SPI_FREQ_*() helper macros to make setting the
transfer frequency less error prone.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.4.1 src/sys/dev/spi/spivar.h

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



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

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:32:56 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: intr.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #832):

sys/arch/x86/x86/intr.c: revision 1.166

Fix use-after-free (source->is_type) when detecting unsharable
interrupts. Doesn't solve the interrupt conflict itself, but
avoids a panic.


To generate a diff of this commit:
cvs rdiff -u -r1.163.2.2 -r1.163.2.3 src/sys/arch/x86/x86/intr.c

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



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

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:32:56 UTC 2024

Modified Files:
src/sys/arch/x86/x86 [netbsd-10]: intr.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #832):

sys/arch/x86/x86/intr.c: revision 1.166

Fix use-after-free (source->is_type) when detecting unsharable
interrupts. Doesn't solve the interrupt conflict itself, but
avoids a panic.


To generate a diff of this commit:
cvs rdiff -u -r1.163.2.2 -r1.163.2.3 src/sys/arch/x86/x86/intr.c

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

Modified files:

Index: src/sys/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.163.2.2 src/sys/arch/x86/x86/intr.c:1.163.2.3
--- src/sys/arch/x86/x86/intr.c:1.163.2.2	Wed Sep 11 10:09:19 2024
+++ src/sys/arch/x86/x86/intr.c	Wed Sep 11 16:32:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.163.2.2 2024/09/11 10:09:19 martin Exp $	*/
+/*	$NetBSD: intr.c,v 1.163.2.3 2024/09/11 16:32:56 martin Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.163.2.2 2024/09/11 10:09:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.163.2.3 2024/09/11 16:32:56 martin Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -911,6 +911,8 @@ intr_establish_xname(int legacy_irq, str
 		/* FALLTHROUGH */
 	case IST_PULSE:
 		if (type != IST_NONE) {
+			int otype = source->is_type;
+
 			intr_source_free(ci, slot, pic, idt_vec);
 			intr_free_io_intrsource_direct(chained);
 			mutex_exit(&cpu_lock);
@@ -918,7 +920,7 @@ intr_establish_xname(int legacy_irq, str
 			printf("%s: pic %s pin %d: can't share "
 			   "type %d with %d\n",
 __func__, pic->pic_name, pin,
-source->is_type, type);
+otype, type);
 			return NULL;
 		}
 		break;



CVS commit: [netbsd-10] src/sys/kern

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:29:26 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: sys_eventfd.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #831):

sys/kern/sys_eventfd.c: revision 1.11

eventfd(2): Prune dead branch.

Fallout from PR kern/57703 fix.


To generate a diff of this commit:
cvs rdiff -u -r1.9.4.1 -r1.9.4.2 src/sys/kern/sys_eventfd.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/sys_eventfd.c
diff -u src/sys/kern/sys_eventfd.c:1.9.4.1 src/sys/kern/sys_eventfd.c:1.9.4.2
--- src/sys/kern/sys_eventfd.c:1.9.4.1	Sun Nov 26 12:33:19 2023
+++ src/sys/kern/sys_eventfd.c	Wed Sep 11 16:29:26 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_eventfd.c,v 1.9.4.1 2023/11/26 12:33:19 bouyer Exp $	*/
+/*	$NetBSD: sys_eventfd.c,v 1.9.4.2 2024/09/11 16:29:26 martin Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_eventfd.c,v 1.9.4.1 2023/11/26 12:33:19 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_eventfd.c,v 1.9.4.2 2024/09/11 16:29:26 martin Exp $");
 
 /*
  * eventfd
@@ -196,9 +196,7 @@ eventfd_wake(struct eventfd * const efd,
 		sel = &efd->efd_write_sel;
 		pollev = POLLOUT | POLLWRNORM;
 	}
-	if (waitcv != NULL) {
-		cv_broadcast(waitcv);
-	}
+	cv_broadcast(waitcv);
 	selnotify(sel, pollev, NOTE_SUBMIT);
 }
 



CVS commit: [netbsd-10] src/sys/kern

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:29:26 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: sys_eventfd.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #831):

sys/kern/sys_eventfd.c: revision 1.11

eventfd(2): Prune dead branch.

Fallout from PR kern/57703 fix.


To generate a diff of this commit:
cvs rdiff -u -r1.9.4.1 -r1.9.4.2 src/sys/kern/sys_eventfd.c

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



CVS commit: [netbsd-10] src/sys/kern

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:26:58 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: uipc_socket.c uipc_syscalls.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #830):

sys/kern/uipc_socket.c: revision 1.304
sys/kern/uipc_syscalls.c: revision 1.207

Fix a ~16 year old perf regression: when creating a socket, add a reference
to the caller's credentials rather than copying them.  On an 80486DX2/66 this
seems to ~halve the time taken to create a socket.

Fix a ~16 year old perf regression: when accepting a connection, add a
reference to the caller's credentials rather than copying them.


To generate a diff of this commit:
cvs rdiff -u -r1.302.4.2 -r1.302.4.3 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.206.4.1 -r1.206.4.2 src/sys/kern/uipc_syscalls.c

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



CVS commit: [netbsd-10] src/sys/kern

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:26:58 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: uipc_socket.c uipc_syscalls.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #830):

sys/kern/uipc_socket.c: revision 1.304
sys/kern/uipc_syscalls.c: revision 1.207

Fix a ~16 year old perf regression: when creating a socket, add a reference
to the caller's credentials rather than copying them.  On an 80486DX2/66 this
seems to ~halve the time taken to create a socket.

Fix a ~16 year old perf regression: when accepting a connection, add a
reference to the caller's credentials rather than copying them.


To generate a diff of this commit:
cvs rdiff -u -r1.302.4.2 -r1.302.4.3 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.206.4.1 -r1.206.4.2 src/sys/kern/uipc_syscalls.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/uipc_socket.c
diff -u src/sys/kern/uipc_socket.c:1.302.4.2 src/sys/kern/uipc_socket.c:1.302.4.3
--- src/sys/kern/uipc_socket.c:1.302.4.2	Sat Jul 20 14:37:05 2024
+++ src/sys/kern/uipc_socket.c	Wed Sep 11 16:26:57 2024
@@ -1,7 +1,7 @@
-/*	$NetBSD: uipc_socket.c,v 1.302.4.2 2024/07/20 14:37:05 martin Exp $	*/
+/*	$NetBSD: uipc_socket.c,v 1.302.4.3 2024/09/11 16:26:57 martin Exp $	*/
 
 /*
- * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 2002, 2007, 2008, 2009, 2023 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.302.4.2 2024/07/20 14:37:05 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.302.4.3 2024/09/11 16:26:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -560,7 +560,7 @@ socreate(int dom, struct socket **aso, i
 		sofree(so);
 		return error;
 	}
-	so->so_cred = kauth_cred_dup(l->l_cred);
+	kauth_cred_hold(so->so_cred = l->l_cred);
 	sounlock(so);
 
 	*aso = so;

Index: src/sys/kern/uipc_syscalls.c
diff -u src/sys/kern/uipc_syscalls.c:1.206.4.1 src/sys/kern/uipc_syscalls.c:1.206.4.2
--- src/sys/kern/uipc_syscalls.c:1.206.4.1	Sun Feb  4 11:20:15 2024
+++ src/sys/kern/uipc_syscalls.c	Wed Sep 11 16:26:57 2024
@@ -1,7 +1,7 @@
-/*	$NetBSD: uipc_syscalls.c,v 1.206.4.1 2024/02/04 11:20:15 martin Exp $	*/
+/*	$NetBSD: uipc_syscalls.c,v 1.206.4.2 2024/09/11 16:26:57 martin Exp $	*/
 
 /*-
- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2009, 2023 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.206.4.1 2024/02/04 11:20:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.206.4.2 2024/09/11 16:26:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pipe.h"
@@ -244,7 +244,7 @@ do_sys_accept(struct lwp *l, int sock, s
 	else
 		so2->so_state &= ~SS_NBIO;
 	error = soaccept(so2, name);
-	so2->so_cred = kauth_cred_dup(so->so_cred);
+	kauth_cred_hold(so2->so_cred = so->so_cred);
 	sounlock(so);
 	if (error) {
 		/* an error occurred, free the file descriptor and mbuf */
@@ -1675,7 +1675,7 @@ do_sys_peeloff(struct socket *head, void
 	so->so_state &= ~SS_NOFDREF;
 	so->so_state &= ~SS_ISCONNECTING;
 	so->so_head = NULL;
-	so->so_cred = kauth_cred_dup(head->so_cred);
+	kauth_cred_hold(so->so_cred = head->so_cred);
 	nfp->f_socket = so;
 	nfp->f_flag = FREAD|FWRITE;
 	nfp->f_ops = &socketops;



CVS commit: [netbsd-10] src/sys/kern

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:24:05 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: subr_localcount.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #829):

sys/kern/subr_localcount.c: revision 1.8

localcount: Update per-CPU total at splhigh.

Otherwise localcount_acquire/release in interrupt context may lose
counts.

Duration spent at splhigh is very short.
PR kern/58610: localcount(9) races with interrupts


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.36.1 src/sys/kern/subr_localcount.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_localcount.c
diff -u src/sys/kern/subr_localcount.c:1.7 src/sys/kern/subr_localcount.c:1.7.36.1
--- src/sys/kern/subr_localcount.c:1.7	Fri Nov 17 09:26:36 2017
+++ src/sys/kern/subr_localcount.c	Wed Sep 11 16:24:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_localcount.c,v 1.7 2017/11/17 09:26:36 ozaki-r Exp $	*/
+/*	$NetBSD: subr_localcount.c,v 1.7.36.1 2024/09/11 16:24:05 martin Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_localcount.c,v 1.7 2017/11/17 09:26:36 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_localcount.c,v 1.7.36.1 2024/09/11 16:24:05 martin Exp $");
 
 #include 
 #include 
@@ -161,11 +161,14 @@ localcount_xc(void *cookie0, void *cooki
 	struct localcount *lc = cookie0;
 	kmutex_t *interlock = cookie1;
 	int64_t *localp;
+	int s;
 
 	mutex_enter(interlock);
 	localp = percpu_getref(lc->lc_percpu);
+	s = splhigh();
 	*lc->lc_totalp += *localp;
 	*localp -= *localp;		/* ie, *localp = 0; */
+	splx(s);
 	percpu_putref(lc->lc_percpu);
 	mutex_exit(interlock);
 }
@@ -180,9 +183,12 @@ static void
 localcount_adjust(struct localcount *lc, int delta)
 {
 	int64_t *localp;
+	int s;
 
 	localp = percpu_getref(lc->lc_percpu);
+	s = splhigh();
 	*localp += delta;
+	splx(s);
 	percpu_putref(lc->lc_percpu);
 }
 



CVS commit: [netbsd-10] src/sys/kern

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:24:05 UTC 2024

Modified Files:
src/sys/kern [netbsd-10]: subr_localcount.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #829):

sys/kern/subr_localcount.c: revision 1.8

localcount: Update per-CPU total at splhigh.

Otherwise localcount_acquire/release in interrupt context may lose
counts.

Duration spent at splhigh is very short.
PR kern/58610: localcount(9) races with interrupts


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.36.1 src/sys/kern/subr_localcount.c

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



CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:21:07 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: if_cdce.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #828):

sys/dev/usb/if_cdce.c: revision 1.82

There is no link state for CDCE. Pretend that the link is always up so that
programs like dhcpcd will handle the interface.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.81.4.1 src/sys/dev/usb/if_cdce.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/if_cdce.c
diff -u src/sys/dev/usb/if_cdce.c:1.81 src/sys/dev/usb/if_cdce.c:1.81.4.1
--- src/sys/dev/usb/if_cdce.c:1.81	Thu Mar  3 05:56:28 2022
+++ src/sys/dev/usb/if_cdce.c	Wed Sep 11 16:21:07 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cdce.c,v 1.81 2022/03/03 05:56:28 riastradh Exp $ */
+/*	$NetBSD: if_cdce.c,v 1.81.4.1 2024/09/11 16:21:07 martin Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul 
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.81 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.81.4.1 2024/09/11 16:21:07 martin Exp $");
 
 #include 
 
@@ -251,6 +251,9 @@ cdce_attach(device_t parent, device_t se
 	usbnet_attach(un);
 	usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
 0, NULL);
+
+	/* XXX There is no link state, pretend we are always on */
+	if_link_state_change(usbnet_ifp(un), LINK_STATE_UP);
 }
 
 static void



CVS commit: [netbsd-10] src/sys/dev/usb

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:21:07 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: if_cdce.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #828):

sys/dev/usb/if_cdce.c: revision 1.82

There is no link state for CDCE. Pretend that the link is always up so that
programs like dhcpcd will handle the interface.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.81.4.1 src/sys/dev/usb/if_cdce.c

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



CVS commit: [netbsd-10] src/sys/net

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:18:36 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: nd.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #827):

sys/net/nd.c: revision 1.6
sys/net/nd.c: revision 1.7

nd_resolve: Maintain la_numheld.

Otherwise lltable_drop_entry_queue never drops anything.

Addresses mbuf leak, PR kern/58297.

nd_timer: Update la_numheld when we clear la_hold (a.k.a. ln_hold).

Followup for PR kern/58297 fix.  Patch by mlelstv@.
PR kern/58301


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.2.1 src/sys/net/nd.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/net/nd.c
diff -u src/sys/net/nd.c:1.5 src/sys/net/nd.c:1.5.2.1
--- src/sys/net/nd.c:1.5	Sat Nov 19 08:00:51 2022
+++ src/sys/net/nd.c	Wed Sep 11 16:18:36 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd.c,v 1.5 2022/11/19 08:00:51 yamt Exp $	*/
+/*	$NetBSD: nd.c,v 1.5.2.1 2024/09/11 16:18:36 martin Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd.c,v 1.5 2022/11/19 08:00:51 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd.c,v 1.5.2.1 2024/09/11 16:18:36 martin Exp $");
 
 #include 
 #include 
@@ -105,8 +105,12 @@ nd_timer(void *arg)
 
 			m->m_nextpkt = NULL;
 			ln->ln_hold = NULL;
+			ln->la_numheld = 0;
 		}
 
+		KASSERTMSG(ln->la_numheld == 0, "la_numheld=%d",
+		ln->la_numheld);
+
 		missed = ND_LLINFO_INCOMPLETE;
 		ln->ln_state = ND_LLINFO_WAITDELETE;
 		break;
@@ -374,14 +378,25 @@ nd_resolve(struct llentry *ln, const str
 break;
 			}
 		}
+		KASSERTMSG(ln->la_numheld == i, "la_numheld=%d i=%d",
+		ln->la_numheld, i);
 		while (i >= nd->nd_maxqueuelen) {
 			m_hold = ln->ln_hold;
 			ln->ln_hold = ln->ln_hold->m_nextpkt;
 			m_freem(m_hold);
 			i--;
+			ln->la_numheld--;
 		}
-	} else
+	} else {
+		KASSERTMSG(ln->la_numheld == 0, "la_numheld=%d",
+		ln->la_numheld);
 		ln->ln_hold = m;
+	}
+
+	KASSERTMSG(ln->la_numheld < nd->nd_maxqueuelen,
+	"la_numheld=%d nd_maxqueuelen=%d",
+	ln->la_numheld, nd->nd_maxqueuelen);
+	ln->la_numheld++;
 
 	if (ln->ln_asked >= nd->nd_mmaxtries)
 		error = (rt != NULL && rt->rt_flags & RTF_GATEWAY) ?



CVS commit: [netbsd-10] src/sys/net

2024-09-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 11 16:18:36 UTC 2024

Modified Files:
src/sys/net [netbsd-10]: nd.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #827):

sys/net/nd.c: revision 1.6
sys/net/nd.c: revision 1.7

nd_resolve: Maintain la_numheld.

Otherwise lltable_drop_entry_queue never drops anything.

Addresses mbuf leak, PR kern/58297.

nd_timer: Update la_numheld when we clear la_hold (a.k.a. ln_hold).

Followup for PR kern/58297 fix.  Patch by mlelstv@.
PR kern/58301


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.2.1 src/sys/net/nd.c

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



  1   2   3   4   5   6   7   8   9   10   >