CVS commit: src/sys/net

2018-04-11 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Apr 12 04:38:13 UTC 2018

Modified Files:
src/sys/net: if.h route.c route.h rtsock.c

Log Message:
Resolve tangled lock dependencies in route.c

This change sweeps remaining lock decisions based on if locked or not by moving
utility functions of rtentry updates from rtsock.c and ensuring holding the
rt_lock.  It also improves the atomicity of a update of a rtentry.


To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/sys/net/if.h
cvs rdiff -u -r1.208 -r1.209 src/sys/net/route.c
cvs rdiff -u -r1.117 -r1.118 src/sys/net/route.h
cvs rdiff -u -r1.239 -r1.240 src/sys/net/rtsock.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.h
diff -u src/sys/net/if.h:1.258 src/sys/net/if.h:1.259
--- src/sys/net/if.h:1.258	Mon Jan 15 13:05:40 2018
+++ src/sys/net/if.h	Thu Apr 12 04:38:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.258 2018/01/15 13:05:40 maxv Exp $	*/
+/*	$NetBSD: if.h,v 1.259 2018/04/12 04:38:13 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1146,8 +1146,6 @@ struct	ifaddr *ifa_ifwithnet(const struc
 struct	ifaddr *ifa_ifwithnet_psref(const struct sockaddr *, struct psref *);
 struct	ifaddr *ifa_ifwithladdr(const struct sockaddr *);
 struct	ifaddr *ifa_ifwithladdr_psref(const struct sockaddr *, struct psref *);
-struct	ifaddr *ifa_ifwithroute_psref(int, const struct sockaddr *,
-	const struct sockaddr *, struct psref *);
 struct	ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *);
 struct	ifaddr *ifaof_ifpforaddr_psref(const struct sockaddr *, struct ifnet *,
 	struct psref *);

Index: src/sys/net/route.c
diff -u src/sys/net/route.c:1.208 src/sys/net/route.c:1.209
--- src/sys/net/route.c:1.208	Thu Apr  5 03:39:14 2018
+++ src/sys/net/route.c	Thu Apr 12 04:38:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.208 2018/04/05 03:39:14 ozaki-r Exp $	*/
+/*	$NetBSD: route.c,v 1.209 2018/04/12 04:38:13 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.208 2018/04/05 03:39:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.209 2018/04/12 04:38:13 ozaki-r Exp $");
 
 #include 
 #ifdef RTFLUSH_DEBUG
@@ -130,6 +130,8 @@ __KERNEL_RCSID(0, "$NetBSD: route.c,v 1.
 #include 
 #include 
 
+#define	PRESERVED_RTF	(RTF_UP | RTF_GATEWAY | RTF_HOST | RTF_DONE | RTF_MASK)
+
 #ifdef RTFLUSH_DEBUG
 #define	rtcache_debug() __predict_false(_rtcache_debug)
 #else /* RTFLUSH_DEBUG */
@@ -224,13 +226,13 @@ static krwlock_t		rt_lock __cacheline_al
 #define RT_RLOCK()		rw_enter(_lock, RW_READER)
 #define RT_WLOCK()		rw_enter(_lock, RW_WRITER)
 #define RT_UNLOCK()		rw_exit(_lock)
-#define RT_LOCKED()		rw_lock_held(_lock)
+#define RT_WLOCKED()		rw_write_held(_lock)
 #define	RT_ASSERT_WLOCK()	KASSERT(rw_write_held(_lock))
 #else
 #define RT_RLOCK()		do {} while (0)
 #define RT_WLOCK()		do {} while (0)
 #define RT_UNLOCK()		do {} while (0)
-#define RT_LOCKED()		false
+#define RT_WLOCKED()		true
 #define	RT_ASSERT_WLOCK()	do {} while (0)
 #endif
 
@@ -280,6 +282,11 @@ static void rt_ref(struct rtentry *);
 static struct rtentry *
 rtalloc1_locked(const struct sockaddr *, int, bool, bool);
 
+static struct ifaddr *rt_getifa(struct rt_addrinfo *, struct psref *);
+static struct ifnet *rt_getifp(struct rt_addrinfo *, struct psref *);
+static struct ifaddr *ifa_ifwithroute_psref(int, const struct sockaddr *,
+const struct sockaddr *, struct psref *);
+
 static void rtcache_ref(struct rtentry *, struct route *);
 
 #ifdef NET_MPSAFE
