CVS commit: src/sys/arch/mips/mips

2020-03-09 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar 10 04:04:45 UTC 2020

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

Log Message:
Comment out the diagnostic message in the TLB_MOD handler that's logged if
pmap_tlb_update_addr() indicates that the VA+ASID was not found in the TLB.
It's a harmless race condition that can happen for legitimate reasons (e.g.
a TLB miss in an interrupt handler that evicts the entry from the TLB).

See discussion:
http://mail-index.netbsd.org/port-mips/2020/03/07/msg000927.html


To generate a diff of this commit:
cvs rdiff -u -r1.250 -r1.251 src/sys/arch/mips/mips/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/mips/mips/trap.c
diff -u src/sys/arch/mips/mips/trap.c:1.250 src/sys/arch/mips/mips/trap.c:1.251
--- src/sys/arch/mips/mips/trap.c:1.250	Sat Mar  7 18:49:49 2020
+++ src/sys/arch/mips/mips/trap.c	Tue Mar 10 04:04:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.250 2020/03/07 18:49:49 thorpej Exp $	*/
+/*	$NetBSD: trap.c,v 1.251 2020/03/10 04:04:45 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.250 2020/03/07 18:49:49 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.251 2020/03/10 04:04:45 thorpej Exp $");
 
 #include "opt_cputype.h"	/* which mips CPU levels do we support? */
 #include "opt_ddb.h"
