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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb 13 07:40:24 UTC 2020

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

Log Message:
Bump the amount of KMEM allowed to 1/3rd of KVM.  _ARCH_ARM_6 has a split
of 2:2 and others have a split of 3:1.

Tested by martin@  Thanks


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/include/arm32/param.h

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



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb 13 07:40:24 UTC 2020

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

Log Message:
Bump the amount of KMEM allowed to 1/3rd of KVM.  _ARCH_ARM_6 has a split
of 2:2 and others have a split of 3:1.

Tested by martin@  Thanks


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/include/arm32/param.h

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

Modified files:

Index: src/sys/arch/arm/include/arm32/param.h
diff -u src/sys/arch/arm/include/arm32/param.h:1.29 src/sys/arch/arm/include/arm32/param.h:1.30
--- src/sys/arch/arm/include/arm32/param.h:1.29	Sat Feb  1 09:21:49 2020
+++ src/sys/arch/arm/include/arm32/param.h	Thu Feb 13 07:40:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.29 2020/02/01 09:21:49 skrll Exp $	*/
+/*	$NetBSD: param.h,v 1.30 2020/02/13 07:40:24 skrll Exp $	*/
 
 /*
  * Copyright (c) 1994,1995 Mark Brinicombe.
@@ -66,7 +66,12 @@
  * logical pages.
  */
 #define	NKMEMPAGES_MIN_DEFAULT	((8 * 1024 * 1024) >> PAGE_SHIFT)
-#define	NKMEMPAGES_MAX_DEFAULT	((128 * 1024 * 1024) >> PAGE_SHIFT)
+
+#if defined(_ARM_ARCH_6)
+#define	NKMEMPAGES_MAX_DEFAULT	((768 * 1024 * 1024) >> PAGE_SHIFT)
+#else
+#define	NKMEMPAGES_MAX_DEFAULT	((256 * 1024 * 1024) >> PAGE_SHIFT)
+#endif
 
 /* Constants used to divide the USPACE area */
 



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb 13 06:28:25 UTC 2020

Modified Files:
src/sys/arch/arm/pci: pci_msi_machdep.c

Log Message:
spaces -> 


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/pci/pci_msi_machdep.c

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

Modified files:

Index: src/sys/arch/arm/pci/pci_msi_machdep.c
diff -u src/sys/arch/arm/pci/pci_msi_machdep.c:1.8 src/sys/arch/arm/pci/pci_msi_machdep.c:1.9
--- src/sys/arch/arm/pci/pci_msi_machdep.c:1.8	Thu Feb 13 00:02:21 2020
+++ src/sys/arch/arm/pci/pci_msi_machdep.c	Thu Feb 13 06:28:25 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_msi_machdep.c,v 1.8 2020/02/13 00:02:21 jmcneill Exp $ */
+/* $NetBSD: pci_msi_machdep.c,v 1.9 2020/02/13 06:28:25 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.8 2020/02/13 00:02:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.9 2020/02/13 06:28:25 skrll Exp $");
 
 #include 
 #include 
@@ -69,7 +69,7 @@ arm_pci_msi_lookup(const struct pci_atta
 	pci_decompose_tag(pa->pa_pc, pa->pa_tag, , , );
 
 	devid = (b << 8) | (d << 3) | f;
-devid = pci_get_devid(pa->pa_pc, devid);
+	devid = pci_get_devid(pa->pa_pc, devid);
 	frameid = pci_get_frameid(pa->pa_pc, devid);
 
 	SIMPLEQ_FOREACH(msip, _pci_msi_list, msi_link)



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb 13 06:28:25 UTC 2020

Modified Files:
src/sys/arch/arm/pci: pci_msi_machdep.c

Log Message:
spaces -> 


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/pci/pci_msi_machdep.c

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



Re: CVS commit: src/external/bsd/dhcpcd/dist/src

2020-02-12 Thread Robert Elz
Date:Thu, 13 Feb 2020 02:45:44 +
From:Roy Marples 
Message-ID:  

  | My understanding was if it could be promoted to an int it would be.
  | So it size_t is bigger in bits than uint16_t and int is also bigger then 
  | promotion occurs and we then have signed vs unsigned.

You're right, but I think Joerg is even more right - or I certainly hope so.

The reasoning is that when the uint16_t gets promoted to int, since int
has more bits than the uint16_t the conversion is done by filling the
low 16 bits of the int with the uint16_t value, and zero filling the rest
(that is, value preserving).   You then have a signed int.  But it is
known to be >= 0.   When that is converted to a size_t (unsigned, and
here assumed to be at least as many bits as an int .. similar reasoning
applies if not) the signed int is sign extended to fit the size_t, and then
made unsigned.   "Sign exiended" here means zero fill, as we know the
value must be >= 0 (so the sign bit must be 0).

The only slightly weird case would be if int were 16 bits, but in that case,
a uint16_t would be an unsigned int, and no promotion to int ever happens,
it simply gets promoted directly to size_t.

If I had to guess, I'd say that gcc is losing the "must be >= 0" part of
the conversion from uint16_t to int, and assuming that the int might be
negative, which would be bad for converting to a size_t.

kre



CVS commit: src/bin/sh

2020-02-12 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb 13 05:19:05 UTC 2020

Modified Files:
src/bin/sh: expand.c expand.h

Log Message:
When expanding a here-doc (NXHERE - the type with an unquoted end delim)
the output will not be further processed (at all) so there is no need
to escape magic chars in the output, and doing so leaves stray CTLESC
chars in the here doc text.  Not good.   So don't do that...

To save a strlen() of the result, to determine the size of the here doc,
make rmescapes() return the length of the resulting string (this isn't
needed for other uses, so didn't happen previously).

Reported on current-users@ (2020-02-06) by Jun Ebihara

XXX pullup -9


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/bin/sh/expand.c
cvs rdiff -u -r1.24 -r1.25 src/bin/sh/expand.h

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



CVS commit: src/bin/sh

2020-02-12 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb 13 05:19:05 UTC 2020

Modified Files:
src/bin/sh: expand.c expand.h

Log Message:
When expanding a here-doc (NXHERE - the type with an unquoted end delim)
the output will not be further processed (at all) so there is no need
to escape magic chars in the output, and doing so leaves stray CTLESC
chars in the here doc text.  Not good.   So don't do that...

To save a strlen() of the result, to determine the size of the here doc,
make rmescapes() return the length of the resulting string (this isn't
needed for other uses, so didn't happen previously).

Reported on current-users@ (2020-02-06) by Jun Ebihara

XXX pullup -9


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/bin/sh/expand.c
cvs rdiff -u -r1.24 -r1.25 src/bin/sh/expand.h

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

Modified files:

Index: src/bin/sh/expand.c
diff -u src/bin/sh/expand.c:1.136 src/bin/sh/expand.c:1.137
--- src/bin/sh/expand.c:1.136	Mon Oct 14 13:34:14 2019
+++ src/bin/sh/expand.c	Thu Feb 13 05:19:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: expand.c,v 1.136 2019/10/14 13:34:14 christos Exp $	*/
+/*	$NetBSD: expand.c,v 1.137 2020/02/13 05:19:05 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)expand.c	8.5 (Berkeley) 5/15/95";
 #else
-__RCSID("$NetBSD: expand.c,v 1.136 2019/10/14 13:34:14 christos Exp $");
+__RCSID("$NetBSD: expand.c,v 1.137 2020/02/13 05:19:05 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -146,10 +146,12 @@ STATIC void rmescapes_nl(char *);
 void
 expandhere(union node *arg, int fd)
 {
+	int len;
 
 	herefd = fd;
 	expandarg(arg, NULL, 0);
-	xwrite(fd, stackblock(), expdest - stackblock());
+	len = rmescapes(stackblock());
+	xwrite(fd, stackblock(),  len);
 }
 
 
@@ -307,7 +309,7 @@ argstr(const char *p, int flag)
 			had_dol_at = 0;
 			break;
 		case CTLESC:
-			if (quotes || ISCTL(*p))
+			if ((quotes || ISCTL(*p)))
 STPUTC(c, expdest);
 			c = *p++;
 			STPUTC(c, expdest);
@@ -2037,9 +2039,11 @@ patmatch(const char *pattern, const char
 
 /*
  * Remove any CTLESC or CTLNONL characters from a string.
+ *
+ * String is modified in place, and we return the length of the result
  */
 
-void
+int
 rmescapes(char *str)
 {
 	char *p, *q;
@@ -2047,7 +2051,7 @@ rmescapes(char *str)
 	p = str;
 	while (!ISCTL(*p)) {
 		if (*p++ == '\0')
-			return;
+			return ((int)(p - str) - 1);
 	}
 	q = p;
 	while (*p) {
@@ -2069,6 +2073,8 @@ rmescapes(char *str)
 		*q++ = *p++;
 	}
 	*q = '\0';
+
+	return ((int)(q - str));
 }
 
 /*

Index: src/bin/sh/expand.h
diff -u src/bin/sh/expand.h:1.24 src/bin/sh/expand.h:1.25
--- src/bin/sh/expand.h:1.24	Sun Nov 18 17:23:37 2018
+++ src/bin/sh/expand.h	Thu Feb 13 05:19:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: expand.h,v 1.24 2018/11/18 17:23:37 kre Exp $	*/
+/*	$NetBSD: expand.h,v 1.25 2020/02/13 05:19:05 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -67,5 +67,5 @@ union node;
 
 void expandhere(union node *, int);
 void expandarg(union node *, struct arglist *, int);
-void rmescapes(char *);
+int rmescapes(char *);
 int casematch(union node *, char *);



CVS commit: src/tests/lib/libc/sys

2020-02-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 13 02:53:46 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_x86_wait.h

Log Message:
Turn off optimization on a function which contains constant labels.
The optimizer splits it and we end up with 2 copies and duplicate symbols.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

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



CVS commit: src/tests/lib/libc/sys

2020-02-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 13 02:53:46 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_x86_wait.h

Log Message:
Turn off optimization on a function which contains constant labels.
The optimizer splits it and we end up with 2 copies and duplicate symbols.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

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

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.18 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.19
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.18	Wed Jan  8 12:23:34 2020
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Wed Feb 12 21:53:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.18 2020/01/08 17:23:34 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.19 2020/02/13 02:53:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -1971,7 +1971,7 @@ ATF_TC_HEAD(x86_cve_2018_8897, tc)
 
 #define X86_CVE_2018_8897_PAGE 0x5000 /* page addressable by 32-bit registers */
 