@@ -884,11 +891,13 @@ rtredirect(const struct sockaddr *dst, c
 			error = rt_update_prepare(rt);
 			if (error == 0) {
 #endif
+RT_WLOCK();
 error = rt_setgate(rt, gateway);
 if (error == 0) {
 	rt->rt_flags |= RTF_MODIFIED;
 	flags |= RTF_MODIFIED;
 }
+RT_UNLOCK();
 #ifdef NET_MPSAFE
 rt_update_finish(rt);
 			} else {
@@ -952,9 +961,9 @@ rtdeletemsg(struct rtentry *rt)
 	return error;
 }
 
-struct ifaddr *
+static struct ifaddr *
 ifa_ifwithroute_psref(int flags, const struct sockaddr *dst,
-	const struct sockaddr *gateway, struct psref *psref)
+const struct sockaddr *gateway, struct psref *psref)
 {
 	struct ifaddr *ifa = NULL;
 
@@ -984,11 +993,7 @@ ifa_ifwithroute_psref(int flags, const s
 		int s;
 		struct rtentry *rt;
 
-		/* XXX we cannot call rtalloc1 if holding the rt lock */
-		if (RT_LOCKED())
-			rt = rtalloc1_locked(gateway, 0, true, true);
-		else
-			rt = rtalloc1(gateway, 0);
+		rt = rtalloc1_locked(gateway, 0, true, true);
 		if (rt == NULL)
 			return NULL;
 		if (rt->rt_flags & RTF_GATEWAY) {
@@ -1074,7 +1079,7 @@ rtrequest_newmsg(const int req, const st
 	return 0;
 }
 
-struct ifnet *
+static struct ifnet *
 rt_getifp(struct rt_addrinfo *info, struct psref *psref)
 {
 	const struct 

CVS commit: src/sys/dev/pci

2018-04-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 12 03:25:08 UTC 2018

Modified Files:
src/sys/dev/pci: if_wm.c if_wmvar.h

Log Message:
 Add PCH_CNP support (I219 with Intel 300 series chipset).
It's required more test, so it's disabled by default.


To generate a diff of this commit:
cvs rdiff -u -r1.569 -r1.570 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/pci/if_wmvar.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_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.569 src/sys/dev/pci/if_wm.c:1.570
--- src/sys/dev/pci/if_wm.c:1.569	Thu Apr 12 03:13:04 2018
+++ src/sys/dev/pci/if_wm.c	Thu Apr 12 03:25:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.569 2018/04/12 03:13:04 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.570 2018/04/12 03:25:08 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.569 2018/04/12 03:13:04 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.570 2018/04/12 03:25:08 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1513,6 +1513,18 @@ static const struct wm_product {
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_LM5,
 	  "I219 LM Ethernet Connection",
 	  WM_T_PCH_SPT,		WMP_F_COPPER },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_V6,
+	  "I219 V Ethernet Connection",
+	  WM_T_PCH_CNP,		WMP_F_COPPER },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_V7,
+	  "I219 V Ethernet Connection",
+	  WM_T_PCH_CNP,		WMP_F_COPPER },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_LM6,
+	  "I219 LM Ethernet Connection",
+	  WM_T_PCH_CNP,		WMP_F_COPPER },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_LM7,
+	  "I219 LM Ethernet Connection",
+	  WM_T_PCH_CNP,		WMP_F_COPPER },
 #endif
 	{ 0,			0,
 	  NULL,
@@ -1986,7 +1998,8 @@ alloc_retry:
 		&& (sc->sc_type != WM_T_PCH)
 		&& (sc->sc_type != WM_T_PCH2)
 		&& (sc->sc_type != WM_T_PCH_LPT)
-		&& (sc->sc_type != WM_T_PCH_SPT)) {
+		&& (sc->sc_type != WM_T_PCH_SPT)
+		&& (sc->sc_type != WM_T_PCH_CNP)) {
 			/* ICH* and PCH* have no PCIe capability registers */
 			if (pci_get_capability(pa->pa_pc, pa->pa_tag,
 PCI_CAP_PCIEXPRESS, >sc_pcixe_capoff,
@@ -2233,6 +2246,7 @@ alloc_retry:
 		sc->nvm.release = wm_put_nvm_ich8lan;
 		break;
 	case WM_T_PCH_SPT:
+	case WM_T_PCH_CNP:
 		sc->nvm.read = wm_nvm_read_spt;
 		/* SPT has no GFPREG; flash registers mapped through BAR0 */
 		sc->sc_flags |= WM_F_EEPROM_FLASH;
@@ -2468,6 +2482,7 @@ alloc_retry:
 	case WM_T_PCH2:
 	case WM_T_PCH_LPT:
 	case WM_T_PCH_SPT:
+	case WM_T_PCH_CNP:
 		/* XXX The funcid should be checked on some devices */
 		apme_mask = WUC_APME;
 		eeprom_data = CSR_READ(sc, WMREG_WUC);
@@ -2577,7 +2592,8 @@ alloc_retry:
 	if (sc->sc_type == WM_T_ICH8 || sc->sc_type == WM_T_ICH9
 	|| sc->sc_type == WM_T_ICH10 || sc->sc_type == WM_T_PCH
 	|| sc->sc_type == WM_T_PCH2 || sc->sc_type == WM_T_PCH_LPT
-	|| sc->sc_type == WM_T_PCH_SPT || sc->sc_type == WM_T_82573
+	|| sc->sc_type == WM_T_PCH_SPT || sc->sc_type == WM_T_PCH_CNP
+	|| sc->sc_type == WM_T_82573
 	|| sc->sc_type == WM_T_82574 || sc->sc_type == WM_T_82583) {
 		/* Copper only */
 	} else if ((sc->sc_type == WM_T_82575) || (sc->sc_type == WM_T_82576)
@@ -2731,6 +2747,7 @@ alloc_retry:
 	case WM_T_PCH2:	/* PCH2 supports 9K frame size */
 	case WM_T_PCH_LPT:
 	case WM_T_PCH_SPT:
+	case WM_T_PCH_CNP:
 		/* XXX limited to 9234 */
 		sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU;
 		break;
@@ -3374,6 +3391,7 @@ wm_set_ral(struct wm_softc *sc, const ui
 	case WM_T_PCH2:
 	case WM_T_PCH_LPT:
 	case WM_T_PCH_SPT:
+	case WM_T_PCH_CNP:
 		if (idx == 0) {
 			CSR_WRITE(sc, WMREG_CORDOVA_RAL(idx), ral_lo);
 			CSR_WRITE_FLUSH(sc);
@@ -3431,7 +3449,7 @@ wm_mchash(struct wm_softc *sc, const uin
 	if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
 	|| (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)
 	|| (sc->sc_type == WM_T_PCH2) || (sc->sc_type == WM_T_PCH_LPT)
-	|| (sc->sc_type == WM_T_PCH_SPT)) {
+	|| (sc->sc_type == WM_T_PCH_SPT) || (sc->sc_type == WM_T_PCH_CNP)){
 		hash = (enaddr[4] >> ich8_lo_shift[sc->sc_mchash_type]) |
 		(((uint16_t) enaddr[5]) << ich8_hi_shift[sc->sc_mchash_type]);
 		return (hash & 0x3ff);
@@ -3486,7 +3504,8 @@ wm_set_filter(struct wm_softc *sc)
 		size = WM_RAL_TABSIZE_ICH8;
 	else if (sc->sc_type == WM_T_PCH2)
 		size = WM_RAL_TABSIZE_PCH2;
-	else if ((sc->sc_type == WM_T_PCH_LPT) ||(sc->sc_type == WM_T_PCH_SPT))
+	else if ((sc->sc_type == WM_T_PCH_LPT) || (sc->sc_type == WM_T_PCH_SPT)
+	|| (sc->sc_type == WM_T_PCH_CNP))
 		size = WM_RAL_TABSIZE_PCH_LPT;
 	else if (sc->sc_type == WM_T_82575)
 		size = WM_RAL_TABSIZE_82575;
@@ -3498,7 +3517,8 @@ wm_set_filter(struct wm_softc *sc)
 		size = WM_RAL_TABSIZE;
 	wm_set_ral(sc, CLLADDR(ifp->if_sadl), 0);
 
-	if 

CVS commit: src/sys/dev/pci

2018-04-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 12 03:13:04 UTC 2018

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

Log Message:
 If the extended configration size in the EXTCNFSIZE register is 0, don't
continue.


To generate a diff of this commit:
cvs rdiff -u -r1.568 -r1.569 src/sys/dev/pci/if_wm.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_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.568 src/sys/dev/pci/if_wm.c:1.569
--- src/sys/dev/pci/if_wm.c:1.568	Thu Apr 12 03:09:24 2018
+++ src/sys/dev/pci/if_wm.c	Thu Apr 12 03:13:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.568 2018/04/12 03:09:24 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.569 2018/04/12 03:13:04 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.568 2018/04/12 03:09:24 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.569 2018/04/12 03:13:04 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3931,6 +3931,8 @@ wm_init_lcd_from_nvm(struct wm_softc *sc
 	
 	reg = CSR_READ(sc, WMREG_EXTCNFSIZE);
 	cnf_size = __SHIFTOUT(reg, EXTCNFSIZE_LENGTH);
+	if (cnf_size == 0)
+		goto release;
 
 	if (((sc->sc_type == WM_T_PCH)
 		&& ((extcnfctr & EXTCNFCTR_OEM_WRITE_ENABLE) == 0))



CVS commit: src/sys/dev/pci

2018-04-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 12 03:09:24 UTC 2018

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

Log Message:
 Our PCH_SPT part of wm_nvm_valid_bank_detect_ich8lan() was based on
FreeBSD r287467. After that, they reverted it and committed the different
code in r287762. r287762's bank detect code didn't work for us because our wm
dirver had a problem in flash access. The problem was fixed in if_wm.c rev.
1.567, so we can use the new way now.


To generate a diff of this commit:
cvs rdiff -u -r1.567 -r1.568 src/sys/dev/pci/if_wm.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_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.567 src/sys/dev/pci/if_wm.c:1.568
--- src/sys/dev/pci/if_wm.c:1.567	Thu Apr 12 02:48:59 2018
+++ src/sys/dev/pci/if_wm.c	Thu Apr 12 03:09:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.567 2018/04/12 02:48:59 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.568 2018/04/12 03:09:24 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.567 2018/04/12 02:48:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.568 2018/04/12 03:09:24 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -11934,23 +11934,38 @@ wm_nvm_valid_bank_detect_ich8lan(struct 
 	uint32_t act_offset = ICH_NVM_SIG_WORD * 2 + 1;
 	uint32_t bank1_offset = sc->sc_ich8_flash_bank_size * sizeof(uint16_t);
 	uint8_t sig_byte = 0;
+	uint32_t nvm_dword = 0;
+ 	int rv;
 
 	switch (sc->sc_type) {
 	case WM_T_PCH_SPT:
-		/*
-		 * In SPT, read from the CTRL_EXT reg instead of accessing the
-		 * sector valid bits from the NVM.
-		 */
-		*bank = CSR_READ(sc, WMREG_CTRL_EXT) & CTRL_EXT_NVMVS;
-		if ((*bank == 0) || (*bank == 1)) {
-			aprint_error_dev(sc->sc_dev,
-			"%s: no valid NVM bank present (%u)\n", __func__,
-*bank);
-			return -1;
-		} else {
-			*bank = *bank - 2;
+		bank1_offset = sc->sc_ich8_flash_bank_size * 2;
+		act_offset = ICH_NVM_SIG_WORD * 2;
+
+		/* set bank to 0 in case flash read fails. */
+		*bank = 0;
+
+		/* Check bank 0 */
+		rv = wm_read_ich8_dword(sc, act_offset, _dword);
+		if (rv != 0)
+			return rv;
+		sig_byte = (uint8_t)((nvm_dword & 0xFF00) >> 8);
+		if ((sig_byte & ICH_NVM_VALID_SIG_MASK) == ICH_NVM_SIG_VALUE) {
+			*bank = 0;
 			return 0;
 		}
+
+		/* Check bank 1 */
+		rv = wm_read_ich8_dword(sc, act_offset + bank1_offset,
+		_dword);
+		sig_byte = (uint8_t)((nvm_dword & 0xFF00) >> 8);
+		if ((sig_byte & ICH_NVM_VALID_SIG_MASK) == ICH_NVM_SIG_VALUE) {
+			*bank = 1;
+			return 0;
+		}
+		aprint_error_dev(sc->sc_dev,
+		"%s: no valid NVM bank present (%u)\n", __func__, *bank);
+		return -1;
 	case WM_T_ICH8:
 	case WM_T_ICH9:
 		eecd = CSR_READ(sc, WMREG_EECD);



CVS commit: src/sys/dev/pci

2018-04-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 12 02:49:00 UTC 2018

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

Log Message:
 On PCH_SPT (and newer), FLASH access should be done by 32bit.
Especially for ICH_FLASH_HSFCTL register, it's located at 0x0006, so
it should be accessed via ICH_FLASH_HSFSTS(0x0004) and use shift or mask.


To generate a diff of this commit:
cvs rdiff -u -r1.566 -r1.567 src/sys/dev/pci/if_wm.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_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.566 src/sys/dev/pci/if_wm.c:1.567
--- src/sys/dev/pci/if_wm.c:1.566	Thu Mar  1 03:32:33 2018
+++ src/sys/dev/pci/if_wm.c	Thu Apr 12 02:48:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.566 2018/03/01 03:32:33 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.567 2018/04/12 02:48:59 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.566 2018/03/01 03:32:33 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.567 2018/04/12 02:48:59 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -11997,7 +11997,10 @@ wm_ich8_cycle_init(struct wm_softc *sc)
 	int32_t error = 1;
 	int32_t i = 0;
 
-	hsfsts = ICH8_FLASH_READ16(sc, ICH_FLASH_HSFSTS);
+	if (sc->sc_type >= WM_T_PCH_SPT)
+		hsfsts = ICH8_FLASH_READ32(sc, ICH_FLASH_HSFSTS) & 0xUL;
+	else
+		hsfsts = ICH8_FLASH_READ16(sc, ICH_FLASH_HSFSTS);
 
 	/* May be check the Flash Des Valid bit in Hw status */
 	if ((hsfsts & HSFSTS_FLDVAL) == 0) {
@@ -12008,7 +12011,10 @@ wm_ich8_cycle_init(struct wm_softc *sc)
 	/* Clear DAEL in Hw status by writing a 1 */
 	hsfsts |= HSFSTS_ERR | HSFSTS_DAEL;
 
-	ICH8_FLASH_WRITE16(sc, ICH_FLASH_HSFSTS, hsfsts);
+	if (sc->sc_type >= WM_T_PCH_SPT)
+		ICH8_FLASH_WRITE32(sc, ICH_FLASH_HSFSTS, hsfsts & 0xUL);
+	else
+		ICH8_FLASH_WRITE16(sc, ICH_FLASH_HSFSTS, hsfsts);
 
 	/*
 	 * Either we should have a hardware SPI cycle in progress bit to check
@@ -12029,7 +12035,11 @@ wm_ich8_cycle_init(struct wm_softc *sc)
 
 		/* Begin by setting Flash Cycle Done. */
 		hsfsts |= HSFSTS_DONE;
-		ICH8_FLASH_WRITE16(sc, ICH_FLASH_HSFSTS, hsfsts);
+		if (sc->sc_type >= WM_T_PCH_SPT)
+			ICH8_FLASH_WRITE32(sc, ICH_FLASH_HSFSTS,
+			hsfsts & 0xUL);
+		else
+			ICH8_FLASH_WRITE16(sc, ICH_FLASH_HSFSTS, hsfsts);
 		error = 0;
 	} else {
 		/*
@@ -12037,7 +12047,12 @@ wm_ich8_cycle_init(struct wm_softc *sc)
 		 * chance to end before giving up.
 		 */
 		for (i = 0; i < ICH_FLASH_COMMAND_TIMEOUT; i++) {
-			hsfsts = ICH8_FLASH_READ16(sc, ICH_FLASH_HSFSTS);
+			if (sc->sc_type >= WM_T_PCH_SPT)
+hsfsts = ICH8_FLASH_READ32(sc,
+ICH_FLASH_HSFSTS) & 0xUL;
+			else
+hsfsts = ICH8_FLASH_READ16(sc,
+ICH_FLASH_HSFSTS);
 			if ((hsfsts & HSFSTS_FLINPRO) == 0) {
 error = 0;
 break;
@@ -12050,7 +12065,12 @@ wm_ich8_cycle_init(struct wm_softc *sc)
 			 * now set the Flash Cycle Done.
 			 */
 			hsfsts |= HSFSTS_DONE;
-			ICH8_FLASH_WRITE16(sc, ICH_FLASH_HSFSTS, hsfsts);
+			if (sc->sc_type >= WM_T_PCH_SPT)
+ICH8_FLASH_WRITE32(sc, ICH_FLASH_HSFSTS,
+hsfsts & 0xUL);
+			else
+ICH8_FLASH_WRITE16(sc, ICH_FLASH_HSFSTS,
+hsfsts);
 		}
 	}
 	return error;
@@ -12070,13 +12090,24 @@ wm_ich8_flash_cycle(struct wm_softc *sc,
 	uint32_t i = 0;
 
 	/* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
-	hsflctl = ICH8_FLASH_READ16(sc, ICH_FLASH_HSFCTL);
+	if (sc->sc_type >= WM_T_PCH_SPT)
+		hsflctl = ICH8_FLASH_READ32(sc, ICH_FLASH_HSFSTS) >> 16;
+	else
+		hsflctl = ICH8_FLASH_READ16(sc, ICH_FLASH_HSFCTL);
 	hsflctl |= HSFCTL_GO;
-	ICH8_FLASH_WRITE16(sc, ICH_FLASH_HSFCTL, hsflctl);
+	if (sc->sc_type >= WM_T_PCH_SPT)
+		ICH8_FLASH_WRITE32(sc, ICH_FLASH_HSFSTS,
+		(uint32_t)hsflctl << 16);
+	else
+		ICH8_FLASH_WRITE16(sc, ICH_FLASH_HSFCTL, hsflctl);
 
 	/* Wait till FDONE bit is set to 1 */
 	do {
-		hsfsts = ICH8_FLASH_READ16(sc, ICH_FLASH_HSFSTS);
+		if (sc->sc_type >= WM_T_PCH_SPT)
+			hsfsts = ICH8_FLASH_READ32(sc, ICH_FLASH_HSFSTS)
+			& 0xUL;
+		else
+			hsfsts = ICH8_FLASH_READ16(sc, ICH_FLASH_HSFSTS);
 		if (hsfsts & HSFSTS_DONE)
 			break;
 		delay(1);
@@ -12121,18 +12152,22 @@ wm_read_ich8_data(struct wm_softc *sc, u
 		if (error)
 			break;
 
-		hsflctl = ICH8_FLASH_READ16(sc, ICH_FLASH_HSFCTL);
+		if (sc->sc_type >= WM_T_PCH_SPT)
+			hsflctl = ICH8_FLASH_READ32(sc, ICH_FLASH_HSFSTS)
+			>> 16;
+		else
+			hsflctl = ICH8_FLASH_READ16(sc, ICH_FLASH_HSFCTL);
 		/* 0b/1b corresponds to 1 or 2 byte size, respectively. */
 		hsflctl |=  ((size - 1) << HSFCTL_BCOUNT_SHIFT)
 		& HSFCTL_BCOUNT_MASK;
 		hsflctl |= ICH_CYCLE_READ << HSFCTL_CYCLE_SHIFT;
-		if (sc->sc_type == WM_T_PCH_SPT) {
+		if (sc->sc_type >= WM_T_PCH_SPT) {
 			/*
 			 * In SPT, This register is in Lan memory space, not
 			 * flash. 

CVS commit: src/sys/dev/pci

2018-04-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 12 02:15:07 UTC 2018

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

Log Message:
No binary change:
- Sort registers.
- Lowercase hexadecimal value.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/pci/if_wmreg.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_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.106 src/sys/dev/pci/if_wmreg.h:1.107
--- src/sys/dev/pci/if_wmreg.h:1.106	Tue Apr 10 08:18:38 2018
+++ src/sys/dev/pci/if_wmreg.h	Thu Apr 12 02:15:07 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.106 2018/04/10 08:18:38 msaitoh Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.107 2018/04/12 02:15:07 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -511,15 +511,15 @@ struct livengood_tcpip_ctxdesc {
 #define EECD_SEC1VAL	(1U << 22)	/* Sector One Valid */
 #define EECD_SEC1VAL_VALMASK (EECD_EE_AUTORD | EECD_EE_PRES) /* Valid Mask */
 
+#define	WMREG_FEXTNVM6	0x0010	/* Future Extended NVM 6 */
+#define	FEXTNVM6_K1_OFF_ENABLE	__BIT(31)
+
 #define	WMREG_EERD	0x0014	/* EEPROM read */
 #define	EERD_DONE	0x02/* done bit */
 #define	EERD_START	0x01	/* First bit for telling part to start operation */
 #define	EERD_ADDR_SHIFT	2	/* Shift to the address bits */
 #define	EERD_DATA_SHIFT	16	/* Offset to data in EEPROM read/write registers */
 
-#define	WMREG_FEXTNVM6	0x0010	/* Future Extended NVM 6 */
-#define	FEXTNVM6_K1_OFF_ENABLE	__BIT(31)
-
 #define	WMREG_CTRL_EXT	0x0018	/* Extended Device Control Register */
 #define	CTRL_EXT_NSICR		__BIT(0) /* Non Interrupt clear on read */
 #define	CTRL_EXT_GPI_EN(x)	(1U << (x)) /* gpin interrupt enable */
@@ -544,14 +544,14 @@ struct livengood_tcpip_ctxdesc {
 #define	CTRL_EXT_SDLPE		(1U << 18) /* SerDes Low Power Enable */
 #define	CTRL_EXT_DMA_DYN_CLK	(1U << 19) /* DMA Dynamic Gating Enable */
 #define	CTRL_EXT_PHYPDEN	__BIT(20)
-#define	CTRL_EXT_LINK_MODE_MASK		0x00C0
+#define	CTRL_EXT_LINK_MODE_MASK		0x00c0
 #define	CTRL_EXT_LINK_MODE_GMII		0x
 #define	CTRL_EXT_LINK_MODE_KMRN		0x
 #define	CTRL_EXT_LINK_MODE_1000KX	0x0040
 #define	CTRL_EXT_LINK_MODE_SGMII	0x0080
 #define	CTRL_EXT_LINK_MODE_PCIX_SERDES	0x0080
-#define	CTRL_EXT_LINK_MODE_TBI		0x00C0
-#define	CTRL_EXT_LINK_MODE_PCIE_SERDES	0x00C0
+#define	CTRL_EXT_LINK_MODE_TBI		0x00c0
+#define	CTRL_EXT_LINK_MODE_PCIE_SERDES	0x00c0
 #define	CTRL_EXT_EIAME		__BIT(24) /* Extended Interrupt Auto Mask En */
 #define CTRL_EXT_I2C_ENA	0x0200  /* I2C enable */
 #define	CTRL_EXT_DRV_LOAD	0x1000
@@ -599,8 +599,8 @@ struct livengood_tcpip_ctxdesc {
 #define	WMREG_FCT	0x0030	/* Flow Control Type */
 
 #define	WMREG_KUMCTRLSTA 0x0034	/* MAC-PHY interface - RW */
-#define	KUMCTRLSTA_MASK			0x
-#define	KUMCTRLSTA_OFFSET		0x001F
+#define	KUMCTRLSTA_MASK			0x
+#define	KUMCTRLSTA_OFFSET		0x001f
 #define	KUMCTRLSTA_OFFSET_SHIFT		16
 #define	KUMCTRLSTA_REN			0x0020
 
@@ -612,8 +612,8 @@ struct livengood_tcpip_ctxdesc {
 #define	KUMCTRLSTA_OFFSET_K1_CONFIG	0x0007
 #define	KUMCTRLSTA_OFFSET_INB_PARAM	0x0009
 #define	KUMCTRLSTA_OFFSET_HD_CTRL	0x0010
-#define	KUMCTRLSTA_OFFSET_M2P_SERDES	0x001E
-#define	KUMCTRLSTA_OFFSET_M2P_MODES	0x001F
+#define	KUMCTRLSTA_OFFSET_M2P_SERDES	0x001e
+#define	KUMCTRLSTA_OFFSET_M2P_MODES	0x001f
 
 /* FIFO Control */
 #define	KUMCTRLSTA_FIFO_CTRL_RX_BYPASS	0x0008
@@ -638,7 +638,7 @@ struct livengood_tcpip_ctxdesc {
 #define	KUMCTRLSTA_OPMODE_INBAND_MDIO 0x0004
 
 #define	WMREG_VET	0x0038	/* VLAN Ethertype */
-#define	WMREG_MDPHYA	0x003C	/* PHY address - RW */
+#define	WMREG_MDPHYA	0x003c	/* PHY address - RW */
 
 #define WMREG_FEXTNVM3	0x003c	/* Future Extended NVM 3 */
 #define FEXTNVM3_PHY_CFG_COUNTER_MASK	__BITS(27, 26)
@@ -795,7 +795,7 @@ struct livengood_tcpip_ctxdesc {
 #define	WMREG_OLD_RDBAL0 0x0110	/* Receive Descriptor Base Low (ring 0) */
 #define	WMREG_RDBAL(x) \
 	((x) < 4 ? (0x02800 + ((x) * 0x100)) :	\
-	(0x0C000 + ((x) * 0x40)))
+	(0x0c000 + ((x) * 0x40)))
 
 #define	WMREG_OLD_RDBAH0 0x0114	/* Receive Descriptor Base High (ring 0) */
 #define	WMREG_RDBAH(x) \
@@ -826,12 +826,12 @@ struct livengood_tcpip_ctxdesc {
 #define	WMREG_OLD_RDH0	0x0120	/* Receive Descriptor Head (ring 0) */
 #define	WMREG_RDH(x) \
 	((x) < 4 ? (0x02810 + ((x) * 0x100)) :  \
-	(0x0C010 + ((x) * 0x40)))
+	(0x0c010 + ((x) * 0x40)))
 
 #define	WMREG_OLD_RDT0	0x0128	/* Receive Descriptor Tail (ring 0) */
 #define	WMREG_RDT(x) \
 	((x) < 4 ? (0x02818 + ((x) * 0x100)) :	\
-	(0x0C018 + ((x) * 0x40)))
+	(0x0c018 + ((x) * 0x40)))
 
 #define	WMREG_RXDCTL(x) \
 	((x) < 4 ? (0x02828 + ((x) * 0x100)) :	\
@@ -851,11 +851,11 @@ struct livengood_tcpip_ctxdesc {
 #define	WMREG_OLD_RDH1	0x0148
 #define	WMREG_OLD_RDT1	0x0150
 #define	WMREG_OLD_FCRTH 0x0160	/* Flow Control Rx Threshold Hi 

CVS commit: [netbsd-8] src/doc

2018-04-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 12 01:51:32 UTC 2018

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

Log Message:
Ticket #741 and #$44.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.178 -r1.1.2.179 src/doc/CHANGES-8.0

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.0
diff -u src/doc/CHANGES-8.0:1.1.2.178 src/doc/CHANGES-8.0:1.1.2.179
--- src/doc/CHANGES-8.0:1.1.2.178	Wed Apr 11 14:55:24 2018
+++ src/doc/CHANGES-8.0	Thu Apr 12 01:51:32 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.178 2018/04/11 14:55:24 martin Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.179 2018/04/12 01:51:32 msaitoh Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -11626,3 +11626,1057 @@ sys/arch/x86/pci/pci_machdep.c			1.80
 	network inteface.
 	[nonaka, ticket #740]
 
+external/bsd/nvi/dist/common/recover.c		1.10
+external/bsd/nvi/dist/common/recover.c		1.11
+lib/libc/stdio/fdopen.c1.18
+lib/libc/stdio/flags.c1.19
+lib/libc/stdio/fopen.c1.17
+lib/libc/stdio/freopen.c			1.20
+lib/libc/sys/open.21.58
+sys/kern/vfs_vnops.c1.196
+sys/sys/fcntl.h	1.49
+
+	- Add O_REGULAR to enforce opening of only regular files (like we have
+	  O_DIRECTORY for directories).
+	- vi(1): Make the checkok test stricter to avoid races, and use
+	  O_REGULAR.
+	- vi:(1): Instead of opening the file and using popen(3), pass the file
+	  descriptor to sendmail directory. Idea and code from Todd Miller.
+	  [christos, ticket #741]
+
+doc/3RDPARTY	1.1502
+distrib/sets/lists/base/shl.mi			1.829
+distrib/sets/lists/debug/shl.mi			1.191
+external/bsd/unbound/Makefile.inc   up to 1.4
+external/bsd/unbound/dist/.gitattributesup to 1.1.1.1
+external/bsd/unbound/dist/.gitignoreup to 1.1.1.2
+external/bsd/unbound/dist/Makefile.in   up to 1.1.1.2
+external/bsd/unbound/dist/ac_pkg_swig.m4up to 1.1.1.2
+external/bsd/unbound/dist/aclocal.m4up to 1.1.1.2
+external/bsd/unbound/dist/acx_nlnetlabs.m4  up to 1.1.1.2
+external/bsd/unbound/dist/acx_python.m4 up to 1.1.1.2
+external/bsd/unbound/dist/cachedb/cachedb.c up to 1.1.1.2
+external/bsd/unbound/dist/compat/arc4_lock.cup to 1.1.1.2
+external/bsd/unbound/dist/compat/arc4random.c   up to 1.1.1.2
+external/bsd/unbound/dist/compat/ctime_r.c  up to 1.1.1.2
+external/bsd/unbound/dist/compat/getentropy_linux.c up to 1.1.1.2
+external/bsd/unbound/dist/config.h.in   up to 1.1.1.2
+external/bsd/unbound/dist/configure up to 1.1.1.2
+external/bsd/unbound/dist/configure.ac  up to 1.1.1.2
+external/bsd/unbound/dist/contrib/READMEup to 1.1.1.2
+external/bsd/unbound/dist/contrib/-filter-iterator.patch up to 1.1.1.2
+external/bsd/unbound/dist/contrib/fastrpz.patch up to 1.1.1.1
+external/bsd/unbound/dist/contrib/libunbound.pc.in up to 1.1.1.1
+external/bsd/unbound/dist/contrib/parseunbound.pl up to 1.1.1.2
+external/bsd/unbound/dist/contrib/redirect-bogus.patch up to 1.1.1.1
+external/bsd/unbound/dist/contrib/unbound.service.in up to 1.1.1.1
+external/bsd/unbound/dist/contrib/unbound.socket.in up to 1.1.1.1
+external/bsd/unbound/dist/contrib/unbound_munin_ up to 1.1.1.2
+external/bsd/unbound/dist/daemon/acl_list.c up to 1.1.1.2
+external/bsd/unbound/dist/daemon/acl_list.h up to 1.1.1.2
+external/bsd/unbound/dist/daemon/cachedump.cup to 1.1.1.2
+external/bsd/unbound/dist/daemon/daemon.c   up to 1.1.1.2
+external/bsd/unbound/dist/daemon/daemon.h   up to 1.1.1.2
+external/bsd/unbound/dist/daemon/remote.c   up to 1.1.1.2
+external/bsd/unbound/dist/daemon/remote.h   up to 1.1.1.2
+external/bsd/unbound/dist/daemon/stats.cup to 1.1.1.2
+external/bsd/unbound/dist/daemon/stats.hup to 1.1.1.2
+external/bsd/unbound/dist/daemon/unbound.c  up to 1.1.1.2
+external/bsd/unbound/dist/daemon/worker.c   up to 1.1.1.2
+external/bsd/unbound/dist/daemon/worker.h   up to 1.1.1.2
+external/bsd/unbound/dist/dns64/dns64.c up to 1.1.1.2
+external/bsd/unbound/dist/dnscrypt/cert.h   up to 1.1.1.1
+external/bsd/unbound/dist/dnscrypt/dnscrypt.c   up to 1.1.1.1
+external/bsd/unbound/dist/dnscrypt/dnscrypt.h   up to 1.1.1.1
+external/bsd/unbound/dist/dnscrypt/dnscrypt.m4  up to 1.1.1.1
+external/bsd/unbound/dist/dnscrypt/dnscrypt_config.h.in up to 1.1.1.1
+external/bsd/unbound/dist/dnscrypt/testdata/gencert.sh up to 1.1.1.1
+external/bsd/unbound/dist/dnscrypt/testdata/keys1/public.key up to 1.1.1.1
+external/bsd/unbound/dist/dnscrypt/testdata/keys1/secret.key up to 1.1.1.1
+external/bsd/unbound/dist/dnscrypt/testdata/keys2/public.key up to 1.1.1.1
+external/bsd/unbound/dist/dnscrypt/testdata/keys2/secret.key up to 1.1.1.1
+external/bsd/unbound/dist/dnstap/dnstap.c   up to 1.1.1.2

CVS commit: [netbsd-8] src

2018-04-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 12 01:45:58 UTC 2018

Modified Files:
src/external/bsd/nvi/dist/common [netbsd-8]: recover.c
src/lib/libc/stdio [netbsd-8]: fdopen.c flags.c fopen.c freopen.c
src/lib/libc/sys [netbsd-8]: open.2
src/sys/kern [netbsd-8]: vfs_vnops.c
src/sys/sys [netbsd-8]: fcntl.h

Log Message:
Pull up following revision(s) (requested by christos in ticket #741):
lib/libc/stdio/flags.c: revision 1.19
lib/libc/stdio/fdopen.c: revision 1.18
sys/kern/vfs_vnops.c: revision 1.196
lib/libc/stdio/freopen.c: revision 1.20
lib/libc/stdio/fopen.c: revision 1.17
external/bsd/nvi/dist/common/recover.c: revision 1.10
external/bsd/nvi/dist/common/recover.c: revision 1.11
lib/libc/sys/open.2: revision 1.58
sys/sys/fcntl.h: revision 1.49
make the checkok test stricter to avoid races, and use O_REGULAR.
Instead of opening the file and using popen(3), pass the file descriptor
to sendmail directory. Idea and code from Todd Miller.
Add O_REGULAR to enforce opening of only regular files
(like we have O_DIRECTORY for directories).
This is better than open(, O_NONBLOCK), fstat()+S_ISREG() because opening
devices can have side effects.


To generate a diff of this commit:
cvs rdiff -u -r1.5.22.1 -r1.5.22.2 src/external/bsd/nvi/dist/common/recover.c
cvs rdiff -u -r1.17 -r1.17.6.1 src/lib/libc/stdio/fdopen.c
cvs rdiff -u -r1.17 -r1.17.22.1 src/lib/libc/stdio/flags.c
cvs rdiff -u -r1.15 -r1.15.24.1 src/lib/libc/stdio/fopen.c
cvs rdiff -u -r1.19 -r1.19.24.1 src/lib/libc/stdio/freopen.c
cvs rdiff -u -r1.57 -r1.57.2.1 src/lib/libc/sys/open.2
cvs rdiff -u -r1.195 -r1.195.6.1 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.48.8.1 -r1.48.8.2 src/sys/sys/fcntl.h

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/nvi/dist/common/recover.c
diff -u src/external/bsd/nvi/dist/common/recover.c:1.5.22.1 src/external/bsd/nvi/dist/common/recover.c:1.5.22.2
--- src/external/bsd/nvi/dist/common/recover.c:1.5.22.1	Mon Nov  6 09:37:24 2017
+++ src/external/bsd/nvi/dist/common/recover.c	Thu Apr 12 01:45:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: recover.c,v 1.5.22.1 2017/11/06 09:37:24 snj Exp $ */
+/*	$NetBSD: recover.c,v 1.5.22.2 2018/04/12 01:45:57 msaitoh Exp $ */
 /*-
  * Copyright (c) 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,12 +16,13 @@
 static const char sccsid[] = "Id: recover.c,v 10.31 2001/11/01 15:24:44 skimo Exp  (Berkeley) Date: 2001/11/01 15:24:44 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: recover.c,v 1.5.22.1 2017/11/06 09:37:24 snj Exp $");
+__RCSID("$NetBSD: recover.c,v 1.5.22.2 2018/04/12 01:45:57 msaitoh Exp $");
 #endif
 
 #include 
 #include 		/* XXX: param.h may not have included types.h */
 #include 
+#include 
 #include 
 
 /*
@@ -116,11 +117,15 @@ __RCSID("$NetBSD: recover.c,v 1.5.22.1 2
 #define	VI_PHEADER	"X-vi-recover-path: "
 
 static int	 rcv_copy(SCR *, int, char *);
-static void	 rcv_email(SCR *, const char *);
+static void	 rcv_email(SCR *, int fd);
 static char	*rcv_gets(char *, size_t, int);
 static int	 rcv_mailfile(SCR *, int, char *);
 static int	 rcv_mktemp(SCR *, char *, const char *, int);
 
+#ifndef O_REGULAR
+#define O_REGULAR O_NONBLOCK
+#endif
+
 /*
  * rcv_tmp --
  *	Build a file name that will be used as the recovery file.
@@ -286,7 +291,7 @@ rcv_sync(SCR *sp, u_int flags)
 
 		/* REQUEST: send email. */
 		if (LF_ISSET(RCV_EMAIL))
-			rcv_email(sp, ep->rcv_mpath);
+			rcv_email(sp, ep->rcv_fd);
 	}
 
 	/*
@@ -466,7 +471,7 @@ wout:		*t2++ = '\n';
 	}
 
 	if (issync) {
-		rcv_email(sp, mpath);
+		rcv_email(sp, fd);
 		if (close(fd)) {
 werr:			msgq(sp, M_SYSERR, "065|Recovery file");
 			goto err;
@@ -487,14 +492,19 @@ err:	if (!issync)
  * This is simpler than checking for getuid() == st.st_uid and we want
  * to preserve the functionality that root can recover anything which
  * means that root should know better and be careful.
+ *
+ * Checking the mode is racy though (someone can chmod between the
+ * open and the stat call, so also check for uid match or root.
  */
 static int
 checkok(int fd)
 {
 	struct stat sb;
+	uid_t uid = getuid();
 
 	return fstat(fd, ) != -1 && S_ISREG(sb.st_mode) &&
-	(sb.st_mode & (S_IRWXG|S_IRWXO)) == 0;
+	(sb.st_mode & (S_IRWXG|S_IRWXO)) == 0 &&
+	(uid == 0 || uid == sb.st_uid);
 }
 
 /*
@@ -659,7 +669,7 @@ rcv_read(SCR *sp, FREF *frp)
 		 * if we're using fcntl(2), there's no way to lock a file
 		 * descriptor that's not open for writing.
 		 */
-		if ((fd = open(recpath, O_RDWR|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC,
+		if ((fd = open(recpath, O_RDWR|O_REGULAR|O_NOFOLLOW|O_CLOEXEC,
 		0)) == -1)
 			continue;
 
@@ -876,12 +886,10 @@ rcv_mktemp(SCR *sp, char *path, const ch
  *	Send email.
  */
 static void
-rcv_email(SCR *sp, const char *fname)

CVS commit: src/sys/kern

2018-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 11 23:20:15 UTC 2018

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

Log Message:
fix type confusion on 32 bits


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/kern/subr_prf.c

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

Modified files:

Index: src/sys/kern/subr_prf.c
diff -u src/sys/kern/subr_prf.c:1.166 src/sys/kern/subr_prf.c:1.167
--- src/sys/kern/subr_prf.c:1.166	Wed Apr 11 11:25:58 2018
+++ src/sys/kern/subr_prf.c	Wed Apr 11 19:20:15 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_prf.c,v 1.166 2018/04/11 15:25:58 christos Exp $	*/
+/*	$NetBSD: subr_prf.c,v 1.167 2018/04/11 23:20:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 1986, 1988, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.166 2018/04/11 15:25:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.167 2018/04/11 23:20:15 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -494,7 +494,7 @@ addtstamp(int flags, struct tty *tp)
 
 	getnanouptime();
 	n = snprintf(buf, sizeof(buf), "[% 9jd.%.9ld] ",
-	(intptr_t)ts.tv_sec, ts.tv_nsec);
+	(intmax_t)ts.tv_sec, ts.tv_nsec);
 
 	for (int i = 0; i < n; i++)
 		putone(buf[i], flags, tp);



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

2018-04-11 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Wed Apr 11 19:44:47 UTC 2018

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: Update TODO file with current state of sun4v support


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sparc64/doc/TODO

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/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.25 src/sys/arch/sparc64/doc/TODO:1.26
--- src/sys/arch/sparc64/doc/TODO:1.25	Sat Feb  3 21:45:54 2018
+++ src/sys/arch/sparc64/doc/TODO	Wed Apr 11 19:44:47 2018
@@ -1,4 +1,4 @@
- /* $NetBSD: TODO,v 1.25 2018/02/03 21:45:54 palle Exp $ */
+ /* $NetBSD: TODO,v 1.26 2018/04/11 19:44:47 palle Exp $ */
 
 Things to be done:
 
@@ -11,7 +11,8 @@ sun4u:
 - GENERIC.UP kernel hangs on v445 (missing interrupt?)
 
 sun4v:
- - current status: The kernel boots and starts the init process (syscalls are done, but crashes...) (*)
+ - current status: The kernel boots and starts the init process (pid 1) 
+   which spawns /bin/sh (pid 2). This is forked as a new/bin/sh (pid 3) which crashes, probably due to MMU DPROT issues.
 - 64-bit kernel support
 - 32-bit kernel support
 - libkvm
@@ -33,39 +34,3 @@ sun4v:
 - vbus.c: handle prom_getprop() memory leaks
 - locore.s: rft_user (sun4v specific manaul fill) - seems to work, but is it good enough (compared to openbsds rft_user?
 
-
-(*)
-The current state of the code crashes in the code path after the init process
-(pid 1) does a fork(), starting pid 2.
-A new lwp is created and lwp_trampoline() is called which in turn calls 
-return_from_trap(). Here the code path continues to rft_user().
-A trap (0x68 - this is a Hyper-Priv trap...) occurs in rft_user_fault_start()
-where the FILL() macro causes the trap trying to load the local register %l0 
-from the stack using ASI AIUS (%o6 contains 0xcd91).
-The Hyper-Priv trap 0x68 is transformed to a Priv trap 0x31, causing 
-sun4v_dtsb_miss() to be called, continuing to sun4v_datatrap().
-Here TRAP_SETUP() is called, 
-The windows registers are now:  %otherwin=0, %cansave=6, canrestore=0.
-Part of the TRAP_SETUP() code will do a 'save %g6, 0, %sp', 
-The windows registers are now:  %otherwin=0, %cansave=5, canrestore=1.
-TRAP_SETUP() now updates %otherwin with the values of %canrestore and clears 
-%canrestore, so the windows registers are now: %otherwin=1, %cansave=5, 
-canrestore=0.
-The execution continues to data_access_fault() and further down the call stack
-with function calls until %cansave reaches 0 causing a spill trap 
-(0xa8 - spill_2_other). The contents of the %sp register is 0xe00x.
-%wstate is (octal) 26.
-The windows registers are now:  %otherwin=1, %cansave=0, canrestore=5.
-The spill code is using ASI AIUS. spill_2_other is selected since %otherwin is
-non-zero, so the index in wstate.other is 2 (spill_2_other).
-SPILLBOTH() is invoked, using ASI AIUS. While storing %l0 to %sp+0x7ff 
-(%sp is 0xcd91) a new trap occurs, 0x68 (Hyper-priv, e.g. 0x31 Priv)
-at trap level 2 causing the trap level to go to 3. This is above the mx trap
-level for sun4v which is 2...
-So... the first access to 0xcd91 causes a cyclic access to
-0xcd91 again causing the max trap level to exceed.
-hmhow to fix this..
-
-
-
-



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

2018-04-11 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Wed Apr 11 19:41:18 UTC 2018

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: handle MMU-related traps properly when they occur at trap level 1. This 
fixes issues when user-level LWPs access the user-level stack


To generate a diff of this commit:
cvs rdiff -u -r1.412 -r1.413 src/sys/arch/sparc64/sparc64/locore.s

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

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.412 src/sys/arch/sparc64/sparc64/locore.s:1.413
--- src/sys/arch/sparc64/sparc64/locore.s:1.412	Sat Aug 26 20:25:00 2017
+++ src/sys/arch/sparc64/sparc64/locore.s	Wed Apr 11 19:41:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.412 2017/08/26 20:25:00 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.413 2018/04/11 19:41:18 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1147,9 +1147,12 @@ _C_LABEL(trapbase_sun4v):
 	!
 	sun4v_trap_entry 36	! 0x000-0x023
 	CLEANWIN1		! 0x24-0x27 = clean window
-	sun4v_trap_entry 9	! 0x028-0x030
-	VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss)			! 0x031 = data MMU miss
-	sun4v_trap_entry 58	! 0x032-0x06b
+	sun4v_trap_entry 8	! 0x028-0x02F
+	VTRAP(T_DATAFAULT, sun4v_tl1_ptbl_miss)			! 0x030 = ???
+	VTRAP(T_DATA_MMU_MISS, sun4v_tl1_dtsb_miss)		! 0x031 = data MMU miss
+	VTRAP(T_DATA_ERROR, sun4v_tl1_ptbl_miss)		! 0x032 = ???
+	VTRAP(T_DATA_PROT, sun4v_tl1_ptbl_miss)			! 0x033 = ???
+	sun4v_trap_entry 56	! 0x034-0x06b
 	VTRAP(T_FDMMU_PROT, sun4v_tl1_dtsb_prot)		! 0x06c
 	sun4v_trap_entry 19	! 0x06d-0x07f
 	SPILL64(uspill8_sun4vt1,ASI_AIUS)			! 0x080 spill_0_normal -- save user windows
@@ -2858,6 +2861,79 @@ sun4v_dtsb_miss:
 	retry
 	NOTREACHED
 
+sun4v_tl1_dtsb_miss:
+	GET_MMFSA %g1! MMU Fault status area
+	add	%g1, 0x48, %g3
+	LDPTRA	[%g3] ASI_PHYS_CACHED, %g3	! Data fault address
+	add	%g1, 0x50, %g6
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g6	! Data fault context
+
+	GET_CTXBUSY %g4
+	sllx	%g6, 3, %g6			! Make it into an offset into ctxbusy
+	LDPTR	[%g4 + %g6], %g4		! Load up our page table.
+
+	srax	%g3, HOLESHIFT, %g5		! Check for valid address
+	brz,pt	%g5, 0f! Should be zero or -1
+	 inc	%g5! Make -1 -> 0
+	brnz,pn	%g5, sun4v_tl1_ptbl_miss	! Error! In hole!
+0:
+	srlx	%g3, STSHIFT, %g6
+	and	%g6, STMASK, %g6		! Index into pm_segs
+	sll	%g6, 3, %g6
+	add	%g4, %g6, %g4
+	LDPTRA	[%g4] ASI_PHYS_CACHED, %g4	! Load page directory pointer
+	srlx	%g3, PDSHIFT, %g6
+	and	%g6, PDMASK, %g6
+	sll	%g6, 3, %g6
+	brz,pn	%g4, sun4v_tl1_ptbl_miss	! NULL entry? check somewhere else
+	 add	%g4, %g6, %g4
+	LDPTRA	[%g4] ASI_PHYS_CACHED, %g4	! Load page table pointer
+
+	srlx	%g3, PTSHIFT, %g6		! Convert to ptab offset
+	and	%g6, PTMASK, %g6
+	sll	%g6, 3, %g6
+	brz,pn	%g4, sun4v_tl1_ptbl_miss	! NULL entry? check somewhere else
+	 add	%g4, %g6, %g6
+1:
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g4	! Fetch TTE
+	brgez,pn %g4, sun4v_tl1_ptbl_miss	! Entry invalid?  Punt
+	 or	%g4, SUN4V_TLB_ACCESS, %g7	! Update the access bit
+
+	btst	SUN4V_TLB_ACCESS, %g4		! Need to update access bit?
+	bne,pt	%xcc, 2f
+	 nop
+	casxa	[%g6] ASI_PHYS_CACHED, %g4, %g7	! and write it out
+	cmp	%g4, %g7
+	bne,pn	%xcc, 1b
+	 or	%g4, SUN4V_TLB_ACCESS, %g4	! Update the access bit
+2:
+	GET_TSB_DMMU %g2
+
+	/* Construct TSB tag word. */
+	add	%g1, 0x50, %g6
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g6	! Data fault context
+	mov	%g3, %g1			! Data fault address
+	srlx	%g1, 22, %g1			! 63..22 of virt addr
+	sllx	%g6, 48, %g6			! context_id in 63..48
+	or	%g1, %g6, %g1			! construct TTE tag
+	srlx	%g3, PTSHIFT, %g3
+	sethi	%hi(_C_LABEL(tsbsize)), %g5
+	mov	512, %g6
+	ld	[%g5 + %lo(_C_LABEL(tsbsize))], %g5
+	sllx	%g6, %g5, %g5			! %g5 = 512 << tsbsize = TSBENTS
+	sub	%g5, 1, %g5			! TSBENTS -> offset
+	and	%g3, %g5, %g3			! mask out TTE index
+	sllx	%g3, 4, %g3			! TTE size is 16 bytes
+	add	%g2, %g3, %g2			! location of TTE in ci_tsb_dmmu
+
+	membar	#StoreStore
+
+	STPTR	%g4, [%g2 + 8]			! store TTE data
+	STPTR	%g1, [%g2]			! store TTE tag
+
+	retry
+	NOTREACHED
+	
 sun4v_datatrap:
 	GET_MMFSA %g3! MMU Fault status area
 	add	%g3, 0x48, %g1



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

2018-04-11 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Wed Apr 11 19:37:58 UTC 2018

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

Log Message:
Fix typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/include/frame.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/frame.h
diff -u src/sys/arch/sparc/include/frame.h:1.9 src/sys/arch/sparc/include/frame.h:1.10
--- src/sys/arch/sparc/include/frame.h:1.9	Tue Oct  6 20:03:05 2015
+++ src/sys/arch/sparc/include/frame.h	Wed Apr 11 19:37:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: frame.h,v 1.9 2015/10/06 20:03:05 martin Exp $ */
+/*	$NetBSD: frame.h,v 1.10 2018/04/11 19:37:58 palle Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -104,7 +104,7 @@ struct frame32 {
  * of the frame, you must first force the kernel to write any such
  * windows to the stack.
  *
- * V9 frames have an odd bias, so you can tall a v9 frame from
+ * V9 frames have an odd bias, so you can tell a v9 frame from
  * a v8 frame by testing the stack pointer's lsb.
  */
 #if !defined(_LOCORE) && !defined(_LIBC)



CVS commit: src/bin/ps

2018-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 11 18:52:29 UTC 2018

Modified Files:
src/bin/ps: ps.c

Log Message:
kvm_geterr() already contains errno, use errx.


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

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

Modified files:

Index: src/bin/ps/ps.c
diff -u src/bin/ps/ps.c:1.90 src/bin/ps/ps.c:1.91
--- src/bin/ps/ps.c:1.90	Wed Apr 11 14:52:05 2018
+++ src/bin/ps/ps.c	Wed Apr 11 14:52:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ps.c,v 1.90 2018/04/11 18:52:05 christos Exp $	*/
+/*	$NetBSD: ps.c,v 1.91 2018/04/11 18:52:29 christos Exp $	*/
 
 /*
  * Copyright (c) 2000-2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19
 #if 0
 static char sccsid[] = "@(#)ps.c	8.4 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: ps.c,v 1.90 2018/04/11 18:52:05 christos Exp $");
+__RCSID("$NetBSD: ps.c,v 1.91 2018/04/11 18:52:29 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -425,7 +425,7 @@ main(int argc, char *argv[])
 	 * select procs
 	 */
 	if (!(kinfo = getkinfo_kvm(kd, what, flag, )))
-		err(EXIT_FAILURE, "%s", kvm_geterr(kd));
+		errx(EXIT_FAILURE, "%s", kvm_geterr(kd));
 	if (nentries == 0) {
 		printheader();
 		return 1;



CVS commit: src/bin/ps

2018-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 11 18:52:05 UTC 2018

Modified Files:
src/bin/ps: keyword.c print.c ps.c

Log Message:
use EXIT_FAILURE instead of 1


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/bin/ps/keyword.c
cvs rdiff -u -r1.128 -r1.129 src/bin/ps/print.c
cvs rdiff -u -r1.89 -r1.90 src/bin/ps/ps.c

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

Modified files:

Index: src/bin/ps/keyword.c
diff -u src/bin/ps/keyword.c:1.55 src/bin/ps/keyword.c:1.56
--- src/bin/ps/keyword.c:1.55	Sat Dec  9 09:56:54 2017
+++ src/bin/ps/keyword.c	Wed Apr 11 14:52:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: keyword.c,v 1.55 2017/12/09 14:56:54 kamil Exp $	*/
+/*	$NetBSD: keyword.c,v 1.56 2018/04/11 18:52:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)keyword.c	8.5 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: keyword.c,v 1.55 2017/12/09 14:56:54 kamil Exp $");
+__RCSID("$NetBSD: keyword.c,v 1.56 2018/04/11 18:52:05 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -308,7 +308,7 @@ parsevarlist(const char *pp, struct varl
 		if ((v = findvar(cp)) == NULL)
 			continue;
 		if ((vent = malloc(sizeof(struct varent))) == NULL)
-			err(1, NULL);
+			err(EXIT_FAILURE, NULL);
 		vent->var = v;
 		if (pos && *pos)
 		SIMPLEQ_INSERT_AFTER(listptr, *pos, vent, next);
@@ -320,7 +320,7 @@ parsevarlist(const char *pp, struct varl
 	}
  	free(sp);
 	if (SIMPLEQ_EMPTY(listptr))
-		errx(1, "no valid keywords");
+		errx(EXIT_FAILURE, "no valid keywords");
 }
 
 void
@@ -389,9 +389,9 @@ findvar(const char *p)
 		char *newheader;
 
 		if ((newvar = malloc(sizeof(struct var))) == NULL)
-			err(1, NULL);
+			err(EXIT_FAILURE, NULL);
 		if ((newheader = strdup(hp)) == NULL)
-			err(1, NULL);
+			err(EXIT_FAILURE, NULL);
 		memcpy(newvar, v, sizeof(struct var));
 		newvar->header = newheader;
 

Index: src/bin/ps/print.c
diff -u src/bin/ps/print.c:1.128 src/bin/ps/print.c:1.129
--- src/bin/ps/print.c:1.128	Sat Dec  9 09:56:54 2017
+++ src/bin/ps/print.c	Wed Apr 11 14:52:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.128 2017/12/09 14:56:54 kamil Exp $	*/
+/*	$NetBSD: print.c,v 1.129 2018/04/11 18:52:05 christos Exp $	*/
 
 /*
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)print.c	8.6 (Berkeley) 4/16/94";
 #else
-__RCSID("$NetBSD: print.c,v 1.128 2017/12/09 14:56:54 kamil Exp $");
+__RCSID("$NetBSD: print.c,v 1.129 2018/04/11 18:52:05 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -938,7 +938,7 @@ wchan(struct pinfo *pi, VARENT *ve, enum
 			(void)asprintf(, "%-*" PRIx64, v->width,
 			l->l_wchan);
 			if (buf == NULL)
-err(1, "%s", "");
+err(EXIT_FAILURE, "%s", "");
 			strprintorsetwidth(v, buf, mode);
 			v->width = min(v->width, KI_WMESGLEN);
 			free(buf);
@@ -1333,7 +1333,7 @@ printval(void *bp, VAR *v, enum mode mod
 		(void)printf(ofmt, width, CHK_INF127(GET(u_int64_t)));
 		return;
 	default:
-		errx(1, "unknown type %d", v->type);
+		errx(EXIT_FAILURE, "unknown type %d", v->type);
 	}
 #undef GET
 #undef CHK_INF127

Index: src/bin/ps/ps.c
diff -u src/bin/ps/ps.c:1.89 src/bin/ps/ps.c:1.90
--- src/bin/ps/ps.c:1.89	Fri Jan 12 18:01:14 2018
+++ src/bin/ps/ps.c	Wed Apr 11 14:52:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ps.c,v 1.89 2018/01/12 23:01:14 kamil Exp $	*/
+/*	$NetBSD: ps.c,v 1.90 2018/04/11 18:52:05 christos Exp $	*/
 
 /*
  * Copyright (c) 2000-2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19
 #if 0
 static char sccsid[] = "@(#)ps.c	8.4 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: ps.c,v 1.89 2018/01/12 23:01:14 kamil Exp $");
+__RCSID("$NetBSD: ps.c,v 1.90 2018/04/11 18:52:05 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -189,10 +189,10 @@ ttyname2dev(const char *ttname, int *xfl
 return makedev(pts, ptsminor);
 		}
 		errno = serrno;
-		err(1, "%s", ttypath);
+		err(EXIT_FAILURE, "%s", ttypath);
 	}
 	if (!S_ISCHR(sb.st_mode))
-		errx(1, "%s: not a terminal", ttypath);
+		errx(EXIT_FAILURE, "%s: not a terminal", ttypath);
 	return sb.st_rdev;
 }
 
@@ -325,7 +325,7 @@ main(int argc, char *argv[])
 			break;
 		case 'T':
 			if ((ttname = ttyname(STDIN_FILENO)) == NULL)
-errx(1, "stdin: not a terminal");
+errx(EXIT_FAILURE, "stdin: not a terminal");
 			flag = ttyname2dev(ttname, , );
 			break;
 		case 't':
@@ -394,7 +394,7 @@ main(int argc, char *argv[])
 		kd = kvm_openfiles(nlistf, memf, swapf, O_RDONLY, errbuf);
 
 	if (kd == NULL)
-		errx(1, "%s", errbuf);
+		errx(EXIT_FAILURE, "%s", errbuf);
 
 	if (!fmt)
 		parsefmt(default_fmt);
@@ -425,7 +425,7 @@ main(int argc, char *argv[])
 	 * select procs
 	 */
 	if (!(kinfo = getkinfo_kvm(kd, what, flag, )))
-		err(1, "%s", kvm_geterr(kd));
+		err(EXIT_FAILURE, "%s", kvm_geterr(kd));
 	if (nentries == 0) {
 		printheader();
 		return 1;
@@ 

CVS commit: src/etc

2018-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 11 18:51:22 UTC 2018

Modified Files:
src/etc: rc.subr

Log Message:
Hide ps error about processes not found (we could be more specific...)
It is superfluous, since we print:
foo not running? (check /var/run/foo/foo.pid).


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/etc/rc.subr

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

Modified files:

Index: src/etc/rc.subr
diff -u src/etc/rc.subr:1.101 src/etc/rc.subr:1.102
--- src/etc/rc.subr:1.101	Sun Apr  1 14:26:51 2018
+++ src/etc/rc.subr	Wed Apr 11 14:51:22 2018
@@ -1,4 +1,4 @@
-# $NetBSD: rc.subr,v 1.101 2018/04/01 18:26:51 kre Exp $
+# $NetBSD: rc.subr,v 1.102 2018/04/11 18:51:22 christos Exp $
 #
 # Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -294,10 +294,10 @@ _find_processes()
 	fi
 
 	_proccheck='
-		ps -o "pid,args" '"$_psargs"' |
+		ps -o "pid,args" '"$_psargs"' 2>&1 |
 		while read _npid '"$_fp_args"'; do
 			case "$_npid" in
-			PID)
+			ps:|PID)
 continue ;;
 			esac ; '"$_fp_match"'
 echo -n "$_pref$_npid" ;



CVS commit: src/external/apache2/mDNSResponder/dist/mDNSPosix

2018-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 11 18:34:18 UTC 2018

Modified Files:
src/external/apache2/mDNSResponder/dist/mDNSPosix: PosixDaemon.c

Log Message:
Add the missing lock.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.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/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c
diff -u src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c:1.11 src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c:1.12
--- src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c:1.11	Sat Mar  3 11:09:56 2018
+++ src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c	Wed Apr 11 14:34:18 2018
@@ -48,6 +48,7 @@ extern int daemon(int, int);
 #include "mDNSUNP.h"// For daemon()
 #include "uds_daemon.h"
 #include "PlatformCommon.h"
+#include "DNSCommon.h"
 
 #define CONFIG_FILE "/etc/mdnsd.conf"
 static domainname DynDNSZone;// Default wide-area zone for service registration
@@ -89,8 +90,10 @@ static void Reconfigure(mDNS *m)
 mDNSAddr DynDNSIP;
 const mDNSAddr dummy = { mDNSAddrType_IPv4, { { { 1, 1, 1, 1 } } } };;
 mDNS_SetPrimaryInterfaceInfo(m, NULL, NULL, NULL);
+mDNS_Lock(m);
 if (ParseDNSServers(m, uDNS_SERVERS_FILE) < 0)
 LogMsg("Unable to parse DNS server list. Unicast DNS-SD unavailable");
+mDNS_Unlock(m);
 ReadDDNSSettingsFromConfFile(m, CONFIG_FILE, , , NULL);
 mDNSPlatformSourceAddrForDest(, );
 if (DynDNSHostname.c[0]) mDNS_AddDynDNSHostName(m, , NULL, NULL);



CVS commit: src/external/apache2/mDNSResponder/dist/mDNSCore

2018-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 11 18:33:21 UTC 2018

Modified Files:
src/external/apache2/mDNSResponder/dist/mDNSCore: mDNS.c

Log Message:
instead of short-circuiting the test, set auto target host on by default.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/external/apache2/mDNSResponder/dist/mDNSCore/mDNS.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/apache2/mDNSResponder/dist/mDNSCore/mDNS.c
diff -u src/external/apache2/mDNSResponder/dist/mDNSCore/mDNS.c:1.10 src/external/apache2/mDNSResponder/dist/mDNSCore/mDNS.c:1.11
--- src/external/apache2/mDNSResponder/dist/mDNSCore/mDNS.c:1.10	Sat Apr  7 15:13:27 2018
+++ src/external/apache2/mDNSResponder/dist/mDNSCore/mDNS.c	Wed Apr 11 14:33:21 2018
@@ -12577,13 +12577,11 @@ mDNSlocal void AdvertiseInterface(mDNS *
 NetworkInterfaceInfo *primary;
 mDNSu8 recordType;
 
-#if 0
 if (m->AutoTargetServices == 0)
 {
 LogInfo("AdvertiseInterface: Returning due to AutoTargetServices zero for %s", set->ifname);
 return;
 }
-#endif
 
 primary = FindFirstAdvertisedInterface(m);
 if (!primary) primary = set; // If no existing advertised interface, this new NetworkInterfaceInfo becomes our new primary
@@ -14479,7 +14477,7 @@ mDNSlocal mStatus mDNS_InitStorage(mDNS 
 m->WABBrowseQueriesCount= 0;
 m->WABLBrowseQueriesCount   = 0;
 m->WABRegQueriesCount   = 0;
-m->AutoTargetServices   = 0;
+m->AutoTargetServices   = 1;
 
 #if BONJOUR_ON_DEMAND
 m->NumAllInterfaceRecords   = 0;



CVS commit: src/external/apache2/mDNSResponder/dist/mDNSCore

2018-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 11 18:33:48 UTC 2018

Modified Files:
src/external/apache2/mDNSResponder/dist/mDNSCore: DNSCommon.c
DNSCommon.h mDNSEmbeddedAPI.h

Log Message:
Add the location of the last lock to help debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c \
src/external/apache2/mDNSResponder/dist/mDNSCore/mDNSEmbeddedAPI.h
cvs rdiff -u -r1.1.1.5 -r1.2 \
src/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h

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

Modified files:

Index: src/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c
diff -u src/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c:1.8 src/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c:1.9
--- src/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c:1.8	Sun Jan 14 15:04:55 2018
+++ src/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c	Wed Apr 11 14:33:48 2018
@@ -3838,7 +3838,7 @@ mDNSexport mStatus mDNSSendDNSMessage(mD
 #pragma mark - RR List Management & Task Management
 #endif
 
-mDNSexport void mDNS_Lock_(mDNS *const m, const char * const functionname)
+mDNSexport void mDNS_Lock_(mDNS *const m, const char * const functionname, int lineno)
 {
 // MUST grab the platform lock FIRST!
 mDNSPlatformLock(m);
@@ -3848,20 +3848,20 @@ mDNSexport void mDNS_Lock_(mDNS *const m
 // If that client callback does mDNS API calls, mDNS_reentrancy and mDNS_busy will both be one
 // If mDNS_busy != mDNS_reentrancy that's a bad sign
 if (m->mDNS_busy != m->mDNS_reentrancy)
-LogFatalError("%s: mDNS_Lock: Locking failure! mDNS_busy (%ld) != mDNS_reentrancy (%ld)", functionname, m->mDNS_busy, m->mDNS_reentrancy);
+LogFatalError("%s,%d: mDNS_Lock: Locking failure! mDNS_busy (%ld) != mDNS_reentrancy (%ld) (last %s,%d)", functionname, lineno, m->mDNS_busy, m->mDNS_reentrancy, m->mDNS_Lock_functionname, m->mDNS_Lock_lineno);
 
 // If this is an initial entry into the mDNSCore code, set m->timenow
 // else, if this is a re-entrant entry into the mDNSCore code, m->timenow should already be set
 if (m->mDNS_busy == 0)
 {
 if (m->timenow)
-LogMsg("%s: mDNS_Lock: m->timenow already set (%ld/%ld)", functionname, m->timenow, mDNS_TimeNow_NoLock(m));
+LogMsg("%s,%d: mDNS_Lock: m->timenow already set (%ld/%ld)", functionname, lineno, m->timenow, mDNS_TimeNow_NoLock(m));
 m->timenow = mDNS_TimeNow_NoLock(m);
 if (m->timenow == 0) m->timenow = 1;
 }
 else if (m->timenow == 0)
 {
-LogMsg("%s: mDNS_Lock: m->mDNS_busy is %ld but m->timenow not set", functionname, m->mDNS_busy);
+LogMsg("%s,%d: mDNS_Lock: m->mDNS_busy is %ld but m->timenow not set", functionname, lineno, m->mDNS_busy);
 m->timenow = mDNS_TimeNow_NoLock(m);
 if (m->timenow == 0) m->timenow = 1;
 }
@@ -3869,13 +3869,15 @@ mDNSexport void mDNS_Lock_(mDNS *const m
 if (m->timenow_last - m->timenow > 0)
 {
 m->timenow_adjust += m->timenow_last - m->timenow;
-LogMsg("%s: mDNSPlatformRawTime went backwards by %ld ticks; setting correction factor to %ld", functionname, m->timenow_last - m->timenow, m->timenow_adjust);
+LogMsg("%s,%d: mDNSPlatformRawTime went backwards by %ld ticks; setting correction factor to %ld", functionname, lineno, m->timenow_last - m->timenow, m->timenow_adjust);
 m->timenow = m->timenow_last;
 }
 m->timenow_last = m->timenow;
 
 // Increment mDNS_busy so we'll recognise re-entrant calls
 m->mDNS_busy++;
+m->mDNS_Lock_functionname = functionname;
+m->mDNS_Lock_lineno = lineno;
 }
 
 mDNSlocal AuthRecord *AnyLocalRecordReady(const mDNS *const m)
@@ -4011,20 +4013,21 @@ mDNSexport void ShowTaskSchedulingError(
 mDNS_Unlock(m);
 }
 
-mDNSexport void mDNS_Unlock_(mDNS *const m, const char *const functionname)
+mDNSexport void mDNS_Unlock_(mDNS *const m, const char *const functionname, int lineno)
 {
 // Decrement mDNS_busy
 m->mDNS_busy--;
 
 // Check for locking failures
 if (m->mDNS_busy != m->mDNS_reentrancy)
-LogFatalError("%s: mDNS_Unlock: Locking failure! mDNS_busy (%ld) != mDNS_reentrancy (%ld)", functionname, m->mDNS_busy, m->mDNS_reentrancy);
+LogFatalError("%s,%d: mDNS_Unlock: Locking failure! mDNS_busy (%ld) != mDNS_reentrancy (%ld) (last %s,%d)", functionname, lineno, m->mDNS_busy,
+	m->mDNS_reentrancy, m->mDNS_Lock_functionname, m->mDNS_Lock_lineno);
 
 // If this is a final exit from the mDNSCore code, set m->NextScheduledEvent and clear m->timenow
 if (m->mDNS_busy == 0)
 {
 m->NextScheduledEvent = GetNextScheduledEvent(m);
-if (m->timenow == 0) LogMsg("%s: mDNS_Unlock: ERROR! m->timenow aready zero", functionname);
+if (m->timenow == 0) 

CVS commit: src/sys/kern

2018-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 11 15:25:58 UTC 2018

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

Log Message:
flip the default and enable kernel timestamps.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/kern/subr_prf.c

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

Modified files:

Index: src/sys/kern/subr_prf.c
diff -u src/sys/kern/subr_prf.c:1.165 src/sys/kern/subr_prf.c:1.166
--- src/sys/kern/subr_prf.c:1.165	Sun Apr  1 15:29:43 2018
+++ src/sys/kern/subr_prf.c	Wed Apr 11 11:25:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_prf.c,v 1.165 2018/04/01 19:29:43 christos Exp $	*/
+/*	$NetBSD: subr_prf.c,v 1.166 2018/04/11 15:25:58 christos Exp $	*/
 
 /*-
  * Copyright (c) 1986, 1988, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.165 2018/04/01 19:29:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.166 2018/04/11 15:25:58 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -482,7 +482,7 @@ putlogpri(int level)
 	putone('>', TOLOG, NULL);
 }
 
-#ifdef KLOG_TIMESTAMP
+#ifndef KLOG_NOTIMESTAMP
 static int needtstamp = 1;
 
 static void
@@ -516,7 +516,7 @@ putchar(int c, int flags, struct tty *tp
 		return;
 	}
 
-#ifdef KLOG_TIMESTAMP
+#ifndef KLOG_NOTIMESTAMP
 	if (needtstamp) {
 		addtstamp(flags, tp);
 		needtstamp = 0;



CVS commit: [netbsd-8] src/doc

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:55:24 UTC 2018

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

Log Message:
Tickets #730 - #740


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.177 -r1.1.2.178 src/doc/CHANGES-8.0

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.0
diff -u src/doc/CHANGES-8.0:1.1.2.177 src/doc/CHANGES-8.0:1.1.2.178
--- src/doc/CHANGES-8.0:1.1.2.177	Wed Apr 11 03:00:03 2018
+++ src/doc/CHANGES-8.0	Wed Apr 11 14:55:24 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.177 2018/04/11 03:00:03 msaitoh Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.178 2018/04/11 14:55:24 martin Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -11542,3 +11542,87 @@ external/bsd/ntp/scripts/mkver			up to 1
 
 	Update ntp to 4.2.8p11.
 	[snj, ticket #729]
+
+sys/net/if_l2tp.c1.22,1.23
+
+	Improve comment. Fix mistake and odd unaligned case.
+	[knakahara, ticket #730]
+
+share/man/man4/options.4			1.485 (patch)
+sys/arch/amd64/conf/ALL1.85
+sys/arch/amd64/conf/GENERIC			1.487-1.489
+sys/arch/amd64/conf/Makefile.amd64		1.67
+sys/arch/amd64/conf/files.amd64			1.102
+sys/arch/i386/conf/ALL1.437
+sys/arch/i386/conf/GENERIC			1.1175-1.1177
+sys/arch/i386/conf/Makefile.i386		1.190
+sys/arch/i386/conf/files.i386			1.392
+
+	Add an SPECTRE_V2_GCC_MITIGATION option to x86 kernels, that turns
+	on the GCC spectre v2 mitigation options. Enable this by default.
+	[mrg, ticket #731]
+
+usr.bin/m4/eval.c1.25,1.26
+
+	Missing argument check caused m4 to core in ifelse().
+	[mrg, ticket #732]
+
+sys/arch/amd64/include/vmparam.h		1.44,1.45
+sys/arch/sparc64/include/vmparam.h		1.38
+
+	Bump PAGER_MAP_DEFAULT_SIZE to 512 MB, to allow more
+	concurrent IOs. Fix a comment.
+	[mrg, ticket #733]
+
+usr.sbin/cpuctl/cpuctl.8			1.18
+
+	Note the default path for ucode updates can be found in sysctl.
+	[mrg, ticket #734]
+
+sys/dev/pckbport/wskbdmap_mfii.c		1.26
+sys/dev/wscons/wsksymdef.h			1.67
+
+	Add Turkish keyboard layout.
+	[maya, ticket #735]
+
+sys/arch/amd64/include/param.h			1.24
+sys/arch/i386/include/param.h			1.83
+
+	Double size of MSGBUFSIZE as existing value is not big enough to hold
+	boot dmesg on modern server-class hardware with lots of CPUs, etc.
+	[sborrill, ticket #736]
+
+sbin/dkctl/dkctl.81.27,1.28
+sbin/dkctl/dkctl.c1.26
+
+	Document, and properly implement, the -q and -e options
+	to dkctl xxN listwedges.
+	[kre, ticket #737]
+
+sys/ufs/ffs/ffs_vfsops.c			1.355
+
+	"mount -u /dev/ /" triggered a kernel panic.
+	[christos, ticket #738]
+
+sys/arch/i386/stand/efiboot/Makefile.efiboot	1.12
+sys/arch/i386/stand/efiboot/boot.c		1.10
+sys/arch/i386/stand/efiboot/conf.c		1.2
+sys/arch/i386/stand/efiboot/dev_net.c		1.1
+sys/arch/i386/stand/efiboot/devopen.c		1.5
+sys/arch/i386/stand/efiboot/devopen.h		1.3
+sys/arch/i386/stand/efiboot/efiboot.c		1.7
+sys/arch/i386/stand/efiboot/efiboot.h		1.8
+sys/arch/i386/stand/efiboot/efidisk.c		1.6
+sys/arch/i386/stand/efiboot/efinet.c		1.1
+sys/arch/i386/stand/efiboot/efinet.h		1.1
+sys/arch/i386/stand/efiboot/efipxe.c		1.1
+
+	efiboot: Added network boot support.
+	[nonaka, ticket #739]
+
+sys/arch/x86/pci/pci_machdep.c			1.80
+
+	efiboot reports parent ppb bus/device/function of booted
+	network inteface.
+	[nonaka, ticket #740]
+



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

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:53:51 UTC 2018

Modified Files:
src/sys/arch/x86/pci [netbsd-8]: pci_machdep.c

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

sys/arch/x86/pci/pci_machdep.c: revision 1.80

efiboot reports parent ppb bus/device/function of booted network inteface.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.79.2.1 src/sys/arch/x86/pci/pci_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/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.79 src/sys/arch/x86/pci/pci_machdep.c:1.79.2.1
--- src/sys/arch/x86/pci/pci_machdep.c:1.79	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x86/pci/pci_machdep.c	Wed Apr 11 14:53:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.79 2017/06/01 02:45:08 chs Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.79.2.1 2018/04/11 14:53:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.79 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.79.2.1 2018/04/11 14:53:50 martin Exp $");
 
 #include 
 #include 
@@ -98,6 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -149,6 +150,10 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
 #include 
 #endif
 
+#ifndef XEN
+#include 
+#endif
+
 #include "opt_pci_conf_mode.h"
 
 #ifdef PCI_CONF_MODE
@@ -1016,6 +1021,7 @@ device_t
 device_pci_register(device_t dev, void *aux)
 {
 	static bool found_console = false;
+	device_t parent = device_parent(dev);
 
 	device_pci_props_register(dev, aux);
 
@@ -1037,8 +1043,7 @@ device_pci_register(device_t dev, void *
 		 * information (checked below) must be sufficient to
 		 * identify the device.
 		 */
-		if (bin->bus == BI_BUS_PCI &&
-		device_is_a(device_parent(dev), "pci")) {
+		if (bin->bus == BI_BUS_PCI && device_is_a(parent, "pci")) {
 			struct pci_attach_args *paa = aux;
 			int b, d, f;
 
@@ -1052,9 +1057,23 @@ device_pci_register(device_t dev, void *
 			pci_decompose_tag(paa->pa_pc, paa->pa_tag, , , );
 			if (bin->addr.tag == ((b << 8) | (d << 3) | f))
 return dev;
+
+#ifndef XEN
+			/*
+			 * efiboot reports parent ppb bus/device/function.
+			 */
+			device_t grand = device_parent(parent);
+			if (efi_probe() && grand && device_is_a(grand, "ppb")) {
+struct ppb_softc *ppb_sc = device_private(grand);
+pci_decompose_tag(ppb_sc->sc_pc, ppb_sc->sc_tag,
+, , );
+if (bin->addr.tag == ((b << 8) | (d << 3) | f))
+	return dev;
+			}
+#endif
 		}
 	}
-	if (device_parent(dev) && device_is_a(device_parent(dev), "pci") &&
+	if (parent && device_is_a(parent, "pci") &&
 	found_console == false) {
 		struct btinfo_framebuffer *fbinfo;
 		struct pci_attach_args *pa = aux;



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

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:51:43 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot [netbsd-8]: Makefile.efiboot boot.c
conf.c devopen.c devopen.h efiboot.c efiboot.h efidisk.c
Added Files:
src/sys/arch/i386/stand/efiboot [netbsd-8]: dev_net.c efinet.c efinet.h
efipxe.c

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

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.


To generate a diff of this commit:
cvs rdiff -u -r1.9.2.2 -r1.9.2.3 \
src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.5.2.4 -r1.5.2.5 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.1 -r1.1.12.1 src/sys/arch/i386/stand/efiboot/conf.c
cvs rdiff -u -r0 -r1.1.2.2 src/sys/arch/i386/stand/efiboot/dev_net.c \
src/sys/arch/i386/stand/efiboot/efinet.c \
src/sys/arch/i386/stand/efiboot/efinet.h \
src/sys/arch/i386/stand/efiboot/efipxe.c
cvs rdiff -u -r1.1.12.3 -r1.1.12.4 src/sys/arch/i386/stand/efiboot/devopen.c
cvs rdiff -u -r1.1.12.1 -r1.1.12.2 src/sys/arch/i386/stand/efiboot/devopen.h
cvs rdiff -u -r1.4.10.2 -r1.4.10.3 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r1.5.2.2 -r1.5.2.3 src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.1.12.4 -r1.1.12.5 src/sys/arch/i386/stand/efiboot/efidisk.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/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.9.2.2 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.9.2.3
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.9.2.2	Mon Apr  2 08:50:33 2018
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Wed Apr 11 14:51:43 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.9.2.2 2018/04/02 08:50:33 martin Exp $
+# $NetBSD: Makefile.efiboot,v 1.9.2.3 2018/04/11 14:51:43 martin Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -8,12 +8,12 @@ NEWVERSWHAT?=	"EFI Boot"
 
 AFLAGS.start.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 
-SOURCES?= start.S conf.c devopen.c efiboot.c self_reloc.c
-LIBI386SRCS= boot.c biosdisk.c bootinfo.c bootinfo_biosgeom.c
-LIBI386SRCS+= bootmenu.c diskbuf.c exec.c menuutils.c
-LIBI386SRCS+= panic.c parseutils.c pread.c
-LIBI386SRCS+= efichar.c eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
-LIBI386SRCS+= efigetsecs.c efimemory.c
+SOURCES= start.S boot.c conf.c devopen.c dev_net.c self_reloc.c panic.c
+SOURCES+= efiboot.c efichar.c eficons.c efidelay.c efidev.c
+SOURCES+= efidisk.c efidisk_ll.c efigetsecs.c efimemory.c
+SOURCES+= efinet.c efipxe.c
+LIBI386SRCS= biosdisk.c bootinfo.c bootinfo_biosgeom.c bootmenu.c
+LIBI386SRCS+= diskbuf.c exec.c menuutils.c parseutils.c pread.c
 SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
 
 PIE_CFLAGS=
@@ -57,10 +57,22 @@ CPPFLAGS+= -DSUPPORT_CD9660
 CPPFLAGS+= -D"devb2cdb(bno)=(bno)"
 CPPFLAGS+= -DSUPPORT_DOSFS
 CPPFLAGS+= -DSUPPORT_EXT2FS
+CPPFLAGS+= -DSUPPORT_BOOTP
+CPPFLAGS+= -DSUPPORT_DHCP
+CPPFLAGS+= -DSUPPORT_NFS
+#CPPFLAGS+= -DSUPPORT_TFTP
 CPPFLAGS+= -DPASS_BIOSGEOM
 CPPFLAGS+= -DBIOSDISK_DEFAULT_SECSIZE=2048	# for bootinfo_biosgeom.c
 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 
+#CPPFLAGS+= -DARP_DEBUG
+#CPPFLAGS+= -DBOOTP_DEBUG
+#CPPFLAGS+= -DNET_DEBUG
+#CPPFLAGS+= -DNETIF_DEBUG
+#CPPFLAGS+= -DNFS_DEBUG
+#CPPFLAGS+= -DRARP_DEBUG
+#CPPFLAGS+= -DRPC_DEBUG
+
 EFIDIR= ${S}/external/bsd/gnu-efi/dist
 GNUEFIARCH?= ${MACHINE_CPU}
 CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH}
@@ -69,12 +81,12 @@ CPPFLAGS+= -I${EFIDIR}/inc/protocol
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
 SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)"
-SAMISCMAKEFLAGS+= SA_USE_CREAD=yes  # Read compressed kernels
-SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS
 
 ### find out what to use for libsa
 SA_AS= library
 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
+SAMISCMAKEFLAGS+="SA_USE_CREAD=yes"
+SAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes"
 SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA= ${SALIB}

Index: src/sys/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.5.2.4 

CVS commit: [netbsd-8] src/sys/ufs/ffs

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:49:08 UTC 2018

Modified Files:
src/sys/ufs/ffs [netbsd-8]: ffs_vfsops.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #738):

sys/ufs/ffs/ffs_vfsops.c: revision 1.355

PR/52728: Izumi Tsutsui: "mount -u /dev/ /" triggers kernel panic

Simplify the control flow of the mount code and make sure that the
mountfrom argument can be converted to a block device in the update
case.


To generate a diff of this commit:
cvs rdiff -u -r1.353.4.1 -r1.353.4.2 src/sys/ufs/ffs/ffs_vfsops.c

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

Modified files:

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.353.4.1 src/sys/ufs/ffs/ffs_vfsops.c:1.353.4.2
--- src/sys/ufs/ffs/ffs_vfsops.c:1.353.4.1	Sun Feb  4 12:52:02 2018
+++ src/sys/ufs/ffs/ffs_vfsops.c	Wed Apr 11 14:49:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.353.4.1 2018/02/04 12:52:02 martin Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.353.4.2 2018/04/11 14:49:08 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.353.4.1 2018/02/04 12:52:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.353.4.2 2018/04/11 14:49:08 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -418,12 +418,13 @@ ffs_mount(struct mount *mp, const char *
 		return EINVAL;
 	}
 
+	ump = VFSTOUFS(mp);
+	if ((mp->mnt_flag & (MNT_GETARGS|MNT_UPDATE)) && ump == NULL) {
+		DPRINTF("no ump");
+		return EIO;
+	}
+
 	if (mp->mnt_flag & MNT_GETARGS) {
-		ump = VFSTOUFS(mp);
-		if (ump == NULL) {
-			DPRINTF("no ump");
-			return EIO;
-		}
 		args->fspec = NULL;
 		*data_len = sizeof *args;
 		return 0;
@@ -432,7 +433,13 @@ ffs_mount(struct mount *mp, const char *
 	update = mp->mnt_flag & MNT_UPDATE;
 
 	/* Check arguments */
-	if (args->fspec != NULL) {
+	if (args->fspec == NULL) {
+		if (!update) {
+			/* New mounts must have a filename for the device */
+			DPRINTF("no filename for mount");
+			return EINVAL;
+		}
+	} else {
 		/*
 		 * Look up the name and verify that it's sane.
 		 */
@@ -443,48 +450,43 @@ ffs_mount(struct mount *mp, const char *
 			return error;
 		}
 
-		if (!update) {
-			/*
-			 * Be sure this is a valid block device
-			 */
-			if (devvp->v_type != VBLK) {
-DPRINTF("non block device %d", devvp->v_type);
-error = ENOTBLK;
-			} else if (bdevsw_lookup(devvp->v_rdev) == NULL) {
-DPRINTF("can't find block device 0x%jx",
-devvp->v_rdev);
-error = ENXIO;
-			}
-		} else {
+		/*
+		 * Be sure this is a valid block device
+		 */
+		if (devvp->v_type != VBLK) {
+			DPRINTF("non block device %d", devvp->v_type);
+			error = ENOTBLK;
+			goto fail;
+		}
+
+		if (bdevsw_lookup(devvp->v_rdev) == NULL) {
+			DPRINTF("can't find block device 0x%jx",
+			devvp->v_rdev);
+			error = ENXIO;
+			goto fail;
+		}
+
+		if (update) {
 			/*
 			 * Be sure we're still naming the same device
 			 * used for our initial mount
 			 */
-			ump = VFSTOUFS(mp);
-			if (devvp != ump->um_devvp) {
-if (devvp->v_rdev != ump->um_devvp->v_rdev) {
-	DPRINTF("wrong device 0x%jx != 0x%jx",
-	(uintmax_t)devvp->v_rdev,
-	(uintmax_t)ump->um_devvp->v_rdev);
-	error = EINVAL;
-} else {
-	vrele(devvp);
-	devvp = ump->um_devvp;
-	vref(devvp);
-}
+			if (devvp != ump->um_devvp &&
+			devvp->v_rdev != ump->um_devvp->v_rdev) {
+DPRINTF("wrong device 0x%jx != 0x%jx",
+(uintmax_t)devvp->v_rdev,
+(uintmax_t)ump->um_devvp->v_rdev);
+error = EINVAL;
+goto fail;
 			}
+			vrele(devvp);
+			devvp = NULL;
 		}
-	} else {
-		if (!update) {
-			/* New mounts must have a filename for the device */
-			DPRINTF("no filename for mount");
-			return EINVAL;
-		} else {
-			/* Use the extant mount */
-			ump = VFSTOUFS(mp);
-			devvp = ump->um_devvp;
-			vref(devvp);
-		}
+	}
+
+	if (devvp == NULL) {
+		devvp = ump->um_devvp;
+		vref(devvp);
 	}
 
 	/*
@@ -495,25 +497,17 @@ ffs_mount(struct mount *mp, const char *
 	 * updating the mount is okay (for example, as far as securelevel goes)
 	 * which leaves us with the normal check.
 	 */
-	if (error == 0) {
-		accessmode = VREAD;
-		if (update ?
-		(mp->mnt_iflag & IMNT_WANTRDWR) != 0 :
-		(mp->mnt_flag & MNT_RDONLY) == 0)
-			accessmode |= VWRITE;
-		vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
-		error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_MOUNT,
-		KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp,
-		KAUTH_ARG(accessmode));
-		if (error) {
-			DPRINTF("kauth returned %d", error);
-		}
-		VOP_UNLOCK(devvp);
-	}
-
+	accessmode = VREAD;
+	if (update ? (mp->mnt_iflag & IMNT_WANTRDWR) != 0 :
+	(mp->mnt_flag & MNT_RDONLY) == 0)
+		accessmode |= VWRITE;
+	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
+	error = 

CVS commit: [netbsd-8] src/sbin/dkctl

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:45:51 UTC 2018

Modified Files:
src/sbin/dkctl [netbsd-8]: dkctl.8 dkctl.c

Log Message:
Pull up following revision(s) (requested by kre in ticket #737):

sbin/dkctl/dkctl.8: revision 1.27
sbin/dkctl/dkctl.8: revision 1.28
sbin/dkctl/dkctl.c: revision 1.26

PR bin/52905

Document, and properly implement, the -q and -e options to dkctl xxN listwedges.
(implementation fix supplied by Petar Bogdanovic.)

Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.26.8.1 src/sbin/dkctl/dkctl.8
cvs rdiff -u -r1.25 -r1.25.4.1 src/sbin/dkctl/dkctl.c

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

Modified files:

Index: src/sbin/dkctl/dkctl.8
diff -u src/sbin/dkctl/dkctl.8:1.26 src/sbin/dkctl/dkctl.8:1.26.8.1
--- src/sbin/dkctl/dkctl.8:1.26	Wed Jan  6 23:01:11 2016
+++ src/sbin/dkctl/dkctl.8	Wed Apr 11 14:45:51 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: dkctl.8,v 1.26 2016/01/06 23:01:11 wiz Exp $
+.\"	$NetBSD: dkctl.8,v 1.26.8.1 2018/04/11 14:45:51 martin Exp $
 .\"
 .\" Copyright 2002 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -33,7 +33,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 6, 2016
+.Dd January 7, 2018
 .Dt DKCTL 8
 .Os
 .Sh NAME
@@ -139,8 +139,16 @@ the disk device.
 is specified, drop if
 .Ar no
 is specified.)
-.It Ic listwedges
+.It Ic listwedges Oo Fl e Oc Op Fl q
 List all of the wedges configured on the specified disk.
+With
+.Fl e
+exit with a non-zero exit status if there are no wedges
+configured on that disk.
+With
+.Fl q
+(quiet mode)
+there is no output related to the wedges that do, or do not, exist.
 .It Ic makewedges
 Delete all wedges configured on the specified disk, and autodiscover
 the wedges again.

Index: src/sbin/dkctl/dkctl.c
diff -u src/sbin/dkctl/dkctl.c:1.25 src/sbin/dkctl/dkctl.c:1.25.4.1
--- src/sbin/dkctl/dkctl.c:1.25	Wed Apr  5 20:27:09 2017
+++ src/sbin/dkctl/dkctl.c	Wed Apr 11 14:45:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dkctl.c,v 1.25 2017/04/05 20:27:09 jdolecek Exp $	*/
+/*	$NetBSD: dkctl.c,v 1.25.4.1 2018/04/11 14:45:51 martin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: dkctl.c,v 1.25 2017/04/05 20:27:09 jdolecek Exp $");
+__RCSID("$NetBSD: dkctl.c,v 1.25.4.1 2018/04/11 14:45:51 martin Exp $");
 #endif
 
 #include 
@@ -684,6 +684,9 @@ disk_listwedges(int argc, char *argv[])
 		return;
 	}
 
+	if (quiet)
+		return;
+
 	qsort(dkw, dkwl.dkwl_nwedges, sizeof(*dkw), dkw_sort);
 
 	printf("%s: %u wedge%s:\n", dvname, dkwl.dkwl_nwedges,



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

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:43:23 UTC 2018

Modified Files:
src/sys/arch/amd64/include [netbsd-8]: param.h
src/sys/arch/i386/include [netbsd-8]: param.h

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #736):

sys/arch/i386/include/param.h: revision 1.83
sys/arch/amd64/include/param.h: revision 1.24

Double size of MSGBUFSIZE as existing value is not big enough to hold
boot dmesg on modern server-class hardware with lots of CPUs, etc.


To generate a diff of this commit:
cvs rdiff -u -r1.21.6.2 -r1.21.6.3 src/sys/arch/amd64/include/param.h
cvs rdiff -u -r1.80 -r1.80.6.1 src/sys/arch/i386/include/param.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/amd64/include/param.h
diff -u src/sys/arch/amd64/include/param.h:1.21.6.2 src/sys/arch/amd64/include/param.h:1.21.6.3
--- src/sys/arch/amd64/include/param.h:1.21.6.2	Thu Mar 22 16:59:03 2018
+++ src/sys/arch/amd64/include/param.h	Wed Apr 11 14:43:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.21.6.2 2018/03/22 16:59:03 martin Exp $	*/
+/*	$NetBSD: param.h,v 1.21.6.3 2018/04/11 14:43:23 martin Exp $	*/
 
 #ifdef __x86_64__
 
@@ -60,7 +60,7 @@
 #define	USPACE		(UPAGES * NBPG)	/* total size of u-area */
 
 #ifndef MSGBUFSIZE
-#define MSGBUFSIZE	(8*NBPG)	/* default message buffer size */
+#define MSGBUFSIZE	(16*NBPG)	/* default message buffer size */
 #endif
 
 /*

Index: src/sys/arch/i386/include/param.h
diff -u src/sys/arch/i386/include/param.h:1.80 src/sys/arch/i386/include/param.h:1.80.6.1
--- src/sys/arch/i386/include/param.h:1.80	Fri Jan 20 00:29:28 2017
+++ src/sys/arch/i386/include/param.h	Wed Apr 11 14:43:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.80 2017/01/20 00:29:28 maya Exp $	*/
+/*	$NetBSD: param.h,v 1.80.6.1 2018/04/11 14:43:23 martin Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -103,7 +103,7 @@
 #define	INTRSTACKSIZE	8192
 
 #ifndef MSGBUFSIZE
-#define MSGBUFSIZE	(8*NBPG)	/* default message buffer size */
+#define MSGBUFSIZE	(16*NBPG)	/* default message buffer size */
 #endif
 
 /*



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

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:41:33 UTC 2018

Modified Files:
src/sys/dev/pckbport [netbsd-8]: wskbdmap_mfii.c
src/sys/dev/wscons [netbsd-8]: wsksymdef.h

Log Message:
Pull up following revision(s) (requested by maya in ticket #735):

sys/dev/wscons/wsksymdef.h: revision 1.67
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.26

Add Turkish keyboard layout.

from berte in PR kern/53011.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.25.20.1 src/sys/dev/pckbport/wskbdmap_mfii.c
cvs rdiff -u -r1.66 -r1.66.32.1 src/sys/dev/wscons/wsksymdef.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/pckbport/wskbdmap_mfii.c
diff -u src/sys/dev/pckbport/wskbdmap_mfii.c:1.25 src/sys/dev/pckbport/wskbdmap_mfii.c:1.25.20.1
--- src/sys/dev/pckbport/wskbdmap_mfii.c:1.25	Mon Jul 14 10:05:24 2014
+++ src/sys/dev/pckbport/wskbdmap_mfii.c	Wed Apr 11 14:41:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: wskbdmap_mfii.c,v 1.25 2014/07/14 10:05:24 mbalmer Exp $	*/
+/*	$NetBSD: wskbdmap_mfii.c,v 1.25.20.1 2018/04/11 14:41:33 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wskbdmap_mfii.c,v 1.25 2014/07/14 10:05:24 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wskbdmap_mfii.c,v 1.25.20.1 2018/04/11 14:41:33 martin Exp $");
 
 #include "opt_wskbdmap.h"
 #include 
@@ -771,6 +771,41 @@ static const keysym_t pckbd_keydesc_us_c
 KC(184), KS_Mode_switch,	KS_Multi_key,
 };
 
+static const keysym_t pckbd_keydesc_tr[] = {
+/*  pos  normal		shifted altgr   shift-altgr */
+KC(3),   KS_2,		KS_apostrophe,	KS_sterling,
+KC(4),   KS_3,		KS_asciicircum,	KS_numbersign,
+KC(5),   KS_4,		KS_plus,	KS_dollar,
+KC(6),   KS_5,		KS_percent,	KS_onehalf,
+KC(7),   KS_6,		KS_ampersand,
+KC(8),   KS_7,		KS_slash,	KS_braceleft,
+KC(9),   KS_8,		KS_parenleft,	KS_bracketleft,
+KC(10),  KS_9,		KS_parenright,	KS_bracketright,
+KC(11),  KS_0,		KS_equal,	KS_braceright,
+KC(12),  KS_asterisk,	KS_question,	KS_backslash,
+KC(13),  KS_minus,		KS_underscore,
+KC(16),  KS_q,		KS_Q,		KS_at,
+KC(23),  KS_L5_idotless,	KS_I,
+KC(26),  KS_L5_gbreve,	KS_L5_Gbreve,	KS_dead_diaeresis,
+KC(27),  KS_udiaeresis,	KS_Udiaeresis,	KS_asciitilde,
+KC(39),  KS_L5_scedilla,	KS_L5_Scedilla,	KS_dead_acute,
+KC(40),  KS_i,		KS_L5_Idotabove,
+KC(41),  KS_quotedbl,	KS_eacute,
+KC(43),  KS_comma,		KS_semicolon,	KS_dead_grave,
+KC(51),  KS_odiaeresis,	KS_Odiaeresis,
+KC(52),  KS_ccedilla,	KS_Ccedilla,
+KC(53),  KS_period,	KS_colon,
+KC(86),  KS_less,		KS_greater,	KS_bar,
+KC(184), KS_Mode_switch,	KS_Multi_key,
+};
+
+static const keysym_t pckbd_keydesc_tr_nodead[] = {
+/*  pos  normal		shifted altgr   shift-altgr */
+KC(26),  KS_L5_gbreve,	KS_L5_Gbreve,
+KC(39),  KS_L5_scedilla,	KS_L5_Scedilla,	KS_apostrophe,
+KC(43),  KS_comma,		KS_semicolon,	KS_grave,
+};
+
 static const keysym_t pckbd_keydesc_swapctrlcaps[] = {
 /*  pos  command		normal		shifted */
 KC(29), 			KS_Caps_Lock,
@@ -838,6 +873,8 @@ const struct wscons_keydesc pckbd_keydes
 	KBD_MAP(KB_HU,			KB_US,	pckbd_keydesc_hu),
 	KBD_MAP(KB_NL,			KB_US,	pckbd_keydesc_nl),
 	KBD_MAP(KB_NL | KB_NODEAD,	KB_NL,	pckbd_keydesc_nl_nodead),
+	KBD_MAP(KB_TR,			KB_US,	pckbd_keydesc_tr),
+	KBD_MAP(KB_TR | KB_NODEAD,	KB_TR,	pckbd_keydesc_tr_nodead),
 #endif /* WSKBD_USONLY */
 
 	/* placeholders */

Index: src/sys/dev/wscons/wsksymdef.h
diff -u src/sys/dev/wscons/wsksymdef.h:1.66 src/sys/dev/wscons/wsksymdef.h:1.66.32.1
--- src/sys/dev/wscons/wsksymdef.h:1.66	Sun Apr 22 14:32:08 2012
+++ src/sys/dev/wscons/wsksymdef.h	Wed Apr 11 14:41:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsksymdef.h,v 1.66 2012/04/22 14:32:08 khorben Exp $ */
+/*	$NetBSD: wsksymdef.h,v 1.66.32.1 2018/04/11 14:41:33 martin Exp $ */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -590,6 +590,18 @@
 
 #define KS_voidSymbol		0xf500
 
+
+/*
+ * Group Latin-5 (iso8859-9)
+ */
+
+#define KS_L5_Gbreve		0xd0
+#define KS_L5_Idotabove		0xdd
+#define KS_L5_Scedilla		0xde
+#define KS_L5_gbreve		0xf0
+#define KS_L5_idotless		0xfd
+#define KS_L5_scedilla		0xfe
+
 /*ENDKEYSYMDECL*/
 
 /*
@@ -661,12 +673,13 @@ action(KB_ES,	0,	0x0b00,	"es",	,	"Spanis
 action(KB_SV,	0,	0x0900,	"sv",	,	"Swedish")	\
 action(KB_SF,	0,	0x1000,	"sf",	,	"Swiss French")	\
 action(KB_SG,	0,	0x0f00,	"sg",	,	"Swiss German")	\
+action(KB_TR,	0,	0x1700,	"tr",	,	"Turkish")	\
 action(KB_UA,	0,	0x1200,	"ua",	,	"Ukrainian")	
 #define KB_NONE 0x
 
 /* Define all the KB_xx numeric values using above table */
 #define KBF_ENUM(tag, tagf, value, cc, ccf, country) tag=value,
-enum { KB_ENC_FUN(KBF_ENUM) KB_NEXT=0x1700 };
+enum { KB_ENC_FUN(KBF_ENUM) KB_NEXT=0x1800 };
 
 /* Define list of KB_xxx and country codes 

CVS commit: [netbsd-8] src/usr.sbin/cpuctl

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:38:34 UTC 2018

Modified Files:
src/usr.sbin/cpuctl [netbsd-8]: cpuctl.8

Log Message:
Pull up following revision(s) (requested by mrg in ticket #734):
usr.sbin/cpuctl/cpuctl.8: revision 1.18
note the default path for ucode updates can be found in sysctl.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.17.6.1 src/usr.sbin/cpuctl/cpuctl.8

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/cpuctl/cpuctl.8
diff -u src/usr.sbin/cpuctl/cpuctl.8:1.17 src/usr.sbin/cpuctl/cpuctl.8:1.17.6.1
--- src/usr.sbin/cpuctl/cpuctl.8:1.17	Sat Sep 17 20:48:04 2016
+++ src/usr.sbin/cpuctl/cpuctl.8	Wed Apr 11 14:38:34 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: cpuctl.8,v 1.17 2016/09/17 20:48:04 wiz Exp $
+.\"	$NetBSD: cpuctl.8,v 1.17.6.1 2018/04/11 14:38:34 martin Exp $
 .\"
 .\" Copyright (c) 2007, 2008, 2012, 2015 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 17, 2016
+.Dd January 13, 2018
 .Dt CPUCTL 8
 .Os
 .Sh NAME
@@ -85,6 +85,8 @@ command prints the installed version on 
 On success the
 .Cm identify
 command show different ucode versions before and after this command.
+The ucode updates are found in the default firmware path found in
+sysctl hw.firmware.path.
 .It intr Ar cpu Op Ar cpu ...
 Enable interrupts for the specified CPUs if supported.
 .It nointr Ar cpu Op Ar cpu ...
@@ -122,7 +124,7 @@ cpu0: UCode version: 0x180
 .Ed
 .Pp
 After applying the microcode patch with
-.Dl cpuctl ucode
+.Dl cpuctl ucode 0
 you can see with
 .Dl cpuctl identify 0
 that the patch got applied:
@@ -132,7 +134,9 @@ cpu0: UCode version: 0x183
 .Sh SEE ALSO
 .Xr intrctl 8 ,
 .Xr psrset 8 ,
-.Xr schedctl 8
+.Xr schedctl 8 ,
+.Xr sysctl 8 ,
+.Xr firmload 9
 .Sh HISTORY
 The
 .Nm



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

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:37:11 UTC 2018

Modified Files:
src/sys/arch/amd64/include [netbsd-8]: vmparam.h
src/sys/arch/sparc64/include [netbsd-8]: vmparam.h

Log Message:
Pull up following revision(s) (requested by mrg in ticket #733):

sys/arch/amd64/include/vmparam.h: revision 1.44
sys/arch/amd64/include/vmparam.h: revision 1.45
sys/arch/sparc64/include/vmparam.h: revision 1.38

bump PAGER_MAP_DEFAULT_SIZE to 512MB.  this should allow more
concurrent IOs to be possible, and i'm unable to see pager_map
contention any more.

other larger platforms should probably do this too.
ok chs@.

Remove superfluous word in comment. Noted by Geoff Wing.

Bump PAGER_MAP_DEFAULT_SIZE to 512 MB (like amd64 recently did).


To generate a diff of this commit:
cvs rdiff -u -r1.39.6.1 -r1.39.6.2 src/sys/arch/amd64/include/vmparam.h
cvs rdiff -u -r1.37 -r1.37.10.1 src/sys/arch/sparc64/include/vmparam.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/amd64/include/vmparam.h
diff -u src/sys/arch/amd64/include/vmparam.h:1.39.6.1 src/sys/arch/amd64/include/vmparam.h:1.39.6.2
--- src/sys/arch/amd64/include/vmparam.h:1.39.6.1	Thu Aug 31 08:32:38 2017
+++ src/sys/arch/amd64/include/vmparam.h	Wed Apr 11 14:37:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.39.6.1 2017/08/31 08:32:38 bouyer Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.39.6.2 2018/04/11 14:37:11 martin Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -57,6 +57,12 @@
 #define	PAGE_MASK	(PAGE_SIZE - 1)
 
 /*
+ * Default pager_map of 16MB is awfully small.  There is plenty
+ * of VA so use it.
+ */
+#define	PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024)
+
+/*
  * USRSTACK is the top (end) of the user stack. Immediately above the
  * user stack resides the user structure, which is UPAGES long and contains
  * the kernel stack.

Index: src/sys/arch/sparc64/include/vmparam.h
diff -u src/sys/arch/sparc64/include/vmparam.h:1.37 src/sys/arch/sparc64/include/vmparam.h:1.37.10.1
--- src/sys/arch/sparc64/include/vmparam.h:1.37	Sat Mar 26 11:49:10 2016
+++ src/sys/arch/sparc64/include/vmparam.h	Wed Apr 11 14:37:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.37 2016/03/26 11:49:10 martin Exp $ */
+/*	$NetBSD: vmparam.h,v 1.37.10.1 2018/04/11 14:37:11 martin Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -58,6 +58,12 @@
 #define	PAGE_MASK	(PAGE_SIZE - 1)
 
 /*
+ * Default pager_map of 16MB is awfully small.  There is plenty
+ * of VA so use it.
+ */
+#definePAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024)
+
+/*
  * The kernel itself is mapped by the boot loader with 4Mb locked VM pages,
  * so let's keep 4Mb definitions here as well.
  */



CVS commit: [netbsd-8] src/usr.bin/m4

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:27:51 UTC 2018

Modified Files:
src/usr.bin/m4 [netbsd-8]: eval.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #732):

usr.bin/m4/eval.c: revision 1.25
usr.bin/m4/eval.c: revision 1.26

PR/52638: matthew green: missing argument check causes m4 to core in ifelse()

remove the braces I accidentally added.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.24.8.1 src/usr.bin/m4/eval.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/m4/eval.c
diff -u src/usr.bin/m4/eval.c:1.24 src/usr.bin/m4/eval.c:1.24.8.1
--- src/usr.bin/m4/eval.c:1.24	Sat Jan 16 16:56:21 2016
+++ src/usr.bin/m4/eval.c	Wed Apr 11 14:27:51 2018
@@ -1,5 +1,5 @@
 /*	$OpenBSD: eval.c,v 1.66 2008/08/21 21:01:47 espie Exp $	*/
-/*	$NetBSD: eval.c,v 1.24 2016/01/16 16:56:21 christos Exp $	*/
+/*	$NetBSD: eval.c,v 1.24.8.1 2018/04/11 14:27:51 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include 
-__RCSID("$NetBSD: eval.c,v 1.24 2016/01/16 16:56:21 christos Exp $");
+__RCSID("$NetBSD: eval.c,v 1.24.8.1 2018/04/11 14:27:51 martin Exp $");
 
 #include 
 #include 
@@ -698,6 +698,8 @@ static void
 doifelse(const char *argv[], int argc)
 {
 	cycle {
+		if (argc < 5)
+			m4errx(1, "wrong number of args for ifelse");
 		if (STREQ(argv[2], argv[3]))
 			pbstr(argv[4]);
 		else if (argc == 6)



CVS commit: [netbsd-8] src

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:23:31 UTC 2018

Modified Files:
src/share/man/man4 [netbsd-8]: options.4
src/sys/arch/amd64/conf [netbsd-8]: ALL GENERIC Makefile.amd64
files.amd64
src/sys/arch/i386/conf [netbsd-8]: ALL GENERIC Makefile.i386 files.i386

Log Message:
Pull up following revision(s) (requested by mrg in ticket #731):
sys/arch/i386/conf/files.i386: revision 1.392
sys/arch/i386/conf/GENERIC: revision 1.1175
sys/arch/i386/conf/GENERIC: revision 1.1176
sys/arch/amd64/conf/files.amd64: revision 1.102
sys/arch/i386/conf/GENERIC: revision 1.1177
share/man/man4/options.4: revision 1.485 (patch)
sys/arch/i386/conf/Makefile.i386: revision 1.190
sys/arch/amd64/conf/GENERIC: revision 1.487
sys/arch/amd64/conf/ALL: revision 1.85
sys/arch/amd64/conf/GENERIC: revision 1.488
sys/arch/amd64/conf/GENERIC: revision 1.489
sys/arch/amd64/conf/Makefile.amd64: revision 1.67
sys/arch/i386/conf/ALL: revision 1.437

add an SPECTRE_V2_GCC_MITIGATION option to x86 kernels, that turns
on the GCC spectre v2 mitigation options.
XXX: pullup-8.
XXX: turn on in all kernels.

actually do what the previous change said:
don't turn on the new 'SPECTRE_V2_GCC_MITIGATION' option yet.

turn on GCC spectre v2 mitigation options.
XXX: amd64 ALL doesn't build for me right now


To generate a diff of this commit:
cvs rdiff -u -r1.466 -r1.466.2.1 src/share/man/man4/options.4
cvs rdiff -u -r1.59.2.4 -r1.59.2.5 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.459.2.7 -r1.459.2.8 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.57 -r1.57.6.1 src/sys/arch/amd64/conf/Makefile.amd64
cvs rdiff -u -r1.88.8.2 -r1.88.8.3 src/sys/arch/amd64/conf/files.amd64
cvs rdiff -u -r1.419.2.2 -r1.419.2.3 src/sys/arch/i386/conf/ALL
cvs rdiff -u -r1.1156.2.7 -r1.1156.2.8 src/sys/arch/i386/conf/GENERIC
cvs rdiff -u -r1.185 -r1.185.10.1 src/sys/arch/i386/conf/Makefile.i386
cvs rdiff -u -r1.378.6.1 -r1.378.6.2 src/sys/arch/i386/conf/files.i386

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/options.4
diff -u src/share/man/man4/options.4:1.466 src/share/man/man4/options.4:1.466.2.1
--- src/share/man/man4/options.4:1.466	Fri May 19 14:18:41 2017
+++ src/share/man/man4/options.4	Wed Apr 11 14:23:30 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: options.4,v 1.466 2017/05/19 14:18:41 abhinav Exp $
+.\"	$NetBSD: options.4,v 1.466.2.1 2018/04/11 14:23:30 martin Exp $
 .\"
 .\" Copyright (c) 1996
 .\" 	Perry E. Metzger.  All rights reserved.
@@ -31,6 +31,7 @@
 .\"
 .\"
 .Dd March 9, 2017
+.Dd April 5, 2018
 .Dt OPTIONS 4
 .Os
 .Sh NAME
@@ -2549,6 +2550,17 @@ base memory size to prevent programs ove
 This is correct behavior, and you should not use the
 .Em REALBASEMEM
 option to access this memory).
+.It Cd options SPECTRE_V2_GCC_MITIGATION=1
+Enable GCC-specific Spectre variant 2 mitigations.
+For 32-bit kernels this means these options:
+.Bd -literal -offset indent
+-mindirect-branch=thunk -mindirect-branch-register
+.Ed
+.Pp
+For 64-bit kernels this means these options:
+.Bd -literal -offset indent
+-mindirect-branch=thunk-inline -mindirect-branch-register
+.Ed
 .It Cd options REALEXTMEM=integer
 Overrides the extended memory size passed in from the boot block.
 (Value given in kilobytes.
@@ -2786,6 +2798,7 @@ bolded
 .\" .Sh EXAMPLES
 .Sh SEE ALSO
 .Xr config 1 ,
+.Xr gcc 1 ,
 .Xr gdb 1 ,
 .Xr ktrace 1 ,
 .Xr pmc 1 ,

Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.59.2.4 src/sys/arch/amd64/conf/ALL:1.59.2.5
--- src/sys/arch/amd64/conf/ALL:1.59.2.4	Mon Apr  9 12:49:32 2018
+++ src/sys/arch/amd64/conf/ALL	Wed Apr 11 14:23:30 2018
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.59.2.4 2018/04/09 12:49:32 bouyer Exp $
+# $NetBSD: ALL,v 1.59.2.5 2018/04/11 14:23:30 martin Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.59.2.4 $"
+#ident		"ALL-$Revision: 1.59.2.5 $"
 
 maxusers	64		# estimated number of users
 
@@ -28,6 +28,8 @@ makeoptions	USE_SSP=yes
 #options 	USER_LDT	# user-settable LDT; used by WINE
 options 	X86EMU		# 386 Real Mode emulator
 #options 	PAE		# PAE mode (36 bits physical addressing)
+makeoptions	SPECTRE_V2_GCC_MITIGATION=1	# GCC Spectre variant 2
+		# migitation
 
 # CPU features
 acpicpu*	at cpu?		# ACPI CPU (including frequency scaling)

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.459.2.7 src/sys/arch/amd64/conf/GENERIC:1.459.2.8
--- src/sys/arch/amd64/conf/GENERIC:1.459.2.7	Wed Apr  4 16:25:23 2018
+++ src/sys/arch/amd64/conf/GENERIC	Wed Apr 11 14:23:30 2018
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.459.2.7 2018/04/04 16:25:23 

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

2018-04-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 11 14:15:45 UTC 2018

Modified Files:
src/sys/net [netbsd-8]: if_l2tp.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #730):

sys/net/if_l2tp.c: revision 1.22
sys/net/if_l2tp.c: revision 1.23

Improve comment. Pointed out by maxv@n.o, thanks.

Fix previous my mistake and odd unaligned case. Pointed out by maxv@n.o, thanks.
It must be rare case to be required this copy routine...


To generate a diff of this commit:
cvs rdiff -u -r1.11.2.6 -r1.11.2.7 src/sys/net/if_l2tp.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_l2tp.c
diff -u src/sys/net/if_l2tp.c:1.11.2.6 src/sys/net/if_l2tp.c:1.11.2.7
--- src/sys/net/if_l2tp.c:1.11.2.6	Mon Apr  9 13:40:20 2018
+++ src/sys/net/if_l2tp.c	Wed Apr 11 14:15:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_l2tp.c,v 1.11.2.6 2018/04/09 13:40:20 bouyer Exp $	*/
+/*	$NetBSD: if_l2tp.c,v 1.11.2.7 2018/04/11 14:15:45 martin Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.11.2.6 2018/04/09 13:40:20 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.11.2.7 2018/04/11 14:15:45 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -477,11 +477,16 @@ l2tp_input(struct mbuf *m, struct ifnet 
 		return;
 	}
 
+	/*
+	 * If the head of the payload is not aligned, align it.
+	 */
 	addr = mtod(m, vaddr_t);
-	if ((addr & 0x03) == 0) {
+	if ((addr & 0x03) != 0x2) {
 		/* copy and align head of payload */
 		struct mbuf *m_head;
 		int copy_length;
+		u_int pad = roundup(sizeof(struct ether_header), 4)
+			- sizeof(struct ether_header);
 
 #define L2TP_COPY_LENGTH		60
 
@@ -504,7 +509,19 @@ l2tp_input(struct mbuf *m, struct ifnet 
 		}
 		M_COPY_PKTHDR(m_head, m);
 
-		MH_ALIGN(m_head, L2TP_COPY_LENGTH);
+		/*
+		 * m_head should be:
+		 * L2TP_COPY_LENGTH
+		 *  <-  + roundup(pad, 4) - pad ->
+		 *   +---++-+--+-+
+		 *   | m_hdr | pkthdr | ... | ether header |   payload   |
+		 *   +---++-+--+-+
+		 *  ^  ^
+		 *  m_data 4 byte aligned
+		 */
+		MH_ALIGN(m_head, L2TP_COPY_LENGTH + roundup(pad, 4));
+		m_head->m_data += pad;
+
 		memcpy(mtod(m_head, void *), mtod(m, void *), copy_length);
 		m_head->m_len = copy_length;
 		m->m_data += copy_length;



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

2018-04-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 11 10:34:20 UTC 2018

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
efiboot reports parent ppb bus/device/function of booted network inteface.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/x86/pci/pci_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/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.79 src/sys/arch/x86/pci/pci_machdep.c:1.80
--- src/sys/arch/x86/pci/pci_machdep.c:1.79	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x86/pci/pci_machdep.c	Wed Apr 11 10:34:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.79 2017/06/01 02:45:08 chs Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.80 2018/04/11 10:34:19 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.79 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.80 2018/04/11 10:34:19 nonaka Exp $");
 
 #include 
 #include 
@@ -98,6 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -149,6 +150,10 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
 #include 
 #endif
 
+#ifndef XEN
+#include 
+#endif
+
 #include "opt_pci_conf_mode.h"
 
 #ifdef PCI_CONF_MODE
@@ -1016,6 +1021,7 @@ device_t
 device_pci_register(device_t dev, void *aux)
 {
 	static bool found_console = false;
+	device_t parent = device_parent(dev);
 
 	device_pci_props_register(dev, aux);
 
@@ -1037,8 +1043,7 @@ device_pci_register(device_t dev, void *
 		 * information (checked below) must be sufficient to
 		 * identify the device.
 		 */
-		if (bin->bus == BI_BUS_PCI &&
-		device_is_a(device_parent(dev), "pci")) {
+		if (bin->bus == BI_BUS_PCI && device_is_a(parent, "pci")) {
 			struct pci_attach_args *paa = aux;
 			int b, d, f;
 
@@ -1052,9 +1057,23 @@ device_pci_register(device_t dev, void *
 			pci_decompose_tag(paa->pa_pc, paa->pa_tag, , , );
 			if (bin->addr.tag == ((b << 8) | (d << 3) | f))
 return dev;
+
+#ifndef XEN
+			/*
+			 * efiboot reports parent ppb bus/device/function.
+			 */
+			device_t grand = device_parent(parent);
+			if (efi_probe() && grand && device_is_a(grand, "ppb")) {
+struct ppb_softc *ppb_sc = device_private(grand);
+pci_decompose_tag(ppb_sc->sc_pc, ppb_sc->sc_tag,
+, , );
+if (bin->addr.tag == ((b << 8) | (d << 3) | f))
+	return dev;
+			}
+#endif
 		}
 	}
-	if (device_parent(dev) && device_is_a(device_parent(dev), "pci") &&
+	if (parent && device_is_a(parent, "pci") &&
 	found_console == false) {
 		struct btinfo_framebuffer *fbinfo;
 		struct pci_attach_args *pa = aux;



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

2018-04-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 11 10:32:10 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot boot.c conf.c
devopen.c devopen.h efiboot.c efiboot.h efidisk.c
Added Files:
src/sys/arch/i386/stand/efiboot: dev_net.c efinet.c efinet.h efipxe.c

Log Message:
efiboot: Added network boot support.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/conf.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/dev_net.c \
src/sys/arch/i386/stand/efiboot/efinet.c \
src/sys/arch/i386/stand/efiboot/efinet.h \
src/sys/arch/i386/stand/efiboot/efipxe.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/devopen.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/devopen.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/efidisk.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/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.11 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.12
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.11	Tue Mar 27 14:15:05 2018
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Wed Apr 11 10:32:09 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.11 2018/03/27 14:15:05 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.12 2018/04/11 10:32:09 nonaka Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -8,12 +8,12 @@ NEWVERSWHAT?=	"EFI Boot"
 
 AFLAGS.start.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 
-SOURCES?= start.S conf.c devopen.c efiboot.c self_reloc.c
-LIBI386SRCS= boot.c biosdisk.c bootinfo.c bootinfo_biosgeom.c
-LIBI386SRCS+= bootmenu.c diskbuf.c exec.c menuutils.c
-LIBI386SRCS+= panic.c parseutils.c pread.c
-LIBI386SRCS+= efichar.c eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
-LIBI386SRCS+= efigetsecs.c efimemory.c
+SOURCES= start.S boot.c conf.c devopen.c dev_net.c self_reloc.c panic.c
+SOURCES+= efiboot.c efichar.c eficons.c efidelay.c efidev.c
+SOURCES+= efidisk.c efidisk_ll.c efigetsecs.c efimemory.c
+SOURCES+= efinet.c efipxe.c
+LIBI386SRCS= biosdisk.c bootinfo.c bootinfo_biosgeom.c bootmenu.c
+LIBI386SRCS+= diskbuf.c exec.c menuutils.c parseutils.c pread.c
 SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
 
 PIE_CFLAGS=
@@ -57,10 +57,22 @@ CPPFLAGS+= -DSUPPORT_CD9660
 CPPFLAGS+= -D"devb2cdb(bno)=(bno)"
 CPPFLAGS+= -DSUPPORT_DOSFS
 CPPFLAGS+= -DSUPPORT_EXT2FS
+CPPFLAGS+= -DSUPPORT_BOOTP
+CPPFLAGS+= -DSUPPORT_DHCP
+CPPFLAGS+= -DSUPPORT_NFS
+#CPPFLAGS+= -DSUPPORT_TFTP
 CPPFLAGS+= -DPASS_BIOSGEOM
 CPPFLAGS+= -DBIOSDISK_DEFAULT_SECSIZE=2048	# for bootinfo_biosgeom.c
 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 
+#CPPFLAGS+= -DARP_DEBUG
+#CPPFLAGS+= -DBOOTP_DEBUG
+#CPPFLAGS+= -DNET_DEBUG
+#CPPFLAGS+= -DNETIF_DEBUG
+#CPPFLAGS+= -DNFS_DEBUG
+#CPPFLAGS+= -DRARP_DEBUG
+#CPPFLAGS+= -DRPC_DEBUG
+
 EFIDIR= ${S}/external/bsd/gnu-efi/dist
 GNUEFIARCH?= ${MACHINE_CPU}
 CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH}
@@ -69,12 +81,12 @@ CPPFLAGS+= -I${EFIDIR}/inc/protocol
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
 SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)"
-SAMISCMAKEFLAGS+= SA_USE_CREAD=yes  # Read compressed kernels
-SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS
 
 ### find out what to use for libsa
 SA_AS= library
 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
+SAMISCMAKEFLAGS+="SA_USE_CREAD=yes"
+SAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes"
 SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA= ${SALIB}

Index: src/sys/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.9 src/sys/arch/i386/stand/efiboot/boot.c:1.10
--- src/sys/arch/i386/stand/efiboot/boot.c:1.9	Mon Apr  2 09:44:18 2018
+++ src/sys/arch/i386/stand/efiboot/boot.c	Wed Apr 11 10:32:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.9 2018/04/02 09:44:18 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.10 2018/04/11 10:32:09 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -182,6 +182,21 @@ parsebootfile(const char *fname, char **
 }
 
 static char *
+snprint_bootdev(char *buf, size_t bufsize, const char *devname, int unit,
+int partition)
+{
+	static const char *no_partition_devs[] = { "esp", "net", "nfs", "tftp" };
+	int i;
+
+	for (i = 0; i < __arraycount(no_partition_devs); i++)
+		if (strcmp(devname, no_partition_devs[i]) == 0)
+			break;
+	snprintf(buf, bufsize, "%s%d%c", devname, unit,
+	i < __arraycount(no_partition_devs) ? '\0' : 'a' + partition);
+	return buf;
+}
+
+static char *
 

CVS commit: src/sys/netinet

2018-04-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Apr 11 08:29:19 UTC 2018

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

Log Message:
Remove whitespaces/tabs, and one non-ASCII character.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/netinet/ip_flow.c

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

Modified files:

Index: src/sys/netinet/ip_flow.c
diff -u src/sys/netinet/ip_flow.c:1.81 src/sys/netinet/ip_flow.c:1.82
--- src/sys/netinet/ip_flow.c:1.81	Fri Nov 17 07:37:12 2017
+++ src/sys/netinet/ip_flow.c	Wed Apr 11 08:29:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_flow.c,v 1.81 2017/11/17 07:37:12 ozaki-r Exp $	*/
+/*	$NetBSD: ip_flow.c,v 1.82 2018/04/11 08:29:19 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.81 2017/11/17 07:37:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.82 2018/04/11 08:29:19 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -64,7 +64,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 
 
 /*
  * Similar code is very well commented in netinet6/ip6_flow.c
- */ 
+ */
 
 #define	IPFLOW_HASHBITS		6	/* should not be a multiple of 8 */
 
@@ -113,7 +113,7 @@ static void ipflow_slowtimo_work(struct 
 static struct workqueue	*ipflow_slowtimo_wq;
 static struct work	ipflow_slowtimo_wk;
 
-static size_t 
+static size_t
 ipflow_hash(const struct ip *ip)
 {
 	size_t hash = ip->ip_tos;
@@ -364,7 +364,7 @@ out:
 	mutex_exit(_lock);
 	return ret;
 }
-
+
 static void
 ipflow_addstats(struct ipflow *ipf)
 {
@@ -376,7 +376,7 @@ ipflow_addstats(struct ipflow *ipf)
 		rt->rt_use += ipf->ipf_uses;
 		rtcache_unref(rt, >ipf_ro);
 	}
-	
+
 	ips = IP_STAT_GETREF();
 	ips[IP_STAT_CANTFORWARD] += ipf->ipf_errors + ipf->ipf_dropped;
 	ips[IP_STAT_TOTAL] += ipf->ipf_uses;
@@ -646,7 +646,7 @@ sysctl_net_inet_ip_hashsize(SYSCTLFN_ARG
 	} else {
 		/*
 		 * EINVAL if not a power of 2
-	 */
+		 */
 		error = EINVAL;
 	}
 



CVS commit: src/sys/netinet

2018-04-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Apr 11 08:11:20 UTC 2018

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

Log Message:
Don't pass IP_ALLOWBROADCAST in ipsec4_input. The flag lands in
ipsec_getpolicybyaddr, and only IP_FORWARDING is taken.

In fact it would be good to change the 'flags' argument of ipsec4_input
to be a boolean, same for ipsec_getpolicybyaddr. It would be less
misleading.


To generate a diff of this commit:
cvs rdiff -u -r1.378 -r1.379 src/sys/netinet/ip_input.c

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

Modified files:

Index: src/sys/netinet/ip_input.c
diff -u src/sys/netinet/ip_input.c:1.378 src/sys/netinet/ip_input.c:1.379
--- src/sys/netinet/ip_input.c:1.378	Wed Apr 11 07:55:19 2018
+++ src/sys/netinet/ip_input.c	Wed Apr 11 08:11:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.378 2018/04/11 07:55:19 maxv Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.379 2018/04/11 08:11:20 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.378 2018/04/11 07:55:19 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.379 2018/04/11 08:11:20 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -729,8 +729,7 @@ ip_input(struct mbuf *m)
 #ifdef IPSEC
 		/* Check the security policy (SP) for the packet */
 		if (ipsec_used) {
-			if (ipsec4_input(m, IP_FORWARDING |
-			(ip_directedbcast ? IP_ALLOWBROADCAST : 0)) != 0) {
+			if (ipsec4_input(m, IP_FORWARDING) != 0) {
 goto out;
 			}
 		}



CVS commit: src/sys

2018-04-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Apr 11 07:55:19 UTC 2018

Modified Files:
src/sys/netinet: ip_input.c
src/sys/netinet6: ip6_input.c

Log Message:
Add comment about IPsec.


To generate a diff of this commit:
cvs rdiff -u -r1.377 -r1.378 src/sys/netinet/ip_input.c
cvs rdiff -u -r1.195 -r1.196 src/sys/netinet6/ip6_input.c

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

Modified files:

Index: src/sys/netinet/ip_input.c
diff -u src/sys/netinet/ip_input.c:1.377 src/sys/netinet/ip_input.c:1.378
--- src/sys/netinet/ip_input.c:1.377	Wed Apr 11 07:52:25 2018
+++ src/sys/netinet/ip_input.c	Wed Apr 11 07:55:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.377 2018/04/11 07:52:25 maxv Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.378 2018/04/11 07:55:19 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.377 2018/04/11 07:52:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.378 2018/04/11 07:55:19 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -569,6 +569,9 @@ ip_input(struct mbuf *m)
 	 * not fast-forwarded, they must clear the M_CANFASTFWD flag.
 	 * Note that filters must _never_ set this flag, as another filter
 	 * in the list may have previously cleared it.
+	 *
+	 * Don't call hooks if the packet has already been processed by
+	 * IPsec (encapsulated, tunnel mode).
 	 */
 #if defined(IPSEC)
 	if (!ipsec_used || !ipsec_indone(m))

Index: src/sys/netinet6/ip6_input.c
diff -u src/sys/netinet6/ip6_input.c:1.195 src/sys/netinet6/ip6_input.c:1.196
--- src/sys/netinet6/ip6_input.c:1.195	Wed Mar 21 14:23:54 2018
+++ src/sys/netinet6/ip6_input.c	Wed Apr 11 07:55:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_input.c,v 1.195 2018/03/21 14:23:54 roy Exp $	*/
+/*	$NetBSD: ip6_input.c,v 1.196 2018/04/11 07:55:19 maxv Exp $	*/
 /*	$KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.195 2018/03/21 14:23:54 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.196 2018/04/11 07:55:19 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -380,10 +380,9 @@ ip6_input(struct mbuf *m, struct ifnet *
 	 * not fast-forwarded, they must clear the M_CANFASTFWD flag.
 	 * Note that filters must _never_ set this flag, as another filter
 	 * in the list may have previously cleared it.
-	 */
-	/*
-	 * let ipfilter look at packet on the wire,
-	 * not the decapsulated packet.
+	 *
+	 * Don't call hooks if the packet has already been processed by
+	 * IPsec (encapsulated, tunnel mode).
 	 */
 #if defined(IPSEC)
 	if (!ipsec_used || !ipsec_indone(m))



CVS commit: src/sys/netinet

2018-04-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Apr 11 07:52:26 UTC 2018

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

Log Message:
Small changes in ip_dooptions: replace bcopy by memcpy, the areas can't
overlap.


To generate a diff of this commit:
cvs rdiff -u -r1.376 -r1.377 src/sys/netinet/ip_input.c

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

Modified files:

Index: src/sys/netinet/ip_input.c
diff -u src/sys/netinet/ip_input.c:1.376 src/sys/netinet/ip_input.c:1.377
--- src/sys/netinet/ip_input.c:1.376	Sat Feb 24 07:37:09 2018
+++ src/sys/netinet/ip_input.c	Wed Apr 11 07:52:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.376 2018/02/24 07:37:09 ozaki-r Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.377 2018/04/11 07:52:25 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.376 2018/02/24 07:37:09 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.377 2018/04/11 07:52:25 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -965,8 +965,8 @@ ip_dooptions(struct mbuf *m)
 goto bad;
 			}
 			ip->ip_dst = ipaddr.sin_addr;
-			bcopy((void *)>ia_addr.sin_addr,
-			(void *)(cp + off), sizeof(struct in_addr));
+			memcpy(cp + off, >ia_addr.sin_addr,
+			sizeof(struct in_addr));
 			ia4_release(ia, );
 			cp[IPOPT_OFFSET] += sizeof(struct in_addr);
 			/*
@@ -1001,7 +1001,7 @@ ip_dooptions(struct mbuf *m)
 			off--;			/* 0 origin */
 			if ((off + sizeof(struct in_addr)) > optlen)
 break;
-			memcpy((void *)_addr, (void *)(>ip_dst),
+			memcpy((void *)_addr, (void *)>ip_dst,
 			sizeof(ipaddr.sin_addr));
 			/*
 			 * locate outgoing interface; if we're the destination,
@@ -1018,8 +1018,8 @@ ip_dooptions(struct mbuf *m)
 			} else {
 ia = ifatoia(ifa);
 			}
-			bcopy((void *)>ia_addr.sin_addr,
-			(void *)(cp + off), sizeof(struct in_addr));
+			memcpy(cp + off, >ia_addr.sin_addr,
+			sizeof(struct in_addr));
 			ia4_release(ia, );
 			cp[IPOPT_OFFSET] += sizeof(struct in_addr);
 			break;
@@ -1081,8 +1081,8 @@ ip_dooptions(struct mbuf *m)
 	break;
 }
 ia = ifatoia(ifa);
-bcopy(>ia_addr.sin_addr,
-cp0, sizeof(struct in_addr));
+memcpy(cp0, >ia_addr.sin_addr,
+sizeof(struct in_addr));
 pserialize_read_exit(_ss);
 ipt->ipt_ptr += sizeof(struct in_addr);
 break;



CVS commit: src/sys/netinet

2018-04-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Apr 11 07:15:12 UTC 2018

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

Log Message:
Add 'static', like the prototype.


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

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

Modified files:

Index: src/sys/netinet/ip_reass.c
diff -u src/sys/netinet/ip_reass.c:1.14 src/sys/netinet/ip_reass.c:1.15
--- src/sys/netinet/ip_reass.c:1.14	Fri Mar  9 11:57:38 2018
+++ src/sys/netinet/ip_reass.c	Wed Apr 11 07:15:12 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_reass.c,v 1.14 2018/03/09 11:57:38 maxv Exp $	*/
+/*	$NetBSD: ip_reass.c,v 1.15 2018/04/11 07:15:12 maxv Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_reass.c,v 1.14 2018/03/09 11:57:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_reass.c,v 1.15 2018/04/11 07:15:12 maxv Exp $");
 
 #include 
 #include 
@@ -211,7 +211,7 @@ ip_nmbclusters_changed(void)
  *	datagram.  If a chain for reassembly of this datagram already exists,
  *	then it is given as 'fp'; otherwise have to make a chain.
  */
-struct mbuf *
+static struct mbuf *
 ip_reass(ipfr_qent_t *ipqe, ipfr_queue_t *fp, const u_int hash)
 {
 	struct ip *ip = ipqe->ipqe_ip, *qip;



CVS commit: src/sbin/gpt

2018-04-11 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Apr 11 07:14:23 UTC 2018

Modified Files:
src/sbin/gpt: map.c

Log Message:
if a new map entry doesn't fit, be more verbose about the sizes.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/gpt/map.c

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

Modified files:

Index: src/sbin/gpt/map.c
diff -u src/sbin/gpt/map.c:1.13 src/sbin/gpt/map.c:1.14
--- src/sbin/gpt/map.c:1.13	Thu Dec  3 21:30:54 2015
+++ src/sbin/gpt/map.c	Wed Apr 11 07:14:23 2018
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/map.c,v 1.6 2005/08/31 01:47:19 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: map.c,v 1.13 2015/12/03 21:30:54 christos Exp $");
+__RCSID("$NetBSD: map.c,v 1.14 2018/04/11 07:14:23 mrg Exp $");
 #endif
 
 #include 
@@ -117,7 +117,10 @@ map_add(gpt_t gpt, off_t start, off_t si
 
 	if (n->map_start + n->map_size < start + size) {
 		if (!(gpt->flags & GPT_QUIET))
-			gpt_warnx(gpt, "map entry doesn't fit media");
+			gpt_warnx(gpt, "map entry doesn't fit media: "
+			"new start + new size < start + size\n"
+			"(%jx + %jx < %jx + %jx)",
+			n->map_start, n->map_size, start, size);
 		return NULL;
 	}
 



CVS commit: src/sbin/gpt

2018-04-11 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Apr 11 07:13:18 UTC 2018

Modified Files:
src/sbin/gpt: gpt.8

Log Message:
add information about how to boot from gpt.  mostly taken from the wiki.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sbin/gpt/gpt.8

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

Modified files:

Index: src/sbin/gpt/gpt.8
diff -u src/sbin/gpt/gpt.8:1.58 src/sbin/gpt/gpt.8:1.59
--- src/sbin/gpt/gpt.8:1.58	Mon Mar 19 09:06:20 2018
+++ src/sbin/gpt/gpt.8	Wed Apr 11 07:13:18 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.58 2018/03/19 09:06:20 mlelstv Exp $
+.\" $NetBSD: gpt.8,v 1.59 2018/04/11 07:13:18 mrg Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
 .\"
-.Dd January 15, 2018
+.Dd March 5, 2018
 .Dt GPT 8
 .Os
 .Sh NAME
@@ -716,6 +716,25 @@ nas# gpt show -l wd3
   3907029167   1 Sec GPT header
 nas#
 .Ed
+.Pp
+Booting from GPT on an BIOS system.
+This creates a bootable partition that can be manually installed to.
+Note that
+.Xr sysinst 8
+does not yet properly support this setup.
+.Bd -literal
+xotica# gpt create wd1
+xotica# gpt add -b 1024 -l bootroot -t ffs -s 1g wd1
+/dev/rwd1: Partition 1 added: 49f48d5a-b10e-11dc-b99b-0019d1879648 1024 2097152
+xotica ~# dmesg | tail -2
+wd1: GPT GUID: 660e0630-0a3f-47c0-bc52-c88bcec79392
+dk0 at wd1: "bootroot", 2097152 blocks at 1024, type: ffs
+xotica# gpt biosboot -L bootroot wd1
+xotica# newfs dk0
+xotica# installboot /dev/rdk0 /usr/mdec/bootxx_ffsv1
+xotica# mount /dev/dk0 /mnt
+xotica# cp /usr/mdec/boot /mnt
+.Ed
 .Sh SEE ALSO
 .Xr boot 8 ,
 .Xr dkctl 8 ,
@@ -723,7 +742,7 @@ nas#
 .Xr installboot 8 ,
 .Xr mount 8 ,
 .Xr newfs 8 ,
-.Xr swapon 8
+.Xr swapctl 8
 .Sh HISTORY
 The
 .Nm



CVS commit: src/sbin/dmesg

2018-04-11 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Apr 11 06:41:23 UTC 2018

Modified Files:
src/sbin/dmesg: dmesg.c

Log Message:
Update usage.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sbin/dmesg/dmesg.c

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

Modified files:

Index: src/sbin/dmesg/dmesg.c
diff -u src/sbin/dmesg/dmesg.c:1.31 src/sbin/dmesg/dmesg.c:1.32
--- src/sbin/dmesg/dmesg.c:1.31	Tue Apr 10 22:21:52 2018
+++ src/sbin/dmesg/dmesg.c	Wed Apr 11 06:41:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmesg.c,v 1.31 2018/04/10 22:21:52 christos Exp $	*/
+/*	$NetBSD: dmesg.c,v 1.32 2018/04/11 06:41:23 wiz Exp $	*/
 /*-
  * Copyright (c) 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -38,7 +38,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)dmesg.c	8.1 (Berkeley) 6/5/93";
 #else
-__RCSID("$NetBSD: dmesg.c,v 1.31 2018/04/10 22:21:52 christos Exp $");
+__RCSID("$NetBSD: dmesg.c,v 1.32 2018/04/11 06:41:23 wiz Exp $");
 #endif
 #endif /* not lint */
 
@@ -282,7 +282,7 @@ static void
 usage(void)
 {
 
-	(void)fprintf(stderr, "Usage: %s [-qt] [-M core] [-N system]\n",
+	(void)fprintf(stderr, "Usage: %s [-dTt] [-M core] [-N system]\n",
 		getprogname());
 	exit(EXIT_FAILURE);
 }



CVS commit: src/sbin/dmesg

2018-04-11 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Apr 11 06:40:53 UTC 2018

Modified Files:
src/sbin/dmesg: dmesg.8

Log Message:
Sort flags in SYNOPSIS.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/dmesg/dmesg.8

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

Modified files:

Index: src/sbin/dmesg/dmesg.8
diff -u src/sbin/dmesg/dmesg.8:1.19 src/sbin/dmesg/dmesg.8:1.20
--- src/sbin/dmesg/dmesg.8:1.19	Tue Apr 10 22:21:52 2018
+++ src/sbin/dmesg/dmesg.8	Wed Apr 11 06:40:53 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: dmesg.8,v 1.19 2018/04/10 22:21:52 christos Exp $
+.\"	$NetBSD: dmesg.8,v 1.20 2018/04/11 06:40:53 wiz Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -34,10 +34,10 @@
 .Os
 .Sh NAME
 .Nm dmesg
-.Nd "display the system message buffer"
+.Nd display the system message buffer
 .Sh SYNOPSIS
 .Nm
-.Op Fl dtT
+.Op Fl dTt
 .Op Fl M Ar core
 .Op Fl N Ar system
 .Sh DESCRIPTION
@@ -59,7 +59,7 @@ Extract the name list from the specified
 ``/netbsd''.
 .It Fl T
 Format uptime timestamps in a human readable form (using
-.Xr ctime 3 ).
+.Xr ctime 3 ) .
 .It Fl t
 Quiet printing, don't print timestamps.
 .El



CVS commit: src/sys/netmpls

2018-04-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Apr 11 06:37:32 UTC 2018

Modified Files:
src/sys/netmpls: mpls_ttl.c

Log Message:
Add one more XXX in the list.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/netmpls/mpls_ttl.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/netmpls/mpls_ttl.c
diff -u src/sys/netmpls/mpls_ttl.c:1.11 src/sys/netmpls/mpls_ttl.c:1.12
--- src/sys/netmpls/mpls_ttl.c:1.11	Fri Jan 19 14:15:35 2018
+++ src/sys/netmpls/mpls_ttl.c	Wed Apr 11 06:37:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpls_ttl.c,v 1.11 2018/01/19 14:15:35 maxv Exp $ */
+/*	$NetBSD: mpls_ttl.c,v 1.12 2018/04/11 06:37:32 maxv Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpls_ttl.c,v 1.11 2018/01/19 14:15:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpls_ttl.c,v 1.12 2018/04/11 06:37:32 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -146,10 +146,12 @@ static struct mbuf *ip4_check(struct mbu
 /*
  * Send an ICMP Extended error message. References: RFC4884 and RFC4950.
  *
- * This should be in sync with icmp_error() in sys/netinet/ip_icmp.c
- * XXX: is called only for ICMP_TIMXCEED_INTRANS but code is too general.
+ * XXX: This code is inspired from icmp_error(), and should really be merged
+ * into it. icmp_error() should handle ICMP Extended error messages.
  *
- * XXX We're not setting the 'length' field of the Extended ICMP header.
+ * XXX: It is called only for ICMP_TIMXCEED_INTRANS but code is too general.
+ *
+ * XXX: We're not setting the 'length' field of the Extended ICMP header.
  * According to RFC4884, we are in 'non-compliant' mode. Moreover, we're
  * not computing the checksum of the Extended ICMP header.
  */



CVS commit: src/sys/netinet

2018-04-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Apr 11 06:26:00 UTC 2018

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

Log Message:
Add XXX.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/netinet/ip_mroute.c

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

Modified files:

Index: src/sys/netinet/ip_mroute.c
diff -u src/sys/netinet/ip_mroute.c:1.156 src/sys/netinet/ip_mroute.c:1.157
--- src/sys/netinet/ip_mroute.c:1.156	Wed Apr 11 05:59:42 2018
+++ src/sys/netinet/ip_mroute.c	Wed Apr 11 06:26:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_mroute.c,v 1.156 2018/04/11 05:59:42 maxv Exp $	*/
+/*	$NetBSD: ip_mroute.c,v 1.157 2018/04/11 06:26:00 maxv Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.156 2018/04/11 05:59:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.157 2018/04/11 06:26:00 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2073,6 +2073,11 @@ priority(struct vif *vifp, struct ip *ip
 	/* temporary hack; may add general packet classifier some day */
 
 	/*
+	 * XXX XXX: We're reading the UDP header, but we didn't ensure
+	 * it was present in the packet.
+	 */
+
+	/*
 	 * The UDP port space is divided up into four priority ranges:
 	 * [0, 16384) : unclassified - lowest priority
 	 * [16384, 32768) : audio - highest priority



CVS commit: src/sys/netinet

2018-04-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Apr 11 05:59:43 UTC 2018

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

Log Message:
Add XXX.


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/netinet/ip_mroute.c

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

Modified files:

Index: src/sys/netinet/ip_mroute.c
diff -u src/sys/netinet/ip_mroute.c:1.155 src/sys/netinet/ip_mroute.c:1.156
--- src/sys/netinet/ip_mroute.c:1.155	Wed Mar 21 14:23:54 2018
+++ src/sys/netinet/ip_mroute.c	Wed Apr 11 05:59:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_mroute.c,v 1.155 2018/03/21 14:23:54 roy Exp $	*/
+/*	$NetBSD: ip_mroute.c,v 1.156 2018/04/11 05:59:42 maxv Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.155 2018/03/21 14:23:54 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.156 2018/04/11 05:59:42 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1279,6 +1279,12 @@ ip_mforward(struct mbuf *m, struct ifnet
 		log(LOG_DEBUG, "ip_mforward: src %x, dst %x, ifp %p\n",
 		ntohl(ip->ip_src.s_addr), ntohl(ip->ip_dst.s_addr), ifp);
 
+	/*
+	 * XXX XXX: Why do we check [1] against IPOPT_LSRR? Because we
+	 * expect [0] to be IPOPT_NOP, maybe? In all cases that doesn't
+	 * make a lot of sense, a forged packet can just put two IPOPT_NOPs
+	 * followed by one IPOPT_LSRR, and bypass the check.
+	 */
 	if (ip->ip_hl < (IP_HDR_LEN + TUNNEL_LEN) >> 2 ||
 	((u_char *)(ip + 1))[1] != IPOPT_LSRR) {
 		/*