CVS commit: xsrc/external/mit/xorg-server/dist

2017-07-06 Thread matthew green
Module Name:xsrc
Committed By:   mrg
Date:   Fri Jul  7 04:46:50 UTC 2017

Modified Files:
xsrc/external/mit/xorg-server/dist/Xi: sendexev.c
xsrc/external/mit/xorg-server/dist/dix: events.c swapreq.c

Log Message:
CVE-2017-10971 and CVE-2017-10972: apply fixes to the event loop from

   
https://cgit.freedesktop.org/xorg/xserver/commit/?id=ba336b24052122b136486961c82deac76bbde455
   
https://cgit.freedesktop.org/xorg/xserver/commit/?id=8caed4df36b1f802b4992edcfd282cbeeec35d9d
   
https://cgit.freedesktop.org/xorg/xserver/commit/?id=215f894965df5fb0bb45b107d84524e700d2073c
   
https://cgit.freedesktop.org/xorg/xserver/commit/?id=05442de962d3dc624f79fc1a00eca3ffc5489ced

XXX: pullup-[678] (6/7 also need xfree port.)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/xorg-server/dist/Xi/sendexev.c
cvs rdiff -u -r1.1.1.9 -r1.2 xsrc/external/mit/xorg-server/dist/dix/events.c
cvs rdiff -u -r1.1.1.3 -r1.2 xsrc/external/mit/xorg-server/dist/dix/swapreq.c

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

Modified files:

Index: xsrc/external/mit/xorg-server/dist/Xi/sendexev.c
diff -u xsrc/external/mit/xorg-server/dist/Xi/sendexev.c:1.3 xsrc/external/mit/xorg-server/dist/Xi/sendexev.c:1.4
--- xsrc/external/mit/xorg-server/dist/Xi/sendexev.c:1.3	Thu Aug 11 00:04:26 2016
+++ xsrc/external/mit/xorg-server/dist/Xi/sendexev.c	Fri Jul  7 04:46:50 2017
@@ -78,7 +78,7 @@ SProcXSendExtensionEvent(ClientPtr clien
 {
 CARD32 *p;
 int i;
-xEvent eventT;
+xEvent eventT = { .u.u.type = 0 };
 xEvent *eventP;
 EventSwapPtr proc;
 
@@ -95,9 +95,17 @@ SProcXSendExtensionEvent(ClientPtr clien
 
 eventP = (xEvent *) [1];
 for (i = 0; i < stuff->num_events; i++, eventP++) {
+if (eventP->u.u.type == GenericEvent) {
+client->errorValue = eventP->u.u.type;
+return BadValue;
+}
+
 proc = EventSwapVector[eventP->u.u.type & 0177];
-if (proc == NotImplemented) /* no swapping proc; invalid event type? */
+/* no swapping proc; invalid event type? */
+if (proc == NotImplemented) {
+client->errorValue = eventP->u.u.type;
 return BadValue;
+}
 (*proc) (eventP, );
 *eventP = eventT;
 }
@@ -117,7 +125,7 @@ SProcXSendExtensionEvent(ClientPtr clien
 int
 ProcXSendExtensionEvent(ClientPtr client)
 {
-int ret;
+int ret, i;
 DeviceIntPtr dev;
 xEvent *first;
 XEventClass *list;
@@ -144,10 +152,12 @@ ProcXSendExtensionEvent(ClientPtr client
 /* The client's event type must be one defined by an extension. */
 
 first = ((xEvent *) [1]);
-if (!((EXTENSION_EVENT_BASE <= first->u.u.type) &&
-  (first->u.u.type < lastEvent))) {
-client->errorValue = first->u.u.type;
-return BadValue;
+for (i = 0; i < stuff->num_events; i++) {
+if (!((EXTENSION_EVENT_BASE <= first[i].u.u.type) &&
+(first[i].u.u.type < lastEvent))) {
+client->errorValue = first[i].u.u.type;
+return BadValue;
+}
 }
 
 list = (XEventClass *) (first + stuff->num_events);

Index: xsrc/external/mit/xorg-server/dist/dix/events.c
diff -u xsrc/external/mit/xorg-server/dist/dix/events.c:1.1.1.9 xsrc/external/mit/xorg-server/dist/dix/events.c:1.2
--- xsrc/external/mit/xorg-server/dist/dix/events.c:1.1.1.9	Wed Aug 10 07:44:32 2016
+++ xsrc/external/mit/xorg-server/dist/dix/events.c	Fri Jul  7 04:46:50 2017
@@ -5355,6 +5355,12 @@ ProcSendEvent(ClientPtr client)
 client->errorValue = stuff->event.u.u.type;
 return BadValue;
 }
+/* Generic events can have variable size, but SendEvent request holds
+   exactly 32B of event data. */
+if (stuff->event.u.u.type == GenericEvent) {
+client->errorValue = stuff->event.u.u.type;
+return BadValue;
+}
 if (stuff->event.u.u.type == ClientMessage &&
 stuff->event.u.u.detail != 8 &&
 stuff->event.u.u.detail != 16 && stuff->event.u.u.detail != 32) {

Index: xsrc/external/mit/xorg-server/dist/dix/swapreq.c
diff -u xsrc/external/mit/xorg-server/dist/dix/swapreq.c:1.1.1.3 xsrc/external/mit/xorg-server/dist/dix/swapreq.c:1.2
--- xsrc/external/mit/xorg-server/dist/dix/swapreq.c:1.1.1.3	Wed Aug 10 07:44:31 2016
+++ xsrc/external/mit/xorg-server/dist/dix/swapreq.c	Fri Jul  7 04:46:50 2017
@@ -292,6 +292,13 @@ SProcSendEvent(ClientPtr client)
 swapl(>destination);
 swapl(>eventMask);
 
+/* Generic events can have variable size, but SendEvent request holds
+   exactly 32B of event data. */
+if (stuff->event.u.u.type == GenericEvent) {
+client->errorValue = stuff->event.u.u.type;
+return BadValue;
+}
+
 /* Swap event */
 proc = EventSwapVector[stuff->event.u.u.type & 0177];
 if (!proc || proc == NotImplemented)/* no swapping proc; invalid event type? */



CVS commit: src/sys

2017-07-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Jul  7 01:37:34 UTC 2017

Modified Files:
src/sys/netinet: tcp_input.c tcp_var.h
src/sys/netipsec: ipsec.c ipsec_input.c ipsec_netbsd.c key.c key.h
xform_ah.c xform_esp.c xform_ipcomp.c

Log Message:
Rename key_alloc* functions (NFC)

We shouldn't use the term "alloc" for functions that just look up
data and actually don't allocate memory.


To generate a diff of this commit:
cvs rdiff -u -r1.358 -r1.359 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.177 -r1.178 src/sys/netinet/tcp_var.h
cvs rdiff -u -r1.100 -r1.101 src/sys/netipsec/ipsec.c
cvs rdiff -u -r1.46 -r1.47 src/sys/netipsec/ipsec_input.c
cvs rdiff -u -r1.43 -r1.44 src/sys/netipsec/ipsec_netbsd.c
cvs rdiff -u -r1.167 -r1.168 src/sys/netipsec/key.c
cvs rdiff -u -r1.19 -r1.20 src/sys/netipsec/key.h
cvs rdiff -u -r1.56 -r1.57 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.57 -r1.58 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.40 -r1.41 src/sys/netipsec/xform_ipcomp.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/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.358 src/sys/netinet/tcp_input.c:1.359
--- src/sys/netinet/tcp_input.c:1.358	Mon Jun 19 10:04:23 2017
+++ src/sys/netinet/tcp_input.c	Fri Jul  7 01:37:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.358 2017/06/19 10:04:23 ozaki-r Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.359 2017/07/07 01:37:34 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.358 2017/06/19 10:04:23 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.359 2017/07/07 01:37:34 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -3208,7 +3208,7 @@ tcp_signature_getsav(struct mbuf *m, str
 	/*
 	 * Look up an SADB entry which matches the address of the peer.
 	 */
-	return KEY_ALLOCSA(, IPPROTO_TCP, htonl(TCP_SIG_SPI), 0, 0);
+	return KEY_LOOKUP_SA(, IPPROTO_TCP, htonl(TCP_SIG_SPI), 0, 0);
 #else
 	return NULL;
 #endif

Index: src/sys/netinet/tcp_var.h
diff -u src/sys/netinet/tcp_var.h:1.177 src/sys/netinet/tcp_var.h:1.178
--- src/sys/netinet/tcp_var.h:1.177	Sat Feb 14 22:09:53 2015
+++ src/sys/netinet/tcp_var.h	Fri Jul  7 01:37:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_var.h,v 1.177 2015/02/14 22:09:53 he Exp $	*/
+/*	$NetBSD: tcp_var.h,v 1.178 2017/07/07 01:37:34 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -157,7 +157,7 @@
 #define	TCP_KEYLEN_MAX	80	/* maximum length of TCP-MD5 key */
 /*
  * Only a single SA per host may be specified at this time. An SPI is
- * needed in order for the KEY_ALLOCSA() lookup to work.
+ * needed in order for the KEY_LOOKUP_SA() lookup to work.
  */
 #define	TCP_SIG_SPI	0x1000
 #endif /* TCP_SIGNATURE */

Index: src/sys/netipsec/ipsec.c
diff -u src/sys/netipsec/ipsec.c:1.100 src/sys/netipsec/ipsec.c:1.101
--- src/sys/netipsec/ipsec.c:1.100	Wed Jun 14 02:00:43 2017
+++ src/sys/netipsec/ipsec.c	Fri Jul  7 01:37:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec.c,v 1.100 2017/06/14 02:00:43 ozaki-r Exp $	*/
+/*	$NetBSD: ipsec.c,v 1.101 2017/07/07 01:37:34 ozaki-r Exp $	*/
 /*	$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $	*/
 /*	$KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.100 2017/06/14 02:00:43 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.101 2017/07/07 01:37:34 ozaki-r Exp $");
 
 /*
  * IPsec controller part.
@@ -362,7 +362,7 @@ ipsec_invalpcbcacheall(void)
  * Return a held reference to the default SP.
  */
 static struct secpolicy *
-key_allocsp_default(int af, const char *where, int tag)
+key_get_default_sp(int af, const char *where, int tag)
 {
 	struct secpolicy *sp;
 
@@ -395,8 +395,8 @@ key_allocsp_default(int af, const char *
 	sp, sp->refcnt);
 	return sp;
 }
-#define	KEY_ALLOCSP_DEFAULT(af) \
-	key_allocsp_default((af), __func__, __LINE__)
+#define	KEY_GET_DEFAULT_SP(af) \
+	key_get_default_sp((af), __func__, __LINE__)
 
 /*
  * For OUTBOUND packet having a socket. Searching SPD for packet,
@@ -418,9 +418,9 @@ ipsec_getpolicy(const struct tdb_ident *
 	KASSERT(tdbi != NULL);
 	KASSERTMSG(IPSEC_DIR_IS_INOROUT(dir), "invalid direction %u", dir);
 
-	sp = KEY_ALLOCSP2(tdbi->spi, >dst, tdbi->proto, dir);
+	sp = KEY_LOOKUP_SP(tdbi->spi, >dst, tdbi->proto, dir);
 	if (sp == NULL)			/*XXX*/
-		sp = KEY_ALLOCSP_DEFAULT(tdbi->dst.sa.sa_family);
+		sp = KEY_GET_DEFAULT_SP(tdbi->dst.sa.sa_family);
 	KASSERT(sp != NULL);
 	return sp;
 }
@@ -515,9 +515,9 @@ ipsec_getpolicybysock(struct mbuf *m, u_
 
 		case IPSEC_POLICY_ENTRUST:
 			/* look for a policy in SPD */
-			sp = KEY_ALLOCSP(>spidx, dir);
+			sp = KEY_LOOKUP_SP_BYSPIDX(>spidx, dir);
 			if (sp == NULL)		/* no 

CVS commit: src/sys/netinet6

2017-07-06 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Jul  7 00:55:16 UTC 2017

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

Log Message:
fix PR kern/52353. implemented by ozaki-r@n.o. I just commit by proxy.

XXX need to pullup to -8.


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/sys/netinet6/icmp6.c

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

Modified files:

Index: src/sys/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.211 src/sys/netinet6/icmp6.c:1.212
--- src/sys/netinet6/icmp6.c:1.211	Tue Mar 14 04:24:04 2017
+++ src/sys/netinet6/icmp6.c	Fri Jul  7 00:55:15 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.211 2017/03/14 04:24:04 ozaki-r Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.212 2017/07/07 00:55:15 knakahara Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.211 2017/03/14 04:24:04 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.212 2017/07/07 00:55:15 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -494,6 +494,15 @@ _icmp6_input(struct mbuf *m, int off, in
 		goto freeit;
 	}
 
+	if (m->m_len < sizeof(struct ip6_hdr)) {
+		m = m_pullup(m, sizeof(struct ip6_hdr));
+		if (m == NULL) {
+			ICMP6_STATINC(ICMP6_STAT_TOOSHORT);
+			icmp6_ifstat_inc(rcvif, ifs6_in_error);
+			goto freeit;
+		}
+	}
+
 	ip6 = mtod(m, struct ip6_hdr *);
 	IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6));
 	if (icmp6 == NULL) {



CVS commit: src/sys/arch/arm

2017-07-06 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Jul  7 00:34:09 UTC 2017

Modified Files:
src/sys/arch/arm/arm32: exception.S
src/sys/arch/arm/include/arm32: frame.h

Log Message:
split PUSHFRAMEINSVC into two pieces so that we can insert some additional
instructions in the middle in undefinedinstruction_bounce, namely to add
some additional space on the stack before the trapframe for undefineds from
SVC mode.  this extra space allows dtrace to emulate a "push" instruction.
the initial version was from me and some improvements were from nick.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/arm32/exception.S
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/include/arm32/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/arm/arm32/exception.S
diff -u src/sys/arch/arm/arm32/exception.S:1.23 src/sys/arch/arm/arm32/exception.S:1.24
--- src/sys/arch/arm/arm32/exception.S:1.23	Sun Jun 21 15:00:06 2015
+++ src/sys/arch/arm/arm32/exception.S	Fri Jul  7 00:34:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: exception.S,v 1.23 2015/06/21 15:00:06 matt Exp $	*/
+/*	$NetBSD: exception.S,v 1.24 2017/07/07 00:34:09 chs Exp $	*/
 
 /*
  * Copyright (c) 1994-1997 Mark Brinicombe.
@@ -51,7 +51,7 @@
 
 #include 
 
-	RCSID("$NetBSD: exception.S,v 1.23 2015/06/21 15:00:06 matt Exp $")
+	RCSID("$NetBSD: exception.S,v 1.24 2017/07/07 00:34:09 chs Exp $")
 
 	.text	
 	.align	0
@@ -258,7 +258,9 @@ ASEND(undefined_entry)
  */
 
 ENTRY_NP(undefinedinstruction_bounce)
-	PUSHFRAMEINSVC
+	PUSHXXXREGSANDSWITCH
+	PUSHDTRACEGAP
+	PUSHTRAPFRAME(r2)
 	ENABLE_ALIGNMENT_FAULTS
 
 	mov	r0, sp

Index: src/sys/arch/arm/include/arm32/frame.h
diff -u src/sys/arch/arm/include/arm32/frame.h:1.43 src/sys/arch/arm/include/arm32/frame.h:1.44
--- src/sys/arch/arm/include/arm32/frame.h:1.43	Thu Jun 22 08:44:21 2017
+++ src/sys/arch/arm/include/arm32/frame.h	Fri Jul  7 00:34:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: frame.h,v 1.43 2017/06/22 08:44:21 skrll Exp $	*/
+/*	$NetBSD: frame.h,v 1.44 2017/07/07 00:34:09 chs Exp $	*/
 
 /*
  * Copyright (c) 1994-1997 Mark Brinicombe.
@@ -95,6 +95,7 @@ void validate_trapframe(trapframe_t *, i
 #include "opt_cpuoptions.h"
 #include "opt_arm_debug.h"
 #include "opt_cputypes.h"
+#include "opt_dtrace.h"
 
 #include 
 
@@ -440,13 +441,25 @@ LOCK_CAS_DEBUG_LOCALS
 	msr cpsr_c, tmp		/* Punch into SVC mode */
 #endif
 
-#define PUSHFRAMEINSVC			   \
+#define PUSHXXXREGSANDSWITCH		   \
 	stmdb	sp, {r0-r3};		/* Save 4 registers */		   \
 	mov	r0, lr;			/* Save xxx32 r14 */		   \
 	mov	r1, sp;			/* Save xxx32 sp */		   \
 	mrs	r3, spsr;		/* Save xxx32 spsr */		   \
-	SET_CPSR_MODE(r2, PSR_SVC32_MODE);   \
-	bic	r2, sp, #7;		/* Align new SVC sp */		   \
+	SET_CPSR_MODE(r2, PSR_SVC32_MODE)
+
+#ifdef KDTRACE_HOOKS
+#define PUSHDTRACEGAP			   \
+	and	r2, r3, #(PSR_MODE);	   \
+	cmp	r2, #(PSR_SVC32_MODE);	/* were we in SVC mode? */	   \
+	mov	r2, sp;			   \
+	subeq	r2, r2, #(4 * 16);	/* if so, leave a gap for dtrace */
+#else
+#define PUSHDTRACEGAP			/* nothing */
+#endif
+
+#define PUSHTRAPFRAME(rX)		   \
+	bic	r2, rX, #7;		/* Align new SVC sp */		   \
 	str	r0, [r2, #-4]!;		/* Push return address */	   \
 	stmdb	r2!, {sp, lr};		/* Push SVC sp, lr */		   \
 	mov	sp, r2;			/* Keep stack aligned */	   \
@@ -458,6 +471,10 @@ LOCK_CAS_DEBUG_LOCALS
 	mrs	r0, spsr;		/* Get the SPSR */		   \
 	str	r0, [sp, #-TF_R0]!	/* Push the SPSR onto the stack */
 
+#define PUSHFRAMEINSVC			   \
+	PUSHXXXREGSANDSWITCH;		   \
+	PUSHTRAPFRAME(sp)
+
 /*
  * PULLFRAMEFROMSVCANDEXIT - macro to pull a trap frame from the stack
  * in SVC32 mode and restore the saved processor mode and PC.



CVS commit: src/sys/arch

2017-07-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul  6 22:10:14 UTC 2017

Modified Files:
src/sys/arch/arm/sunxi: sunxi_ccu.h sunxi_ccu_nkmp.c sunxi_gpio.c
sunxi_gpio.h sunxi_platform.c
src/sys/arch/evbarm/conf: SUNXI
Added Files:
src/sys/arch/arm/sunxi: sun8i_a83t_ccu.c sun8i_a83t_ccu.h
sun8i_a83t_gpio.c

Log Message:
Add support for Allwinner A83T SoC.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sun8i_a83t_ccu.c \
src/sys/arch/arm/sunxi/sun8i_a83t_ccu.h \
src/sys/arch/arm/sunxi/sun8i_a83t_gpio.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_ccu.h \
src/sys/arch/arm/sunxi/sunxi_gpio.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_ccu_nkmp.c \
src/sys/arch/arm/sunxi/sunxi_platform.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sunxi_gpio.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/evbarm/conf/SUNXI

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_ccu.h
diff -u src/sys/arch/arm/sunxi/sunxi_ccu.h:1.5 src/sys/arch/arm/sunxi/sunxi_ccu.h:1.6
--- src/sys/arch/arm/sunxi/sunxi_ccu.h:1.5	Sun Jul  2 00:14:09 2017
+++ src/sys/arch/arm/sunxi/sunxi_ccu.h	Thu Jul  6 22:10:14 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu.h,v 1.5 2017/07/02 00:14:09 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu.h,v 1.6 2017/07/06 22:10:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -96,6 +96,7 @@ struct sunxi_ccu_nkmp {
 	uint32_t	enable;
 	uint32_t	flags;
 #define	SUNXI_CCU_NKMP_DIVIDE_BY_TWO	__BIT(0)
+#define	SUNXI_CCU_NKMP_FACTOR_N_EXACT	__BIT(1)
 };
 
 int	sunxi_ccu_nkmp_enable(struct sunxi_ccu_softc *,
Index: src/sys/arch/arm/sunxi/sunxi_gpio.c
diff -u src/sys/arch/arm/sunxi/sunxi_gpio.c:1.5 src/sys/arch/arm/sunxi/sunxi_gpio.c:1.6
--- src/sys/arch/arm/sunxi/sunxi_gpio.c:1.5	Thu Jul  6 10:44:19 2017
+++ src/sys/arch/arm/sunxi/sunxi_gpio.c	Thu Jul  6 22:10:14 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_gpio.c,v 1.5 2017/07/06 10:44:19 jmcneill Exp $ */
+/* $NetBSD: sunxi_gpio.c,v 1.6 2017/07/06 22:10:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_soc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.5 2017/07/06 10:44:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.6 2017/07/06 22:10:14 jmcneill Exp $");
 
 #include 
 #include 
@@ -62,6 +62,10 @@ static const struct of_compat_data compa
 	{ "allwinner,sun6i-a31-pinctrl",	(uintptr_t)_a31_padconf },
 	{ "allwinner,sun6i-a31-r-pinctrl",	(uintptr_t)_a31_r_padconf },
 #endif
+#ifdef SOC_SUN8I_A83T
+	{ "allwinner,sun8i-a83t-pinctrl",	(uintptr_t)_a83t_padconf },
+	{ "allwinner,sun8i-a83t-r-pinctrl",	(uintptr_t)_a83t_r_padconf },
+#endif
 #ifdef SOC_SUN8I_H3
 	{ "allwinner,sun8i-h3-pinctrl",		(uintptr_t)_h3_padconf },
 	{ "allwinner,sun8i-h3-r-pinctrl",	(uintptr_t)_h3_r_padconf },

Index: src/sys/arch/arm/sunxi/sunxi_ccu_nkmp.c
diff -u src/sys/arch/arm/sunxi/sunxi_ccu_nkmp.c:1.3 src/sys/arch/arm/sunxi/sunxi_ccu_nkmp.c:1.4
--- src/sys/arch/arm/sunxi/sunxi_ccu_nkmp.c:1.3	Sun Jul  2 00:14:09 2017
+++ src/sys/arch/arm/sunxi/sunxi_ccu_nkmp.c	Thu Jul  6 22:10:14 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu_nkmp.c,v 1.3 2017/07/02 00:14:09 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu_nkmp.c,v 1.4 2017/07/06 22:10:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_nkmp.c,v 1.3 2017/07/02 00:14:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_nkmp.c,v 1.4 2017/07/06 22:10:14 jmcneill Exp $");
 
 #include 
 #include 
@@ -79,8 +79,14 @@ sunxi_ccu_nkmp_get_rate(struct sunxi_ccu
 		return 0;
 
 	val = CCU_READ(sc, nkmp->reg);
-	n = __SHIFTOUT(val, nkmp->n);
-	k = __SHIFTOUT(val, nkmp->k);
+	if (nkmp->n)
+		n = __SHIFTOUT(val, nkmp->n);
+	else
+		n = 0;
+	if (nkmp->k)
+		k = __SHIFTOUT(val, nkmp->k);
+	else
+		k = 0;
 	if (nkmp->m)
 		m = __SHIFTOUT(val, nkmp->m);
 	else
@@ -93,7 +99,8 @@ sunxi_ccu_nkmp_get_rate(struct sunxi_ccu
 	if (nkmp->enable && !(val & nkmp->enable))
 		return 0;
 
-	n++;
+	if ((nkmp->flags & SUNXI_CCU_NKMP_FACTOR_N_EXACT) == 0)
+		n++;
 	k++;
 	m++;
 	p++;
Index: src/sys/arch/arm/sunxi/sunxi_platform.c
diff -u src/sys/arch/arm/sunxi/sunxi_platform.c:1.3 src/sys/arch/arm/sunxi/sunxi_platform.c:1.4
--- src/sys/arch/arm/sunxi/sunxi_platform.c:1.3	Sun Jul  2 00:14:09 2017
+++ src/sys/arch/arm/sunxi/sunxi_platform.c	Thu Jul  6 22:10:14 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_platform.c,v 1.3 2017/07/02 00:14:09 jmcneill Exp $ */
+/* $NetBSD: sunxi_platform.c,v 1.4 2017/07/06 22:10:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -31,7 +31,7 @@
 #include "opt_fdt_arm.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.3 

CVS commit: src

2017-07-06 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jul  6 21:08:44 UTC 2017

Modified Files:
src/common/lib/libc/stdlib: _strtol.h _strtoul.h
src/tests/lib/libc/stdlib: t_strtol.c

Log Message:
Fix ISO C compliance: strtol of "0xX" should give the largest valid
numeric prefix, which is 0.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/common/lib/libc/stdlib/_strtol.h \
src/common/lib/libc/stdlib/_strtoul.h
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/stdlib/t_strtol.c

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

Modified files:

Index: src/common/lib/libc/stdlib/_strtol.h
diff -u src/common/lib/libc/stdlib/_strtol.h:1.10 src/common/lib/libc/stdlib/_strtol.h:1.11
--- src/common/lib/libc/stdlib/_strtol.h:1.10	Fri Nov 13 16:02:07 2015
+++ src/common/lib/libc/stdlib/_strtol.h	Thu Jul  6 21:08:44 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtol.h,v 1.10 2015/11/13 16:02:07 christos Exp $ */
+/* $NetBSD: _strtol.h,v 1.11 2017/07/06 21:08:44 joerg Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -101,13 +101,17 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const
 			c = *s++;
 	}
 	if ((base == 0 || base == 16) &&
-	c == '0' && (*s == 'x' || *s == 'X')) {
+	c == '0' && (*s == 'x' || *s == 'X') &&
+	((s[1] >= '0' && s[1] <= '9') ||
+	 (s[1] >= 'a' && s[1] <= 'f') ||
+	 (s[1] >= 'A' && s[1] <= 'F'))) {
 		c = s[1];
 		s += 2;
 		base = 16;
 #if 0
 	} else if ((base == 0 || base == 2) &&
-	c == '0' && (*s == 'b' || *s == 'B')) {
+	c == '0' && (*s == 'b' || *s == 'B') &&
+	(s[1] >= '0' && s[1] <= '1')) {
 		c = s[1];
 		s += 2;
 		base = 2;
Index: src/common/lib/libc/stdlib/_strtoul.h
diff -u src/common/lib/libc/stdlib/_strtoul.h:1.10 src/common/lib/libc/stdlib/_strtoul.h:1.11
--- src/common/lib/libc/stdlib/_strtoul.h:1.10	Sat Nov  5 21:11:30 2016
+++ src/common/lib/libc/stdlib/_strtoul.h	Thu Jul  6 21:08:44 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoul.h,v 1.10 2016/11/05 21:11:30 riastradh Exp $ */
+/* $NetBSD: _strtoul.h,v 1.11 2017/07/06 21:08:44 joerg Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -101,13 +101,17 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const
 			c = *s++;
 	}
 	if ((base == 0 || base == 16) &&
-	c == '0' && (*s == 'x' || *s == 'X')) {
+	c == '0' && (*s == 'x' || *s == 'X') &&
+	((s[1] >= '0' && s[1] <= '9') ||
+	 (s[1] >= 'a' && s[1] <= 'f') ||
+	 (s[1] >= 'A' && s[1] <= 'F'))) {
 		c = s[1];
 		s += 2;
 		base = 16;
 #if 0
 	} else if ((base == 0 || base == 2) &&
-	c == '0' && (*s == 'b' || *s == 'B')) {
+	c == '0' && (*s == 'b' || *s == 'B') &&
+	(s[1] >= '0' && s[1] <= '1')) {
 		c = s[1];
 		s += 2;
 		base = 2;

Index: src/tests/lib/libc/stdlib/t_strtol.c
diff -u src/tests/lib/libc/stdlib/t_strtol.c:1.6 src/tests/lib/libc/stdlib/t_strtol.c:1.7
--- src/tests/lib/libc/stdlib/t_strtol.c:1.6	Wed Jun  1 01:12:02 2016
+++ src/tests/lib/libc/stdlib/t_strtol.c	Thu Jul  6 21:08:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_strtol.c,v 1.6 2016/06/01 01:12:02 pgoyette Exp $ */
+/*	$NetBSD: t_strtol.c,v 1.7 2017/07/06 21:08:44 joerg Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_strtol.c,v 1.6 2016/06/01 01:12:02 pgoyette Exp $");
+__RCSID("$NetBSD: t_strtol.c,v 1.7 2017/07/06 21:08:44 joerg Exp $");
 
 #include 
 #include 
@@ -61,8 +61,8 @@ check(struct test *t, long int li, long 
 
 	if ((t->end != NULL && strcmp(t->end, end) != 0) ||
 	(t->end == NULL && *end != '\0'))
-		atf_tc_fail_nonfatal("invalid end pointer ('%s') from "
-		"strtol(%s, , %d)", end, t->str, t->base);
+		atf_tc_fail_nonfatal("invalid end pointer (%p) from "
+		"strtol(%p, , %d)", end, t->str, t->base);
 }
 
 ATF_TC(strtol_base);
@@ -93,12 +93,18 @@ ATF_TC_BODY(strtol_base, tc)
 		{ "1234567",			342391,  8, NULL	},
 		{ "01234567",			342391,  0, NULL	},
 		{ "0123456789",			 123456789, 10, NULL	},
-		{ "0x75bcd15",		 123456789,  0, NULL	},
+		{ "0x75bcd15",			 123456789,  0, NULL	},
+		{ " 0xX",			 0,  0, "xX"	},
+		{ " 0xX",			 0, 16, "xX"	},
+		{ " 0XX",			 0,  0, "XX"	},
+		{ " 0XX",			 0, 16, "XX"	},
 	};
 
 	long long int lli;
 	long int li;
-	char *end;
+	long long int ulli;
+	long int uli;
+	char *end, *end2;
 	size_t i;
 
 	for (i = 0; i < __arraycount(t); i++) {
@@ -106,7 +112,20 @@ ATF_TC_BODY(strtol_base, tc)
 		li = strtol(t[i].str, , t[i].base);
 		lli = strtoll(t[i].str, NULL, t[i].base);
 
+		uli = strtoul(t[i].str, , t[i].base);
+		ulli = strtoull(t[i].str, NULL, t[i].base);
+
 		check([i], li, lli, end);
+
+		if (li != uli)
+			atf_tc_fail_nonfatal("strtoul(%s, NULL, %d) failed "
+			"(rv = %lu)", t[i].str, t[i].base, uli);
+		if (end != end2)
+			atf_tc_fail_nonfatal("invalid end pointer ('%p') from "
+			"strtoul(%s, , %d)", end2, t[i].str, t[i].base);
+		if (lli != ulli)
+			atf_tc_fail_nonfatal("strtoull(%s, 

CVS commit: src/distrib/utils/embedded/conf

2017-07-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul  6 21:07:09 UTC 2017

Modified Files:
src/distrib/utils/embedded/conf: armv7.conf

Log Message:
Test for kernel build directory before reading DTB list


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/distrib/utils/embedded/conf/armv7.conf

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

Modified files:

Index: src/distrib/utils/embedded/conf/armv7.conf
diff -u src/distrib/utils/embedded/conf/armv7.conf:1.13 src/distrib/utils/embedded/conf/armv7.conf:1.14
--- src/distrib/utils/embedded/conf/armv7.conf:1.13	Thu Jul  6 00:17:04 2017
+++ src/distrib/utils/embedded/conf/armv7.conf	Thu Jul  6 21:07:09 2017
@@ -1,4 +1,4 @@
-# $NetBSD: armv7.conf,v 1.13 2017/07/06 00:17:04 jmcneill Exp $
+# $NetBSD: armv7.conf,v 1.14 2017/07/06 21:07:09 jmcneill Exp $
 # ARMv7 customization script used by mkimage
 #
 board=armv7
@@ -139,7 +139,9 @@ populate() {
 	done
 	# .dtb files
 	for k in $kernels_sunxi $kernels_tegra; do
-		dtbs="$(${MAKE} -C ${KERNOBJDIR}/${k} -v DTB)"
+		test -d "${KERNOBJDIR}/${k}" && \
+		dtbs="$(${MAKE} -C ${KERNOBJDIR}/${k} -v DTB)" || \
+		dtbs=
 		for dtb in $dtbs; do
 			f="${kernel}/${dtb}.gz"
 			test -f "${f}" && kernels="${kernels} ${f}"



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

2017-07-06 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Jul  6 20:26:05 UTC 2017

Modified Files:
src/sys/arch/xen/x86: cpu.c

Log Message:
gdt_prepframes() is called with a number of pages, don't convert to a number
of pages again. This didn't fail because we're called with only one page, and
the conversion from '1' to pages resulted in 1 again.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/arch/xen/x86/cpu.c

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

Modified files:

Index: src/sys/arch/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.110 src/sys/arch/xen/x86/cpu.c:1.111
--- src/sys/arch/xen/x86/cpu.c:1.110	Thu Mar 23 18:08:06 2017
+++ src/sys/arch/xen/x86/cpu.c	Thu Jul  6 20:26:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.110 2017/03/23 18:08:06 maxv Exp $	*/
+/*	$NetBSD: cpu.c,v 1.111 2017/07/06 20:26:05 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.110 2017/03/23 18:08:06 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.111 2017/07/06 20:26:05 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -762,7 +762,7 @@ static void
 gdt_prepframes(paddr_t *frames, vaddr_t base, uint32_t entries)
 {
 	int i;
-	for (i = 0; i < roundup(entries, PAGE_SIZE) >> PAGE_SHIFT; i++) {
+	for (i = 0; i < entries; i++) {
 		frames[i] = ((paddr_t)xpmap_ptetomach(
 		(pt_entry_t *)(base + (i << PAGE_SHIFT >> PAGE_SHIFT;
 



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

2017-07-06 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Jul  6 20:23:57 UTC 2017

Modified Files:
src/sys/arch/i386/i386: gdt.c

Log Message:
gdt_size is now in bytes, but the HYPERVISOR_set_gdt() expects a number
of entries and has not been converted.
Xen/i386 now boots again.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/i386/i386/gdt.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/i386/gdt.c
diff -u src/sys/arch/i386/i386/gdt.c:1.64 src/sys/arch/i386/i386/gdt.c:1.65
--- src/sys/arch/i386/i386/gdt.c:1.64	Sun Jul  2 11:21:13 2017
+++ src/sys/arch/i386/i386/gdt.c	Thu Jul  6 20:23:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: gdt.c,v 1.64 2017/07/02 11:21:13 maxv Exp $	*/
+/*	$NetBSD: gdt.c,v 1.65 2017/07/06 20:23:57 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.64 2017/07/02 11:21:13 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.65 2017/07/06 20:23:57 bouyer Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -202,13 +202,14 @@ gdt_init_cpu(struct cpu_info *ci)
 	setregion(, ci->ci_gdt, max_len - 1);
 	lgdt();
 #else
-	size_t len = gdt_size;
+	size_t len = roundup(gdt_size, PAGE_SIZE);
 	unsigned long frames[len >> PAGE_SHIFT];
 	vaddr_t va;
 	pt_entry_t *ptp;
 	size_t f;
 
-	for (va = (vaddr_t)ci->ci_gdt, f = 0; va < (vaddr_t)ci->ci_gdt + len;
+	for (va = (vaddr_t)ci->ci_gdt, f = 0;
+	va < (vaddr_t)ci->ci_gdt + gdt_size;
 	va += PAGE_SIZE, f++) {
 		KASSERT(va >= VM_MIN_KERNEL_ADDRESS);
 		ptp = kvtopte(va);
@@ -226,7 +227,7 @@ gdt_init_cpu(struct cpu_info *ci)
 		}
 	}
 
-	if (HYPERVISOR_set_gdt(frames, gdt_size))
+	if (HYPERVISOR_set_gdt(frames, gdt_size / sizeof(gdtstore[0])))
 		panic("HYPERVISOR_set_gdt failed!\n");
 	lgdt_finish();
 #endif



CVS commit: src/sys/kern

2017-07-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  6 17:42:39 UTC 2017

Modified Files:
src/sys/kern: uipc_socket.c uipc_socket2.c

Log Message:
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.125 -r1.126 src/sys/kern/uipc_socket2.c

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

Modified files:

Index: src/sys/kern/uipc_socket.c
diff -u src/sys/kern/uipc_socket.c:1.255 src/sys/kern/uipc_socket.c:1.256
--- src/sys/kern/uipc_socket.c:1.255	Sat May 27 17:02:56 2017
+++ src/sys/kern/uipc_socket.c	Thu Jul  6 13:42:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket.c,v 1.255 2017/05/27 21:02:56 bouyer Exp $	*/
+/*	$NetBSD: uipc_socket.c,v 1.256 2017/07/06 17:42:39 christos Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.255 2017/05/27 21:02:56 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.256 2017/07/06 17:42:39 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -2410,6 +2410,33 @@ sopoll(struct socket *so, int events)
 	return revents;
 }
 
+struct mbuf **
+sbsavetimestamp(int opt, struct mbuf *m, struct mbuf **mp)
+{
+	struct timeval tv;
+	microtime();
+
+#ifdef SO_OTIMESTAMP
+	if (opt & SO_OTIMESTAMP) {
+		struct timeval50 tv50;
+
+		timeval_to_timeval50(, );
+		*mp = sbcreatecontrol(, sizeof(tv50),
+		SCM_OTIMESTAMP, SOL_SOCKET);
+		if (*mp)
+			mp = &(*mp)->m_next;
+	} else
+#endif
+
+	if (opt & SO_TIMESTAMP) {
+		*mp = sbcreatecontrol(, sizeof(tv),
+		SCM_TIMESTAMP, SOL_SOCKET);
+		if (*mp)
+			mp = &(*mp)->m_next;
+	}
+	return mp;
+}
+
 
 #include 
 

Index: src/sys/kern/uipc_socket2.c
diff -u src/sys/kern/uipc_socket2.c:1.125 src/sys/kern/uipc_socket2.c:1.126
--- src/sys/kern/uipc_socket2.c:1.125	Thu Jul  6 13:08:57 2017
+++ src/sys/kern/uipc_socket2.c	Thu Jul  6 13:42:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket2.c,v 1.125 2017/07/06 17:08:57 christos Exp $	*/
+/*	$NetBSD: uipc_socket2.c,v 1.126 2017/07/06 17:42:39 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,12 +58,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.125 2017/07/06 17:08:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.126 2017/07/06 17:42:39 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
 #include "opt_sb_max.h"
-#include "opt_compat_netbsd.h"
 #endif
 
 #include 
@@ -1528,35 +1527,3 @@ sowait(struct socket *so, bool catch_p, 
 		solockretry(so, lock);
 	return error;
 }
-
-#ifdef COMPAT_50
-#include 
-#include 
-#endif
-
-struct mbuf **
-sbsavetimestamp(int opt, struct mbuf *m, struct mbuf **mp)
-{
-	struct timeval tv;
-	microtime();
-
-#ifdef SO_OTIMESTAMP
-	if (opt & SO_OTIMESTAMP) {
-		struct timeval50 tv50;
-
-		timeval_to_timeval50(, );
-		*mp = sbcreatecontrol(, sizeof(tv50),
-		SCM_OTIMESTAMP, SOL_SOCKET);
-		if (*mp)
-			mp = &(*mp)->m_next;
-	} else
-#endif
-
-	if (opt & SO_TIMESTAMP) {
-		*mp = sbcreatecontrol(, sizeof(tv),
-		SCM_TIMESTAMP, SOL_SOCKET);
-		if (*mp)
-			mp = &(*mp)->m_next;
-	}
-	return mp;
-}



CVS commit: src/sys/netinet6

2017-07-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  6 17:14:35 UTC 2017

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

Log Message:
remove unnecessary casts; use sizeof(var) instead of sizeof(type).


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 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/netinet6/ip6_input.c
diff -u src/sys/netinet6/ip6_input.c:1.179 src/sys/netinet6/ip6_input.c:1.180
--- src/sys/netinet6/ip6_input.c:1.179	Thu Jul  6 13:08:57 2017
+++ src/sys/netinet6/ip6_input.c	Thu Jul  6 13:14:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_input.c,v 1.179 2017/07/06 17:08:57 christos Exp $	*/
+/*	$NetBSD: ip6_input.c,v 1.180 2017/07/06 17:14:35 christos 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.179 2017/07/06 17:08:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.180 2017/07/06 17:14:35 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -1100,8 +1100,7 @@ ip6_savecontrol(struct in6pcb *in6p, str
 		memcpy(_addr, >ip6_dst, sizeof(struct in6_addr));
 		in6_clearscope(_addr);	/* XXX */
 		pi6.ipi6_ifindex = m->m_pkthdr.rcvif_index;
-		*mp = sbcreatecontrol((void *) ,
-		sizeof(struct in6_pktinfo),
+		*mp = sbcreatecontrol(, sizeof(pi6),
 		IS2292(IPV6_2292PKTINFO, IPV6_PKTINFO), IPPROTO_IPV6);
 		if (*mp)
 			mp = &(*mp)->m_next;
@@ -1110,7 +1109,7 @@ ip6_savecontrol(struct in6pcb *in6p, str
 	if (in6p->in6p_flags & IN6P_HOPLIMIT) {
 		int hlim = ip6->ip6_hlim & 0xff;
 
-		*mp = sbcreatecontrol((void *) , sizeof(int),
+		*mp = sbcreatecontrol(, sizeof(hlim),
 		IS2292(IPV6_2292HOPLIMIT, IPV6_HOPLIMIT), IPPROTO_IPV6);
 		if (*mp)
 			mp = &(*mp)->m_next;
@@ -1124,7 +1123,7 @@ ip6_savecontrol(struct in6pcb *in6p, str
 		flowinfo >>= 20;
 
 		tclass = flowinfo & 0xff;
-		*mp = sbcreatecontrol((void *), sizeof(tclass),
+		*mp = sbcreatecontrol(, sizeof(tclass),
 		IPV6_TCLASS, IPPROTO_IPV6);
 
 		if (*mp)
@@ -1172,7 +1171,7 @@ ip6_savecontrol(struct in6pcb *in6p, str
 			 * be removed before returning in the RFC 2292.
 			 * Note: this constraint is removed in RFC3542.
 			 */
-			*mp = sbcreatecontrol((void *)hbh, hbhlen,
+			*mp = sbcreatecontrol(hbh, hbhlen,
 			IS2292(IPV6_2292HOPOPTS, IPV6_HOPOPTS),
 			IPPROTO_IPV6);
 			if (*mp)
@@ -1234,7 +1233,7 @@ ip6_savecontrol(struct in6pcb *in6p, str
 if (!(in6p->in6p_flags & IN6P_DSTOPTS))
 	break;
 
-*mp = sbcreatecontrol((void *)ip6e, elen,
+*mp = sbcreatecontrol(ip6e, elen,
 IS2292(IPV6_2292DSTOPTS, IPV6_DSTOPTS),
 IPPROTO_IPV6);
 if (*mp)
@@ -1245,7 +1244,7 @@ ip6_savecontrol(struct in6pcb *in6p, str
 if (!(in6p->in6p_flags & IN6P_RTHDR))
 	break;
 
-*mp = sbcreatecontrol((void *)ip6e, elen,
+*mp = sbcreatecontrol(ip6e, elen,
 IS2292(IPV6_2292RTHDR, IPV6_RTHDR),
 IPPROTO_IPV6);
 if (*mp)
@@ -1303,7 +1302,7 @@ ip6_notify_pmtu(struct in6pcb *in6p, con
 	if (sa6_recoverscope(_addr))
 		return;
 
-	if ((m_mtu = sbcreatecontrol((void *), sizeof(mtuctl),
+	if ((m_mtu = sbcreatecontrol(, sizeof(mtuctl),
 	IPV6_PATHMTU, IPPROTO_IPV6)) == NULL)
 		return;
 



CVS commit: src/sys/netinet

2017-07-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  6 17:12:34 UTC 2017

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

Log Message:
remove unnecessary casts (no functional change)


To generate a diff of this commit:
cvs rdiff -u -r1.356 -r1.357 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.356 src/sys/netinet/ip_input.c:1.357
--- src/sys/netinet/ip_input.c:1.356	Thu Jul  6 13:08:57 2017
+++ src/sys/netinet/ip_input.c	Thu Jul  6 13:12:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.356 2017/07/06 17:08:57 christos Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.357 2017/07/06 17:12:34 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.356 2017/07/06 17:08:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.357 2017/07/06 17:12:34 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1527,7 +1527,7 @@ ip_savecontrol(struct inpcb *inp, struct
 		mp = sbsavetimestamp(so->so_options, m, mp);
 
 	if (inpflags & INP_RECVDSTADDR) {
-		*mp = sbcreatecontrol((void *) >ip_dst,
+		*mp = sbcreatecontrol(>ip_dst,
 		sizeof(struct in_addr), IP_RECVDSTADDR, IPPROTO_IP);
 		if (*mp)
 			mp = &(*mp)->m_next;
@@ -1536,7 +1536,7 @@ ip_savecontrol(struct inpcb *inp, struct
 		struct in_pktinfo ipi;
 		ipi.ipi_addr = ip->ip_src;
 		ipi.ipi_ifindex = ifp->if_index;
-		*mp = sbcreatecontrol((void *) ,
+		*mp = sbcreatecontrol(,
 		sizeof(ipi), IP_RECVPKTINFO, IPPROTO_IP);
 		if (*mp)
 			mp = &(*mp)->m_next;
@@ -1545,7 +1545,7 @@ ip_savecontrol(struct inpcb *inp, struct
 		struct in_pktinfo ipi;
 		ipi.ipi_addr = ip->ip_dst;
 		ipi.ipi_ifindex = ifp->if_index;
-		*mp = sbcreatecontrol((void *) ,
+		*mp = sbcreatecontrol(,
 		sizeof(ipi), IP_PKTINFO, IPPROTO_IP);
 		if (*mp)
 			mp = &(*mp)->m_next;
@@ -1560,7 +1560,7 @@ ip_savecontrol(struct inpcb *inp, struct
 			mp = &(*mp)->m_next;
 	}
 	if (inpflags & INP_RECVTTL) {
-		*mp = sbcreatecontrol((void *) >ip_ttl,
+		*mp = sbcreatecontrol(>ip_ttl,
 		sizeof(uint8_t), IP_RECVTTL, IPPROTO_IP);
 		if (*mp)
 			mp = &(*mp)->m_next;



CVS commit: src/sys

2017-07-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  6 17:08:57 UTC 2017

Modified Files:
src/sys/kern: uipc_socket2.c
src/sys/netinet: ip_input.c raw_ip.c udp_usrreq.c
src/sys/netinet6: ip6_input.c udp6_usrreq.c
src/sys/sys: socketvar.h

Log Message:
Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.355 -r1.356 src/sys/netinet/ip_input.c
cvs rdiff -u -r1.164 -r1.165 src/sys/netinet/raw_ip.c
cvs rdiff -u -r1.233 -r1.234 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.178 -r1.179 src/sys/netinet6/ip6_input.c
cvs rdiff -u -r1.129 -r1.130 src/sys/netinet6/udp6_usrreq.c
cvs rdiff -u -r1.144 -r1.145 src/sys/sys/socketvar.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/kern/uipc_socket2.c
diff -u src/sys/kern/uipc_socket2.c:1.124 src/sys/kern/uipc_socket2.c:1.125
--- src/sys/kern/uipc_socket2.c:1.124	Sun Oct  2 15:26:46 2016
+++ src/sys/kern/uipc_socket2.c	Thu Jul  6 13:08:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket2.c,v 1.124 2016/10/02 19:26:46 christos Exp $	*/
+/*	$NetBSD: uipc_socket2.c,v 1.125 2017/07/06 17:08:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,11 +58,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.124 2016/10/02 19:26:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.125 2017/07/06 17:08:57 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
 #include "opt_sb_max.h"
+#include "opt_compat_netbsd.h"
 #endif
 
 #include 
@@ -1527,3 +1528,35 @@ sowait(struct socket *so, bool catch_p, 
 		solockretry(so, lock);
 	return error;
 }
+
+#ifdef COMPAT_50
+#include 
+#include 
+#endif
+
+struct mbuf **
+sbsavetimestamp(int opt, struct mbuf *m, struct mbuf **mp)
+{
+	struct timeval tv;
+	microtime();
+
+#ifdef SO_OTIMESTAMP
+	if (opt & SO_OTIMESTAMP) {
+		struct timeval50 tv50;
+
+		timeval_to_timeval50(, );
+		*mp = sbcreatecontrol(, sizeof(tv50),
+		SCM_OTIMESTAMP, SOL_SOCKET);
+		if (*mp)
+			mp = &(*mp)->m_next;
+	} else
+#endif
+
+	if (opt & SO_TIMESTAMP) {
+		*mp = sbcreatecontrol(, sizeof(tv),
+		SCM_TIMESTAMP, SOL_SOCKET);
+		if (*mp)
+			mp = &(*mp)->m_next;
+	}
+	return mp;
+}

Index: src/sys/netinet/ip_input.c
diff -u src/sys/netinet/ip_input.c:1.355 src/sys/netinet/ip_input.c:1.356
--- src/sys/netinet/ip_input.c:1.355	Wed May 31 22:45:14 2017
+++ src/sys/netinet/ip_input.c	Thu Jul  6 13:08:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.355 2017/06/01 02:45:14 chs Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.356 2017/07/06 17:08:57 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,11 +91,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.355 2017/06/01 02:45:14 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.356 2017/07/06 17:08:57 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
-#include "opt_compat_netbsd.h"
 #include "opt_gateway.h"
 #include "opt_ipsec.h"
 #include "opt_mrouting.h"
@@ -174,11 +173,6 @@ __KERNEL_RCSID(0, "$NetBSD: ip_input.c,v
 #define IPMTUDISCTIMEOUT (10 * 60)	/* as per RFC 1191 */
 #endif
 
-#ifdef COMPAT_50
-#include 
-#include 
-#endif
-
 /*
  * Note: DIRECTED_BROADCAST is handled this way so that previous
  * configuration using this option will Just Work.
@@ -1529,27 +1523,9 @@ ip_savecontrol(struct inpcb *inp, struct
 	if (__predict_false(ifp == NULL))
 		return; /* XXX should report error? */
 
-	if (so->so_options & SO_TIMESTAMP
-#ifdef SO_OTIMESTAMP
-	|| so->so_options & SO_OTIMESTAMP
-#endif
-	) {
-		struct timeval tv;
-
-		microtime();
-#ifdef SO_OTIMESTAMP
-		if (so->so_options & SO_OTIMESTAMP) {
-			struct timeval50 tv50;
-			timeval_to_timeval50(, );
-			*mp = sbcreatecontrol((void *) , sizeof(tv50),
-			SCM_OTIMESTAMP, SOL_SOCKET);
-		} else
-#endif
-		*mp = sbcreatecontrol((void *) , sizeof(tv),
-		SCM_TIMESTAMP, SOL_SOCKET);
-		if (*mp)
-			mp = &(*mp)->m_next;
-	}
+	if (SOOPT_TIMESTAMP(so->so_options))
+		mp = sbsavetimestamp(so->so_options, m, mp);
+
 	if (inpflags & INP_RECVDSTADDR) {
 		*mp = sbcreatecontrol((void *) >ip_dst,
 		sizeof(struct in_addr), IP_RECVDSTADDR, IPPROTO_IP);

Index: src/sys/netinet/raw_ip.c
diff -u src/sys/netinet/raw_ip.c:1.164 src/sys/netinet/raw_ip.c:1.165
--- src/sys/netinet/raw_ip.c:1.164	Thu Apr 20 04:46:07 2017
+++ src/sys/netinet/raw_ip.c	Thu Jul  6 13:08:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip.c,v 1.164 2017/04/20 08:46:07 ozaki-r Exp $	*/
+/*	$NetBSD: raw_ip.c,v 1.165 2017/07/06 17:08:57 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,11 +65,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 

CVS commit: [netbsd-6] src/doc

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:30:16 UTC 2017

Modified Files:
src/doc [netbsd-6]: CHANGES-6.2

Log Message:
1419, 1420, 1423, 1427, 1428, 1434


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.287 -r1.1.2.288 src/doc/CHANGES-6.2

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

Modified files:

Index: src/doc/CHANGES-6.2
diff -u src/doc/CHANGES-6.2:1.1.2.287 src/doc/CHANGES-6.2:1.1.2.288
--- src/doc/CHANGES-6.2:1.1.2.287	Wed Jun 21 16:56:53 2017
+++ src/doc/CHANGES-6.2	Thu Jul  6 15:30:16 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.2,v 1.1.2.287 2017/06/21 16:56:53 snj Exp $
+# $NetBSD: CHANGES-6.2,v 1.1.2.288 2017/07/06 15:30:16 snj Exp $
 
 A complete list of changes from the 6.1 release until the 6.2 release:
 
@@ -17893,3 +17893,36 @@ external/mit/expat/dist/xmlwf/xmlwf.dsp 
 	Update expat to 2.2.1.
 	[spz, ticket #1458]
 
+sys/kern/subr_xcall.c1.19
+
+	Fix a race condition of low priority xcall.  PR kern/51632.
+	[ozaki-r, ticket #1419]
+
+share/man/man3/bits.31.17
+
+	These have been able to handle uintmax-width masks since creation.
+	[riastradh, ticket #1420]
+
+usr.bin/ftp/fetch.c1.226
+
+	handle proxy authentication correctly.
+	[nonaka, ticket #1423]
+
+usr.sbin/traceroute6/traceroute6.c		1.43
+
+	PR/47304: -s (source IPv6 address to be used) option does not
+	work because the wrong variable is used.
+	[is, ticket #1427]
+
+usr.bin/ftp/fetch.c1.227
+
+	Use the first name we requested the http/https URL for, not
+	any name we ended up with after random redirects.
+	[nonaka, ticket #1428]
+
+sys/miscfs/procfs/procfs_map.c			1.45
+
+	Maps don't change that frequently between reads, so don't give
+	up and do what linux does (support reading from an offset).
+	[tsutsui, ticket #1434]
+



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

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:28:21 UTC 2017

Modified Files:
src/sys/miscfs/procfs [netbsd-6]: procfs_map.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1434):
sys/miscfs/procfs/procfs_map.c: revision 1.45
Maps don't change that frequently between reads, so don't give up and
do what linux does (support reading from an offset).


To generate a diff of this commit:
cvs rdiff -u -r1.41.8.1 -r1.41.8.2 src/sys/miscfs/procfs/procfs_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/sys/miscfs/procfs/procfs_map.c
diff -u src/sys/miscfs/procfs/procfs_map.c:1.41.8.1 src/sys/miscfs/procfs/procfs_map.c:1.41.8.2
--- src/sys/miscfs/procfs/procfs_map.c:1.41.8.1	Mon Jul 29 08:17:55 2013
+++ src/sys/miscfs/procfs/procfs_map.c	Thu Jul  6 15:28:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_map.c,v 1.41.8.1 2013/07/29 08:17:55 msaitoh Exp $	*/
+/*	$NetBSD: procfs_map.c,v 1.41.8.2 2017/07/06 15:28:21 snj Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_map.c,v 1.41.8.1 2013/07/29 08:17:55 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_map.c,v 1.41.8.2 2017/07/06 15:28:21 snj Exp $");
 
 #include 
 #include 
@@ -124,15 +124,6 @@ procfs_domap(struct lwp *curl, struct pr
 	if (uio->uio_rw != UIO_READ)
 		return EOPNOTSUPP;
 
-	if (uio->uio_offset != 0) {
-		/*
-		 * we return 0 here, so that the second read returns EOF
-		 * we don't support reading from an offset because the
-		 * map could have changed between the two reads.
-		 */
-		return 0;
-	}
-
 	error = 0;
 
 	if (linuxmode != 0)
@@ -219,7 +210,16 @@ again:
 	vm_map_unlock_read(map);
 	uvmspace_free(vm);
 
-	error = uiomove(buffer, pos, uio);
+	/*
+	 * We support reading from an offset, because linux does.
+	 * The map could have changed between the two reads, and
+	 * that could result in junk, but typically it does not.
+	 */
+	if (uio->uio_offset < pos)
+		error = uiomove(buffer + uio->uio_offset,
+		pos - uio->uio_offset, uio);
+	else
+		error = 0;
 out:
 	if (path != NULL)
 		free(path, M_TEMP);



CVS commit: [netbsd-6] src/usr.bin/ftp

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:27:18 UTC 2017

Modified Files:
src/usr.bin/ftp [netbsd-6]: fetch.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #1428):
usr.bin/ftp/fetch.c: revision 1.227
Use the first name we requested the http/https URL for, not any name we ended
up with after random redirects.


To generate a diff of this commit:
cvs rdiff -u -r1.195.2.5 -r1.195.2.6 src/usr.bin/ftp/fetch.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/ftp/fetch.c
diff -u src/usr.bin/ftp/fetch.c:1.195.2.5 src/usr.bin/ftp/fetch.c:1.195.2.6
--- src/usr.bin/ftp/fetch.c:1.195.2.5	Thu Jul  6 15:22:41 2017
+++ src/usr.bin/ftp/fetch.c	Thu Jul  6 15:27:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fetch.c,v 1.195.2.5 2017/07/06 15:22:41 snj Exp $	*/
+/*	$NetBSD: fetch.c,v 1.195.2.6 2017/07/06 15:27:18 snj Exp $	*/
 
 /*-
  * Copyright (c) 1997-2015 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.195.2.5 2017/07/06 15:22:41 snj Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.195.2.6 2017/07/06 15:27:18 snj Exp $");
 #endif /* not lint */
 
 /*
@@ -1369,6 +1369,12 @@ fetch_url(const char *url, const char *p
 			savefile = ftp_strdup(cp + 1);
 		else
 			savefile = ftp_strdup(decodedpath);
+		/*
+		 * Use the first URL we requested not the name after a
+		 * possible redirect, but careful to save it because our
+		 * "safety" check is the match to outfile.
+		 */
+		outfile = ftp_strdup(savefile);
 	}
 	DPRINTF("%s: savefile `%s'\n", __func__, savefile);
 	if (EMPTYSTRING(savefile)) {



CVS commit: [netbsd-6] src/usr.sbin/traceroute6

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:25:57 UTC 2017

Modified Files:
src/usr.sbin/traceroute6 [netbsd-6]: traceroute6.c

Log Message:
Pull up following revision(s) (requested by is in ticket #1427):
usr.sbin/traceroute6/traceroute6.c: revision 1.43
PR/47304: Kouki Ooyatsu: -s (source IPv6 address to be used) option does not
work because the wrong variable is used.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.42.2.1 src/usr.sbin/traceroute6/traceroute6.c

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

Modified files:

Index: src/usr.sbin/traceroute6/traceroute6.c
diff -u src/usr.sbin/traceroute6/traceroute6.c:1.42 src/usr.sbin/traceroute6/traceroute6.c:1.42.2.1
--- src/usr.sbin/traceroute6/traceroute6.c:1.42	Wed Jan  4 16:09:44 2012
+++ src/usr.sbin/traceroute6/traceroute6.c	Thu Jul  6 15:25:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: traceroute6.c,v 1.42 2012/01/04 16:09:44 drochner Exp $	*/
+/*	$NetBSD: traceroute6.c,v 1.42.2.1 2017/07/06 15:25:57 snj Exp $	*/
 /*	$KAME: traceroute6.c,v 1.67 2004/01/25 03:24:39 itojun Exp $	*/
 
 /*
@@ -75,7 +75,7 @@ static char sccsid[] = "@(#)traceroute.c
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: traceroute6.c,v 1.42 2012/01/04 16:09:44 drochner Exp $");
+__RCSID("$NetBSD: traceroute6.c,v 1.42.2.1 2017/07/06 15:25:57 snj Exp $");
 #endif
 #endif
 
@@ -724,10 +724,10 @@ main(int argc, char *argv[])
 		if (error0)
 			errx(1, "Cannot get address for `%s' (%s)", source,
 			gai_strerror(error0));
-		if (res->ai_addrlen > sizeof(Src))
+		if (res0->ai_addrlen > sizeof(Src))
 			errx(1, "Bad incompatible address length");
-		memcpy(, res->ai_addr, res->ai_addrlen);
-		freeaddrinfo(res);
+		memcpy(, res0->ai_addr, res0->ai_addrlen);
+		freeaddrinfo(res0);
 	} else {
 		struct sockaddr_in6 Nxt;
 		int dummy;



CVS commit: [netbsd-6] src/usr.bin/ftp

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:22:41 UTC 2017

Modified Files:
src/usr.bin/ftp [netbsd-6]: fetch.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #1423):
usr.bin/ftp/fetch.c: revision 1.226
handle proxy authentication correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.195.2.4 -r1.195.2.5 src/usr.bin/ftp/fetch.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/ftp/fetch.c
diff -u src/usr.bin/ftp/fetch.c:1.195.2.4 src/usr.bin/ftp/fetch.c:1.195.2.5
--- src/usr.bin/ftp/fetch.c:1.195.2.4	Wed Nov 16 17:56:42 2016
+++ src/usr.bin/ftp/fetch.c	Thu Jul  6 15:22:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fetch.c,v 1.195.2.4 2016/11/16 17:56:42 snj Exp $	*/
+/*	$NetBSD: fetch.c,v 1.195.2.5 2017/07/06 15:22:41 snj Exp $	*/
 
 /*-
  * Copyright (c) 1997-2015 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.195.2.4 2016/11/16 17:56:42 snj Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.195.2.5 2017/07/06 15:22:41 snj Exp $");
 #endif /* not lint */
 
 /*
@@ -855,8 +855,7 @@ print_connect(FETCH *fin, const struct u
 #define C_OK 0
 #define C_CLEANUP 1
 #define C_IMPROPER 2
-#define C_PROXY 3
-#define C_NOPROXY 4
+#define C_RESTART 3
 
 static int
 getresponseline(FETCH *fin, char *buf, size_t buflen, int *len)
@@ -1087,7 +1086,7 @@ negotiate_connection(FETCH *fin, const c
 	case 401:
 	case 407:
 	{
-		struct  authinfo aauth;
+		struct authinfo aauth;
 		char **authp;
 
 		if (hcode == 401)
@@ -1122,7 +1121,8 @@ negotiate_connection(FETCH *fin, const c
 		authp = 
 		if (auth_url(*auth, authp, ) == 0) {
 			*rval = fetch_url(url, penv,
-			pauth->auth, wauth->auth);
+			hcode == 401 ? pauth->auth : aauth.auth,
+			hcode == 401 ? aauth.auth : wauth->auth);
 			memset(*authp, 0, strlen(*authp));
 			FREEPTR(*authp);
 		}
@@ -1217,6 +1217,34 @@ connectmethod(int s, FETCH *fin, struct 
 	switch (hcode) {
 	case 200:
 		break;
+#ifndef NO_AUTH
+	case 407:
+		if (verbose || pauth->auth == NULL ||
+		pauth->user == NULL || pauth->pass == NULL)
+			fprintf(ttyout, "%s\n", message);
+		if (EMPTYSTRING(*auth)) {
+			warnx("No authentication challenge provided by server");
+			goto cleanup_fetch_url;
+		}
+
+		if (pauth->auth != NULL) {
+			char reply[10];
+
+			fprintf(ttyout, "Authorization failed. Retry (y/n)? ");
+			if (get_line(stdin, reply, sizeof(reply), NULL)
+			< 0) {
+goto cleanup_fetch_url;
+			}
+			if (tolower((unsigned char)reply[0]) != 'y')
+goto cleanup_fetch_url;
+			pauth->user = NULL;
+			pauth->pass = NULL;
+		}
+
+		if (auth_url(*auth, >auth, pauth) == 0)
+			goto restart_fetch_url;
+		goto cleanup_fetch_url;
+#endif
 	default:
 		if (message)
 			warnx("Error proxy connect " "`%s'", message);
@@ -1237,6 +1265,9 @@ improper:
 cleanup_fetch_url:
 	rv = C_CLEANUP;
 	goto out;
+restart_fetch_url:
+	rv = C_RESTART;
+	goto out;
 out:
 	FREEPTR(message);
 	return rv;
@@ -1445,6 +1476,10 @@ fetch_url(const char *url, const char *p
 		if (isproxy && oui.utype == HTTPS_URL_T) {
 			switch (connectmethod(s, fin, , , , ,
 			)) {
+			case C_RESTART:
+rval = fetch_url(url, penv, pauth.auth,
+wauth.auth);
+/*FALLTHROUGH*/
 			case C_CLEANUP:
 goto cleanup_fetch_url;
 			case C_IMPROPER:



CVS commit: [netbsd-6] src/share/man/man3

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:21:32 UTC 2017

Modified Files:
src/share/man/man3 [netbsd-6]: bits.3

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1420):
share/man/man3/bits.3: revision 1.17
These have been able to handle uintmax-width masks since creation.


To generate a diff of this commit:
cvs rdiff -u -r1.12.6.1 -r1.12.6.2 src/share/man/man3/bits.3

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/man3/bits.3
diff -u src/share/man/man3/bits.3:1.12.6.1 src/share/man/man3/bits.3:1.12.6.2
--- src/share/man/man3/bits.3:1.12.6.1	Thu Oct 25 17:09:43 2012
+++ src/share/man/man3/bits.3	Thu Jul  6 15:21:32 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bits.3,v 1.12.6.1 2012/10/25 17:09:43 riz Exp $
+.\"	$NetBSD: bits.3,v 1.12.6.2 2017/07/06 15:21:32 snj Exp $
 .\"
 .\" Copyright (c) 2006, 2010 David Young.  All rights reserved.
 .\"
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 17, 2012
+.Dd November 6, 2016
 .Dt BITS 3
 .Os
 .Sh NAME
@@ -146,8 +146,3 @@ contributed the macro names
 .Fn SHIFTIN
 and
 .Fn SHIFTOUT .
-.Sh BUGS
-.Fn __BIT
-and
-.Fn __BITS
-can only express 32-bit bitmasks.



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

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:20:00 UTC 2017

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

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #1419):
sys/kern/subr_xcall.c: revision 1.19
Fix a race condition of low priority xcall
xc_lowpri and xc_thread are racy and xc_wait may return during/before
executing all xcall callbacks, resulting in a kernel panic at worst.
xc_lowpri serializes multiple jobs by a mutex and a cv. If all xcall
callbacks are done, xc_wait returns and also xc_lowpri accepts a next job.
The problem is that a counter that counts the number of finished xcall
callbacks is incremented *before* actually executing a xcall callback
(see xc_tailp++ in xc_thread). So xc_lowpri accepts a next job before
all xcall callbacks complete and a next job begins to run its xcall callbacks.
Even worse the counter is global and shared between jobs, so if a xcall
callback of the next job completes, the shared counter is incremented,
which confuses wc_wait of the previous job as all xcall callbacks of the
previous job are done and wc_wait of the previous job returns during/before
executing its xcall callbacks.
How to fix: there are actually two counters that count the number of finished
xcall callbacks for low priority xcall for historical reasons (I guess):
xc_tailp and xc_low_pri.xc_donep. xc_low_pri.xc_donep is incremented correctly
while xc_tailp is incremented wrongly, i.e., before executing a xcall callback.
We can fix the issue by dropping xc_tailp and using only xc_low_pri.xc_donep.
PR kern/51632


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

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

Modified files:

Index: src/sys/kern/subr_xcall.c
diff -u src/sys/kern/subr_xcall.c:1.13.10.1 src/sys/kern/subr_xcall.c:1.13.10.2
--- src/sys/kern/subr_xcall.c:1.13.10.1	Sat Apr 20 10:05:22 2013
+++ src/sys/kern/subr_xcall.c	Thu Jul  6 15:20:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_xcall.c,v 1.13.10.1 2013/04/20 10:05:22 bouyer Exp $	*/
+/*	$NetBSD: subr_xcall.c,v 1.13.10.2 2017/07/06 15:20:00 snj Exp $	*/
 
 /*-
  * Copyright (c) 2007-2010 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
  
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.13.10.1 2013/04/20 10:05:22 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.13.10.2 2017/07/06 15:20:00 snj Exp $");
 
 #include 
 #include 
@@ -101,7 +101,6 @@ typedef struct {
 
 /* Low priority xcall structures. */
 static xc_state_t	xc_low_pri	__cacheline_aligned;
-static uint64_t		xc_tailp	__cacheline_aligned;
 
 /* High priority xcall structures. */
 static xc_state_t	xc_high_pri	__cacheline_aligned;
@@ -131,7 +130,6 @@ xc_init(void)
 	memset(xclo, 0, sizeof(xc_state_t));
 	mutex_init(>xc_lock, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(>xc_busy, "xclocv");
-	xc_tailp = 0;
 
 	memset(xchi, 0, sizeof(xc_state_t));
 	mutex_init(>xc_lock, MUTEX_DEFAULT, IPL_SOFTCLOCK);
@@ -253,7 +251,7 @@ xc_lowpri(xcfunc_t func, void *arg1, voi
 	uint64_t where;
 
 	mutex_enter(>xc_lock);
-	while (xc->xc_headp != xc_tailp) {
+	while (xc->xc_headp != xc->xc_donep) {
 		cv_wait(>xc_busy, >xc_lock);
 	}
 	xc->xc_arg1 = arg1;
@@ -274,7 +272,7 @@ xc_lowpri(xcfunc_t func, void *arg1, voi
 		ci->ci_data.cpu_xcall_pending = true;
 		cv_signal(>ci_data.cpu_xcall);
 	}
-	KASSERT(xc_tailp < xc->xc_headp);
+	KASSERT(xc->xc_donep < xc->xc_headp);
 	where = xc->xc_headp;
 	mutex_exit(>xc_lock);
 
@@ -299,7 +297,7 @@ xc_thread(void *cookie)
 	mutex_enter(>xc_lock);
 	for (;;) {
 		while (!ci->ci_data.cpu_xcall_pending) {
-			if (xc->xc_headp == xc_tailp) {
+			if (xc->xc_headp == xc->xc_donep) {
 cv_broadcast(>xc_busy);
 			}
 			cv_wait(>ci_data.cpu_xcall, >xc_lock);
@@ -309,7 +307,6 @@ xc_thread(void *cookie)
 		func = xc->xc_func;
 		arg1 = xc->xc_arg1;
 		arg2 = xc->xc_arg2;
-		xc_tailp++;
 		mutex_exit(>xc_lock);
 
 		KASSERT(func != NULL);



CVS commit: [netbsd-6-1] src/doc

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:19:22 UTC 2017

Modified Files:
src/doc [netbsd-6-1]: CHANGES-6.1.6

Log Message:
1419


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.94 -r1.1.2.95 src/doc/CHANGES-6.1.6

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-6.1.6
diff -u src/doc/CHANGES-6.1.6:1.1.2.94 src/doc/CHANGES-6.1.6:1.1.2.95
--- src/doc/CHANGES-6.1.6:1.1.2.94	Wed Jun 21 16:46:44 2017
+++ src/doc/CHANGES-6.1.6	Thu Jul  6 15:19:22 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.1.6,v 1.1.2.94 2017/06/21 16:46:44 snj Exp $
+# $NetBSD: CHANGES-6.1.6,v 1.1.2.95 2017/07/06 15:19:22 snj Exp $
 
 A complete list of changes from the NetBSD 6.1.5 release to the NetBSD 6.1.6
 release:
@@ -11940,3 +11940,8 @@ external/mit/expat/dist/xmlwf/xmlwf.dsp 
 	Update expat to 2.2.1.
 	[spz, ticket #1458]
 
+sys/kern/subr_xcall.c1.19
+
+	Fix a race condition of low priority xcall.  PR kern/51632.
+	[ozaki-r, ticket #1419]
+



CVS commit: [netbsd-6-1] src/sys/kern

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:19:01 UTC 2017

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

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #1419):
sys/kern/subr_xcall.c: revision 1.19
Fix a race condition of low priority xcall
xc_lowpri and xc_thread are racy and xc_wait may return during/before
executing all xcall callbacks, resulting in a kernel panic at worst.
xc_lowpri serializes multiple jobs by a mutex and a cv. If all xcall
callbacks are done, xc_wait returns and also xc_lowpri accepts a next job.
The problem is that a counter that counts the number of finished xcall
callbacks is incremented *before* actually executing a xcall callback
(see xc_tailp++ in xc_thread). So xc_lowpri accepts a next job before
all xcall callbacks complete and a next job begins to run its xcall callbacks.
Even worse the counter is global and shared between jobs, so if a xcall
callback of the next job completes, the shared counter is incremented,
which confuses wc_wait of the previous job as all xcall callbacks of the
previous job are done and wc_wait of the previous job returns during/before
executing its xcall callbacks.
How to fix: there are actually two counters that count the number of finished
xcall callbacks for low priority xcall for historical reasons (I guess):
xc_tailp and xc_low_pri.xc_donep. xc_low_pri.xc_donep is incremented correctly
while xc_tailp is incremented wrongly, i.e., before executing a xcall callback.
We can fix the issue by dropping xc_tailp and using only xc_low_pri.xc_donep.
PR kern/51632


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

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

Modified files:

Index: src/sys/kern/subr_xcall.c
diff -u src/sys/kern/subr_xcall.c:1.13.10.1 src/sys/kern/subr_xcall.c:1.13.10.1.2.1
--- src/sys/kern/subr_xcall.c:1.13.10.1	Sat Apr 20 10:05:22 2013
+++ src/sys/kern/subr_xcall.c	Thu Jul  6 15:19:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_xcall.c,v 1.13.10.1 2013/04/20 10:05:22 bouyer Exp $	*/
+/*	$NetBSD: subr_xcall.c,v 1.13.10.1.2.1 2017/07/06 15:19:01 snj Exp $	*/
 
 /*-
  * Copyright (c) 2007-2010 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
  
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.13.10.1 2013/04/20 10:05:22 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.13.10.1.2.1 2017/07/06 15:19:01 snj Exp $");
 
 #include 
 #include 
@@ -101,7 +101,6 @@ typedef struct {
 
 /* Low priority xcall structures. */
 static xc_state_t	xc_low_pri	__cacheline_aligned;
-static uint64_t		xc_tailp	__cacheline_aligned;
 
 /* High priority xcall structures. */
 static xc_state_t	xc_high_pri	__cacheline_aligned;
@@ -131,7 +130,6 @@ xc_init(void)
 	memset(xclo, 0, sizeof(xc_state_t));
 	mutex_init(>xc_lock, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(>xc_busy, "xclocv");
-	xc_tailp = 0;
 
 	memset(xchi, 0, sizeof(xc_state_t));
 	mutex_init(>xc_lock, MUTEX_DEFAULT, IPL_SOFTCLOCK);
@@ -253,7 +251,7 @@ xc_lowpri(xcfunc_t func, void *arg1, voi
 	uint64_t where;
 
 	mutex_enter(>xc_lock);
-	while (xc->xc_headp != xc_tailp) {
+	while (xc->xc_headp != xc->xc_donep) {
 		cv_wait(>xc_busy, >xc_lock);
 	}
 	xc->xc_arg1 = arg1;
@@ -274,7 +272,7 @@ xc_lowpri(xcfunc_t func, void *arg1, voi
 		ci->ci_data.cpu_xcall_pending = true;
 		cv_signal(>ci_data.cpu_xcall);
 	}
-	KASSERT(xc_tailp < xc->xc_headp);
+	KASSERT(xc->xc_donep < xc->xc_headp);
 	where = xc->xc_headp;
 	mutex_exit(>xc_lock);
 
@@ -299,7 +297,7 @@ xc_thread(void *cookie)
 	mutex_enter(>xc_lock);
 	for (;;) {
 		while (!ci->ci_data.cpu_xcall_pending) {
-			if (xc->xc_headp == xc_tailp) {
+			if (xc->xc_headp == xc->xc_donep) {
 cv_broadcast(>xc_busy);
 			}
 			cv_wait(>ci_data.cpu_xcall, >xc_lock);
@@ -309,7 +307,6 @@ xc_thread(void *cookie)
 		func = xc->xc_func;
 		arg1 = xc->xc_arg1;
 		arg2 = xc->xc_arg2;
-		xc_tailp++;
 		mutex_exit(>xc_lock);
 
 		KASSERT(func != NULL);



CVS commit: [netbsd-6-0] src/doc

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:18:44 UTC 2017

Modified Files:
src/doc [netbsd-6-0]: CHANGES-6.0.7

Log Message:
1419


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.96 -r1.1.2.97 src/doc/CHANGES-6.0.7

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-6.0.7
diff -u src/doc/CHANGES-6.0.7:1.1.2.96 src/doc/CHANGES-6.0.7:1.1.2.97
--- src/doc/CHANGES-6.0.7:1.1.2.96	Wed Jun 21 16:42:22 2017
+++ src/doc/CHANGES-6.0.7	Thu Jul  6 15:18:44 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.0.7,v 1.1.2.96 2017/06/21 16:42:22 snj Exp $
+# $NetBSD: CHANGES-6.0.7,v 1.1.2.97 2017/07/06 15:18:44 snj Exp $
 
 A complete list of changes from the NetBSD 6.0.6 release to the NetBSD 6.0.7
 release:
@@ -12241,3 +12241,8 @@ external/mit/expat/dist/xmlwf/xmlwf.dsp 
 	Update expat to 2.2.1.
 	[spz, ticket #1458]
 
+sys/kern/subr_xcall.c1.19
+
+	Fix a race condition of low priority xcall.  PR kern/51632.
+	[ozaki-r, ticket #1419]
+



CVS commit: [netbsd-6-0] src/sys/kern

2017-07-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul  6 15:18:23 UTC 2017

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

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #1419):
sys/kern/subr_xcall.c: revision 1.19
Fix a race condition of low priority xcall
xc_lowpri and xc_thread are racy and xc_wait may return during/before
executing all xcall callbacks, resulting in a kernel panic at worst.
xc_lowpri serializes multiple jobs by a mutex and a cv. If all xcall
callbacks are done, xc_wait returns and also xc_lowpri accepts a next job.
The problem is that a counter that counts the number of finished xcall
callbacks is incremented *before* actually executing a xcall callback
(see xc_tailp++ in xc_thread). So xc_lowpri accepts a next job before
all xcall callbacks complete and a next job begins to run its xcall callbacks.
Even worse the counter is global and shared between jobs, so if a xcall
callback of the next job completes, the shared counter is incremented,
which confuses wc_wait of the previous job as all xcall callbacks of the
previous job are done and wc_wait of the previous job returns during/before
executing its xcall callbacks.
How to fix: there are actually two counters that count the number of finished
xcall callbacks for low priority xcall for historical reasons (I guess):
xc_tailp and xc_low_pri.xc_donep. xc_low_pri.xc_donep is incremented correctly
while xc_tailp is incremented wrongly, i.e., before executing a xcall callback.
We can fix the issue by dropping xc_tailp and using only xc_low_pri.xc_donep.
PR kern/51632


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

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

Modified files:

Index: src/sys/kern/subr_xcall.c
diff -u src/sys/kern/subr_xcall.c:1.13.16.1 src/sys/kern/subr_xcall.c:1.13.16.2
--- src/sys/kern/subr_xcall.c:1.13.16.1	Sat Apr 20 10:05:44 2013
+++ src/sys/kern/subr_xcall.c	Thu Jul  6 15:18:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_xcall.c,v 1.13.16.1 2013/04/20 10:05:44 bouyer Exp $	*/
+/*	$NetBSD: subr_xcall.c,v 1.13.16.2 2017/07/06 15:18:23 snj Exp $	*/
 
 /*-
  * Copyright (c) 2007-2010 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
  
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.13.16.1 2013/04/20 10:05:44 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.13.16.2 2017/07/06 15:18:23 snj Exp $");
 
 #include 
 #include 
@@ -101,7 +101,6 @@ typedef struct {
 
 /* Low priority xcall structures. */
 static xc_state_t	xc_low_pri	__cacheline_aligned;
-static uint64_t		xc_tailp	__cacheline_aligned;
 
 /* High priority xcall structures. */
 static xc_state_t	xc_high_pri	__cacheline_aligned;
@@ -131,7 +130,6 @@ xc_init(void)
 	memset(xclo, 0, sizeof(xc_state_t));
 	mutex_init(>xc_lock, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(>xc_busy, "xclocv");
-	xc_tailp = 0;
 
 	memset(xchi, 0, sizeof(xc_state_t));
 	mutex_init(>xc_lock, MUTEX_DEFAULT, IPL_SOFTCLOCK);
@@ -253,7 +251,7 @@ xc_lowpri(xcfunc_t func, void *arg1, voi
 	uint64_t where;
 
 	mutex_enter(>xc_lock);
-	while (xc->xc_headp != xc_tailp) {
+	while (xc->xc_headp != xc->xc_donep) {
 		cv_wait(>xc_busy, >xc_lock);
 	}
 	xc->xc_arg1 = arg1;
@@ -274,7 +272,7 @@ xc_lowpri(xcfunc_t func, void *arg1, voi
 		ci->ci_data.cpu_xcall_pending = true;
 		cv_signal(>ci_data.cpu_xcall);
 	}
-	KASSERT(xc_tailp < xc->xc_headp);
+	KASSERT(xc->xc_donep < xc->xc_headp);
 	where = xc->xc_headp;
 	mutex_exit(>xc_lock);
 
@@ -299,7 +297,7 @@ xc_thread(void *cookie)
 	mutex_enter(>xc_lock);
 	for (;;) {
 		while (!ci->ci_data.cpu_xcall_pending) {
-			if (xc->xc_headp == xc_tailp) {
+			if (xc->xc_headp == xc->xc_donep) {
 cv_broadcast(>xc_busy);
 			}
 			cv_wait(>ci_data.cpu_xcall, >xc_lock);
@@ -309,7 +307,6 @@ xc_thread(void *cookie)
 		func = xc->xc_func;
 		arg1 = xc->xc_arg1;
 		arg2 = xc->xc_arg2;
-		xc_tailp++;
 		mutex_exit(>xc_lock);
 
 		KASSERT(func != NULL);



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

2017-07-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul  6 15:17:47 UTC 2017

Modified Files:
src/sys/arch/arm/include/arm32: pmap.h

Log Message:
KNF two comments


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/sys/arch/arm/include/arm32/pmap.h

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

Modified files:

Index: src/sys/arch/arm/include/arm32/pmap.h
diff -u src/sys/arch/arm/include/arm32/pmap.h:1.149 src/sys/arch/arm/include/arm32/pmap.h:1.150
--- src/sys/arch/arm/include/arm32/pmap.h:1.149	Thu Jul  6 15:07:56 2017
+++ src/sys/arch/arm/include/arm32/pmap.h	Thu Jul  6 15:17:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.149 2017/07/06 15:07:56 skrll Exp $	*/
+/*	$NetBSD: pmap.h,v 1.150 2017/07/06 15:17:47 skrll Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@@ -924,8 +924,10 @@ extern void (*pmap_zero_page_func)(paddr
 #define	L2_L_CACHE_MASK		L2_L_CACHE_MASK_armv6n
 #define	L2_S_CACHE_MASK		L2_S_CACHE_MASK_armv6n
 
-/* These prototypes make writeable mappings, while the other MMU types
- * make read-only mappings. */
+/*
+ * These prototypes make writeable mappings, while the other MMU types
+ * make read-only mappings.
+ */
 #define	L1_SS_PROTO		L1_SS_PROTO_armv6
 #define	L1_S_PROTO		L1_S_PROTO_armv6
 #define	L1_C_PROTO		L1_C_PROTO_armv6
@@ -1007,8 +1009,10 @@ extern void (*pmap_zero_page_func)(paddr
 #define	L2_L_CACHE_MASK		L2_L_CACHE_MASK_armv7
 #define	L2_S_CACHE_MASK		L2_S_CACHE_MASK_armv7
 
-/* These prototypes make writeable mappings, while the other MMU types
- * make read-only mappings. */
+/*
+ * These prototypes make writeable mappings, while the other MMU types
+ * make read-only mappings.
+ */
 #define	L1_SS_PROTO		L1_SS_PROTO_armv7
 #define	L1_S_PROTO		L1_S_PROTO_armv7
 #define	L1_C_PROTO		L1_C_PROTO_armv7



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

2017-07-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul  6 15:09:17 UTC 2017

Modified Files:
src/sys/arch/arm/arm32: arm32_kvminit.c

Log Message:
Now that we can... mark kernel text as non-writable on MMUs that support
it.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/arm/arm32/arm32_kvminit.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/arm/arm32/arm32_kvminit.c
diff -u src/sys/arch/arm/arm32/arm32_kvminit.c:1.39 src/sys/arch/arm/arm32/arm32_kvminit.c:1.40
--- src/sys/arch/arm/arm32/arm32_kvminit.c:1.39	Sat Jul  1 09:18:31 2017
+++ src/sys/arch/arm/arm32/arm32_kvminit.c	Thu Jul  6 15:09:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm32_kvminit.c,v 1.39 2017/07/01 09:18:31 skrll Exp $	*/
+/*	$NetBSD: arm32_kvminit.c,v 1.40 2017/07/06 15:09:17 skrll Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003, 2005  Genetec Corporation.  All rights reserved.
@@ -124,7 +124,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.39 2017/07/01 09:18:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.40 2017/07/06 15:09:17 skrll Exp $");
 
 #include 
 #include 
@@ -687,7 +687,7 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	text.pv_pa = bmi->bmi_kernelstart;
 	text.pv_va = KERN_PHYSTOV(bmi, bmi->bmi_kernelstart);
 	text.pv_size = textsize;
-	text.pv_prot = VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE;
+	text.pv_prot = VM_PROT_READ | VM_PROT_EXECUTE;
 	text.pv_cache = PTE_CACHE;
 
 #ifdef VERBOSE_INIT_ARM



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

2017-07-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul  6 15:07:56 UTC 2017

Modified Files:
src/sys/arch/arm/include/arm32: pmap.h

Log Message:
Re-define the L*_PROT_RO for MMUs that don't really support RO mapping
and adjust l2pte_set_{writeable,readony} to the new values.

This allows RO mappings for MMUs that actually support them.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/arch/arm/include/arm32/pmap.h

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

Modified files:

Index: src/sys/arch/arm/include/arm32/pmap.h
diff -u src/sys/arch/arm/include/arm32/pmap.h:1.148 src/sys/arch/arm/include/arm32/pmap.h:1.149
--- src/sys/arch/arm/include/arm32/pmap.h:1.148	Thu Jul  6 06:31:24 2017
+++ src/sys/arch/arm/include/arm32/pmap.h	Thu Jul  6 15:07:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.148 2017/07/06 06:31:24 skrll Exp $	*/
+/*	$NetBSD: pmap.h,v 1.149 2017/07/06 15:07:56 skrll Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@@ -728,12 +728,12 @@ extern void (*pmap_zero_page_func)(paddr
  */
 #define	L1_S_PROT_U_generic	(L1_S_AP(AP_U))
 #define	L1_S_PROT_W_generic	(L1_S_AP(AP_W))
-#define	L1_S_PROT_RO_generic	(0)
+#define	L1_S_PROT_RO_generic	(L1_S_AP(AP_R))	/* AP_W == AP_R */
 #define	L1_S_PROT_MASK_generic	(L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO)
 
 #define	L1_S_PROT_U_xscale	(L1_S_AP(AP_U))
 #define	L1_S_PROT_W_xscale	(L1_S_AP(AP_W))
-#define	L1_S_PROT_RO_xscale	(0)
+#define	L1_S_PROT_RO_xscale	(L1_S_AP(AP_R))	/* AP_W == AP_R */
 #define	L1_S_PROT_MASK_xscale	(L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO)
 
 #define	L1_S_PROT_U_armv6	(L1_S_AP(AP_R) | L1_S_AP(AP_U))
@@ -754,12 +754,12 @@ extern void (*pmap_zero_page_func)(paddr
 
 #define	L2_L_PROT_U_generic	(L2_AP(AP_U))
 #define	L2_L_PROT_W_generic	(L2_AP(AP_W))
-#define	L2_L_PROT_RO_generic	(0)
+#define	L2_L_PROT_RO_generic	(L2_AP(AP_R))
 #define	L2_L_PROT_MASK_generic	(L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO)
 
 #define	L2_L_PROT_U_xscale	(L2_AP(AP_U))
 #define	L2_L_PROT_W_xscale	(L2_AP(AP_W))
-#define	L2_L_PROT_RO_xscale	(0)
+#define	L2_L_PROT_RO_xscale	(L2_AP(AP_R))
 #define	L2_L_PROT_MASK_xscale	(L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO)
 
 #define	L2_L_PROT_U_armv6n	(L2_AP0(AP_R) | L2_AP0(AP_U))
@@ -780,12 +780,12 @@ extern void (*pmap_zero_page_func)(paddr
 
 #define	L2_S_PROT_U_generic	(L2_AP(AP_U))
 #define	L2_S_PROT_W_generic	(L2_AP(AP_W))
-#define	L2_S_PROT_RO_generic	(0)
+#define	L2_S_PROT_RO_generic	(L2_AP(AP_R))
 #define	L2_S_PROT_MASK_generic	(L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO)
 
 #define	L2_S_PROT_U_xscale	(L2_AP0(AP_U))
 #define	L2_S_PROT_W_xscale	(L2_AP0(AP_W))
-#define	L2_S_PROT_RO_xscale	(0)
+#define	L2_S_PROT_RO_xscale	(L2_AP(AP_R))
 #define	L2_S_PROT_MASK_xscale	(L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO)
 
 #define	L2_S_PROT_U_armv6n	(L2_AP0(AP_R) | L2_AP0(AP_U))
@@ -1023,11 +1023,15 @@ extern void (*pmap_zero_page_func)(paddr
  */
 #define l1pte_set_writable(pte)	(((pte) & ~L1_S_PROT_RO) | L1_S_PROT_W)
 #define l1pte_set_readonly(pte)	(((pte) & ~L1_S_PROT_W) | L1_S_PROT_RO)
-#define l2pte_set_writable(pte)	(((pte) & ~L2_S_PROT_RO) | L2_S_PROT_W)
-#define l2pte_set_readonly(pte)	(((pte) & ~L2_S_PROT_W) | L2_S_PROT_RO)
+
+#define l2pte_set_writable(pte)	(L2_S_PROT_W == L2_S_PROT_RO ? \
+((pte) | L2_S_PROT_W) : (((pte) & ~L2_S_PROT_RO) | L2_S_PROT_W))
+
+#define l2pte_set_readonly(pte)	(L2_S_PROT_W == L2_S_PROT_RO ? \
+((pte) & ~L2_S_PROT_RO) : (((pte) & ~L2_S_PROT_W) | L2_S_PROT_RO))
 
 #define l2pte_writable_p(pte)	(((pte) & L2_S_PROT_W) == L2_S_PROT_W && \
- (L2_S_PROT_RO == 0 || \
+ (L2_S_PROT_W == L2_S_PROT_RO || \
   ((pte) & L2_S_PROT_RO) != L2_S_PROT_RO))
 
 /*



CVS commit: src/sys/dev/fdt

2017-07-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul  6 14:26:00 UTC 2017

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

Log Message:
Only read gpio pin if the pin is valid


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/gpiokeys.c

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

Modified files:

Index: src/sys/dev/fdt/gpiokeys.c
diff -u src/sys/dev/fdt/gpiokeys.c:1.3 src/sys/dev/fdt/gpiokeys.c:1.4
--- src/sys/dev/fdt/gpiokeys.c:1.3	Thu Jul  6 14:01:38 2017
+++ src/sys/dev/fdt/gpiokeys.c	Thu Jul  6 14:26:00 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: gpiokeys.c,v 1.3 2017/07/06 14:01:38 jmcneill Exp $ */
+/* $NetBSD: gpiokeys.c,v 1.4 2017/07/06 14:26:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gpiokeys.c,v 1.3 2017/07/06 14:01:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpiokeys.c,v 1.4 2017/07/06 14:26:00 jmcneill Exp $");
 
 #include 
 #include 
@@ -128,7 +128,8 @@ gpiokeys_attach(device_t parent, device_
 		key->key_debounce = debounce;
 		key->key_pin = fdtbus_gpio_acquire(child, "gpios",
 		GPIO_PIN_INPUT);
-		key->key_state = fdtbus_gpio_read(key->key_pin);
+		if (key->key_pin)
+			key->key_state = fdtbus_gpio_read(key->key_pin);
 
 		key->key_pswitch.smpsw_name = key->key_label;
 		switch (code) {



CVS commit: src/sys/dev/fdt

2017-07-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul  6 14:01:38 UTC 2017

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

Log Message:
Read the initial key state at startup so we only trigger events on state
changes. Prevents a misconfigured power button from shutting us down at
boot.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/gpiokeys.c

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

Modified files:

Index: src/sys/dev/fdt/gpiokeys.c
diff -u src/sys/dev/fdt/gpiokeys.c:1.2 src/sys/dev/fdt/gpiokeys.c:1.3
--- src/sys/dev/fdt/gpiokeys.c:1.2	Wed Dec 16 19:33:55 2015
+++ src/sys/dev/fdt/gpiokeys.c	Thu Jul  6 14:01:38 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: gpiokeys.c,v 1.2 2015/12/16 19:33:55 jmcneill Exp $ */
+/* $NetBSD: gpiokeys.c,v 1.3 2017/07/06 14:01:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gpiokeys.c,v 1.2 2015/12/16 19:33:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpiokeys.c,v 1.3 2017/07/06 14:01:38 jmcneill Exp $");
 
 #include 
 #include 
@@ -128,6 +128,7 @@ gpiokeys_attach(device_t parent, device_
 		key->key_debounce = debounce;
 		key->key_pin = fdtbus_gpio_acquire(child, "gpios",
 		GPIO_PIN_INPUT);
+		key->key_state = fdtbus_gpio_read(key->key_pin);
 
 		key->key_pswitch.smpsw_name = key->key_label;
 		switch (code) {



CVS commit: src/sys/arch/sparc64

2017-07-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jul  6 11:09:01 UTC 2017

Modified Files:
src/sys/arch/sparc64/conf: files.sparc64
Removed Files:
src/sys/arch/sparc64/dev: power.c power.h

Log Message:
Remove unused "power @ ebus" device, we use the firmware to handle power/
reboot.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/arch/sparc64/conf/files.sparc64
cvs rdiff -u -r1.12 -r0 src/sys/arch/sparc64/dev/power.c
cvs rdiff -u -r1.2 -r0 src/sys/arch/sparc64/dev/power.h

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

Modified files:

Index: src/sys/arch/sparc64/conf/files.sparc64
diff -u src/sys/arch/sparc64/conf/files.sparc64:1.152 src/sys/arch/sparc64/conf/files.sparc64:1.153
--- src/sys/arch/sparc64/conf/files.sparc64:1.152	Fri Aug 19 19:02:07 2016
+++ src/sys/arch/sparc64/conf/files.sparc64	Thu Jul  6 11:09:00 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc64,v 1.152 2016/08/19 19:02:07 palle Exp $
+#	$NetBSD: files.sparc64,v 1.153 2017/07/06 11:09:00 martin Exp $
 
 # @(#)files.sparc64	8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -94,10 +94,6 @@ file	arch/sparc64/dev/psm.c			psm
 device timer
 attach timer at mainbus, sbus
 
-device power
-attach power at sbus, ebus
-file	arch/sparc64/dev/power.c		power
-
 device	tda: sysmon_envsys
 attach	tda at iic
 file	arch/sparc64/dev/tda.c			tda



CVS commit: src/sys/arch

2017-07-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul  6 10:44:20 UTC 2017

Modified Files:
src/sys/arch/arm/sunxi: sunxi_gpio.c
src/sys/arch/evbarm/conf: SUNXI

Log Message:
Attach gpio(4) to sunxigpio


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sunxi/sunxi_gpio.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/evbarm/conf/SUNXI

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

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_gpio.c
diff -u src/sys/arch/arm/sunxi/sunxi_gpio.c:1.4 src/sys/arch/arm/sunxi/sunxi_gpio.c:1.5
--- src/sys/arch/arm/sunxi/sunxi_gpio.c:1.4	Sun Jul  2 21:13:06 2017
+++ src/sys/arch/arm/sunxi/sunxi_gpio.c	Thu Jul  6 10:44:19 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_gpio.c,v 1.4 2017/07/02 21:13:06 jmcneill Exp $ */
+/* $NetBSD: sunxi_gpio.c,v 1.5 2017/07/06 10:44:19 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_soc.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.4 2017/07/02 21:13:06 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.5 2017/07/06 10:44:19 jmcneill Exp $");
 
 #include 
 #include 
@@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -73,6 +74,11 @@ struct sunxi_gpio_softc {
 	bus_space_tag_t sc_bst;
 	bus_space_handle_t sc_bsh;
 	const struct sunxi_gpio_padconf *sc_padconf;
+	kmutex_t sc_lock;
+
+	struct gpio_chipset_tag sc_gp;
+	gpio_pin_t *sc_pins;
+	device_t sc_gpiodev;
 };
 
 struct sunxi_gpio_pin {
@@ -130,6 +136,8 @@ sunxi_gpio_setfunc(struct sunxi_gpio_sof
 	uint32_t cfg;
 	u_int n;
 
+	KASSERT(mutex_owned(>sc_lock));
+
 	const bus_size_t cfg_reg = SUNXI_GPIO_CFG(pin_def->port, pin_def->pin);
 	const uint32_t cfg_mask = SUNXI_GPIO_CFG_PINMASK(pin_def->pin);
 
@@ -162,6 +170,8 @@ sunxi_gpio_setpull(struct sunxi_gpio_sof
 {
 	uint32_t pull;
 
+	KASSERT(mutex_owned(>sc_lock));
+
 	const bus_size_t pull_reg = SUNXI_GPIO_PULL(pin_def->port, pin_def->pin);
 	const uint32_t pull_mask = SUNXI_GPIO_PULL_PINMASK(pin_def->pin);
 
@@ -188,6 +198,8 @@ sunxi_gpio_setdrv(struct sunxi_gpio_soft
 {
 	uint32_t drv;
 
+	KASSERT(mutex_owned(>sc_lock));
+
 	if (drive_strength < 10 || drive_strength > 40)
 		return EINVAL;
 
@@ -210,6 +222,8 @@ static int
 sunxi_gpio_ctl(struct sunxi_gpio_softc *sc, const struct sunxi_gpio_pins *pin_def,
 int flags)
 {
+	KASSERT(mutex_owned(>sc_lock));
+
 	if (flags & GPIO_PIN_INPUT)
 		return sunxi_gpio_setfunc(sc, pin_def, "gpio_in");
 	if (flags & GPIO_PIN_OUTPUT)
@@ -238,7 +252,10 @@ sunxi_gpio_acquire(device_t dev, const v
 	if (pin_def == NULL)
 		return NULL;
 
+	mutex_enter(>sc_lock);
 	error = sunxi_gpio_ctl(sc, pin_def, flags);
+	mutex_exit(>sc_lock);
+
 	if (error != 0)
 		return NULL;
 
@@ -275,6 +292,7 @@ sunxi_gpio_read(device_t dev, void *priv
 	const bus_size_t data_reg = SUNXI_GPIO_DATA(pin_def->port);
 	const uint32_t data_mask = __BIT(pin_def->pin);
 
+	/* No lock required for reads */
 	data = GPIO_READ(sc, data_reg);
 	val = __SHIFTOUT(data, data_mask);
 	if (!raw && pin->pin_actlo)
@@ -305,7 +323,7 @@ sunxi_gpio_write(device_t dev, void *pri
 	if (!raw && pin->pin_actlo)
 		val = !val;
 
-	/* XXX locking */
+	mutex_enter(>sc_lock);
 	data = GPIO_READ(sc, data_reg);
 	data &= ~data_mask;
 	data |= __SHIFTIN(val, data_mask);
@@ -314,6 +332,7 @@ sunxi_gpio_write(device_t dev, void *pri
 	pin_def->port + 'A', pin_def->pin, GPIO_READ(sc, data_reg), data);
 #endif
 	GPIO_WRITE(sc, data_reg, data_mask);
+	mutex_exit(>sc_lock);
 }
 
 static struct fdtbus_gpio_controller_func sunxi_gpio_funcs = {
@@ -348,6 +367,8 @@ sunxi_pinctrl_set_config(device_t dev, c
 		return -1;
 	const char *pins = fdtbus_get_string(phandle, "pins");
 
+	mutex_enter(>sc_lock);
+
 	for (pins = fdtbus_get_string(phandle, "pins");
 	 pins_len > 0;
 	 pins_len -= strlen(pins) + 1, pins += strlen(pins) + 1) {
@@ -370,6 +391,8 @@ sunxi_pinctrl_set_config(device_t dev, c
 			sunxi_gpio_setdrv(sc, pin_def, drive_strength);
 	}
 
+	mutex_exit(>sc_lock);
+
 	return 0;
 }
 
@@ -378,6 +401,95 @@ static struct fdtbus_pinctrl_controller_
 };
 
 static int
+sunxi_gpio_pin_read(void *priv, int pin)
+{
+	struct sunxi_gpio_softc * const sc = priv;
+	const struct sunxi_gpio_pins *pin_def = >sc_padconf->pins[pin];
+	uint32_t data;
+	int val;
+
+	KASSERT(pin < sc->sc_padconf->npins);
+
+	const bus_size_t data_reg = SUNXI_GPIO_DATA(pin_def->port);
+	const uint32_t data_mask = __BIT(pin_def->pin);
+
+	/* No lock required for reads */
+	data = GPIO_READ(sc, data_reg);
+	val = __SHIFTOUT(data, data_mask);
+
+	return val;
+}
+
+static void
+sunxi_gpio_pin_write(void *priv, int pin, int val)
+{
+	struct sunxi_gpio_softc * const sc = priv;
+	const struct sunxi_gpio_pins *pin_def = >sc_padconf->pins[pin];
+	uint32_t data;
+
+	KASSERT(pin < sc->sc_padconf->npins);
+
+	const bus_size_t data_reg = 

CVS commit: src/sys/dev/gpio

2017-07-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul  6 10:43:06 UTC 2017

Modified Files:
src/sys/dev/gpio: gpio.c gpiovar.h

Log Message:
Let the controller provide a default name for pins. This makes pins easier
to locate when we have multiple banks and a variable number of pins per
bank.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/gpio/gpio.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/gpio/gpiovar.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/gpio/gpio.c
diff -u src/sys/dev/gpio/gpio.c:1.58 src/sys/dev/gpio/gpio.c:1.59
--- src/sys/dev/gpio/gpio.c:1.58	Wed May 11 18:33:40 2016
+++ src/sys/dev/gpio/gpio.c	Thu Jul  6 10:43:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.c,v 1.58 2016/05/11 18:33:40 bouyer Exp $ */
+/* $NetBSD: gpio.c,v 1.59 2017/07/06 10:43:06 jmcneill Exp $ */
 /*	$OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.58 2016/05/11 18:33:40 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.59 2017/07/06 10:43:06 jmcneill Exp $");
 
 /*
  * General Purpose Input/Output framework.
@@ -202,6 +202,8 @@ gpio_attach(device_t parent, device_t se
 {
 	struct gpio_softc *sc = device_private(self);
 	struct gpiobus_attach_args *gba = aux;
+	struct gpio_name *nm;
+	int pin;
 
 	sc->sc_dev = self;
 	sc->sc_gc = gba->gba_gc;
@@ -211,6 +213,17 @@ gpio_attach(device_t parent, device_t se
 	aprint_normal(": %d pins\n", sc->sc_npins);
 	aprint_naive("\n");
 
+	/* Configure default pin names */
+	for (pin = 0; pin < sc->sc_npins; pin++) {
+		if (sc->sc_pins[pin].pin_defname[0] == '\0')
+			continue;
+		nm = kmem_alloc(sizeof(*nm), KM_SLEEP);
+		strlcpy(nm->gp_name, sc->sc_pins[pin].pin_defname,
+		sizeof(nm->gp_name));
+		nm->gp_pin = pin;
+		LIST_INSERT_HEAD(>sc_names, nm, gp_next);
+	}
+
 	if (!pmf_device_register(self, NULL, gpio_resume))
 		aprint_error_dev(self, "couldn't establish power handler\n");
 	mutex_init(>sc_mtx, MUTEX_DEFAULT, IPL_VM);

Index: src/sys/dev/gpio/gpiovar.h
diff -u src/sys/dev/gpio/gpiovar.h:1.16 src/sys/dev/gpio/gpiovar.h:1.17
--- src/sys/dev/gpio/gpiovar.h:1.16	Wed May 11 18:33:40 2016
+++ src/sys/dev/gpio/gpiovar.h	Thu Jul  6 10:43:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: gpiovar.h,v 1.16 2016/05/11 18:33:40 bouyer Exp $ */
+/* $NetBSD: gpiovar.h,v 1.17 2017/07/06 10:43:06 jmcneill Exp $ */
 /*	$OpenBSD: gpiovar.h,v 1.3 2006/01/14 12:33:49 grange Exp $	*/
 
 /*
@@ -44,6 +44,7 @@ typedef struct gpio_pin {
 	gpio_chipset_tag_t	pin_gc;		/* reference the controller */
 	void			(*pin_callback)(void *); /* irq callback */
 	void *			pin_callback_arg; /* callback arg */
+	char			pin_defname[GPIOMAXNAME]; /* default name */
 } gpio_pin_t;
 
 /* Attach GPIO framework to the controller */



CVS commit: src/etc/rc.d

2017-07-06 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Jul  6 09:49:39 UTC 2017

Modified Files:
src/etc/rc.d: network

Log Message:
Revert previous - not a typo, even though it looks like one


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/etc/rc.d/network

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.d/network
diff -u src/etc/rc.d/network:1.72 src/etc/rc.d/network:1.73
--- src/etc/rc.d/network:1.72	Thu Jul  6 09:24:47 2017
+++ src/etc/rc.d/network	Thu Jul  6 09:49:39 2017
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: network,v 1.72 2017/07/06 09:24:47 kre Exp $
+# $NetBSD: network,v 1.73 2017/07/06 09:49:39 kre Exp $
 #
 
 # PROVIDE: network
@@ -435,7 +435,7 @@ network_start_ipv6_autoconf()
 	# IPv6 interface autoconfiguration.
 
 	# dhcpcd will ensure DAD completes before forking
-	if checkyesno rtsol && ! checkyesno dhcpcd; then
+	if checkyesnox rtsol && ! checkyesno dhcpcd; then
 		if [ "$ip6mode" = "autohost" ]; then
 			echo
 			warn "rtsol has been removed, " \



CVS commit: src/sys/netipsec

2017-07-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jul  6 09:49:46 UTC 2017

Modified Files:
src/sys/netipsec: ipsec_input.c ipsec_output.c

Log Message:
Simplify; we can assume sav->tdb_xform cannot be NULL while it's valid


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/netipsec/ipsec_input.c
cvs rdiff -u -r1.49 -r1.50 src/sys/netipsec/ipsec_output.c

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

Modified files:

Index: src/sys/netipsec/ipsec_input.c
diff -u src/sys/netipsec/ipsec_input.c:1.45 src/sys/netipsec/ipsec_input.c:1.46
--- src/sys/netipsec/ipsec_input.c:1.45	Wed Jul  5 03:44:59 2017
+++ src/sys/netipsec/ipsec_input.c	Thu Jul  6 09:49:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec_input.c,v 1.45 2017/07/05 03:44:59 ozaki-r Exp $	*/
+/*	$NetBSD: ipsec_input.c,v 1.46 2017/07/06 09:49:46 ozaki-r Exp $	*/
 /*	$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $	*/
 /*	$OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $	*/
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.45 2017/07/05 03:44:59 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.46 2017/07/06 09:49:46 ozaki-r Exp $");
 
 /*
  * IPsec input processing.
@@ -281,18 +281,7 @@ ipsec_common_input(struct mbuf *m, int s
 		return ENOENT;
 	}
 
-	if (sav->tdb_xform == NULL) {
-		IPSECLOG(LOG_DEBUG,
-		"attempted to use uninitialized SA %s/%08lx/%u\n",
-		ipsec_address(_address, buf, sizeof(buf)),
-		(u_long) ntohl(spi), sproto);
-		IPSEC_ISTAT(sproto, ESP_STAT_NOXFORM, AH_STAT_NOXFORM,
-		IPCOMP_STAT_NOXFORM);
-		KEY_FREESAV();
-		splx(s);
-		m_freem(m);
-		return ENXIO;
-	}
+	KASSERT(sav->tdb_xform != NULL);
 
 	/*
 	 * Call appropriate transform and return -- callback takes care of

Index: src/sys/netipsec/ipsec_output.c
diff -u src/sys/netipsec/ipsec_output.c:1.49 src/sys/netipsec/ipsec_output.c:1.50
--- src/sys/netipsec/ipsec_output.c:1.49	Tue Jul  4 06:45:05 2017
+++ src/sys/netipsec/ipsec_output.c	Thu Jul  6 09:49:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec_output.c,v 1.49 2017/07/04 06:45:05 ozaki-r Exp $	*/
+/*	$NetBSD: ipsec_output.c,v 1.50 2017/07/06 09:49:46 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.49 2017/07/04 06:45:05 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.50 2017/07/06 09:49:46 ozaki-r Exp $");
 
 /*
  * IPsec output processing.
@@ -428,12 +428,7 @@ again:
 	 * Sanity check the SA contents for the caller
 	 * before they invoke the xform output method.
 	 */
-	if (sav->tdb_xform == NULL) {
-		IPSECLOG(LOG_DEBUG, "no transform for SA\n");
-		IPSEC_OSTAT(NOXFORM);
-		*error = EHOSTUNREACH;
-		goto bad;
-	}
+	KASSERT(sav->tdb_xform != NULL);
 	return isr;
 bad:
 	KASSERTMSG(*error != 0, "error return w/ no error code");



CVS commit: src/sys/netipsec

2017-07-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jul  6 09:48:42 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Avoid updating sav directly

On SADB_UPDATE a target sav was updated directly, which was unsafe.
Instead allocate another sav, copy variables of the old sav to
the new one and replace the old one with the new one.


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/netipsec/key.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.166 src/sys/netipsec/key.c:1.167
--- src/sys/netipsec/key.c:1.166	Thu Jul  6 09:04:26 2017
+++ src/sys/netipsec/key.c	Thu Jul  6 09:48:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.166 2017/07/06 09:04:26 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.167 2017/07/06 09:48:42 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.166 2017/07/06 09:04:26 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.167 2017/07/06 09:48:42 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -3150,6 +3150,9 @@ key_setsaval(struct secasvar *sav, struc
 	KASSERT(mhp != NULL);
 	KASSERT(mhp->msg != NULL);
 
+	/* We shouldn't initialize sav variables while someone uses it. */
+	KASSERT(sav->refcnt == 0);
+
 	/* initialization */
 	key_freesaval(sav);
 	sav->tdb_xform = NULL;		/* transform */
@@ -5176,7 +5179,7 @@ key_api_update(struct socket *so, struct
 	const struct sockaddr *src, *dst;
 	struct secasindex saidx;
 	struct secashead *sah;
-	struct secasvar *sav;
+	struct secasvar *sav, *newsav;
 	u_int16_t proto;
 	u_int8_t mode;
 	u_int16_t reqid;
@@ -5283,24 +5286,47 @@ key_api_update(struct socket *so, struct
 		return key_senderror(so, m, EINVAL);
 	}
 
+	/*
+	 * Allocate a new SA instead of modifying the existing SA directly
+	 * to avoid race conditions.
+	 */
+	newsav = kmem_zalloc(sizeof(struct secasvar), KM_SLEEP);
+
 	/* copy sav values */
-	error = key_setsaval(sav, m, mhp);
+	newsav->spi = sav->spi;
+	newsav->seq = sav->seq;
+	newsav->created = sav->created;
+	newsav->pid = sav->pid;
+
+	error = key_setsaval(newsav, m, mhp);
 	if (error) {
-		KEY_FREESAV();
+		KEY_FREESAV();
 		return key_senderror(so, m, error);
 	}
 
-	error = key_handle_natt_info(sav,mhp);
-	if (error != 0)
-		return key_senderror(so, m, EINVAL);
+	error = key_handle_natt_info(newsav, mhp);
+	if (error != 0) {
+		KEY_FREESAV();
+		return key_senderror(so, m, error);
+	}
+
+	/* add to satree */
+	newsav->sah = sah;
+	newsav->refcnt = 1;
+	newsav->state = sav->state;
+	/* We have to keep the order */
+	LIST_INSERT_AFTER(sav, newsav, chain);
 
 	/* check SA values to be mature. */
-	error = key_mature(sav);
+	error = key_mature(newsav);
 	if (error != 0) {
-		KEY_FREESAV();
+		KEY_FREESAV();
 		return key_senderror(so, m, error);
 	}
 
+	key_sa_chgstate(sav, SADB_SASTATE_DEAD);
+	KEY_FREESAV();
+
 {
 	struct mbuf *n;
 



CVS commit: src/etc/rc.d

2017-07-06 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Jul  6 09:24:47 UTC 2017

Modified Files:
src/etc/rc.d: network

Log Message:
PR misc/52370

Correct typo.

XXX pullup 8, pullup 7


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/etc/rc.d/network

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.d/network
diff -u src/etc/rc.d/network:1.71 src/etc/rc.d/network:1.72
--- src/etc/rc.d/network:1.71	Sun Mar  6 18:50:06 2016
+++ src/etc/rc.d/network	Thu Jul  6 09:24:47 2017
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: network,v 1.71 2016/03/06 18:50:06 christos Exp $
+# $NetBSD: network,v 1.72 2017/07/06 09:24:47 kre Exp $
 #
 
 # PROVIDE: network
@@ -435,7 +435,7 @@ network_start_ipv6_autoconf()
 	# IPv6 interface autoconfiguration.
 
 	# dhcpcd will ensure DAD completes before forking
-	if checkyesnox rtsol && ! checkyesno dhcpcd; then
+	if checkyesno rtsol && ! checkyesno dhcpcd; then
 		if [ "$ip6mode" = "autohost" ]; then
 			echo
 			warn "rtsol has been removed, " \



CVS commit: src/sys/netipsec

2017-07-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jul  6 09:04:26 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Fix usages of sadb_msg_errno


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/netipsec/key.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.165 src/sys/netipsec/key.c:1.166
--- src/sys/netipsec/key.c:1.165	Tue Jul  4 08:11:32 2017
+++ src/sys/netipsec/key.c	Thu Jul  6 09:04:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.165 2017/07/04 08:11:32 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.166 2017/07/06 09:04:26 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.165 2017/07/04 08:11:32 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.166 2017/07/06 09:04:26 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -5295,10 +5295,10 @@ key_api_update(struct socket *so, struct
 		return key_senderror(so, m, EINVAL);
 
 	/* check SA values to be mature. */
-	mhp->msg->sadb_msg_errno = key_mature(sav);
-	if (mhp->msg->sadb_msg_errno != 0) {
+	error = key_mature(sav);
+	if (error != 0) {
 		KEY_FREESAV();
-		return key_senderror(so, m, 0);
+		return key_senderror(so, m, error);
 	}
 
 {
@@ -6523,7 +6523,7 @@ key_api_acquire(struct socket *so, struc
 	error = key_acquire(, NULL);
 	if (error != 0) {
 		IPSECLOG(LOG_DEBUG, "error %d returned from key_acquire.\n",
-		mhp->msg->sadb_msg_errno);
+		error);
 		return key_senderror(so, m, error);
 	}
 



CVS commit: src/sys/dev/pci

2017-07-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul  6 08:50:52 UTC 2017

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

Log Message:
 Move the location of wm_get_hw_control() in wm_init_locked() again. Doing
it "after" wm_reset() is required for some AMT based machines to linkup
1Gbps. Tested with HP dc7700.


To generate a diff of this commit:
cvs rdiff -u -r1.517 -r1.518 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.517 src/sys/dev/pci/if_wm.c:1.518
--- src/sys/dev/pci/if_wm.c:1.517	Mon Jun 26 04:22:46 2017
+++ src/sys/dev/pci/if_wm.c	Thu Jul  6 08:50:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.517 2017/06/26 04:22:46 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.518 2017/07/06 08:50:52 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.517 2017/06/26 04:22:46 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.518 2017/07/06 08:50:52 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -5129,10 +5129,6 @@ wm_init_locked(struct ifnet *ifp)
 	ifp->if_collisions += CSR_READ(sc, WMREG_COLC);
 	ifp->if_ierrors += CSR_READ(sc, WMREG_RXERRC);
 
-	/* AMT based hardware can now take control from firmware */
-	if ((sc->sc_flags & WM_F_HAS_AMT) != 0)
-		wm_get_hw_control(sc);
-
 	/* PCH_SPT hardware workaround */
 	if (sc->sc_type == WM_T_PCH_SPT)
 		wm_flush_desc_rings(sc);
@@ -5140,6 +5136,13 @@ wm_init_locked(struct ifnet *ifp)
 	/* Reset the chip to a known state. */
 	wm_reset(sc);
 
+	/*
+	 * AMT based hardware can now take control from firmware
+	 * Do this after reset.
+	 */
+	if ((sc->sc_flags & WM_F_HAS_AMT) != 0)
+		wm_get_hw_control(sc);
+
 	if ((sc->sc_type == WM_T_PCH_SPT) &&
 	pci_intr_type(sc->sc_pc, sc->sc_intrs[0]) == PCI_INTR_TYPE_INTX)
 		wm_legacy_irq_quirk_spt(sc);



CVS commit: src/sys/opencrypto

2017-07-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jul  6 08:27:07 UTC 2017

Modified Files:
src/sys/opencrypto: xform.c

Log Message:
Apply C99-style struct initialization to enc_xform, auth_hash and comp_algo


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/opencrypto/xform.c

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

Modified files:

Index: src/sys/opencrypto/xform.c
diff -u src/sys/opencrypto/xform.c:1.28 src/sys/opencrypto/xform.c:1.29
--- src/sys/opencrypto/xform.c:1.28	Thu May 26 21:50:03 2011
+++ src/sys/opencrypto/xform.c	Thu Jul  6 08:27:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform.c,v 1.28 2011/05/26 21:50:03 drochner Exp $ */
+/*	$NetBSD: xform.c,v 1.29 2017/07/06 08:27:07 ozaki-r Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/xform.c,v 1.1.2.1 2002/11/21 23:34:23 sam Exp $	*/
 /*	$OpenBSD: xform.c,v 1.19 2002/08/16 22:47:25 dhartmei Exp $	*/
 
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform.c,v 1.28 2011/05/26 21:50:03 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform.c,v 1.29 2017/07/06 08:27:07 ozaki-r Exp $");
 
 #include 
 #include 
@@ -90,169 +90,292 @@ const u_int8_t hmac_opad_buffer[128] = {
 
 /* Encryption instances */
 const struct enc_xform enc_xform_null = {
-	CRYPTO_NULL_CBC, "NULL",
+	.type		= CRYPTO_NULL_CBC,
+	.name		= "NULL",
 	/* NB: blocksize of 4 is to generate a properly aligned ESP header */
-	4, 0, 0, 256 /* 2048 bits, max key */
+	.blocksize	= 4,
+	.ivsize		= 0,
+	.minkey		= 0,
+	.maxkey		= 256, /* 2048 bits, max key */
 };
 
 const struct enc_xform enc_xform_des = {
-	CRYPTO_DES_CBC, "DES",
-	8, 8, 8, 8
+	.type		= CRYPTO_DES_CBC,
+	.name		= "DES",
+	.blocksize	= 8,
+	.ivsize		= 8,
+	.minkey		= 8,
+	.maxkey		= 8,
 };
 
 const struct enc_xform enc_xform_3des = {
-	CRYPTO_3DES_CBC, "3DES",
-	8, 8, 24, 24
+	.type		= CRYPTO_3DES_CBC,
+	.name		= "3DES",
+	.blocksize	= 8,
+	.ivsize		= 8,
+	.minkey		= 24,
+	.maxkey		= 24,
 };
 
 const struct enc_xform enc_xform_blf = {
-	CRYPTO_BLF_CBC, "Blowfish",
-	8, 8, 5, 56 /* 448 bits, max key */
+	.type		= CRYPTO_BLF_CBC,
+	.name		= "Blowfish",
+	.blocksize	= 8,
+	.ivsize		= 8,
+	.minkey		= 5,
+	.maxkey		= 56, /* 448 bits, max key */
 };
 
 const struct enc_xform enc_xform_cast5 = {
-	CRYPTO_CAST_CBC, "CAST-128",
-	8, 8, 5, 16
+	.type		= CRYPTO_CAST_CBC,
+	.name		= "CAST-128",
+	.blocksize	= 8,
+	.ivsize		= 8,
+	.minkey		= 5,
+	.maxkey		= 16,
 };
 
 const struct enc_xform enc_xform_skipjack = {
-	CRYPTO_SKIPJACK_CBC, "Skipjack",
-	8, 8, 10, 10
+	.type		= CRYPTO_SKIPJACK_CBC,
+	.name		= "Skipjack",
+	.blocksize	= 8,
+	.ivsize		= 8,
+	.minkey		= 10,
+	.maxkey		= 10,
 };
 
 const struct enc_xform enc_xform_rijndael128 = {
-	CRYPTO_RIJNDAEL128_CBC, "Rijndael-128/AES",
-	16, 16, 16, 32
+	.type		= CRYPTO_RIJNDAEL128_CBC,
+	.name		= "Rijndael-128/AES",
+	.blocksize	= 16,
+	.ivsize		= 16,
+	.minkey		= 16,
+	.maxkey		= 32,
 };
 
 const struct enc_xform enc_xform_arc4 = {
-	CRYPTO_ARC4, "ARC4",
-	1, 0, 1, 32
+	.type		= CRYPTO_ARC4,
+	.name		= "ARC4",
+	.blocksize	= 1,
+	.ivsize		= 0,
+	.minkey		= 1,
+	.maxkey		= 32,
 };
 
 const struct enc_xform enc_xform_camellia = {
-	CRYPTO_CAMELLIA_CBC, "Camellia",
-	16, 16, 8, 32
+	.type		= CRYPTO_CAMELLIA_CBC,
+	.name		= "Camellia",
+	.blocksize	= 16,
+	.ivsize		= 16,
+	.minkey		= 8,
+	.maxkey		= 32,
 };
 
 const struct enc_xform enc_xform_aes_ctr = {
-	CRYPTO_AES_CTR, "AES-CTR",
-	16, 8, 16+4, 32+4
+	.type		= CRYPTO_AES_CTR,
+	.name		= "AES-CTR",
+	.blocksize	= 16,
+	.ivsize		= 8,
+	.minkey		= 16 + 4,
+	.maxkey		= 32 + 4,
 };
 
 const struct enc_xform enc_xform_aes_gcm = {
-	CRYPTO_AES_GCM_16, "AES-GCM",
-	4 /* ??? */, 8, 16+4, 32+4
+	.type		= CRYPTO_AES_GCM_16,
+	.name		= "AES-GCM",
+	.blocksize	= 4, /* ??? */
+	.ivsize		= 8,
+	.minkey		= 16 + 4,
+	.maxkey		= 32 + 4,
 };
 
 const struct enc_xform enc_xform_aes_gmac = {
-	CRYPTO_AES_GMAC, "AES-GMAC",
-	4 /* ??? */, 8, 16+4, 32+4
+	.type		= CRYPTO_AES_GMAC,
+	.name		= "AES-GMAC",
+	.blocksize	= 4, /* ??? */
+	.ivsize		= 8,
+	.minkey		= 16 + 4,
+	.maxkey		= 32 + 4,
 };
 
 /* Authentication instances */
 const struct auth_hash auth_hash_null = {
-	CRYPTO_NULL_HMAC, "NULL-HMAC",
-	0, 0, 12, 64
+	.type		= CRYPTO_NULL_HMAC,
+	.name		= "NULL-HMAC",
+	.keysize	= 0,
+	.hashsize	= 0,
+	.authsize	= 12,
+	.blocksize	= 64,
 };
 
 const struct auth_hash auth_hash_hmac_md5 = {
-	CRYPTO_MD5_HMAC, "HMAC-MD5",
-	16, 16, 16, 64
+	.type		= CRYPTO_MD5_HMAC,
+	.name		= "HMAC-MD5",
+	.keysize	= 16,
+	.hashsize	= 16,
+	.authsize	= 16,
+	.blocksize	= 64,
 };
 
 const struct auth_hash auth_hash_hmac_sha1 = {
-	CRYPTO_SHA1_HMAC, "HMAC-SHA1",
-	20, 20, 20, 64
+	.type		= CRYPTO_SHA1_HMAC,
+	.name		= "HMAC-SHA1",
+	.keysize	= 20,
+	.hashsize	= 20,
+	.authsize	= 20,
+	.blocksize	= 64,
 };
 
 const struct auth_hash auth_hash_hmac_ripemd_160 = {
-	CRYPTO_RIPEMD160_HMAC, "HMAC-RIPEMD-160",
-	20, 20, 20, 64
+	.type		= CRYPTO_RIPEMD160_HMAC,
+	.name		= 

CVS commit: src/sys/opencrypto

2017-07-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jul  6 08:22:45 UTC 2017

Modified Files:
src/sys/opencrypto: xform.h

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/opencrypto/xform.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/opencrypto/xform.h
diff -u src/sys/opencrypto/xform.h:1.19 src/sys/opencrypto/xform.h:1.20
--- src/sys/opencrypto/xform.h:1.19	Thu May 26 21:50:03 2011
+++ src/sys/opencrypto/xform.h	Thu Jul  6 08:22:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform.h,v 1.19 2011/05/26 21:50:03 drochner Exp $ */
+/*	$NetBSD: xform.h,v 1.20 2017/07/06 08:22:45 ozaki-r Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/xform.h,v 1.1.2.1 2002/11/21 23:34:23 sam Exp $	*/
 /*	$OpenBSD: xform.h,v 1.10 2002/04/22 23:10:09 deraadt Exp $	*/
 
@@ -42,8 +42,10 @@ struct auth_hash {
 struct enc_xform {
 	int type;
 	const char *name;
-	u_int16_t blocksize, ivsize;
-	u_int16_t minkey, maxkey;
+	u_int16_t blocksize;
+	u_int16_t ivsize;
+	u_int16_t minkey;
+	u_int16_t maxkey;
 };
 
 struct comp_algo {



CVS commit: src/sys/dev/mii

2017-07-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jul  6 08:09:05 UTC 2017

Modified Files:
src/sys/dev/mii: igphy.c

Log Message:
 Update comment. SmartSpeed workaroud code was added in rev. 1.5. No functional
change.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/mii/igphy.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/mii/igphy.c
diff -u src/sys/dev/mii/igphy.c:1.26 src/sys/dev/mii/igphy.c:1.27
--- src/sys/dev/mii/igphy.c:1.26	Thu Jul  7 06:55:41 2016
+++ src/sys/dev/mii/igphy.c	Thu Jul  6 08:09:05 2017
@@ -1,8 +1,8 @@
-/*	$NetBSD: igphy.c,v 1.26 2016/07/07 06:55:41 msaitoh Exp $	*/
+/*	$NetBSD: igphy.c,v 1.27 2017/07/06 08:09:05 msaitoh Exp $	*/
 
 /*
  * The Intel copyright applies to the analog register setup, and the
- * (currently disabled) SmartSpeed workaround code.
+ * SmartSpeed workaround code.
  */
 
 /***
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.26 2016/07/07 06:55:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.27 2017/07/06 08:09:05 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mii.h"



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

2017-07-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul  6 06:31:24 UTC 2017

Modified Files:
src/sys/arch/arm/include/arm32: pmap.h

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/arch/arm/include/arm32/pmap.h

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

Modified files:

Index: src/sys/arch/arm/include/arm32/pmap.h
diff -u src/sys/arch/arm/include/arm32/pmap.h:1.147 src/sys/arch/arm/include/arm32/pmap.h:1.148
--- src/sys/arch/arm/include/arm32/pmap.h:1.147	Thu May 25 20:42:41 2017
+++ src/sys/arch/arm/include/arm32/pmap.h	Thu Jul  6 06:31:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.147 2017/05/25 20:42:41 skrll Exp $	*/
+/*	$NetBSD: pmap.h,v 1.148 2017/07/06 06:31:24 skrll Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@@ -488,7 +488,7 @@ extern int pmap_needs_pte_sync;
  * Finally, MEMC, GENERIC and XSCALE MMUs do not need PTE syncs.
  *
  * Use run time evaluation for all other cases.
- * 
+ *
  */
 #if (ARM_NMMUS == 1)
 #if (ARM_MMU_SA1 + ARM_MMU_V6 != 0)