-static void
+static __attribute__((__optimize__("O0"))) void
 x86_cve_2018_8897_trigger(void)
 {
 	/*



Re: CVS commit: src/external/bsd/dhcpcd/dist/src

2020-02-12 Thread Roy Marples

On 13/02/2020 02:17, Joerg Sonnenberger wrote:

I thought this fell under int promotion and thus became signed vs unsigned?


size_t is guaranteed to be at least 16bit. If INT_MAX == 32767, an
implicit cast of uint16_t would go to unsigned anyway and in all other
cases, any implicit cast must be value preserving.


My understanding was if it could be promoted to an int it would be.
So it size_t is bigger in bits than uint16_t and int is also bigger then 
promotion occurs and we then have signed vs unsigned.


Roy


Re: CVS commit: src/external/bsd/dhcpcd/dist/src

2020-02-12 Thread Joerg Sonnenberger
On Thu, Feb 13, 2020 at 02:07:23AM +, Roy Marples wrote:
> On 12/02/2020 23:58, Joerg Sonnenberger wrote:
> > On Mon, Feb 10, 2020 at 04:45:35PM +, Roy Marples wrote:
> > > On 09/02/2020 19:21, Joerg Sonnenberger wrote:
> > > > On Sat, Feb 08, 2020 at 12:17:16PM +, Santhosh Raju wrote:
> > > > > Module Name:  src
> > > > > Committed By: fox
> > > > > Date: Sat Feb  8 12:17:16 UTC 2020
> > > > > 
> > > > > Modified Files:
> > > > >   src/external/bsd/dhcpcd/dist/src: dhcp.c
> > > > > 
> > > > > Log Message:
> > > > > external/bsd/dhcpcd: Fix a -Wconversion warning.
> > > > > 
> > > > > Type cast uint16_t to size_t to prevent implicit type conversion.
> > > > 
> > > > Seriously? That should not warn and no cast should be used either.
> > > 
> > > What fix would you recommend then?
> > 
> > Disable the warning in GCC and fill an upstream PR against it. A
> > conversion from uint16_t to size_t is value preserving by definition of
> > the ISO C platform limits. It should never create a warning.
> 
> I thought this fell under int promotion and thus became signed vs unsigned?

size_t is guaranteed to be at least 16bit. If INT_MAX == 32767, an
implicit cast of uint16_t would go to unsigned anyway and in all other
cases, any implicit cast must be value preserving.

Joerg


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

2020-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Feb 13 02:12:07 UTC 2020

Modified Files:
src/sys/arch/arm/cortex: gicv3.c gicv3_its.c

Log Message:
Make intr affinity work with MSIs again


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/cortex/gicv3.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/cortex/gicv3_its.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/cortex/gicv3.c
diff -u src/sys/arch/arm/cortex/gicv3.c:1.23 src/sys/arch/arm/cortex/gicv3.c:1.24
--- src/sys/arch/arm/cortex/gicv3.c:1.23	Thu Feb 13 00:42:59 2020
+++ src/sys/arch/arm/cortex/gicv3.c	Thu Feb 13 02:12:06 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3.c,v 1.23 2020/02/13 00:42:59 jmcneill Exp $ */
+/* $NetBSD: gicv3.c,v 1.24 2020/02/13 02:12:06 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -31,7 +31,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.23 2020/02/13 00:42:59 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.24 2020/02/13 02:12:06 jmcneill Exp $");
 
 #include 
 #include 
@@ -634,6 +634,7 @@ gicv3_lpi_get_affinity(struct pic_softc 
 	struct gicv3_softc * const sc = LPITOSOFTC(pic);
 	struct gicv3_lpi_callback *cb;
 
+	kcpuset_zero(affinity);
 	LIST_FOREACH(cb, >sc_lpi_callbacks, list)
 		cb->get_affinity(cb->priv, irq, affinity);
 }
@@ -647,11 +648,11 @@ gicv3_lpi_set_affinity(struct pic_softc 
 
 	LIST_FOREACH(cb, >sc_lpi_callbacks, list) {
 		error = cb->set_affinity(cb->priv, irq, affinity);
-		if (error)
+		if (error != EPASSTHROUGH)
 			return error;
 	}
 
-	return error;
+	return EINVAL;
 }
 #endif
 

Index: src/sys/arch/arm/cortex/gicv3_its.c
diff -u src/sys/arch/arm/cortex/gicv3_its.c:1.26 src/sys/arch/arm/cortex/gicv3_its.c:1.27
--- src/sys/arch/arm/cortex/gicv3_its.c:1.26	Thu Feb 13 00:42:59 2020
+++ src/sys/arch/arm/cortex/gicv3_its.c	Thu Feb 13 02:12:06 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_its.c,v 1.26 2020/02/13 00:42:59 jmcneill Exp $ */
+/* $NetBSD: gicv3_its.c,v 1.27 2020/02/13 02:12:06 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.26 2020/02/13 00:42:59 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.27 2020/02/13 02:12:06 jmcneill Exp $");
 
 #include 
 #include 
@@ -806,7 +806,6 @@ gicv3_its_get_affinity(void *priv, size_
 	struct gicv3_its * const its = priv;
 	struct cpu_info *ci;
 
-	kcpuset_zero(affinity);
 	ci = its->its_targets[irq];
 	if (ci)
 		kcpuset_set(affinity, cpu_index(ci));
@@ -825,7 +824,7 @@ gicv3_its_set_affinity(void *priv, size_
 
 	pa = its->its_pa[irq];
 	if (pa == NULL)
-		return EINVAL;
+		return EPASSTHROUGH;
 
 	ci = cpu_lookup(kcpuset_ffs(affinity) - 1);
 	its->its_targets[irq] = ci;



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

2020-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Feb 13 02:12:07 UTC 2020

Modified Files:
src/sys/arch/arm/cortex: gicv3.c gicv3_its.c

Log Message:
Make intr affinity work with MSIs again


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/cortex/gicv3.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/cortex/gicv3_its.c

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



Re: CVS commit: src/external/bsd/dhcpcd/dist/src

2020-02-12 Thread Roy Marples

On 12/02/2020 23:58, Joerg Sonnenberger wrote:

On Mon, Feb 10, 2020 at 04:45:35PM +, Roy Marples wrote:

On 09/02/2020 19:21, Joerg Sonnenberger wrote:

On Sat, Feb 08, 2020 at 12:17:16PM +, Santhosh Raju wrote:

Module Name:src
Committed By:   fox
Date:   Sat Feb  8 12:17:16 UTC 2020

Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c

Log Message:
external/bsd/dhcpcd: Fix a -Wconversion warning.

Type cast uint16_t to size_t to prevent implicit type conversion.


Seriously? That should not warn and no cast should be used either.


What fix would you recommend then?


Disable the warning in GCC and fill an upstream PR against it. A
conversion from uint16_t to size_t is value preserving by definition of
the ISO C platform limits. It should never create a warning.


I thought this fell under int promotion and thus became signed vs unsigned?

Roy


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

2020-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Feb 13 00:42:59 UTC 2020

Modified Files:
src/sys/arch/arm/cortex: gicv3.c gicv3.h gicv3_its.c

Log Message:
Since all ITS instances share a common LPI configuration table, used a
shared vmem arena to allocate pic irqs. Idea from FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/cortex/gicv3.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/cortex/gicv3.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/cortex/gicv3_its.c

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



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

2020-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Feb 13 00:42:59 UTC 2020

Modified Files:
src/sys/arch/arm/cortex: gicv3.c gicv3.h gicv3_its.c

Log Message:
Since all ITS instances share a common LPI configuration table, used a
shared vmem arena to allocate pic irqs. Idea from FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/cortex/gicv3.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/cortex/gicv3.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/cortex/gicv3_its.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/cortex/gicv3.c
diff -u src/sys/arch/arm/cortex/gicv3.c:1.22 src/sys/arch/arm/cortex/gicv3.c:1.23
--- src/sys/arch/arm/cortex/gicv3.c:1.22	Tue Dec 24 09:12:56 2019
+++ src/sys/arch/arm/cortex/gicv3.c	Thu Feb 13 00:42:59 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3.c,v 1.22 2019/12/24 09:12:56 skrll Exp $ */
+/* $NetBSD: gicv3.c,v 1.23 2020/02/13 00:42:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -31,7 +31,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.22 2019/12/24 09:12:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.23 2020/02/13 00:42:59 jmcneill Exp $");
 
 #include 
 #include 
@@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -828,6 +829,11 @@ gicv3_init(struct gicv3_softc *sc)
 		snprintf(sc->sc_lpi.pic_name, sizeof(sc->sc_lpi.pic_name), "gicv3-lpi");
 		pic_add(>sc_lpi, GIC_LPI_BASE);
 
+		sc->sc_lpi_pool = vmem_create("gicv3-lpi", 0, sc->sc_lpi.pic_maxsources,
+		1, NULL, NULL, NULL, 0, VM_SLEEP, IPL_HIGH);
+		if (sc->sc_lpi_pool == NULL)
+			panic("failed to create gicv3 lpi pool\n");
+
 		gicv3_lpi_init(sc);
 	}
 

Index: src/sys/arch/arm/cortex/gicv3.h
diff -u src/sys/arch/arm/cortex/gicv3.h:1.7 src/sys/arch/arm/cortex/gicv3.h:1.8
--- src/sys/arch/arm/cortex/gicv3.h:1.7	Sun Jun 30 11:11:38 2019
+++ src/sys/arch/arm/cortex/gicv3.h	Thu Feb 13 00:42:59 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3.h,v 1.7 2019/06/30 11:11:38 jmcneill Exp $ */
+/* $NetBSD: gicv3.h,v 1.8 2020/02/13 00:42:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -30,6 +30,7 @@
 #define _ARM_CORTEX_GICV3_H
 
 #include 
+#include 
 
 struct gicv3_dma {
 	bus_dma_segment_t	segs[1];
@@ -73,6 +74,9 @@ struct gicv3_softc {
 	/* LPI pending tables */
 	struct gicv3_dma	sc_lpipend[MAXCPUS];
 
+	/* LPI IDs */
+	vmem_t			*sc_lpi_pool;
+
 	/* Unique identifier for PEs */
 	u_int			sc_processor_id[MAXCPUS];
 

Index: src/sys/arch/arm/cortex/gicv3_its.c
diff -u src/sys/arch/arm/cortex/gicv3_its.c:1.25 src/sys/arch/arm/cortex/gicv3_its.c:1.26
--- src/sys/arch/arm/cortex/gicv3_its.c:1.25	Sat Feb  1 15:33:48 2020
+++ src/sys/arch/arm/cortex/gicv3_its.c	Thu Feb 13 00:42:59 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_its.c,v 1.25 2020/02/01 15:33:48 jmcneill Exp $ */
+/* $NetBSD: gicv3_its.c,v 1.26 2020/02/13 00:42:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.25 2020/02/01 15:33:48 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.26 2020/02/13 00:42:59 jmcneill Exp $");
 
 #include 
 #include 
@@ -284,18 +284,19 @@ gicv3_its_msi_alloc_lpi(struct gicv3_its
 const struct pci_attach_args *pa)
 {
 	struct pci_attach_args *new_pa;
-	int n;
+	vmem_addr_t n;
 
-	for (n = 0; n < its->its_pic->pic_maxsources; n++) {
-		if (its->its_pa[n] == NULL) {
-			new_pa = kmem_alloc(sizeof(*new_pa), KM_SLEEP);
-			memcpy(new_pa, pa, sizeof(*new_pa));
-			its->its_pa[n] = new_pa;
-			return n + its->its_pic->pic_irqbase;
-		}
-	}
+	KASSERT(its->its_gic->sc_lpi_pool != NULL);
 
-return -1;
+	if (vmem_alloc(its->its_gic->sc_lpi_pool, 1, VM_INSTANTFIT|VM_SLEEP, ) != 0)
+		return -1;
+	
+	KASSERT(its->its_pa[n] == NULL);
+
+	new_pa = kmem_alloc(sizeof(*new_pa), KM_SLEEP);
+	memcpy(new_pa, pa, sizeof(*new_pa));
+	its->its_pa[n] = new_pa;
+	return n + its->its_pic->pic_irqbase;
 }
 
 static void
@@ -303,11 +304,14 @@ gicv3_its_msi_free_lpi(struct gicv3_its 
 {
 	struct pci_attach_args *pa;
 
+	KASSERT(its->its_gic->sc_lpi_pool != NULL);
 	KASSERT(lpi >= its->its_pic->pic_irqbase);
 
 	pa = its->its_pa[lpi - its->its_pic->pic_irqbase];
 	its->its_pa[lpi - its->its_pic->pic_irqbase] = NULL;
 	kmem_free(pa, sizeof(*pa));
+
+	vmem_free(its->its_gic->sc_lpi_pool, lpi - its->its_pic->pic_irqbase, 1);
 }
 
 static uint32_t



Re: CVS commit: src/external/bsd/dhcpcd/dist/src

2020-02-12 Thread Joerg Sonnenberger
On Mon, Feb 10, 2020 at 04:45:35PM +, Roy Marples wrote:
> On 09/02/2020 19:21, Joerg Sonnenberger wrote:
> > On Sat, Feb 08, 2020 at 12:17:16PM +, Santhosh Raju wrote:
> > > Module Name:  src
> > > Committed By: fox
> > > Date: Sat Feb  8 12:17:16 UTC 2020
> > > 
> > > Modified Files:
> > >   src/external/bsd/dhcpcd/dist/src: dhcp.c
> > > 
> > > Log Message:
> > > external/bsd/dhcpcd: Fix a -Wconversion warning.
> > > 
> > > Type cast uint16_t to size_t to prevent implicit type conversion.
> > 
> > Seriously? That should not warn and no cast should be used either.
> 
> What fix would you recommend then?

Disable the warning in GCC and fill an upstream PR against it. A
conversion from uint16_t to size_t is value preserving by definition of
the ISO C platform limits. It should never create a warning.

Joerg


CVS commit: src/sys/arch/arm

2020-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Feb 13 00:02:21 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_iort.c acpi_iort.h acpi_pci_machdep.c
gicv3_acpi.c
src/sys/arch/arm/include: pci_machdep.h
src/sys/arch/arm/pci: pci_msi_machdep.c

Log Message:
Add support for multiple GICv3 ITS domains.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/acpi/acpi_iort.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_iort.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/acpi/acpi_pci_machdep.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/acpi/gicv3_acpi.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/include/pci_machdep.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/pci/pci_msi_machdep.c

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

Modified files:

Index: src/sys/arch/arm/acpi/acpi_iort.c
diff -u src/sys/arch/arm/acpi/acpi_iort.c:1.2 src/sys/arch/arm/acpi/acpi_iort.c:1.3
--- src/sys/arch/arm/acpi/acpi_iort.c:1.2	Fri Feb  7 00:35:00 2020
+++ src/sys/arch/arm/acpi/acpi_iort.c	Thu Feb 13 00:02:21 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_iort.c,v 1.2 2020/02/07 00:35:00 jmcneill Exp $ */
+/* $NetBSD: acpi_iort.c,v 1.3 2020/02/13 00:02:21 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_iort.c,v 1.2 2020/02/07 00:35:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_iort.c,v 1.3 2020/02/13 00:02:21 jmcneill Exp $");
 
 #include 
 #include 
@@ -99,7 +99,7 @@ acpi_iort_pci_root_map(u_int seg, uint32
 do {
 	node = acpi_iort_find_ref(iort, node, );
 } while (node != NULL);
-aprint_debug("ACPI: IORT remapped devid %#x -> %#x\n", odevid, devid);
+aprint_debug("ACPI: IORT mapped devid %#x -> devid %#x\n", odevid, devid);
 return devid;
 			}
 		}
@@ -108,3 +108,44 @@ acpi_iort_pci_root_map(u_int seg, uint32
 
 	return devid;
 }
+
+uint32_t
+acpi_iort_its_id_map(u_int seg, uint32_t devid)
+{
+	ACPI_TABLE_IORT *iort;
+	ACPI_IORT_NODE *node;
+	ACPI_IORT_ROOT_COMPLEX *root;
+	ACPI_IORT_ITS_GROUP *its_group;
+	uint32_t offset, n;
+	ACPI_STATUS rv;
+
+	rv = AcpiGetTable(ACPI_SIG_IORT, 0, (ACPI_TABLE_HEADER **));
+	if (ACPI_FAILURE(rv))
+		return 0;
+
+	offset = iort->NodeOffset;
+	for (n = 0; n < iort->NodeCount; n++) {
+		node = ACPI_ADD_PTR(ACPI_IORT_NODE, iort, offset);
+		if (node->Type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) {
+			root = (ACPI_IORT_ROOT_COMPLEX *)node->NodeData;
+			if (root->PciSegmentNumber == seg) {
+const uint32_t odevid = devid;
+do {
+	node = acpi_iort_find_ref(iort, node, );
+	if (node != NULL && node->Type == ACPI_IORT_NODE_ITS_GROUP) {
+		its_group = (ACPI_IORT_ITS_GROUP *)node->NodeData;
+		if (its_group->ItsCount == 0)
+			return 0;
+		aprint_debug("ACPI: IORT mapped devid %#x -> ITS %#x\n",
+		odevid, its_group->Identifiers[0]);
+		return its_group->Identifiers[0];
+	}
+} while (node != NULL);
+return 0;
+			}
+		}
+		offset += node->Length;
+	}
+
+	return 0;
+}

Index: src/sys/arch/arm/acpi/acpi_iort.h
diff -u src/sys/arch/arm/acpi/acpi_iort.h:1.1 src/sys/arch/arm/acpi/acpi_iort.h:1.2
--- src/sys/arch/arm/acpi/acpi_iort.h:1.1	Sat Dec  8 15:04:40 2018
+++ src/sys/arch/arm/acpi/acpi_iort.h	Thu Feb 13 00:02:21 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_iort.h,v 1.1 2018/12/08 15:04:40 jmcneill Exp $ */
+/* $NetBSD: acpi_iort.h,v 1.2 2020/02/13 00:02:21 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -33,5 +33,6 @@
 #define _ARM_ACPI_ACPI_IORT_H
 
 uint32_t	acpi_iort_pci_root_map(u_int, uint32_t);
+uint32_t	acpi_iort_its_id_map(u_int, uint32_t);
 
 #endif /* !_ARM_ACPI_ACPI_IORT_H */

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.15 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.16
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.15	Sat Feb  1 13:26:43 2020
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Thu Feb 13 00:02:21 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.15 2020/02/01 13:26:43 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.16 2020/02/13 00:02:21 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.15 2020/02/01 13:26:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.16 2020/02/13 00:02:21 jmcneill Exp $");
 
 #include 
 #include 
@@ -113,6 +113,7 @@ static pcitag_t	acpi_pci_md_make_tag(voi
 static void	acpi_pci_md_decompose_tag(void *, pcitag_t, int *, int *, int *);
 static u_int	acpi_pci_md_get_segment(void *);
 static uint32_t	acpi_pci_md_get_devid(void *, uint32_t);
+static uint32_t	acpi_pci_md_get_frameid(void *, uint32_t);
 static pcireg_t	acpi_pci_md_conf_read(void *, pcitag_t, int);
 static void	

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

2020-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Feb 13 00:02:40 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_n1sdp.c

Log Message:
Enable MSI and MSI-X support on N1SDP


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c

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



CVS commit: src/sys/arch/arm

2020-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Feb 13 00:02:21 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_iort.c acpi_iort.h acpi_pci_machdep.c
gicv3_acpi.c
src/sys/arch/arm/include: pci_machdep.h
src/sys/arch/arm/pci: pci_msi_machdep.c

Log Message:
Add support for multiple GICv3 ITS domains.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/acpi/acpi_iort.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_iort.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/acpi/acpi_pci_machdep.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/acpi/gicv3_acpi.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/include/pci_machdep.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/pci/pci_msi_machdep.c

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



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

2020-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Feb 13 00:02:40 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_n1sdp.c

Log Message:
Enable MSI and MSI-X support on N1SDP


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_pci_n1sdp.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/acpi/acpi_pci_n1sdp.c
diff -u src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.1 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.2
--- src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.1	Fri Jan 17 17:06:33 2020
+++ src/sys/arch/arm/acpi/acpi_pci_n1sdp.c	Thu Feb 13 00:02:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_n1sdp.c,v 1.1 2020/01/17 17:06:33 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_n1sdp.c,v 1.2 2020/02/13 00:02:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_n1sdp.c,v 1.1 2020/01/17 17:06:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_n1sdp.c,v 1.2 2020/02/13 00:02:40 jmcneill Exp $");
 
 #include 
 #include 
@@ -186,8 +186,6 @@ acpi_pci_n1sdp_init(struct acpi_pci_cont
 	ap->ap_conf_read = acpi_pci_n1sdp_conf_read;
 	ap->ap_conf_write = acpi_pci_n1sdp_conf_write;
 
-	/* IO space access and MSI seems to cause async SErrors, so disable for now */
-	ap->ap_pciflags_clear = PCI_FLAGS_IO_OKAY |
-PCI_FLAGS_MSI_OKAY |
-PCI_FLAGS_MSIX_OKAY;
+	/* IO space access seems to cause async SErrors, so disable for now */
+	ap->ap_pciflags_clear = PCI_FLAGS_IO_OKAY;
 }



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 22:34:51 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci:
nouveau_nvkm_subdev_pci_base.c

Log Message:
adjust the PCI interrupt allocation code to work the same as
drm_pci_request_irq(), now the driver successfully allocates MSI interrupt

[   3.6619808] nouveau0: info: NVIDIA GK208B (b06070b1)
[   3.7685336] nouveau0: info: bios: version 80.28.78.00.4b
[   3.7785491] nouveau0: interrupting at msi8 vec 0 (nouveau0)

related to PR kern/52440 by John D. Baker


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \

src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.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/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.c:1.6 src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.c:1.6	Fri Feb  7 18:13:33 2020
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.c	Wed Feb 12 22:34:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_nvkm_subdev_pci_base.c,v 1.6 2020/02/07 18:13:33 jmcneill Exp $	*/
+/*	$NetBSD: nouveau_nvkm_subdev_pci_base.c,v 1.7 2020/02/12 22:34:51 jdolecek Exp $	*/
 
 /*
  * Copyright 2015 Red Hat Inc.
@@ -24,7 +24,7 @@
  * Authors: Ben Skeggs 
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_pci_base.c,v 1.6 2020/02/07 18:13:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_pci_base.c,v 1.7 2020/02/12 22:34:51 jdolecek Exp $");
 
 #include "priv.h"
 #include "agp.h"
@@ -141,22 +141,51 @@ nvkm_pci_init(struct nvkm_subdev *subdev
 
 #ifdef __NetBSD__
 {
+	const char *const name = device_xname(pci_dev_dev(pdev));
 	const struct pci_attach_args *pa = >pd_pa;
-	int counts[PCI_INTR_TYPE_SIZE] =  {
-			[PCI_INTR_TYPE_INTX] = 1,
-			[PCI_INTR_TYPE_MSI] = 0,
-			[PCI_INTR_TYPE_MSIX] = 0,
-	};
+	const char *intrstr;
+	char intrbuf[PCI_INTRSTR_LEN];
 
-	/* XXX errno NetBSD->Linux */
-	ret = -pci_intr_alloc(pa, >pci_ihp, counts, PCI_INTR_TYPE_INTX);
-	if (ret)
-		return ret;
+	/* XXX convert to use drm_pci_request_irq() */
+	if (pdev->msi_enabled) {
+		if (pdev->pd_intr_handles == NULL) {
+			if ((ret = pci_msi_alloc_exact(pa, >pci_ihp,
+			1))) {
+aprint_error_dev(pci_dev_dev(pdev),
+"couldn't allocate MSI (%s)\n", name);
+/* XXX errno NetBSD->Linux */
+return -ret;
+			}
+		} else {
+			pci->pci_ihp = pdev->pd_intr_handles;
+			pdev->pd_intr_handles = NULL;
+		}
+	} else {
+		if ((ret = pci_intx_alloc(pa, >pci_ihp))) {
+			aprint_error_dev(pci_dev_dev(pdev),
+			"couldn't allocate INTx interrupt (%s)\n",
+			name);
+
+			/* XXX errno NetBSD->Linux */
+			return -ret;
+		}
+	}
+
+	intrstr = pci_intr_string(pa->pa_pc, pci->pci_ihp[0],
+	intrbuf, sizeof(intrbuf));
 	pci->pci_intrcookie = pci_intr_establish_xname(pa->pa_pc,
 	pci->pci_ihp[0], IPL_DRM, nvkm_pci_intr, pci,
-	device_xname(pci_dev_dev(pdev)));
-	if (pci->pci_intrcookie == NULL)
+	name);
+	if (pci->pci_intrcookie == NULL) {
+		aprint_error_dev(pci_dev_dev(pdev),
+		"couldn't establish interrupt at %s (%s)\n", intrstr, name);
+		pci_intr_release(pa->pa_pc, pci->pci_ihp, 1);
+		pci->pci_ihp = NULL;
 		return -EIO;	/* XXX er? */
+	}
+
+	aprint_normal_dev(pci_dev_dev(pdev), "interrupting at %s (%s)\n",
+	intrstr, name);
 }
 #else
 	ret = request_irq(pdev->irq, nvkm_pci_intr, IRQF_SHARED, "nvkm", pci);



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 22:34:51 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci:
nouveau_nvkm_subdev_pci_base.c

Log Message:
adjust the PCI interrupt allocation code to work the same as
drm_pci_request_irq(), now the driver successfully allocates MSI interrupt

[   3.6619808] nouveau0: info: NVIDIA GK208B (b06070b1)
[   3.7685336] nouveau0: info: bios: version 80.28.78.00.4b
[   3.7785491] nouveau0: interrupting at msi8 vec 0 (nouveau0)

related to PR kern/52440 by John D. Baker


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \

src/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_base.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 20:31:46 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fbcon.c

Log Message:
remove superfluous static variable used only to zero attach args


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.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/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.7 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.8
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.7	Wed Feb 12 20:25:48 2020
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c	Wed Feb 12 20:31:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fbcon.c,v 1.7 2020/02/12 20:25:48 jdolecek Exp $	*/
+/*	$NetBSD: nouveau_fbcon.c,v 1.8 2020/02/12 20:31:46 jdolecek Exp $	*/
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fbcon.c,v 1.7 2020/02/12 20:25:48 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fbcon.c,v 1.8 2020/02/12 20:31:46 jdolecek Exp $");
 
 #include 
 #include 
