CVS commit: src/sys/dev/pci

2020-01-16 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Jan 17 05:22:42 UTC 2020

Modified Files:
src/sys/dev/pci: files.pci if_aq.c

Log Message:
support internal PHY temperature sensor


To generate a diff of this commit:
cvs rdiff -u -r1.420 -r1.421 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/if_aq.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/files.pci
diff -u src/sys/dev/pci/files.pci:1.420 src/sys/dev/pci/files.pci:1.421
--- src/sys/dev/pci/files.pci:1.420	Thu Jan 16 07:11:50 2020
+++ src/sys/dev/pci/files.pci	Fri Jan 17 05:22:42 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.420 2020/01/16 07:11:50 yamaguchi Exp $
+#	$NetBSD: files.pci,v 1.421 2020/01/17 05:22:42 ryo Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -168,7 +168,7 @@ attach	mpii at pci
 file	dev/pci/mpii.c			mpii
 
 # Aquantia/Atlantic 10-Gigabit Ethernet
-device	aq: ether, ifnet, arp
+device	aq: ether, ifnet, arp, sysmon_envsys
 attach	aq at pci
 file	dev/pci/if_aq.c			aq
 defflag opt_if_aq.h	AQ_EVENT_COUNTERS

Index: src/sys/dev/pci/if_aq.c
diff -u src/sys/dev/pci/if_aq.c:1.3 src/sys/dev/pci/if_aq.c:1.4
--- src/sys/dev/pci/if_aq.c:1.3	Fri Jan 17 05:16:33 2020
+++ src/sys/dev/pci/if_aq.c	Fri Jan 17 05:22:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_aq.c,v 1.3 2020/01/17 05:16:33 ryo Exp $	*/
+/*	$NetBSD: if_aq.c,v 1.4 2020/01/17 05:22:42 ryo Exp $	*/
 
 /**
  * aQuantia Corporation Network Driver
@@ -62,10 +62,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.3 2020/01/17 05:16:33 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.4 2020/01/17 05:22:42 ryo Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_if_aq.h"
+#include "sysmon_envsys.h"
 #endif
 
 #include 
@@ -87,6 +88,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.
 #include 
 #include 
 #include 
+#include 
 
 /* driver configuration */
 #define CONFIG_INTR_MODERATION_ENABLE	true	/* delayed interrupt */