@@ -296,10 +296,20 @@ trap(uint32_t status, uint32_t cause, va
 		vaddr = trunc_page(vaddr);
 		int ok = pmap_tlb_update_addr(pmap, vaddr, pte, 0);
 		kpreempt_enable();
-		if (ok != 1)
+		if (ok != 1) {
+#if 0 /* PMAP_FAULTINFO? */
+			/*
+			 * Since we don't block interrupts here,
+			 * this can legitimately happen if we get
+			 * a TLB miss that's serviced in an interrupt
+			 * hander that happens to randomly evict the
+			 * TLB entry we're concerned about.
+			 */
 			printf("pmap_tlb_update_addr(%p,%#"
 			PRIxVADDR",%#"PRIxPTE", 0) returned %d\n",
 			pmap, vaddr, pte_value(pte), ok);
+#endif
+		}
 		paddr_t pa = pte_to_paddr(pte);
 		KASSERTMSG(uvm_pageismanaged(pa),
 		"%#"PRIxVADDR" pa %#"PRIxPADDR, vaddr, pa);



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

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 10 03:49:56 UTC 2020

Modified Files:
src/sys/arch/sparc64/include: cpu.h

Log Message:
kill extra curproc/curlwp definitions that have no chance of working.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/arch/sparc64/include/cpu.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/sparc64/include/cpu.h
diff -u src/sys/arch/sparc64/include/cpu.h:1.129 src/sys/arch/sparc64/include/cpu.h:1.130
--- src/sys/arch/sparc64/include/cpu.h:1.129	Sun Dec 29 16:09:27 2019
+++ src/sys/arch/sparc64/include/cpu.h	Mon Mar  9 23:49:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.129 2019/12/29 21:09:27 martin Exp $ */
+/*	$NetBSD: cpu.h,v 1.130 2020/03/10 03:49:56 christos Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -457,15 +457,5 @@ void kgdb_panic(void);
 int	fixalign(struct lwp *, struct trapframe64 *);
 int	emulinstr(vaddr_t, struct trapframe64 *);
 
-#else /* _KERNEL */
-
-/*
- * XXX: provide some definitions for crash(8), probably can share
- */
-#if defined(_KMEMUSER)
-#define	curcpu()	(((struct cpu_info *)CPUINFO_VA)->ci_self)
-#define curlwp		curcpu()->ci_curlwp
-#endif
-
 #endif /* _KERNEL */
 #endif /* _CPU_H_ */



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

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 10 03:48:05 UTC 2020

Modified Files:
src/sys/arch/sparc/include: cpu.h

Log Message:
tuck curproc/curlwp under _KERNEL only (no _KMEMUSER)


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/sparc/include/cpu.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/sparc/include/cpu.h
diff -u src/sys/arch/sparc/include/cpu.h:1.104 src/sys/arch/sparc/include/cpu.h:1.105
--- src/sys/arch/sparc/include/cpu.h:1.104	Mon Dec 30 17:13:47 2019
+++ src/sys/arch/sparc/include/cpu.h	Mon Mar  9 23:48:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.104 2019/12/30 22:13:47 ad Exp $ */
+/*	$NetBSD: cpu.h,v 1.105 2020/03/10 03:48:05 christos Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -397,6 +397,11 @@ struct cpu_info {
 	struct evcnt ci_sintrcnt[16];
 };
 
+#endif /* _KERNEL || _KMEMUSER */
+
+/* Kernel only things. */
+#if defined(_KERNEL)
+
 /*
  * definitions of cpu-dependent requirements
  * referenced in generic code
@@ -408,10 +413,6 @@ struct cpu_info {
 
 #define	cpu_number()		(cpuinfo.ci_cpuid)
 
-#endif /* _KERNEL || _KMEMUSER */
-
-/* Kernel only things. */
-#if defined(_KERNEL)
 void	cpu_proc_fork(struct proc *, struct proc *);
 
 #if defined(MULTIPROCESSOR)



CVS commit: src/sys/dev/pci

2020-03-09 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar 10 01:23:42 UTC 2020

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

Log Message:
On NetBSD it's spelled "__NO_STRICT_ALIGNMENT".  Adjust txp_rx_reclaim()
accordingly and structure it like other NetBSD drivers so as to re-use
the original Rx buffer rather than doing a needless free/alloc cycle.

Note this happened to work previously on my Qube2 because IP, TCP, etc.
perform their own alignment checks and react accordingly.  However, it's
not clear that ALL protocols do this yet, so it's better to just do the
safe thing for now.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pci/if_txp.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_txp.c
diff -u src/sys/dev/pci/if_txp.c:1.72 src/sys/dev/pci/if_txp.c:1.73
--- src/sys/dev/pci/if_txp.c:1.72	Tue Mar 10 00:26:47 2020
+++ src/sys/dev/pci/if_txp.c	Tue Mar 10 01:23:42 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_txp.c,v 1.72 2020/03/10 00:26:47 thorpej Exp $ */
+/* $NetBSD: if_txp.c,v 1.73 2020/03/10 01:23:42 thorpej Exp $ */
 
 /*
  * Copyright (c) 2001
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.72 2020/03/10 00:26:47 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.73 2020/03/10 01:23:42 thorpej Exp $");
 
 #include "opt_inet.h"
 
@@ -714,6 +714,7 @@ txp_rx_reclaim(struct txp_softc *sc, str
 	struct mbuf *m;
 	struct txp_swdesc *sd;
 	uint32_t roff, woff;
+	uint16_t len;
 	int sumflags = 0;
 	int idx;
 
@@ -741,44 +742,43 @@ txp_rx_reclaim(struct txp_softc *sc, str
 
 		bus_dmamap_sync(sc->sc_dmat, sd->sd_map, 0,
 		sd->sd_map->dm_mapsize, BUS_DMASYNC_POSTREAD);
+
+		len = le16toh(rxd->rx_len);
+
+#ifdef __NO_STRICT_ALIGNMENT
 		bus_dmamap_unload(sc->sc_dmat, sd->sd_map);
 		m = sd->sd_mbuf;
 		sd->sd_mbuf = NULL;
 		txp_rxd_free(sc, sd);
-		m->m_pkthdr.len = m->m_len = le16toh(rxd->rx_len);
-
-#ifdef __STRICT_ALIGNMENT
-		{
-			/*
-			 * XXX Nice chip, except it won't accept "off by 2"
-			 * buffers, so we're force to copy.  Supposedly
-			 * this will be fixed in a newer firmware rev
-			 * and this will be temporary.
-			 */
-			struct mbuf *mnew;
-
-			MGETHDR(mnew, M_DONTWAIT, MT_DATA);
-			if (mnew == NULL) {
+#else
+		/*
+		 * The Typhoon's receive buffers must be 4-byte aligned.
+		 * But this means the data after the Ethernet header
+		 * is misaligned.  We must allocate a new buffer and
+		 * copy the data, shifted forward 2 bytes.
+		 */
+		MGETHDR(m, M_DONTWAIT, MT_DATA);
+		if (m == NULL) {
+ dropit:
+			if_statinc(ifp, if_ierrors);
+			txp_rxd_free(sc, sd);
+			goto next;
+		}
+		MCLAIM(m, >sc_arpcom.ec_rx_mowner);
+		if (len > (MHLEN - ETHER_ALIGN)) {
+			MCLGET(m, M_DONTWAIT);
+			if ((m->m_flags & M_EXT) == 0) {
 m_freem(m);
-goto next;
+goto dropit;
 			}
-			MCLAIM(mnew, >sc_arpcom.ec_rx_mowner);
-			if (m->m_len > (MHLEN - 2)) {
-MCLGET(mnew, M_DONTWAIT);
-if (!(mnew->m_flags & M_EXT)) {
-	m_freem(mnew);
-	m_freem(m);
-	goto next;
-}
-			}
-			m_set_rcvif(mnew, ifp);
-			mnew->m_pkthdr.len = mnew->m_len = m->m_len;
-			mnew->m_data += 2;
-			memcpy(mnew->m_data, m->m_data, m->m_len);
-			m_freem(m);
-			m = mnew;
 		}
-#endif
+		m_set_rcvif(m, ifp);
+		m->m_data += ETHER_ALIGN;
+		memcpy(mtod(m, void *), mtod(sd->sd_mbuf, void *), len);
+		txp_rxd_free(sc, sd);
+#endif /* __NO_STRICT_ALIGNMENT */
+
+		m->m_pkthdr.len = m->m_len = len;
 
 		if (rxd->rx_stat & htole32(RX_STAT_IPCKSUMBAD))
 			sumflags |= (M_CSUM_IPv4 | M_CSUM_IPv4_BAD);
@@ -845,19 +845,23 @@ txp_rxbuf_reclaim(struct txp_softc *sc)
 		if (sd == NULL)
 			break;
 
-		MGETHDR(sd->sd_mbuf, M_DONTWAIT, MT_DATA);
-		if (sd->sd_mbuf == NULL)
-			goto err_sd;
-		MCLAIM(sd->sd_mbuf, >sc_arpcom.ec_rx_mowner);
-
-		MCLGET(sd->sd_mbuf, M_DONTWAIT);
-		if ((sd->sd_mbuf->m_flags & M_EXT) == 0)
-			goto err_mbuf;
-		m_set_rcvif(sd->sd_mbuf, ifp);
-		sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES;
-		if (bus_dmamap_load_mbuf(sc->sc_dmat, sd->sd_map, sd->sd_mbuf,
-		BUS_DMA_NOWAIT)) {
-			goto err_mbuf;
+		/* We might already have a buffer allocated. */
+		if (sd->sd_mbuf == NULL) {
+			MGETHDR(sd->sd_mbuf, M_DONTWAIT, MT_DATA);
+			if (sd->sd_mbuf == NULL)
+goto err_sd;
+			MCLAIM(sd->sd_mbuf, >sc_arpcom.ec_rx_mowner);
+
+			MCLGET(sd->sd_mbuf, M_DONTWAIT);
+			if ((sd->sd_mbuf->m_flags & M_EXT) == 0)
+goto err_mbuf;
+			m_set_rcvif(sd->sd_mbuf, ifp);
+			sd->sd_mbuf->m_pkthdr.len =
+			sd->sd_mbuf->m_len = MCLBYTES;
+			if (bus_dmamap_load_mbuf(sc->sc_dmat, sd->sd_map,
+			sd->sd_mbuf, BUS_DMA_NOWAIT)) {
+goto err_mbuf;
+			}
 		}
 
 		bus_dmamap_sync(sc->sc_dmat, sc->sc_rxbufring_dma.dma_map,



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

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 10 01:17:34 UTC 2020

Modified Files:
src/sys/arch/aarch64/include: cpu.h

Log Message:
protect curcpu/curlwp from _KMEMUSER


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/aarch64/include/cpu.h

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

Modified files:

Index: src/sys/arch/aarch64/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.21 src/sys/arch/aarch64/include/cpu.h:1.22
--- src/sys/arch/aarch64/include/cpu.h:1.21	Sat Feb 15 03:16:10 2020
+++ src/sys/arch/aarch64/include/cpu.h	Mon Mar  9 21:17:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.21 2020/02/15 08:16:10 skrll Exp $ */
+/* $NetBSD: cpu.h,v 1.22 2020/03/10 01:17:33 christos Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -112,6 +112,7 @@ struct cpu_info {
 
 } __aligned(COHERENCY_UNIT);
 
+#ifdef _KERNEL
 static inline struct cpu_info *
 curcpu(void)
 {
@@ -159,6 +160,8 @@ cpu_dosoftints(void)
 #endif
 }
 
+#endif /* _KERNEL */
+
 #endif /* _KERNEL || _KMEMUSER */
 
 #endif



CVS commit: src/sys/dev/pci

2020-03-09 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar 10 00:26:47 UTC 2020

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

Log Message:
- Add support for MBUFTRACE.
- Fix an mbuf leak I introduced in rev 1.68 (failed to increment "cnt"
  variable in txp_start(), which subsequently caused txp_tx_reclaim()
  to never run).
- Use the context address pointer in the Tx descriptor to stash the
  pointer to the Tx job software state in a manner like that which
  is used for Rx software state.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/pci/if_txp.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_txp.c
diff -u src/sys/dev/pci/if_txp.c:1.71 src/sys/dev/pci/if_txp.c:1.72
--- src/sys/dev/pci/if_txp.c:1.71	Mon Mar  9 01:55:16 2020
+++ src/sys/dev/pci/if_txp.c	Tue Mar 10 00:26:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_txp.c,v 1.71 2020/03/09 01:55:16 thorpej Exp $ */
+/* $NetBSD: if_txp.c,v 1.72 2020/03/10 00:26:47 thorpej Exp $ */
 
 /*
  * Copyright (c) 2001
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.71 2020/03/09 01:55:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.72 2020/03/10 00:26:47 thorpej Exp $");
 
 #include "opt_inet.h"
 
@@ -343,6 +343,19 @@ txp_attach(device_t parent, device_t sel
 	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, enaddr);
 
+	/*
+	 * XXX Because we allocate Rx buffers in txp_alloc_rings(),
+	 * XXX we have to go back and claim them now that our mowners
+	 * XXX have been initialized (in ether_ifattach()).
+	 *
+	 * XXX FIXME by allocating Rx buffers only when interface is
+	 * XXX running, like other drivers do.
+	 */
+	for (i = 0; i < RXBUF_ENTRIES; i++) {
+		KASSERT(sc->sc_rxd[i].sd_mbuf != NULL);
+		MCLAIM(sc->sc_rxd[i].sd_mbuf, >sc_arpcom.ec_rx_mowner);
+	}
+
 	if (pmf_device_register1(self, NULL, NULL, txp_shutdown))
 		pmf_class_network_register(self, ifp);
 	else
@@ -685,6 +698,13 @@ txp_rxd_idx(struct txp_softc *sc, struct
 	return (uint32_t)(sd - >sc_rxd[0]);
 }
 
+static inline uint32_t
+txp_txd_idx(struct txp_softc *sc, struct txp_swdesc *sd)
+{
+	KASSERT(sd >= >sc_txd[0] && sd < >sc_txd[TX_ENTRIES]);
+	return (uint32_t)(sd - >sc_txd[0]);
+}
+
 static void
 txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r,
 struct txp_dma_alloc *dma)
@@ -723,6 +743,7 @@ txp_rx_reclaim(struct txp_softc *sc, str
 		sd->sd_map->dm_mapsize, BUS_DMASYNC_POSTREAD);
 		bus_dmamap_unload(sc->sc_dmat, sd->sd_map);
 		m = sd->sd_mbuf;
+		sd->sd_mbuf = NULL;
 		txp_rxd_free(sc, sd);
 		m->m_pkthdr.len = m->m_len = le16toh(rxd->rx_len);
 
@@ -741,6 +762,7 @@ txp_rx_reclaim(struct txp_softc *sc, str
 m_freem(m);
 goto next;
 			}
+			MCLAIM(mnew, >sc_arpcom.ec_rx_mowner);
 			if (m->m_len > (MHLEN - 2)) {
 MCLGET(mnew, M_DONTWAIT);
 if (!(mnew->m_flags & M_EXT)) {
@@ -826,6 +848,7 @@ txp_rxbuf_reclaim(struct txp_softc *sc)
 		MGETHDR(sd->sd_mbuf, M_DONTWAIT, MT_DATA);
 		if (sd->sd_mbuf == NULL)
 			goto err_sd;
+		MCLAIM(sd->sd_mbuf, >sc_arpcom.ec_rx_mowner);
 
 		MCLGET(sd->sd_mbuf, M_DONTWAIT);
 		if ((sd->sd_mbuf->m_flags & M_EXT) == 0)
@@ -868,6 +891,7 @@ txp_rxbuf_reclaim(struct txp_softc *sc)
 
 err_mbuf:
 	m_freem(sd->sd_mbuf);
+	sd->sd_mbuf = NULL;
 err_sd:
 	txp_rxd_free(sc, sd);
 }
@@ -883,7 +907,7 @@ txp_tx_reclaim(struct txp_softc *sc, str
 	uint32_t idx = TXP_OFFSET2IDX(le32toh(*(r->r_off)));
 	uint32_t cons = r->r_cons, cnt = r->r_cnt;
 	struct txp_tx_desc *txd = r->r_desc + cons;
-	struct txp_swdesc *sd = sc->sc_txd + cons;
+	struct txp_swdesc *sd;
 	struct mbuf *m;
 
 	while (cons != idx) {
@@ -897,11 +921,15 @@ txp_tx_reclaim(struct txp_softc *sc, str
 
 		if ((txd->tx_flags & TX_FLAGS_TYPE_M) ==
 		TX_FLAGS_TYPE_DATA) {
-			bus_dmamap_sync(sc->sc_dmat, sd->sd_map, 0,
-			sd->sd_map->dm_mapsize, BUS_DMASYNC_POSTWRITE);
-			bus_dmamap_unload(sc->sc_dmat, sd->sd_map);
+			KASSERT(txd->tx_addrlo < TX_ENTRIES);
+			sd = >sc_txd[txd->tx_addrlo];
 			m = sd->sd_mbuf;
+			sd->sd_mbuf = NULL;
 			if (m != NULL) {
+bus_dmamap_sync(sc->sc_dmat, sd->sd_map, 0,
+sd->sd_map->dm_mapsize,
+BUS_DMASYNC_POSTWRITE);
+bus_dmamap_unload(sc->sc_dmat, sd->sd_map);
 m_freem(m);
 txd->tx_addrlo = 0;
 txd->tx_addrhi = 0;
@@ -913,11 +941,8 @@ txp_tx_reclaim(struct txp_softc *sc, str
 		if (++cons == TX_ENTRIES) {
 			txd = r->r_desc;
 			cons = 0;
-			sd = sc->sc_txd;
-		} else {
+		} else
 			txd++;
-			sd++;
-		}
 
 		cnt--;
 	}
@@ -1457,6 +1482,7 @@ txp_start(struct ifnet *ifp)
 device_xname(sc->sc_dev));
 break;
 			}
+			MCLAIM(mnew, >sc_arpcom.ec_tx_mowner);
 			if (m->m_pkthdr.len > MHLEN) {
 MCLGET(mnew, M_DONTWAIT);
 if ((mnew->m_flags & M_EXT) == 0) {
@@ -1496,7 +1522,7 @@ txp_start(struct ifnet *ifp)
 		txdidx = prod;
 		txd->tx_flags = TX_FLAGS_TYPE_DATA;
 		txd->tx_numdesc = 0;
-		

CVS commit: src/sys/dev/pci

2020-03-09 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar 10 00:24:08 UTC 2020

Modified Files:
src/sys/dev/pci: if_txpreg.h

Log Message:
Protect against multiple inclusion.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/if_txpreg.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/pci/if_txpreg.h
diff -u src/sys/dev/pci/if_txpreg.h:1.10 src/sys/dev/pci/if_txpreg.h:1.11
--- src/sys/dev/pci/if_txpreg.h:1.10	Mon Mar  9 00:32:53 2020
+++ src/sys/dev/pci/if_txpreg.h	Tue Mar 10 00:24:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_txpreg.h,v 1.10 2020/03/09 00:32:53 thorpej Exp $ */
+/* $NetBSD: if_txpreg.h,v 1.11 2020/03/10 00:24:08 thorpej Exp $ */
 
 /*
  * Copyright (c) 2001 Aaron Campbell .
@@ -26,6 +26,9 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef _DEV_PCI_IF_TXPREG_H_
+#define	_DEV_PCI_IF_TXPREG_H_
+
 #define	TXP_PCI_LOMEM			0x14	/* pci conf, memory map BAR */
 #define	TXP_PCI_LOIO			0x10	/* pci conf, IO map BAR */
 
@@ -626,3 +629,4 @@ struct txp_fw_section_header {
 #define	READ_REG(sc,reg) \
 bus_space_read_4((sc)->sc_bt, (sc)->sc_bh, reg)
 
+#endif /* _DEV_PCI_IF_TXPREG_H_ */



CVS commit: src/sys

2020-03-09 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Mar  9 21:49:26 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: trap.c
src/sys/compat/netbsd32: netbsd32_mod.c

Log Message:
Rework previous, so that the real syscall code is not invoked from within
the module_hook code.  Otherwise, if the syscall just happens to be exit()
we will exit while still holding a reference to the hook's localcount, and
nothing will ever release that reference.  Attempts to manually unload the
module will hang indefinitely, as will modstat(8).

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.19 -r1.20 src/sys/compat/netbsd32/netbsd32_mod.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/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.126 src/sys/arch/amd64/amd64/trap.c:1.127
--- src/sys/arch/amd64/amd64/trap.c:1.126	Sun Mar  8 00:53:12 2020
+++ src/sys/arch/amd64/amd64/trap.c	Mon Mar  9 21:49:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.126 2020/03/08 00:53:12 pgoyette Exp $	*/
+/*	$NetBSD: trap.c,v 1.127 2020/03/09 21:49:26 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.126 2020/03/08 00:53:12 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.127 2020/03/09 21:49:26 pgoyette Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -348,8 +348,11 @@ trap(struct trapframe *frame)
 
 		MODULE_HOOK_CALL(amd64_oosyscall_hook, (p, frame),
 			ENOSYS, hook_ret);
-		if (hook_ret == 0)
+		if (hook_ret == 0) {
+			/* Do the syscall */
+			p->p_md.md_syscall(frame);
 			goto out;
+		}
 	}
 		/* FALLTHROUGH */
 	case T_TSSFLT|T_USER:

Index: src/sys/compat/netbsd32/netbsd32_mod.c
diff -u src/sys/compat/netbsd32/netbsd32_mod.c:1.19 src/sys/compat/netbsd32/netbsd32_mod.c:1.20
--- src/sys/compat/netbsd32/netbsd32_mod.c:1.19	Mon Mar  9 01:06:34 2020
+++ src/sys/compat/netbsd32/netbsd32_mod.c	Mon Mar  9 21:49:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_mod.c,v 1.19 2020/03/09 01:06:34 pgoyette Exp $	*/
+/*	$NetBSD: netbsd32_mod.c,v 1.20 2020/03/09 21:49:26 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.19 2020/03/09 01:06:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.20 2020/03/09 21:49:26 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -151,9 +151,6 @@ amd64_oosyscall_handle(struct proc *p, s
 		/* Advance past the lcall and save instruction size. */
 		frame->tf_rip += sz;
 		frame->tf_err = sz;
-
-		/* Do the syscall */
-		p->p_md.md_syscall(frame);
 		return 0;
 	} else
 		return EPASSTHROUGH;



CVS commit: src/sys

2020-03-09 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Mar  9 21:20:56 UTC 2020

Modified Files:
src/sys/net: route.h rtsock.c
src/sys/netinet: icmp6.h if_arp.c
src/sys/netinet6: icmp6.c nd6.c nd6_nbr.c

Log Message:
route: RTM_MISS now puts the message source address in RTA_AUTHOR

route(8) also reports this.
A userland app could use this to blacklist nodes who probe for machines
that doesn't exist on a subnet / prefix.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/net/route.h
cvs rdiff -u -r1.254 -r1.255 src/sys/net/rtsock.c
cvs rdiff -u -r1.52 -r1.53 src/sys/netinet/icmp6.h
cvs rdiff -u -r1.293 -r1.294 src/sys/netinet/if_arp.c
cvs rdiff -u -r1.243 -r1.244 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.266 -r1.267 src/sys/netinet6/nd6.c
cvs rdiff -u -r1.176 -r1.177 src/sys/netinet6/nd6_nbr.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/route.h
diff -u src/sys/net/route.h:1.126 src/sys/net/route.h:1.127
--- src/sys/net/route.h:1.126	Sat Feb  8 14:17:30 2020
+++ src/sys/net/route.h	Mon Mar  9 21:20:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.h,v 1.126 2020/02/08 14:17:30 roy Exp $	*/
+/*	$NetBSD: route.h,v 1.127 2020/03/09 21:20:55 roy Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -543,8 +543,8 @@ void	rt_addrmsg_rt(int, struct ifaddr *,
 void	route_enqueue(struct mbuf *, int);
 
 struct llentry;
-void	rt_clonedmsg(int, const struct sockaddr *, const uint8_t *,
-const struct ifnet *);
+void	rt_clonedmsg(int, const struct sockaddr *, const struct sockaddr *,
+	const uint8_t *, const struct ifnet *);
 
 void	rt_setmetrics(void *, struct rtentry *);
 

Index: src/sys/net/rtsock.c
diff -u src/sys/net/rtsock.c:1.254 src/sys/net/rtsock.c:1.255
--- src/sys/net/rtsock.c:1.254	Mon Feb  3 20:34:13 2020
+++ src/sys/net/rtsock.c	Mon Mar  9 21:20:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock.c,v 1.254 2020/02/03 20:34:13 roy Exp $	*/
+/*	$NetBSD: rtsock.c,v 1.255 2020/03/09 21:20:55 roy Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.254 2020/02/03 20:34:13 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.255 2020/03/09 21:20:55 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -145,8 +145,8 @@ if_addrflags(struct ifaddr *ifa)
  * Send a routing message as mimicing that a cloned route is added.
  */
 void
-rt_clonedmsg(int type, const struct sockaddr *dst, const uint8_t *lladdr,
-const struct ifnet *ifp)
+rt_clonedmsg(int type, const struct sockaddr *src, const struct sockaddr *dst,
+const uint8_t *lladdr, const struct ifnet *ifp)
 {
 	struct rt_addrinfo info;
 	/* Mimic flags exactly */
@@ -164,6 +164,7 @@ rt_clonedmsg(int type, const struct sock
 	if (type == RTM_ADD || type == RTM_CHANGE)
 		flags |= RTF_UP;
 	memset(, 0, sizeof(info));
+	info.rti_info[RTAX_AUTHOR] = src;
 	info.rti_info[RTAX_DST] = dst;
 	sockaddr_dl_init(, sizeof(u.ss), ifp->if_index, ifp->if_type,
 	NULL, 0, lladdr, ifp->if_addrlen);

Index: src/sys/netinet/icmp6.h
diff -u src/sys/netinet/icmp6.h:1.52 src/sys/netinet/icmp6.h:1.53
--- src/sys/netinet/icmp6.h:1.52	Wed Aug 22 01:05:24 2018
+++ src/sys/netinet/icmp6.h	Mon Mar  9 21:20:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.h,v 1.52 2018/08/22 01:05:24 msaitoh Exp $	*/
+/*	$NetBSD: icmp6.h,v 1.53 2020/03/09 21:20:55 roy Exp $	*/
 /*	$KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $	*/
 
 
@@ -643,7 +643,8 @@ struct	rtentry;
 void	icmp6_init(void);
 void	icmp6_paramerror(struct mbuf *, int);
 void	icmp6_error(struct mbuf *, int, int, int);
-void	icmp6_error2(struct mbuf *, int, int, int, struct ifnet *);
+void	icmp6_error2(struct mbuf *, int, int, int, struct ifnet *,
+	struct in6_addr *);
 int	icmp6_input(struct mbuf **, int *, int);
 void	icmp6_fasttimo(void);
 void	icmp6_prepare(struct mbuf *);

Index: src/sys/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.293 src/sys/netinet/if_arp.c:1.294
--- src/sys/netinet/if_arp.c:1.293	Mon Mar  9 17:57:19 2020
+++ src/sys/netinet/if_arp.c	Mon Mar  9 21:20:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.293 2020/03/09 17:57:19 roy Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.294 2020/03/09 21:20:55 roy Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.293 2020/03/09 17:57:19 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.294 2020/03/09 21:20:55 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -309,20 +309,31 @@ arptimer(void *arg)
 	if (lle->la_flags & LLE_LINKED) {
 		int rt_cmd;
 		struct in_addr *in;
-		struct sockaddr_in sin;
+		struct sockaddr_in dsin, ssin;
+		struct sockaddr *sa;
 		const char *lladdr;
 		size_t pkts_dropped;
 
 		in = >r_l3addr.addr4;
-		sockaddr_in_init(, in, 0);
+		sockaddr_in_init(, in, 0);
 		if 

CVS commit: src/external/bsd/atf

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  9 20:34:52 UTC 2020

Modified Files:
src/external/bsd/atf: Makefile.inc
src/external/bsd/atf/dist/atf-c++: check.cpp check.hpp check_test.cpp
tests.hpp
src/external/bsd/atf/dist/atf-c++/detail: process_test.cpp
src/external/bsd/atf/dist/atf-sh: atf-check.cpp
src/external/bsd/atf/dist/tools: atf-report.cpp atffile_test.cpp fs.hpp
io.hpp parser.hpp process_test.cpp timers.hpp

Log Message:
remove -std=gnu++98


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/atf/Makefile.inc
cvs rdiff -u -r1.1.1.6 -r1.2 src/external/bsd/atf/dist/atf-c++/check.cpp
cvs rdiff -u -r1.1.1.8 -r1.2 src/external/bsd/atf/dist/atf-c++/check.hpp
cvs rdiff -u -r1.1.1.7 -r1.2 src/external/bsd/atf/dist/atf-c++/check_test.cpp
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/atf/dist/atf-c++/tests.hpp
cvs rdiff -u -r1.1.1.3 -r1.2 \
src/external/bsd/atf/dist/atf-c++/detail/process_test.cpp
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/atf/dist/atf-sh/atf-check.cpp
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/atf/dist/tools/atf-report.cpp
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/atf/dist/tools/atffile_test.cpp \
src/external/bsd/atf/dist/tools/fs.hpp \
src/external/bsd/atf/dist/tools/io.hpp \
src/external/bsd/atf/dist/tools/parser.hpp \
src/external/bsd/atf/dist/tools/process_test.cpp \
src/external/bsd/atf/dist/tools/timers.hpp

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

Modified files:

Index: src/external/bsd/atf/Makefile.inc
diff -u src/external/bsd/atf/Makefile.inc:1.6 src/external/bsd/atf/Makefile.inc:1.7
--- src/external/bsd/atf/Makefile.inc:1.6	Sat Feb  3 20:41:05 2018
+++ src/external/bsd/atf/Makefile.inc	Mon Mar  9 16:34:52 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.6 2018/02/04 01:41:05 mrg Exp $
+# $NetBSD: Makefile.inc,v 1.7 2020/03/09 20:34:52 christos Exp $
 
 .include 
 
@@ -41,8 +41,6 @@ CPPFLAGS+=	-I${TOPDIR}			# For bconfig.h
 CPPFLAGS+=	-I${TOPDIR}/lib/libatf-c	# For atf-c/defs.hpp.
 CPPFLAGS+=	-I${SRCDIR}
 
-CXXFLAGS+=	-std=gnu++98
-
 .if defined(USE_ATF_LIBTOOLS)
 LIBTOOLSOBJDIR!=	cd ${TOPDIR}/lib/tools; ${PRINTOBJDIR}
 CPPFLAGS+=		-I${LIBTOOLSOBJDIR}

Index: src/external/bsd/atf/dist/atf-c++/check.cpp
diff -u src/external/bsd/atf/dist/atf-c++/check.cpp:1.1.1.6 src/external/bsd/atf/dist/atf-c++/check.cpp:1.2
--- src/external/bsd/atf/dist/atf-c++/check.cpp:1.1.1.6	Mon Jan 16 17:36:43 2012
+++ src/external/bsd/atf/dist/atf-c++/check.cpp	Mon Mar  9 16:34:52 2020
@@ -145,7 +145,7 @@ impl::build_cxx_o(const std::string& sfi
 return success;
 }
 
-std::auto_ptr< impl::check_result >
+std::unique_ptr< impl::check_result >
 impl::exec(const atf::process::argv_array& argva)
 {
 atf_check_result_t result;
@@ -154,5 +154,5 @@ impl::exec(const atf::process::argv_arra
 if (atf_is_error(err))
 throw_atf_error(err);
 
-return std::auto_ptr< impl::check_result >(new impl::check_result());
+return std::unique_ptr< impl::check_result >(new impl::check_result());
 }

Index: src/external/bsd/atf/dist/atf-c++/check.hpp
diff -u src/external/bsd/atf/dist/atf-c++/check.hpp:1.1.1.8 src/external/bsd/atf/dist/atf-c++/check.hpp:1.2
--- src/external/bsd/atf/dist/atf-c++/check.hpp:1.1.1.8	Sat Feb  8 14:11:31 2014
+++ src/external/bsd/atf/dist/atf-c++/check.hpp	Mon Mar  9 16:34:52 2020
@@ -75,7 +75,7 @@ class check_result {
 check_result(const atf_check_result_t* result);
 
 friend check_result test_constructor(const char* const*);
-friend std::auto_ptr< check_result > exec(const atf::process::argv_array&);
+friend std::unique_ptr< check_result > exec(const atf::process::argv_array&);
 
 public:
 //!
@@ -124,7 +124,7 @@ bool build_cpp(const std::string&, const
const atf::process::argv_array&);
 bool build_cxx_o(const std::string&, const std::string&,
  const atf::process::argv_array&);
-std::auto_ptr< check_result > exec(const atf::process::argv_array&);
+std::unique_ptr< check_result > exec(const atf::process::argv_array&);
 
 // Useful for testing only.
 check_result test_constructor(void);

Index: src/external/bsd/atf/dist/atf-c++/check_test.cpp
diff -u src/external/bsd/atf/dist/atf-c++/check_test.cpp:1.1.1.7 src/external/bsd/atf/dist/atf-c++/check_test.cpp:1.2
--- src/external/bsd/atf/dist/atf-c++/check_test.cpp:1.1.1.7	Sat Feb  8 14:11:31 2014
+++ src/external/bsd/atf/dist/atf-c++/check_test.cpp	Mon Mar  9 16:34:52 2020
@@ -57,7 +57,7 @@ extern "C" {
 // 
 
 static
-std::auto_ptr< atf::check::check_result >
+std::unique_ptr< atf::check::check_result >
 do_exec(const atf::tests::tc* tc, const char* helper_name)
 {
 std::vector< std::string > argv;
@@ -70,7 +70,7 @@ do_exec(const atf::tests::tc* tc, const 
 }
 
 static
-std::auto_ptr< 

CVS commit: src/tests/usr.bin/config

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  9 20:33:16 UTC 2020

Modified Files:
src/tests/usr.bin/config: t_config.sh

Log Message:
update expected result


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/config/t_config.sh

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

Modified files:

Index: src/tests/usr.bin/config/t_config.sh
diff -u src/tests/usr.bin/config/t_config.sh:1.9 src/tests/usr.bin/config/t_config.sh:1.10
--- src/tests/usr.bin/config/t_config.sh:1.9	Sun Mar  8 13:21:52 2020
+++ src/tests/usr.bin/config/t_config.sh	Mon Mar  9 16:33:16 2020
@@ -1,4 +1,4 @@
-# $NetBSD: t_config.sh,v 1.9 2020/03/08 17:21:52 christos Exp $
+# $NetBSD: t_config.sh,v 1.10 2020/03/09 20:33:16 christos Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -279,7 +279,7 @@ check_ifdef_files()
 check_ifdef_makefile()
 {
 	local f=Makefile
-	local e='-DOK1_1  -DOK2_1  -DOK2_2  -DOK3_1  -DOK3_2  -DOK3_3  -DOK3_4  -DOK3_5  -DMAXUSERS="4"'
+	local e='-DOK1_1  -DOK2_1  -DOK2_2  -DOK3_1  -DOK3_2  -DOK3_3  -DOK3_4  -DOK3_5  -DOK4_1  -DMAXUSERS="4"'
 	local r
 	r=$(make -f Makefile -V IDENT)
 	if [ "$r" != "$e" ]; then



CVS commit: [netbsd-9] src/doc

2020-03-09 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Mar  9 18:51:35 UTC 2020

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

Log Message:
777


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.14 -r1.1.2.15 src/doc/CHANGES-9.1

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

Modified files:

Index: src/doc/CHANGES-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.14 src/doc/CHANGES-9.1:1.1.2.15
--- src/doc/CHANGES-9.1:1.1.2.14	Mon Mar  9 18:29:16 2020
+++ src/doc/CHANGES-9.1	Mon Mar  9 18:51:35 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.14 2020/03/09 18:29:16 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.15 2020/03/09 18:51:35 snj Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -501,3 +501,9 @@ usr.bin/config/util.c   
 	config(1): fix issue with incorrect handling of elifdef statements.
 	[christos, ticket #776]
 
+usr.sbin/sysinst/arch/alpha/md.c		1.8
+
+	The (unused) md_pre_disklabel() function needs to return
+	success, otherwise all installations will be aborted.
+	[martin, ticket #777]
+



CVS commit: [netbsd-9] src/usr.sbin/sysinst/arch/alpha

2020-03-09 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Mar  9 18:50:19 UTC 2020

Modified Files:
src/usr.sbin/sysinst/arch/alpha [netbsd-9]: md.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #777):
usr.sbin/sysinst/arch/alpha/md.c: 1.8
The (unused) md_pre_disklabel() function needs to return success, otherwise
all installations will be aborted.


To generate a diff of this commit:
cvs rdiff -u -r1.6.2.1 -r1.6.2.2 src/usr.sbin/sysinst/arch/alpha/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/usr.sbin/sysinst/arch/alpha/md.c
diff -u src/usr.sbin/sysinst/arch/alpha/md.c:1.6.2.1 src/usr.sbin/sysinst/arch/alpha/md.c:1.6.2.2
--- src/usr.sbin/sysinst/arch/alpha/md.c:1.6.2.1	Tue Dec 17 09:44:50 2019
+++ src/usr.sbin/sysinst/arch/alpha/md.c	Mon Mar  9 18:50:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.6.2.1 2019/12/17 09:44:50 msaitoh Exp $ */
+/*	$NetBSD: md.c,v 1.6.2.2 2020/03/09 18:50:19 snj Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -126,7 +126,7 @@ bool
 md_pre_disklabel(struct install_partition_desc *install,
 struct disk_partitions *part)
 {
-	return 0;
+	return true;
 }
 
 /*



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

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  9 18:43:52 UTC 2020

Modified Files:
src/sys/arch/arm/include: cpu.h

Log Message:
Don't expose curproc/curlwp and other random kernel macros/functions/variables
du-jour.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/arm/include/cpu.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/arm/include/cpu.h
diff -u src/sys/arch/arm/include/cpu.h:1.108 src/sys/arch/arm/include/cpu.h:1.109
--- src/sys/arch/arm/include/cpu.h:1.108	Sat Feb 15 03:16:11 2020
+++ src/sys/arch/arm/include/cpu.h	Mon Mar  9 14:43:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.108 2020/02/15 08:16:11 skrll Exp $	*/
+/*	$NetBSD: cpu.h,v 1.109 2020/03/09 18:43:52 christos Exp $	*/
 
 /*
  * Copyright (c) 1994-1996 Mark Brinicombe.
@@ -101,7 +101,7 @@ void	cpu_proc_fork(struct proc *, struct
 #ifndef _LOCORE
 #if defined(TPIDRPRW_IS_CURLWP) || defined(TPIDRPRW_IS_CURCPU)
 #include 
-#endif
+#endif /* TPIDRPRW_IS_CURLWP || TPIDRPRW_IS_CURCPU */
 
 /* 1 == use cpu_sleep(), 0 == don't */
 extern int cpu_do_powersave;
@@ -217,6 +217,7 @@ extern struct cpu_info cpu_info_store[];
 struct lwp *arm_curlwp(void);
 struct cpu_info *arm_curcpu(void);
 
+#ifdef _KERNEL
 #if defined(_MODULE)
 
 #define	curlwp		arm_curlwp()
@@ -343,9 +344,11 @@ vaddr_t cpu_uarea_alloc_idlelwp(struct c
 int	cpu_maxproc_hook(int);
 #endif
 
+#endif /* _KERNEL */
+
 #endif /* !_LOCORE */
 
-#endif /* _KERNEL */
+#endif /* _KERNEL || _KMEMUSER */
 
 #elif defined(__aarch64__)
 



CVS commit: [netbsd-9] src/doc

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 18:29:16 UTC 2020

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

Log Message:
Ammend ticket #776


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.13 -r1.1.2.14 src/doc/CHANGES-9.1

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

Modified files:

Index: src/doc/CHANGES-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.13 src/doc/CHANGES-9.1:1.1.2.14
--- src/doc/CHANGES-9.1:1.1.2.13	Mon Mar  9 15:23:55 2020
+++ src/doc/CHANGES-9.1	Mon Mar  9 18:29:16 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.13 2020/03/09 15:23:55 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.14 2020/03/09 18:29:16 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -494,7 +494,7 @@ usr.bin/config/defs.h   
 usr.bin/config/files.c  up to 1.37
 usr.bin/config/gram.y   up to 1.55
 usr.bin/config/main.c   up to 1.99
-usr.bin/config/scan.l   up to 1.30
+usr.bin/config/scan.l   up to 1.31
 usr.bin/config/sem.cup to 1.84
 usr.bin/config/util.c   up to 1.21
 



CVS commit: [netbsd-9] src/usr.bin/config

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 18:28:14 UTC 2020

Modified Files:
src/usr.bin/config [netbsd-9]: scan.l

Log Message:
Addionally pull up for ticket ticket #776, requested by christos:

src/usr.bin/config/scan.l   1.31

Add an enabled bit to keep track of the parent state (if we are ignoring
or parsing). Idea from uwe.


To generate a diff of this commit:
cvs rdiff -u -r1.26.16.1 -r1.26.16.2 src/usr.bin/config/scan.l

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

Modified files:

Index: src/usr.bin/config/scan.l
diff -u src/usr.bin/config/scan.l:1.26.16.1 src/usr.bin/config/scan.l:1.26.16.2
--- src/usr.bin/config/scan.l:1.26.16.1	Mon Mar  9 15:22:21 2020
+++ src/usr.bin/config/scan.l	Mon Mar  9 18:28:14 2020
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: scan.l,v 1.26.16.1 2020/03/09 15:22:21 martin Exp $	*/
+/*	$NetBSD: scan.l,v 1.26.16.2 2020/03/09 18:28:14 martin Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: scan.l,v 1.26.16.1 2020/03/09 15:22:21 martin Exp $");
+__RCSID("$NetBSD: scan.l,v 1.26.16.2 2020/03/09 18:28:14 martin Exp $");
 
 #include 
 #include 
@@ -68,19 +68,21 @@ int	 ifdefshift = -1;
 /*
  * The state is represented by 3 bits.
  */
-#define IDS_MATCH	1ll
-#define IDS_ELIF	2ll
-#define	IDS_ELSE	4ll
-
-#define IDS_BITS	7
-#define IDS_SHIFT	3
-
-#define IDS_ISMATCH(st) (((st) & IDS_MATCH) != 0)
-#define IDS_PARENT_DISABLED \
-	(ifdefshift > 0 && !IDS_ISMATCH(ifdefstate >> IDS_SHIFT))
-#define IDS_MAX_DEPTH	21 /* 64 / 3 */
+#define	IDS_ENABLED	1ll
+#define	IDS_MATCH	2ll
+#define	IDS_ELIF	4ll
+#define	IDS_ELSE	8ll
+
+#define	IDS_BITS	0xf
+#define	IDS_SHIFT	4
+
+#define	IDS_ISMATCH(st) (((st) & IDS_MATCH) != 0)
+#define	IDS_ISENABLED(st) (((st) & IDS_ENABLED) != 0)
+#define	IDS_PARENT_DISABLED \
+	(ifdefshift > 0 && !IDS_ISENABLED(ifdefstate >> IDS_SHIFT))
+#define IDS_MAX_DEPTH	16 /* 64 / 4 */
 
-#ifdef IDS_DEBUG
+#ifdef	IDS_DEBUG
 # define IDS_PRINT(s, st, x) \
 	do { \
 		for (int i = 0; i < ifdefshift + 1; i++) \
@@ -90,12 +92,12 @@ int	 ifdefshift = -1;
 		ifdefstate); \
 	} while (/*CONSTCOND*/0)
 #else
-# define IDS_PRINT(s, st, x) __nothing
+# define IDS_PRINT(s, st, x) ((void)0)
 #endif
 
-#define IDS_ENTER(s, st) \
+#define	IDS_ENTER(s, st) \
 	IDS_PRINT(s, st, ">")
-#define IDS_EXIT(s, st) \
+#define	IDS_EXIT(s, st) \
 	IDS_PRINT(s, st, "<")
 
 /*
@@ -195,9 +197,10 @@ with		return WITH;
 		}
 		IDS_ENTER(ifdef, 0);
 		if (IDS_PARENT_DISABLED || !getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		IDS_EXIT(ifdef, 0);
@@ -211,9 +214,10 @@ with		return WITH;
 		}
 		IDS_ENTER(ifndef, 0);
 		if (IDS_PARENT_DISABLED || getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		IDS_EXIT(ifndef, 0);
@@ -228,9 +232,10 @@ with		return WITH;
 			yyerror("mismatched elifdef");
 		}
 		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st) || !getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELIF;
@@ -245,9 +250,10 @@ with		return WITH;
 			yyerror("mismatched elifndef");
 		}
 		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st) || getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELIF;
@@ -262,9 +268,10 @@ with		return WITH;
 			yyerror("mismatched else");
 		}
 		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st)) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELSE;



CVS commit: src/sys/netinet

2020-03-09 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Mar  9 17:57:19 UTC 2020

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

Log Message:
arp: report RTM_MISS when removing an unresolved entry in the arp table

Otherwise we only get it when renewing and we've sent too many requests.
This mirrors INET6 behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.292 -r1.293 src/sys/netinet/if_arp.c

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

Modified files:

Index: src/sys/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.292 src/sys/netinet/if_arp.c:1.293
--- src/sys/netinet/if_arp.c:1.292	Thu Jan 23 17:27:35 2020
+++ src/sys/netinet/if_arp.c	Mon Mar  9 17:57:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.292 2020/01/23 17:27:35 roy Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.293 2020/03/09 17:57:19 roy Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.292 2020/01/23 17:27:35 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.293 2020/03/09 17:57:19 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -307,18 +307,22 @@ arptimer(void *arg)
 
 	/* Guard against race with other llentry_free(). */
 	if (lle->la_flags & LLE_LINKED) {
+		int rt_cmd;
+		struct in_addr *in;
+		struct sockaddr_in sin;
+		const char *lladdr;
 		size_t pkts_dropped;
 
+		in = >r_l3addr.addr4;
+		sockaddr_in_init(, in, 0);
 		if (lle->la_flags & LLE_VALID) {
-			struct in_addr *in;
-			struct sockaddr_in sin;
-			const char *lladdr;
-
-			in = >r_l3addr.addr4;
-			sockaddr_in_init(, in, 0);
+			rt_cmd = RTM_DELETE;
 			lladdr = (const char *)>ll_addr;
-			rt_clonedmsg(RTM_DELETE, sintosa(), lladdr, ifp);
+		} else {
+			rt_cmd = RTM_MISS;
+			lladdr = NULL;
 		}
+		rt_clonedmsg(rt_cmd, sintosa(), lladdr, ifp);
 
 		LLE_REMREF(lle);
 		pkts_dropped = llentry_free(lle);



CVS commit: src/tests/usr.bin/config

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  9 17:27:29 UTC 2020

Modified Files:
src/tests/usr.bin/config: d_ifdef

Log Message:
One more test from uwe.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/config/d_ifdef

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

Modified files:

Index: src/tests/usr.bin/config/d_ifdef
diff -u src/tests/usr.bin/config/d_ifdef:1.1 src/tests/usr.bin/config/d_ifdef:1.2
--- src/tests/usr.bin/config/d_ifdef:1.1	Sun Mar  8 13:21:52 2020
+++ src/tests/usr.bin/config/d_ifdef	Mon Mar  9 13:27:29 2020
@@ -49,4 +49,14 @@ endif
 options OK3_5
 endif
 
+ifdef TRUE
+options OK4_1
+else
+ifdef TRUE
+options BAD4_2
+else
+options BAD4_3
+endif
+endif
+
 config regress root on ?



CVS commit: src/usr.bin/config

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  9 17:27:03 UTC 2020

Modified Files:
src/usr.bin/config: scan.l

Log Message:
Add an enabled bit to keep track of the parent state (if we are ignoring
or parsing). Idea from uwe.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/config/scan.l

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

Modified files:

Index: src/usr.bin/config/scan.l
diff -u src/usr.bin/config/scan.l:1.30 src/usr.bin/config/scan.l:1.31
--- src/usr.bin/config/scan.l:1.30	Sun Mar  8 13:38:37 2020
+++ src/usr.bin/config/scan.l	Mon Mar  9 13:27:03 2020
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: scan.l,v 1.30 2020/03/08 17:38:37 christos Exp $	*/
+/*	$NetBSD: scan.l,v 1.31 2020/03/09 17:27:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: scan.l,v 1.30 2020/03/08 17:38:37 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.31 2020/03/09 17:27:03 christos Exp $");
 
 #include 
 #include 
@@ -68,19 +68,21 @@ int	 ifdefshift = -1;
 /*
  * The state is represented by 3 bits.
  */
-#define IDS_MATCH	1ll
-#define IDS_ELIF	2ll
-#define	IDS_ELSE	4ll
-
-#define IDS_BITS	7
-#define IDS_SHIFT	3
-
-#define IDS_ISMATCH(st) (((st) & IDS_MATCH) != 0)
-#define IDS_PARENT_DISABLED \
-	(ifdefshift > 0 && !IDS_ISMATCH(ifdefstate >> IDS_SHIFT))
-#define IDS_MAX_DEPTH	21 /* 64 / 3 */
+#define	IDS_ENABLED	1ll
+#define	IDS_MATCH	2ll
+#define	IDS_ELIF	4ll
+#define	IDS_ELSE	8ll
+
+#define	IDS_BITS	0xf
+#define	IDS_SHIFT	4
+
+#define	IDS_ISMATCH(st) (((st) & IDS_MATCH) != 0)
+#define	IDS_ISENABLED(st) (((st) & IDS_ENABLED) != 0)
+#define	IDS_PARENT_DISABLED \
+	(ifdefshift > 0 && !IDS_ISENABLED(ifdefstate >> IDS_SHIFT))
+#define IDS_MAX_DEPTH	16 /* 64 / 4 */
 
-#ifdef IDS_DEBUG
+#ifdef	IDS_DEBUG
 # define IDS_PRINT(s, st, x) \
 	do { \
 		for (int i = 0; i < ifdefshift + 1; i++) \
@@ -90,12 +92,12 @@ int	 ifdefshift = -1;
 		ifdefstate); \
 	} while (/*CONSTCOND*/0)
 #else
-# define IDS_PRINT(s, st, x) __nothing
+# define IDS_PRINT(s, st, x) ((void)0)
 #endif
 
-#define IDS_ENTER(s, st) \
+#define	IDS_ENTER(s, st) \
 	IDS_PRINT(s, st, ">")
-#define IDS_EXIT(s, st) \
+#define	IDS_EXIT(s, st) \
 	IDS_PRINT(s, st, "<")
 
 /*
@@ -195,9 +197,10 @@ with		return WITH;
 		}
 		IDS_ENTER(ifdef, 0);
 		if (IDS_PARENT_DISABLED || !getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		IDS_EXIT(ifdef, 0);
@@ -211,9 +214,10 @@ with		return WITH;
 		}
 		IDS_ENTER(ifndef, 0);
 		if (IDS_PARENT_DISABLED || getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		IDS_EXIT(ifndef, 0);
@@ -228,9 +232,10 @@ with		return WITH;
 			yyerror("mismatched elifdef");
 		}
 		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st) || !getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELIF;
@@ -245,9 +250,10 @@ with		return WITH;
 			yyerror("mismatched elifndef");
 		}
 		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st) || getcurifdef()) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELIF;
@@ -262,9 +268,10 @@ with		return WITH;
 			yyerror("mismatched else");
 		}
 		if (IDS_PARENT_DISABLED || IDS_ISMATCH(st)) {
+			ifdefstate &= (uint64_t)~IDS_ENABLED;
 			BEGIN(IGNORED);
 		} else {
-			ifdefstate |= IDS_MATCH;
+			ifdefstate |= IDS_MATCH|IDS_ENABLED;
 			BEGIN(INITIAL);
 		}
 		ifdefstate |= IDS_ELSE;



CVS commit: src/usr.sbin/sysinst/arch/alpha

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 17:10:31 UTC 2020

Modified Files:
src/usr.sbin/sysinst/arch/alpha: md.c

Log Message:
The (unused) md_pre_disklabel() function needs to return success, otherwise
all installations will be aborted.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/sysinst/arch/alpha/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/usr.sbin/sysinst/arch/alpha/md.c
diff -u src/usr.sbin/sysinst/arch/alpha/md.c:1.7 src/usr.sbin/sysinst/arch/alpha/md.c:1.8
--- src/usr.sbin/sysinst/arch/alpha/md.c:1.7	Sun Dec 15 13:39:24 2019
+++ src/usr.sbin/sysinst/arch/alpha/md.c	Mon Mar  9 17:10:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.7 2019/12/15 13:39:24 martin Exp $ */
+/*	$NetBSD: md.c,v 1.8 2020/03/09 17:10:31 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -126,7 +126,7 @@ bool
 md_pre_disklabel(struct install_partition_desc *install,
 struct disk_partitions *part)
 {
-	return 0;
+	return true;
 }
 
 /*



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2020-03-09 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Mon Mar  9 15:40:50 UTC 2020

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: metaslab.c

Log Message:
external/cddl/osnet: Fix possible null pointer access.

Detected by UBSan and fixed upstream, pick only the fix from the commit.

Cherry-pick:
>From 928e8ad47d3478a3d5d01f0dd6ae74a9371af65e Mon Sep 17 00:00:00 2001
From: Serapheim Dimitropoulos 
Date: Wed, 20 Feb 2019 09:59:57 -0800
Subject: [PATCH] Introduce auxiliary metaslab histograms

Reviewed by: Paul Dagnelie 
Reviewed-by: Brian Behlendorf 
Reviewed by: Matt Ahrens 
Signed-off-by: Serapheim Dimitropoulos 
Closes #8358

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r1.2 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/metaslab.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/metaslab.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/metaslab.c:1.1.1.3 src/external/cddl/osnet/dist/uts/common/fs/zfs/metaslab.c:1.2
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/metaslab.c:1.1.1.3	Mon May 28 20:52:58 2018
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/metaslab.c	Mon Mar  9 15:40:50 2020
@@ -3370,7 +3370,7 @@ metaslab_alloc(spa_t *spa, metaslab_clas
 zio_alloc_list_t *zal, zio_t *zio)
 {
 	dva_t *dva = bp->blk_dva;
-	dva_t *hintdva = hintbp->blk_dva;
+	dva_t *hintdva = (hintbp != NULL) ? hintbp->blk_dva : NULL;
 	int error = 0;
 
 	ASSERT(bp->blk_birth == 0);



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2020-03-09 Thread Santhosh Raju
Module Name:src
Committed By:   fox
Date:   Mon Mar  9 15:37:46 UTC 2020

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dmu_tx.c spa.c

Log Message:
external/cddl/osnet: Fix possible signed integer overflow

Detected by UBSan and fixed upstream

Cherry-pick:
>From 05852b3467b44cdf88541ec67624cd1f5f2ded1d Mon Sep 17 00:00:00 2001
From: luozhengzheng 
Date: Fri, 14 Oct 2016 05:25:05 +0800
Subject: [PATCH] Fix coverity defects: CID 147571, 147574

CID 147571: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
CID 147574: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)

Reviewed-by: Brian Behlendorf 
Signed-off-by: luozhengzheng 
Closes #5268

Reviewed by: kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c
cvs rdiff -u -r1.10 -r1.11 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.4 src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.5
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.4	Fri Jun 21 10:59:50 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c	Mon Mar  9 15:37:46 2020
@@ -412,7 +412,7 @@ dmu_tx_count_dnode(dmu_tx_hold_t *txh)
 	dnode_t *dn = txh->txh_dnode;
 	dnode_t *mdn = DMU_META_DNODE(txh->txh_tx->tx_objset);
 	uint64_t space = mdn->dn_datablksz +
-	((mdn->dn_nlevels-1) << mdn->dn_indblkshift);
+	((uint64_t)(mdn->dn_nlevels-1) << mdn->dn_indblkshift);
 
 	if (dn && dn->dn_dbuf->db_blkptr &&
 	dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset,

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c:1.10 src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c:1.11
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c:1.10	Tue Jul 23 07:46:22 2019
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c	Mon Mar  9 15:37:46 2020
@@ -6293,7 +6293,7 @@ spa_async_tasks_pending(spa_t *spa)
 	} else {
 		config_task_suspended =
 		(gethrtime() - spa->spa_ccw_fail_time) <
-		(zfs_ccw_retry_interval * NANOSEC);
+		((hrtime_t)zfs_ccw_retry_interval * NANOSEC);
 	}
 
 	return (non_config_tasks || (config_task && !config_task_suspended));



CVS commit: [netbsd-9] src/doc

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 15:23:55 UTC 2020

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

Log Message:
Ticket #776


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.12 -r1.1.2.13 src/doc/CHANGES-9.1

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

Modified files:

Index: src/doc/CHANGES-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.12 src/doc/CHANGES-9.1:1.1.2.13
--- src/doc/CHANGES-9.1:1.1.2.12	Mon Mar  9 10:39:43 2020
+++ src/doc/CHANGES-9.1	Mon Mar  9 15:23:55 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.12 2020/03/09 10:39:43 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.13 2020/03/09 15:23:55 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -489,3 +489,15 @@ sys/arch/powerpc/ibm4xx/pic_uic.c		1.5
 	Remove unused macros.
 	[rin, ticket #774]
 
+usr.bin/config/TODO up to 1.32
+usr.bin/config/defs.h   up to 1.105
+usr.bin/config/files.c  up to 1.37
+usr.bin/config/gram.y   up to 1.55
+usr.bin/config/main.c   up to 1.99
+usr.bin/config/scan.l   up to 1.30
+usr.bin/config/sem.cup to 1.84
+usr.bin/config/util.c   up to 1.21
+
+	config(1): fix issue with incorrect handling of elifdef statements.
+	[christos, ticket #776]
+



CVS commit: [netbsd-9] src/usr.bin/config

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 15:22:21 UTC 2020

Modified Files:
src/usr.bin/config [netbsd-9]: TODO defs.h files.c gram.y main.c scan.l
sem.c util.c

Log Message:
Pull up the following, requested by christos in ticket #776:

usr.bin/config/TODO up to 1.32
usr.bin/config/defs.h   up to 1.105
usr.bin/config/files.c  up to 1.37
usr.bin/config/gram.y   up to 1.55
usr.bin/config/main.c   up to 1.99
usr.bin/config/scan.l   up to 1.30
usr.bin/config/sem.cup to 1.84
usr.bin/config/util.c   up to 1.21

config(1): fix issue with incorrect handling of elifdef statements.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.18.1 src/usr.bin/config/TODO
cvs rdiff -u -r1.104 -r1.104.2.1 src/usr.bin/config/defs.h
cvs rdiff -u -r1.36 -r1.36.16.1 src/usr.bin/config/files.c
cvs rdiff -u -r1.54 -r1.54.16.1 src/usr.bin/config/gram.y
cvs rdiff -u -r1.98 -r1.98.2.1 src/usr.bin/config/main.c
cvs rdiff -u -r1.26 -r1.26.16.1 src/usr.bin/config/scan.l
cvs rdiff -u -r1.83 -r1.83.4.1 src/usr.bin/config/sem.c
cvs rdiff -u -r1.20 -r1.20.18.1 src/usr.bin/config/util.c

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

Modified files:

Index: src/usr.bin/config/TODO
diff -u src/usr.bin/config/TODO:1.31 src/usr.bin/config/TODO:1.31.18.1
--- src/usr.bin/config/TODO:1.31	Sun Nov 22 01:20:36 2015
+++ src/usr.bin/config/TODO	Mon Mar  9 15:22:21 2020
@@ -259,7 +259,7 @@ o Control ELF sections using linker scri
 		 *.ko --->  *.ro	Modular MI linkage
 		 *.ro --->  *.kmod	Modular MD linkage
 
-  Genric MI linkage is for processing MI linkage that can be applied generally.
+  Generic MI linkage is for processing MI linkage that can be applied generally.
   Data section alignment (.data.read_mostly and .data.cacheline_aligned) is
   processed here.
 

Index: src/usr.bin/config/defs.h
diff -u src/usr.bin/config/defs.h:1.104 src/usr.bin/config/defs.h:1.104.2.1
--- src/usr.bin/config/defs.h:1.104	Mon Aug 27 16:04:45 2018
+++ src/usr.bin/config/defs.h	Mon Mar  9 15:22:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.104 2018/08/27 16:04:45 riastradh Exp $	*/
+/*	$NetBSD: defs.h,v 1.104.2.1 2020/03/09 15:22:21 martin Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -110,6 +110,10 @@ extern const char *progname;
 #define CONFIG_VERSION		20180827
 #define CONFIG_MINVERSION	0
 
+struct where {
+	const char *w_srcfile;		/* file name where we are defined */
+	u_short	w_srcline;		/* line number where we are defined */
+};
 /*
  * Name/value lists.  Values can be strings or pointers and/or can carry
  * integers.  The names can be NULL, resulting in simple value lists.
@@ -123,6 +127,7 @@ struct nvlist {
 	int		nv_ifunit;		/* XXX XXX XXX */
 	int		nv_flags;
 #define	NV_DEPENDED	1
+	struct where	nv_where;
 };
 
 /*
@@ -131,10 +136,10 @@ struct nvlist {
 struct config {
 	TAILQ_ENTRY(config) cf_next;
 	const char *cf_name;		/* "netbsd" */
-	int	cf_lineno;		/* source line */
 	const char *cf_fstype;		/* file system type */
 	struct	nvlist *cf_root;	/* "root on ra0a" */
 	struct	nvlist *cf_dump;	/* "dumps on ra0b" */
+	struct where	cf_where;
 };
 
 /*
@@ -147,6 +152,7 @@ struct defoptlist {
 	const char *dl_lintvalue;
 	int dl_obsolete;
 	struct nvlist *dl_depends;
+	struct where	dl_where;
 };
 
 struct files;
@@ -199,6 +205,7 @@ struct attr {
 
 	/* "device class" */
 	const char *a_devclass;		/* device class described */
+	struct where a_where;
 };
 
 /*
@@ -277,8 +284,7 @@ struct devbase {
 	struct	deva *d_ahead;		/* first attachment, if any */
 	struct	deva **d_app;		/* used for tacking on attachments */
 	struct	attr *d_classattr;	/* device class attribute (if any) */
-	const char *d_srcfile;		/* file name where we are defined */
-	u_short	d_srcline;		/* line number where we are defined */
+	struct	where d_where;
 };
 
 struct deva {
@@ -291,8 +297,7 @@ struct deva {
 	struct	attrlist *d_attrs;	/* attributes, if any */
 	struct	devi *d_ihead;		/* first instance, if any */
 	struct	devi **d_ipp;		/* used for tacking on more instances */
-	const char *d_srcfile;		/* file name where we are defined */
-	u_short	d_srcline;		/* line number where we are defined */
+	struct	where d_where;
 };
 
 /*
@@ -319,8 +324,6 @@ struct devi {
 	struct	deva *i_atdeva;
 	const char **i_locs;	/* locators (as given by pspec's iattr) */
 	int	i_cfflags;	/* flags from config line */
-	int	i_lineno;	/* line # in config, for later errors */
-	const char *i_srcfile;	/* file it appears in */
 	int	i_level;	/* position between negated instances */
 	int	i_active;
 #define	DEVI_ORPHAN	0	/* instance has no active parent */
@@ -333,7 +336,7 @@ struct devi {
 	short	i_collapsed;	/* set 

CVS commit: src/sys/rump

2020-03-09 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Mar  9 14:45:42 UTC 2020

Modified Files:
src/sys/rump: Makefile.rump

Log Message:
Revert previous

Requested by 


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/rump/Makefile.rump

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

Modified files:

Index: src/sys/rump/Makefile.rump
diff -u src/sys/rump/Makefile.rump:1.126 src/sys/rump/Makefile.rump:1.127
--- src/sys/rump/Makefile.rump:1.126	Mon Mar  9 00:03:00 2020
+++ src/sys/rump/Makefile.rump	Mon Mar  9 14:45:41 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.rump,v 1.126 2020/03/09 00:03:00 kamil Exp $
+#	$NetBSD: Makefile.rump,v 1.127 2020/03/09 14:45:41 kamil Exp $
 #
 
 .if !defined(_RUMP_MK)
@@ -22,9 +22,7 @@ CPPFLAGS+=	-D_RUMPKERNEL -I${RUMPTOP}/li
 # We are compiling the kernel code with no-delete-null-pointer-checks,
 # and compiling without it, causes issues at least on sh3 by adding
 # aborts after kern_assert on NULL pointer checks.
-# no-delete-null-pointer-checks is required in Clang/LLVM at least for
-# NULL + 0 operations that trigger LLVM UBSan and could be miscompiled.
-CFLAGS+=-fno-delete-null-pointer-checks
+CFLAGS+=${${ACTIVE_CC} == "gcc":? -fno-delete-null-pointer-checks :}
 
 # Define baseline cpu for mips ports, required for
 # rumpcomp_sync_icache() hypercall.



CVS commit: src/common/lib/libc/arch/m68k/string

2020-03-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Mar  9 13:36:10 UTC 2020

Modified Files:
src/common/lib/libc/arch/m68k/string: ffs.S

Log Message:
Add missing END() for coldfire.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/m68k/string/ffs.S

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

Modified files:

Index: src/common/lib/libc/arch/m68k/string/ffs.S
diff -u src/common/lib/libc/arch/m68k/string/ffs.S:1.6 src/common/lib/libc/arch/m68k/string/ffs.S:1.7
--- src/common/lib/libc/arch/m68k/string/ffs.S:1.6	Sat Sep  7 19:06:29 2013
+++ src/common/lib/libc/arch/m68k/string/ffs.S	Mon Mar  9 13:36:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.S,v 1.6 2013/09/07 19:06:29 chs Exp $	*/
+/*	$NetBSD: ffs.S,v 1.7 2020/03/09 13:36:10 rin Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -39,7 +39,7 @@
 #if 0
 	RCSID("from: @(#)ffs.s	5.1 (Berkeley) 5/12/90")
 #else
-	RCSID("$NetBSD: ffs.S,v 1.6 2013/09/07 19:06:29 chs Exp $")
+	RCSID("$NetBSD: ffs.S,v 1.7 2020/03/09 13:36:10 rin Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -76,6 +76,7 @@ ENTRY(ffs)
 	jcc	.L1		| keep looping while carry is clear.
 .L2:
 	rts
+END(ffs)
 
 #else	/* __mc68010__ */
 



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

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 13:12:14 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-9]: trap.c

Log Message:
Fix merge botch in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.121.2.1 -r1.121.2.2 src/sys/arch/amd64/amd64/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/amd64/amd64/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.121.2.1 src/sys/arch/amd64/amd64/trap.c:1.121.2.2
--- src/sys/arch/amd64/amd64/trap.c:1.121.2.1	Sun Mar  8 10:54:43 2020
+++ src/sys/arch/amd64/amd64/trap.c	Mon Mar  9 13:12:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.121.2.1 2020/03/08 10:54:43 martin Exp $	*/
+/*	$NetBSD: trap.c,v 1.121.2.2 2020/03/09 13:12:14 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.121.2.1 2020/03/08 10:54:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.121.2.2 2020/03/09 13:12:14 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -357,6 +357,7 @@ trap(struct trapframe *frame)
 		MODULE_HOOK_CALL(amd64_oosyscall_hook, (p, frame),
 			ENOSYS, hook_ret);
 		if (hook_ret == 0)
+			goto out;
 	}
 		/* FALLTHROUGH */
 	case T_TSSFLT|T_USER:



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

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 11:52:15 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx [netbsd-9]: copyinstr.c copyoutstr.c

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

sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.12
sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.13
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.10
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.11
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.12
sys/arch/powerpc/ibm4xx/copyoutstr.c: revision 1.13
sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.10
sys/arch/powerpc/ibm4xx/copyinstr.c: revision 1.11

copy{in,out}str: sync style with booke.
- early return in case of len == 0
- *done = 0 on fault

copy{in,out}str: Correctly return ENAMETOOLONG if source is not
NUL-terminated.

Use dcbst instead of dcbf to flush cache; the former does not invalidate
the cache line, which should be used immediately in most cases.

Cosmetic changes. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.64.1 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.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/powerpc/ibm4xx/copyinstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.9 src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.9.64.1
--- src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.9	Sat Mar 20 23:31:29 2010
+++ src/sys/arch/powerpc/ibm4xx/copyinstr.c	Mon Mar  9 11:52:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyinstr.c,v 1.9 2010/03/20 23:31:29 chs Exp $	*/
+/*	$NetBSD: copyinstr.c,v 1.9.64.1 2020/03/09 11:52:14 martin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.9 2010/03/20 23:31:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.9.64.1 2020/03/09 11:52:14 martin Exp $");
 
 #include 
 #include 
@@ -46,14 +46,20 @@ int
 copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done)
 {
 	struct pmap *pm = curproc->p_vmspace->vm_map.pmap;
-	int rv, msr, pid, tmp, ctx;
+	size_t resid;
+	int rv, msr, pid, data, ctx;
 	struct faultbuf env;
 
+	if (__predict_false(len == 0)) {
+		if (done)
+			*done = 0;
+		return 0;
+	}
+
 	if ((rv = setfault())) {
 		curpcb->pcb_onfault = NULL;
-		/*  -- len may be lost on a fault */
 		if (done)
-			*done = len;
+			*done = 0;
 		return rv;
 	}
 
@@ -63,36 +69,37 @@ copyinstr(const void *udaddr, void *kadd
 		ctx = pm->pm_ctx;
 	}
 
-	if (len) {
-		__asm volatile("mtctr %3;"		/* Set up counter */
-			"mfmsr %0;"			/* Save MSR */
-			"li %1,0x20; "
-			"andc %1,%0,%1; mtmsr %1;"	/* Disable IMMU */
-			"mfpid %1;"			/* Save old PID */
-			"sync; isync;"
-
-			"li %3,0;"			/* Clear len */
-
-			"1: "
-			"mtpid %4; sync;"		/* Load user ctx */
-			"lbz %2,0(%5); addi %5,%5,1;"	/* Load byte */
-			"sync; isync;"
-			"mtpid %1;sync;"
-			"stb %2,0(%6);  dcbf 0,%6; addi %6,%6,1;"	/* Store kernel byte */
-			"sync; isync;"
-			"addi %3,%3,1;"			/* Inc len */
-			"or. %2,%2,%2;"
-			"bdnzf 2,1b;"			/*
-			 * while(ctr-- && !zero)
-			 */
-
-			"mtpid %1; mtmsr %0;"		/* Restore PID, MSR */
-			"sync; isync;"
-			: "=" (msr), "=" (pid), "=" (tmp), "+b" (len)
-			: "r" (ctx), "b" (udaddr), "b" (kaddr));
-	}
+	resid = len;
+	__asm volatile(
+		"mtctr %3;"			/* Set up counter */
+		"mfmsr %0;"			/* Save MSR */
+		"li %1,0x20;"
+		"andc %1,%0,%1; mtmsr %1;"	/* Disable IMMU */
+		"mfpid %1;"			/* Save old PID */
+		"sync; isync;"
+
+		"1: "
+		"mtpid %4; sync;"		/* Load user ctx */
+		"lbz %2,0(%5); addi %5,%5,1;"	/* Load byte */
+		"sync; isync;"
+		"mtpid %1; sync;"
+		"stb %2,0(%6); dcbst 0,%6; addi %6,%6,1;"
+		/* Store kernel byte */
+		"sync; isync;"
+		"or. %2,%2,%2;"
+		"bdnzf 2,1b;"			/* while(ctr-- && !zero) */
+
+		"mtpid %1; mtmsr %0;"		/* Restore PID, MSR */
+		"sync; isync;"
+		"mfctr %3;"			/* Restore resid */
+		: "=" (msr), "=" (pid), "=" (data), "+r" (resid)
+		: "r" (ctx), "b" (udaddr), "b" (kaddr));
+
 	curpcb->pcb_onfault = NULL;
 	if (done)
-		*done = len;
-	return 0;
+		*done = len - resid;
+	if (resid == 0 && (char)data != '\0')
+		return ENAMETOOLONG;
+	else
+		return 0;
 }
Index: src/sys/arch/powerpc/ibm4xx/copyoutstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.9 src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.9.64.1
--- src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.9	Sat Mar 20 23:31:29 2010
+++ src/sys/arch/powerpc/ibm4xx/copyoutstr.c	Mon Mar  9 11:52:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyoutstr.c,v 1.9 2010/03/20 23:31:29 chs Exp $	*/
+/*	$NetBSD: copyoutstr.c,v 1.9.64.1 2020/03/09 11:52:14 martin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.9 2010/03/20 23:31:29 chs Exp $");

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

2020-03-09 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Mar  9 11:21:54 UTC 2020

Modified Files:
src/common/lib/libc/arch/arm/atomic: atomic_cas_up.S

Log Message:
Give the thumb atomic ops a chance of working


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S

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

Modified files:

Index: src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S
diff -u src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S:1.7 src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S:1.8
--- src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S:1.7	Tue Mar  4 03:36:24 2014
+++ src/common/lib/libc/arch/arm/atomic/atomic_cas_up.S	Mon Mar  9 11:21:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic_cas_up.S,v 1.7 2014/03/04 03:36:24 matt Exp $	*/
+/*	$NetBSD: atomic_cas_up.S,v 1.8 2020/03/09 11:21:54 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -41,6 +41,7 @@ RAS_START_ASM_HIDDEN(_atomic_cas)
 	cmp	r0, r1
 #if defined(__thumb__)
 	beq	1f
+	str	r2, [r3]
 #else
 	streq	r2, [r3]
 #endif
@@ -75,6 +76,7 @@ RAS_START_ASM_HIDDEN(_atomic_cas_16)
 	cmp	r0, r1
 #if defined(__thumb__)
 	beq	1f
+	strh	r2, [r3]
 #else
 	strheq	r2, [r3]
 #endif
@@ -91,6 +93,7 @@ RAS_START_ASM_HIDDEN(_atomic_cas_8)
 	cmp	r0, r1
 #if defined(__thumb__)
 	beq	1f
+	strb	r2, [r3]
 #else
 	strbeq	r2, [r3]
 #endif



CVS commit: [netbsd-9] src/doc

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 10:39:43 UTC 2020

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

Log Message:
Tickets #769 - #774


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.11 -r1.1.2.12 src/doc/CHANGES-9.1

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

Modified files:

Index: src/doc/CHANGES-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.11 src/doc/CHANGES-9.1:1.1.2.12
--- src/doc/CHANGES-9.1:1.1.2.11	Mon Mar  9 05:37:37 2020
+++ src/doc/CHANGES-9.1	Mon Mar  9 10:39:43 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.11 2020/03/09 05:37:37 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.12 2020/03/09 10:39:43 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -441,3 +441,51 @@ sys/compat/netbsd32/netbsd32_mod.c		1.17
 	Fix MODULE_HOOK_SET arguments (broken in ticket #762).
 	[pgoyette, ticket #775]
 
+external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c 1.63
+
+	Avoid unnecessary zil_commit on rm.
+	[riastradh, ticket #769]
+
+sys/compat/netbsd32/netbsd32_mod.c		1.19
+
+	Fix restarting of syscalls in compat_netbsd32.
+	[pgoyette, ticket #770]
+
+sys/arch/powerpc/booke/copyout.c		1.6-1.8
+
+	copyoutstr(9):
+	 - sync style with copyinstr(9)
+	 - return  ENAMETOOLONG correctly when source string is not
+	   NUL-terminated.
+	Comment out full function of optimized version of copyoutstr(9),
+	which has never been enabled so far.
+	[rin, ticket #771]
+
+sys/arch/powerpc/ibm4xx/copyinstr.c		1.10-1.13
+sys/arch/powerpc/ibm4xx/copyoutstr.c		1.10-1.13
+
+	copy{in,out}str: sync style with booke.
+	copy{in,out}str: Correctly return ENAMETOOLONG if source is not
+	NUL-terminated.
+	Use dcbst instead of dcbf to flush cache.
+	Cosmetic changes.
+	[rin, ticket #772]
+
+sys/arch/powerpc/ibm4xx/pmap.c			1.81-1.85
+sys/arch/powerpc/include/ibm4xx/pmap.h		1.20
+sys/arch/powerpc/include/ibm4xx/tlb.h		1.6
+
+	Misc non-critical fixes.
+	ppc4xx_tlb_enter(): invalidate entry after clearing MSR for sure.
+	pmap_procwr(): use dcbst instead of dcbf as a tiny optimization.
+	Retire tlbpid_t (u_short).
+	Fix pmap_procwr().
+	[rin, ticket #773]
+
+sys/arch/powerpc/ibm4xx/cpu.c			1.34
+sys/arch/powerpc/ibm4xx/pic_uic.c		1.5
+
+	Cosmetic change. No binary changes.
+	Remove unused macros.
+	[rin, ticket #774]
+



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

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 10:37:57 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx [netbsd-9]: cpu.c pic_uic.c

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

sys/arch/powerpc/ibm4xx/cpu.c: revision 1.34
sys/arch/powerpc/ibm4xx/pic_uic.c: revision 1.5

Cosmetic change. No binary changes.

Remove unused macros.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.34.1 src/sys/arch/powerpc/ibm4xx/cpu.c
cvs rdiff -u -r1.4 -r1.4.34.1 src/sys/arch/powerpc/ibm4xx/pic_uic.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/powerpc/ibm4xx/cpu.c
diff -u src/sys/arch/powerpc/ibm4xx/cpu.c:1.33 src/sys/arch/powerpc/ibm4xx/cpu.c:1.33.34.1
--- src/sys/arch/powerpc/ibm4xx/cpu.c:1.33	Mon Mar 24 19:29:59 2014
+++ src/sys/arch/powerpc/ibm4xx/cpu.c	Mon Mar  9 10:37:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.33 2014/03/24 19:29:59 christos Exp $	*/
+/*	$NetBSD: cpu.c,v 1.33.34.1 2020/03/09 10:37:57 martin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.33 2014/03/24 19:29:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.33.34.1 2020/03/09 10:37:57 martin Exp $");
 
 #include 
 #include 
@@ -317,6 +317,6 @@ dcache_wbinv_page(vaddr_t va)
 		for (size_t i = 0; i < PAGE_SIZE; i += dcache_line_size) {
 			__asm volatile("dcbf %0,%1" : : "b" (va), "r" (i));
 		}
-		__asm volatile("sync;isync" : : );
+		__asm volatile("sync; isync" : : );
 	}
 }

Index: src/sys/arch/powerpc/ibm4xx/pic_uic.c
diff -u src/sys/arch/powerpc/ibm4xx/pic_uic.c:1.4 src/sys/arch/powerpc/ibm4xx/pic_uic.c:1.4.34.1
--- src/sys/arch/powerpc/ibm4xx/pic_uic.c:1.4	Tue Nov 19 12:46:43 2013
+++ src/sys/arch/powerpc/ibm4xx/pic_uic.c	Mon Mar  9 10:37:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_uic.c,v 1.4 2013/11/19 12:46:43 kiyohara Exp $	*/
+/*	$NetBSD: pic_uic.c,v 1.4.34.1 2020/03/09 10:37:57 martin Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_uic.c,v 1.4 2013/11/19 12:46:43 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_uic.c,v 1.4.34.1 2020/03/09 10:37:57 martin Exp $");
 
 #include 
 #include 
@@ -295,12 +295,6 @@ struct pic_ops pic_uic2 = {
 #endif /* MULTIUIC */
 #endif /* !PPC_IBM403 */
 
-/* Write External Enable Immediate */
-#define	wrteei(en) 		__asm volatile ("wrteei %0" : : "K"(en))
-
-/* Enforce In Order Execution of I/O */
-#define	eieio() 		__asm volatile ("eieio")
-
 /*
  * Set up interrupt mapping array.
  */



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

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 10:36:42 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx [netbsd-9]: pmap.c
src/sys/arch/powerpc/include/ibm4xx [netbsd-9]: pmap.h tlb.h

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

sys/arch/powerpc/ibm4xx/pmap.c: revision 1.81
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.82
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.83
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.84
sys/arch/powerpc/ibm4xx/pmap.c: revision 1.85
sys/arch/powerpc/include/ibm4xx/tlb.h: revision 1.6
sys/arch/powerpc/include/ibm4xx/pmap.h: revision 1.20

Misc non-critical fixes.
- __asm --> __asm volatile for sure
- turn DEBUG code in __asm into DIAGNOSTIC code in C
- style

ppc4xx_tlb_enter(): invalidate entry after clearing MSR for sure.

pmap_procwr(): use dcbst instead of dcbf as a tiny optimization.

Retire tlbpid_t (u_short):
- PID (ctx, ASID) is 8-bit length, not half word.
- For struct pmap, no need to use integer types smaller than word as
  pm_ctx because of alignment.
- For ppc4xx_tlb_enter(), we need word-length storage for pid (and msr).
XXX
Better to rewrite pmap module with more suggestive integer types rather
than char, int, long, and so on.

Fix pmap_procwr().
While we need to turn off IMMU, DMMU should be kept on. Otherwise,
dcbst (and also icbi probably, though not documented clearly both
for 405 and 403) should not work correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.76.20.1 -r1.76.20.2 src/sys/arch/powerpc/ibm4xx/pmap.c
cvs rdiff -u -r1.19 -r1.19.2.1 src/sys/arch/powerpc/include/ibm4xx/pmap.h
cvs rdiff -u -r1.5 -r1.5.6.1 src/sys/arch/powerpc/include/ibm4xx/tlb.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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.76.20.1 src/sys/arch/powerpc/ibm4xx/pmap.c:1.76.20.2
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.76.20.1	Thu Feb 27 18:23:10 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Mon Mar  9 10:36:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.76.20.1 2020/02/27 18:23:10 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.76.20.2 2020/03/09 10:36:42 martin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.76.20.1 2020/02/27 18:23:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.76.20.2 2020/03/09 10:36:42 martin Exp $");
 
 #include 
 #include 
@@ -1173,16 +1173,18 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 		ctx_alloc(pm);
 		ctx = pm->pm_ctx;
 	}
-	__asm volatile("mfmsr %0;"
-		"li %1, %7;"
+	__asm volatile(
+		"mfmsr %0;"
+		"li %1,0x20;"		/* Turn off IMMU */
 		"andc %1,%0,%1;"
+		"ori %1,%1,0x10;"	/* Turn on DMMU for sure */
 		"mtmsr %1;"
 		"sync;isync;"
 		"mfpid %1;"
 		"mtpid %2;"
 		"sync; isync;"
 		"1:"
-		"dcbf 0,%3;"
+		"dcbst 0,%3;"
 		"icbi 0,%3;"
 		"add %3,%3,%5;"
 		"addc. %4,%4,%6;"
@@ -1191,8 +1193,7 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 		"mtmsr %0;"
 		"sync; isync"
 		: "=" (msr), "=" (opid)
-		: "r" (ctx), "r" (va), "r" (len), "r" (step), "r" (-step),
-		  "K" (PSL_IR | PSL_DR));
+		: "r" (ctx), "r" (va), "r" (len), "r" (step), "r" (-step));
 }
 
 
@@ -1207,7 +1208,8 @@ ppc4xx_tlb_flush(vaddr_t va, int pid)
 	if (!pid)
 		return;
 
-	__asm( 	"mfpid %1;"		/* Save PID */
+	__asm volatile(
+		"mfpid %1;"		/* Save PID */
 		"mfmsr %2;"		/* Save MSR */
 		"li %0,0;"		/* Now clear MSR */
 		"mtmsr %0;"
@@ -1225,7 +1227,6 @@ ppc4xx_tlb_flush(vaddr_t va, int pid)
 		: "=" (i), "=" (found), "=" (msr)
 		: "r" (va), "r" (pid));
 	if (found && !TLB_LOCKED(i)) {
-
 		/* Now flush translation */
 		__asm volatile(
 			"tlbwe %0,%1,0;"
@@ -1292,8 +1293,7 @@ void
 ppc4xx_tlb_enter(int ctx, vaddr_t va, u_int pte)
 {
 	u_long th, tl, idx;
-	tlbpid_t pid;
-	u_short msr;
+	int msr, pid;
 	paddr_t pa;
 	int sz;
 
@@ -1308,7 +1308,7 @@ ppc4xx_tlb_enter(int ctx, vaddr_t va, u_
 	idx = ppc4xx_tlb_find_victim();
 
 #ifdef DIAGNOSTIC
-	if ((idx < tlb_nreserved) || (idx >= NTLB)) {
+	if ((idx < tlb_nreserved) || (idx >= NTLB) || (idx & 63) == 0) {
 		panic("ppc4xx_tlb_enter: replacing entry %ld", idx);
 	}
 #endif
@@ -1320,15 +1320,11 @@ ppc4xx_tlb_enter(int ctx, vaddr_t va, u_
 	__asm volatile(
 		"mfmsr %0;"			/* Save MSR */
 		"li %1,0;"
-		"tlbwe %1,%3,0;"		/* Invalidate old entry. */
 		"mtmsr %1;"			/* Clear MSR */
+		"tlbwe %1,%3,0;"		/* Invalidate old entry. */
 		"mfpid %1;"			/* Save old PID */
 		"mtpid %2;"			/* Load translation ctx */
 		"sync; isync;"
-#ifdef DEBUG
-		"andi. %3,%3,63;"
-		"tweqi %3,0;" 			/* X DEBUG trap on index 0 */
-#endif
 		"tlbwe %4,%3,1; tlbwe %5,%3,0;"	/* Set TLB */
 		"sync; isync;"
 		"mtpid %1; mtmsr %0;"		/* Restore PID and MSR */

Index: src/sys/arch/powerpc/include/ibm4xx/pmap.h
diff -u src/sys/arch/powerpc/include/ibm4xx/pmap.h:1.19 

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

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 10:11:40 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke [netbsd-9]: copyout.c

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

sys/arch/powerpc/booke/copyout.c: revision 1.6
sys/arch/powerpc/booke/copyout.c: revision 1.7
sys/arch/powerpc/booke/copyout.c: revision 1.8

copyoutstr(9): sync style with copyinstr(9).
- use variable name "done" instead of "lenp"
- return return value from setfault() on fault, instead of hardcoded EFAULT
No functional changes intended.

copyoutstr(9): return ENAMETOOLONG correctly when source string is
not NUL-terminated.

Comment out full function of optimized version of copyoutstr(9),
which has never been enabled so far.
Only for clarity. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.4.1 src/sys/arch/powerpc/booke/copyout.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/powerpc/booke/copyout.c
diff -u src/sys/arch/powerpc/booke/copyout.c:1.5 src/sys/arch/powerpc/booke/copyout.c:1.5.4.1
--- src/sys/arch/powerpc/booke/copyout.c:1.5	Sun Apr  7 05:25:55 2019
+++ src/sys/arch/powerpc/booke/copyout.c	Mon Mar  9 10:11:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyout.c,v 1.5 2019/04/07 05:25:55 thorpej Exp $	*/
+/*	$NetBSD: copyout.c,v 1.5.4.1 2020/03/09 10:11:40 martin Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.5 2019/04/07 05:25:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.5.4.1 2020/03/09 10:11:40 martin Exp $");
 
 #define	__UFETCHSTORE_PRIVATE
 
@@ -400,39 +400,73 @@ copyout(const void *vksaddr, void *vudad
 	return 0;
 }
 
+#if 1
 int
-copyoutstr(const void *ksaddr, void *udaddr, size_t len, size_t *lenp)
+copyoutstr(const void *ksaddr, void *udaddr, size_t len, size_t *done)
 {
 	struct pcb * const pcb = lwp_getpcb(curlwp);
 	struct faultbuf env;
+	int rv;
 
 	if (__predict_false(len == 0)) {
-		if (lenp)
-			*lenp = 0;
+		if (done)
+			*done = 0;
 		return 0;
 	}
 
-	if (setfault()) {
+	rv = setfault();
+	if (rv != 0) {
 		pcb->pcb_onfault = NULL;
-		if (lenp)
-			*lenp = 0;
-		return EFAULT;
+		if (done)
+			*done = 0;
+		return rv;
 	}
 
 	const register_t ds_msr = mfmsr() | PSL_DS;
 	const uint8_t *ksaddr8 = ksaddr;
 	size_t copylen = 0;
 
-#if 1
 	uint8_t *udaddr8 = (void *)udaddr;
 
 	while (copylen++ < len) {
 		const uint8_t data = *ksaddr8++;
 		copyout_uint8(udaddr8++, data, ds_msr);
 		if (data == 0)
-			break;
+			goto out;
 	}
+	rv = ENAMETOOLONG;
+
+out:
+	pcb->pcb_onfault = NULL;
+	if (done)
+		*done = copylen;
+	return rv;
+}
 #else
+/* XXX This version of copyoutstr(9) has never beeen enabled so far. */
+int
+copyoutstr(const void *ksaddr, void *udaddr, size_t len, size_t *lenp)
+{
+	struct pcb * const pcb = lwp_getpcb(curlwp);
+	struct faultbuf env;
+
+	if (__predict_false(len == 0)) {
+		if (lenp)
+			*lenp = 0;
+		return 0;
+	}
+
+	if (setfault()) {
+		pcb->pcb_onfault = NULL;
+		if (lenp)
+			*lenp = 0;
+		return EFAULT;
+	}
+
+	const register_t ds_msr = mfmsr() | PSL_DS;
+	const uint8_t *ksaddr8 = ksaddr;
+	size_t copylen = 0;
+
 	uint32_t *udaddr32 = (void *)((uintptr_t)udaddr & ~3);
 
 	size_t boff = (uintptr_t)udaddr & 3;
@@ -523,10 +557,10 @@ copyoutstr(const void *ksaddr, void *uda
 		copyout_le32_with_mask(udaddr32, data, mask, ds_msr);
 		copylen += wlen;
 	}
-#endif
 
 	pcb->pcb_onfault = NULL;
 	if (lenp)
 		*lenp = copylen;
 	return 0;
 }
+#endif



CVS commit: [netbsd-9] src/sys/compat/netbsd32

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 09:55:52 UTC 2020

Modified Files:
src/sys/compat/netbsd32 [netbsd-9]: netbsd32_mod.c

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

sys/compat/netbsd32/netbsd32_mod.c: revision 1.19

If a syscall requires a module to be autoloaded, the initial invocation
of that syscall will return ERESTART.  For amd64's netbsd32_syscall()
that means we need to back up the PC saved in the trap frame so we can
re-issue the syscall instruction.  For "normal" syscall traps, we saved
the instruction length in the trap frame, but this was missing for the
oosyscall/lcall path.  Since the PC was not backed up, the kernel-only
value ERESTART was returned to userland, causing all sort of grief for
old compat_netbsd32 executables!

XXX Pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.15.4.2 -r1.15.4.3 src/sys/compat/netbsd32/netbsd32_mod.c

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

Modified files:

Index: src/sys/compat/netbsd32/netbsd32_mod.c
diff -u src/sys/compat/netbsd32/netbsd32_mod.c:1.15.4.2 src/sys/compat/netbsd32/netbsd32_mod.c:1.15.4.3
--- src/sys/compat/netbsd32/netbsd32_mod.c:1.15.4.2	Mon Mar  9 05:36:24 2020
+++ src/sys/compat/netbsd32/netbsd32_mod.c	Mon Mar  9 09:55:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_mod.c,v 1.15.4.2 2020/03/09 05:36:24 martin Exp $	*/
+/*	$NetBSD: netbsd32_mod.c,v 1.15.4.3 2020/03/09 09:55:52 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.15.4.2 2020/03/09 05:36:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.15.4.3 2020/03/09 09:55:52 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -148,8 +148,9 @@ amd64_oosyscall_handle(struct proc *p, s
 	copyin((void *)frame->tf_rip, tmp, sz) == 0 &&
 	memcmp(tmp, lcall, sz) == 0) {
 
-		/* Advance past the lcall. */
+		/* Advance past the lcall and save instruction size. */
 		frame->tf_rip += sz;
+		frame->tf_err = sz;
 
 		/* Do the syscall */
 		p->p_md.md_syscall(frame);
@@ -157,7 +158,7 @@ amd64_oosyscall_handle(struct proc *p, s
 	} else
 		return EPASSTHROUGH;
 }
-#endif
+#endif /* defined(__amd64__) */
 
 static int
 compat_netbsd32_modcmd(modcmd_t cmd, void *arg)
@@ -175,14 +176,14 @@ compat_netbsd32_modcmd(modcmd_t cmd, voi
 #if defined(__amd64__)
 			MODULE_HOOK_SET(amd64_oosyscall_hook, "nb32oo",
 			amd64_oosyscall_handle);
-#endif
+#endif /* defined(__amd64__) */
 		}
 		return error;
 
 	case MODULE_CMD_FINI:
 #if defined(__amd64__)
 		MODULE_HOOK_UNSET(amd64_oosyscall_hook);
-#endif
+#endif /* defined(__amd64__) */
 		netbsd32_machdep_md_fini();
 		netbsd32_sysctl_fini();
 		netbsd32_kern_proc_32_fini();
@@ -196,7 +197,7 @@ compat_netbsd32_modcmd(modcmd_t cmd, voi
 #if defined(__amd64__)
 			MODULE_HOOK_SET(amd64_oosyscall_hook, "nb32oo",
 			amd64_oosyscall_handle);
-#endif
+#endif /* defined(__amd64__) */
 		}
 		return error;
 



CVS commit: [netbsd-9] src/external/cddl/osnet/dist/uts/common/fs/zfs

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 09:52:00 UTC 2020

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs [netbsd-9]: zfs_vnops.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #769):

external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c: revision 1.63

Avoid unnecessary zil_commit on rm.

1. Issue zil_commit only if we're actually updating something --
   there's no need to commit if we're unlinking the file or if
   there's no atime update being applied.

2. Issue zil_commit only if the zfs has sync=always set -- for
   sync=standard there's no need for us to commit anything here since
   no application asked for an explicit sync.

Speeds up untarring base.tgz on top of itself by a factor of about
2x, and speeds up rm by a factor of about 10x, on my system with an
SSD SLOG over SATA.  Histogram of unlink, rmdir, and rename timing
shows dramatic reduction in latency for most samples.

(To be fair, this was not an improvement over zfs; issuing the
unnecessary zil_commit was a self-inflicted performance wound.)


To generate a diff of this commit:
cvs rdiff -u -r1.50.2.6 -r1.50.2.7 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.50.2.6 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.50.2.7
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.50.2.6	Tue Feb 25 20:03:12 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Mon Mar  9 09:52:00 2020
@@ -5836,10 +5836,10 @@ zfs_netbsd_reclaim(void *v)
 			zp->z_atime_dirty = 0;
 			dmu_tx_commit(tx);
 		}
-	}
 
-	if (zfsvfs->z_log)
-		zil_commit(zfsvfs->z_log, zp->z_id);
+		if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
+			zil_commit(zfsvfs->z_log, zp->z_id);
+	}
 
 	if (zp->z_sa_hdl == NULL)
 		zfs_znode_free(zp);



CVS commit: [netbsd-8] src/doc

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 09:48:51 UTC 2020

Modified Files:
src/doc [netbsd-8]: CHANGES-8.2

Log Message:
Ticket #1519


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.105 -r1.1.2.106 src/doc/CHANGES-8.2

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

Modified files:

Index: src/doc/CHANGES-8.2
diff -u src/doc/CHANGES-8.2:1.1.2.105 src/doc/CHANGES-8.2:1.1.2.106
--- src/doc/CHANGES-8.2:1.1.2.105	Sun Mar  8 10:03:19 2020
+++ src/doc/CHANGES-8.2	Mon Mar  9 09:48:51 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.2,v 1.1.2.105 2020/03/08 10:03:19 martin Exp $
+# $NetBSD: CHANGES-8.2,v 1.1.2.106 2020/03/09 09:48:51 martin Exp $
 
 A complete list of changes from the NetBSD 8.1 release to the NetBSD 8.2
 release:
@@ -2126,3 +2126,9 @@ sys/arch/amigappc/include/bus_defs.h		1.
 	methods since we already define them anyway.
 	[is, ticket #1518]
 
+sys/arch/i386/stand/efiboot/eficons.c		1.10,1.11
+
+	PR 55000: if the default GOP mode is unavailable, fallback to the
+	first mode defined.
+	[nonaka, ticket #1519]
+



CVS commit: [netbsd-8] src/sys/arch/i386/stand/efiboot

2020-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  9 09:48:00 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot [netbsd-8]: eficons.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #1519):

sys/arch/i386/stand/efiboot/eficons.c: revision 1.10
sys/arch/i386/stand/efiboot/eficons.c: revision 1.11

If the default GOP mode is unavailable, fallback to the first mode defined.
PR# port-amd64/55000

Remove check for bestmode==-1 (shouldn't happen)


To generate a diff of this commit:
cvs rdiff -u -r1.4.2.5 -r1.4.2.6 src/sys/arch/i386/stand/efiboot/eficons.c

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

Modified files:

Index: src/sys/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.4.2.5 src/sys/arch/i386/stand/efiboot/eficons.c:1.4.2.6
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.4.2.5	Tue Feb 11 11:38:33 2020
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Mon Mar  9 09:48:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.4.2.5 2020/02/11 11:38:33 martin Exp $	*/
+/*	$NetBSD: eficons.c,v 1.4.2.6 2020/03/09 09:48:00 martin Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -37,6 +37,7 @@
 #ifndef DEFAULT_GOP_MODE
 #define DEFAULT_GOP_MODE	"1024x768"
 #endif
+#define FALLBACK_GOP_MODE	0
 
 extern struct x86_boot_params boot_params;
 
@@ -420,7 +421,7 @@ bi_framebuffer(void)
 	EFI_STATUS status;
 	EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
 	struct btinfo_framebuffer fb;
-	INT32 bestmode = -1;
+	INT32 bestmode;
 	UINTN sz;
 
 	if (efi_gop == NULL)
@@ -431,9 +432,9 @@ bi_framebuffer(void)
 	} else {
 		/* If a mode has not been selected, choose a default */
 		bestmode = efi_find_gop_mode(DEFAULT_GOP_MODE);
+		if (bestmode == -1)
+			bestmode = FALLBACK_GOP_MODE;
 	}
-	if (bestmode == -1)
-		goto nofb;
 
 	status = uefi_call_wrapper(efi_gop->SetMode, 2, efi_gop,
 	bestmode);



CVS commit: src/sys/dev

2020-03-09 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Mar  9 08:33:15 UTC 2020

Modified Files:
src/sys/dev: cgd.c cgdvar.h

Log Message:
Defer crypto operations to a workqueue and make it utilize all CPUs.
Make device mpsafe.
Some code cleanup.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/dev/cgd.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/cgdvar.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/cgd.c
diff -u src/sys/dev/cgd.c:1.121 src/sys/dev/cgd.c:1.122
--- src/sys/dev/cgd.c:1.121	Mon Mar  2 16:01:56 2020
+++ src/sys/dev/cgd.c	Mon Mar  9 08:33:15 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.121 2020/03/02 16:01:56 riastradh Exp $ */
+/* $NetBSD: cgd.c,v 1.122 2020/03/09 08:33:15 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.121 2020/03/02 16:01:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.122 2020/03/09 08:33:15 mlelstv Exp $");
 
 #include 
 #include 
@@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.12
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -51,6 +52,8 @@ __KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.12
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -90,7 +93,7 @@ const struct bdevsw cgd_bdevsw = {
 	.d_dump = cgddump,
 	.d_psize = cgdsize,
 	.d_discard = nodiscard,
-	.d_flag = D_DISK
+	.d_flag = D_DISK | D_MPSAFE
 };
 
 const struct cdevsw cgd_cdevsw = {
@@ -105,7 +108,7 @@ const struct cdevsw cgd_cdevsw = {
 	.d_mmap = nommap,
 	.d_kqfilter = nokqfilter,
 	.d_discard = nodiscard,
-	.d_flag = D_DISK
+	.d_flag = D_DISK | D_MPSAFE
 };
 
 /*
@@ -207,12 +210,20 @@ static int cgd_match(device_t, cfdata_t,
 static void cgd_attach(device_t, device_t, void *);
 static int cgd_detach(device_t, int);
 static struct cgd_softc	*cgd_spawn(int);
+static struct cgd_worker *cgd_create_one_worker(void);
+static void cgd_destroy_one_worker(struct cgd_worker *);
+static struct cgd_worker *cgd_create_worker(void);
+static void cgd_destroy_worker(struct cgd_worker *);
 static int cgd_destroy(device_t);
 
 /* Internal Functions */
 
 static int	cgd_diskstart(device_t, struct buf *);
+static void	cgd_diskstart2(struct cgd_softc *, struct cgd_xfer *);
 static void	cgdiodone(struct buf *);
+static void	cgd_iodone2(struct cgd_softc *, struct cgd_xfer *);
+static void	cgd_enqueue(struct cgd_softc *, struct cgd_xfer *);
+static void	cgd_process(struct work *, void *);
 static int	cgd_dumpblocks(device_t, void *, daddr_t, int);
 
 static int	cgd_ioctl_set(struct cgd_softc *, void *, struct lwp *);
@@ -264,25 +275,49 @@ static void	hexprint(const char *, void 
 
 /* Global variables */
 
+static kmutex_t cgd_spawning_mtx;
+static kcondvar_t cgd_spawning_cv;
+static bool cgd_spawning;
+static struct cgd_worker *cgd_worker;
+static u_int cgd_refcnt;	/* number of users of cgd_worker */
+
 /* Utility Functions */
 
 #define CGDUNIT(x)		DISKUNIT(x)
-#define GETCGD_SOFTC(_cs, x)	if (!((_cs) = getcgd_softc(x))) return ENXIO
 
 /* The code */
 
-static struct cgd_softc *
-getcgd_softc(dev_t dev)
+static int
+cgd_lock(bool intr)
 {
-	int	unit = CGDUNIT(dev);
-	struct cgd_softc *sc;
+	int error = 0;
 
-	DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit));
+	mutex_enter(_spawning_mtx);
+	while (cgd_spawning) {
+		if (intr)
+			error = cv_wait_sig(_spawning_cv, _spawning_mtx);
+		else
+			cv_wait(_spawning_cv, _spawning_mtx);
+	}
+	if (error == 0)
+		cgd_spawning = true;
+	mutex_exit(_spawning_mtx);
+	return error;
+}
 
-	sc = device_lookup_private(_cd, unit);
-	if (sc == NULL)
-		sc = cgd_spawn(unit);
-	return sc;
+static void
+cgd_unlock(void)
+{
+	mutex_enter(_spawning_mtx);
+	cgd_spawning = false;
+	cv_broadcast(_spawning_cv);
+	mutex_exit(_spawning_mtx);
+}
+
+static struct cgd_softc *
+getcgd_softc(dev_t dev)
+{
+	return device_lookup_private(_cd, CGDUNIT(dev));
 }
 
 static int
@@ -298,6 +333,7 @@ cgd_attach(device_t parent, device_t sel
 	struct cgd_softc *sc = device_private(self);
 
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_BIO);
+	cv_init(>sc_cv, "cgdcv");
 	dk_init(>sc_dksc, self, DKTYPE_CGD);
 	disk_init(>sc_dksc.sc_dkdev, sc->sc_dksc.sc_xname, );
 
@@ -323,6 +359,7 @@ cgd_detach(device_t self, int flags)
 		return ret;
 
 	disk_destroy(>sc_dkdev);
+	cv_destroy(>sc_cv);
 	mutex_destroy(>sc_lock);
 
 	return 0;
@@ -331,89 +368,224 @@ cgd_detach(device_t self, int flags)
 void
 cgdattach(int num)
 {
+#ifndef _MODULE
 	int error;
 
+	mutex_init(_spawning_mtx, MUTEX_DEFAULT, IPL_NONE);
+	cv_init(_spawning_cv, "cgspwn");
+
 	error = config_cfattach_attach(cgd_cd.cd_name, _ca);
 	if (error != 0)
 		aprint_error("%s: unable to register cfattach\n",
 		cgd_cd.cd_name);
+#endif
 }
 
 static struct cgd_softc *
 cgd_spawn(int unit)
 {
 	cfdata_t cf;
+	struct cgd_worker *cw;
+	struct 

CVS commit: src/common/lib/libc/arch/m68k/gen

2020-03-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Mar  9 08:29:12 UTC 2020

Modified Files:
src/common/lib/libc/arch/m68k/gen: mulsi3.S

Log Message:
Remove wrong comment (copy-paste from somewhere);
__mulsi3 does not depend on __udivsi3.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/m68k/gen/mulsi3.S

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

Modified files:

Index: src/common/lib/libc/arch/m68k/gen/mulsi3.S
diff -u src/common/lib/libc/arch/m68k/gen/mulsi3.S:1.4 src/common/lib/libc/arch/m68k/gen/mulsi3.S:1.5
--- src/common/lib/libc/arch/m68k/gen/mulsi3.S:1.4	Tue Jul 16 23:24:18 2013
+++ src/common/lib/libc/arch/m68k/gen/mulsi3.S	Mon Mar  9 08:29:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mulsi3.S,v 1.4 2013/07/16 23:24:18 matt Exp $	*/
+/*	$NetBSD: mulsi3.S,v 1.5 2020/03/09 08:29:11 rin Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -39,7 +39,7 @@
 #if 0
 	RCSID("from: @(#)mulsi3.s	5.1 (Berkeley) 6/7/90")
 #else
-	RCSID("$NetBSD: mulsi3.S,v 1.4 2013/07/16 23:24:18 matt Exp $")
+	RCSID("$NetBSD: mulsi3.S,v 1.5 2020/03/09 08:29:11 rin Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -49,8 +49,6 @@ ENTRY(__mulsi3)
 	movel	4(%sp),%d0
 	mulsl	8(%sp),%d0
 #else
-| NB: this requires that __udivsi3 preserve %a0 and return
-| the modulus in %d1:
 	movew	6(%sp), %d0
 	movel	%d0, %a0	| save B
 	muluw	8(%sp), %d0	| %d0 holds B * C