@@ -434,10 +434,9 @@ nouveau_fbcon_create(struct drm_fb_helpe
 
 	nouveau_fbcon_zfill(dev, fbcon);
 
-{
-	static const struct nouveaufb_attach_args zero_nfa;
-	struct nouveaufb_attach_args nfa = zero_nfa;
+	struct nouveaufb_attach_args nfa;
 
+	memset(, 0, sizeof(nfa));
 	nfa.nfa_fb_helper = helper;
 	nfa.nfa_fb_sizes = *sizes;
 	nfa.nfa_fb_ptr = nvbo_kmap_obj_iovirtual(nvbo);
@@ -448,7 +447,7 @@ nouveau_fbcon_create(struct drm_fb_helpe
 	if (helper->fbdev == NULL) {
 		goto out_unlock;
 	}
-}
+
 	helper->fb = fb;
 
 	return 0;



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 20:31:46 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fbcon.c

Log Message:
remove superfluous static variable used only to zero attach args


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 20:25:48 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fbcon.c

Log Message:
don't consider it error when nouveaufbbus fails to attach, it currently
can happen only not configured into the kernel


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 20:25:48 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fbcon.c

Log Message:
don't consider it error when nouveaufbbus fails to attach, it currently
can happen only not configured into the kernel


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.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/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.6 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.6	Wed Feb 12 20:08:31 2020
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c	Wed Feb 12 20:25:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fbcon.c,v 1.6 2020/02/12 20:08:31 jdolecek Exp $	*/
+/*	$NetBSD: nouveau_fbcon.c,v 1.7 2020/02/12 20:25:48 jdolecek Exp $	*/
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fbcon.c,v 1.6 2020/02/12 20:08:31 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fbcon.c,v 1.7 2020/02/12 20:25:48 jdolecek Exp $");
 
 #include 
 #include 
@@ -356,6 +356,17 @@ nouveau_fbcon_zfill(struct drm_device *d
 #endif
 }
 
+#ifdef __NetBSD__
+static int
+nouveau_fbcon_print(void *aux, const char *pnp)
+{
+	if (pnp)
+		aprint_normal("nouveaufbbus at %s", pnp);
+
+	return (UNCONF);
+}
+#endif
+
 static int
 nouveau_fbcon_create(struct drm_fb_helper *helper,
 		 struct drm_fb_helper_surface_size *sizes)
@@ -432,9 +443,9 @@ nouveau_fbcon_create(struct drm_fb_helpe
 	nfa.nfa_fb_ptr = nvbo_kmap_obj_iovirtual(nvbo);
 	nfa.nfa_fb_linebytes = mode_cmd.pitches[0];
 
-	helper->fbdev = config_found_ia(dev->dev, "nouveaufbbus", , NULL);
+	helper->fbdev = config_found_ia(dev->dev, "nouveaufbbus", ,
+	nouveau_fbcon_print);
 	if (helper->fbdev == NULL) {
-		DRM_ERROR("failed to attach nouveaufb\n");
 		goto out_unlock;
 	}
 }



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

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:24:07 UTC 2020

Modified Files:
src/doc [netbsd-7-0]: CHANGES-7.0.3

Log Message:
Ticket #1722


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.159 -r1.1.2.160 src/doc/CHANGES-7.0.3

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



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

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:24:07 UTC 2020

Modified Files:
src/doc [netbsd-7-0]: CHANGES-7.0.3

Log Message:
Ticket #1722


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.159 -r1.1.2.160 src/doc/CHANGES-7.0.3

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-7.0.3
diff -u src/doc/CHANGES-7.0.3:1.1.2.159 src/doc/CHANGES-7.0.3:1.1.2.160
--- src/doc/CHANGES-7.0.3:1.1.2.159	Thu Jan  2 09:58:20 2020
+++ src/doc/CHANGES-7.0.3	Wed Feb 12 20:24:07 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.159 2020/01/02 09:58:20 martin Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.160 2020/02/12 20:24:07 martin Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -5941,3 +5941,8 @@ sys/conf/copyright1.18
 	Welcome to 2020.
 	[mlelstv, ticket #1719]
 
+external/bsd/ppp/dist/pppd/eap.c		1.5
+
+	pppd: Fix bounds check in EAP code
+	[christos, ticket #1722]
+



CVS commit: [netbsd-7-0] src/external/bsd/ppp/dist/pppd

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:23:39 UTC 2020

Modified Files:
src/external/bsd/ppp/dist/pppd [netbsd-7-0]: eap.c

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

external/bsd/ppp/dist/pppd/eap.c: revision 1.5

pppd: Fix bounds check in EAP code

Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel 

Signed-off-by: Paul Mackerras 

From:
https://github.com/paulusmack/ppp/commit/8d7970b8f3db727fe798b65f3377fe6787575426


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.10.1 src/external/bsd/ppp/dist/pppd/eap.c

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



CVS commit: [netbsd-7-0] src/external/bsd/ppp/dist/pppd

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:23:39 UTC 2020

Modified Files:
src/external/bsd/ppp/dist/pppd [netbsd-7-0]: eap.c

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

external/bsd/ppp/dist/pppd/eap.c: revision 1.5

pppd: Fix bounds check in EAP code

Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel 

Signed-off-by: Paul Mackerras 

From:
https://github.com/paulusmack/ppp/commit/8d7970b8f3db727fe798b65f3377fe6787575426


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.10.1 src/external/bsd/ppp/dist/pppd/eap.c

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

Modified files:

Index: src/external/bsd/ppp/dist/pppd/eap.c
diff -u src/external/bsd/ppp/dist/pppd/eap.c:1.2 src/external/bsd/ppp/dist/pppd/eap.c:1.2.10.1
--- src/external/bsd/ppp/dist/pppd/eap.c:1.2	Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/eap.c	Wed Feb 12 20:23:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eap.c,v 1.2 2013/11/28 22:33:42 christos Exp $	*/
+/*	$NetBSD: eap.c,v 1.2.10.1 2020/02/12 20:23:39 martin Exp $	*/
 /*
  * eap.c - Extensible Authentication Protocol for PPP (RFC 2284)
  *
@@ -49,7 +49,7 @@
 #define RCSID	"Id: eap.c,v 1.4 2004/11/09 22:39:25 paulus Exp "
 static const char rcsid[] = RCSID;
 #else
-__RCSID("$NetBSD: eap.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
+__RCSID("$NetBSD: eap.c,v 1.2.10.1 2020/02/12 20:23:39 martin Exp $");
 #endif
 
 /*
@@ -1433,7 +1433,7 @@ int len;
 		}
 
 		/* Not so likely to happen. */
-		if (vallen >= len + sizeof (rhostname)) {
+		if (len - vallen >= sizeof (rhostname)) {
 			dbglog("EAP: trimming really long peer name down");
 			BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
 			rhostname[sizeof (rhostname) - 1] = '\0';
@@ -1859,7 +1859,7 @@ int len;
 		}
 
 		/* Not so likely to happen. */
-		if (vallen >= len + sizeof (rhostname)) {
+		if (len - vallen >= sizeof (rhostname)) {
 			dbglog("EAP: trimming really long peer name down");
 			BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
 			rhostname[sizeof (rhostname) - 1] = '\0';



CVS commit: [netbsd-7-1] src/external/bsd/ppp/dist/pppd

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:22:07 UTC 2020

Modified Files:
src/external/bsd/ppp/dist/pppd [netbsd-7-1]: eap.c

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

external/bsd/ppp/dist/pppd/eap.c: revision 1.5

pppd: Fix bounds check in EAP code

Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel 

Signed-off-by: Paul Mackerras 

From:
https://github.com/paulusmack/ppp/commit/8d7970b8f3db727fe798b65f3377fe6787575426


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.14.1 src/external/bsd/ppp/dist/pppd/eap.c

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

Modified files:

Index: src/external/bsd/ppp/dist/pppd/eap.c
diff -u src/external/bsd/ppp/dist/pppd/eap.c:1.2 src/external/bsd/ppp/dist/pppd/eap.c:1.2.14.1
--- src/external/bsd/ppp/dist/pppd/eap.c:1.2	Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/eap.c	Wed Feb 12 20:22:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eap.c,v 1.2 2013/11/28 22:33:42 christos Exp $	*/
+/*	$NetBSD: eap.c,v 1.2.14.1 2020/02/12 20:22:07 martin Exp $	*/
 /*
  * eap.c - Extensible Authentication Protocol for PPP (RFC 2284)
  *
@@ -49,7 +49,7 @@
 #define RCSID	"Id: eap.c,v 1.4 2004/11/09 22:39:25 paulus Exp "
 static const char rcsid[] = RCSID;
 #else
-__RCSID("$NetBSD: eap.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
+__RCSID("$NetBSD: eap.c,v 1.2.14.1 2020/02/12 20:22:07 martin Exp $");
 #endif
 
 /*
@@ -1433,7 +1433,7 @@ int len;
 		}
 
 		/* Not so likely to happen. */
-		if (vallen >= len + sizeof (rhostname)) {
+		if (len - vallen >= sizeof (rhostname)) {
 			dbglog("EAP: trimming really long peer name down");
 			BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
 			rhostname[sizeof (rhostname) - 1] = '\0';
@@ -1859,7 +1859,7 @@ int len;
 		}
 
 		/* Not so likely to happen. */
-		if (vallen >= len + sizeof (rhostname)) {
+		if (len - vallen >= sizeof (rhostname)) {
 			dbglog("EAP: trimming really long peer name down");
 			BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
 			rhostname[sizeof (rhostname) - 1] = '\0';



CVS commit: src/sys/external/bsd/drm2/dist/drm/ttm

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 20:22:37 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/ttm: ttm_bo.c

Log Message:
mark case fallthrough to avoid warning


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c

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



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

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:22:35 UTC 2020

Modified Files:
src/doc [netbsd-7-1]: CHANGES-7.1.3

Log Message:
Ticket #1722


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.67 -r1.1.2.68 src/doc/CHANGES-7.1.3

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-7.1.3
diff -u src/doc/CHANGES-7.1.3:1.1.2.67 src/doc/CHANGES-7.1.3:1.1.2.68
--- src/doc/CHANGES-7.1.3:1.1.2.67	Tue Jan 21 19:24:10 2020
+++ src/doc/CHANGES-7.1.3	Wed Feb 12 20:22:35 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.3,v 1.1.2.67 2020/01/21 19:24:10 martin Exp $
+# $NetBSD: CHANGES-7.1.3,v 1.1.2.68 2020/02/12 20:22:35 martin Exp $
 
 A complete list of changes from the NetBSD 7.1.2 release to the NetBSD 7.1.3
 release:
@@ -666,3 +666,8 @@ sys/sys/shm.h		1.54 (patch)
 	subsystems. 
 	[christos, ticket #1720]
 
+external/bsd/ppp/dist/pppd/eap.c		1.5
+
+	pppd: Fix bounds check in EAP code
+	[christos, ticket #1722]
+



CVS commit: [netbsd-7-1] src/external/bsd/ppp/dist/pppd

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:22:07 UTC 2020

Modified Files:
src/external/bsd/ppp/dist/pppd [netbsd-7-1]: eap.c

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

external/bsd/ppp/dist/pppd/eap.c: revision 1.5

pppd: Fix bounds check in EAP code

Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel 

Signed-off-by: Paul Mackerras 

From:
https://github.com/paulusmack/ppp/commit/8d7970b8f3db727fe798b65f3377fe6787575426


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.14.1 src/external/bsd/ppp/dist/pppd/eap.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/ttm

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 20:22:37 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/ttm: ttm_bo.c

Log Message:
mark case fallthrough to avoid warning


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.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/external/bsd/drm2/dist/drm/ttm/ttm_bo.c
diff -u src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c:1.15 src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c:1.16
--- src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c:1.15	Sat Feb  2 21:46:27 2019
+++ src/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c	Wed Feb 12 20:22:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ttm_bo.c,v 1.15 2019/02/02 21:46:27 mrg Exp $	*/
+/*	$NetBSD: ttm_bo.c,v 1.16 2020/02/12 20:22:37 jdolecek Exp $	*/
 
 /**
  *
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ttm_bo.c,v 1.15 2019/02/02 21:46:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttm_bo.c,v 1.16 2020/02/12 20:22:37 jdolecek Exp $");
 
 #define pr_fmt(fmt) "[TTM] " fmt
 
@@ -273,6 +273,7 @@ static int ttm_bo_add_ttm(struct ttm_buf
 	case ttm_bo_type_device:
 		if (zero_alloc)
 			page_flags |= TTM_PAGE_FLAG_ZERO_ALLOC;
+		/* FALLTHROUGH */
 	case ttm_bo_type_kernel:
 		bo->ttm = bdev->driver->ttm_tt_create(bdev, bo->num_pages << PAGE_SHIFT,
 		  page_flags, glob->dummy_read_page);



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

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:22:35 UTC 2020

Modified Files:
src/doc [netbsd-7-1]: CHANGES-7.1.3

Log Message:
Ticket #1722


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.67 -r1.1.2.68 src/doc/CHANGES-7.1.3

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



CVS commit: [netbsd-7] src/doc

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:21:12 UTC 2020

Modified Files:
src/doc [netbsd-7]: CHANGES-7.3

Log Message:
Tickets #1721 and #1722


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.75 -r1.1.2.76 src/doc/CHANGES-7.3

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-7.3
diff -u src/doc/CHANGES-7.3:1.1.2.75 src/doc/CHANGES-7.3:1.1.2.76
--- src/doc/CHANGES-7.3:1.1.2.75	Tue Jan 21 19:21:14 2020
+++ src/doc/CHANGES-7.3	Wed Feb 12 20:21:12 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.3,v 1.1.2.75 2020/01/21 19:21:14 martin Exp $
+# $NetBSD: CHANGES-7.3,v 1.1.2.76 2020/02/12 20:21:12 martin Exp $
 
 A complete list of changes from the NetBSD 7.2 release to the NetBSD 7.3
 release:
@@ -792,3 +792,13 @@ sys/sys/shm.h		1.54 (patch)
 	subsystems. 
 	[christos, ticket #1720]
 
+sys/arch/mac68k/nubus/grf_nubus.c		1.78
+
+	Set sc_dev field of softc.
+	[tsutsui, ticket #1721]
+
+external/bsd/ppp/dist/pppd/eap.c		1.5
+
+	pppd: Fix bounds check in EAP code
+	[christos, ticket #1722]
+



CVS commit: [netbsd-7] src/doc

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:21:12 UTC 2020

Modified Files:
src/doc [netbsd-7]: CHANGES-7.3

Log Message:
Tickets #1721 and #1722


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.75 -r1.1.2.76 src/doc/CHANGES-7.3

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



CVS commit: [netbsd-7] src/external/bsd/ppp/dist/pppd

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:19:10 UTC 2020

Modified Files:
src/external/bsd/ppp/dist/pppd [netbsd-7]: eap.c

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

external/bsd/ppp/dist/pppd/eap.c: revision 1.5

pppd: Fix bounds check in EAP code

Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel 

Signed-off-by: Paul Mackerras 

From:
https://github.com/paulusmack/ppp/commit/8d7970b8f3db727fe798b65f3377fe6787575426


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.6.1 src/external/bsd/ppp/dist/pppd/eap.c

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



CVS commit: [netbsd-7] src/external/bsd/ppp/dist/pppd

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:19:10 UTC 2020

Modified Files:
src/external/bsd/ppp/dist/pppd [netbsd-7]: eap.c

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

external/bsd/ppp/dist/pppd/eap.c: revision 1.5

pppd: Fix bounds check in EAP code

Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel 

Signed-off-by: Paul Mackerras 

From:
https://github.com/paulusmack/ppp/commit/8d7970b8f3db727fe798b65f3377fe6787575426


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.6.1 src/external/bsd/ppp/dist/pppd/eap.c

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

Modified files:

Index: src/external/bsd/ppp/dist/pppd/eap.c
diff -u src/external/bsd/ppp/dist/pppd/eap.c:1.2 src/external/bsd/ppp/dist/pppd/eap.c:1.2.6.1
--- src/external/bsd/ppp/dist/pppd/eap.c:1.2	Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/eap.c	Wed Feb 12 20:19:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eap.c,v 1.2 2013/11/28 22:33:42 christos Exp $	*/
+/*	$NetBSD: eap.c,v 1.2.6.1 2020/02/12 20:19:10 martin Exp $	*/
 /*
  * eap.c - Extensible Authentication Protocol for PPP (RFC 2284)
  *
@@ -49,7 +49,7 @@
 #define RCSID	"Id: eap.c,v 1.4 2004/11/09 22:39:25 paulus Exp "
 static const char rcsid[] = RCSID;
 #else
-__RCSID("$NetBSD: eap.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
+__RCSID("$NetBSD: eap.c,v 1.2.6.1 2020/02/12 20:19:10 martin Exp $");
 #endif
 
 /*
@@ -1433,7 +1433,7 @@ int len;
 		}
 
 		/* Not so likely to happen. */
-		if (vallen >= len + sizeof (rhostname)) {
+		if (len - vallen >= sizeof (rhostname)) {
 			dbglog("EAP: trimming really long peer name down");
 			BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
 			rhostname[sizeof (rhostname) - 1] = '\0';
@@ -1859,7 +1859,7 @@ int len;
 		}
 
 		/* Not so likely to happen. */
-		if (vallen >= len + sizeof (rhostname)) {
+		if (len - vallen >= sizeof (rhostname)) {
 			dbglog("EAP: trimming really long peer name down");
 			BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
 			rhostname[sizeof (rhostname) - 1] = '\0';



CVS commit: [netbsd-7] src/sys/arch/mac68k/nubus

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:17:14 UTC 2020

Modified Files:
src/sys/arch/mac68k/nubus [netbsd-7]: grf_nubus.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1721):

sys/arch/mac68k/nubus/grf_nubus.c: revision 1.78

Set sc_dev field of softc.
Should pullup to 7.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.77.4.1 src/sys/arch/mac68k/nubus/grf_nubus.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/mac68k/nubus/grf_nubus.c
diff -u src/sys/arch/mac68k/nubus/grf_nubus.c:1.77 src/sys/arch/mac68k/nubus/grf_nubus.c:1.77.4.1
--- src/sys/arch/mac68k/nubus/grf_nubus.c:1.77	Fri Oct 25 21:42:30 2013
+++ src/sys/arch/mac68k/nubus/grf_nubus.c	Wed Feb 12 20:17:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: grf_nubus.c,v 1.77 2013/10/25 21:42:30 martin Exp $	*/
+/*	$NetBSD: grf_nubus.c,v 1.77.4.1 2020/02/12 20:17:14 martin Exp $	*/
 
 /*
  * Copyright (c) 1995 Allen Briggs.  All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: grf_nubus.c,v 1.77 2013/10/25 21:42:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grf_nubus.c,v 1.77.4.1 2020/02/12 20:17:14 martin Exp $");
 
 #include 
 
@@ -143,6 +143,7 @@ grfmv_attach(device_t parent, device_t s
 
 	memcpy(>sc_slot, na->fmt, sizeof(nubus_slot));
 
+	sc->sc_dev = self;
 	sc->sc_tag = na->na_tag;
 	sc->card_id = na->drhw;
 	sc->sc_basepa = (bus_addr_t)NUBUS_SLOT2PA(na->slot);



CVS commit: [netbsd-8] src/external/bsd/ppp/dist/pppd

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:13:57 UTC 2020

Modified Files:
src/external/bsd/ppp/dist/pppd [netbsd-8]: eap.c

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

external/bsd/ppp/dist/pppd/eap.c: revision 1.5

pppd: Fix bounds check in EAP code

Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel 

Signed-off-by: Paul Mackerras 

From:
https://github.com/paulusmack/ppp/commit/8d7970b8f3db727fe798b65f3377fe6787575426


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.8.1 src/external/bsd/ppp/dist/pppd/eap.c

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



CVS commit: [netbsd-9] src/doc

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:11:33 UTC 2020

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

Log Message:
Tickets #697 - #705


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

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



CVS commit: [netbsd-7] src/sys/arch/mac68k/nubus

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:17:14 UTC 2020

Modified Files:
src/sys/arch/mac68k/nubus [netbsd-7]: grf_nubus.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1721):

sys/arch/mac68k/nubus/grf_nubus.c: revision 1.78

Set sc_dev field of softc.
Should pullup to 7.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.77.4.1 src/sys/arch/mac68k/nubus/grf_nubus.c

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



CVS commit: [netbsd-8] src/doc

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:15:04 UTC 2020

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

Log Message:
Ticket #1503


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

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



CVS commit: [netbsd-8] src/doc

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:15:04 UTC 2020

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

Log Message:
Ticket #1503


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

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

Modified files:

Index: src/doc/CHANGES-8.2
diff -u src/doc/CHANGES-8.2:1.1.2.96 src/doc/CHANGES-8.2:1.1.2.97
--- src/doc/CHANGES-8.2:1.1.2.96	Tue Feb 11 11:40:09 2020
+++ src/doc/CHANGES-8.2	Wed Feb 12 20:15:04 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.2,v 1.1.2.96 2020/02/11 11:40:09 martin Exp $
+# $NetBSD: CHANGES-8.2,v 1.1.2.97 2020/02/12 20:15:04 martin Exp $
 
 A complete list of changes from the NetBSD 8.1 release to the NetBSD 8.2
 release:
@@ -2031,3 +2031,8 @@ sys/arch/i386/stand/efiboot/eficons.c		1
 	Use 1024x768 as the default GOP mode.
 	[jmcneill, ticket #1502]
 
+external/bsd/ppp/dist/pppd/eap.c		1.5
+
+	pppd: Fix bounds check in EAP code.
+	[christos, ticket #1503]
+



CVS commit: [netbsd-8] src/external/bsd/ppp/dist/pppd

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:13:57 UTC 2020

Modified Files:
src/external/bsd/ppp/dist/pppd [netbsd-8]: eap.c

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

external/bsd/ppp/dist/pppd/eap.c: revision 1.5

pppd: Fix bounds check in EAP code

Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel 

Signed-off-by: Paul Mackerras 

From:
https://github.com/paulusmack/ppp/commit/8d7970b8f3db727fe798b65f3377fe6787575426


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.8.1 src/external/bsd/ppp/dist/pppd/eap.c

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

Modified files:

Index: src/external/bsd/ppp/dist/pppd/eap.c
diff -u src/external/bsd/ppp/dist/pppd/eap.c:1.4 src/external/bsd/ppp/dist/pppd/eap.c:1.4.8.1
--- src/external/bsd/ppp/dist/pppd/eap.c:1.4	Sat Oct 25 21:11:37 2014
+++ src/external/bsd/ppp/dist/pppd/eap.c	Wed Feb 12 20:13:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eap.c,v 1.4 2014/10/25 21:11:37 christos Exp $	*/
+/*	$NetBSD: eap.c,v 1.4.8.1 2020/02/12 20:13:57 martin Exp $	*/
 /*
  * eap.c - Extensible Authentication Protocol for PPP (RFC 2284)
  *
@@ -49,7 +49,7 @@
 #define RCSID	"Id: eap.c,v 1.4 2004/11/09 22:39:25 paulus Exp "
 static const char rcsid[] = RCSID;
 #else
-__RCSID("$NetBSD: eap.c,v 1.4 2014/10/25 21:11:37 christos Exp $");
+__RCSID("$NetBSD: eap.c,v 1.4.8.1 2020/02/12 20:13:57 martin Exp $");
 #endif
 
 /*
@@ -1433,7 +1433,7 @@ int len;
 		}
 
 		/* Not so likely to happen. */
-		if (vallen >= len + sizeof (rhostname)) {
+		if (len - vallen >= sizeof (rhostname)) {
 			dbglog("EAP: trimming really long peer name down");
 			BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
 			rhostname[sizeof (rhostname) - 1] = '\0';
@@ -1859,7 +1859,7 @@ int len;
 		}
 
 		/* Not so likely to happen. */
-		if (vallen >= len + sizeof (rhostname)) {
+		if (len - vallen >= sizeof (rhostname)) {
 			dbglog("EAP: trimming really long peer name down");
 			BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
 			rhostname[sizeof (rhostname) - 1] = '\0';



CVS commit: [netbsd-9] src/doc

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:11:33 UTC 2020

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

Log Message:
Tickets #697 - #705


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

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

Modified files:

Index: src/doc/CHANGES-9.0
diff -u src/doc/CHANGES-9.0:1.1.2.177 src/doc/CHANGES-9.0:1.1.2.178
--- src/doc/CHANGES-9.0:1.1.2.177	Tue Feb 11 11:38:05 2020
+++ src/doc/CHANGES-9.0	Wed Feb 12 20:11:33 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.0,v 1.1.2.177 2020/02/11 11:38:05 martin Exp $
+# $NetBSD: CHANGES-9.0,v 1.1.2.178 2020/02/12 20:11:33 martin Exp $
 
 A complete list of changes from the initial NetBSD 9.0 branch on 2019-07-30
 until the 9.0 release:
@@ -8794,3 +8794,76 @@ sys/arch/i386/stand/efiboot/eficons.c		1
 	Use 1024x768 as the default GOP mode.
 	[jmcneill, ticket #696]
 
+sys/kern/kern_lwp.c1.224,1.225
+
+	Preserve pcu(9) state in fork.
+	[maya, ticket #697]
+
+external/bsd/ppp/dist/pppd/eap.c		1.5
+
+	pppd: Fix bounds check in EAP code.
+	[christos, ticket #698]
+
+sys/net/npf/npf_ruleset.c			1.50
+
+	PR 54950: Lloyd Parkes: Avoid NULL deref.
+	[christos, ticket #699]
+
+share/man/man5/fstab.51.45
+
+	fstab.5: add mention of zfs
+	[christos, ticket #700]
+
+external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c 1.2
+external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c 1.2,1.3
+external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c	1.2-1.6
+external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h 1.9
+external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c 1.18
+external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c 1.17
+sys/arch/aarch64/aarch64/vectors.S		1.10
+sys/arch/aarch64/include/cpu.h			1.20
+sys/modules/cyclic/Makefile			1.5
+
+	Fix dtrace(1) for aarch64:
+	- Reserve stack space on trap to emulate function prologue.
+	- Fix memory protection in fbt function patching.
+	- Fix dtrace stack traces and implement argument references.
+	- Allow dtrace to read direct-mapped addresses.
+	- Forbid dtrace from reading I/O-mapped addresses.
+	- Fix cpu_number() in modules on aarch64.
+	- Fix build fallout from cpu_number() change.
+	- [MI] Use /dev/ksyms, not /netbsd, to get running kernel's symbols.
+	[riastradh, ticket #701]
+
+sys/miscfs/kernfs/kernfs.h			1.43
+sys/miscfs/kernfs/kernfs_vfsops.c		1.98
+sys/miscfs/kernfs/kernfs_vnops.c		1.163
+
+	Fix various kernfs issues.
+	[riastradh, ticket #702]
+
+sys/external/bsd/common/linux/linux_work.c	1.45
+
+	Fix abuse of TAILQ_CONCAT.
+	[riastradh, ticket #703]
+
+sys/dev/usb/uatp.c1.20-1.23
+
+	Fix uatp(4) on some Apple iBooks and PowerBooks.
+	[riastradh, ticket #704]
+
+sys/arch/aarch64/aarch64/aarch64_machdep.c	1.35
+sys/arch/aarch64/include/machdep.h		1.9
+sys/arch/arm/arm32/arm32_machdep.c		1.129
+sys/arch/arm/include/arm32/machdep.h		1.30
+sys/arch/evbarm/fdt/fdt_machdep.c		1.65
+sys/stand/efiboot/boot.c			1.19
+sys/stand/efiboot/efiboot.h			1.11
+sys/stand/efiboot/efifdt.c			1.20
+sys/stand/efiboot/efifdt.h			1.7
+sys/stand/efiboot/exec.c			1.12
+sys/stand/efiboot/version			1.14
+
+	Support random seed loading from efiboot.
+	[riastradh, ticket #705]
+



CVS commit: [netbsd-9] src/sys

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:10:10 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: aarch64_machdep.c
src/sys/arch/aarch64/include [netbsd-9]: machdep.h
src/sys/arch/arm/arm32 [netbsd-9]: arm32_machdep.c
src/sys/arch/arm/include/arm32 [netbsd-9]: machdep.h
src/sys/arch/evbarm/fdt [netbsd-9]: fdt_machdep.c
src/sys/stand/efiboot [netbsd-9]: boot.c efiboot.h efifdt.c efifdt.h
exec.c version

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

sys/arch/aarch64/aarch64/aarch64_machdep.c: revision 1.35
sys/stand/efiboot/efifdt.c: revision 1.20
sys/stand/efiboot/efifdt.h: revision 1.7
sys/arch/aarch64/include/machdep.h: revision 1.9
sys/stand/efiboot/efiboot.h: revision 1.11
sys/arch/arm/arm32/arm32_machdep.c: revision 1.129
sys/arch/arm/include/arm32/machdep.h: revision 1.30
sys/stand/efiboot/exec.c: revision 1.12
sys/arch/evbarm/fdt/fdt_machdep.c: revision 1.65
sys/stand/efiboot/version: revision 1.14
sys/stand/efiboot/boot.c: revision 1.19

New function cpu_startup_hook on arm.

Called at end of cpu_startup.  Can be defined in, e.g., evbarm to do
additional stuff after cpu_startup.  Defined as a weak alias to a
function that does nothing, so optional.
ok jmcneill

Implement rndseed support in efiboot and fdt arm.

The EFI environment variable `rndseed' specifies the path to the
random seed.  It is loaded only for fdt platforms at the moment.
Since the rndseed (an rndsave_t object as defined in )
is 536 bytes long (for hysterical raisins), and to avoid having to
erase parts of the fdt tree, we load it into a physical page whose
address is passed in the fdt tree, rather than passing the content of
the file as an fdt node directly; the kernel then reserves the page
from uvm, and maps it into kva to call rnd_seed.

For now, the only kernel that does use efiboot with fdt is evbarm,
which knows to handle the rndseed.  Any new kernels that use efiboot
with fdt must do the same; otherwise uvm may hand out the page with
the secret key on it for a normal page allocation in the kernel --
which should be OK if there are no kernel memory disclosure bugs, but
would lead to worse consequences than simply loading the seed late in
userland with /etc/rc.d/random_seed otherwise.

ok jmcneill


To generate a diff of this commit:
cvs rdiff -u -r1.28.4.2 -r1.28.4.3 \
src/sys/arch/aarch64/aarch64/aarch64_machdep.c
cvs rdiff -u -r1.8 -r1.8.2.1 src/sys/arch/aarch64/include/machdep.h
cvs rdiff -u -r1.128 -r1.128.2.1 src/sys/arch/arm/arm32/arm32_machdep.c
cvs rdiff -u -r1.29 -r1.29.2.1 src/sys/arch/arm/include/arm32/machdep.h
cvs rdiff -u -r1.64 -r1.64.2.1 src/sys/arch/evbarm/fdt/fdt_machdep.c
cvs rdiff -u -r1.18.4.1 -r1.18.4.2 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.17.2.2 -r1.17.2.3 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.6 -r1.6.2.1 src/sys/stand/efiboot/efifdt.h
cvs rdiff -u -r1.11.2.1 -r1.11.2.2 src/sys/stand/efiboot/exec.c
cvs rdiff -u -r1.11.2.2 -r1.11.2.3 src/sys/stand/efiboot/version

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



CVS commit: [netbsd-9] src/sys

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:10:10 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: aarch64_machdep.c
src/sys/arch/aarch64/include [netbsd-9]: machdep.h
src/sys/arch/arm/arm32 [netbsd-9]: arm32_machdep.c
src/sys/arch/arm/include/arm32 [netbsd-9]: machdep.h
src/sys/arch/evbarm/fdt [netbsd-9]: fdt_machdep.c
src/sys/stand/efiboot [netbsd-9]: boot.c efiboot.h efifdt.c efifdt.h
exec.c version

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

sys/arch/aarch64/aarch64/aarch64_machdep.c: revision 1.35
sys/stand/efiboot/efifdt.c: revision 1.20
sys/stand/efiboot/efifdt.h: revision 1.7
sys/arch/aarch64/include/machdep.h: revision 1.9
sys/stand/efiboot/efiboot.h: revision 1.11
sys/arch/arm/arm32/arm32_machdep.c: revision 1.129
sys/arch/arm/include/arm32/machdep.h: revision 1.30
sys/stand/efiboot/exec.c: revision 1.12
sys/arch/evbarm/fdt/fdt_machdep.c: revision 1.65
sys/stand/efiboot/version: revision 1.14
sys/stand/efiboot/boot.c: revision 1.19

New function cpu_startup_hook on arm.

Called at end of cpu_startup.  Can be defined in, e.g., evbarm to do
additional stuff after cpu_startup.  Defined as a weak alias to a
function that does nothing, so optional.
ok jmcneill

Implement rndseed support in efiboot and fdt arm.

The EFI environment variable `rndseed' specifies the path to the
random seed.  It is loaded only for fdt platforms at the moment.
Since the rndseed (an rndsave_t object as defined in )
is 536 bytes long (for hysterical raisins), and to avoid having to
erase parts of the fdt tree, we load it into a physical page whose
address is passed in the fdt tree, rather than passing the content of
the file as an fdt node directly; the kernel then reserves the page
from uvm, and maps it into kva to call rnd_seed.

For now, the only kernel that does use efiboot with fdt is evbarm,
which knows to handle the rndseed.  Any new kernels that use efiboot
with fdt must do the same; otherwise uvm may hand out the page with
the secret key on it for a normal page allocation in the kernel --
which should be OK if there are no kernel memory disclosure bugs, but
would lead to worse consequences than simply loading the seed late in
userland with /etc/rc.d/random_seed otherwise.

ok jmcneill


To generate a diff of this commit:
cvs rdiff -u -r1.28.4.2 -r1.28.4.3 \
src/sys/arch/aarch64/aarch64/aarch64_machdep.c
cvs rdiff -u -r1.8 -r1.8.2.1 src/sys/arch/aarch64/include/machdep.h
cvs rdiff -u -r1.128 -r1.128.2.1 src/sys/arch/arm/arm32/arm32_machdep.c
cvs rdiff -u -r1.29 -r1.29.2.1 src/sys/arch/arm/include/arm32/machdep.h
cvs rdiff -u -r1.64 -r1.64.2.1 src/sys/arch/evbarm/fdt/fdt_machdep.c
cvs rdiff -u -r1.18.4.1 -r1.18.4.2 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.17.2.2 -r1.17.2.3 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.6 -r1.6.2.1 src/sys/stand/efiboot/efifdt.h
cvs rdiff -u -r1.11.2.1 -r1.11.2.2 src/sys/stand/efiboot/exec.c
cvs rdiff -u -r1.11.2.2 -r1.11.2.3 src/sys/stand/efiboot/version

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.28.4.2 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.28.4.3
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.28.4.2	Tue Jan 21 11:11:00 2020
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Wed Feb 12 20:10:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.28.4.2 2020/01/21 11:11:00 martin Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.28.4.3 2020/02/12 20:10:09 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.28.4.2 2020/01/21 11:11:00 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.28.4.3 2020/02/12 20:10:09 martin Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -599,6 +599,14 @@ cpu_startup(void)
 
 	/* Hello! */
 	banner();
+
+	cpu_startup_hook();
+}
+
+__weak_alias(cpu_startup_hook,cpu_startup_default)
+void
+cpu_startup_default(void)
+{
 }
 
 /*

Index: src/sys/arch/aarch64/include/machdep.h
diff -u src/sys/arch/aarch64/include/machdep.h:1.8 src/sys/arch/aarch64/include/machdep.h:1.8.2.1
--- src/sys/arch/aarch64/include/machdep.h:1.8	Tue Jul 16 16:18:56 2019
+++ src/sys/arch/aarch64/include/machdep.h	Wed Feb 12 20:10:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.h,v 1.8 2019/07/16 16:18:56 skrll Exp $	*/
+/*	$NetBSD: machdep.h,v 1.8.2.1 2020/02/12 20:10:09 martin Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -83,6 +83,9 @@ void uartputc(int);
 void parse_mi_bootargs(char *);
 void dumpsys(void);
 
+void 

CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 20:08:32 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fbcon.c

Log Message:
fix error path when nouveaufb fails to attach (such as when it's not
actually configured into the kernel), the gem was not released
properly leading to:
panic: LOCKDEBUG: Reader / writer lock error: kmem_intr_free,289: allocation 
contains active lock


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 20:08:32 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fbcon.c

Log Message:
fix error path when nouveaufb fails to attach (such as when it's not
actually configured into the kernel), the gem was not released
properly leading to:
panic: LOCKDEBUG: Reader / writer lock error: kmem_intr_free,289: allocation 
contains active lock


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.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/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.5 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.5	Mon Aug 27 07:57:34 2018
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c	Wed Feb 12 20:08:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fbcon.c,v 1.5 2018/08/27 07:57:34 riastradh Exp $	*/
+/*	$NetBSD: nouveau_fbcon.c,v 1.6 2020/02/12 20:08:31 jdolecek Exp $	*/
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fbcon.c,v 1.5 2018/08/27 07:57:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fbcon.c,v 1.6 2020/02/12 20:08:31 jdolecek Exp $");
 
 #include 
 #include 
@@ -507,7 +507,7 @@ out_unlock:
 out_unpin:
 	nouveau_bo_unpin(nvbo);
 out_unref:
-	nouveau_bo_ref(NULL, );
+	nouveau_gem_object_del(>gem);
 out:
 	return ret;
 }



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

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:05:58 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-9]: uatp.c

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

sys/dev/usb/uatp.c: revision 1.20
sys/dev/usb/uatp.c: revision 1.21
sys/dev/usb/uatp.c: revision 1.22
sys/dev/usb/uatp.c: revision 1.23

Work around quirk of Fountain and Geyser 1 trackpads.

Sometimes they get desynchronized, but we know the last packet is a
17-byte packet, so if we get one early then stop here.

Tested by macallan on an iBook and a PowerBook.  This code path
shouldn't break anything on MacBooks because they have different
total numbers of sensors so this branch won't be reached.

Downgrade noisy message from aprint_verbose to DPRINTF.

Unconditionally enable UATP_DEBUG.

Use __BIT.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.4.1 src/sys/dev/usb/uatp.c

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

Modified files:

Index: src/sys/dev/usb/uatp.c
diff -u src/sys/dev/usb/uatp.c:1.19 src/sys/dev/usb/uatp.c:1.19.4.1
--- src/sys/dev/usb/uatp.c:1.19	Tue Jan 22 06:47:20 2019
+++ src/sys/dev/usb/uatp.c	Wed Feb 12 20:05:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uatp.c,v 1.19 2019/01/22 06:47:20 skrll Exp $	*/
+/*	$NetBSD: uatp.c,v 1.19.4.1 2020/02/12 20:05:58 martin Exp $	*/
 
 /*-
  * Copyright (c) 2011-2014 The NetBSD Foundation, Inc.
@@ -146,7 +146,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uatp.c,v 1.19 2019/01/22 06:47:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uatp.c,v 1.19.4.1 2020/02/12 20:05:58 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -184,22 +184,29 @@ __KERNEL_RCSID(0, "$NetBSD: uatp.c,v 1.1
 	}\
 } while (0)
 
-#define UATP_DEBUG_ATTACH	(1 << 0)
-#define UATP_DEBUG_MISC		(1 << 1)
-#define UATP_DEBUG_WSMOUSE	(1 << 2)
-#define UATP_DEBUG_IOCTL	(1 << 3)
-#define UATP_DEBUG_RESET	(1 << 4)
-#define UATP_DEBUG_INTR		(1 << 5)
-#define UATP_DEBUG_PARSE	(1 << 6)
-#define UATP_DEBUG_TAP		(1 << 7)
-#define UATP_DEBUG_EMUL_BUTTON	(1 << 8)
-#define UATP_DEBUG_ACCUMULATE	(1 << 9)
-#define UATP_DEBUG_STATUS	(1 << 10)
-#define UATP_DEBUG_SPURINTR	(1 << 11)
-#define UATP_DEBUG_MOVE		(1 << 12)
-#define UATP_DEBUG_ACCEL	(1 << 13)
-#define UATP_DEBUG_TRACK_DIST	(1 << 14)
-#define UATP_DEBUG_PALM		(1 << 15)
+#define UATP_DEBUG_ATTACH	__BIT(0)
+#define UATP_DEBUG_MISC		__BIT(1)
+#define UATP_DEBUG_WSMOUSE	__BIT(2)
+#define UATP_DEBUG_IOCTL	__BIT(3)
+#define UATP_DEBUG_RESET	__BIT(4)
+#define UATP_DEBUG_INTR		__BIT(5)
+#define UATP_DEBUG_PARSE	__BIT(6)
+#define UATP_DEBUG_TAP		__BIT(7)
+#define UATP_DEBUG_EMUL_BUTTON	__BIT(8)
+#define UATP_DEBUG_ACCUMULATE	__BIT(9)
+#define UATP_DEBUG_STATUS	__BIT(10)
+#define UATP_DEBUG_SPURINTR	__BIT(11)
+#define UATP_DEBUG_MOVE		__BIT(12)
+#define UATP_DEBUG_ACCEL	__BIT(13)
+#define UATP_DEBUG_TRACK_DIST	__BIT(14)
+#define UATP_DEBUG_PALM		__BIT(15)
+
+/*
+ * Unconditionally enable the debug output so you don't have to
+ * recompile the kernel to diagnose it.  This is not a high-throughput
+ * NIC driver or anything that will be hurt by a few conditionals.
+ */
+#define	UATP_DEBUG	1
 
 #if UATP_DEBUG
 #  define DPRINTF(sc, flags, format) do {\
@@ -239,9 +246,9 @@ __KERNEL_RCSID(0, "$NetBSD: uatp.c,v 1.1
 #define UATP_MAX_MOTION_MULTIPLIER	16
 
 /* Status bits transmitted in the last byte of an input packet.  */
-#define UATP_STATUS_BUTTON	(1 << 0)	/* Button pressed */
-#define UATP_STATUS_BASE	(1 << 2)	/* Base sensor data */
-#define UATP_STATUS_POST_RESET	(1 << 4)	/* Post-reset */
+#define UATP_STATUS_BUTTON	__BIT(0)	/* Button pressed */
+#define UATP_STATUS_BASE	__BIT(2)	/* Base sensor data */
+#define UATP_STATUS_POST_RESET	__BIT(4)	/* Post-reset */
 
 /* Forward declarations */
 
@@ -507,9 +514,9 @@ struct uatp_softc {
 	unsigned int sc_track_distance;	/* Distance^2 finger has tracked,
 	 * squared to avoid sqrt in kernel.  */
 	uint32_t sc_status;		/* Status flags:  */
-#define UATP_ENABLED	(1 << 0)	/* . Is the wsmouse enabled?  */
-#define UATP_DYING	(1 << 1)	/* . Have we been deactivated?  */
-#define UATP_VALID	(1 << 2)	/* . Do we have valid sensor data?  */
+#define UATP_ENABLED	__BIT(0)	/* . Is the wsmouse enabled?  */
+#define UATP_DYING	__BIT(1)	/* . Have we been deactivated?  */
+#define UATP_VALID	__BIT(2)	/* . Do we have valid sensor data?  */
 	struct usb_task sc_reset_task;	/* Task for resetting device.  */
 
 	callout_t sc_untap_callout;	/* Releases button after tap.  */
@@ -1416,6 +1423,19 @@ uatp_intr(struct uhidev *addr, void *ibu
 		(sc->sc_input_index + len));
 		sc->sc_input_index = 0;
 		return;
+	} else if (sc->sc_input_size == 81 && len == 17 &&
+	sc->sc_input_index != 64) {
+		/*
+		 * Quirk of Fountain and Geyser 1 devices: a 17-byte
+		 * packet seems to mean the last one, but sometimes we
+		 * get desynchronized, so drop this one and start 

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

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:05:58 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-9]: uatp.c

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

sys/dev/usb/uatp.c: revision 1.20
sys/dev/usb/uatp.c: revision 1.21
sys/dev/usb/uatp.c: revision 1.22
sys/dev/usb/uatp.c: revision 1.23

Work around quirk of Fountain and Geyser 1 trackpads.

Sometimes they get desynchronized, but we know the last packet is a
17-byte packet, so if we get one early then stop here.

Tested by macallan on an iBook and a PowerBook.  This code path
shouldn't break anything on MacBooks because they have different
total numbers of sensors so this branch won't be reached.

Downgrade noisy message from aprint_verbose to DPRINTF.

Unconditionally enable UATP_DEBUG.

Use __BIT.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.4.1 src/sys/dev/usb/uatp.c

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



CVS commit: [netbsd-9] src/sys/external/bsd/common/linux

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:02:20 UTC 2020

Modified Files:
src/sys/external/bsd/common/linux [netbsd-9]: linux_work.c

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

sys/external/bsd/common/linux/linux_work.c: revision 1.45

Fix abuse of TAILQ_CONCAT.

Other parts of this expect that the entries will be on wq->wq_queue
or wq->wq_dqueue, so we can't just move a batch of entries onto a
temporary queue.  Instead, use a marker node to delimit when the
batch ends.

XXX pullup


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.4.1 src/sys/external/bsd/common/linux/linux_work.c

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



CVS commit: [netbsd-9] src/sys/external/bsd/common/linux

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 20:02:20 UTC 2020

Modified Files:
src/sys/external/bsd/common/linux [netbsd-9]: linux_work.c

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

sys/external/bsd/common/linux/linux_work.c: revision 1.45

Fix abuse of TAILQ_CONCAT.

Other parts of this expect that the entries will be on wq->wq_queue
or wq->wq_dqueue, so we can't just move a batch of entries onto a
temporary queue.  Instead, use a marker node to delimit when the
batch ends.

XXX pullup


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.4.1 src/sys/external/bsd/common/linux/linux_work.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/external/bsd/common/linux/linux_work.c
diff -u src/sys/external/bsd/common/linux/linux_work.c:1.44 src/sys/external/bsd/common/linux/linux_work.c:1.44.4.1
--- src/sys/external/bsd/common/linux/linux_work.c:1.44	Tue Mar 19 08:17:46 2019
+++ src/sys/external/bsd/common/linux/linux_work.c	Wed Feb 12 20:02:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_work.c,v 1.44 2019/03/19 08:17:46 ryo Exp $	*/
+/*	$NetBSD: linux_work.c,v 1.44.4.1 2020/02/12 20:02:19 martin Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.44 2019/03/19 08:17:46 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.44.4.1 2020/02/12 20:02:19 martin Exp $");
 
 #include 
 #include 
@@ -348,8 +348,8 @@ static void __dead
 linux_workqueue_thread(void *cookie)
 {
 	struct workqueue_struct *const wq = cookie;
-	struct work_head queue, dqueue;
-	struct work_head *const q[2] = { ,  };
+	struct work_head *const q[2] = { >wq_queue, >wq_dqueue };
+	struct work_struct marker, *work;
 	unsigned i;
 
 	lwp_setspecific(workqueue_key, wq);
@@ -368,22 +368,22 @@ linux_workqueue_thread(void *cookie)
 			continue;
 		}
 
-		/* Grab a batch of work off the queue.  */
+		/*
+		 * Start a batch of work.  Use a marker to delimit when
+		 * the batch ends so we can advance the generation
+		 * after the batch.
+		 */
 		SDT_PROBE1(sdt, linux, work, batch__start,  wq);
-		TAILQ_INIT();
-		TAILQ_INIT();
-		TAILQ_CONCAT(, >wq_queue, work_entry);
-		TAILQ_CONCAT(, >wq_dqueue, work_entry);
-
-		/* Process each work item in the batch.  */
 		for (i = 0; i < 2; i++) {
-			while (!TAILQ_EMPTY(q[i])) {
-struct work_struct *work = TAILQ_FIRST(q[i]);
+			if (TAILQ_EMPTY(q[i]))
+continue;
+			TAILQ_INSERT_TAIL(q[i], , work_entry);
+			while ((work = TAILQ_FIRST(q[i])) != ) {
 void (*func)(struct work_struct *);
 
 KASSERT(work_queue(work) == wq);
 KASSERT(work_claimed(work, wq));
-KASSERTMSG((q[i] !=  ||
+KASSERTMSG((q[i] != >wq_dqueue ||
 	container_of(work, struct delayed_work,
 	work)->dw_state ==
 	DELAYED_WORK_IDLE),
@@ -407,6 +407,7 @@ linux_workqueue_thread(void *cookie)
 wq->wq_current_work = NULL;
 cv_broadcast(>wq_cv);
 			}
+			TAILQ_REMOVE(q[i], , work_entry);
 		}
 
 		/* Notify flush that we've completed a batch of work.  */



CVS commit: [netbsd-9] src/sys/miscfs/kernfs

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:59:22 UTC 2020

Modified Files:
src/sys/miscfs/kernfs [netbsd-9]: kernfs.h kernfs_vfsops.c
kernfs_vnops.c

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

sys/miscfs/kernfs/kernfs_vfsops.c: revision 1.98
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.163
sys/miscfs/kernfs/kernfs.h: revision 1.43

Use specfs vnops for specnodes in kernfs.

While here, don't filter out rootdev and rrootdev merely because
they're not cached.

Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only
appeared sometimes when they felt like it, and fixes operations on
/kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP.

We didn't seem to have a single PR for these issues but the following
PRs are all relevant:

PR bin/13564
PR kern/38265
PR kern/38778
PR kern/45974

XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, p=
ullup-2, pullup-1.4T...


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.40.32.1 src/sys/miscfs/kernfs/kernfs.h
cvs rdiff -u -r1.96 -r1.96.18.1 src/sys/miscfs/kernfs/kernfs_vfsops.c
cvs rdiff -u -r1.160.4.1 -r1.160.4.2 src/sys/miscfs/kernfs/kernfs_vnops.c

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



CVS commit: [netbsd-9] src/sys/miscfs/kernfs

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:59:22 UTC 2020

Modified Files:
src/sys/miscfs/kernfs [netbsd-9]: kernfs.h kernfs_vfsops.c
kernfs_vnops.c

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

sys/miscfs/kernfs/kernfs_vfsops.c: revision 1.98
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.163
sys/miscfs/kernfs/kernfs.h: revision 1.43

Use specfs vnops for specnodes in kernfs.

While here, don't filter out rootdev and rrootdev merely because
they're not cached.

Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only
appeared sometimes when they felt like it, and fixes operations on
/kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP.

We didn't seem to have a single PR for these issues but the following
PRs are all relevant:

PR bin/13564
PR kern/38265
PR kern/38778
PR kern/45974

XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, p=
ullup-2, pullup-1.4T...


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.40.32.1 src/sys/miscfs/kernfs/kernfs.h
cvs rdiff -u -r1.96 -r1.96.18.1 src/sys/miscfs/kernfs/kernfs_vfsops.c
cvs rdiff -u -r1.160.4.1 -r1.160.4.2 src/sys/miscfs/kernfs/kernfs_vnops.c

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

Modified files:

Index: src/sys/miscfs/kernfs/kernfs.h
diff -u src/sys/miscfs/kernfs/kernfs.h:1.40 src/sys/miscfs/kernfs/kernfs.h:1.40.32.1
--- src/sys/miscfs/kernfs/kernfs.h:1.40	Sun Jul 20 13:58:04 2014
+++ src/sys/miscfs/kernfs/kernfs.h	Wed Feb 12 19:59:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs.h,v 1.40 2014/07/20 13:58:04 hannken Exp $	*/
+/*	$NetBSD: kernfs.h,v 1.40.32.1 2020/02/12 19:59:22 martin Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -121,6 +121,7 @@ extern const struct kern_target kern_tar
 extern int nkern_targets;
 extern const int static_nkern_targets;
 extern int (**kernfs_vnodeop_p)(void *);
+extern int (**kernfs_specop_p)(void *);
 extern struct vfsops kernfs_vfsops;
 extern dev_t rrootdev;
 extern kmutex_t kfs_lock;

Index: src/sys/miscfs/kernfs/kernfs_vfsops.c
diff -u src/sys/miscfs/kernfs/kernfs_vfsops.c:1.96 src/sys/miscfs/kernfs/kernfs_vfsops.c:1.96.18.1
--- src/sys/miscfs/kernfs/kernfs_vfsops.c:1.96	Fri Feb 17 08:31:25 2017
+++ src/sys/miscfs/kernfs/kernfs_vfsops.c	Wed Feb 12 19:59:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $	*/
+/*	$NetBSD: kernfs_vfsops.c,v 1.96.18.1 2020/02/12 19:59:22 martin Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.96.18.1 2020/02/12 19:59:22 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -283,6 +283,7 @@ again:
 		vp->v_vflag = VV_ROOT;
 
 	if (kt->kt_tag == KFSdevice) {
+		vp->v_op = kernfs_specop_p;
 		spec_node_init(vp, *(dev_t *)kt->kt_data);
 	}
 
@@ -293,9 +294,11 @@ again:
 }
 
 extern const struct vnodeopv_desc kernfs_vnodeop_opv_desc;
+extern const struct vnodeopv_desc kernfs_specop_opv_desc;
 
 const struct vnodeopv_desc * const kernfs_vnodeopv_descs[] = {
 	_vnodeop_opv_desc,
+	_specop_opv_desc,
 	NULL,
 };
 

Index: src/sys/miscfs/kernfs/kernfs_vnops.c
diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.160.4.1 src/sys/miscfs/kernfs/kernfs_vnops.c:1.160.4.2
--- src/sys/miscfs/kernfs/kernfs_vnops.c:1.160.4.1	Sun Sep  1 11:02:27 2019
+++ src/sys/miscfs/kernfs/kernfs_vnops.c	Wed Feb 12 19:59:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vnops.c,v 1.160.4.1 2019/09/01 11:02:27 martin Exp $	*/
+/*	$NetBSD: kernfs_vnops.c,v 1.160.4.2 2020/02/12 19:59:22 martin Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.160.4.1 2019/09/01 11:02:27 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.160.4.2 2020/02/12 19:59:22 martin Exp $");
 
 #include 
 #include 
@@ -227,6 +227,54 @@ const struct vnodeopv_entry_desc kernfs_
 const struct vnodeopv_desc kernfs_vnodeop_opv_desc =
 	{ _vnodeop_p, kernfs_vnodeop_entries };
 
+int (**kernfs_specop_p)(void *);
+const struct vnodeopv_entry_desc kernfs_specop_entries[] = {
+	{ _default_desc, vn_default_error },
+	{ _lookup_desc, spec_lookup },		/* lookup */
+	{ _create_desc, spec_create },		/* create */
+	{ _mknod_desc, spec_mknod },		/* mknod */
+	{ _open_desc, spec_open },			/* open */
+	{ _close_desc, spec_close },		/* close */
+	{ _access_desc, kernfs_access },		/* access */
+	{ _getattr_desc, kernfs_getattr },		/* getattr */
+	{ _setattr_desc, kernfs_setattr },		/* setattr */
+	{ _read_desc, spec_read },			/* read */
+	{ _write_desc, spec_write },		/* write */
+	{ _fallocate_desc, spec_fallocate },	/* fallocate */
+	{ _fdiscard_desc, spec_fdiscard },		/* fdiscard */
+	{ _fcntl_desc, spec_fcntl },		/* fcntl */
+	{ 

CVS commit: src/sys/arch/evbarm/stand/gzboot

2020-02-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Feb 12 19:55:32 UTC 2020

Modified Files:
src/sys/arch/evbarm/stand/gzboot: Makefile.gzboot gzboot.c

Log Message:
Allow a configuration to specify an arbitrary address where the
compressed kernel image is located, in the event it can't be appended
to or embedded within the gzboot binary itself.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/evbarm/stand/gzboot/Makefile.gzboot
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/evbarm/stand/gzboot/gzboot.c

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



CVS commit: [netbsd-9] src

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:55:57 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/dtrace/aarch64 [netbsd-9]: dtrace_isa.c
dtrace_subr.c
src/external/cddl/osnet/dev/fbt/aarch64 [netbsd-9]: fbt_isa.c
src/external/cddl/osnet/dist/lib/libdtrace/common [netbsd-9]: dt_impl.h
dt_module.c dt_open.c
src/sys/arch/aarch64/aarch64 [netbsd-9]: vectors.S
src/sys/arch/aarch64/include [netbsd-9]: cpu.h
src/sys/modules/cyclic [netbsd-9]: Makefile

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

external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c: revision 1.2
external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c: revision 1.17
external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c: revision 1.18
sys/modules/cyclic/Makefile: revision 1.5
external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c: revision 1.2
external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c: revision 1.3
sys/arch/aarch64/aarch64/vectors.S: revision 1.10
external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c: revision 1.2
external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c: revision 1.3
external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c: revision 1.4
external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c: revision 1.5
external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c: revision 1.6
sys/arch/aarch64/include/cpu.h: revision 1.20
external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h: revision 1.9

Create a buffer space of 512 bytes before the trapframe.

dtrace fbt needs enough space to emulate an

stp x29, x30, [sp,#-FRAMESIZE]!

instruction in a function prologue.  In the aarch64 instruction
encoding, FRAMESIZE can be as large as 512 bytes, so reserve this
much space when KDTRACE_HOOKS is enabled.

Use db_write_bytes to overwrite kernel text.

Tidy up a bit.  No functional change intended.

aarch64 fbt_invop doesn't actually use the argument, but it would
make more sense for it to be the return value and/or first argument
register.  Certainly it's not `eax'!

Tidy up a bit: don't set things we won't use; assert nonzeroness.

Use /dev/ksyms, not /netbsd, for the running kernel's symbols.

Teach dtrace about el1_trap_exit frames on aarch64.

Implement dtrace_getarg and dtrace_getreg while here.

Count the number of artificial frames in aarch64 fbt probe correctly.

Change the address ranges that aarch64 considers toxic for dtrace.
`Toxic' means dtrace forbids D scripts from even attempting to read
or write at them.

Previously we considered [0, VM_MIN_KERNEL_ADDRESS) toxic, but
VM_MIN_KERNEL_ADDRESS is only the minimum address of the kernel map;
the direct-mapped region lies below it, and with PMAP_MAP_POOLPAGE we
allocate virtual pages for pool backing directly from physical pages
through the direct-mapped region.  Also, this did not consider I/O
mappings to be toxic, which they probably should be.

Instead, treat:

[0, AARCH64_KSEG_START)
and
[VM_KERNEL_IO_ADDRESS, 0xfff...ff)

as toxic.  (The upper bound for 0xfff...ff ought to be inclusive, not
exclusive, but I think we'll need another mechanism for expressing
that to dtrace!)

Switch from db_write_bytes to using direct-mapping.

This way there's no dependency on ddb.

Define the MULTIPROCESSOR cpu_number() for modules too.
Modules should work whether the main kernel is multiprocessor or not.
In particular, dtrace should not think cpu_number() is 0 while
cpu_index(curcpu()) and curcpu()->ci_index are nonzero, leading to
rather spectacularly bogus results...

cyclic.kmod needs -Wno-sign-compare for aarch64 CPU_INFO_FOREACH.
Provisional workaround; feel free to fix.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c
cvs rdiff -u -r1.8 -r1.8.4.1 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h
cvs rdiff -u -r1.17 -r1.17.4.1 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c
cvs rdiff -u -r1.16 -r1.16.2.1 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/arch/aarch64/aarch64/vectors.S
cvs rdiff -u -r1.13.4.1 -r1.13.4.2 src/sys/arch/aarch64/include/cpu.h
cvs rdiff -u -r1.3.34.1 -r1.3.34.2 src/sys/modules/cyclic/Makefile

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



CVS commit: [netbsd-9] src

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:55:57 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/dtrace/aarch64 [netbsd-9]: dtrace_isa.c
dtrace_subr.c
src/external/cddl/osnet/dev/fbt/aarch64 [netbsd-9]: fbt_isa.c
src/external/cddl/osnet/dist/lib/libdtrace/common [netbsd-9]: dt_impl.h
dt_module.c dt_open.c
src/sys/arch/aarch64/aarch64 [netbsd-9]: vectors.S
src/sys/arch/aarch64/include [netbsd-9]: cpu.h
src/sys/modules/cyclic [netbsd-9]: Makefile

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

external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c: revision 1.2
external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c: revision 1.17
external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c: revision 1.18
sys/modules/cyclic/Makefile: revision 1.5
external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c: revision 1.2
external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c: revision 1.3
sys/arch/aarch64/aarch64/vectors.S: revision 1.10
external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c: revision 1.2
external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c: revision 1.3
external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c: revision 1.4
external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c: revision 1.5
external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c: revision 1.6
sys/arch/aarch64/include/cpu.h: revision 1.20
external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h: revision 1.9

Create a buffer space of 512 bytes before the trapframe.

dtrace fbt needs enough space to emulate an

stp x29, x30, [sp,#-FRAMESIZE]!

instruction in a function prologue.  In the aarch64 instruction
encoding, FRAMESIZE can be as large as 512 bytes, so reserve this
much space when KDTRACE_HOOKS is enabled.

Use db_write_bytes to overwrite kernel text.

Tidy up a bit.  No functional change intended.

aarch64 fbt_invop doesn't actually use the argument, but it would
make more sense for it to be the return value and/or first argument
register.  Certainly it's not `eax'!

Tidy up a bit: don't set things we won't use; assert nonzeroness.

Use /dev/ksyms, not /netbsd, for the running kernel's symbols.

Teach dtrace about el1_trap_exit frames on aarch64.

Implement dtrace_getarg and dtrace_getreg while here.

Count the number of artificial frames in aarch64 fbt probe correctly.

Change the address ranges that aarch64 considers toxic for dtrace.
`Toxic' means dtrace forbids D scripts from even attempting to read
or write at them.

Previously we considered [0, VM_MIN_KERNEL_ADDRESS) toxic, but
VM_MIN_KERNEL_ADDRESS is only the minimum address of the kernel map;
the direct-mapped region lies below it, and with PMAP_MAP_POOLPAGE we
allocate virtual pages for pool backing directly from physical pages
through the direct-mapped region.  Also, this did not consider I/O
mappings to be toxic, which they probably should be.

Instead, treat:

[0, AARCH64_KSEG_START)
and
[VM_KERNEL_IO_ADDRESS, 0xfff...ff)

as toxic.  (The upper bound for 0xfff...ff ought to be inclusive, not
exclusive, but I think we'll need another mechanism for expressing
that to dtrace!)

Switch from db_write_bytes to using direct-mapping.

This way there's no dependency on ddb.

Define the MULTIPROCESSOR cpu_number() for modules too.
Modules should work whether the main kernel is multiprocessor or not.
In particular, dtrace should not think cpu_number() is 0 while
cpu_index(curcpu()) and curcpu()->ci_index are nonzero, leading to
rather spectacularly bogus results...

cyclic.kmod needs -Wno-sign-compare for aarch64 CPU_INFO_FOREACH.
Provisional workaround; feel free to fix.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c
cvs rdiff -u -r1.8 -r1.8.4.1 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h
cvs rdiff -u -r1.17 -r1.17.4.1 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c
cvs rdiff -u -r1.16 -r1.16.2.1 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/arch/aarch64/aarch64/vectors.S
cvs rdiff -u -r1.13.4.1 -r1.13.4.2 src/sys/arch/aarch64/include/cpu.h
cvs rdiff -u -r1.3.34.1 -r1.3.34.2 src/sys/modules/cyclic/Makefile

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c:1.1.2.2 src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c:1.1.2.3
--- src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c:1.1.2.2	Mon Dec  9 15:19:30 2019
+++ 

CVS commit: src/sys/arch/evbarm/stand/gzboot

2020-02-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Feb 12 19:55:32 UTC 2020

Modified Files:
src/sys/arch/evbarm/stand/gzboot: Makefile.gzboot gzboot.c

Log Message:
Allow a configuration to specify an arbitrary address where the
compressed kernel image is located, in the event it can't be appended
to or embedded within the gzboot binary itself.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/evbarm/stand/gzboot/Makefile.gzboot
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/evbarm/stand/gzboot/gzboot.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/evbarm/stand/gzboot/Makefile.gzboot
diff -u src/sys/arch/evbarm/stand/gzboot/Makefile.gzboot:1.37 src/sys/arch/evbarm/stand/gzboot/Makefile.gzboot:1.38
--- src/sys/arch/evbarm/stand/gzboot/Makefile.gzboot:1.37	Thu Oct 24 18:46:21 2019
+++ src/sys/arch/evbarm/stand/gzboot/Makefile.gzboot	Wed Feb 12 19:55:32 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.gzboot,v 1.37 2019/10/24 18:46:21 christos Exp $
+#	$NetBSD: Makefile.gzboot,v 1.38 2020/02/12 19:55:32 thorpej Exp $
 
 NOMAN=  # defined
 
@@ -49,6 +49,9 @@ CPPFLAGS+= -DHEAP_VARIABLE
 CPPFLAGS+= -DRELOC=${RELOC}
 CPPFLAGS+= -DMAXIMAGESIZE=${MAXIMAGESIZE}
 CPPFLAGS+= -DLOADADDR=${LOADADDR}
+.if defined(GZSRCADDR)
+CPPFLAGS+= -DGZSRCADDR=${GZSRCADDR}
+.endif
 
 COPTS+=	-ffreestanding
 COPTS+=	-fno-stack-protector

Index: src/sys/arch/evbarm/stand/gzboot/gzboot.c
diff -u src/sys/arch/evbarm/stand/gzboot/gzboot.c:1.15 src/sys/arch/evbarm/stand/gzboot/gzboot.c:1.16
--- src/sys/arch/evbarm/stand/gzboot/gzboot.c:1.15	Sat Jan 22 19:19:17 2011
+++ src/sys/arch/evbarm/stand/gzboot/gzboot.c	Wed Feb 12 19:55:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: gzboot.c,v 1.15 2011/01/22 19:19:17 joerg Exp $	*/
+/*	$NetBSD: gzboot.c,v 1.16 2020/02/12 19:55:32 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2002 Wasabi Systems, Inc.
@@ -111,6 +111,12 @@ void	zmemcpy(unsigned char *, unsigned c
 void	main(void);
 void	gzcopy(void *, const void *, size_t);
 
+#ifdef GZSRCADDR
+#define	compressed_image	(void *)GZSRCADDR
+#else
+#define	compressed_image	md_root_image
+#endif
+
 void
 main(void)
 {
@@ -131,11 +137,14 @@ main(void)
 	 * decompressing from an image which was concatenated onto
 	 * the end of the gzboot binary.
 	 */
+#ifdef GZSRCADDR
+	printf(">> Image address: %p\n", compressed_image);
+#endif
 	if (md_root_size != 0)
 		printf(">> Image size: %u\n", md_root_size);
 
 	printf("Uncompressing image...");
-	gzcopy((void *) loadaddr, md_root_image, md_root_size);
+	gzcopy((void *) loadaddr, compressed_image, md_root_size);
 	printf("done.\n");
 
 	printf("Jumping to image @ 0x%x...\n", md_root_loadaddr);



CVS commit: [netbsd-9] src/share/man/man5

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:44:27 UTC 2020

Modified Files:
src/share/man/man5 [netbsd-9]: fstab.5

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

share/man/man5/fstab.5: revision 1.45

fstab.5: add mention of zfs


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/share/man/man5/fstab.5

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/man5/fstab.5
diff -u src/share/man/man5/fstab.5:1.44 src/share/man/man5/fstab.5:1.44.2.1
--- src/share/man/man5/fstab.5:1.44	Sat Oct  6 13:09:53 2018
+++ src/share/man/man5/fstab.5	Wed Feb 12 19:44:27 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: fstab.5,v 1.44 2018/10/06 13:09:53 jmcneill Exp $
+.\"	$NetBSD: fstab.5,v 1.44.2.1 2020/02/12 19:44:27 martin Exp $
 .\"
 .\" Copyright (c) 1980, 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)fstab.5	8.1 (Berkeley) 6/5/93
 .\"
-.Dd October 6, 2018
+.Dd September 15, 2019
 .Dt FSTAB 5
 .Os
 .Sh NAME
@@ -173,6 +173,8 @@ an efficient memory file system.
 a user and group re-mapping file system.
 .It Em union
 a translucent file system.
+.It Em zfs
+a ZFS file system.
 .El
 .Pp
 The fourth field,



CVS commit: [netbsd-9] src/share/man/man5

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:44:27 UTC 2020

Modified Files:
src/share/man/man5 [netbsd-9]: fstab.5

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

share/man/man5/fstab.5: revision 1.45

fstab.5: add mention of zfs


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/share/man/man5/fstab.5

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



CVS commit: [netbsd-9] src/sys/net/npf

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:41:13 UTC 2020

Modified Files:
src/sys/net/npf [netbsd-9]: npf_ruleset.c

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

sys/net/npf/npf_ruleset.c: revision 1.50

PR/54950: Lloyd Parkes: Avoid NULL deref.


To generate a diff of this commit:
cvs rdiff -u -r1.48.2.1 -r1.48.2.2 src/sys/net/npf/npf_ruleset.c

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



CVS commit: [netbsd-9] src/sys/net/npf

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:41:13 UTC 2020

Modified Files:
src/sys/net/npf [netbsd-9]: npf_ruleset.c

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

sys/net/npf/npf_ruleset.c: revision 1.50

PR/54950: Lloyd Parkes: Avoid NULL deref.


To generate a diff of this commit:
cvs rdiff -u -r1.48.2.1 -r1.48.2.2 src/sys/net/npf/npf_ruleset.c

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

Modified files:

Index: src/sys/net/npf/npf_ruleset.c
diff -u src/sys/net/npf/npf_ruleset.c:1.48.2.1 src/sys/net/npf/npf_ruleset.c:1.48.2.2
--- src/sys/net/npf/npf_ruleset.c:1.48.2.1	Fri Oct  4 08:06:35 2019
+++ src/sys/net/npf/npf_ruleset.c	Wed Feb 12 19:41:12 2020
@@ -33,7 +33,7 @@
 
 #ifdef _KERNEL
 #include 
-__KERNEL_RCSID(0, "$NetBSD: npf_ruleset.c,v 1.48.2.1 2019/10/04 08:06:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_ruleset.c,v 1.48.2.2 2020/02/12 19:41:12 martin Exp $");
 
 #include 
 #include 
@@ -153,6 +153,9 @@ npf_ruleset_create(size_t slots)
 void
 npf_ruleset_destroy(npf_ruleset_t *rlset)
 {
+	if (rlset == NULL)
+		return;
+
 	size_t len = offsetof(npf_ruleset_t, rs_rules[rlset->rs_slots]);
 	npf_rule_t *rl;
 



CVS commit: [netbsd-9] src/external/bsd/ppp/dist/pppd

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:37:33 UTC 2020

Modified Files:
src/external/bsd/ppp/dist/pppd [netbsd-9]: eap.c

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

external/bsd/ppp/dist/pppd/eap.c: revision 1.5

pppd: Fix bounds check in EAP code

Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel 

Signed-off-by: Paul Mackerras 

From:
https://github.com/paulusmack/ppp/commit/8d7970b8f3db727fe798b65f3377fe6787575426


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.18.1 src/external/bsd/ppp/dist/pppd/eap.c

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



CVS commit: [netbsd-9] src/external/bsd/ppp/dist/pppd

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:37:33 UTC 2020

Modified Files:
src/external/bsd/ppp/dist/pppd [netbsd-9]: eap.c

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

external/bsd/ppp/dist/pppd/eap.c: revision 1.5

pppd: Fix bounds check in EAP code

Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel 

Signed-off-by: Paul Mackerras 

From:
https://github.com/paulusmack/ppp/commit/8d7970b8f3db727fe798b65f3377fe6787575426


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.18.1 src/external/bsd/ppp/dist/pppd/eap.c

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

Modified files:

Index: src/external/bsd/ppp/dist/pppd/eap.c
diff -u src/external/bsd/ppp/dist/pppd/eap.c:1.4 src/external/bsd/ppp/dist/pppd/eap.c:1.4.18.1
--- src/external/bsd/ppp/dist/pppd/eap.c:1.4	Sat Oct 25 21:11:37 2014
+++ src/external/bsd/ppp/dist/pppd/eap.c	Wed Feb 12 19:37:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eap.c,v 1.4 2014/10/25 21:11:37 christos Exp $	*/
+/*	$NetBSD: eap.c,v 1.4.18.1 2020/02/12 19:37:33 martin Exp $	*/
 /*
  * eap.c - Extensible Authentication Protocol for PPP (RFC 2284)
  *
@@ -49,7 +49,7 @@
 #define RCSID	"Id: eap.c,v 1.4 2004/11/09 22:39:25 paulus Exp "
 static const char rcsid[] = RCSID;
 #else
-__RCSID("$NetBSD: eap.c,v 1.4 2014/10/25 21:11:37 christos Exp $");
+__RCSID("$NetBSD: eap.c,v 1.4.18.1 2020/02/12 19:37:33 martin Exp $");
 #endif
 
 /*
@@ -1433,7 +1433,7 @@ int len;
 		}
 
 		/* Not so likely to happen. */
-		if (vallen >= len + sizeof (rhostname)) {
+		if (len - vallen >= sizeof (rhostname)) {
 			dbglog("EAP: trimming really long peer name down");
 			BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
 			rhostname[sizeof (rhostname) - 1] = '\0';
@@ -1859,7 +1859,7 @@ int len;
 		}
 
 		/* Not so likely to happen. */
-		if (vallen >= len + sizeof (rhostname)) {
+		if (len - vallen >= sizeof (rhostname)) {
 			dbglog("EAP: trimming really long peer name down");
 			BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
 			rhostname[sizeof (rhostname) - 1] = '\0';



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

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:35:31 UTC 2020

Modified Files:
src/sys/kern [netbsd-9]: kern_lwp.c

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

sys/kern/kern_lwp.c: revision 1.224
sys/kern/kern_lwp.c: revision 1.225

Preserve pcu(9) state in fork.

There should perhaps be a pcu_fork operation to keep this factored
neatly but this will be simpler to pull up.

In practical terms, this may not affect most architecture that use
pcu(9) -- alpha, arm32, mips, powerpc, riscv -- but it does affect
aarch64, in which v8-v15 are callee-saves, and GCC actually takes
advantage of them, and for more than just floating-point data too.

XXX pullup

fix compilation failure for arches without l_pcu_valid
ok riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.202.2.2 -r1.202.2.3 src/sys/kern/kern_lwp.c

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

Modified files:

Index: src/sys/kern/kern_lwp.c
diff -u src/sys/kern/kern_lwp.c:1.202.2.2 src/sys/kern/kern_lwp.c:1.202.2.3
--- src/sys/kern/kern_lwp.c:1.202.2.2	Tue Oct 15 19:01:06 2019
+++ src/sys/kern/kern_lwp.c	Wed Feb 12 19:35:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lwp.c,v 1.202.2.2 2019/10/15 19:01:06 martin Exp $	*/
+/*	$NetBSD: kern_lwp.c,v 1.202.2.3 2020/02/12 19:35:31 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -211,7 +211,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.202.2.2 2019/10/15 19:01:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.202.2.3 2020/02/12 19:35:31 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -897,6 +897,9 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_
 	 * the MD cpu_lwp_fork() can copy the saved state to the new LWP.
 	 */
 	pcu_save_all(l1);
+#if PCU_UNIT_COUNT > 0
+	l2->l_pcu_valid = l1->l_pcu_valid;
+#endif
 
 	uvm_lwp_setuarea(l2, uaddr);
 	uvm_lwp_fork(l1, l2, stack, stacksize, func, (arg != NULL) ? arg : l2);



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

2020-02-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 12 19:35:31 UTC 2020

Modified Files:
src/sys/kern [netbsd-9]: kern_lwp.c

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

sys/kern/kern_lwp.c: revision 1.224
sys/kern/kern_lwp.c: revision 1.225

Preserve pcu(9) state in fork.

There should perhaps be a pcu_fork operation to keep this factored
neatly but this will be simpler to pull up.

In practical terms, this may not affect most architecture that use
pcu(9) -- alpha, arm32, mips, powerpc, riscv -- but it does affect
aarch64, in which v8-v15 are callee-saves, and GCC actually takes
advantage of them, and for more than just floating-point data too.

XXX pullup

fix compilation failure for arches without l_pcu_valid
ok riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.202.2.2 -r1.202.2.3 src/sys/kern/kern_lwp.c

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



CVS commit: src/sys/external/bsd/drm2/linux

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 18:35:02 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/linux: linux_pci.c

Log Message:
re-enable MSI - this actually enables MSI only for intel/radeon/generic
which are reported to work fine, while nouveau (which breaks with
MSI) still uses INTx

see the thread
http://mail-index.netbsd.org/current-users/2020/02/06/msg037661.html


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/linux/linux_pci.c

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



CVS commit: src/sys/external/bsd/drm2/linux

2020-02-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Feb 12 18:35:02 UTC 2020

Modified Files:
src/sys/external/bsd/drm2/linux: linux_pci.c

Log Message:
re-enable MSI - this actually enables MSI only for intel/radeon/generic
which are reported to work fine, while nouveau (which breaks with
MSI) still uses INTx

see the thread
http://mail-index.netbsd.org/current-users/2020/02/06/msg037661.html


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/linux/linux_pci.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/external/bsd/drm2/linux/linux_pci.c
diff -u src/sys/external/bsd/drm2/linux/linux_pci.c:1.9 src/sys/external/bsd/drm2/linux/linux_pci.c:1.10
--- src/sys/external/bsd/drm2/linux/linux_pci.c:1.9	Fri Feb  7 18:13:33 2020
+++ src/sys/external/bsd/drm2/linux/linux_pci.c	Wed Feb 12 18:35:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_pci.c,v 1.9 2020/02/07 18:13:33 jmcneill Exp $	*/
+/*	$NetBSD: linux_pci.c,v 1.10 2020/02/12 18:35:01 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.9 2020/02/07 18:13:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.10 2020/02/12 18:35:01 jdolecek Exp $");
 
 #include 
 
@@ -266,7 +266,6 @@ pci_bus_write_config_byte(struct pci_bus
 int
 pci_enable_msi(struct pci_dev *pdev)
 {
-#ifdef notyet
 	const struct pci_attach_args *const pa = >pd_pa;
 
 	if (pci_msi_alloc_exact(pa, >pd_intr_handles, 1))
@@ -274,9 +273,6 @@ pci_enable_msi(struct pci_dev *pdev)
 
 	pdev->msi_enabled = 1;
 	return 0;
-#else
-	return -ENOSYS;
-#endif
 }
 
 void



CVS commit: src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d00000

2020-02-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Feb 12 18:11:30 UTC 2020

Modified Files:
src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d0: ldscript

Log Message:
Because everything goes into the same memory region at run-time in this
configuration *and* image data concatenated onto the end, the BSS segment
needs to be allocated in the file.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d0/ldscript

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

Modified files:

Index: src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d0/ldscript
diff -u src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d0/ldscript:1.1 src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d0/ldscript:1.2
--- src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d0/ldscript:1.1	Wed Feb 12 06:57:35 2020
+++ src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d0/ldscript	Wed Feb 12 18:11:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldscript,v 1.1 2020/02/12 06:57:35 thorpej Exp $	*/
+/*	$NetBSD: ldscript,v 1.2 2020/02/12 18:11:30 thorpej Exp $	*/
 
 OUTPUT_FORMAT("elf32-bigarm", "elf32-bigarm",
 	  "elf32-littlearm")
@@ -55,7 +55,7 @@ SECTIONS
   __bss_start = .;
   __bss_start__ = .;
   .sbss  :
-  AT (ADDR(.sbss))
+  AT (LOADADDR(.sdata) + SIZEOF(.sdata))
   {
 PROVIDE (__sbss_start = .);
 PROVIDE (___sbss_start = .);
@@ -67,7 +67,7 @@ SECTIONS
 PROVIDE (___sbss_end = .);
   } > sdram
   .bss   :
-  AT (ADDR(.bss))
+  AT (LOADADDR(.sbss) + SIZEOF(.sbss))
   {
*(.dynbss)
*(.bss)
@@ -82,9 +82,9 @@ SECTIONS
   _end = .;
   _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
   PROVIDE (end = .);
-  .image   (SDRAM + SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.sdata)) :
-  AT (LOADADDR(.sdata) + SIZEOF(.sdata))
+  .image :
+  AT (LOADADDR(.bss) + SIZEOF(.bss))
   {
 *(.image)
-  }
+  } > sdram
 }



CVS commit: src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d00000

2020-02-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Feb 12 18:11:30 UTC 2020

Modified Files:
src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d0: ldscript

Log Message:
Because everything goes into the same memory region at run-time in this
configuration *and* image data concatenated onto the end, the BSS segment
needs to be allocated in the file.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/arch/evbarm/stand/gzboot/NSLU2_dram_0x01d0/ldscript

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



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb 12 17:36:41 UTC 2020

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

Log Message:
Convert the DEBUG code in pmap_grow_map to DIAGNOSTIC


To generate a diff of this commit:
cvs rdiff -u -r1.391 -r1.392 src/sys/arch/arm/arm32/pmap.c

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



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb 12 17:36:41 UTC 2020

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

Log Message:
Convert the DEBUG code in pmap_grow_map to DIAGNOSTIC


To generate a diff of this commit:
cvs rdiff -u -r1.391 -r1.392 src/sys/arch/arm/arm32/pmap.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/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.391 src/sys/arch/arm/arm32/pmap.c:1.392
--- src/sys/arch/arm/arm32/pmap.c:1.391	Wed Feb 12 17:34:18 2020
+++ src/sys/arch/arm/arm32/pmap.c	Wed Feb 12 17:36:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.391 2020/02/12 17:34:18 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.392 2020/02/12 17:36:41 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -198,7 +198,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.391 2020/02/12 17:34:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.392 2020/02/12 17:36:41 skrll Exp $");
 
 #include 
 #include 
@@ -5842,14 +5842,15 @@ pmap_grow_map(vaddr_t va, paddr_t *pap)
 		*pap = pa;
 
 	PMAPCOUNT(pt_mappings);
-#ifdef DEBUG
-	struct l2_bucket * const l2b = pmap_get_l2_bucket(pmap_kernel(), va);
-	KDASSERT(l2b != NULL);
 
-	pt_entry_t * const ptep = >l2b_kva[l2pte_index(va)];
-	const pt_entry_t opte = *ptep;
-	KDASSERT((opte & L2_S_CACHE_MASK) == pte_l2_s_cache_mode_pt);
-#endif
+	struct l2_bucket * const l2b __diagused =
+	pmap_get_l2_bucket(pmap_kernel(), va);
+	KASSERT(l2b != NULL);
+
+	pt_entry_t * const ptep __diagused = >l2b_kva[l2pte_index(va)];
+	const pt_entry_t opte __diagused = *ptep;
+	KASSERT((opte & L2_S_CACHE_MASK) == pte_l2_s_cache_mode_pt);
+
 	memset((void *)va, 0, PAGE_SIZE);
 	return 0;
 }



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb 12 17:34:18 UTC 2020

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

Log Message:
Add a CTASSERT to pmap_grow_l2_bucket that PAGE_SIZE is a multiple of
L2_TABLE_SIZE_REAL.


To generate a diff of this commit:
cvs rdiff -u -r1.390 -r1.391 src/sys/arch/arm/arm32/pmap.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/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.390 src/sys/arch/arm/arm32/pmap.c:1.391
--- src/sys/arch/arm/arm32/pmap.c:1.390	Wed Feb 12 17:31:51 2020
+++ src/sys/arch/arm/arm32/pmap.c	Wed Feb 12 17:34:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.390 2020/02/12 17:31:51 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.391 2020/02/12 17:34:18 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -198,7 +198,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.390 2020/02/12 17:31:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.391 2020/02/12 17:34:18 skrll Exp $");
 
 #include 
 #include 
@@ -5865,6 +5865,7 @@ pmap_grow_l2_bucket(pmap_t pm, vaddr_t v
 	struct l2_dtable *l2;
 	vaddr_t nva;
 
+	CTASSERT((PAGE_SIZE % L2_TABLE_SIZE_REAL) == 0);
 	if ((l2 = pm->pm_l2[L2_IDX(l1slot)]) == NULL) {
 		/*
 		 * No mapping at this address, as there is



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb 12 17:34:18 UTC 2020

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

Log Message:
Add a CTASSERT to pmap_grow_l2_bucket that PAGE_SIZE is a multiple of
L2_TABLE_SIZE_REAL.


To generate a diff of this commit:
cvs rdiff -u -r1.390 -r1.391 src/sys/arch/arm/arm32/pmap.c

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



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb 12 17:31:51 UTC 2020

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

Log Message:
Add a KASERT that we're not overwriting anything in pmap_growkernel


To generate a diff of this commit:
cvs rdiff -u -r1.389 -r1.390 src/sys/arch/arm/arm32/pmap.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/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.389 src/sys/arch/arm/arm32/pmap.c:1.390
--- src/sys/arch/arm/arm32/pmap.c:1.389	Wed Feb 12 16:08:19 2020
+++ src/sys/arch/arm/arm32/pmap.c	Wed Feb 12 17:31:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.389 2020/02/12 16:08:19 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.390 2020/02/12 17:31:51 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -198,7 +198,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.389 2020/02/12 16:08:19 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.390 2020/02/12 17:31:51 skrll Exp $");
 
 #include 
 #include 
@@ -5978,6 +5978,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 		const pd_entry_t npde = L1_C_PROTO | l2b->l2b_pa
 		| L1_C_DOM(PMAP_DOMAIN_KERNEL);
 #ifdef ARM_MMU_EXTENDED
+		KASSERT(*pdep == 0);
 		l1pte_setone(pdep, npde);
 #else
 		/* Distribute new L1 entry to all other L1s */



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb 12 17:31:51 UTC 2020

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

Log Message:
Add a KASERT that we're not overwriting anything in pmap_growkernel


To generate a diff of this commit:
cvs rdiff -u -r1.389 -r1.390 src/sys/arch/arm/arm32/pmap.c

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



CVS commit: src/usr.bin/make

2020-02-12 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Feb 12 16:50:37 UTC 2020

Modified Files:
src/usr.bin/make: meta.c

Log Message:
meta_compat_parent check for USE_FILEMON

patch from Soeren Tempel


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/meta.c

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



CVS commit: src/usr.bin/make

2020-02-12 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Feb 12 16:50:37 UTC 2020

Modified Files:
src/usr.bin/make: meta.c

Log Message:
meta_compat_parent check for USE_FILEMON

patch from Soeren Tempel


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/meta.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/make/meta.c
diff -u src/usr.bin/make/meta.c:1.78 src/usr.bin/make/meta.c:1.79
--- src/usr.bin/make/meta.c:1.78	Thu Feb  6 01:13:19 2020
+++ src/usr.bin/make/meta.c	Wed Feb 12 16:50:37 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.78 2020/02/06 01:13:19 sjg Exp $ */
+/*  $NetBSD: meta.c,v 1.79 2020/02/12 16:50:37 sjg Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -1686,7 +1686,11 @@ meta_compat_parent(pid_t child)
 meta_job_parent(NULL, child);
 close(childPipe[1]);			/* child side */
 outfd = childPipe[0];
+#ifdef USE_FILEMON
 metafd = Mybm.filemon ? filemon_readfd(Mybm.filemon) : -1;
+#else
+metafd = -1;
+#endif
 maxfd = -1;
 if (outfd > maxfd)
 	maxfd = outfd;



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb 12 16:08:19 UTC 2020

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

Log Message:
Minor changes to make pmap_grow_l2_bucket look more like
pmap_alloc_l2_bucket.  NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.388 -r1.389 src/sys/arch/arm/arm32/pmap.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/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.388 src/sys/arch/arm/arm32/pmap.c:1.389
--- src/sys/arch/arm/arm32/pmap.c:1.388	Wed Feb  5 07:37:35 2020
+++ src/sys/arch/arm/arm32/pmap.c	Wed Feb 12 16:08:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.388 2020/02/05 07:37:35 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.389 2020/02/12 16:08:19 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -198,7 +198,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.388 2020/02/05 07:37:35 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.389 2020/02/12 16:08:19 skrll Exp $");
 
 #include 
 #include 
@@ -5861,13 +5861,10 @@ pmap_grow_map(vaddr_t va, paddr_t *pap)
 static inline struct l2_bucket *
 pmap_grow_l2_bucket(pmap_t pm, vaddr_t va)
 {
+	const size_t l1slot = l1pte_index(va);
 	struct l2_dtable *l2;
-	struct l2_bucket *l2b;
-	u_short l1slot;
 	vaddr_t nva;
 
-	l1slot = l1pte_index(va);
-
 	if ((l2 = pm->pm_l2[L2_IDX(l1slot)]) == NULL) {
 		/*
 		 * No mapping at this address, as there is
@@ -5903,7 +5900,7 @@ pmap_grow_l2_bucket(pmap_t pm, vaddr_t v
 		pm->pm_l2[L2_IDX(l1slot)] = l2;
 	}
 
-	l2b = >l2_bucket[L2_BUCKET(l1slot)];
+	struct l2_bucket * const l2b = >l2_bucket[L2_BUCKET(l1slot)];
 
 	/*
 	 * Fetch pointer to the L2 page table associated with the address.



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

2020-02-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb 12 16:08:19 UTC 2020

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

Log Message:
Minor changes to make pmap_grow_l2_bucket look more like
pmap_alloc_l2_bucket.  NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.388 -r1.389 src/sys/arch/arm/arm32/pmap.c

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



CVS commit: src/sys

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 16:02:01 UTC 2020

Modified Files:
src/sys/arch/mips/adm5120/dev: ahci.c
src/sys/dev/usb: ehci.c ohci.c uhci.c vhci.c xhci.c
src/sys/external/bsd/dwc2: dwc2.c

Log Message:
Fix steady state of root intr xfers.

Why?

- Avoid completing a root intr xfer multiple times in races.
- Avoid potential use-after-free in poll_hub callouts (uhci, ahci).

How?

- Use sc->sc_intr_xfer or equivalent to store only a pending xfer
  that has not yet completed -- whether successfully, by timeout, or
  by synchronous abort.  When any of those happens, set it to null
  under the lock, so the xfer is completed only once.

- For hci drivers that use a callout to poll the root hub (uhci, ahci):

  . Pass the softc pointer, not the xfer, to the callout, so the
callout is not even tempted to use xfer after free -- if the
callout fires, but the xfer is synchronously aborted before the
callout can do anything, the xfer might be freed by the time the
callout starts to examine it.

  . Teach the callout to do nothing if it is callout_pending after it
has fired.  This way:

1. completion or synchronous abort can just callout_stop
2. start can just callout_schedule

If the callout had already fired before (1), and doesn't acquire
the bus lock until after (2), it may be tempted to abort the new
root intr xfer just after submission, which would be wrong -- so
instead we just have the callout do nothing if it notices it has
been rescheduled, since it will fire again after the appropriate
time has elapsed.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/mips/adm5120/dev/ahci.c
cvs rdiff -u -r1.271 -r1.272 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.293 -r1.294 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.289 -r1.290 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/vhci.c
cvs rdiff -u -r1.116 -r1.117 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.67 -r1.68 src/sys/external/bsd/dwc2/dwc2.c

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



CVS commit: src/sys

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 16:02:01 UTC 2020

Modified Files:
src/sys/arch/mips/adm5120/dev: ahci.c
src/sys/dev/usb: ehci.c ohci.c uhci.c vhci.c xhci.c
src/sys/external/bsd/dwc2: dwc2.c

Log Message:
Fix steady state of root intr xfers.

Why?

- Avoid completing a root intr xfer multiple times in races.
- Avoid potential use-after-free in poll_hub callouts (uhci, ahci).

How?

- Use sc->sc_intr_xfer or equivalent to store only a pending xfer
  that has not yet completed -- whether successfully, by timeout, or
  by synchronous abort.  When any of those happens, set it to null
  under the lock, so the xfer is completed only once.

- For hci drivers that use a callout to poll the root hub (uhci, ahci):

  . Pass the softc pointer, not the xfer, to the callout, so the
callout is not even tempted to use xfer after free -- if the
callout fires, but the xfer is synchronously aborted before the
callout can do anything, the xfer might be freed by the time the
callout starts to examine it.

  . Teach the callout to do nothing if it is callout_pending after it
has fired.  This way:

1. completion or synchronous abort can just callout_stop
2. start can just callout_schedule

If the callout had already fired before (1), and doesn't acquire
the bus lock until after (2), it may be tempted to abort the new
root intr xfer just after submission, which would be wrong -- so
instead we just have the callout do nothing if it notices it has
been rescheduled, since it will fire again after the appropriate
time has elapsed.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/mips/adm5120/dev/ahci.c
cvs rdiff -u -r1.271 -r1.272 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.293 -r1.294 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.289 -r1.290 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/vhci.c
cvs rdiff -u -r1.116 -r1.117 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.67 -r1.68 src/sys/external/bsd/dwc2/dwc2.c

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

Modified files:

Index: src/sys/arch/mips/adm5120/dev/ahci.c
diff -u src/sys/arch/mips/adm5120/dev/ahci.c:1.18 src/sys/arch/mips/adm5120/dev/ahci.c:1.19
--- src/sys/arch/mips/adm5120/dev/ahci.c:1.18	Wed Feb 12 16:01:00 2020
+++ src/sys/arch/mips/adm5120/dev/ahci.c	Wed Feb 12 16:02:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahci.c,v 1.18 2020/02/12 16:01:00 riastradh Exp $	*/
+/*	$NetBSD: ahci.c,v 1.19 2020/02/12 16:02:01 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.18 2020/02/12 16:01:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.19 2020/02/12 16:02:01 riastradh Exp $");
 
 #include 
 #include 
@@ -283,6 +283,7 @@ ahci_attach(device_t parent, device_t se
 	SIMPLEQ_INIT(>sc_free_xfers);
 
 	callout_init(>sc_poll_handle, 0);
+	callout_setfunc(>sc_poll_handle, ahci_poll_hub, sc);
 
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
 	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED /* XXXNH */);
@@ -422,13 +423,39 @@ ahci_poll(struct usbd_bus *bus)
 void
 ahci_poll_hub(void *arg)
 {
-	struct usbd_xfer *xfer = arg;
-	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
+	struct ahci_softc *sc = arg;
+	struct usbd_xfer *xfer;
 	u_char *p;
 	static int p0_state=0;
 	static int p1_state=0;
 
-	callout_reset(>sc_poll_handle, sc->sc_interval, ahci_poll_hub, xfer);
+	mutex_enter(>sc_lock);
+
+	/*
+	 * If the intr xfer has completed or been synchronously
+	 * aborted, we have nothing to do.
+	 */
+	xfer = sc->sc_intr_xfer;
+	if (xfer == NULL)
+		goto out;
+
+	/*
+	 * If the intr xfer for which we were scheduled is done, and
+	 * another intr xfer has been submitted, let that one be dealt
+	 * with when the callout fires again.
+	 *
+	 * The call to callout_pending is racy, but the the transition
+	 * from pending to invoking happens atomically.  The
+	 * callout_ack ensures callout_invoking does not return true
+	 * due to this invocation of the callout; the lock ensures the
+	 * next invocation of the callout cannot callout_ack (unless it
+	 * had already run to completion and nulled sc->sc_intr_xfer,
+	 * in which case would have bailed out already).
+	 */
+	callout_ack(>sc_poll_handle);
+	if (callout_pending(>sc_poll_handle) ||
+	callout_invoking(>sc_poll_handle))
+		goto out;
 
 	/* USB spec 11.13.3 (p.260) */
 	p = KERNADDR(>ux_dmabuf, 0);
@@ -444,15 +471,23 @@ ahci_poll_hub(void *arg)
 		p1_state=(REG_READ(ADMHCD_REG_PORTSTATUS1) & ADMHCD_CCS);
 	};
 
-	/* no change, return NAK */
-	if (p[0] == 0)
-		return;
+	/* no change, return NAK and try again later */
+	if (p[0] == 0) {
+		callout_schedule(>sc_poll_handle, sc->sc_interval);
+		goto out;
+	}
 
+	/*
+	 * Interrupt completed, and the xfer has not been completed or
+	 * synchronously aborted.  Complete 

CVS commit: src/sys/dev/usb

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 16:00:34 UTC 2020

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
Fix steady state of timeouts in ehci.

This is complicated because:

1. There are three ways that an xfer can be completed:
   (a) hardware interrupt completes xfer
   (b) software decision aborts xfer with USBD_CANCELLED
   (c) timeout aborts xfer with USBD_TIMEOUT

2. The timeout abort can't be done in callout because ehci_sync_hc,
   called unconditionally by ehci_abort_xfer to wait until the device
   has finished using any references to the xfer, may sleep.  So we
   have to schedule a callout that, when run, will schedule a usb_task.

3. The hardware completion interrupt can't sleep waiting for a callout
   or task to finish -- can't use callout_halt or usb_rem_task_wait.
   So the callout and usb_task must be able to run _after_ the hardware
   completion interrupt, and recognize that they're late to the party.

   (Note, though, that usbd_free_xfer does wait for the callout and
   task to complete, so there's no danger they may use themselves after
   free.)

4. The xfer may resubmitted -- and the timeout may be rescheduled --
   immediately after the hardware completion interrupt, _while_ the
   callout and/or usb_task may still be scheduled.  Specifically, we
   may have the following sequence of events:
   (a) hardware completion interrupt
   (b) callout or usb_task fires
   (c) driver resubmits xfer
   (d) callout or usb_task acquires lock and looks around dazed and
   bewildered at the firehose of events like reading the news in 2019

The mechanism for sorting this out is that we have two bits of state:

- xfer->ux_timeout_set informs the driver, when submitting an xfer and
  setting up its timeout, whether either the callout or usb_task is
  already scheduled or not.

- xfer->ux_timeout_reset informs the callout or usb_task whether it
  should reschedule the callout, because the xfer got resubmitted, or
  not.


To generate a diff of this commit:
cvs rdiff -u -r1.269 -r1.270 src/sys/dev/usb/ehci.c

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



CVS commit: src/sys

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 16:01:00 UTC 2020

Modified Files:
src/sys/arch/mips/adm5120/dev: ahci.c
src/sys/dev/usb: ehci.c motg.c ohci.c uhci.c usbdi.c usbdi.h usbdivar.h
xhci.c
src/sys/external/bsd/dwc2: dwc2.c dwc2var.h

Log Message:
Factor out HCI-independent xfer completion logic.

New API for HCI drivers to synchronize hardware completion
interrupts, synchronous aborts, and asynchronous timeouts:

- When submitting an xfer to hardware, call
  usbd_xfer_schedule_timeout(xfer).

- On HCI completion interrupt for xfer completion:

if (!usbd_xfer_trycomplete(xfer))
return; /* timed out or aborted, ignore it */

- In upm_abort methods, call usbd_xfer_abort(xfer).

For HCI drivers that use this API (not needed in drivers that don't,
or for xfers like root intr xfers that don't use it):

- New ubm_abortx method serves role of former *hci_abort_xfer, but
  without any logic for wrangling timeouts/callouts/tasks -- caller
  in usbd_xfer_abort has already handled them.

- New ubm_dying method, returns true if the device is in the process
  of detaching, used by the timeout logic.

Converted and tested:
- ehci
- ohci

Converted and compile-tested:
- ahci (XXX did this ever work?)
- dwc2
- motg (XXX missing usbd_xfer_schedule_timeout in motg_*_start?)
- uhci
- xhci

Not changed:

- slhci (sys/dev/ic/sl811hs.c) -- doesn't use a separate per-xfer
  callout for timeouts (XXX but maybe should?)

- ugenhc (sys/rump/dev/lib/libugenhc/ugenhc.c) -- doesn't manage its
  own transfer timeouts

- vhci -- times transfers out only on detach; could be adapted easily
  if we wanted to use the xfer->ux_callout


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/mips/adm5120/dev/ahci.c
cvs rdiff -u -r1.270 -r1.271 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/usb/motg.c
cvs rdiff -u -r1.292 -r1.293 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.288 -r1.289 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.191 -r1.192 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/usb/usbdi.h
cvs rdiff -u -r1.121 -r1.122 src/sys/dev/usb/usbdivar.h
cvs rdiff -u -r1.115 -r1.116 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.66 -r1.67 src/sys/external/bsd/dwc2/dwc2.c
cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/dwc2/dwc2var.h

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



CVS commit: src/sys/dev/usb

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 16:00:34 UTC 2020

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
Fix steady state of timeouts in ehci.

This is complicated because:

1. There are three ways that an xfer can be completed:
   (a) hardware interrupt completes xfer
   (b) software decision aborts xfer with USBD_CANCELLED
   (c) timeout aborts xfer with USBD_TIMEOUT

2. The timeout abort can't be done in callout because ehci_sync_hc,
   called unconditionally by ehci_abort_xfer to wait until the device
   has finished using any references to the xfer, may sleep.  So we
   have to schedule a callout that, when run, will schedule a usb_task.

3. The hardware completion interrupt can't sleep waiting for a callout
   or task to finish -- can't use callout_halt or usb_rem_task_wait.
   So the callout and usb_task must be able to run _after_ the hardware
   completion interrupt, and recognize that they're late to the party.

   (Note, though, that usbd_free_xfer does wait for the callout and
   task to complete, so there's no danger they may use themselves after
   free.)

4. The xfer may resubmitted -- and the timeout may be rescheduled --
   immediately after the hardware completion interrupt, _while_ the
   callout and/or usb_task may still be scheduled.  Specifically, we
   may have the following sequence of events:
   (a) hardware completion interrupt
   (b) callout or usb_task fires
   (c) driver resubmits xfer
   (d) callout or usb_task acquires lock and looks around dazed and
   bewildered at the firehose of events like reading the news in 2019

The mechanism for sorting this out is that we have two bits of state:

- xfer->ux_timeout_set informs the driver, when submitting an xfer and
  setting up its timeout, whether either the callout or usb_task is
  already scheduled or not.

- xfer->ux_timeout_reset informs the callout or usb_task whether it
  should reschedule the callout, because the xfer got resubmitted, or
  not.


To generate a diff of this commit:
cvs rdiff -u -r1.269 -r1.270 src/sys/dev/usb/ehci.c

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

Modified files:

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.269 src/sys/dev/usb/ehci.c:1.270
--- src/sys/dev/usb/ehci.c:1.269	Tue Feb  4 06:30:46 2020
+++ src/sys/dev/usb/ehci.c	Wed Feb 12 16:00:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.269 2020/02/04 06:30:46 mrg Exp $ */
+/*	$NetBSD: ehci.c,v 1.270 2020/02/12 16:00:34 riastradh Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.269 2020/02/04 06:30:46 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.270 2020/02/12 16:00:34 riastradh Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -168,6 +168,9 @@ Static void		ehci_check_sitd_intr(ehci_s
 Static void		ehci_idone(struct ehci_xfer *, ex_completeq_t *);
 Static void		ehci_timeout(void *);
 Static void		ehci_timeout_task(void *);
+Static bool		ehci_probe_timeout(struct usbd_xfer *);
+Static void		ehci_schedule_timeout(struct usbd_xfer *);
+Static void		ehci_cancel_timeout_async(struct usbd_xfer *);
 Static void		ehci_intrlist_timeout(void *);
 Static void		ehci_doorbell(void *);
 Static void		ehci_pcd(void *);
@@ -1057,13 +1060,11 @@ ehci_idone(struct ehci_xfer *ex, ex_comp
 	}
 
 	/*
-	 * Cancel the timeout and the task, which have not yet
-	 * run.  If they have already fired, at worst they are
-	 * waiting for the lock.  They will see that the xfer
-	 * is no longer in progress and give up.
+	 * We are completing the xfer.  Cancel the timeout if we can,
+	 * but only asynchronously.  See ehci_cancel_timeout_async for
+	 * why we need not wait for the callout or task here.
 	 */
-	callout_stop(>ux_callout);
-	usb_rem_task(xfer->ux_pipe->up_dev, >ux_aborttask);
+	ehci_cancel_timeout_async(xfer);
 
 #ifdef DIAGNOSTIC
 #ifdef EHCI_DEBUG
@@ -3235,35 +3236,38 @@ ehci_abort_xfer(struct usbd_xfer *xfer, 
 	KASSERT(mutex_owned(>sc_lock));
 	ASSERT_SLEEPABLE();
 
+	/*
+	 * Nobody else can set this status: only one caller can time
+	 * out, and only one caller can synchronously abort.  So the
+	 * status can't be the status we're trying to set this to.
+	 */
+	KASSERT(xfer->ux_status != status);
+
+	/*
+	 * If host controller or timer interrupt has completed it, too
+	 * late to abort.  Forget about it.
+	 */
+	if (xfer->ux_status != USBD_IN_PROGRESS)
+		return;
+
 	if (status == USBD_CANCELLED) {
 		/*
-		 * We are synchronously aborting.  Try to stop the
-		 * callout and task, but if we can't, wait for them to
-		 * complete.
+		 * We are synchronously aborting.  Cancel the timeout
+		 * if we can, but only asynchronously.  See
+		 * ehci_cancel_timeout_async for why we need not wait
+		 * for the callout or task here.
 		 */
-		callout_halt(>ux_callout, >sc_lock);
-		usb_rem_task_wait(xfer->ux_pipe->up_dev, 

CVS commit: src/sys

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 16:01:00 UTC 2020

Modified Files:
src/sys/arch/mips/adm5120/dev: ahci.c
src/sys/dev/usb: ehci.c motg.c ohci.c uhci.c usbdi.c usbdi.h usbdivar.h
xhci.c
src/sys/external/bsd/dwc2: dwc2.c dwc2var.h

Log Message:
Factor out HCI-independent xfer completion logic.

New API for HCI drivers to synchronize hardware completion
interrupts, synchronous aborts, and asynchronous timeouts:

- When submitting an xfer to hardware, call
  usbd_xfer_schedule_timeout(xfer).

- On HCI completion interrupt for xfer completion:

if (!usbd_xfer_trycomplete(xfer))
return; /* timed out or aborted, ignore it */

- In upm_abort methods, call usbd_xfer_abort(xfer).

For HCI drivers that use this API (not needed in drivers that don't,
or for xfers like root intr xfers that don't use it):

- New ubm_abortx method serves role of former *hci_abort_xfer, but
  without any logic for wrangling timeouts/callouts/tasks -- caller
  in usbd_xfer_abort has already handled them.

- New ubm_dying method, returns true if the device is in the process
  of detaching, used by the timeout logic.

Converted and tested:
- ehci
- ohci

Converted and compile-tested:
- ahci (XXX did this ever work?)
- dwc2
- motg (XXX missing usbd_xfer_schedule_timeout in motg_*_start?)
- uhci
- xhci

Not changed:

- slhci (sys/dev/ic/sl811hs.c) -- doesn't use a separate per-xfer
  callout for timeouts (XXX but maybe should?)

- ugenhc (sys/rump/dev/lib/libugenhc/ugenhc.c) -- doesn't manage its
  own transfer timeouts

- vhci -- times transfers out only on detach; could be adapted easily
  if we wanted to use the xfer->ux_callout


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/mips/adm5120/dev/ahci.c
cvs rdiff -u -r1.270 -r1.271 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/usb/motg.c
cvs rdiff -u -r1.292 -r1.293 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.288 -r1.289 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.191 -r1.192 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/usb/usbdi.h
cvs rdiff -u -r1.121 -r1.122 src/sys/dev/usb/usbdivar.h
cvs rdiff -u -r1.115 -r1.116 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.66 -r1.67 src/sys/external/bsd/dwc2/dwc2.c
cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/dwc2/dwc2var.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/mips/adm5120/dev/ahci.c
diff -u src/sys/arch/mips/adm5120/dev/ahci.c:1.17 src/sys/arch/mips/adm5120/dev/ahci.c:1.18
--- src/sys/arch/mips/adm5120/dev/ahci.c:1.17	Sun Feb 17 04:17:52 2019
+++ src/sys/arch/mips/adm5120/dev/ahci.c	Wed Feb 12 16:01:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahci.c,v 1.17 2019/02/17 04:17:52 rin Exp $	*/
+/*	$NetBSD: ahci.c,v 1.18 2020/02/12 16:01:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.17 2019/02/17 04:17:52 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.18 2020/02/12 16:01:00 riastradh Exp $");
 
 #include 
 #include 
@@ -98,6 +98,7 @@ static void		ahci_poll_device(void *arg)
 static struct usbd_xfer *
 			ahci_allocx(struct usbd_bus *, unsigned int);
 static void		ahci_freex(struct usbd_bus *, struct usbd_xfer *);
+static void		ahci_abortx(struct usbd_xfer *);
 
 static void		ahci_get_lock(struct usbd_bus *, kmutex_t **);
 static int		ahci_roothub_ctrl(struct usbd_bus *, usb_device_request_t *,
@@ -136,7 +137,6 @@ static void		ahci_device_bulk_done(struc
 static int		ahci_transaction(struct ahci_softc *,
 	struct usbd_pipe *, uint8_t, int, u_char *, uint8_t);
 static void		ahci_noop(struct usbd_pipe *);
-static void		ahci_abort_xfer(struct usbd_xfer *, usbd_status);
 static void		ahci_device_clear_toggle(struct usbd_pipe *);
 
 extern int usbdebug;
@@ -169,6 +169,7 @@ struct usbd_bus_methods ahci_bus_methods
 	.ubm_dopoll = ahci_poll,
 	.ubm_allocx = ahci_allocx,
 	.ubm_freex = ahci_freex,
+	.ubm_abortx = ahci_abortx,
 	.ubm_getlock = ahci_get_lock,
 	.ubm_rhctrl = ahci_roothub_ctrl,
 };
@@ -919,7 +920,7 @@ static void
 ahci_device_ctrl_abort(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("Cab "));
-	ahci_abort_xfer(xfer, USBD_CANCELLED);
+	usbd_xfer_abort(xfer);
 }
 
 static void
@@ -1031,7 +1032,7 @@ ahci_device_intr_abort(struct usbd_xfer 
 	} else {
 		printf("%s: sx == NULL!\n", __func__);
 	}
-	ahci_abort_xfer(xfer, USBD_CANCELLED);
+	usbd_xfer_abort(xfer);
 }
 
 static void
@@ -1247,7 +1248,7 @@ static void
 ahci_device_bulk_abort(struct usbd_xfer *xfer)
 {
 	DPRINTF(D_TRACE, ("Bab "));
-	ahci_abort_xfer(xfer, USBD_CANCELLED);
+	usbd_xfer_abort(xfer);
 }
 
 static void
@@ -1377,11 +1378,15 @@ ahci_transaction(struct ahci_softc *sc, 
 #endif
 }
 
-void
-ahci_abort_xfer(struct usbd_xfer *xfer, usbd_status status)
+static void
+ahci_abortx(struct usbd_xfer *xfer)
 {
-	

CVS commit: src/sys/dev/usb

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 16:00:17 UTC 2020

Modified Files:
src/sys/dev/usb: usbdi.c usbdivar.h

Log Message:
New xfer state variables ux_timeout_set and ux_timeout_reset.

These are needed because:

- The host controller interrupt cannot wait for the callout or task
  to finish running.

- Nothing in the USBD API as is waits for the callout or task to
  finish running.

- Callers expect to be able to resubmit USB xfers from xfer callbacks
  without waiting for anything to finish running.

The variable ux_timeout_set can be used by a host controller to
decide on submission whether to schedule the callout or to ask an
already-scheduled callout or already-queued task to reschedule the
callout, by setting the variable ux_timeout_reset to true.

When the callout or task runs and sees that ux_timeout_reset is true,
rather than queue the task or abort the xfer, it can instead just
schedule the callout anew.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.120 -r1.121 src/sys/dev/usb/usbdivar.h

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



CVS commit: src/sys/dev/usb

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 16:00:17 UTC 2020

Modified Files:
src/sys/dev/usb: usbdi.c usbdivar.h

Log Message:
New xfer state variables ux_timeout_set and ux_timeout_reset.

These are needed because:

- The host controller interrupt cannot wait for the callout or task
  to finish running.

- Nothing in the USBD API as is waits for the callout or task to
  finish running.

- Callers expect to be able to resubmit USB xfers from xfer callbacks
  without waiting for anything to finish running.

The variable ux_timeout_set can be used by a host controller to
decide on submission whether to schedule the callout or to ask an
already-scheduled callout or already-queued task to reschedule the
callout, by setting the variable ux_timeout_reset to true.

When the callout or task runs and sees that ux_timeout_reset is true,
rather than queue the task or abort the xfer, it can instead just
schedule the callout anew.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.120 -r1.121 src/sys/dev/usb/usbdivar.h

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

Modified files:

Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.190 src/sys/dev/usb/usbdi.c:1.191
--- src/sys/dev/usb/usbdi.c:1.190	Wed Feb 12 15:59:59 2020
+++ src/sys/dev/usb/usbdi.c	Wed Feb 12 16:00:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.190 2020/02/12 15:59:59 riastradh Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.191 2020/02/12 16:00:17 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.190 2020/02/12 15:59:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.191 2020/02/12 16:00:17 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -494,6 +494,7 @@ usbd_free_xfer(struct usbd_xfer *xfer)
 
 	/* Wait for any straggling timeout to complete. */
 	mutex_enter(xfer->ux_bus->ub_lock);
+	xfer->ux_timeout_reset = false; /* do not resuscitate */
 	callout_halt(>ux_callout, xfer->ux_bus->ub_lock);
 	usb_rem_task_wait(xfer->ux_pipe->up_dev, >ux_aborttask,
 	USB_TASKQ_HC, xfer->ux_bus->ub_lock);

Index: src/sys/dev/usb/usbdivar.h
diff -u src/sys/dev/usb/usbdivar.h:1.120 src/sys/dev/usb/usbdivar.h:1.121
--- src/sys/dev/usb/usbdivar.h:1.120	Sat Feb  8 08:47:27 2020
+++ src/sys/dev/usb/usbdivar.h	Wed Feb 12 16:00:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdivar.h,v 1.120 2020/02/08 08:47:27 maxv Exp $	*/
+/*	$NetBSD: usbdivar.h,v 1.121 2020/02/12 16:00:17 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -288,6 +288,19 @@ struct usbd_xfer {
 
 	struct usb_task		ux_aborttask;
 	struct callout		ux_callout;
+
+	/*
+	 * Protected by bus lock.
+	 *
+	 * - ux_timeout_set: The timeout is scheduled as a callout or
+	 *   usb task, and has not yet acquired the bus lock.
+	 *
+	 * - ux_timeout_reset: The xfer completed, and was resubmitted
+	 *   before the callout or task was able to acquire the bus
+	 *   lock, so one or the other needs to schedule a new callout.
+	 */
+	bool			ux_timeout_set;
+	bool			ux_timeout_reset;
 };
 
 void usbd_init(void);



CVS commit: src/sys/dev/usb

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 15:59:30 UTC 2020

Modified Files:
src/sys/dev/usb: usb.c usbdi.h

Log Message:
Teach usb_rem_task to return whether removed from queue or not.


To generate a diff of this commit:
cvs rdiff -u -r1.180 -r1.181 src/sys/dev/usb/usb.c
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/usb/usbdi.h

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

Modified files:

Index: src/sys/dev/usb/usb.c
diff -u src/sys/dev/usb/usb.c:1.180 src/sys/dev/usb/usb.c:1.181
--- src/sys/dev/usb/usb.c:1.180	Wed Aug 21 10:48:37 2019
+++ src/sys/dev/usb/usb.c	Wed Feb 12 15:59:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.c,v 1.180 2019/08/21 10:48:37 mrg Exp $	*/
+/*	$NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.180 2019/08/21 10:48:37 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -431,14 +431,16 @@ usb_add_task(struct usbd_device *dev, st
 /*
  * usb_rem_task(dev, task)
  *
- *	If task is queued to run, remove it from the queue.
+ *	If task is queued to run, remove it from the queue.  Return
+ *	true if it successfully removed the task from the queue, false
+ *	if not.
  *
  *	Caller is _not_ guaranteed that the task is not running when
  *	this is done.
  *
  *	Never sleeps.
  */
-void
+bool
 usb_rem_task(struct usbd_device *dev, struct usb_task *task)
 {
 	unsigned queue;
@@ -452,10 +454,12 @@ usb_rem_task(struct usbd_device *dev, st
 			TAILQ_REMOVE(>tasks, task, next);
 			task->queue = USB_NUM_TASKQS;
 			mutex_exit(>lock);
-			break;
+			return true; /* removed from the queue */
 		}
 		mutex_exit(>lock);
 	}
+
+	return false;		/* was not removed from the queue */
 }
 
 /*

Index: src/sys/dev/usb/usbdi.h
diff -u src/sys/dev/usb/usbdi.h:1.98 src/sys/dev/usb/usbdi.h:1.99
--- src/sys/dev/usb/usbdi.h:1.98	Sat Feb  8 07:38:17 2020
+++ src/sys/dev/usb/usbdi.h	Wed Feb 12 15:59:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.h,v 1.98 2020/02/08 07:38:17 maxv Exp $	*/
+/*	$NetBSD: usbdi.h,v 1.99 2020/02/12 15:59:30 riastradh Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $	*/
 
 /*
@@ -222,7 +222,7 @@ struct usb_task {
 #define	USB_TASKQ_MPSAFE	0x80
 
 void usb_add_task(struct usbd_device *, struct usb_task *, int);
-void usb_rem_task(struct usbd_device *, struct usb_task *);
+bool usb_rem_task(struct usbd_device *, struct usb_task *);
 bool usb_rem_task_wait(struct usbd_device *, struct usb_task *, int,
 kmutex_t *);
 #define usb_init_task(t, f, a, fl) ((t)->fun = (f), (t)->arg = (a), (t)->queue = USB_NUM_TASKQS, (t)->flags = (fl))



CVS commit: src/sys/dev/usb

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 15:59:44 UTC 2020

Modified Files:
src/sys/dev/usb: usb.c usbdi.h

Log Message:
New function usb_task_pending for diagnostic assertions.

Usable only for negative diagnostic assertions:

KASSERT(!usb_task_pending(dev, task))

If you can think of a better name for this than !usb_task_pending,
I'm all ears.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/sys/dev/usb/usb.c
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/usb/usbdi.h

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



CVS commit: src/sys/dev/usb

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 15:59:59 UTC 2020

Modified Files:
src/sys/dev/usb: usbdi.c

Log Message:
Nothing guarantees xfer's timeout has completed.

Wait for it when we free the xfer.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/dev/usb/usbdi.c

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

Modified files:

Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.189 src/sys/dev/usb/usbdi.c:1.190
--- src/sys/dev/usb/usbdi.c:1.189	Sat Feb  8 07:57:16 2020
+++ src/sys/dev/usb/usbdi.c	Wed Feb 12 15:59:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.189 2020/02/08 07:57:16 maxv Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.190 2020/02/12 15:59:59 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.189 2020/02/08 07:57:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.190 2020/02/12 15:59:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -491,12 +491,14 @@ usbd_free_xfer(struct usbd_xfer *xfer)
 	if (xfer->ux_buf) {
 		usbd_free_buffer(xfer);
 	}
-#if defined(DIAGNOSTIC)
-	if (callout_pending(>ux_callout)) {
-		callout_stop(>ux_callout);
-		printf("usbd_free_xfer: timeout_handle pending\n");
-	}
-#endif
+
+	/* Wait for any straggling timeout to complete. */
+	mutex_enter(xfer->ux_bus->ub_lock);
+	callout_halt(>ux_callout, xfer->ux_bus->ub_lock);
+	usb_rem_task_wait(xfer->ux_pipe->up_dev, >ux_aborttask,
+	USB_TASKQ_HC, xfer->ux_bus->ub_lock);
+	mutex_exit(xfer->ux_bus->ub_lock);
+
 	cv_destroy(>ux_cv);
 	xfer->ux_bus->ub_methods->ubm_freex(xfer->ux_bus, xfer);
 	return USBD_NORMAL_COMPLETION;



CVS commit: src/sys/dev/usb

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 15:59:44 UTC 2020

Modified Files:
src/sys/dev/usb: usb.c usbdi.h

Log Message:
New function usb_task_pending for diagnostic assertions.

Usable only for negative diagnostic assertions:

KASSERT(!usb_task_pending(dev, task))

If you can think of a better name for this than !usb_task_pending,
I'm all ears.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/sys/dev/usb/usb.c
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/usb/usbdi.h

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

Modified files:

Index: src/sys/dev/usb/usb.c
diff -u src/sys/dev/usb/usb.c:1.181 src/sys/dev/usb/usb.c:1.182
--- src/sys/dev/usb/usb.c:1.181	Wed Feb 12 15:59:30 2020
+++ src/sys/dev/usb/usb.c	Wed Feb 12 15:59:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 riastradh Exp $	*/
+/*	$NetBSD: usb.c,v 1.182 2020/02/12 15:59:44 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.182 2020/02/12 15:59:44 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -530,6 +530,23 @@ usb_rem_task_wait(struct usbd_device *de
 	return removed;
 }
 
+/*
+ * usb_task_pending(dev, task)
+ *
+ *	True if task is queued, false if not.  Note that if task is
+ *	already running, it is not considered queued.
+ *
+ *	For _negative_ diagnostic assertions only:
+ *
+ *		KASSERT(!usb_task_pending(dev, task));
+ */
+bool
+usb_task_pending(struct usbd_device *dev, struct usb_task *task)
+{
+
+	return task->queue != USB_NUM_TASKQS;
+}
+
 void
 usb_event_thread(void *arg)
 {

Index: src/sys/dev/usb/usbdi.h
diff -u src/sys/dev/usb/usbdi.h:1.99 src/sys/dev/usb/usbdi.h:1.100
--- src/sys/dev/usb/usbdi.h:1.99	Wed Feb 12 15:59:30 2020
+++ src/sys/dev/usb/usbdi.h	Wed Feb 12 15:59:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.h,v 1.99 2020/02/12 15:59:30 riastradh Exp $	*/
+/*	$NetBSD: usbdi.h,v 1.100 2020/02/12 15:59:44 riastradh Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $	*/
 
 /*
@@ -225,6 +225,7 @@ void usb_add_task(struct usbd_device *, 
 bool usb_rem_task(struct usbd_device *, struct usb_task *);
 bool usb_rem_task_wait(struct usbd_device *, struct usb_task *, int,
 kmutex_t *);
+bool usb_task_pending(struct usbd_device *, struct usb_task *);
 #define usb_init_task(t, f, a, fl) ((t)->fun = (f), (t)->arg = (a), (t)->queue = USB_NUM_TASKQS, (t)->flags = (fl))
 
 struct usb_devno {



CVS commit: src/sys/dev/usb

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 15:59:30 UTC 2020

Modified Files:
src/sys/dev/usb: usb.c usbdi.h

Log Message:
Teach usb_rem_task to return whether removed from queue or not.


To generate a diff of this commit:
cvs rdiff -u -r1.180 -r1.181 src/sys/dev/usb/usb.c
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/usb/usbdi.h

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



CVS commit: src/sys/dev/usb

2020-02-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 15:59:59 UTC 2020

Modified Files:
src/sys/dev/usb: usbdi.c

Log Message:
Nothing guarantees xfer's timeout has completed.

Wait for it when we free the xfer.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/dev/usb/usbdi.c

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



Re: CVS commit: src/lib/libpthread

2020-02-12 Thread Ryo ONODERA
Hi,

Kamil Rytarowski  writes:

> Hello,
>
> I will have a look at them.

Thank you.
Real fix is welcome.

And multimedia/handbrake has workaround already.
I have workaround patches for lang/mono6 (like your nspr patch).
I will commit them after some tests.

> On 12.02.2020 14:02, Ryo ONODERA wrote:
>> Hi,
>> 
>> Kamil Rytarowski  writes:
>> 
>>> Please apple workaround (same like in NSPR) for now if fixing is difficult.
>>>
>>> Such bugs can have security implications.
>> 
>> Adding workarounds will not improve security problems.
>> And I feel that such workarounds will not be accepted by upstream.
>> I will add workarounds to some packages.
>> However I feel that it is not meaningful...
>> 
>>> On 12.02.2020 09:49, Ryo ONODERA wrote:
 Hi,

 I have two problematic pkgsrc packages at least.
 Of course these programs have misuses and/or bugs, however I feel that
 dealing pt_magic in pthread_equal() is too hasty for pkgsrc.

 multimedia/handbrake (internal libbluray):
 The invalid thread pointer is not NULL.
 pthread_equal t1: 0x
 pthread_equal t2: 0x7073b25e2000

 Another one is lang/mono6:
 The invalid thread pointer is not 0x.
 pthread_equal t1: 0x7b066d4d7800
 pthread_equal t2: 0x60f5f000

 Of course, it is desirable to fix every misuses and bugs in pkgsrc.
 However it is impossible for now (at least for me).

 "Kamil Rytarowski"  writes:

> Module Name:  src
> Committed By: kamil
> Date: Sat Feb  8 17:06:03 UTC 2020
>
> Modified Files:
>   src/lib/libpthread: pthread.c
>
> Log Message:
> Change the behavior of pthread_equal()
>
> On error when not aborting, do not return EINVAL as it has a side effect
> of being interpreted as matching threads. For invalid threads return
> unmatched.
>
> Check pthreads for NULL, before accessing pt_magic field. This avoids
> faults on comparision with a NULL pointer.
>
> This behavior is in the scope of UB, but should be easier to deal with
> buggy software.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.163 -r1.164 src/lib/libpthread/pthread.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>
> Modified files:
>
> Index: src/lib/libpthread/pthread.c
> diff -u src/lib/libpthread/pthread.c:1.163 
> src/lib/libpthread/pthread.c:1.164
> --- src/lib/libpthread/pthread.c:1.163Wed Feb  5 14:56:04 2020
> +++ src/lib/libpthread/pthread.c  Sat Feb  8 17:06:03 2020
> @@ -1,4 +1,4 @@
> -/*   $NetBSD: pthread.c,v 1.163 2020/02/05 14:56:04 ryoon Exp $  
> */
> +/*   $NetBSD: pthread.c,v 1.164 2020/02/08 17:06:03 kamil Exp $  
> */
>  
>  /*-
>   * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020
> @@ -31,7 +31,7 @@
>   */
>  
>  #include 
> -__RCSID("$NetBSD: pthread.c,v 1.163 2020/02/05 14:56:04 ryoon Exp $");
> +__RCSID("$NetBSD: pthread.c,v 1.164 2020/02/08 17:06:03 kamil Exp $");
>  
>  #define  __EXPOSE_STACK  1
>  
> @@ -770,11 +770,11 @@ pthread_equal(pthread_t t1, pthread_t t2
>   if (__predict_false(__uselibcstub))
>   return __libc_thr_equal_stub(t1, t2);
>  
> - pthread__error(EINVAL, "Invalid thread",
> - t1->pt_magic == PT_MAGIC);
> + pthread__error(0, "Invalid thread",
> + (t1 != NULL) && (t1->pt_magic == PT_MAGIC));
>  
> - pthread__error(EINVAL, "Invalid thread",
> - t2->pt_magic == PT_MAGIC);
> + pthread__error(0, "Invalid thread",
> + (t2 != NULL) && (t2->pt_magic == PT_MAGIC));
>  
>   /* Nothing special here. */
>   return (t1 == t2);
>

>>>
>>>
>> 
>
>

-- 
Ryo ONODERA // r...@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


  1   2   >