@@ -710,11 +712,14 @@ typedef struct fw2x_capabilities {
 typedef struct fw2x_mailbox {		/* struct fwHostInterface */
 	aq_mailbox_header_t header;
 	fw2x_msm_statistics_t msm;	/* msmStatistics_t msm; */
-	uint16_t phy_h_bit;
-	uint16_t phy_fault_code;
-	int16_t phy_temperature;
-	uint8_t cable_len;
-	uint8_t reserved1;
+
+	uint32_t phy_info1;
+#define PHYINFO1_FAULT_CODE	__BITS(31,16)
+#define PHYINFO1_PHY_H_BIT	__BITS(0,15)
+	uint32_t phy_info2;
+#define PHYINFO2_TEMPERATURE	__BITS(15,0)
+#define PHYINFO2_CABLE_LEN	__BITS(23,16)
+
 	fw2x_phy_cable_diag_data_t diag_data;
 	uint32_t reserved[8];
 
@@ -907,6 +912,9 @@ struct aq_firmware_ops {
 	int (*get_mode)(struct aq_softc *, aq_hw_fw_mpi_state_t *,
 	aq_link_speed_t *, aq_link_fc_t *, aq_link_eee_t *);
 	int (*get_stats)(struct aq_softc *, aq_hw_stats_s_t *);
+#if NSYSMON_ENVSYS > 0
+	int (*get_temperature)(struct aq_softc *, uint32_t *);
+#endif
 };
 
 #ifdef AQ_EVENT_COUNTERS
@@ -933,6 +941,11 @@ struct aq_firmware_ops {
 #define AQ_LOCK(sc)		mutex_enter(&(sc)->sc_mutex);
 #define AQ_UNLOCK(sc)		mutex_exit(&(sc)->sc_mutex);
 
+/* lock for FW2X_MPI_{CONTROL,STATE]_REG read-modify-write */
+#define AQ_MPI_LOCK(sc)		mutex_enter(&(sc)->sc_mpi_mutex);
+#define AQ_MPI_UNLOCK(sc)	mutex_exit(&(sc)->sc_mpi_mutex);
+
+
 struct aq_softc {
 	device_t sc_dev;
 
@@ -951,6 +964,11 @@ struct aq_softc {
 	bool sc_poll_linkstat;
 	bool sc_detect_linkstat;
 
+#if NSYSMON_ENVSYS > 0
+	struct sysmon_envsys *sc_sme;
+	envsys_data_t sc_sensor_temp;
+#endif
+
 	callout_t sc_tick_ch;
 
 	int sc_nintrs;
@@ -965,6 +983,7 @@ struct aq_softc {
 	uint16_t sc_revision;
 
 	kmutex_t sc_mutex;
+	kmutex_t sc_mpi_mutex;
 
 	struct aq_firmware_ops *sc_fw_ops;
 	uint64_t sc_fw_caps;
@@ -1063,6 +1082,9 @@ static void aq_tx_pcq_free(struct aq_sof
 static void aq_initmedia(struct aq_softc *);
 static void aq_enable_intr(struct aq_softc *, bool, bool);
 
+#if NSYSMON_ENVSYS > 0
+static void aq_temp_refresh(struct sysmon_envsys *, envsys_data_t *);
+#endif
 static void aq_tick(void *);
 static int aq_legacy_intr(void *);
 static int aq_link_intr(void *);
@@ -1099,19 +1121,28 @@ static int fw2x_set_mode(struct aq_softc
 static int fw2x_get_mode(struct aq_softc *, aq_hw_fw_mpi_state_t *,
 aq_link_speed_t *, aq_link_fc_t *, aq_link_eee_t *);
 static int fw2x_get_stats(struct aq_softc *, aq_hw_stats_s_t *);
+#if NSYSMON_ENVSYS > 0
+static int fw2x_get_temperature(struct aq_softc *, uint32_t *);
+#endif
 
 static struct aq_firmware_ops aq_fw1x_ops = {
 	.reset = fw1x_reset,
 	.set_mode = fw1x_set_mode,
 	.get_mode = fw1x_get_mode,
-	.get_stats = fw1x_get_stats
+	.get_stats = fw1x_get_stats,
+#if NSYSMON_ENVSYS > 0
+	.get_temperature = NULL
+#endif
 };
 
 static struct aq_firmware_ops aq_fw2x_ops = {
 	.reset = fw2x_reset,
 	.set_mode = fw2x_set_mode,
 	.get_mode = fw2x_get_mode,
-	.get_stats = fw2x_get_stats
+	

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

2020-01-16 Thread John Klos
Module Name:src
Committed By:   jklos
Date:   Fri Jan 17 05:20:21 UTC 2020

Modified Files:
src/sys/arch/evbarm/conf: POGO

Log Message:
Remove npf in POGO because it's now in SHEEVAPLUG.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbarm/conf/POGO

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/evbarm/conf/POGO
diff -u src/sys/arch/evbarm/conf/POGO:1.5 src/sys/arch/evbarm/conf/POGO:1.6
--- src/sys/arch/evbarm/conf/POGO:1.5	Wed Aug  1 20:04:11 2018
+++ src/sys/arch/evbarm/conf/POGO	Fri Jan 17 05:20:21 2020
@@ -36,20 +36,16 @@ no audio*
 no spkr* at audio?
 no config netbsd
 
-# Use ld0a for SD slot in Mobile and v4 or sd0a for USB disk
-config netbsd root on ld0a type ffs
+# Use ld0 for SD slot in Mobile and v4 or sd0 for USB disk
+config netbsd root on ld0a type ?
 
 # Uncomment these for PogoPlug v4. Note that MVSDIO_MAX_CLOCK is mandatory
-options 	MVSDIO_MAX_CLOCK="(19 * 1000)"
-xhci*		at pci? dev ? function ?	# eXtensible Host Controller
-usb*		at xhci?
+#options 	MVSDIO_MAX_CLOCK="(19 * 1000)"
+#xhci*		at pci? dev ? function ?	# eXtensible Host Controller
+#usb*		at xhci?
 
-options	GATEWAY		# packet forwarding
+options 	GATEWAY			# packet forwarding
 
-# Uncomment for npf
-pseudo-device		npf			# NPF packet filter
-options 		BPFJIT
-
-pseudo-device		tun			# network tunneling over tty
-pseudo-device		gre			# generic L3 over IP tunnel
-pseudo-device		gif			# IPv[46] over IPv[46] tunnel (RFC 1933)
+pseudo-device	tun			# network tunneling over tty
+pseudo-device	gre			# generic L3 over IP tunnel
+pseudo-device	gif			# IPv[46] over IPv[46] tunnel (RFC 1933)



CVS commit: src/sys/dev/pci

2020-01-16 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Jan 17 05:16:33 UTC 2020

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

Log Message:
make counters per queue


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/if_aq.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_aq.c
diff -u src/sys/dev/pci/if_aq.c:1.2 src/sys/dev/pci/if_aq.c:1.3
--- src/sys/dev/pci/if_aq.c:1.2	Fri Jan 17 05:11:04 2020
+++ src/sys/dev/pci/if_aq.c	Fri Jan 17 05:16:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_aq.c,v 1.2 2020/01/17 05:11:04 ryo Exp $	*/
+/*	$NetBSD: if_aq.c,v 1.3 2020/01/17 05:16:33 ryo Exp $	*/
 
 /**
  * aQuantia Corporation Network Driver
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.2 2020/01/17 05:11:04 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.3 2020/01/17 05:16:33 ryo Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_if_aq.h"
@@ -862,6 +862,12 @@ struct aq_txring {
 	unsigned int txr_prodidx;
 	unsigned int txr_considx;
 	int txr_nfree;
+
+	/* counters */
+	uint64_t txr_opackets;
+	uint64_t txr_obytes;
+	uint64_t txr_omcasts;
+	uint64_t txr_oerrors;
 };
 
 struct aq_rxring {
@@ -879,6 +885,12 @@ struct aq_rxring {
 		bus_dmamap_t dmamap;
 	} rxr_mbufs[AQ_RXD_NUM];
 	unsigned int rxr_readidx;
+
+	/* counters */
+	uint64_t rxr_ipackets;
+	uint64_t rxr_ibytes;
+	uint64_t rxr_ierrors;
+	uint64_t rxr_iqdrops;
 };
 
 struct aq_queue {
@@ -4015,6 +4027,7 @@ aq_tx_intr(void *arg)
 	struct aq_txring *txring = arg;
 	struct aq_softc *sc = txring->txr_sc;
 	struct ifnet *ifp = >sc_ethercom.ec_if;
+	struct mbuf *m;
 	const int ringidx = txring->txr_index;
 	unsigned int idx, hw_head, n = 0;
 
@@ -4032,12 +4045,17 @@ aq_tx_intr(void *arg)
 	for (idx = txring->txr_considx; idx != hw_head;
 	idx = TXRING_NEXTIDX(idx), n++) {
 
-		if (txring->txr_mbufs[idx].m != NULL) {
+		if ((m = txring->txr_mbufs[idx].m) != NULL) {
 			bus_dmamap_unload(sc->sc_dmat,
 			txring->txr_mbufs[idx].dmamap);
-			m_freem(txring->txr_mbufs[idx].m);
+
+			txring->txr_opackets++;
+			txring->txr_obytes += m->m_pkthdr.len;
+			if (m->m_flags & M_MCAST)
+txring->txr_omcasts++;
+
+			m_freem(m);
 			txring->txr_mbufs[idx].m = NULL;
-			ifp->if_opackets++;
 		}
 
 		txring->txr_nfree++;
@@ -4105,7 +4123,7 @@ aq_rx_intr(void *arg)
 
 		if ((rxd_status & RXDESC_STATUS_MACERR) ||
 		(rxd_type & RXDESC_TYPE_MAC_DMA_ERR)) {
-			ifp->if_ierrors++;
+			rxring->rxr_ierrors++;
 			goto rx_next;
 		}
 
@@ -4120,6 +4138,7 @@ aq_rx_intr(void *arg)
 			 * cannot allocate new mbuf.
 			 * discard this packet, and reuse mbuf for next.
 			 */
+			rxring->rxr_iqdrops++;
 			goto rx_next;
 		}
 		rxring->rxr_mbufs[idx].m = NULL;
@@ -4220,10 +4239,10 @@ aq_rx_intr(void *arg)
 }
 			}
 #endif
-
 			m_set_rcvif(m0, ifp);
+			rxring->rxr_ipackets++;
+			rxring->rxr_ibytes += m0->m_pkthdr.len;
 			if_percpuq_enqueue(ifp->if_percpuq, m0);
-
 			m0 = mprev = NULL;
 		}
 
@@ -4361,7 +4380,7 @@ aq_send_common_locked(struct ifnet *ifp,
 		if (error != 0) {
 			/* too many mbuf chains? or not enough descriptors? */
 			m_freem(m);
-			ifp->if_oerrors++;
+			txring->txr_oerrors++;
 			if (txring->txr_index == 0 && error == ENOBUFS)
 ifp->if_flags |= IFF_OACTIVE;
 			break;
@@ -4518,12 +4537,61 @@ aq_ioctl(struct ifnet *ifp, unsigned lon
 {
 	struct aq_softc *sc __unused;
 	struct ifreq *ifr __unused;
-	int error, s;
+	uint64_t opackets, oerrors, obytes, omcasts;
+	uint64_t ipackets, ierrors, ibytes, iqdrops;
+	int error, i, s;
 
 	sc = (struct aq_softc *)ifp->if_softc;
 	ifr = (struct ifreq *)data;
 	error = 0;
 
+	switch (cmd) {
+	case SIOCGIFDATA:
+	case SIOCZIFDATA:
+		opackets = oerrors = obytes = omcasts = 0;
+		ipackets = ierrors = ibytes = iqdrops = 0;
+		for (i = 0; i < sc->sc_nqueues; i++) {
+			struct aq_txring *txring = >sc_queue[i].txring;
+			mutex_enter(>txr_mutex);
+			if (cmd == SIOCZIFDATA) {
+txring->txr_opackets = 0;
+txring->txr_obytes = 0;
+txring->txr_omcasts = 0;
+txring->txr_oerrors = 0;
+			} else {
+opackets += txring->txr_opackets;
+oerrors += txring->txr_oerrors;
+obytes += txring->txr_obytes;
+omcasts += txring->txr_omcasts;
+			}
+			mutex_exit(>txr_mutex);
+
+			struct aq_rxring *rxring = >sc_queue[i].rxring;
+			mutex_enter(>rxr_mutex);
+			if (cmd == SIOCZIFDATA) {
+rxring->rxr_ipackets = 0;
+rxring->rxr_ibytes = 0;
+rxring->rxr_ierrors = 0;
+rxring->rxr_iqdrops = 0;
+			} else {
+ipackets += rxring->rxr_ipackets;
+ierrors += rxring->rxr_ierrors;
+ibytes += rxring->rxr_ibytes;
+iqdrops += rxring->rxr_iqdrops;
+			}
+			mutex_exit(>rxr_mutex);
+		}
+		ifp->if_opackets = opackets;
+		ifp->if_oerrors = oerrors;
+		ifp->if_obytes = obytes;
+		ifp->if_omcasts = omcasts;
+		ifp->if_ipackets = ipackets;
+		ifp->if_ierrors = ierrors;
+		ifp->if_ibytes = ibytes;
+		ifp->if_iqdrops = iqdrops;
+		

CVS commit: src/sys/dev/pci

2020-01-16 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Jan 17 05:11:04 UTC 2020

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

Log Message:
set/clear IFF_OACTIVE flag only on txring 0


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/if_aq.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_aq.c
diff -u src/sys/dev/pci/if_aq.c:1.1 src/sys/dev/pci/if_aq.c:1.2
--- src/sys/dev/pci/if_aq.c:1.1	Wed Jan  1 10:11:21 2020
+++ src/sys/dev/pci/if_aq.c	Fri Jan 17 05:11:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_aq.c,v 1.1 2020/01/01 10:11:21 ryo Exp $	*/
+/*	$NetBSD: if_aq.c,v 1.2 2020/01/17 05:11:04 ryo Exp $	*/
 
 /**
  * aQuantia Corporation Network Driver
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.1 2020/01/01 10:11:21 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.2 2020/01/17 05:11:04 ryo Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_if_aq.h"
@@ -4362,7 +4362,7 @@ aq_send_common_locked(struct ifnet *ifp,
 			/* too many mbuf chains? or not enough descriptors? */
 			m_freem(m);
 			ifp->if_oerrors++;
-			if (error == ENOBUFS)
+			if (txring->txr_index == 0 && error == ENOBUFS)
 ifp->if_flags |= IFF_OACTIVE;
 			break;
 		}
@@ -4375,7 +4375,7 @@ aq_send_common_locked(struct ifnet *ifp,
 		bpf_mtap(ifp, m, BPF_D_OUT);
 	}
 
-	if (!is_transmit && txring->txr_nfree < AQ_TXD_MIN)
+	if (txring->txr_index == 0 && txring->txr_nfree < AQ_TXD_MIN)
 		ifp->if_flags |= IFF_OACTIVE;
 
 	if (npkt)



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

2020-01-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jan 17 04:48:21 UTC 2020

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

Log Message:
 Add Fast Short Rep Mov(fsrm).


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x86/x86/procfs_machdep.c

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

Modified files:

Index: src/sys/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.34 src/sys/arch/x86/x86/procfs_machdep.c:1.35
--- src/sys/arch/x86/x86/procfs_machdep.c:1.34	Thu Oct 17 06:58:48 2019
+++ src/sys/arch/x86/x86/procfs_machdep.c	Fri Jan 17 04:48:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.34 2019/10/17 06:58:48 msaitoh Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.35 2020/01/17 04:48:21 msaitoh Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.34 2019/10/17 06:58:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.35 2020/01/17 04:48:21 msaitoh Exp $");
 
 #include 
 #include 
@@ -188,7 +188,7 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (18) Intel 0x0007 edx */
-	NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", NULL, NULL, NULL, NULL,
+	NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", "fsrm", NULL, NULL, NULL,
 	NULL, NULL, "md_clear", NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, "pconfig", NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL,



CVS commit: src/sys/dev/pci

2020-01-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jan 17 02:08:26 UTC 2020

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

Log Message:
 Fix a bug that the virtual channel extended configuraton's arbitration phase
register can't be decoded correcty. Found by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.219 src/sys/dev/pci/pci_subr.c

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

Modified files:

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.218 src/sys/dev/pci/pci_subr.c:1.219
--- src/sys/dev/pci/pci_subr.c:1.218	Wed Dec 11 07:33:55 2019
+++ src/sys/dev/pci/pci_subr.c	Fri Jan 17 02:08:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.218 2019/12/11 07:33:55 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.219 2020/01/17 02:08:25 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.218 2019/12/11 07:33:55 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.219 2020/01/17 02:08:25 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -2864,36 +2864,42 @@ pci_conf_print_aer_cap(const pcireg_t *r
 	}
 }
 
+/*
+ * Helper function to print the arbitration phase register.
+ *
+ * phases: Number of phases in the arbitration tables.
+ * arbsize: Number of bits in each phase.
+ * indent: Add more two spaces if it's true.
+ */
 static void
 pci_conf_print_vc_cap_arbtab(const pcireg_t *regs, int off, const char *name,
-pcireg_t parbsel, int parbsize)
+const int phases, int arbsize, bool indent)
 {
 	pcireg_t reg;
-	int num = 16 << parbsel;
-	int num_per_reg = sizeof(pcireg_t) / parbsize;
+	int num_per_reg = 32 / arbsize;
 	int i, j;
 
-	/* First, dump the table */
-	for (i = 0; i < num; i += num_per_reg) {
-		reg = regs[o2i(off + i / num_per_reg)];
-		printf("%s Arbitration Table: 0x%08x\n", name, reg);
-	}
-	/* And then, decode each entry */
-	for (i = 0; i < num; i += num_per_reg) {
-		reg = regs[o2i(off + i / num_per_reg)];
-		for (j = 0; j < num_per_reg; j++)
-			printf("  Phase[%d]: %d\n", j, reg);
+	printf("%s%s Arbitration Table:\n", indent ? "  " : "", name);
+	for (i = 0; i < phases; i += num_per_reg) {
+		reg = regs[o2i(off + (sizeof(uint32_t) * (i / num_per_reg)))];
+		for (j = 0; j < num_per_reg; j++) {
+			printf("%s  Phase[%d]: 0x%x\n", indent ? "  " : "",
+			i + j,
+			(uint32_t)(reg & __BITS(arbsize - 1, 0)));
+			reg >>= arbsize;
+		}
 	}
 }
 
+/* For VC, bit 4-7 are reserved. For Port, bit 6-7 are reserved */
+static const int arb_phases[8] = {0, 32, 64, 128, 128, 256, 0, 0 };
+
 static void
 pci_conf_print_vc_cap(const pcireg_t *regs, int extcapoff)
 {
 	pcireg_t reg, n;
-	int parbtab, parbsize;
-	pcireg_t parbsel;
-	int varbtab, varbsize;
-	pcireg_t varbsel;
+	int arbtab, parbsize;
+	pcireg_t arbsel;
 	int i, count;
 
 	printf("\n  Virtual Channel Register\n");
@@ -2919,19 +2925,23 @@ pci_conf_print_vc_cap(const pcireg_t *re
 	reg, PCI_VC_CAP2_ARB_CAP_WRR_64);
 	onoff("WRR arbitration with 128 phases",
 	reg, PCI_VC_CAP2_ARB_CAP_WRR_128);
-	varbtab = __SHIFTOUT(reg, PCI_VC_CAP2_ARB_TABLE_OFFSET);
-	printf("  VC Arbitration Table Offset: 0x%x\n", varbtab);
+	arbtab = __SHIFTOUT(reg, PCI_VC_CAP2_ARB_TABLE_OFFSET);
+	printf("  VC Arbitration Table Offset: 0x%x\n", arbtab);
 
 	reg = regs[o2i(extcapoff + PCI_VC_CONTROL)] & 0x;
 	printf("Port VC Control register: 0x%04x\n", reg);
-	varbsel = __SHIFTOUT(reg, PCI_VC_CONTROL_VC_ARB_SELECT);
-	printf("  VC Arbitration Select: 0x%x\n", varbsel);
+	arbsel = __SHIFTOUT(reg, PCI_VC_CONTROL_VC_ARB_SELECT);
+	printf("  VC Arbitration Select: 0x%x\n", arbsel);
 
 	reg = regs[o2i(extcapoff + PCI_VC_STATUS)] >> 16;
 	printf("Port VC Status register: 0x%04x\n", reg);
 	onoff("VC Arbitration Table Status",
 	reg, PCI_VC_STATUS_LOAD_VC_ARB_TABLE);
 
+	if ((arbtab != 0) && (arbsel != 0))
+		pci_conf_print_vc_cap_arbtab(regs, extcapoff + (arbtab * 16),
+		"VC", arb_phases[arbsel], 4, false);
+
 	for (i = 0; i < count + 1; i++) {
 		reg = regs[o2i(extcapoff + PCI_VC_RESOURCE_CAP(i))];
 		printf("VC number %d\n", i);
@@ -2954,9 +2964,10 @@ pci_conf_print_vc_cap(const pcireg_t *re
 		reg, PCI_VC_RESOURCE_CAP_REJCT_SNOOP_TRANS);
 		n = __SHIFTOUT(reg, PCI_VC_RESOURCE_CAP_MAX_TIME_SLOTS) + 1;
 		printf("Maximum Time Slots: %d\n", n);
-		parbtab = reg >> PCI_VC_RESOURCE_CAP_PORT_ARB_TABLE_OFFSET_S;
+		arbtab = __SHIFTOUT(reg,
+		PCI_VC_RESOURCE_CAP_PORT_ARB_TABLE_OFFSET);
 		printf("Port Arbitration Table offset: 0x%02x\n",
-		parbtab);
+		arbtab);
 
 		reg = regs[o2i(extcapoff + PCI_VC_RESOURCE_CTL(i))];
 		printf("  VC Resource Control Register: 0x%08x\n", reg);
@@ -2967,8 +2978,8 @@ pci_conf_print_vc_cap(const pcireg_t *re
 		 * the Port Arbitration logic and it's always 0 on read, so
 		 * we 

CVS commit: src/external/bsd/libarchive

2020-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 17 00:39:27 UTC 2020

Modified Files:
src/external/bsd/libarchive: prepare-import.sh

Log Message:
Don't remove the test harness utilities (the tests were not removed already
which is the majority of the files), we can use them for atf now.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/libarchive/prepare-import.sh

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/libarchive/prepare-import.sh
diff -u src/external/bsd/libarchive/prepare-import.sh:1.4 src/external/bsd/libarchive/prepare-import.sh:1.5
--- src/external/bsd/libarchive/prepare-import.sh:1.4	Wed Jul 24 10:07:17 2019
+++ src/external/bsd/libarchive/prepare-import.sh	Thu Jan 16 19:39:27 2020
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: prepare-import.sh,v 1.4 2019/07/24 14:07:17 joerg Exp $
+# $NetBSD: prepare-import.sh,v 1.5 2020/01/17 00:39:27 christos Exp $
 #
 # Extract the new tarball and rename the libarchive-X.Y.Z directory
 # to dist.  Run this script and check for additional files and
@@ -9,7 +9,7 @@ set -e
 
 cd dist
 
-rm -rf build contrib doc examples test_utils autom4te.cache
+rm -rf build contrib doc examples autom4te.cache
 rm -f INSTALL Makefile.am Makefile.in aclocal.m4 config.h.in
 rm -f configure configure.ac CMakeLists.txt */CMakeLists.txt */*/CMakeLists.txt
 rm -f */config_freebsd.h  CTestConfig.cmake .gitattributes .gitignore



CVS commit: src/external/bsd/libarchive/dist/test_utils

2020-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 17 00:38:19 UTC 2020

Added Files:
src/external/bsd/libarchive/dist/test_utils: test_common.h test_main.c
test_utils.c test_utils.h

Log Message:
Add back the test harness


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
src/external/bsd/libarchive/dist/test_utils/test_common.h \
src/external/bsd/libarchive/dist/test_utils/test_main.c \
src/external/bsd/libarchive/dist/test_utils/test_utils.c \
src/external/bsd/libarchive/dist/test_utils/test_utils.h

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

Added files:

Index: src/external/bsd/libarchive/dist/test_utils/test_common.h
diff -u /dev/null src/external/bsd/libarchive/dist/test_utils/test_common.h:1.1
--- /dev/null	Thu Jan 16 19:38:19 2020
+++ src/external/bsd/libarchive/dist/test_utils/test_common.h	Thu Jan 16 19:38:19 2020
@@ -0,0 +1,457 @@
+/*
+ * Copyright (c) 2003-2017 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef	TEST_COMMON_H
+#define	TEST_COMMON_H
+
+/*
+ * The goal of this file (and the matching test.c) is to
+ * simplify the very repetitive test-*.c test programs.
+ */
+#if defined(HAVE_CONFIG_H)
+/* Most POSIX platforms use the 'configure' script to build config.h */
+#include "config.h"
+#elif defined(__FreeBSD__)
+/* Building as part of FreeBSD system requires a pre-built config.h. */
+#include "config_freebsd.h"
+#elif defined(__NetBSD__)
+/* Building as part of NetBSD system requires a pre-built config.h. */
+#include "config_netbsd.h"
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+/* Win32 can't run the 'configure' script. */
+#include "config_windows.h"
+#else
+/* Warn if the library hasn't been (automatically or manually) configured. */
+#error Oops: No config.h and no pre-built configuration in test.h.
+#endif
+
+#include   /* Windows requires this before sys/stat.h */
+#include 
+
+#if HAVE_DIRENT_H
+#include 
+#endif
+#ifdef HAVE_DIRECT_H
+#include 
+#define dirent direct
+#endif
+#include 
+#include 
+#ifdef HAVE_IO_H
+#include 
+#endif
+#ifdef HAVE_STDINT_H
+#include 
+#endif
+#include 
+#include 
+#include 
+#include 
+#include 
+#ifdef HAVE_UNISTD_H
+#include 
+#endif
+#include 
+#ifdef HAVE_ACL_LIBACL_H
+#include 
+#endif
+#ifdef HAVE_SYS_ACL_H
+#include 
+#endif
+#ifdef HAVE_SYS_RICHACL_H
+#include 
+#endif
+#ifdef HAVE_WINDOWS_H
+#define NOCRYPT
+#include 
+#include 
+#endif
+
+/*
+ * System-specific tweaks.  We really want to minimize these
+ * as much as possible, since they make it harder to understand
+ * the mainline code.
+ */
+
+/* Windows (including Visual Studio and MinGW but not Cygwin) */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#if !defined(__BORLANDC__)
+#undef chdir
+#define chdir _chdir
+#define strdup _strdup
+#endif
+#endif
+
+/* Visual Studio */
+#if defined(_MSC_VER) && _MSC_VER < 1900
+#define snprintf	sprintf_s
+#endif
+
+#if defined(__BORLANDC__)
+#pragma warn -8068	/* Constant out of range in comparison. */
+#endif
+
+/* Haiku OS and QNX */
+#if defined(__HAIKU__) || defined(__QNXNTO__)
+/* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */
+#include 
+#endif
+
+/* Get a real definition for __FBSDID if we can */
+#if HAVE_SYS_CDEFS_H
+#include 
+#endif
+
+/* If not, define it so as to avoid dangling semicolons. */
+#ifndef __FBSDID
+#define	__FBSDID(a) struct _undefined_hack
+#endif
+
+#ifndef O_BINARY
+#define	O_BINARY 0
+#endif
+
+#ifndef __LIBARCHIVE_TEST_COMMON
+#define __LIBARCHIVE_TEST_COMMON
+#endif
+
+#include "archive_platform_acl.h"
+#define	ARCHIVE_TEST_ACL_TYPE_POSIX1E	1
+#define	ARCHIVE_TEST_ACL_TYPE_NFS4	2
+

CVS commit: src/external/bsd/libarchive/dist/libarchive/test

2020-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 17 00:37:26 UTC 2020

Modified Files:
src/external/bsd/libarchive/dist/libarchive/test:
test_archive_write_set_format_filter_by_ext.c
test_read_format_7zip.c test_sparse_basic.c
test_write_format_zip_file.c test_write_format_zip_file_zip64.c

Log Message:
make things compile (pullup merged)


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \

src/external/bsd/libarchive/dist/libarchive/test/test_archive_write_set_format_filter_by_ext.c
 \
src/external/bsd/libarchive/dist/libarchive/test/test_read_format_7zip.c \

src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file.c \

src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file_zip64.c
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/external/bsd/libarchive/dist/libarchive/test/test_sparse_basic.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/bsd/libarchive/dist/libarchive/test/test_archive_write_set_format_filter_by_ext.c
diff -u src/external/bsd/libarchive/dist/libarchive/test/test_archive_write_set_format_filter_by_ext.c:1.1.1.1 src/external/bsd/libarchive/dist/libarchive/test/test_archive_write_set_format_filter_by_ext.c:1.2
--- src/external/bsd/libarchive/dist/libarchive/test/test_archive_write_set_format_filter_by_ext.c:1.1.1.1	Thu Apr 20 08:55:56 2017
+++ src/external/bsd/libarchive/dist/libarchive/test/test_archive_write_set_format_filter_by_ext.c	Thu Jan 16 19:37:26 2020
@@ -30,7 +30,7 @@ __FBSDID("$FreeBSD$");
 
 static void
 test_format_filter_by_ext(const char *output_file, 
-int format_id, int filter_id, int dot_stored, char * def_ext)
+int format_id, int filter_id, int dot_stored, const char * def_ext)
 {
 	struct archive_entry *ae;
 	struct archive *a;
Index: src/external/bsd/libarchive/dist/libarchive/test/test_read_format_7zip.c
diff -u src/external/bsd/libarchive/dist/libarchive/test/test_read_format_7zip.c:1.1.1.1 src/external/bsd/libarchive/dist/libarchive/test/test_read_format_7zip.c:1.2
--- src/external/bsd/libarchive/dist/libarchive/test/test_read_format_7zip.c:1.1.1.1	Thu Apr 20 08:55:53 2017
+++ src/external/bsd/libarchive/dist/libarchive/test/test_read_format_7zip.c	Thu Jan 16 19:37:26 2020
@@ -87,7 +87,7 @@ test_copy(int use_open_fd)
  * An archive file has no entry.
  */
 static void
-test_empty_archive()
+test_empty_archive(void)
 {
 	const char *refname = "test_read_format_7zip_empty_archive.7z";
 	struct archive_entry *ae;
@@ -119,7 +119,7 @@ test_empty_archive()
  * in the archive file except for a header.
  */
 static void
-test_empty_file()
+test_empty_file(void)
 {
 	const char *refname = "test_read_format_7zip_empty_file.7z";
 	struct archive_entry *ae;
@@ -609,7 +609,7 @@ test_bcj(const char *refname)
  * Extract a file compressed with PPMd.
  */
 static void
-test_ppmd()
+test_ppmd(void)
 {
 	const char *refname = "test_read_format_7zip_ppmd.7z";
 	struct archive_entry *ae;
@@ -663,7 +663,7 @@ test_ppmd()
 }
 
 static void
-test_symname()
+test_symname(void)
 {
 	const char *refname = "test_read_format_7zip_symbolic_name.7z";
 	struct archive_entry *ae;
Index: src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file.c
diff -u src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file.c:1.1.1.1 src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file.c:1.2
--- src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file.c:1.1.1.1	Thu Apr 20 08:55:40 2017
+++ src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file.c	Thu Jan 16 19:37:26 2020
@@ -84,7 +84,7 @@ DEFINE_TEST(test_write_format_zip_file)
 	unsigned char *central_header, *local_header, *eocd, *eocd_record;
 	unsigned char *extension_start, *extension_end;
 	char file_data[] = {'1', '2', '3', '4', '5', '6', '7', '8'};
-	char *file_name = "file";
+	const char *file_name = "file";
 
 #ifndef HAVE_ZLIB_H
 	zip_version = 10;
Index: src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file_zip64.c
diff -u src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file_zip64.c:1.1.1.1 src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file_zip64.c:1.2
--- src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file_zip64.c:1.1.1.1	Thu Apr 20 08:55:49 2017
+++ src/external/bsd/libarchive/dist/libarchive/test/test_write_format_zip_file_zip64.c	Thu Jan 16 19:37:26 2020
@@ -86,7 +86,7 @@ DEFINE_TEST(test_write_format_zip_file_z
 	unsigned char *central_header, *local_header, *eocd, *eocd_record;
 	unsigned char *extension_start, *extension_end;
 	char file_data[] = {'1', '2', '3', '4', '5', '6', '7', '8'};
-	char *file_name = "file";
+	const char *file_name = "file";
 
 #ifndef HAVE_ZLIB_H
 	zip_compression = 0;

Index: 

CVS commit: src/external/bsd/libarchive/dist/libarchive/test

2020-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 17 00:37:03 UTC 2020

Modified Files:
src/external/bsd/libarchive/dist/libarchive/test:
test_write_disk_secure.c

Log Message:
fix test I broke by commenting out flags.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/bsd/libarchive/dist/libarchive/test/test_write_disk_secure.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/bsd/libarchive/dist/libarchive/test/test_write_disk_secure.c
diff -u src/external/bsd/libarchive/dist/libarchive/test/test_write_disk_secure.c:1.2 src/external/bsd/libarchive/dist/libarchive/test/test_write_disk_secure.c:1.3
--- src/external/bsd/libarchive/dist/libarchive/test/test_write_disk_secure.c:1.2	Sun Jan 12 11:10:49 2020
+++ src/external/bsd/libarchive/dist/libarchive/test/test_write_disk_secure.c	Thu Jan 16 19:37:03 2020
@@ -87,6 +87,7 @@ DEFINE_TEST(test_write_disk_secure)
 #endif
 
 	/* Write an absolute symlink to /tmp. */
+	archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
 	assert((ae = archive_entry_new()) != NULL);
 	archive_entry_copy_pathname(ae, "/tmp/libarchive_test-test_write_disk_secure-absolute_symlink");
 	archive_entry_set_mode(ae, S_IFLNK | 0777);



CVS commit: src/external/bsd/libarchive/dist/libarchive/test

2020-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 17 00:36:20 UTC 2020

Modified Files:
src/external/bsd/libarchive/dist/libarchive/test:
test_read_disk_directory_traversals.c

Log Message:
pull fix from head (O_EXEC means O_SEARCH only on FreeBSD)


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \

src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.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/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c
diff -u src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c:1.1.1.2 src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c:1.2
--- src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c:1.1.1.2	Wed Jul 24 09:50:38 2019
+++ src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c	Thu Jan 16 19:36:20 2020
@@ -1775,7 +1775,8 @@ test_parent(void)
 	archive_entry_clear(ae);
 	r = archive_read_next_header2(a, ae);
 	if (r == ARCHIVE_FAILED) {
-#if defined(O_PATH) || defined(O_SEARCH) || defined(O_EXEC)
+#if defined(O_PATH) || defined(O_SEARCH) || \
+ (defined(__FreeBSD__) && defined(O_EXEC))
 		assertEqualIntA(a, ARCHIVE_OK, r);
 #endif
 		/* Close the disk object. */



CVS commit: src/usr.sbin/sysinst

2020-01-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 16 16:47:19 UTC 2020

Modified Files:
src/usr.sbin/sysinst: bsddisklabel.c defs.h disks.c main.c

Log Message:
Fix /tmp tmpfs handling and on machines with enough RAM default to
creating a /tmp tmpfs with 25% of ram size limit. Suggested by ad@.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/sysinst/bsddisklabel.c
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/sysinst/disks.c
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/sysinst/main.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/bsddisklabel.c
diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.34 src/usr.sbin/sysinst/bsddisklabel.c:1.35
--- src/usr.sbin/sysinst/bsddisklabel.c:1.34	Thu Jan  9 13:22:30 2020
+++ src/usr.sbin/sysinst/bsddisklabel.c	Thu Jan 16 16:47:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bsddisklabel.c,v 1.34 2020/01/09 13:22:30 martin Exp $	*/
+/*	$NetBSD: bsddisklabel.c,v 1.35 2020/01/16 16:47:19 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -236,8 +236,16 @@ draw_size_menu_line(menudesc *m, int opt
 		size / sizemult);
 	}
 	size = pset->infos[opt].size;
-	snprintf(psize, sizeof psize, "%" PRIu64 "%s",
-	size / sizemult, inc_free);
+	if (pset->infos[opt].fs_type == FS_TMPFS) {
+		if (pset->infos[opt].size < 0)
+			snprintf(psize, sizeof psize, "%" PRIu64 "%%", -size);
+		else
+			snprintf(psize, sizeof psize, "%" PRIu64 " %s", size,
+			msg_string(MSG_megname));
+	} else {
+		snprintf(psize, sizeof psize, "%" PRIu64 "%s",
+		size / sizemult, inc_free);
+	}
 
 	if (pset->infos[opt].type == PT_swap) {
 		snprintf(swap, sizeof swap, "<%s>",
@@ -521,6 +529,20 @@ find_part_at(struct disk_partitions *par
 	return NO_PART;
 }
 
+static daddr_t
+parse_ram_size(const char *str, bool *is_percent)
+{
+	daddr_t val;
+	char *cp;
+
+	val = strtoull(str, , 10);
+	while (*cp && isspace((unsigned char)*cp))
+		cp++;
+
+	*is_percent = *cp == '%';
+	return val;
+}
+
 int
 set_ptn_size(menudesc *m, void *arg)
 {
@@ -531,7 +553,7 @@ set_ptn_size(menudesc *m, void *arg)
 	size_t i, root = ~0U;
 	daddr_t size, old_size, new_size_val, mult;
 	int rv;
-	bool non_zero, extend;
+	bool non_zero, extend, is_ram_size, is_percent = false;
 
 	if (pset->cur_free_space == 0 && p->size == 0 &&
 	!(p->flags & PUIFLG_JUST_MOUNTPOINT))
@@ -561,22 +583,47 @@ set_ptn_size(menudesc *m, void *arg)
 		}
 	}
 
+	is_ram_size = (p->flags & PUIFLG_JUST_MOUNTPOINT)
+	&& p->fs_type == FS_TMPFS;
+
 	size = p->size;
+	if (is_ram_size && size < 0) {
+		is_percent = true;
+		size = -size;
+	}
 	old_size = size;
 	if (size == 0)
 		size = p->def_size;
-	size /= sizemult;
-	snprintf(dflt, sizeof dflt, "%" PRIu64 "%s",
-	size, p->flags & PUIFLAG_EXTEND ? "+" : "");
+	if (!is_ram_size)
+		size /= sizemult;
+
+	if (is_ram_size) {
+		snprintf(dflt, sizeof dflt, "%" PRIu64 "%s",
+		size, is_percent ? "%" : "");
+	} else {
+		snprintf(dflt, sizeof dflt, "%" PRIu64 "%s",
+		size, p->flags & PUIFLAG_EXTEND ? "+" : "");
+	}
 
 	for (;;) {
 		msg_fmt_prompt_win(MSG_askfssize, -1, 18, 0, 0,
-		dflt, answer, sizeof answer, "%s%s", p->mount, multname);
+		dflt, answer, sizeof answer, "%s%s", p->mount,
+		is_ram_size ? msg_string(MSG_megname) : multname);
 
-		/* cp will be checked below */
+		if (is_ram_size) {
+			new_size_val = parse_ram_size(answer, _percent);
+			if (is_percent && 
+			(new_size_val < 0 || new_size_val > 100))
+continue;
+			if (!is_percent && new_size_val < 0)
+continue;
+			size = new_size_val;
+			extend = false;
+			break;
+		}
 		mult = sizemult;
-		new_size_val = parse_disk_pos(answer, , pm->dlcylsize,
-		);
+		new_size_val = parse_disk_pos(answer, ,
+		pm->dlcylsize, );
 
 		if (strcmp(answer, dflt) == 0)
 			non_zero = p->def_size > 0;
@@ -613,7 +660,9 @@ set_ptn_size(menudesc *m, void *arg)
 	}
 
 	daddr_t align = pset->parts->pscheme->get_part_alignment(pset->parts);
-	size = NUMSEC(size, mult, align);
+	if (!is_ram_size) {
+		size = NUMSEC(size, mult, align);
+	}
 	if (p->flags & PUIFLAG_EXTEND)
 		p->flags &= ~PUIFLAG_EXTEND;
 	if (extend && (p->limit == 0 || p->limit > p->size)) {
@@ -626,7 +675,7 @@ set_ptn_size(menudesc *m, void *arg)
 adjust_free:
 	if ((p->flags & (PUIFLG_IS_OUTER|PUIFLG_JUST_MOUNTPOINT)) == 0)
 		pset->cur_free_space += p->size - size;
-	p->size = size;
+	p->size = is_percent ? -size : size;
 	set_pset_exit_str(pset);
 
 	return 0;
@@ -879,6 +928,20 @@ fill_defaults(struct partition_usage_set
 
 	memcpy(wanted->infos, default_parts_init, sizeof(default_parts_init));
 
+#ifdef HAVE_TMPFS
+	if (get_ramsize() > 96) {
+		for (i = 0; i < wanted->num; i++) {
+			if (wanted->infos[i].type != PT_root ||
+			wanted->infos[i].fs_type != FS_TMPFS)
+continue;
+			/* default tmpfs to 1/4 RAM */
+			

CVS commit: [ad-namecache] src/sys/kern

2020-01-16 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Jan 16 16:45:31 UTC 2020

Modified Files:
src/sys/kern [ad-namecache]: vfs_lookup.c

Log Message:
Push the vnode locking in namei() about as far back as it will go.


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.212.4.1 src/sys/kern/vfs_lookup.c

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

Modified files:

Index: src/sys/kern/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.212 src/sys/kern/vfs_lookup.c:1.212.4.1
--- src/sys/kern/vfs_lookup.c:1.212	Thu Jul 18 09:39:40 2019
+++ src/sys/kern/vfs_lookup.c	Thu Jan 16 16:45:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.212 2019/07/18 09:39:40 hannken Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.212.4.1 2020/01/16 16:45:30 ad Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.212 2019/07/18 09:39:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.212.4.1 2020/01/16 16:45:30 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_magiclinks.h"
@@ -710,8 +710,6 @@ namei_start(struct namei_state *state, i
 		return ENOTDIR;
 	}
 
-	vn_lock(startdir, LK_EXCLUSIVE | LK_RETRY);
-
 	*startdir_ret = startdir;
 	return 0;
 }
@@ -749,15 +747,17 @@ namei_follow(struct namei_state *state, 
 	size_t linklen;
 	int error;
 
-	KASSERT(VOP_ISLOCKED(searchdir) == LK_EXCLUSIVE);
-	KASSERT(VOP_ISLOCKED(foundobj) == LK_EXCLUSIVE);
 	if (ndp->ni_loopcnt++ >= MAXSYMLINKS) {
 		return ELOOP;
 	}
+
+	vn_lock(foundobj, LK_EXCLUSIVE | LK_RETRY);
 	if (foundobj->v_mount->mnt_flag & MNT_SYMPERM) {
 		error = VOP_ACCESS(foundobj, VEXEC, cnp->cn_cred);
-		if (error != 0)
+		if (error != 0) {
+			VOP_UNLOCK(foundobj);
 			return error;
+		}
 	}
 
 	/* FUTURE: fix this to not use a second buffer */
@@ -771,6 +771,7 @@ namei_follow(struct namei_state *state, 
 	auio.uio_resid = MAXPATHLEN;
 	UIO_SETUP_SYSSPACE();
 	error = VOP_READLINK(foundobj, , cnp->cn_cred);
+	VOP_UNLOCK(foundobj);
 	if (error) {
 		PNBUF_PUT(cp);
 		return error;
@@ -807,14 +808,11 @@ namei_follow(struct namei_state *state, 
 	/* we're now starting from the beginning of the buffer again */
 	cnp->cn_nameptr = ndp->ni_pnbuf;
 
-	/* must unlock this before relocking searchdir */
-	VOP_UNLOCK(foundobj);
-
 	/*
 	 * Check if root directory should replace current directory.
 	 */
 	if (ndp->ni_pnbuf[0] == '/') {
-		vput(searchdir);
+		vrele(searchdir);
 		/* Keep absolute symbolic links inside emulation root */
 		searchdir = ndp->ni_erootdir;
 		if (searchdir == NULL ||
@@ -825,7 +823,6 @@ namei_follow(struct namei_state *state, 
 			searchdir = ndp->ni_rootdir;
 		}
 		vref(searchdir);
-		vn_lock(searchdir, LK_EXCLUSIVE | LK_RETRY);
 		while (cnp->cn_nameptr[0] == '/') {
 			cnp->cn_nameptr++;
 			ndp->ni_pathlen--;
@@ -833,7 +830,6 @@ namei_follow(struct namei_state *state, 
 	}
 
 	*newsearchdir_ret = searchdir;
-	KASSERT(VOP_ISLOCKED(searchdir) == LK_EXCLUSIVE);
 	return 0;
 }
 
@@ -933,19 +929,20 @@ static int
 lookup_once(struct namei_state *state,
 	struct vnode *searchdir,
 	struct vnode **newsearchdir_ret,
-	struct vnode **foundobj_ret)
+	struct vnode **foundobj_ret,
+	bool *newsearchdir_locked_ret)
 {
 	struct vnode *tmpvn;		/* scratch vnode */
 	struct vnode *foundobj;		/* result */
 	struct mount *mp;		/* mount table entry */
 	struct lwp *l = curlwp;
+	bool searchdir_locked = false;
 	int error;
 
 	struct componentname *cnp = state->cnp;
 	struct nameidata *ndp = state->ndp;
 
 	KASSERT(cnp == >ni_cnd);
-	KASSERT(VOP_ISLOCKED(searchdir) == LK_EXCLUSIVE);
 	*newsearchdir_ret = searchdir;
 
 	/*
@@ -977,9 +974,7 @@ lookup_once(struct namei_state *state,
 			if (ndp->ni_rootdir != rootvnode) {
 int retval;
 
-VOP_UNLOCK(searchdir);
 retval = vn_isunder(searchdir, ndp->ni_rootdir, l);
-vn_lock(searchdir, LK_EXCLUSIVE | LK_RETRY);
 if (!retval) {
 /* Oops! We got out of jail! */
 log(LOG_WARNING,
@@ -988,12 +983,11 @@ lookup_once(struct namei_state *state,
 	p->p_pid, kauth_cred_geteuid(l->l_cred),
 	p->p_comm);
 /* Put us at the jail root. */
-vput(searchdir);
+vrele(searchdir);
 searchdir = NULL;
 foundobj = ndp->ni_rootdir;
 vref(foundobj);
 vref(foundobj);
-vn_lock(foundobj, LK_EXCLUSIVE | LK_RETRY);
 *newsearchdir_ret = foundobj;
 *foundobj_ret = foundobj;
 error = 0;
@@ -1006,18 +1000,19 @@ lookup_once(struct namei_state *state,
 			tmpvn = searchdir;
 			searchdir = searchdir->v_mount->mnt_vnodecovered;
 			vref(searchdir);
-			vput(tmpvn);
-			vn_lock(searchdir, LK_EXCLUSIVE | LK_RETRY);
+			vrele(tmpvn);
 			*newsearchdir_ret = searchdir;
 		}
 	}
 
 	/*
 	 * We now have a segment name to search for, and a directory to search.
-	 * Our vnode state here is that "searchdir" is held and locked.
+	 * Our vnode state here 

CVS commit: src/sys/opencrypto

2020-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 16 15:29:24 UTC 2020

Modified Files:
src/sys/opencrypto: cryptodev.c ocryptodev.c

Log Message:
Initialize the session variable to an impossible session to prevent compiler
warnings.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.14 -r1.15 src/sys/opencrypto/ocryptodev.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/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.102 src/sys/opencrypto/cryptodev.c:1.103
--- src/sys/opencrypto/cryptodev.c:1.102	Fri Nov 29 03:30:30 2019
+++ src/sys/opencrypto/cryptodev.c	Thu Jan 16 10:29:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptodev.c,v 1.102 2019/11/29 08:30:30 hikaru Exp $ */
+/*	$NetBSD: cryptodev.c,v 1.103 2020/01/16 15:29:24 christos Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $	*/
 /*	$OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $	*/
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.102 2019/11/29 08:30:30 hikaru Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.103 2020/01/16 15:29:24 christos Exp $");
 
 #include 
 #include 
@@ -1787,6 +1787,7 @@ cryptodev_msession(struct fcrypt *fcr, s
 		s_op.key =		sn_ops->key;
 		s_op.mackeylen =	sn_ops->mackeylen;
 		s_op.mackey =		sn_ops->mackey;
+		s_op.ses =		~0;
 
 		sn_ops->status = cryptodev_session(fcr, _op);
 

Index: src/sys/opencrypto/ocryptodev.c
diff -u src/sys/opencrypto/ocryptodev.c:1.14 src/sys/opencrypto/ocryptodev.c:1.15
--- src/sys/opencrypto/ocryptodev.c:1.14	Wed Dec 11 21:15:43 2019
+++ src/sys/opencrypto/ocryptodev.c	Thu Jan 16 10:29:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ocryptodev.c,v 1.14 2019/12/12 02:15:43 pgoyette Exp $ */
+/*	$NetBSD: ocryptodev.c,v 1.15 2020/01/16 15:29:24 christos Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $	*/
 /*	$OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $	*/
 
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ocryptodev.c,v 1.14 2019/12/12 02:15:43 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ocryptodev.c,v 1.15 2020/01/16 15:29:24 christos Exp $");
 
 #include 
 #include 
@@ -279,6 +279,7 @@ ocryptodev_msession(struct fcrypt *fcr, 
 		os_op.key =		osn_ops->key;
 		os_op.mackeylen =	osn_ops->mackeylen;
 		os_op.mackey =		osn_ops->mackey;
+		os_op.ses =		~0;
 
 		osn_ops->status = ocryptodev_session(fcr, _op);
 		osn_ops->ses =		os_op.ses;



CVS commit: src/usr.sbin/sysinst

2020-01-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 16 13:56:24 UTC 2020

Modified Files:
src/usr.sbin/sysinst: install.c upgrade.c

Log Message:
Remove useless calls to get_ramsize() - return value is ignored and
the function has no side effects.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/sysinst/install.c \
src/usr.sbin/sysinst/upgrade.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/install.c
diff -u src/usr.sbin/sysinst/install.c:1.13 src/usr.sbin/sysinst/install.c:1.14
--- src/usr.sbin/sysinst/install.c:1.13	Wed Nov 13 18:57:26 2019
+++ src/usr.sbin/sysinst/install.c	Thu Jan 16 13:56:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: install.c,v 1.13 2019/11/13 18:57:26 martin Exp $	*/
+/*	$NetBSD: install.c,v 1.14 2020/01/16 13:56:24 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -155,8 +155,6 @@ do_install(void)
 
 	memset(, 0, sizeof install);
 
-	get_ramsize();
-
 	/* Create and mount partitions */
 	find_disks_ret = find_disks(msg_string(MSG_install), false);
 	if (partman_go == 1) {
Index: src/usr.sbin/sysinst/upgrade.c
diff -u src/usr.sbin/sysinst/upgrade.c:1.13 src/usr.sbin/sysinst/upgrade.c:1.14
--- src/usr.sbin/sysinst/upgrade.c:1.13	Tue Aug 27 14:11:00 2019
+++ src/usr.sbin/sysinst/upgrade.c	Thu Jan 16 13:56:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: upgrade.c,v 1.13 2019/08/27 14:11:00 martin Exp $	*/
+/*	$NetBSD: upgrade.c,v 1.14 2020/01/16 13:56:24 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -62,8 +62,6 @@ do_upgrade(void)
 	if (!ask_noyes(NULL))
 		return;
 
-	get_ramsize();
-
 	if (find_disks(msg_string(MSG_upgrade), !root_is_read_only()) < 0)
 		return;
 



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

2020-01-16 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Jan 16 13:37:27 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: boot.S
src/sys/arch/x68k/stand/boot_ustar: boot_ustar.S
src/sys/arch/x68k/stand/xxboot: boot.S

Log Message:
Use .org directive to fix disklabel location instead of hand calculation.
If the code size before disklabel is less, zero is filled automatically.
If the code size before disklabel is exceeded, assembler stops with error.
Note that this changes a padding word in the current output binary from
a NOP instruction to zero but there are no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x68k/stand/boot_ufs/boot.S
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x68k/stand/xxboot/boot.S

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

Modified files:

Index: src/sys/arch/x68k/stand/boot_ufs/boot.S
diff -u src/sys/arch/x68k/stand/boot_ufs/boot.S:1.12 src/sys/arch/x68k/stand/boot_ufs/boot.S:1.13
--- src/sys/arch/x68k/stand/boot_ufs/boot.S:1.12	Tue Jan 14 04:00:41 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot.S	Thu Jan 16 13:37:26 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.12 2020/01/14 04:00:41 isaki Exp $
+| $NetBSD: boot.S,v 1.13 2020/01/16 13:37:26 isaki Exp $
 
 #include 
 #include "iocscall.h"
@@ -44,7 +44,7 @@ ASENTRY_NOPROFILE(entry0)
 |	Disklabel= 404bytes
 |	Since LABELOFFSET in  is 0x40,
 |	entry must be after 0x01d4 (0x000f01d4)
-		nop
+		.org	0x40
 disklabel:
 		.space	404
 

Index: src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S
diff -u src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.9 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.10
--- src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.9	Mon Jan 13 03:34:05 2020
+++ src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S	Thu Jan 16 13:37:26 2020
@@ -3,7 +3,7 @@
 | ITOH Yasufumi
 |	  mino...@netbsd.org
 |
-| $NetBSD: boot_ustar.S,v 1.9 2020/01/13 03:34:05 isaki Exp $
+| $NetBSD: boot_ustar.S,v 1.10 2020/01/16 13:37:26 isaki Exp $
 
 | supports floppy only
 
@@ -46,8 +46,8 @@ ASENTRY_NOPROFILE(entry0)
 |	Disklabel= 404bytes
 |	Since LABELOFFSET in  is 0x40,
 |	entry must be after 0x01d4 (0x21d4)
-		nop
-GLOBAL(disklabel)
+		.org	0x40
+disklabel:
 		.space	404
 
 ASENTRY_NOPROFILE(entry)

Index: src/sys/arch/x68k/stand/xxboot/boot.S
diff -u src/sys/arch/x68k/stand/xxboot/boot.S:1.4 src/sys/arch/x68k/stand/xxboot/boot.S:1.5
--- src/sys/arch/x68k/stand/xxboot/boot.S:1.4	Mon Jan 13 03:34:05 2020
+++ src/sys/arch/x68k/stand/xxboot/boot.S	Thu Jan 16 13:37:27 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.4 2020/01/13 03:34:05 isaki Exp $
+| $NetBSD: boot.S,v 1.5 2020/01/16 13:37:27 isaki Exp $
 
 #include 
 #include "iocscall.h"
@@ -46,7 +46,7 @@ ASENTRY_NOPROFILE(entry0)
 |	Disklabel= 404bytes
 |	Since LABELOFFSET in  is 0x40,
 |	entry must be after 0x01d4 (0x000f01d4)
-		nop
+		.org	0x40
 disklabel:
 		.space	404
 



CVS commit: src/sys/net

2020-01-16 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Thu Jan 16 13:16:59 UTC 2020

Modified Files:
src/sys/net: if_ethersubr.c

Log Message:
use the CARP interface for arp/nd instead of the carp parent interface.
this provides the correct source mac address for the packets.

there are routers out there that cache the source mac during
nd and then subsequently bypass/miss packet filters on carp
interfaces as they send to the parent interface mac instead of the
correct carp interface mac.


To generate a diff of this commit:
cvs rdiff -u -r1.280 -r1.281 src/sys/net/if_ethersubr.c

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

Modified files:

Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.280 src/sys/net/if_ethersubr.c:1.281
--- src/sys/net/if_ethersubr.c:1.280	Wed Oct 16 18:29:49 2019
+++ src/sys/net/if_ethersubr.c	Thu Jan 16 13:16:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.280 2019/10/16 18:29:49 christos Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.281 2020/01/16 13:16:59 kardel Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.280 2019/10/16 18:29:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.281 2020/01/16 13:16:59 kardel Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -243,7 +243,7 @@ ether_output(struct ifnet * const ifp0, 
 		} else if (m->m_flags & M_MCAST) {
 			ETHER_MAP_IP_MULTICAST((dst)->sin_addr, edst);
 		} else {
-			error = arpresolve(ifp, rt, m, dst, edst, sizeof(edst));
+			error = arpresolve(ifp0, rt, m, dst, edst, sizeof(edst));
 			if (error)
 return (error == EWOULDBLOCK) ? 0 : error;
 		}
@@ -292,7 +292,7 @@ ether_output(struct ifnet * const ifp0, 
 			ETHER_MAP_IPV6_MULTICAST((dst)->sin6_addr,
 			edst);
 		} else {
-			error = nd6_resolve(ifp, rt, m, dst, edst,
+			error = nd6_resolve(ifp0, rt, m, dst, edst,
 			sizeof(edst));
 			if (error)
 return (error == EWOULDBLOCK) ? 0 : error;



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

2020-01-16 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Jan 16 13:15:47 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: Makefile
src/sys/arch/x68k/stand/boot_ustar: Makefile
src/sys/arch/x68k/stand/xxboot: Makefile.xxboot

Log Message:
Rewrite limit check using cross-build tools.
This eliminates use of hosts tr(1) and bc(1).
(But I'm going to remove this again soon due to other reason)


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/x68k/stand/boot_ufs/Makefile
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x68k/stand/boot_ustar/Makefile
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot

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/x68k/stand/boot_ufs/Makefile
diff -u src/sys/arch/x68k/stand/boot_ufs/Makefile:1.30 src/sys/arch/x68k/stand/boot_ufs/Makefile:1.31
--- src/sys/arch/x68k/stand/boot_ufs/Makefile:1.30	Sat Apr  8 19:53:23 2017
+++ src/sys/arch/x68k/stand/boot_ufs/Makefile	Thu Jan 16 13:15:47 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.30 2017/04/08 19:53:23 christos Exp $
+#	$NetBSD: Makefile,v 1.31 2020/01/16 13:15:47 isaki Exp $
 
 NOMAN=		# defined
 
@@ -59,13 +59,11 @@ $(PROG): $(OBJS)
 	:
 	$(LD) $(LINKFLAGS) -o $(PROG).x $(OBJS) $(LDADD) >$(PROG).map
 	@grep first_kbyte $(PROG).map
-	@if [ `(echo ibase=16;		\
-		${TOOL_SED} -n	-e '/[ 	]first_kbyte/{'			\
-			-e 's/.*0x\([0-9a-fA-F]*\).*/\1-$(TEXT)-400/p'	\
-			-e '}' $(PROG).map |\
-		tr a-f A-F) | bc` -gt 0 ];\
-	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	\
-		exit 1;			\
+	@if [ `${TOOL_AWK}		   \
+	'/first_kbyte/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'  \
+	$(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
+	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
+	exit 1;			   \
 	fi
 	mv -f $(PROG).x $(PROG)
 

Index: src/sys/arch/x68k/stand/boot_ustar/Makefile
diff -u src/sys/arch/x68k/stand/boot_ustar/Makefile:1.24 src/sys/arch/x68k/stand/boot_ustar/Makefile:1.25
--- src/sys/arch/x68k/stand/boot_ustar/Makefile:1.24	Sat Apr  8 19:53:23 2017
+++ src/sys/arch/x68k/stand/boot_ustar/Makefile	Thu Jan 16 13:15:47 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.24 2017/04/08 19:53:23 christos Exp $
+#	$NetBSD: Makefile,v 1.25 2020/01/16 13:15:47 isaki Exp $
 
 NOMAN=		# defined
 
@@ -50,19 +50,15 @@ ${PROG}: $(OBJS)
 	${_MKTARGET_LINK}
 	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDADD) > $(PROG).map
 	@grep first_kbyte $(PROG).map
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p'\
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
+	@if [ `${TOOL_AWK}		   \
+	'/first_kbyte/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'  \
+	$(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
 	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
 	rm $(PROG) ; exit 1; 	   \
 	fi
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/^.*0x\([0-9a-f]*\).* _edata *= *\.$$/\1-$(TEXT)-2000/p' \
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
+	@if [ `${TOOL_AWK}		   \
+	'/_edata/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'	   \
+	$(PROG).map | ${TOOL_M4} -` -gt 8192 ];			   \
 	then echo '$(BOOT): text+data is too large';			   \
 	rm $(PROG) ; exit 1; 	   \
 	fi

Index: src/sys/arch/x68k/stand/xxboot/Makefile.xxboot
diff -u src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.5 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.6
--- src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.5	Thu Jan 16 12:54:16 2020
+++ src/sys/arch/x68k/stand/xxboot/Makefile.xxboot	Thu Jan 16 13:15:47 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.xxboot,v 1.5 2020/01/16 12:54:16 isaki Exp $
+#	$NetBSD: Makefile.xxboot,v 1.6 2020/01/16 13:15:47 isaki Exp $
 
 NOMAN=		# defined
 
@@ -64,19 +64,17 @@ ${PROG}: $(OBJS)
 	${_MKTARGET_LINK}
 	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS) > $(PROG).map
 	@grep first_kbyte $(PROG).map
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p'\
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
+	@if [ `${TOOL_AWK}		   \
+	'/first_kbyte/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'  \
+	$(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
 	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
 	rm $(PROG) ; exit 1; 	   \
 	fi
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/^.*0x\([0-9a-f]*\).* _edata *= *\.$$/\1-$(TEXT)-$(TEXTDATASIZE)/p' \
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
+	@if [ `${TOOL_AWK}		   \
+	'/_edata/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'	   \
+	$(PROG).map | ${TOOL_M4} -`	   \
+	-gt   

CVS commit: src

2020-01-16 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Thu Jan 16 12:56:40 UTC 2020

Modified Files:
src/share/man/man4: carp.4
src/sys/netinet: ip_carp.c ip_carp.h

Log Message:
Provide SIOCGIFMEDIA ioctl to deliver link status.
Add link0 (IFF_LINK0) flag to map INIT state to LINK_STATE_DOWN
instead of LINK_STATE_UNKNOWN. This allows routing software to
suppress routes to the interface of the carp interface when in
init state (e. g. link down in the parent interface).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/share/man/man4/carp.4
cvs rdiff -u -r1.104 -r1.105 src/sys/netinet/ip_carp.c
cvs rdiff -u -r1.10 -r1.11 src/sys/netinet/ip_carp.h

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

Modified files:

Index: src/share/man/man4/carp.4
diff -u src/share/man/man4/carp.4:1.6 src/share/man/man4/carp.4:1.7
--- src/share/man/man4/carp.4:1.6	Wed Apr 10 00:18:39 2019
+++ src/share/man/man4/carp.4	Thu Jan 16 12:56:39 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: carp.4,v 1.6 2019/04/10 00:18:39 sevan Exp $
+.\"	$NetBSD: carp.4,v 1.7 2020/01/16 12:56:39 kardel Exp $
 .\"	$OpenBSD: carp.4,v 1.19 2005/08/09 09:52:12 jmc Exp $
 .\"
 .\" Copyright (c) 2003, Ryan McBride.  All rights reserved.
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 10, 2019
+.Dd January 16, 2020
 .Dt CARP 4
 .Os
 .Sh NAME
@@ -76,6 +76,20 @@ or through the
 .Dv SIOCSVH
 ioctl.
 .Pp
+Setting the
+.Cm link0
+parameter will cause the carp interface to report
+.Dv LINK_STATE_DOWN
+in non
+.Dv MASTER/BACKUP
+mode instead of
+.Dv LINK_STATE_UNKNOWN
+as link status.
+This prevents routing software to announce routes for the carp
+interface when in
+.Dv INIT
+mode.
+.Pp
 Additionally, there are a number of global parameters which can be set using
 .Xr sysctl 8 :
 .Bl -tag -width xx

Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.104 src/sys/netinet/ip_carp.c:1.105
--- src/sys/netinet/ip_carp.c:1.104	Sun Nov 10 21:16:38 2019
+++ src/sys/netinet/ip_carp.c	Thu Jan 16 12:56:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_carp.c,v 1.104 2019/11/10 21:16:38 chs Exp $	*/
+/*	$NetBSD: ip_carp.c,v 1.105 2020/01/16 12:56:40 kardel Exp $	*/
 /*	$OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.104 2019/11/10 21:16:38 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.105 2020/01/16 12:56:40 kardel Exp $");
 
 /*
  * TODO:
@@ -67,6 +67,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -122,6 +123,7 @@ struct carp_softc {
 #define	sc_carpdev	sc_ac.ec_if.if_carpdev
 	int ah_cookie;
 	int lh_cookie;
+	struct ifmedia  sc_im;	/* ifmedia for link status */
 	struct ip_moptions sc_imo;
 #ifdef INET6
 	struct ip6_moptions sc_im6o;
@@ -233,6 +235,9 @@ static int	carp_clone_destroy(struct ifn
 static int	carp_ether_addmulti(struct carp_softc *, struct ifreq *);
 static int	carp_ether_delmulti(struct carp_softc *, struct ifreq *);
 static void	carp_ether_purgemulti(struct carp_softc *);
+static int  carp_mediachange(struct ifnet *ifp);
+static void	carp_mediastatus(struct ifnet *ifp, struct ifmediareq *imr);
+static void	carp_update_link_state(struct carp_softc *sc);
 
 static void	sysctl_net_inet_carp_setup(struct sysctllog **);
 
@@ -893,6 +898,8 @@ carp_clone_create(struct if_clone *ifc, 
 
 		return rv;
 	}
+	ifmedia_init(>sc_im, 0, carp_mediachange, carp_mediastatus);
+	sc->sc_im.ifm_media = IFM_CARP;
 	ether_ifattach(ifp, NULL);
 	carp_set_enaddr(sc);
 	/* Overwrite ethernet defaults */
@@ -908,6 +915,7 @@ carp_clone_destroy(struct ifnet *ifp)
 {
 	struct carp_softc *sc = ifp->if_softc;
 
+	ifmedia_delete_instance(>sc_im, IFM_INST_ANY);
 	carpdetach(ifp->if_softc);
 	ether_ifdetach(ifp);
 	if_detach(ifp);
@@ -2069,6 +2077,7 @@ carp_ioctl(struct ifnet *ifp, u_long cmd
 			sc->sc_if.if_flags |= IFF_UP;
 			carp_setrun(sc, 0);
 		}
+		carp_update_link_state(sc);
 		break;
 
 	case SIOCSVH:
@@ -2174,6 +2183,10 @@ carp_ioctl(struct ifnet *ifp, u_long cmd
 			error = 0;
 		break;
 
+case SIOCGIFMEDIA:
+		error = ifmedia_ioctl(ifp, ifr, >sc_im, cmd);
+		break;
+
 	default:
 		error = ether_ioctl(ifp, cmd, data);
 	}
@@ -2209,11 +,32 @@ carp_output(struct ifnet *ifp, struct mb
 	}
 }
 
+static int
+carp_mediachange(struct ifnet *ifp)
+{
+return (0);
+}
+
+static void
+carp_mediastatus(struct ifnet *ifp, struct ifmediareq *imr)
+{
+switch (ifp->if_link_state) {
+case LINK_STATE_UP:
+imr->ifm_status = IFM_AVALID | IFM_ACTIVE;
+break;
+case LINK_STATE_DOWN:
+imr->ifm_status = IFM_AVALID;
+break;
+default:
+imr->ifm_status = 0;
+break;
+ 

CVS commit: src/sys/arch/x68k/stand/xxboot

2020-01-16 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Jan 16 12:54:16 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/xxboot: Makefile.xxboot

Log Message:
Remove .else part of .if OBJECT_FMT == ELF.
All similar parts in other Makefiles are removed in 2010.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot

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/x68k/stand/xxboot/Makefile.xxboot
diff -u src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.4 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.5
--- src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.4	Sat Apr  8 19:53:23 2017
+++ src/sys/arch/x68k/stand/xxboot/Makefile.xxboot	Thu Jan 16 12:54:16 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.xxboot,v 1.4 2017/04/08 19:53:23 christos Exp $
+#	$NetBSD: Makefile.xxboot,v 1.5 2020/01/16 12:54:16 isaki Exp $
 
 NOMAN=		# defined
 
@@ -38,12 +38,8 @@ CPPFLAGS+= -DBOOT_STAGE1 $(BOOTCPPFLAGS)
 CPPFLAGS+= -nostdinc -I${.OBJDIR} -I${S}
 CPPFLAGS+= -I$M/stand/libiocs -I$M/stand/libsa -I$M/stand/common
 AFLAGS=	   ${CFLAGS:M-[ID]*}
-.if ${OBJECT_FMT} == "ELF"
 LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript -M
 LINKFLAGS+=  -noinhibit-exec	# XXX
-.else
-LINKFLAGS=   -n -Bstatic -Ttext ${TEXT} -M
-.endif
 LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
 LIBSA!=	  cd $M/stand/libsa && ${PRINTOBJDIR}
 LDLIBS=	  -L${LIBSA}/lib/sa -lsa -L ${LIBSA}/lib/kern -lkern
@@ -68,7 +64,6 @@ ${PROG}: $(OBJS)
 	${_MKTARGET_LINK}
 	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS) > $(PROG).map
 	@grep first_kbyte $(PROG).map
-.if ${OBJECT_FMT} == "ELF"
 	@if [ `(echo ibase=16; 		   \
 	${TOOL_SED} -n		   \
 		's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p'\
@@ -85,27 +80,6 @@ ${PROG}: $(OBJS)
 	then echo '$(BOOT): text+data is too large';			   \
 	rm $(PROG) ; exit 1; 	   \
 	fi
-.else
-	mv $(PROG) $(PROG).x
-	$(OBJCOPY) -I a.out-m68k-netbsd -O binary $(PROG).x $(PROG)
-	@rm -f $(PROG).x
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/  first_kbyte:.*0x\(.*\),.*$$/\1-$(TEXT)-400/p'	   \
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
-	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
-	rm $(PROG) ; exit 1; 	   \
-	fi
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/  _edata:.*0x\(.*\),.*$$/\1-$(TEXT)-$(TEXTDATASIZE)/p'  \
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
-	then echo '$(BOOT): text+data is too large';			   \
-	rm $(PROG) ; exit 1; 	   \
-	fi
-.endif
 	${TOUCHPROG}
 
 .include 



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

2020-01-16 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Jan 16 09:23:43 UTC 2020

Modified Files:
src/common/lib/libc/arch/x86_64/string: memcmp.S

Log Message:
Back out previous, it's broken.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/x86_64/string/memcmp.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/x86_64/string/memcmp.S
diff -u src/common/lib/libc/arch/x86_64/string/memcmp.S:1.4 src/common/lib/libc/arch/x86_64/string/memcmp.S:1.5
--- src/common/lib/libc/arch/x86_64/string/memcmp.S:1.4	Wed Jan 15 10:56:49 2020
+++ src/common/lib/libc/arch/x86_64/string/memcmp.S	Thu Jan 16 09:23:43 2020
@@ -1,34 +1,3 @@
-/*	$NetBSD: memcmp.S,v 1.4 2020/01/15 10:56:49 ad Exp $	*/
-
-/*-
- * Copyright (c) 2020 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Andrew Doran.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
 /*
  * Written by J.T. Conklin .
  * Public domain.
@@ -38,39 +7,34 @@
 #include 
 
 #if defined(LIBC_SCCS)
-	RCSID("$NetBSD: memcmp.S,v 1.4 2020/01/15 10:56:49 ad Exp $")
+	RCSID("$NetBSD: memcmp.S,v 1.5 2020/01/16 09:23:43 ad Exp $")
 #endif
 
 ENTRY(memcmp)
-	movq	%rdx, %rcx	/* compare by longs, equality only */
-	shrq	$3, %rcx
-	jz	2f
-1:
-	movq	(%rdi), %rax
-	cmpq	%rax, (%rsi)
-	jne	6f
-	decq	%rcx
-	leaq	8(%rdi), %rdi
-	leaq	8(%rsi), %rsi
-	jnz	1b
-2:
-	andl	$7, %edx
-	jz	5f
-3:
-	movb	(%rdi), %al	/* compare by chars, find difference */
-	subb	(%rsi), %al
-	jne	4f
-	decl	%edx
-	leaq	1(%rdi), %rdi
-	leaq	1(%rsi), %rsi
-	jnz	3b
-4:
-	movsbl	%al, %eax
+	movq	%rdx,%rcx		/* compare by longs */
+	shrq	$3,%rcx
+	repe
+	cmpsq
+	jne	L5			/* do we match so far? */
+
+	movq	%rdx,%rcx		/* compare remainder by bytes */
+	andq	$7,%rcx
+	repe
+	cmpsb
+	jne	L6			/* do we match? */
+
+	xorl	%eax,%eax		/* we match, return zero	*/
 	ret
-5:
-	xorl	%eax, %eax
+
+L5:	movl	$8,%ecx			/* We know that one of the next	*/
+	subq	%rcx,%rdi		/* eight pairs of bytes do not	*/
+	subq	%rcx,%rsi		/* match.			*/
+	repe
+	cmpsb
+L6:	xorl	%eax,%eax		/* Perform unsigned comparison	*/
+	movb	-1(%rdi),%al
+	xorl	%edx,%edx
+	movb	-1(%rsi),%dl
+	subl%edx,%eax
 	ret
-6:
-	movl	$8, %edx
-	jmp	3b
 END(memcmp)