CVS commit: [netbsd-8] src/sys/compat/common

2021-08-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug 15 10:03:46 UTC 2021

Modified Files:
src/sys/compat/common [netbsd-8]: vfs_syscalls_30.c vfs_syscalls_43.c
vfs_syscalls_50.c

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

sys/compat/common/vfs_syscalls_43.c: revision 1.67
sys/compat/common/vfs_syscalls_50.c: revision 1.26
sys/compat/common/vfs_syscalls_30.c: revision 1.42

- memset struct stat to avoid kernel memory disclosure of padded fields
  (thanks Trend Micro for the report)
- use do_fhstat
- consistency in argument order of compat functions


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.36.12.1 src/sys/compat/common/vfs_syscalls_30.c
cvs rdiff -u -r1.59.8.2 -r1.59.8.3 src/sys/compat/common/vfs_syscalls_43.c
cvs rdiff -u -r1.18 -r1.18.12.1 src/sys/compat/common/vfs_syscalls_50.c

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

Modified files:

Index: src/sys/compat/common/vfs_syscalls_30.c
diff -u src/sys/compat/common/vfs_syscalls_30.c:1.36 src/sys/compat/common/vfs_syscalls_30.c:1.36.12.1
--- src/sys/compat/common/vfs_syscalls_30.c:1.36	Mon Oct 20 11:58:01 2014
+++ src/sys/compat/common/vfs_syscalls_30.c	Sun Aug 15 10:03:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls_30.c,v 1.36 2014/10/20 11:58:01 christos Exp $	*/
+/*	$NetBSD: vfs_syscalls_30.c,v 1.36.12.1 2021/08/15 10:03:46 martin Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.36 2014/10/20 11:58:01 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.36.12.1 2021/08/15 10:03:46 martin Exp $");
 
 #include 
 #include 
@@ -55,7 +55,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls
 #include 
 #include 
 
-static void cvtstat(struct stat13 *, const struct stat *);
 
 /*
  * Convert from a new to an old stat structure.
@@ -64,6 +63,8 @@ static void
 cvtstat(struct stat13 *ost, const struct stat *st)
 {
 
+	/* Handle any padding. */
+	memset(ost, 0, sizeof(*ost));
 	ost->st_dev = st->st_dev;
 	ost->st_ino = (uint32_t)st->st_ino;
 	ost->st_mode = st->st_mode;
@@ -101,8 +102,7 @@ compat_30_sys___stat13(struct lwp *l, co
 	if (error)
 		return error;
 	cvtstat(&osb, &sb);
-	error = copyout(&osb, SCARG(uap, ub), sizeof (osb));
-	return error;
+	return copyout(&osb, SCARG(uap, ub), sizeof(osb));
 }
 
 
@@ -125,8 +125,7 @@ compat_30_sys___lstat13(struct lwp *l, c
 	if (error)
 		return error;
 	cvtstat(&osb, &sb);
-	error = copyout(&osb, SCARG(uap, ub), sizeof (osb));
-	return error;
+	return copyout(&osb, SCARG(uap, ub), sizeof(osb));
 }
 
 /* ARGSUSED */
@@ -140,33 +139,12 @@ compat_30_sys_fhstat(struct lwp *l, cons
 	struct stat sb;
 	struct stat13 osb;
 	int error;
-	struct compat_30_fhandle fh;
-	struct mount *mp;
-	struct vnode *vp;
-
-	/*
-	 * Must be super user
-	 */
-	if ((error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FILEHANDLE,
-	0, NULL, NULL, NULL)))
-		return (error);
 
-	if ((error = copyin(SCARG(uap, fhp), &fh, sizeof(fh))) != 0)
-		return (error);
-
-	if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL)
-		return (ESTALE);
-	if (mp->mnt_op->vfs_fhtovp == NULL)
-		return EOPNOTSUPP;
-	if ((error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, &vp)))
-		return (error);
-	error = vn_stat(vp, &sb);
-	vput(vp);
+	error = do_fhstat(l, SCARG(uap, fhp), sizeof(*SCARG(uap, fhp)), &sb);
 	if (error)
-		return (error);
+		return error;
 	cvtstat(&osb, &sb);
-	error = copyout(&osb, SCARG(uap, sb), sizeof(sb));
-	return (error);
+	return copyout(&osb, SCARG(uap, sb), sizeof(osb));
 }
 
 /*
@@ -188,8 +166,7 @@ compat_30_sys___fstat13(struct lwp *l, c
 	if (error)
 		return error;
 	cvtstat(&osb, &sb);
-	error = copyout(&osb, SCARG(uap, sb), sizeof (osb));
-	return error;
+	return copyout(&osb, SCARG(uap, sb), sizeof(osb));
 }
 
 /*
@@ -265,7 +242,7 @@ again:
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
 		if (reclen & _DIRENT_ALIGN(bdp))
-			panic("netbsd30_getdents: bad reclen %d", reclen);
+			panic("%s: bad reclen %d", __func__, reclen);
 		if (cookie)
 			off = *cookie++; /* each entry points to the next */
 		else
@@ -368,9 +345,8 @@ compat_30_sys_getfh(struct lwp *l, const
 		error = EINVAL;
 	}
 	if (error)
-		return (error);
-	error = copyout(&fh, SCARG(uap, fhp), sizeof(struct compat_30_fhandle));
-	return (error);
+		return error;
+	return copyout(&fh, SCARG(uap, fhp), sizeof(fh));
 }
 
 /*
@@ -407,8 +383,7 @@ compat_30_sys___fhstat30(struct lwp *l, 
 	if (error)
 		return error;
 	cvtstat(&osb, &sb);
-	error = copyout(&osb, SCARG(uap_30, sb), sizeof (osb));
-	return error;
+	return copyout(&osb, SCARG(uap_30, sb), sizeof(osb));
 }
 
 /* ARGSUSED */

Index: src/sys/compat/common/vfs_syscalls_43.c
diff -u src/sys/compat/common/vfs_syscalls_43.c:1.59.8.2 src/sys/compat/common/vfs_syscalls_43.c:1.59.8.3

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

2021-08-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug 11 17:24:43 UTC 2021

Modified Files:
src/sys/netinet6 [netbsd-8]: in6_src.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1690):

sys/netinet6/in6_src.c: revision 1.88

PR kern/56348

MTU discovery fails with IPv6 sockets bound to IPv4 mapped address
pick up the IPv4 route for IPv4 mapped IPv6 address to get the correct
MTU and not any unrelated/inappropriate MTU from IPv6 routes. IPv4 mapped
IPv6 addresses are always handled by the IPv4 stack and MTU discovery
is solely handled with the IPv4 routing table.


To generate a diff of this commit:
cvs rdiff -u -r1.79.6.2 -r1.79.6.3 src/sys/netinet6/in6_src.c

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

Modified files:

Index: src/sys/netinet6/in6_src.c
diff -u src/sys/netinet6/in6_src.c:1.79.6.2 src/sys/netinet6/in6_src.c:1.79.6.3
--- src/sys/netinet6/in6_src.c:1.79.6.2	Sun Dec 10 09:24:30 2017
+++ src/sys/netinet6/in6_src.c	Wed Aug 11 17:24:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_src.c,v 1.79.6.2 2017/12/10 09:24:30 snj Exp $	*/
+/*	$NetBSD: in6_src.c,v 1.79.6.3 2021/08/11 17:24:42 martin Exp $	*/
 /*	$KAME: in6_src.c,v 1.159 2005/10/19 01:40:32 t-momose Exp $	*/
 
 /*
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.79.6.2 2017/12/10 09:24:30 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.79.6.3 2021/08/11 17:24:42 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -608,6 +608,7 @@ in6_selectroute(struct sockaddr_in6 *dst
 	struct rtentry *rt = NULL;
 	union {
 		struct sockaddr		dst;
+		struct sockaddr_in	dst4;
 		struct sockaddr_in6	dst6;
 	} u;
 
@@ -674,9 +675,17 @@ in6_selectroute(struct sockaddr_in6 *dst
 	 * Use a cached route if it exists and is valid, else try to allocate
 	 * a new one.  Note that we should check the address family of the
 	 * cached destination, in case of sharing the cache with IPv4.
+	 *
+	 * for V4 mapped addresses we want to pick up the v4 route
+	 * see PR kern/56348
 	 */
-	u.dst6 = *dstsock;
-	u.dst6.sin6_scope_id = 0;
+	if (IN6_IS_ADDR_V4MAPPED(&dstsock->sin6_addr)) {
+		in6_sin6_2_sin(&u.dst4, dstsock);
+	} else {
+		u.dst6 = *dstsock;
+		u.dst6.sin6_scope_id = 0;
+	}
+
 	rt = rtcache_lookup1(*ro, &u.dst, 1);
 
 	if (rt == NULL)



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

2021-07-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jul 14 17:53:50 UTC 2021

Modified Files:
src/sys/arch/hppa/dev [netbsd-8]: sti_sgc.c

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

sys/arch/hppa/dev/sti_sgc.c: revision 1.3

Fix silent freeze on probing sti(4) framebuffer on 712/60.  PR/52162

Ok'ed by skrll@.
Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.28.1 src/sys/arch/hppa/dev/sti_sgc.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/hppa/dev/sti_sgc.c
diff -u src/sys/arch/hppa/dev/sti_sgc.c:1.1 src/sys/arch/hppa/dev/sti_sgc.c:1.1.28.1
--- src/sys/arch/hppa/dev/sti_sgc.c:1.1	Mon Feb 24 07:23:43 2014
+++ src/sys/arch/hppa/dev/sti_sgc.c	Wed Jul 14 17:53:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti_sgc.c,v 1.1 2014/02/24 07:23:43 skrll Exp $	*/
+/*	$NetBSD: sti_sgc.c,v 1.1.28.1 2021/07/14 17:53:50 martin Exp $	*/
 
 /*	$OpenBSD: sti_sgc.c,v 1.38 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.1 2014/02/24 07:23:43 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.1.28.1 2021/07/14 17:53:50 martin Exp $");
 
 #include "opt_cputype.h"
 
@@ -73,6 +73,16 @@ extern int stidebug;
 #define	STI_ROMSIZE	(sizeof(struct sti_dd) * 4)
 #define	STI_ID_FDDI	0x280b31af	/* Medusa FDDI ROM id */
 
+/*
+ * hpa addresses to check on-board variants
+ * XXX should check via device_register(9)?
+ * 
+ * 0xf400: HPA1991AC19 on 715/33, 715/50
+ * 0xf800: HPA1439A on 735/99, HPA208LCxxx on 715/80, 715/100, 712
+ */
+#define	STI_ONBOARD_HPA0	0xf400
+#define	STI_ONBOARD_HPA1	0xf800
+
 /* gecko optional graphics */
 #define	STI_GOPT1_REV	0x17
 #define	STI_GOPT2_REV	0x70
@@ -118,7 +128,9 @@ sti_sgc_getrom(struct confargs *ca)
 	rom = PAGE0->pd_resv2[1];
 	hppa_pagezero_unmap(pagezero_cookie);
 
-	if (ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC) {
+	if (ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC &&
+	ca->ca_hpa != STI_ONBOARD_HPA0 &&
+	ca->ca_hpa != STI_ONBOARD_HPA1) {
 		int i;
 		for (i = sizeof(sti_sgc_opt); i--; )
 			if (sti_sgc_opt[i] == ca->ca_type.iodc_revision)



CVS commit: [netbsd-8] src/sys

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 14:56:46 UTC 2021

Modified Files:
src/sys/rump/include/rump [netbsd-8]: rump_namei.h
src/sys/sys [netbsd-8]: namei.h

Log Message:
Regen for ticket #1685


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.6.1 src/sys/rump/include/rump/rump_namei.h
cvs rdiff -u -r1.97 -r1.97.6.1 src/sys/sys/namei.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/rump/include/rump/rump_namei.h
diff -u src/sys/rump/include/rump/rump_namei.h:1.31 src/sys/rump/include/rump/rump_namei.h:1.31.6.1
--- src/sys/rump/include/rump/rump_namei.h:1.31	Tue Mar 21 10:20:38 2017
+++ src/sys/rump/include/rump/rump_namei.h	Mon Jun 21 14:56:46 2021
@@ -1,11 +1,11 @@
-/*	$NetBSD: rump_namei.h,v 1.31 2017/03/21 10:20:38 riastradh Exp $	*/
+/*	$NetBSD: rump_namei.h,v 1.31.6.1 2021/06/21 14:56:46 martin Exp $	*/
 
 
 /*
  * WARNING: GENERATED FILE.  DO NOT EDIT
  * (edit namei.src and run make namei in src/sys/sys)
  *   by:   NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp 
- *   from: NetBSD: namei.src,v 1.41 2017/03/21 10:20:12 riastradh Exp 
+ *   from: NetBSD: namei.src,v 1.41.6.1 2021/06/21 14:55:15 martin Exp 
  */
 
 #ifndef _RUMP_RUMP_NAMEI_H_
@@ -24,7 +24,8 @@
 #define RUMP_NAMEI_NOFOLLOW	0x
 #define RUMP_NAMEI_EMULROOTSET	0x0080
 #define RUMP_NAMEI_NOCHROOT	0x0100
-#define RUMP_NAMEI_MODMASK	0x01fc
+#define RUMP_NAMEI_NONEXCLHACK	0x0200
+#define RUMP_NAMEI_MODMASK	0x03fc
 #define RUMP_NAMEI_NOCROSSMOUNT	0x100
 #define RUMP_NAMEI_RDONLY	0x200
 #define RUMP_NAMEI_ISDOTDOT	0x0002000

Index: src/sys/sys/namei.h
diff -u src/sys/sys/namei.h:1.97 src/sys/sys/namei.h:1.97.6.1
--- src/sys/sys/namei.h:1.97	Tue Mar 21 10:20:38 2017
+++ src/sys/sys/namei.h	Mon Jun 21 14:56:46 2021
@@ -1,11 +1,11 @@
-/*	$NetBSD: namei.h,v 1.97 2017/03/21 10:20:38 riastradh Exp $	*/
+/*	$NetBSD: namei.h,v 1.97.6.1 2021/06/21 14:56:46 martin Exp $	*/
 
 
 /*
  * WARNING: GENERATED FILE.  DO NOT EDIT
  * (edit namei.src and run make namei in src/sys/sys)
  *   by:   NetBSD: gennameih.awk,v 1.5 2009/12/23 14:17:19 pooka Exp 
- *   from: NetBSD: namei.src,v 1.41 2017/03/21 10:20:12 riastradh Exp 
+ *   from: NetBSD: namei.src,v 1.41.6.1 2021/06/21 14:55:15 martin Exp 
  */
 
 /*
@@ -160,7 +160,8 @@ struct nameidata {
 #define	EMULROOTSET	0x0080	/* emulation root already
 	   in ni_erootdir */
 #define	NOCHROOT	0x0100	/* no chroot on abs path lookups */
-#define	MODMASK		0x01fc	/* mask of operational modifiers */
+#define	NONEXCLHACK	0x0200	/* open wwith O_CREAT but not O_EXCL */
+#define	MODMASK		0x03fc	/* mask of operational modifiers */
 /*
  * Namei parameter descriptors.
  */
@@ -351,7 +352,8 @@ struct	nchstats _NAMEI_CACHE_STATS(uint6
 #define NAMEI_NOFOLLOW	0x
 #define NAMEI_EMULROOTSET	0x0080
 #define NAMEI_NOCHROOT	0x0100
-#define NAMEI_MODMASK	0x01fc
+#define NAMEI_NONEXCLHACK	0x0200
+#define NAMEI_MODMASK	0x03fc
 #define NAMEI_NOCROSSMOUNT	0x100
 #define NAMEI_RDONLY	0x200
 #define NAMEI_ISDOTDOT	0x0002000



CVS commit: [netbsd-8] src/sys

2021-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 21 14:55:15 UTC 2021

Modified Files:
src/sys/kern [netbsd-8]: vfs_lookup.c vfs_vnops.c
src/sys/sys [netbsd-8]: namei.src

Log Message:
Pull up following revision(s) (requested by dholland in ticket #1685):

sys/sys/namei.src: revision 1.59(via patch)
sys/kern/vfs_vnops.c: revision 1.215
sys/kern/vfs_lookup.c: revision 1.226

Add a new namei flag NONEXCLHACK for open with O_CREAT and not O_EXCL.
This case needs to be distinguished from the other CREATE operations
because it is supposed to successfully return (and open) the target if
it exists. In the case where that target is the root, or a mount
point, such that there's no parent dir, "real" CREATE operations fail,
but O_CREAT without O_EXCL needs to succeed.

So (a) add the flag, (b) test for it in namei in the situation
described above, (c) set it in open under the appropriate
circumstances, and (d) because this can result in namei returning
ni_dvp of NULL, cope with that case.

Should get into -9 and maybe even -8, because it was prompted by
issues with 3rd-party code. The use of a flag (vs. adding an
additional nameiop, which would be more appropriate) was deliberate to
make the patch small and noninvasive.


To generate a diff of this commit:
cvs rdiff -u -r1.207.2.1 -r1.207.2.2 src/sys/kern/vfs_lookup.c
cvs rdiff -u -r1.195.6.1 -r1.195.6.2 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.41 -r1.41.6.1 src/sys/sys/namei.src

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

Modified files:

Index: src/sys/kern/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.207.2.1 src/sys/kern/vfs_lookup.c:1.207.2.2
--- src/sys/kern/vfs_lookup.c:1.207.2.1	Mon Jul 10 13:02:47 2017
+++ src/sys/kern/vfs_lookup.c	Mon Jun 21 14:55:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.207.2.1 2017/07/10 13:02:47 martin Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.207.2.2 2021/06/21 14:55:15 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.207.2.1 2017/07/10 13:02:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.207.2.2 2021/06/21 14:55:15 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_magiclinks.h"
@@ -1402,10 +1402,33 @@ namei_oneroot(struct namei_state *state,
 		 * a CREATE, DELETE, or RENAME), and we don't have one
 		 * (because this is the root directory, or we crossed
 		 * a mount point), then we must fail.
+		 *
+		 * 20210604 dholland when NONEXCLHACK is set (open
+		 * with O_CREAT but not O_EXCL) skip this logic. Since
+		 * we have a foundobj, open will not be creating, so
+		 * it doesn't actually need or use the searchdir, so
+		 * it's ok to return it even if it's on a different
+		 * volume, and it's also ok to return NULL; by setting
+		 * NONEXCLHACK the open code promises to cope with
+		 * those cases correctly. (That is, it should do what
+		 * it would do anyway, that is, just release the
+		 * searchdir, except not crash if it's null.) This is
+		 * needed because otherwise opening mountpoints with
+		 * O_CREAT but not O_EXCL fails... which is a silly
+		 * thing to do but ought to work. (This whole issue
+		 * came to light because 3rd party code wanted to open
+		 * certain procfs nodes with O_CREAT for some 3rd
+		 * party reason, and it failed.)
+		 *
+		 * Note that NONEXCLHACK is properly a different
+		 * nameiop (it is partway between LOOKUP and CREATE)
+		 * but it was stuffed in as a flag instead to make the
+		 * resulting patch less invasive for pullup. Blah.
 		 */
 		if (cnp->cn_nameiop != LOOKUP &&
 		(searchdir == NULL ||
-		 searchdir->v_mount != foundobj->v_mount)) {
+		 searchdir->v_mount != foundobj->v_mount) &&
+		(cnp->cn_flags & NONEXCLHACK) == 0) {
 			if (searchdir) {
 vput(searchdir);
 			}

Index: src/sys/kern/vfs_vnops.c
diff -u src/sys/kern/vfs_vnops.c:1.195.6.1 src/sys/kern/vfs_vnops.c:1.195.6.2
--- src/sys/kern/vfs_vnops.c:1.195.6.1	Thu Apr 12 01:45:57 2018
+++ src/sys/kern/vfs_vnops.c	Mon Jun 21 14:55:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnops.c,v 1.195.6.1 2018/04/12 01:45:57 msaitoh Exp $	*/
+/*	$NetBSD: vfs_vnops.c,v 1.195.6.2 2021/06/21 14:55:15 martin Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.195.6.1 2018/04/12 01:45:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.195.6.2 2021/06/21 14:55:15 martin Exp $");
 
 #include "veriexec.h"
 
@@ -160,6 +160,8 @@ vn_open(struct nameidata *ndp, int fmode
 		if ((fmode & O_EXCL) == 0 &&
 		((fmode & O_NOFOLLOW) == 0))
 			ndp->ni_cnd.cn_flags |= FOLLOW;
+		if ((fmode & O_EXCL) == 0)
+			ndp->ni_cnd.cn_flags |= NONEXCLHACK;
 	} else {
 		ndp->ni_cnd.cn_nameiop = LOOKUP;
 		ndp->ni_cnd.cn_flags |= LOCKLEAF;
@@ -182,7 +184,12 @@ vn_open(struct nameid

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

2021-06-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun  5 10:57:11 UTC 2021

Modified Files:
src/sys/dev/pci [netbsd-8]: if_iwmreg.h

Log Message:
Pull up following revision(s) (requested by nia in ticket #1682):

sys/dev/pci/if_iwmreg.h: revision 1.8

Can't left shift a signed int by 31. Found by kubsan.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.6.1 src/sys/dev/pci/if_iwmreg.h

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

Modified files:

Index: src/sys/dev/pci/if_iwmreg.h
diff -u src/sys/dev/pci/if_iwmreg.h:1.6 src/sys/dev/pci/if_iwmreg.h:1.6.6.1
--- src/sys/dev/pci/if_iwmreg.h:1.6	Tue Mar 14 23:59:26 2017
+++ src/sys/dev/pci/if_iwmreg.h	Sat Jun  5 10:57:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwmreg.h,v 1.6 2017/03/14 23:59:26 nonaka Exp $	*/
+/*	$NetBSD: if_iwmreg.h,v 1.6.6.1 2021/06/05 10:57:11 martin Exp $	*/
 /*	OpenBSD: if_iwmreg.h,v 1.19 2016/09/20 11:46:09 stsp Exp 	*/
 
 /*-
@@ -191,7 +191,7 @@
 
 /* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
  * acknowledged (reset) by host writing "1" to flagged bits. */
-#define IWM_CSR_INT_BIT_FH_RX	(1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
+#define IWM_CSR_INT_BIT_FH_RX	(1U << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
 #define IWM_CSR_INT_BIT_HW_ERR	(1 << 29) /* DMA hardware error FH_INT[31] */
 #define IWM_CSR_INT_BIT_RX_PERIODIC	(1 << 28) /* Rx periodic */
 #define IWM_CSR_INT_BIT_FH_TX	(1 << 27) /* Tx DMA FH_INT[1:0] */
@@ -214,7 +214,7 @@
  IWM_CSR_INT_BIT_RX_PERIODIC)
 
 /* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
-#define IWM_CSR_FH_INT_BIT_ERR   (1 << 31) /* Error */
+#define IWM_CSR_FH_INT_BIT_ERR   (1U << 31) /* Error */
 #define IWM_CSR_FH_INT_BIT_HI_PRIOR  (1 << 30) /* High priority Rx, bypass coalescing */
 #define IWM_CSR_FH_INT_BIT_RX_CHNL1  (1 << 17) /* Rx channel 1 */
 #define IWM_CSR_FH_INT_BIT_RX_CHNL0  (1 << 16) /* Rx channel 0 */
@@ -405,7 +405,7 @@
 #define IWM_CSR_DBG_HPET_MEM_REG_VAL	(0x)
 
 /* DRAM INT TABLE */
-#define IWM_CSR_DRAM_INT_TBL_ENABLE		(1 << 31)
+#define IWM_CSR_DRAM_INT_TBL_ENABLE		(1U << 31)
 #define IWM_CSR_DRAM_INIT_TBL_WRITE_POINTER	(1 << 28)
 #define IWM_CSR_DRAM_INIT_TBL_WRAP_CHECK	(1 << 27)
 
@@ -558,7 +558,7 @@ enum iwm_secure_load_status_reg {
 #define IWM_HOST_INT_TIMEOUT_MAX	(0xFF)
 #define IWM_HOST_INT_TIMEOUT_DEF	(0x40)
 #define IWM_HOST_INT_TIMEOUT_MIN	(0x0)
-#define IWM_HOST_INT_OPER_MODE		(1 << 31)
+#define IWM_HOST_INT_OPER_MODE		(1U << 31)
 
 /*
  *7000/3000 series SHR DTS addresses *
@@ -643,7 +643,7 @@ enum iwm_ucode_tlv_flag {
 	IWM_UCODE_TLV_FLAGS_P2P_PS_UAPSD	= (1 << 26),
 	IWM_UCODE_TLV_FLAGS_BCAST_FILTERING	= (1 << 29),
 	IWM_UCODE_TLV_FLAGS_GO_UAPSD		= (1 << 30),
-	IWM_UCODE_TLV_FLAGS_LTE_COEX		= (1 << 31),
+	IWM_UCODE_TLV_FLAGS_LTE_COEX		= (1U << 31),
 };
 #define IWM_UCODE_TLV_FLAG_BITS \
 	"\020\1PAN\2NEWSCAN\3MFP\4P2P\5DW_BC_TABLE\6NEWBT_COEX\7PM_CMD\10SHORT_BL\11RX_ENERGY\12TIME_EVENT_V2\13D3_6_IPV6\14BF_UPDATED\15NO_BASIC_SSID\17D3_CONTINUITY\20NEW_NSOFFL_S\21NEW_NSOFFL_L\22SCHED_SCAN\24STA_KEY_CMD\25DEVICE_PS_CMD\26P2P_PS\27P2P_PS_DCM\30P2P_PS_SCM\31UAPSD_SUPPORT\32EBS\33P2P_PS_UAPSD\36BCAST_FILTERING\37GO_UAPSD\40LTE_COEX"
@@ -4369,7 +4369,7 @@ enum iwm_tx_flags {
 	IWM_TX_CMD_FLG_FW_DROP		= (1 << 26),
 	IWM_TX_CMD_FLG_EXEC_PAPD	= (1 << 27),
 	IWM_TX_CMD_FLG_PAPD_TYPE	= (1 << 28),
-	IWM_TX_CMD_FLG_HCCA_CHUNK	= (1 << 31)
+	IWM_TX_CMD_FLG_HCCA_CHUNK	= (1U << 31)
 }; /* IWM_TX_FLAGS_BITS_API_S_VER_1 */
 
 /**



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

2021-06-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun  5 10:37:10 UTC 2021

Modified Files:
src/sys/arch/hp300/conf [netbsd-8]: INSTALL

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

sys/arch/hp300/conf/INSTALL: revision 1.67
sys/arch/hp300/conf/INSTALL: revision 1.68

Add missed 'nhpib at intio' for internal HP-IB.  Found on testing HPDisk.
Also fix comments for HP-IB devices.
Should be pulled up to netbsd-8 and netbsd-9.

Reduce maxusers to 8 as GENERIC.
Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.60.12.1 src/sys/arch/hp300/conf/INSTALL

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/hp300/conf/INSTALL
diff -u src/sys/arch/hp300/conf/INSTALL:1.60 src/sys/arch/hp300/conf/INSTALL:1.60.12.1
--- src/sys/arch/hp300/conf/INSTALL:1.60	Sat Aug 23 20:26:58 2014
+++ src/sys/arch/hp300/conf/INSTALL	Sat Jun  5 10:37:10 2021
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.60 2014/08/23 20:26:58 dholland Exp $
+# $NetBSD: INSTALL,v 1.60.12.1 2021/06/05 10:37:10 martin Exp $
 #
 # INSTALL machine description file
 #
@@ -39,7 +39,7 @@ options 	HP433
 options 	FPSP		# floating point interface for 68040
 
 # Need to set locally
-maxusers	32
+maxusers	8
 
 # Standard system options
 #options 	COMPAT_43	# compatibility with 4.3BSD interfaces
@@ -202,10 +202,11 @@ dcm*		at dio? scode ?	flags 0xe # DCM 4-
 
 le*		at dio? scode ?		# LANCE ethernet interfaces
 
-nhpib0		at dio? scode 7		# slow internal HP-IB
+nhpib*		at intio?		# internal HP-IB
+nhpib0		at dio? scode 7		# 98624A HP-IB
 nhpib*		at dio? scode ?
 
-fhpib*		at dio? scode ?		# `fast' HP-IB
+fhpib*		at dio? scode ?		# 98625A/98625B HP-IB
 
 hpibbus0	at nhpib0
 hpibbus*	at nhpib?



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

2021-05-03 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon May  3 09:15:31 UTC 2021

Modified Files:
src/sys/kern [netbsd-8]: kern_exec.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #1677):
sys/kern/kern_exec.c: revision 1.505 via patch
Fix copy&pasto in handling of POSIX_SPAWN_RESETIDS in posix_spawn(3)


To generate a diff of this commit:
cvs rdiff -u -r1.442.4.7 -r1.442.4.8 src/sys/kern/kern_exec.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_exec.c
diff -u src/sys/kern/kern_exec.c:1.442.4.7 src/sys/kern/kern_exec.c:1.442.4.8
--- src/sys/kern/kern_exec.c:1.442.4.7	Mon Aug  5 14:47:49 2019
+++ src/sys/kern/kern_exec.c	Mon May  3 09:15:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.442.4.7 2019/08/05 14:47:49 martin Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.442.4.8 2021/05/03 09:15:30 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.7 2019/08/05 14:47:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.8 2021/05/03 09:15:30 bouyer Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -2143,7 +2143,7 @@ spawn_return(void *arg)
 
 		/* Reset user ID's */
 		if (spawn_data->sed_attrs->sa_flags & POSIX_SPAWN_RESETIDS) {
-			error = do_setresuid(l, -1,
+			error = do_setresgid(l, -1,
 			 kauth_cred_getgid(l->l_cred), -1,
 			 ID_E_EQ_R | ID_E_EQ_S);
 			if (error)



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

2021-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Apr 30 14:22:24 UTC 2021

Modified Files:
src/sys/arch/xen/x86 [netbsd-8]: xen_ipi.c

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

sys/arch/xen/x86/xen_ipi.c: revision 1.24 (patch)

make compile without DDB
PR port-xen/50282


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.20.10.1 src/sys/arch/xen/x86/xen_ipi.c

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

Modified files:

Index: src/sys/arch/xen/x86/xen_ipi.c
diff -u src/sys/arch/xen/x86/xen_ipi.c:1.20 src/sys/arch/xen/x86/xen_ipi.c:1.20.10.1
--- src/sys/arch/xen/x86/xen_ipi.c:1.20	Thu Jul  7 06:55:40 2016
+++ src/sys/arch/xen/x86/xen_ipi.c	Fri Apr 30 14:22:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_ipi.c,v 1.20 2016/07/07 06:55:40 msaitoh Exp $ */
+/* $NetBSD: xen_ipi.c,v 1.20.10.1 2021/04/30 14:22:24 martin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -33,10 +33,12 @@
 
 /* 
  * Based on: x86/ipi.c
- * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.20 2016/07/07 06:55:40 msaitoh Exp $");
+ * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.20.10.1 2021/04/30 14:22:24 martin Exp $");
  */
 
-__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.20 2016/07/07 06:55:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.20.10.1 2021/04/30 14:22:24 martin Exp $");
+
+#include "opt_ddb.h"
 
 #include 
 
@@ -59,15 +61,17 @@ __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 
 #include 
 #include 
 
+#ifdef DDB
 #ifdef __x86_64__
 extern void ddb_ipi(struct trapframe);
 #else
 extern void ddb_ipi(int, struct trapframe);
 #endif /* __x86_64__ */
+static void xen_ipi_ddb(struct cpu_info *, struct intrframe *);
+#endif
 
 static void xen_ipi_halt(struct cpu_info *, struct intrframe *);
 static void xen_ipi_synch_fpu(struct cpu_info *, struct intrframe *);
-static void xen_ipi_ddb(struct cpu_info *, struct intrframe *);
 static void xen_ipi_xcall(struct cpu_info *, struct intrframe *);
 static void xen_ipi_hvcb(struct cpu_info *, struct intrframe *);
 static void xen_ipi_generic(struct cpu_info *, struct intrframe *);
@@ -76,7 +80,11 @@ static void (*ipifunc[XEN_NIPIS])(struct
 {	/* In order of priority (see: xen/include/intrdefs.h */
 	xen_ipi_halt,
 	xen_ipi_synch_fpu,
+#ifdef DDB
 	xen_ipi_ddb,
+#else
+	NULL,
+#endif
 	xen_ipi_xcall,
 	xen_ipi_hvcb,
 	xen_ipi_generic,
@@ -226,6 +234,7 @@ xen_ipi_synch_fpu(struct cpu_info *ci, s
 	fpusave_cpu(true);
 }
 
+#ifdef DDB
 static void
 xen_ipi_ddb(struct cpu_info *ci, struct intrframe *intrf)
 {
@@ -264,6 +273,7 @@ xen_ipi_ddb(struct cpu_info *ci, struct 
 	ddb_ipi(SEL_KPL, tf);
 #endif
 }
+#endif /* DDB */
 
 static void
 xen_ipi_xcall(struct cpu_info *ci, struct intrframe *intrf)



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

2021-03-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 27 13:10:45 UTC 2021

Modified Files:
src/sys/dev/usb [netbsd-8]: usbdevs.h usbdevs_data.h

Log Message:
Regen for ticket #1667 (BELKIN F5D7050E fix)


To generate a diff of this commit:
cvs rdiff -u -r1.727.2.6 -r1.727.2.7 src/sys/dev/usb/usbdevs.h
cvs rdiff -u -r1.728.2.6 -r1.728.2.7 src/sys/dev/usb/usbdevs_data.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/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.727.2.6 src/sys/dev/usb/usbdevs.h:1.727.2.7
--- src/sys/dev/usb/usbdevs.h:1.727.2.6	Thu Feb 27 14:34:11 2020
+++ src/sys/dev/usb/usbdevs.h	Sat Mar 27 13:10:43 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.727.2.6 2020/02/27 14:34:11 martin Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.727.2.7 2021/03/27 13:10:43 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.736.2.6 2020/02/27 14:32:31 martin Exp
+ *	NetBSD: usbdevs,v 1.736.2.7 2021/03/27 13:09:46 martin Exp
  */
 
 /*-
@@ -1087,7 +1087,7 @@
 #define	USB_PRODUCT_BELKIN_F5D7051	0x7051		/* F5D7051 54g USB Network Adapter */
 #define	USB_PRODUCT_BELKIN_F5D7050A	0x705a		/* F5D705A 54g USB Network Adapter */
 #define	USB_PRODUCT_BELKIN_F5D7050C	0x705c		/* F5D705C 54g USB Network Adapter */
-#define	USB_PRODUCT_BELKIN_F5D7050E	0x705c		/* F5D705E 54g USB Network Adapter */
+#define	USB_PRODUCT_BELKIN_F5D7050E	0x705e		/* F5D705E 54g USB Network Adapter */
 #define	USB_PRODUCT_BELKIN_RT2870_1	0x8053		/* RT2870 */
 #define	USB_PRODUCT_BELKIN_RT2870_2	0x805c		/* RT2870 */
 #define	USB_PRODUCT_BELKIN_F5D8053V3	0x815c		/* F5D8053 v3 */

Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.728.2.6 src/sys/dev/usb/usbdevs_data.h:1.728.2.7
--- src/sys/dev/usb/usbdevs_data.h:1.728.2.6	Thu Feb 27 14:34:11 2020
+++ src/sys/dev/usb/usbdevs_data.h	Sat Mar 27 13:10:43 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.728.2.6 2020/02/27 14:34:11 martin Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.728.2.7 2021/03/27 13:10:43 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.736.2.6 2020/02/27 14:32:31 martin Exp
+ *	NetBSD: usbdevs,v 1.736.2.7 2021/03/27 13:09:46 martin Exp
  */
 
 /*-



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

2021-03-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 27 13:09:46 UTC 2021

Modified Files:
src/sys/dev/usb [netbsd-8]: usbdevs

Log Message:
Pull up following revision(s) (requested by nia in ticket #1667):

sys/dev/usb/usbdevs: revision 1.793

correct usb device id for BELKIN F5D7050E

matches freebsd / openbsd (sources of urtw driver), various online
sources

PR kern/56056


To generate a diff of this commit:
cvs rdiff -u -r1.736.2.6 -r1.736.2.7 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.736.2.6 src/sys/dev/usb/usbdevs:1.736.2.7
--- src/sys/dev/usb/usbdevs:1.736.2.6	Thu Feb 27 14:32:31 2020
+++ src/sys/dev/usb/usbdevs	Sat Mar 27 13:09:46 2021
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.736.2.6 2020/02/27 14:32:31 martin Exp $
+$NetBSD: usbdevs,v 1.736.2.7 2021/03/27 13:09:46 martin Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1080,7 +1080,7 @@ product BELKIN F5D7050		0x7050	F5D7050 5
 product BELKIN F5D7051		0x7051	F5D7051 54g USB Network Adapter
 product BELKIN F5D7050A		0x705a	F5D705A 54g USB Network Adapter
 product BELKIN F5D7050C		0x705c	F5D705C 54g USB Network Adapter
-product BELKIN F5D7050E		0x705c	F5D705E 54g USB Network Adapter
+product BELKIN F5D7050E		0x705e	F5D705E 54g USB Network Adapter
 product BELKIN RT2870_1		0x8053	RT2870
 product BELKIN RT2870_2		0x805c	RT2870
 product BELKIN F5D8053V3	0x815c	F5D8053 v3



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

2021-03-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar 22 18:07:38 UTC 2021

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

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

sys/net/if_l2tp.h: revision 1.10

Fix l2tp(4) ioctl type. Pointed out by yamaguchi@n.o, thanks.
XXX pullup-[89]


To generate a diff of this commit:
cvs rdiff -u -r1.2.2.4 -r1.2.2.5 src/sys/net/if_l2tp.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/net/if_l2tp.h
diff -u src/sys/net/if_l2tp.h:1.2.2.4 src/sys/net/if_l2tp.h:1.2.2.5
--- src/sys/net/if_l2tp.h:1.2.2.4	Tue Sep 24 18:27:09 2019
+++ src/sys/net/if_l2tp.h	Mon Mar 22 18:07:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_l2tp.h,v 1.2.2.4 2019/09/24 18:27:09 martin Exp $	*/
+/*	$NetBSD: if_l2tp.h,v 1.2.2.5 2021/03/22 18:07:38 martin Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -44,11 +44,11 @@
 #include 
 #include 
 
-#define	SIOCSL2TPSESSION	_IOW('i', 151, struct l2tp_req)
-#define	SIOCDL2TPSESSION	_IOW('i', 152, struct l2tp_req)
-#define	SIOCSL2TPCOOKIE		_IOW('i', 153, struct l2tp_req)
-#define	SIOCDL2TPCOOKIE		_IOW('i', 154, struct l2tp_req)
-#define	SIOCSL2TPSTATE		_IOW('i', 155, struct l2tp_req)
+#define	SIOCSL2TPSESSION	_IOW('i', 151, struct ifreq)
+#define	SIOCDL2TPSESSION	_IOW('i', 152, struct ifreq)
+#define	SIOCSL2TPCOOKIE		_IOW('i', 153, struct ifreq)
+#define	SIOCDL2TPCOOKIE		_IOW('i', 154, struct ifreq)
+#define	SIOCSL2TPSTATE		_IOW('i', 155, struct ifreq)
 #define	SIOCGL2TP		SIOCGIFGENERIC
 
 struct l2tp_req {



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

2021-03-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar  9 15:56:51 UTC 2021

Modified Files:
src/sys/netinet [netbsd-8]: in_var.h tcp_subr.c tcp_timer.c

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

sys/netinet/tcp_subr.c: revision 1.286
sys/netinet/tcp_timer.c: revision 1.96
sys/netinet/in_var.h: revision 1.102
sys/netinet/in_var.h: revision 1.99

Don't increment the iss sequence on each connection because it exposes
information (Amit Klein)

Add some randomness to the iss offset

Use a random IPv4 ID because the shuffling algorithm used before could expose
information (Amit Klein)

mv  include to the kernel portion


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.95.2.1 src/sys/netinet/in_var.h
cvs rdiff -u -r1.270.6.2 -r1.270.6.3 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.91.8.1 -r1.91.8.2 src/sys/netinet/tcp_timer.c

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

Modified files:

Index: src/sys/netinet/in_var.h
diff -u src/sys/netinet/in_var.h:1.95 src/sys/netinet/in_var.h:1.95.2.1
--- src/sys/netinet/in_var.h:1.95	Fri May 12 17:53:54 2017
+++ src/sys/netinet/in_var.h	Tue Mar  9 15:56:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_var.h,v 1.95 2017/05/12 17:53:54 ryo Exp $	*/
+/*	$NetBSD: in_var.h,v 1.95.2.1 2021/03/09 15:56:51 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -374,6 +374,7 @@ struct in_multi {
 #ifdef _KERNEL
 
 #include 
+#include 
 
 extern pktqueue_t *ip_pktq;
 
@@ -450,7 +451,8 @@ ip_newid_range(const struct in_ifaddr *i
 
 	if (ip_do_randomid) {
 		/* XXX ignore num */
-		return ip_randomid(ip_ids, ia ? ia->ia_idsalt : 0);
+		id = (uint16_t)cprng_fast32();
+		return id ? id : 1;
 	}
 
 	/* Never allow an IP ID of 0 (detect wrap). */

Index: src/sys/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.270.6.2 src/sys/netinet/tcp_subr.c:1.270.6.3
--- src/sys/netinet/tcp_subr.c:1.270.6.2	Sun Mar  7 19:13:24 2021
+++ src/sys/netinet/tcp_subr.c	Tue Mar  9 15:56:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_subr.c,v 1.270.6.2 2021/03/07 19:13:24 martin Exp $	*/
+/*	$NetBSD: tcp_subr.c,v 1.270.6.3 2021/03/09 15:56:51 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.270.6.2 2021/03/07 19:13:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.270.6.3 2021/03/09 15:56:51 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2301,7 +2301,6 @@ tcp_new_iss1(void *laddr, void *faddr, u
 		 * XXX Use `addin'?
 		 * XXX TCP_ISSINCR too large to use?
 		 */
-		tcp_iss_seq += TCP_ISSINCR;
 #ifdef TCPISS_DEBUG
 		printf("ISS hash 0x%08x, ", tcp_iss);
 #endif
@@ -2337,7 +2336,6 @@ tcp_new_iss1(void *laddr, void *faddr, u
 		} else {
 			tcp_iss &= TCP_ISS_RANDOM_MASK;
 			tcp_iss += tcp_iss_seq;
-			tcp_iss_seq += TCP_ISSINCR;
 #ifdef TCPISS_DEBUG
 			printf("ISS %08x\n", tcp_iss);
 #endif

Index: src/sys/netinet/tcp_timer.c
diff -u src/sys/netinet/tcp_timer.c:1.91.8.1 src/sys/netinet/tcp_timer.c:1.91.8.2
--- src/sys/netinet/tcp_timer.c:1.91.8.1	Sat Feb  3 22:07:26 2018
+++ src/sys/netinet/tcp_timer.c	Tue Mar  9 15:56:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_timer.c,v 1.91.8.1 2018/02/03 22:07:26 snj Exp $	*/
+/*	$NetBSD: tcp_timer.c,v 1.91.8.2 2021/03/09 15:56:51 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.91.8.1 2018/02/03 22:07:26 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.91.8.2 2021/03/09 15:56:51 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -111,6 +111,7 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -261,7 +262,7 @@ tcp_slowtimo_work(struct work *wk, void 
 {
 
 	mutex_enter(softnet_lock);
-	tcp_iss_seq += TCP_ISSINCR;			/* increment iss */
+	tcp_iss_seq += TCP_ISSINCR + (TCP_ISS_RANDOM_MASK & cprng_fast32());
 	tcp_now++;	/* for timestamps */
 	mutex_exit(softnet_lock);
 



CVS commit: [netbsd-8] src/sys

2021-03-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  7 19:13:24 UTC 2021

Modified Files:
src/sys/netinet [netbsd-8]: ip6.h ip_input.c tcp_subr.c
src/sys/netinet6 [netbsd-8]: ip6_id.c ip6_var.h

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

sys/netinet6/ip6_id.c: revision 1.19-1.21
sys/netinet6/ip6_var.h: revision 1.88
sys/netinet/ip_input.c: revision 1.400
sys/netinet/tcp_subr.c: revision 1.285
sys/netinet/ip6.h: revision 1.30

netinet: Enable random IP fragment ids by default (from riastradh)

netinet: Enable RFC 1948 pseudorandom TCP ISS selection by default.
(from riastradh)

netinet6: Mark randomid unused.

Will make merging and bisection easier if anything goes wrong with
flow label or fragment id randomization changes.
(from riastradh)

netinet/netinet6: Add necessary includes to make these standalone.
(from riastradh)

Replace randomid() by cprng_fast32()


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.23.90.1 src/sys/netinet/ip6.h
cvs rdiff -u -r1.355.2.8 -r1.355.2.9 src/sys/netinet/ip_input.c
cvs rdiff -u -r1.270.6.1 -r1.270.6.2 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.18 -r1.18.10.1 src/sys/netinet6/ip6_id.c
cvs rdiff -u -r1.74.6.3 -r1.74.6.4 src/sys/netinet6/ip6_var.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/netinet/ip6.h
diff -u src/sys/netinet/ip6.h:1.23 src/sys/netinet/ip6.h:1.23.90.1
--- src/sys/netinet/ip6.h:1.23	Tue Dec 25 18:33:46 2007
+++ src/sys/netinet/ip6.h	Sun Mar  7 19:13:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6.h,v 1.23 2007/12/25 18:33:46 perry Exp $	*/
+/*	$NetBSD: ip6.h,v 1.23.90.1 2021/03/07 19:13:24 martin Exp $	*/
 /*	$KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $	*/
 
 /*
@@ -64,6 +64,11 @@
 #ifndef _NETINET_IP6_H_
 #define _NETINET_IP6_H_
 
+#include 
+#include 
+
+#include 
+
 /*
  * Definition for internet protocol version 6.
  * RFC 2460

Index: src/sys/netinet/ip_input.c
diff -u src/sys/netinet/ip_input.c:1.355.2.8 src/sys/netinet/ip_input.c:1.355.2.9
--- src/sys/netinet/ip_input.c:1.355.2.8	Tue Sep 24 18:27:10 2019
+++ src/sys/netinet/ip_input.c	Sun Mar  7 19:13:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.355.2.8 2019/09/24 18:27:10 martin Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.355.2.9 2021/03/07 19:13:24 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.355.2.8 2019/09/24 18:27:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.355.2.9 2021/03/07 19:13:24 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -202,7 +202,7 @@ int	ip_mtudisc_timeout = IPMTUDISCTIMEOU
 int	ipprintfs = 0;
 #endif
 
-int	ip_do_randomid = 0;
+int	ip_do_randomid = 1;
 
 /*
  * XXX - Setting ip_checkinterface mostly implements the receive side of

Index: src/sys/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.270.6.1 src/sys/netinet/tcp_subr.c:1.270.6.2
--- src/sys/netinet/tcp_subr.c:1.270.6.1	Sat Feb  3 22:07:26 2018
+++ src/sys/netinet/tcp_subr.c	Sun Mar  7 19:13:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_subr.c,v 1.270.6.1 2018/02/03 22:07:26 snj Exp $	*/
+/*	$NetBSD: tcp_subr.c,v 1.270.6.2 2021/03/07 19:13:24 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.270.6.1 2018/02/03 22:07:26 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.270.6.2 2021/03/07 19:13:24 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -169,7 +169,7 @@ int 	tcp_mssdflt = TCP_MSS;
 int	tcp_minmss = TCP_MINMSS;
 int 	tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
 int	tcp_do_rfc1323 = 1;	/* window scaling / timestamps (obsolete) */
-int	tcp_do_rfc1948 = 0;	/* ISS by cryptographic hash */
+int	tcp_do_rfc1948 = 1;	/* ISS by cryptographic hash */
 int	tcp_do_sack = 1;	/* selective acknowledgement */
 int	tcp_do_win_scale = 1;	/* RFC1323 window scaling */
 int	tcp_do_timestamps = 1;	/* RFC1323 timestamps */

Index: src/sys/netinet6/ip6_id.c
diff -u src/sys/netinet6/ip6_id.c:1.18 src/sys/netinet6/ip6_id.c:1.18.10.1
--- src/sys/netinet6/ip6_id.c:1.18	Fri Aug  7 08:11:33 2015
+++ src/sys/netinet6/ip6_id.c	Sun Mar  7 19:13:23 2021
@@ -1,9 +1,7 @@
-/*	$NetBSD: ip6_id.c,v 1.18 2015/08/07 08:11:33 ozaki-r Exp $	*/
-/*	$KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $	*/
-/*	$OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $	*/
+/*	$NetBSD: ip6_id.c,v 1.18.10.1 2021/03/07 19:13:23 martin Exp $	*/
 
-/*
- * Copyright (C) 2003 WIDE Project.
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,241 +12,38 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of con

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

2021-02-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 25 09:38:48 UTC 2021

Modified Files:
src/sys/arch/m68k/m68k [netbsd-8]: reenter_syscall.s

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

sys/arch/m68k/m68k/reenter_syscall.s: revision 1.5
sys/arch/m68k/m68k/reenter_syscall.s: revision 1.6
sys/arch/m68k/m68k/reenter_syscall.s: revision 1.7

Replace magic numbers with proper macros prepared in assym.h.

No binary changes.

Note this is a preparation for a possible fix of PR port-m68k/55990.

Consistently use motorola style.  No binary changes.
Seems missed in rev 1.3:
 https://mail-index.netbsd.org/source-changes/2013/08/01/msg046378.html

Plug kernel stack leaks in reenter_syscall() for setcontext(2).
This fixes long standing kernel crashes (MMU fault, address error,
and silent freeze by a double bus fault etc. seen for ~10 years)
caused by kernel stack overflow, especially on x68k and sun3 running
Xorg based servers.  See PR/55990 for more details.

"This change seems perfectly reasonable" from thorpej@ and
jklos@ also reported this also solved freeze of his mac68k system
with 10 megabyes of memory.

Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.22.1 src/sys/arch/m68k/m68k/reenter_syscall.s

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

Modified files:

Index: src/sys/arch/m68k/m68k/reenter_syscall.s
diff -u src/sys/arch/m68k/m68k/reenter_syscall.s:1.4 src/sys/arch/m68k/m68k/reenter_syscall.s:1.4.22.1
--- src/sys/arch/m68k/m68k/reenter_syscall.s:1.4	Sat Sep  7 19:06:29 2013
+++ src/sys/arch/m68k/m68k/reenter_syscall.s	Thu Feb 25 09:38:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: reenter_syscall.s,v 1.4 2013/09/07 19:06:29 chs Exp $	*/
+/*	$NetBSD: reenter_syscall.s,v 1.4.22.1 2021/02/25 09:38:48 martin Exp $	*/
 
 /*
  * Written by ITOH Yasufumi.
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include "assym.h"
 
 /*
  * void reenter_syscall(struct frame *fp, int stkadj)
@@ -38,18 +39,31 @@ ENTRY_NOPROFILE(reenter_syscall)
 .Lcpfr:	movel	(%a0)+,(%a1)+
 	dbra	%d0,.Lcpfr
 
-	movew	%d1,%sp@(16*4+2)	| set stack adjust count
+	movew	%d1,FR_ADJ(%sp)		| set stack adjust count
 	movel	(%sp),-(%sp)		| push syscall no (original d0 value)
 	jbsr	_C_LABEL(syscall)	| re-enter syscall()
 	addql	#4,%sp			| pop syscall no
 #ifdef DEBUG
-	tstw	%sp@(16*4+2)		| stack adjust must be zero
+	tstw	FR_ADJ(%sp)		| stack adjust must be zero
 	jeq	.Ladjzero
 	PANIC("reenter_syscall")
 .Ladjzero:
 #endif
-	moveal	%sp@(15*4),%a0		| grab and restore
+	moveal	FR_SP(%sp),%a0		| grab and restore
 	movel	%a0,%usp		|   user SP
+	movw	FR_ADJ(%sp),%d0		| need to adjust stack?
+	jne	.Ladjstk		| yes, go to it
 	moveml	(%sp)+,#0x7FFF		| restore user registers
 	addql	#8,%sp			| pop SP and stack adjust
 	jra	_ASM_LABEL(rei)		| rte
+.Ladjstk:
+	lea	FR_HW(%sp),%a1		| pointer to HW frame
+	addql	#8,%a1			| source pointer
+	movl	%a1,%a0			| source
+	addw	%d0,%a0			|  + hole size = dest pointer
+	movl	-(%a1),-(%a0)		| copy
+	movl	-(%a1),-(%a0)		|  8 bytes
+	movl	%a0,FR_SP(%sp)		| new SSP
+	moveml	(%sp)+,#0x7FFF		| restore user register
+	movl	(%sp),%sp		| and do real RTE
+	jra	_ASM_LABEL(rei)		| rte



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

2021-02-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Feb 19 17:49:19 UTC 2021

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

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

sys/arch/x86/x86/intr.c: revision 1.154 (via patch)

Fix x86's pci_intr_disestablish clean up routine.  Pointed out by t-kusaba@IIJ, 
thanks.

Fix panic on x86 by the following code.


sc_ih = pci_intr_establish_xname(sc_pc, ...);
pci_intr_disestablish(sc_pc, sc_ih);
sc_ih = pci_intr_establish(sc_pc, ...);


ena(4) do such processing when ifconfig down/up.

XXX pullup-8,9


To generate a diff of this commit:
cvs rdiff -u -r1.101.2.7 -r1.101.2.8 src/sys/arch/x86/x86/intr.c

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

Modified files:

Index: src/sys/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.101.2.7 src/sys/arch/x86/x86/intr.c:1.101.2.8
--- src/sys/arch/x86/x86/intr.c:1.101.2.7	Thu Nov 14 15:58:06 2019
+++ src/sys/arch/x86/x86/intr.c	Fri Feb 19 17:49:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.101.2.7 2019/11/14 15:58:06 martin Exp $	*/
+/*	$NetBSD: intr.c,v 1.101.2.8 2021/02/19 17:49:19 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.101.2.7 2019/11/14 15:58:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.101.2.8 2021/02/19 17:49:19 martin Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -807,6 +807,9 @@ intr_source_free(struct cpu_info *ci, in
 	ci->ci_isources[slot] = NULL;
 	if (pic != &i8259_pic)
 		idt_vec_free(idtvec);
+
+	isp->is_recurse = NULL;
+	isp->is_resume = NULL;
 }
 
 #ifdef MULTIPROCESSOR
@@ -1161,12 +1164,12 @@ intr_disestablish_xcall(void *arg1, void
 	else
 		(*pic->pic_hwunmask)(pic, ih->ih_pin);
 
-	/* Re-enable interrupts. */
-	x86_write_psl(psl);
-
 	/* If the source is free we can drop it now. */
 	intr_source_free(ci, ih->ih_slot, pic, idtvec);
 
+	/* Re-enable interrupts. */
+	x86_write_psl(psl);
+
 	DPRINTF(("%s: remove slot %d (pic %s pin %d vec %d)\n",
 	device_xname(ci->ci_dev), ih->ih_slot, pic->pic_name,
 	ih->ih_pin, idtvec));



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

2021-02-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 17 09:36:10 UTC 2021

Modified Files:
src/sys/dev/raidframe [netbsd-8]: rf_reconstruct.c

Log Message:
Pull up following revision(s) (requested by oster in ticket #1655):

sys/dev/raidframe/rf_reconstruct.c: revision 1.125

Fix a long long-standing off-by-one error in computing lastPSID.

SUsPerPU is only really supported for a value of 1, and since the
first PSID is 0, the last will be numStripe-1.  Also update the
setting of pending_writes to reflect the change to lastPSID.

Needs pullups to -8 and -9.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.121.12.1 src/sys/dev/raidframe/rf_reconstruct.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/raidframe/rf_reconstruct.c
diff -u src/sys/dev/raidframe/rf_reconstruct.c:1.121 src/sys/dev/raidframe/rf_reconstruct.c:1.121.12.1
--- src/sys/dev/raidframe/rf_reconstruct.c:1.121	Fri Nov 14 14:29:16 2014
+++ src/sys/dev/raidframe/rf_reconstruct.c	Wed Feb 17 09:36:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_reconstruct.c,v 1.121 2014/11/14 14:29:16 oster Exp $	*/
+/*	$NetBSD: rf_reconstruct.c,v 1.121.12.1 2021/02/17 09:36:10 martin Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  /
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.121 2014/11/14 14:29:16 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.121.12.1 2021/02/17 09:36:10 martin Exp $");
 
 #include 
 #include 
@@ -616,7 +616,7 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 	mapPtr = raidPtr->reconControl->reconMap;
 
 	incPSID = RF_RECONMAP_SIZE;
-	lastPSID = raidPtr->Layout.numStripe / raidPtr->Layout.SUsPerPU;
+	lastPSID = raidPtr->Layout.numStripe / raidPtr->Layout.SUsPerPU - 1;
 	RUsPerPU = raidPtr->Layout.SUsPerPU / raidPtr->Layout.SUsPerRU;
 	recon_error = 0;
 	write_error = 0;
@@ -631,7 +631,7 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 		raidPtr->reconControl->lastPSID = lastPSID;
 
 	if (pending_writes > lastPSID)
-		pending_writes = lastPSID;
+		pending_writes = lastPSID + 1;
 
 	/* start the actual reconstruction */
 
@@ -796,7 +796,6 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 			pending_writes = lastPSID - prev;
 			raidPtr->reconControl->lastPSID = lastPSID;
 		}
-		
 		/* back down curPSID to get ready for the next round... */
 		for (i = 0; i < raidPtr->numCol; i++) {
 			if (i != col) {



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

2021-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 11 13:04:01 UTC 2021

Modified Files:
src/sys/arch/x68k/x68k [netbsd-8]: machdep.c

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

sys/arch/x68k/x68k/machdep.c: revision 1.204

Restore fixes for PR/51663 lost in r1.195 (uvm_hotplug(9) merge).

The kernel crashdump and savecore(8) on NetBSD/x68k have been broken
(even without EXTNEDED_MEMORY) since NetBSD 8.0. Oops.

Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.196.6.1 src/sys/arch/x68k/x68k/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/x68k/x68k/machdep.c
diff -u src/sys/arch/x68k/x68k/machdep.c:1.196 src/sys/arch/x68k/x68k/machdep.c:1.196.6.1
--- src/sys/arch/x68k/x68k/machdep.c:1.196	Mon Apr  3 17:37:29 2017
+++ src/sys/arch/x68k/x68k/machdep.c	Thu Feb 11 13:04:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.196 2017/04/03 17:37:29 christos Exp $	*/
+/*	$NetBSD: machdep.c,v 1.196.6.1 2021/02/11 13:04:01 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.196 2017/04/03 17:37:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.196.6.1 2021/02/11 13:04:01 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -554,7 +554,10 @@ cpu_init_kcore_hdr(void)
 {
 	cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
 	struct m68k_kcore_hdr *m = &h->un._m68k;
-	uvm_physseg_t i;
+	psize_t size;
+#ifdef EXTENDED_MEMORY
+	int i, seg;
+#endif
 
 	memset(&cpu_kcore_hdr, 0, sizeof(cpu_kcore_hdr));
 
@@ -603,25 +606,20 @@ cpu_init_kcore_hdr(void)
 	/*
 	 * X68k has multiple RAM segments on some models.
 	 */
-	m->ram_segs[0].start = lowram;
-	m->ram_segs[0].size = mem_size - lowram;
-
-	i = uvm_physseg_get_first();
-	
-for (uvm_physseg_get_next(i); uvm_physseg_valid_p(i); i = uvm_physseg_get_next(i)) {
-		if (uvm_physseg_valid_p(i) == false)
-			break;
-
-		const paddr_t startpfn = uvm_physseg_get_start(i);
-		const paddr_t endpfn = uvm_physseg_get_end(i);
-
-		KASSERT(startpfn != -1 && endpfn != -1);
-
-		m->ram_segs[i].start = 
-		ctob(startpfn);
-		m->ram_segs[i].size  =			
-		ctob(endpfn - startpfn);
+	size = phys_basemem_seg.end - phys_basemem_seg.start;
+	m->ram_segs[0].start = phys_basemem_seg.start;
+	m->ram_segs[0].size  = size;
+#ifdef EXTENDED_MEMORY
+	seg = 1;
+	for (i = 0; i < EXTMEM_SEGS; i++) {
+		size = phys_extmem_seg[i].end - phys_extmem_seg[i].start;
+		if (size == 0)
+			continue;
+		m->ram_segs[seg].start = phys_extmem_seg[i].start;
+		m->ram_segs[seg].size  = size;
+		seg++;
 	}
+#endif
 }
 
 /*



CVS commit: [netbsd-8] src/sys/fs/msdosfs

2021-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 11 12:59:38 UTC 2021

Modified Files:
src/sys/fs/msdosfs [netbsd-8]: msdosfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by ryoon in ticket #1653):

sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.136

Enable to mount Raspberry Pi Pico's USB mass storage partition
Fix PR kern/55985.

O.k. by thorpej@.
Pull-up to netbsd-8 and netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.127.4.2 -r1.127.4.3 src/sys/fs/msdosfs/msdosfs_vfsops.c

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

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.127.4.2 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.127.4.3
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.127.4.2	Mon Jan 22 12:34:25 2018
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Thu Feb 11 12:59:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.127.4.2 2018/01/22 12:34:25 martin Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.127.4.3 2021/02/11 12:59:38 martin Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.127.4.2 2018/01/22 12:34:25 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.127.4.3 2021/02/11 12:59:38 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -518,6 +518,13 @@ msdosfs_mountfs(struct vnode *devvp, str
 	b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB;
 	b710 = (struct byte_bpb710 *)bsp->bs710.bsBPB;
 
+#if 0
+	/*
+	 * Some FAT partition, for example Raspberry Pi Pico's
+	 * USB mass storage, does not have exptected BOOTSIGs.
+	 * According to FreeBSD's comment, some PC-9800/9821
+	 * FAT floppy disks have similar problems.
+	 */
 	if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
 		if (bsp->bs50.bsBootSectSig0 != BOOTSIG0
 		|| bsp->bs50.bsBootSectSig1 != BOOTSIG1) {
@@ -528,6 +535,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 			goto error_exit;
 		}
 	}
+#endif
 
 	pmp = malloc(sizeof(*pmp), M_MSDOSFSMNT, M_WAITOK|M_ZERO);
 	pmp->pm_mountp = mp;



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

2021-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 11 12:54:56 UTC 2021

Modified Files:
src/sys/dev/scsipi [netbsd-8]: cd.c sd.c

Log Message:
Pull up following revision(s) (requested by ryoon in ticket #1652):

sys/dev/scsipi/cd.c: revision 1.350
sys/dev/scsipi/sd.c: revision 1.331

PR 55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()


To generate a diff of this commit:
cvs rdiff -u -r1.340.6.2 -r1.340.6.3 src/sys/dev/scsipi/cd.c
cvs rdiff -u -r1.324.6.1 -r1.324.6.2 src/sys/dev/scsipi/sd.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/scsipi/cd.c
diff -u src/sys/dev/scsipi/cd.c:1.340.6.2 src/sys/dev/scsipi/cd.c:1.340.6.3
--- src/sys/dev/scsipi/cd.c:1.340.6.2	Sun Mar 29 12:10:37 2020
+++ src/sys/dev/scsipi/cd.c	Thu Feb 11 12:54:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.340.6.2 2020/03/29 12:10:37 martin Exp $	*/
+/*	$NetBSD: cd.c,v 1.340.6.3 2021/02/11 12:54:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.340.6.2 2020/03/29 12:10:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.340.6.3 2021/02/11 12:54:56 martin Exp $");
 
 #include 
 #include 
@@ -1378,7 +1378,7 @@ cdioctl(dev_t dev, u_long cmd, void *add
 		XS_CTL_IGNORE_NOT_READY | XS_CTL_IGNORE_MEDIA_CHANGE));
 	case DIOCEJECT:
 		if (*(int *)addr == 0) {
-			int pmask = 1 << part;
+			int pmask = __BIT(part);
 			/*
 			 * Don't force eject: check that we are the only
 			 * partition open. If so, unlock it.

Index: src/sys/dev/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.324.6.1 src/sys/dev/scsipi/sd.c:1.324.6.2
--- src/sys/dev/scsipi/sd.c:1.324.6.1	Wed Jun 21 18:18:55 2017
+++ src/sys/dev/scsipi/sd.c	Thu Feb 11 12:54:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.324.6.1 2017/06/21 18:18:55 snj Exp $	*/
+/*	$NetBSD: sd.c,v 1.324.6.2 2021/02/11 12:54:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.324.6.1 2017/06/21 18:18:55 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.324.6.2 2021/02/11 12:54:56 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -950,11 +950,12 @@ sdioctl(dev_t dev, u_long cmd, void *add
 		if ((periph->periph_flags & PERIPH_REMOVABLE) == 0)
 			return (ENOTTY);
 		if (*(int *)addr == 0) {
+			int pmask = __BIT(part);
 			/*
 			 * Don't force eject: check that we are the only
 			 * partition open. If so, unlock it.
 			 */
-			if (DK_BUSY(dksc, part) == 0) {
+			if (DK_BUSY(dksc, pmask) == 0) {
 error = scsipi_prevent(periph, SPAMR_ALLOW,
 XS_CTL_IGNORE_NOT_READY);
 if (error)



CVS commit: [netbsd-8] src/sys

2021-02-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb  6 15:22:20 UTC 2021

Modified Files:
src/sys/conf [netbsd-8]: param.c
src/sys/kern [netbsd-8]: init_main.c
src/sys/sys [netbsd-8]: param.h

Log Message:
Pull up following revision(s) (requested by simonb in ticket #1649):

sys/sys/param.h: revision 1.679
sys/conf/param.c: revision 1.69
sys/kern/init_main.c: revision 1.533 (via patch)

Set a better default for MAXFILES on larger RAM machines if not
otherwise specified the kernel config file.  Arbitary numbers are
20,000 files for 16GB RAM or more and 10,000 files for 1GB RAM or
more.

TODO: Adjust this and other values totally dynamically.


To generate a diff of this commit:
cvs rdiff -u -r1.67.10.1 -r1.67.10.2 src/sys/conf/param.c
cvs rdiff -u -r1.490.6.1 -r1.490.6.2 src/sys/kern/init_main.c
cvs rdiff -u -r1.542.2.10 -r1.542.2.11 src/sys/sys/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/conf/param.c
diff -u src/sys/conf/param.c:1.67.10.1 src/sys/conf/param.c:1.67.10.2
--- src/sys/conf/param.c:1.67.10.1	Wed Apr 10 07:39:31 2019
+++ src/sys/conf/param.c	Sat Feb  6 15:22:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.c,v 1.67.10.1 2019/04/10 07:39:31 martin Exp $	*/
+/*	$NetBSD: param.c,v 1.67.10.2 2021/02/06 15:22:19 martin Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1989 Regents of the University of California.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: param.c,v 1.67.10.1 2019/04/10 07:39:31 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: param.c,v 1.67.10.2 2021/02/06 15:22:19 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_hz.h"
@@ -105,10 +105,6 @@ __KERNEL_RCSID(0, "$NetBSD: param.c,v 1.
 #define	HZ 100
 #endif
 
-#ifndef MAXFILES
-#define	MAXFILES	(3 * (NPROC + MAXUSERS) + 80)
-#endif
-
 #ifndef MAXEXEC
 #define	MAXEXEC		16
 #endif

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.490.6.1 src/sys/kern/init_main.c:1.490.6.2
--- src/sys/kern/init_main.c:1.490.6.1	Fri Jul 13 15:49:55 2018
+++ src/sys/kern/init_main.c	Sat Feb  6 15:22:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.490.6.1 2018/07/13 15:49:55 martin Exp $	*/
+/*	$NetBSD: init_main.c,v 1.490.6.2 2021/02/06 15:22:19 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.490.6.1 2018/07/13 15:49:55 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.490.6.2 2021/02/06 15:22:19 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -447,7 +447,23 @@ main(void)
 	10, VNODE_KMEM_MAXPCT) / VNODE_COST;
 	if (usevnodes > desiredvnodes)
 		desiredvnodes = usevnodes;
-#endif
+#endif /* NVNODE_IMPLICIT */
+#ifdef MAXFILES_IMPLICIT
+	/*
+	 * If maximum number of files is not explicitly defined in
+	 * kernel config, adjust the number so that it is somewhat
+	 * more reasonable on machines with larger memory sizes.
+	 * Arbitary numbers are 20,000 files for 16GB RAM or more
+	 * and 10,000 files for 1GB RAM or more.
+	 *
+	 * XXXtodo: adjust this and other values totally dynamically
+	 */
+	if (ctob((uint64_t)physmem) >= 16ULL * 1024 * 1024 * 1024)
+		maxfiles = MAX(maxfiles, 2);
+	if (ctob((uint64_t)physmem) >= 1024 * 1024 * 1024)
+		maxfiles = MAX(maxfiles, 1);
+#endif /* MAXFILES_IMPLICIT */
+
 	vfsinit();
 	lf_init();
 

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.542.2.10 src/sys/sys/param.h:1.542.2.11
--- src/sys/sys/param.h:1.542.2.10	Tue Apr 14 15:50:28 2020
+++ src/sys/sys/param.h	Sat Feb  6 15:22:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.542.2.10 2020/04/14 15:50:28 martin Exp $	*/
+/*	$NetBSD: param.h,v 1.542.2.11 2021/02/06 15:22:19 martin Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -148,13 +148,17 @@
 #include 
 #include 
 #ifndef NPROC
-#define	NPROC	(20 + 16 * MAXUSERS)
+#define	NPROC			(20 + 16 * MAXUSERS)
+#endif
+#ifndef MAXFILES
+#define	MAXFILES		(3 * (NPROC + MAXUSERS) + 80)
+#define	MAXFILES_IMPLICIT
 #endif
 #ifndef NTEXT
-#define	NTEXT	(80 + NPROC / 8)		/* actually the object cache */
+#define	NTEXT			(80 + NPROC / 8) /* actually the object cache */
 #endif
 #ifndef NVNODE
-#define	NVNODE	(NPROC + NTEXT + 100)
+#define	NVNODE			(NPROC + NTEXT + 100)
 #define	NVNODE_IMPLICIT
 #endif
 #ifndef VNODE_KMEM_MAXPCT
@@ -163,7 +167,7 @@
 #ifndef BUFCACHE_VA_MAXPCT
 #define	BUFCACHE_VA_MAXPCT	20
 #endif
-#define	VNODE_COST	2048			/* assumed space in bytes */
+#define	VNODE_COST		2048		/* assumed space in bytes */
 #endif /* _KERNEL */
 
 /* Signals. */



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

2021-01-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan 29 18:18:25 UTC 2021

Modified Files:
src/sys/dev/hyperv [netbsd-8]: hvkbd.c if_hvn.c vmbus.c

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

sys/dev/hyperv/if_hvn.c: revision 1.20 (via patch)
sys/dev/hyperv/hvkbd.c: revision 1.7 (via patch)
sys/dev/hyperv/vmbus.c: revision 1.12 (via patch)

hvkbd(4): Don't wait forever.
vmbus(4): Don't wait forever.
hvn(4): Don't wait forever.


To generate a diff of this commit:
cvs rdiff -u -r1.1.4.6 -r1.1.4.7 src/sys/dev/hyperv/hvkbd.c
cvs rdiff -u -r1.2.2.8 -r1.2.2.9 src/sys/dev/hyperv/if_hvn.c
cvs rdiff -u -r1.2.2.5 -r1.2.2.6 src/sys/dev/hyperv/vmbus.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/hyperv/hvkbd.c
diff -u src/sys/dev/hyperv/hvkbd.c:1.1.4.6 src/sys/dev/hyperv/hvkbd.c:1.1.4.7
--- src/sys/dev/hyperv/hvkbd.c:1.1.4.6	Sun Nov 24 08:11:06 2019
+++ src/sys/dev/hyperv/hvkbd.c	Fri Jan 29 18:18:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hvkbd.c,v 1.1.4.6 2019/11/24 08:11:06 martin Exp $	*/
+/*	$NetBSD: hvkbd.c,v 1.1.4.7 2021/01/29 18:18:25 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017 Microsoft Corp.
@@ -36,7 +36,7 @@
 #endif /* _KERNEL_OPT */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.1.4.6 2019/11/24 08:11:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.1.4.7 2021/01/29 18:18:25 martin Exp $");
 
 #include 
 #include 
@@ -363,7 +363,8 @@ hvkbd_connect(struct hvkbd_softc *sc)
 			hvkbd_intr(sc);
 			splx(s);
 		} else
-			tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", mstohz(1));
+			tsleep(sc, PRIBIO | PCATCH, "hvkbdcon",
+			max(1, mstohz(1)));
 	} while (--timo > 0 && sc->sc_connected == 0);
 
 	if (timo == 0 && sc->sc_connected == 0) {

Index: src/sys/dev/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.2.2.8 src/sys/dev/hyperv/if_hvn.c:1.2.2.9
--- src/sys/dev/hyperv/if_hvn.c:1.2.2.8	Fri Dec 11 15:48:02 2020
+++ src/sys/dev/hyperv/if_hvn.c	Fri Jan 29 18:18:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.2.2.8 2020/12/11 15:48:02 martin Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.2.2.9 2021/01/29 18:18:25 martin Exp $	*/
 /*	$OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.2.2.8 2020/12/11 15:48:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.2.2.9 2021/01/29 18:18:25 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1065,7 +1065,8 @@ hvn_nvs_cmd(struct hvn_softc *sc, void *
 			if (cold)
 delay(1000);
 			else
-tsleep(cmd, PRIBIO, "nvsout", mstohz(1));
+tsleep(cmd, PRIBIO, "nvsout",
+max(1, mstohz(1)));
 		} else if (rv) {
 			DPRINTF("%s: NVSP operation %u send error %d\n",
 			device_xname(sc->sc_dev), hdr->nvs_type, rv);
@@ -1090,7 +1091,7 @@ hvn_nvs_cmd(struct hvn_softc *sc, void *
 			splx(s);
 		} else
 			tsleep(sc->sc_nvsrsp, PRIBIO | PCATCH, "nvscmd",
-			mstohz(1));
+			max(1, mstohz(1)));
 	} while (--timo > 0 && sc->sc_nvsdone != 1);
 
 	if (timo == 0 && sc->sc_nvsdone != 1) {
@@ -1388,7 +1389,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru
 			if (cold)
 delay(1000);
 			else
-tsleep(rc, PRIBIO, "rndisout", mstohz(1));
+tsleep(rc, PRIBIO, "rndisout",
+max(1, mstohz(1)));
 		} else if (rv) {
 			DPRINTF("%s: RNDIS operation %u send error %d\n",
 			device_xname(sc->sc_dev), hdr->rm_type, rv);
@@ -1413,7 +1415,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru
 			hvn_nvs_intr(sc);
 			splx(s);
 		} else
-			tsleep(rc, PRIBIO | PCATCH, "rndiscmd", mstohz(1));
+			tsleep(rc, PRIBIO | PCATCH, "rndiscmd",
+			max(1, mstohz(1)));
 	} while (--timo > 0 && rc->rc_done != 1);
 
 	bus_dmamap_sync(sc->sc_dmat, rc->rc_dmap, 0, PAGE_SIZE,

Index: src/sys/dev/hyperv/vmbus.c
diff -u src/sys/dev/hyperv/vmbus.c:1.2.2.5 src/sys/dev/hyperv/vmbus.c:1.2.2.6
--- src/sys/dev/hyperv/vmbus.c:1.2.2.5	Sun Nov 24 08:11:06 2019
+++ src/sys/dev/hyperv/vmbus.c	Fri Jan 29 18:18:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbus.c,v 1.2.2.5 2019/11/24 08:11:06 martin Exp $	*/
+/*	$NetBSD: vmbus.c,v 1.2.2.6 2021/01/29 18:18:25 martin Exp $	*/
 /*	$OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.2.2.5 2019/11/24 08:11:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.2.2.6 2021/01/29 18:18:25 martin Exp $");
 
 #include 
 #include 
@@ -604,7 +604,8 @@ vmbus_start(struct vmbus_softc *sc, stru
 			hyperv_intr();
 			splx(s);
 		} else
-			tsleep(wchan, PRIBIO, wchan, mstohz(delays[i]));
+			tsleep(wchan, PRIBIO, wchan,
+			max(1, mstohz(delays[i] / 1000)));
 	}
 	if (status != HYPERCALL_STATUS_SUCCESS) {
 		device_printf(sc->sc_dev,
@@ -667,7 +668,7 @@ vmbus_wait(struct vmbus_softc *sc,
 			splx(s);
 		} else
 			tsleep(wchan, PRIBIO, wmsg ? wmsg : "hvwait",
-		

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

2021-01-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan  1 13:19:58 UTC 2021

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

Log Message:
Pull up following revision(s) (requested by nia in ticket #1645):

sys/ufs/ufs/ufs_quota1.c: revision 1.23

Avoid potentially accessing an array with an index out of range.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.10.1 src/sys/ufs/ufs/ufs_quota1.c

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

Modified files:

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.22 src/sys/ufs/ufs/ufs_quota1.c:1.22.10.1
--- src/sys/ufs/ufs/ufs_quota1.c:1.22	Mon Jun 20 00:52:04 2016
+++ src/sys/ufs/ufs/ufs_quota1.c	Fri Jan  1 13:19:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $	*/
+/*	$NetBSD: ufs_quota1.c,v 1.22.10.1 2021/01/01 13:19:57 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22 2016/06/20 00:52:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22.10.1 2021/01/01 13:19:57 martin Exp $");
 
 #include 
 #include 
@@ -311,6 +311,9 @@ quota1_handle_cmd_quotaon(struct lwp *l,
 	struct pathbuf *pb;
 	struct nameidata nd;
 
+	if (type < 0 || type >= MAXQUOTAS)
+		return EINVAL;
+
 	if (ump->um_flags & UFS_QUOTA2) {
 		uprintf("%s: quotas v2 already enabled\n",
 		mp->mnt_stat.f_mntonname);
@@ -421,6 +424,9 @@ quota1_handle_cmd_quotaoff(struct lwp *l
 	kauth_cred_t cred;
 	int i, error;
 
+	if (type < 0 || type >= MAXQUOTAS)
+		return EINVAL;
+
 	mutex_enter(&dqlock);
 	while ((ump->umq1_qflags[type] & (QTF_CLOSING | QTF_OPENING)) != 0)
 		cv_wait(&dqcv, &dqlock);



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

2020-12-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec 28 19:52:59 UTC 2020

Modified Files:
src/sys/arch/hp300/dev [netbsd-8]: dnkbd.c hil_intio.c

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

sys/arch/hp300/dev/dnkbd.c: revision 1.11
sys/arch/hp300/dev/hil_intio.c: revision 1.4

Fix a longstanding bug in hilkbd (and dnkbd) console attachment.
cn_tab->cn_dev is initialized in wsdisplay_emul_attach()
(but not in wsdiaplay_cnattach()) so it cannot be used
when hil(4) is attached before wsdisplay(4) is attached.

Instead, use exported wsdisplay_cnputc() that is actually
set in early wsdisplay_cnattach().

Now we can use ddb and RB_ASKNAME via HIL keyboard console.

Should be pulleld up to netbsd-8 and netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.6.1 src/sys/arch/hp300/dev/dnkbd.c
cvs rdiff -u -r1.3 -r1.3.52.1 src/sys/arch/hp300/dev/hil_intio.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/hp300/dev/dnkbd.c
diff -u src/sys/arch/hp300/dev/dnkbd.c:1.10 src/sys/arch/hp300/dev/dnkbd.c:1.10.6.1
--- src/sys/arch/hp300/dev/dnkbd.c:1.10	Sat Apr  8 17:04:56 2017
+++ src/sys/arch/hp300/dev/dnkbd.c	Mon Dec 28 19:52:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dnkbd.c,v 1.10 2017/04/08 17:04:56 tsutsui Exp $	*/
+/*	$NetBSD: dnkbd.c,v 1.10.6.1 2020/12/28 19:52:59 martin Exp $	*/
 /*	$OpenBSD: dnkbd.c,v 1.17 2009/07/23 21:05:56 blambert Exp $	*/
 
 /*
@@ -69,6 +69,9 @@
 
 #include "opt_wsdisplay_compat.h"
 
+#include "wsdisplay.h"
+#include "wsmouse.h"
+
 #include 
 #include 
 #include 
@@ -87,7 +90,9 @@
 #include 
 #include 
 #include 
-#include "wsmouse.h"
+#if NWSDISPLAY > 0
+#include 
+#endif
 #if NWSMOUSE > 0
 #include 
 #endif
@@ -354,7 +359,8 @@ dnkbd_attach_subdevices(struct dnkbd_sof
 	 * plugged), unless the console keyboard has been claimed already
 	 * (i.e. late hotplug with hil keyboard plugged first).
 	 */
-	if (major(cn_tab->cn_dev) == devsw_name2chr("wsdisplay", NULL, 0)) {
+#if NWSDISPLAY > 0
+	if (cn_tab->cn_putc == wsdisplay_cnputc) {
 #if NHILKBD > 0
 		if (hil_is_console == -1) {
 			ka.console = 1;
@@ -365,7 +371,10 @@ dnkbd_attach_subdevices(struct dnkbd_sof
 		ka.console = 1;
 #endif
 	} else
+#endif
+	{
 		ka.console = 0;
+	}
 
 	ka.keymap = &dnkbd_keymapdata;
 	ka.accessops = &dnkbd_accessops;

Index: src/sys/arch/hp300/dev/hil_intio.c
diff -u src/sys/arch/hp300/dev/hil_intio.c:1.3 src/sys/arch/hp300/dev/hil_intio.c:1.3.52.1
--- src/sys/arch/hp300/dev/hil_intio.c:1.3	Sat Feb 19 05:36:49 2011
+++ src/sys/arch/hp300/dev/hil_intio.c	Mon Dec 28 19:52:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hil_intio.c,v 1.3 2011/02/19 05:36:49 tsutsui Exp $	*/
+/*	$NetBSD: hil_intio.c,v 1.3.52.1 2020/12/28 19:52:59 martin Exp $	*/
 /*	$OpenBSD: hil_intio.c,v 1.8 2007/01/06 20:10:57 miod Exp $	*/
 
 /*
@@ -28,6 +28,8 @@
  *
  */
 
+#include "wsdisplay.h"
+
 #include 
 #include 
 #include 
@@ -38,6 +40,9 @@
 #include 
 
 #include 
+#if NWSDISPLAY > 0
+#include 
+#endif
 
 #include 
 
@@ -88,8 +93,12 @@ hil_intio_attach(device_t parent, device
 	/*
 	 * Check that the configured console device is a wsdisplay.
 	 */
-	if (major(cn_tab->cn_dev) != devsw_name2chr("wsdisplay", NULL, 0))
+#if NWSDISPLAY > 0
+	if (cn_tab->cn_putc != wsdisplay_cnputc)
+#endif
+	{
 		hil_is_console = 0;
+	}
 
 	hil_attach(sc, &hil_is_console);
 	intr_establish(hil_intr, sc, ia->ia_ipl, IPL_TTY);



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

2020-12-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 19 19:04:49 UTC 2020

Modified Files:
src/sys/dev/scsipi [netbsd-8]: scsiconf.c

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

sys/dev/scsipi/scsiconf.c: revision 1.283

Add NOLUNS quirk for more SEAGATE SCA/WIDE drives.

Tested on NetBSD/luna68k and LUNA with SCA 80pin -> NARROW 50pin and
WIDE 68pin -> NARROW 50pin connectors.


To generate a diff of this commit:
cvs rdiff -u -r1.279.6.2 -r1.279.6.3 src/sys/dev/scsipi/scsiconf.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/scsipi/scsiconf.c
diff -u src/sys/dev/scsipi/scsiconf.c:1.279.6.2 src/sys/dev/scsipi/scsiconf.c:1.279.6.3
--- src/sys/dev/scsipi/scsiconf.c:1.279.6.2	Mon Jul 13 14:10:25 2020
+++ src/sys/dev/scsipi/scsiconf.c	Sat Dec 19 19:04:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $	*/
+/*	$NetBSD: scsiconf.c,v 1.279.6.3 2020/12/19 19:04:49 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.3 2020/12/19 19:04:49 martin Exp $");
 
 #include 
 #include 
@@ -674,6 +674,12 @@ static const struct scsi_quirk_inquiry_p
 	{{T_DIRECT, T_FIXED,
 	 "SEAGATE ", "ST318404LC  ", ""}, PQUIRK_NOLUNS},
 	{{T_DIRECT, T_FIXED,
+	 "SEAGATE ", "ST336753LC  ", ""}, PQUIRK_NOLUNS},
+	{{T_DIRECT, T_FIXED,
+	 "SEAGATE ", "ST336753LW  ", ""}, PQUIRK_NOLUNS},
+	{{T_DIRECT, T_FIXED,
+	 "SEAGATE ", "ST336754LC  ", ""}, PQUIRK_NOLUNS},
+	{{T_DIRECT, T_FIXED,
 	 "SEAGATE ", "ST39236LC   ", ""}, PQUIRK_NOLUNS},
 	{{T_DIRECT, T_FIXED,
 	 "SEAGATE ", "ST15150N", ""}, PQUIRK_NOTAG},



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

2020-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 12 20:30:57 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: ohci.c ohcivar.h

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1637):

sys/dev/usb/ohci.c: revision 1.311
sys/dev/usb/ohci.c: revision 1.312
sys/dev/usb/ohcivar.h: revision 1.62

Restructure the abort code for TD based transfers (ctrl, bulk, intr).

In PR kern/22646 some TDs can be on the done queue when the abort start
and, if this is the case, they need to processed after the WDH interrupt.
Instead of waiting for WDH we release TDs that have been touched by the
HC and replace them with new ones.  Once WDH happens the floating TDs
will be returned to the free list.

Also addresses the issue seen in PR kern/55835

Thanks to both Andreas Gustafsson and Edgar Fu=C3=9F for testing.  Apologi=
es to
Andreas Gustafsson for not committing this to HEAD for 4y6m.w

Remove leading space that crept in in the last change


To generate a diff of this commit:
cvs rdiff -u -r1.273.6.6 -r1.273.6.7 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.58.10.1 -r1.58.10.2 src/sys/dev/usb/ohcivar.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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.273.6.6 src/sys/dev/usb/ohci.c:1.273.6.7
--- src/sys/dev/usb/ohci.c:1.273.6.6	Tue Feb 25 18:52:44 2020
+++ src/sys/dev/usb/ohci.c	Sat Dec 12 20:30:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.273.6.6 2020/02/25 18:52:44 martin Exp $	*/
+/*	$NetBSD: ohci.c,v 1.273.6.7 2020/12/12 20:30:57 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.273.6.6 2020/02/25 18:52:44 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.273.6.7 2020/12/12 20:30:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -390,6 +390,7 @@ ohci_detach(struct ohci_softc *sc, int f
 	if (sc->sc_hcca != NULL)
 		usb_freemem(&sc->sc_bus, &sc->sc_hccadma);
 	pool_cache_destroy(sc->sc_xferpool);
+	cv_destroy(&sc->sc_abort_cv);
 
 	return rv;
 }
@@ -492,6 +493,7 @@ ohci_alloc_std(ohci_softc_t *sc)
 	memset(&std->td, 0, sizeof(ohci_td_t));
 	std->nexttd = NULL;
 	std->xfer = NULL;
+	std->held = NULL;
 
 	return std;
 }
@@ -539,14 +541,17 @@ ohci_alloc_std_chain(ohci_softc_t *sc, s
 
 	DPRINTFN(8, "xfer %#jx nstd %jd", (uintptr_t)xfer, nstd, 0, 0);
 
-	for (size_t j = 0; j < ox->ox_nstd;) {
+	for (size_t j = 0; j < ox->ox_nstd; j++) {
 		ohci_soft_td_t *cur = ohci_alloc_std(sc);
 		if (cur == NULL)
 			goto nomem;
 
-		ox->ox_stds[j++] = cur;
+		ox->ox_stds[j] = cur;
+		cur->held = &ox->ox_stds[j];
 		cur->xfer = xfer;
 		cur->flags = 0;
+		DPRINTFN(10, "xfer=%#jx new std=%#jx held at %#jx", (uintptr_t)ox,
+		(uintptr_t)cur, (uintptr_t)cur->held, 0);
 	}
 
 	return 0;
@@ -797,6 +802,9 @@ ohci_init(ohci_softc_t *sc)
 	for (i = 0; i < OHCI_HASH_SIZE; i++)
 		LIST_INIT(&sc->sc_hash_itds[i]);
 
+	TAILQ_INIT(&sc->sc_abortingxfers);
+	cv_init(&sc->sc_abort_cv, "ohciabt");
+
 	sc->sc_xferpool = pool_cache_init(sizeof(struct ohci_xfer), 0, 0, 0,
 	"ohcixfer", NULL, IPL_USB, NULL, NULL, NULL);
 
@@ -1313,6 +1321,21 @@ ohci_intr1(ohci_softc_t *sc)
 		 */
 		usb_schedsoftintr(&sc->sc_bus);
 	}
+	if (eintrs & OHCI_SF) {
+		struct ohci_xfer *ox, *tmp;
+		TAILQ_FOREACH_SAFE(ox, &sc->sc_abortingxfers, ox_abnext, tmp) {
+			DPRINTFN(10, "SF %#jx xfer %#jx", (uintptr_t)sc,
+			(uintptr_t)ox, 0, 0);
+			ox->ox_abintrs &= ~OHCI_SF;
+			KASSERT(ox->ox_abintrs == 0);
+			TAILQ_REMOVE(&sc->sc_abortingxfers, ox, ox_abnext);
+		}
+		cv_broadcast(&sc->sc_abort_cv);
+
+		KASSERT(TAILQ_EMPTY(&sc->sc_abortingxfers));
+		DPRINTFN(10, "end SOF %#jx", (uintptr_t)sc, 0, 0, 0);
+		/* Don't remove OHIC_SF from eintrs so it is blocked below */
+	}
 	if (eintrs & OHCI_RD) {
 /* 1 argument, but zero format strings */
 		DPRINTFN(5, "resume detect", (uintptr_t)sc, 0, 0, 0);
@@ -1391,12 +1414,22 @@ ohci_softintr(void *v)
 	struct ohci_pipe *opipe;
 	int len, cc;
 	int i, j, actlen, iframes, uedir;
-	ohci_physaddr_t done;
+	ohci_physaddr_t done = 0;
 
 	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock));
 
 	OHCIHIST_FUNC(); OHCIHIST_CALLED();
 
+	/*
+	 * Only read hccadone if WDH is set - we might get here from places
+	 * other than an interrupt
+	 */
+	if (!(OREAD4(sc, OHCI_INTERRUPT_STATUS) & OHCI_WDH)) {
+		DPRINTFN(10, "no WDH %#jx", (uintptr_t)sc, 0, 0, 0);
+		return;
+	}
+
+	DPRINTFN(10, "WDH %#jx", (uintptr_t)sc, 0, 0, 0);
 	usb_syncmem(&sc->sc_hccadma, offsetof(struct ohci_hcca, hcca_done_head),
 	sizeof(sc->sc_hcca->hcca_done_head),
 	BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
@@ -1449,11 +1482,19 @@ ohci_softintr(void *v)
 	DPRINTFN(10, "--- TD dump end ---", 0, 0, 0, 0);
 
 	for (std = sdone; std; std = stdnext) {
-		xfer = std->xfer;
 		stdnext = std->dnext;
-		

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

2020-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 12 12:58:51 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: ucom.c

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

sys/dev/usb/ucom.c: revision 1.128

properly wait for refcounts to drain.
fixes panic at detach that jmnceill saw.

XXX: pullup-[89].


To generate a diff of this commit:
cvs rdiff -u -r1.118.8.4 -r1.118.8.5 src/sys/dev/usb/ucom.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.118.8.4 src/sys/dev/usb/ucom.c:1.118.8.5
--- src/sys/dev/usb/ucom.c:1.118.8.4	Tue May  7 18:47:01 2019
+++ src/sys/dev/usb/ucom.c	Sat Dec 12 12:58:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.118.8.4 2019/05/07 18:47:01 martin Exp $	*/
+/*	$NetBSD: ucom.c,v 1.118.8.5 2020/12/12 12:58:51 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.118.8.4 2019/05/07 18:47:01 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.118.8.5 2020/12/12 12:58:51 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -431,7 +431,7 @@ ucom_detach(device_t self, int flags)
 	}
 
 	sc->sc_refcnt--;
-	while (sc->sc_refcnt > 0) {
+	while (sc->sc_refcnt >= 0) {
 		/* Wake up anyone waiting */
 		if (tp != NULL) {
 			mutex_spin_enter(&tty_lock);



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

2020-12-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Dec 11 15:48:02 UTC 2020

Modified Files:
src/sys/dev/hyperv [netbsd-8]: if_hvn.c

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

sys/dev/hyperv/if_hvn.c: revision 1.19 (via patch)

hvn(4): fix unable to ifconfig up/down.


To generate a diff of this commit:
cvs rdiff -u -r1.2.2.7 -r1.2.2.8 src/sys/dev/hyperv/if_hvn.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/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.2.2.7 src/sys/dev/hyperv/if_hvn.c:1.2.2.8
--- src/sys/dev/hyperv/if_hvn.c:1.2.2.7	Tue Nov 26 08:25:28 2019
+++ src/sys/dev/hyperv/if_hvn.c	Fri Dec 11 15:48:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.2.2.7 2019/11/26 08:25:28 martin Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.2.2.8 2020/12/11 15:48:02 martin Exp $	*/
 /*	$OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.2.2.7 2019/11/26 08:25:28 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.2.2.8 2020/12/11 15:48:02 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -379,20 +379,6 @@ hvn_ioctl(struct ifnet *ifp, u_long comm
 	s = splnet();
 
 	switch (command) {
-	case SIOCSIFFLAGS:
-		if (ifp->if_flags & IFF_UP) {
-			if (ifp->if_flags & IFF_RUNNING)
-error = ENETRESET;
-			else {
-error = hvn_init(ifp);
-if (error)
-	ifp->if_flags &= ~IFF_UP;
-			}
-		} else {
-			if (ifp->if_flags & IFF_RUNNING)
-hvn_stop(ifp, 1);
-		}
-		break;
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
 		error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, command);



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

2020-12-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec  7 20:05:36 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-8]: nvme.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1633):

sys/dev/ic/nvme.c: revision 1.53

PR kern/55839:

handle multiple nvme_rescan()s correctly by doing the
name-space identify only once per nsid.
fixes issue where modloading triggers multiple
rescans.


To generate a diff of this commit:
cvs rdiff -u -r1.30.2.8 -r1.30.2.9 src/sys/dev/ic/nvme.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/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.30.2.8 src/sys/dev/ic/nvme.c:1.30.2.9
--- src/sys/dev/ic/nvme.c:1.30.2.8	Sun Sep 27 10:33:45 2020
+++ src/sys/dev/ic/nvme.c	Mon Dec  7 20:05:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.30.2.8 2020/09/27 10:33:45 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.30.2.9 2020/12/07 20:05:36 martin Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.8 2020/09/27 10:33:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.9 2020/12/07 20:05:36 martin Exp $");
 
 #include 
 #include 
@@ -625,6 +625,12 @@ nvme_ns_identify(struct nvme_softc *sc, 
 
 	KASSERT(nsid > 0);
 
+	ns = nvme_ns_get(sc, nsid);
+	KASSERT(ns);
+
+	if (ns->ident != NULL)
+		return 0;
+
 	ccb = nvme_ccb_get(sc->sc_admin_q, false);
 	KASSERT(ccb != NULL); /* it's a bug if we don't have spare ccb here */
 
@@ -662,9 +668,6 @@ nvme_ns_identify(struct nvme_softc *sc, 
 	/* Convert data to host endian */
 	nvme_identify_namespace_swapbytes(identify);
 
-	ns = nvme_ns_get(sc, nsid);
-	KASSERT(ns);
-	KASSERT(ns->ident == NULL);
 	ns->ident = identify;
 
 done:



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

2020-12-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec  7 20:01:02 UTC 2020

Modified Files:
src/sys/netinet [netbsd-8]: ip_mroute.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1632):

sys/netinet/ip_mroute.c: revision 1.164 (patch)

PR kern/55779:

restore non-desctructive guarantee of ip_mforward() mbuf
argument. This avoids generation invalid UDP checksums
on multicast packets in ip_output().

XXX the root cause of the misguided fix in 2008 should be
XXX investigated


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

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

Modified files:

Index: src/sys/netinet/ip_mroute.c
diff -u src/sys/netinet/ip_mroute.c:1.146.6.4 src/sys/netinet/ip_mroute.c:1.146.6.5
--- src/sys/netinet/ip_mroute.c:1.146.6.4	Fri Jul 13 14:26:47 2018
+++ src/sys/netinet/ip_mroute.c	Mon Dec  7 20:01:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_mroute.c,v 1.146.6.4 2018/07/13 14:26:47 martin Exp $	*/
+/*	$NetBSD: ip_mroute.c,v 1.146.6.5 2020/12/07 20:01:01 martin Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.146.6.4 2018/07/13 14:26:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.146.6.5 2020/12/07 20:01:01 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -239,6 +239,8 @@ static int tbf_dq_sel(struct vif *, stru
 static void tbf_send_packet(struct vif *, struct mbuf *);
 static void tbf_update_tokens(struct vif *);
 static int priority(struct vif *, struct ip *);
+static int ip_mforward_real(struct mbuf *, struct ifnet *);
+
 
 /*
  * Bandwidth monitoring
@@ -1309,6 +1311,34 @@ ip_mforward(struct mbuf *m, struct ifnet
 ip_mforward(struct mbuf *m, struct ifnet *ifp)
 #endif /* RSVP_ISI */
 {
+	int rc;
+	/*
+	 * save csum_flags to uphold the 
+	 * "unscathed" guarantee.
+	 * ip_output() relies on that and
+	 * without it we send out
+	 * multicast packets with an invalid
+	 * checksum
+	 *
+	 * see PR kern/55779
+	 */
+	int csum_flags = m->m_pkthdr.csum_flags;
+
+	/*
+	 * Temporarily clear any in-bound checksum flags for this packet.
+	 */
+	m->m_pkthdr.csum_flags = 0;
+
+	rc = ip_mforward_real(m, ifp);
+
+	m->m_pkthdr.csum_flags = csum_flags;
+
+	return rc;
+}
+
+static int
+ip_mforward_real(struct mbuf *m, struct ifnet *ifp)
+{
 	struct ip *ip = mtod(m, struct ip *);
 	struct mfc *rt;
 	static int srctun = 0;
@@ -1340,11 +1370,6 @@ ip_mforward(struct mbuf *m, struct ifnet
 		return (1);
 	}
 
-	/*
-	 * Clear any in-bound checksum flags for this packet.
-	 */
-	m->m_pkthdr.csum_flags = 0;
-
 #ifdef RSVP_ISI
 	if (imo && ((vifi = imo->imo_multicast_vif) < numvifs)) {
 		if (ip->ip_ttl < MAXTTL)



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

2020-11-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 16 18:18:15 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: if_wm.c

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

sys/dev/pci/if_wm.c: revision 1.696

Fix little-endian dependence in wm_rxeof(), by which packets cannot be
received by 82574 and successors on big-endian machines.

Tested by aarch64eb with I210-T1 on ROCKPro64.

Thanks msaitoh for discussion!
XXX
pullup to netbsd-9 and netbsd-8


To generate a diff of this commit:
cvs rdiff -u -r1.508.4.41 -r1.508.4.42 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.41 src/sys/dev/pci/if_wm.c:1.508.4.42
--- src/sys/dev/pci/if_wm.c:1.508.4.41	Wed Nov  4 11:51:57 2020
+++ src/sys/dev/pci/if_wm.c	Mon Nov 16 18:18:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.508.4.41 2020/11/04 11:51:57 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508.4.42 2020/11/16 18:18:14 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.41 2020/11/04 11:51:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.42 2020/11/16 18:18:14 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -8790,9 +8790,11 @@ wm_rxdesc_get_status(struct wm_rxqueue *
 	struct wm_softc *sc = rxq->rxq_sc;
 
 	if (sc->sc_type == WM_T_82574)
-		return EXTRXC_STATUS(rxq->rxq_ext_descs[idx].erx_ctx.erxc_err_stat);
+		return EXTRXC_STATUS(
+		le32toh(rxq->rxq_ext_descs[idx].erx_ctx.erxc_err_stat));
 	else if ((sc->sc_flags & WM_F_NEWQUEUE) != 0)
-		return NQRXC_STATUS(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_err_stat);
+		return NQRXC_STATUS(
+		le32toh(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_err_stat));
 	else
 		return rxq->rxq_descs[idx].wrx_status;
 }
@@ -8803,9 +8805,11 @@ wm_rxdesc_get_errors(struct wm_rxqueue *
 	struct wm_softc *sc = rxq->rxq_sc;
 
 	if (sc->sc_type == WM_T_82574)
-		return EXTRXC_ERROR(rxq->rxq_ext_descs[idx].erx_ctx.erxc_err_stat);
+		return EXTRXC_ERROR(
+		le32toh(rxq->rxq_ext_descs[idx].erx_ctx.erxc_err_stat));
 	else if ((sc->sc_flags & WM_F_NEWQUEUE) != 0)
-		return NQRXC_ERROR(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_err_stat);
+		return NQRXC_ERROR(
+		le32toh(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_err_stat));
 	else
 		return rxq->rxq_descs[idx].wrx_errors;
 }



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

2020-11-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 14 12:59:06 UTC 2020

Modified Files:
src/sys/coda [netbsd-8]: coda.h coda_vnops.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1622):

sys/coda/coda_vnops.c: revision 1.114 (patch)
sys/coda/coda.h: revision 1.21 (patch)

Rewrite coda_readdir() to directly process the container file.

Passing this operation down to the file system holding the container
cannot work for anything but UFS and UFS doesn't allow reading
directory from a plain file since ~2015.

Fixes PR kern/55775 Coda client, its in-kernel part, opens wrong files ...


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.10.1 src/sys/coda/coda.h
cvs rdiff -u -r1.106 -r1.106.2.1 src/sys/coda/coda_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/coda/coda.h
diff -u src/sys/coda/coda.h:1.19 src/sys/coda/coda.h:1.19.10.1
--- src/sys/coda/coda.h:1.19	Sun Sep  6 06:00:59 2015
+++ src/sys/coda/coda.h	Sat Nov 14 12:59:06 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: coda.h,v 1.19 2015/09/06 06:00:59 dholland Exp $ */
+/* $NetBSD: coda.h,v 1.19.10.1 2020/11/14 12:59:06 martin Exp $ */
 
 /*
 
@@ -61,6 +61,10 @@ Mellon the rights to redistribute these 
 #define CODA_MAXSYMLINKS 10
 #endif
 
+#ifndef CODA_DIRBLKSIZ
+#define CODA_DIRBLKSIZ 0x1000
+#endif
+
 #if defined(DJGPP) || defined(__CYGWIN32__)
 #ifdef KERNEL
 typedef unsigned long u_long;
@@ -169,7 +173,7 @@ struct venus_dirent {
 #ifndef _VENUS_DIRENT_T_
 #define _VENUS_DIRENT_T_ 1
 struct venus_dirent {
-unsigned long	d_fileno;		/* file number of entry */
+unsigned int	d_fileno;		/* file number of entry */
 unsigned short	d_reclen;		/* length of this record */
 unsigned char 	d_type;			/* file type, see below */
 unsigned char	d_namlen;		/* length of string in d_name */

Index: src/sys/coda/coda_vnops.c
diff -u src/sys/coda/coda_vnops.c:1.106 src/sys/coda/coda_vnops.c:1.106.2.1
--- src/sys/coda/coda_vnops.c:1.106	Fri May 26 14:21:00 2017
+++ src/sys/coda/coda_vnops.c	Sat Nov 14 12:59:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: coda_vnops.c,v 1.106 2017/05/26 14:21:00 riastradh Exp $	*/
+/*	$NetBSD: coda_vnops.c,v 1.106.2.1 2020/11/14 12:59:06 martin Exp $	*/
 
 /*
  *
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.106 2017/05/26 14:21:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.106.2.1 2020/11/14 12:59:06 martin Exp $");
 
 #include 
 #include 
@@ -62,6 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: coda_vnops.c
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1526,63 +1527,143 @@ int
 coda_readdir(void *v)
 {
 /* true args */
-struct vop_readdir_args *ap = v;
-vnode_t *vp = ap->a_vp;
-struct cnode *cp = VTOC(vp);
-struct uio *uiop = ap->a_uio;
-kauth_cred_t cred = ap->a_cred;
-int *eofflag = ap->a_eofflag;
-off_t **cookies = ap->a_cookies;
-int *ncookies = ap->a_ncookies;
+	struct vop_readdir_args *ap = v;
+	vnode_t *vp = ap->a_vp;
+	struct cnode *cp = VTOC(vp);
+	struct uio *uiop = ap->a_uio;
+	kauth_cred_t cred = ap->a_cred;
+	int *eofflag = ap->a_eofflag;
 /* upcall decl */
 /* locals */
-int error = 0;
-
-MARK_ENTRY(CODA_READDIR_STATS);
-
-CODADEBUG(CODA_READDIR, myprintf(("%s: (%p, %lu, %lld)\n", __func__,
-	uiop->uio_iov->iov_base, (unsigned long) uiop->uio_resid,
-	(long long) uiop->uio_offset)); )
-
-/* Check for readdir of control object. */
-if (IS_CTL_VP(vp)) {
-	MARK_INT_FAIL(CODA_READDIR_STATS);
-	return(ENOENT);
-}
+	size_t initial_resid = uiop->uio_resid;
+	int error = 0;
+	int opened_internally = 0;
+	int ncookies;
+	char *buf;
+	struct vnode *cvp;
+	struct dirent *dirp;
+
+	MARK_ENTRY(CODA_READDIR_STATS);
+
+	CODADEBUG(CODA_READDIR, myprintf(("%s: (%p, %lu, %lld)\n", __func__,
+	uiop->uio_iov->iov_base, (unsigned long) uiop->uio_resid,
+	(long long) uiop->uio_offset)); )
 
-{
-	/* Redirect the request to UFS. */
+	/* Check for readdir of control object. */
+	if (IS_CTL_VP(vp)) {
+		MARK_INT_FAIL(CODA_READDIR_STATS);
+		return ENOENT;
+	}
 
 	/* If directory is not already open do an "internal open" on it. */
-	int opened_internally = 0;
 	if (cp->c_ovp == NULL) {
-	opened_internally = 1;
-	MARK_INT_GEN(CODA_OPEN_STATS);
-	error = VOP_OPEN(vp, FREAD, cred);
+		opened_internally = 1;
+		MARK_INT_GEN(CODA_OPEN_STATS);
+		error = VOP_OPEN(vp, FREAD, cred);
 #ifdef	CODA_VERBOSE
-	printf("%s: Internally Opening %p\n", __func__, vp);
+		printf("%s: Internally Opening %p\n", __func__, vp);
 #endif
-	if (error) return(error);
-	} else
-	vp = cp->c_ovp;
+		if (error)
+			return error;
+		KASSERT(cp->c_ovp != NULL);
+	}
+	cvp = cp->c_ovp;
 
-	/* Have UFS handle the call. */
 	CODADEBUG(CODA_READDIR, myprintf(("%s: fid = %s, refcnt = %d\n",
-	__func__, coda_f2s(&cp->c_fid), 

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

2020-11-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov  4 11:51:57 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: if_wm.c if_wmvar.h

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

sys/dev/pci/if_wm.c: revision 1.694
sys/dev/pci/if_wm.c: revision 1.695 (via patch)
sys/dev/pci/if_wmvar.h: revision 1.47

Add WMPHY_I350. Not used yet.

Workaround for ihphy and atphy(ICH*/PCH*, 82580 and I350).
These phys stop DMA while link is down which causes device timeout.
Fix PR/kern 40981
Reviewed and tested by msaitoh@n.o, thanks.
XXX pullup-[89]


To generate a diff of this commit:
cvs rdiff -u -r1.508.4.40 -r1.508.4.41 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.33.6.6 -r1.33.6.7 src/sys/dev/pci/if_wmvar.h

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.40 src/sys/dev/pci/if_wm.c:1.508.4.41
--- src/sys/dev/pci/if_wm.c:1.508.4.40	Fri Oct 16 08:06:02 2020
+++ src/sys/dev/pci/if_wm.c	Wed Nov  4 11:51:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.508.4.40 2020/10/16 08:06:02 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508.4.41 2020/11/04 11:51:57 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.40 2020/10/16 08:06:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.41 2020/11/04 11:51:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -374,7 +374,8 @@ struct wm_txqueue {
 	 * to manage Tx H/W queue's busy flag.
 	 */
 	int txq_flags;			/* flags for H/W queue, see below */
-#define	WM_TXQ_NO_SPACE	0x1
+#define	WM_TXQ_NO_SPACE		0x1
+#define	WM_TXQ_LINKDOWN_DISCARD	0x2
 
 	bool txq_stopping;
 
@@ -1018,6 +1019,9 @@ static void	wm_toggle_lanphypc_pch_lpt(s
 static int	wm_platform_pm_pch_lpt(struct wm_softc *, bool);
 static void	wm_pll_workaround_i210(struct wm_softc *);
 static void	wm_legacy_irq_quirk_spt(struct wm_softc *);
+static bool	wm_phy_need_linkdown_discard(struct wm_softc *);
+static void	wm_set_linkdown_discard(struct wm_softc *);
+static void	wm_clear_linkdown_discard(struct wm_softc *);
 
 CFATTACH_DECL3_NEW(wm, sizeof(struct wm_softc),
 wm_match, wm_attach, wm_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
@@ -3041,6 +3045,9 @@ alloc_retry:
 
 	sc->sc_txrx_use_workqueue = false;
 
+	if (wm_phy_need_linkdown_discard(sc))
+		wm_set_linkdown_discard(sc);
+
 	wm_init_sysctls(sc);
 
 	if (pmf_device_register(self, wm_suspend, wm_resume))
@@ -3399,6 +3406,49 @@ out:
 	return rc;
 }
 
+static bool
+wm_phy_need_linkdown_discard(struct wm_softc *sc)
+{
+
+	switch(sc->sc_phytype) {
+	case WMPHY_82577: /* ihphy */
+	case WMPHY_82578: /* atphy */
+	case WMPHY_82579: /* ihphy */
+	case WMPHY_I217: /* ihphy */
+	case WMPHY_82580: /* ihphy */
+	case WMPHY_I350: /* ihphy */
+		return true;
+	default:
+		return false;
+	}
+}
+
+static void
+wm_set_linkdown_discard(struct wm_softc *sc)
+{
+
+	for (int i = 0; i < sc->sc_nqueues; i++) {
+		struct wm_txqueue *txq = &sc->sc_queue[i].wmq_txq;
+
+		mutex_enter(txq->txq_lock);
+		txq->txq_flags |= WM_TXQ_LINKDOWN_DISCARD;
+		mutex_exit(txq->txq_lock);
+	}
+}
+
+static void
+wm_clear_linkdown_discard(struct wm_softc *sc)
+{
+
+	for (int i = 0; i < sc->sc_nqueues; i++) {
+		struct wm_txqueue *txq = &sc->sc_queue[i].wmq_txq;
+
+		mutex_enter(txq->txq_lock);
+		txq->txq_flags &= ~WM_TXQ_LINKDOWN_DISCARD;
+		mutex_exit(txq->txq_lock);
+	}
+}
+
 /*
  * wm_ioctl:		[ifnet interface function]
  *
@@ -3442,6 +3492,12 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 #ifdef WM_MPSAFE
 		splx(s);
 #endif
+		if (error == 0 && wm_phy_need_linkdown_discard(sc)) {
+			if (IFM_SUBTYPE(ifr->ifr_media) == IFM_NONE)
+wm_set_linkdown_discard(sc);
+			else
+wm_clear_linkdown_discard(sc);
+		}
 		break;
 	case SIOCINITIFADDR:
 		WM_CORE_LOCK(sc);
@@ -3456,8 +3512,17 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 			break;
 		}
 		WM_CORE_UNLOCK(sc);
+		if (((ifp->if_flags & IFF_UP) == 0) && wm_phy_need_linkdown_discard(sc))
+			wm_clear_linkdown_discard(sc);
 		/*FALLTHROUGH*/
 	default:
+		if (cmd == SIOCSIFFLAGS && wm_phy_need_linkdown_discard(sc)) {
+			if (((ifp->if_flags & IFF_UP) == 0) && ((ifr->ifr_flags & IFF_UP) != 0)) {
+wm_clear_linkdown_discard(sc);
+			} else if (((ifp->if_flags & IFF_UP) != 0) && ((ifr->ifr_flags & IFF_UP) == 0)) {
+wm_set_linkdown_discard(sc);
+			}
+		}
 #ifdef WM_MPSAFE
 		s = splnet();
 #endif
@@ -7542,6 +7607,16 @@ wm_select_txqueue(struct ifnet *ifp, str
 	return ((cpuid + ncpu - sc->sc_affinity_offset) % ncpu) % sc->sc_nqueues;
 }
 
+static inline bool
+wm_linkdown_discard(struct wm_txqueue *txq)
+{
+
+	if ((txq->txq_flags & WM_TXQ_LINKDOWN_DISCARD) != 0)
+		return true;
+
+	return false;
+}
+
 /*
  * wm_start:		[ifnet interface function]
  *
@@ -7636,6 +7711,23 @@ wm_

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

2020-10-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 16 08:06:02 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: if_wm.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1617):

sys/dev/pci/if_wm.c: revision 1.691

  Fixes a problem that the attach function reported
"wm_gmii_setup_phytype: Unknown PHY model. OUI=00, model=" and
"PHY type is still unknown." Don't call wm_gmii_setup_phytype() three times if
the interface uses SGMII with internal MDIO.

  Tested with I354(Rangeley(SGMII(MDIO))) and I350(SERDES(SFP), SGMII(SFP)).


To generate a diff of this commit:
cvs rdiff -u -r1.508.4.39 -r1.508.4.40 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.39 src/sys/dev/pci/if_wm.c:1.508.4.40
--- src/sys/dev/pci/if_wm.c:1.508.4.39	Wed Aug  5 17:22:45 2020
+++ src/sys/dev/pci/if_wm.c	Fri Oct 16 08:06:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.508.4.39 2020/08/05 17:22:45 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508.4.40 2020/10/16 08:06:02 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.39 2020/08/05 17:22:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.40 2020/10/16 08:06:02 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2847,7 +2847,8 @@ alloc_retry:
 			reg &= ~CTRL_EXT_I2C_ENA;
 		CSR_WRITE(sc, WMREG_CTRL_EXT, reg);
 		if ((sc->sc_flags & WM_F_SGMII) != 0) {
-			wm_gmii_setup_phytype(sc, 0, 0);
+			if (!wm_sgmii_uses_mdio(sc))
+wm_gmii_setup_phytype(sc, 0, 0);
 			wm_reset_mdicnfg_82580(sc);
 		}
 	} else if (sc->sc_type < WM_T_82543 ||



CVS commit: [netbsd-8] src/sys/compat/common

2020-10-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Oct 10 14:36:57 UTC 2020

Modified Files:
src/sys/compat/common [netbsd-8]: tty_43.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1614):

sys/compat/common/tty_43.c: revision 1.38

tty_43: Check a bitset from userspace is valid before shifting it

Passing a negative value to these legacy compat ioctls results in
left shift on a negative value which is undefined behaviour and results
in the tty (at least, possibly other things) locking up.
The argument to the ioctl should always be > 0. Return EINVAL otherwise.

While here, adjustments to code style to match current guidelines.
Found by UBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.30.20.1 src/sys/compat/common/tty_43.c

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

Modified files:

Index: src/sys/compat/common/tty_43.c
diff -u src/sys/compat/common/tty_43.c:1.30 src/sys/compat/common/tty_43.c:1.30.20.1
--- src/sys/compat/common/tty_43.c:1.30	Thu May 22 16:31:19 2014
+++ src/sys/compat/common/tty_43.c	Sat Oct 10 14:36:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty_43.c,v 1.30 2014/05/22 16:31:19 dholland Exp $	*/
+/*	$NetBSD: tty_43.c,v 1.30.20.1 2020/10/10 14:36:57 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tty_43.c,v 1.30 2014/05/22 16:31:19 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_43.c,v 1.30.20.1 2020/10/10 14:36:57 martin Exp $");
 
 #include 
 #include 
@@ -211,20 +211,24 @@ ttcompat(struct tty *tp, u_long com, voi
 	case TIOCLBIC:
 	case TIOCLSET: {
 		struct termios term;
-		int flags;
+		int argbits, flags;
+
+		argbits = *(int *)data;
+		if (argbits < 0)
+			return EINVAL;
 
 		mutex_spin_enter(&tty_lock);
 		term = tp->t_termios;
 		flags = ttcompatgetflags(tp);
 		switch (com) {
 		case TIOCLSET:
-			tp->t_flags = (flags&0x) | (*(int *)data<<16);
+			tp->t_flags = (flags & 0x) | (argbits << 16);
 			break;
 		case TIOCLBIS:
-			tp->t_flags = flags | (*(int *)data<<16);
+			tp->t_flags = flags | (argbits << 16);
 			break;
 		case TIOCLBIC:
-			tp->t_flags = flags & ~(*(int *)data<<16);
+			tp->t_flags = flags & ~(argbits << 16);
 			break;
 		}
 		ttcompatsetlflags(tp, &term);



CVS commit: [netbsd-8] src/sys

2020-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct  8 18:06:13 UTC 2020

Modified Files:
src/sys/netinet [netbsd-8]: in.c
src/sys/netinet6 [netbsd-8]: in6.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #1613):

sys/netinet/in.c: revision 1.241
sys/netinet6/in6.c: revision 1.282

inet: Treat LINK_STATE_UNKNOWN as LINK_STATE_UP when changing

It's something we have always done.
it's really rare for anything to transition to UNKNOWN from either
UP or DOWN, but technically it is possible.


To generate a diff of this commit:
cvs rdiff -u -r1.203.2.13 -r1.203.2.14 src/sys/netinet/in.c
cvs rdiff -u -r1.245.2.12 -r1.245.2.13 src/sys/netinet6/in6.c

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

Modified files:

Index: src/sys/netinet/in.c
diff -u src/sys/netinet/in.c:1.203.2.13 src/sys/netinet/in.c:1.203.2.14
--- src/sys/netinet/in.c:1.203.2.13	Mon Apr  9 04:04:21 2018
+++ src/sys/netinet/in.c	Thu Oct  8 18:06:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: in.c,v 1.203.2.13 2018/04/09 04:04:21 snj Exp $	*/
+/*	$NetBSD: in.c,v 1.203.2.14 2020/10/08 18:06:12 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.203.2.13 2018/04/09 04:04:21 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.203.2.14 2020/10/08 18:06:12 martin Exp $");
 
 #include "arp.h"
 
@@ -1553,14 +1553,15 @@ void
 in_if_link_state_change(struct ifnet *ifp, int link_state)
 {
 
-	switch (link_state) {
-	case LINK_STATE_DOWN:
+	/*
+	 * Treat LINK_STATE_UNKNOWN as UP.
+	 * LINK_STATE_UNKNOWN transitions to LINK_STATE_DOWN when
+	 * if_link_state_change() transitions to LINK_STATE_UP.
+	 */
+	if (link_state == LINK_STATE_DOWN)
 		in_if_link_down(ifp);
-		break;
-	case LINK_STATE_UP:
+	else
 		in_if_link_up(ifp);
-		break;
-	}
 }
 
 /*

Index: src/sys/netinet6/in6.c
diff -u src/sys/netinet6/in6.c:1.245.2.12 src/sys/netinet6/in6.c:1.245.2.13
--- src/sys/netinet6/in6.c:1.245.2.12	Tue Nov  6 14:38:58 2018
+++ src/sys/netinet6/in6.c	Thu Oct  8 18:06:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.245.2.12 2018/11/06 14:38:58 martin Exp $	*/
+/*	$NetBSD: in6.c,v 1.245.2.13 2020/10/08 18:06:13 martin Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.245.2.12 2018/11/06 14:38:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.245.2.13 2020/10/08 18:06:13 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2325,14 +2325,15 @@ void
 in6_if_link_state_change(struct ifnet *ifp, int link_state)
 {
 
-	switch (link_state) {
-	case LINK_STATE_DOWN:
+	/*
+	 * Treat LINK_STATE_UNKNOWN as UP.
+	 * LINK_STATE_UNKNOWN transitions to LINK_STATE_DOWN when
+	 * if_link_state_change() transitions to LINK_STATE_UP.
+	 */
+	if (link_state == LINK_STATE_DOWN)
 		in6_if_link_down(ifp);
-		break;
-	case LINK_STATE_UP:
+	else
 		in6_if_link_up(ifp);
-		break;
-	}
 }
 
 /*



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

2020-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct  8 17:50:11 UTC 2020

Modified Files:
src/sys/netipsec [netbsd-8]: xform_esp.c

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

sys/netipsec/xform_esp.c: revision 1.101

Make sequence number of esp header MP-safe for IPsec Tx side. reviewed by 
ozaki-r@n.o

In IPsec Tx side, one Security Association can be used by multiple CPUs.
On the other hand, in IPsec Rx side, one Security Association is used
by only one CPU.

XXX pullup-{8,9}


To generate a diff of this commit:
cvs rdiff -u -r1.55.2.3 -r1.55.2.4 src/sys/netipsec/xform_esp.c

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

Modified files:

Index: src/sys/netipsec/xform_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.55.2.3 src/sys/netipsec/xform_esp.c:1.55.2.4
--- src/sys/netipsec/xform_esp.c:1.55.2.3	Fri Mar 30 11:53:13 2018
+++ src/sys/netipsec/xform_esp.c	Thu Oct  8 17:50:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.55.2.3 2018/03/30 11:53:13 martin Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.55.2.4 2020/10/08 17:50:11 martin Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.55.2.3 2018/03/30 11:53:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.55.2.4 2020/10/08 17:50:11 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -804,11 +804,12 @@ esp_output(struct mbuf *m, const struct 
 
 #ifdef IPSEC_DEBUG
 		/* Emulate replay attack when ipsec_replay is TRUE. */
-		if (!ipsec_replay)
+		if (ipsec_replay)
+			replay = htonl(sav->replay->count);
+		else
 #endif
-			sav->replay->count++;
+			replay = htonl(atomic_inc_32_nv(&sav->replay->count));
 
-		replay = htonl(sav->replay->count);
 		memcpy(mtod(mo,char *) + roff + sizeof(uint32_t), &replay,
 		sizeof(uint32_t));
 	}



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

2020-09-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 27 10:33:45 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-8]: ld_nvme.c nvme.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1610):

sys/dev/ic/ld_nvme.c: revision 1.24 (patch)
sys/dev/ic/nvme.c: revision 1.50 (patch)

PR kern/55674:
move name space availability check from ld_nvme.c:ld_nvme_attach()
to nvme.c:nvme_rescan().
this avoids allocation of ld(4) instances for every possible
name space, even if it is not usable. it also reduces the device
node flood generated from that strategy.


To generate a diff of this commit:
cvs rdiff -u -r1.16.2.4 -r1.16.2.5 src/sys/dev/ic/ld_nvme.c
cvs rdiff -u -r1.30.2.7 -r1.30.2.8 src/sys/dev/ic/nvme.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/ic/ld_nvme.c
diff -u src/sys/dev/ic/ld_nvme.c:1.16.2.4 src/sys/dev/ic/ld_nvme.c:1.16.2.5
--- src/sys/dev/ic/ld_nvme.c:1.16.2.4	Mon Oct 28 18:27:47 2019
+++ src/sys/dev/ic/ld_nvme.c	Sun Sep 27 10:33:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.16.2.4 2019/10/28 18:27:47 martin Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.16.2.5 2020/09/27 10:33:45 martin Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.16.2.4 2019/10/28 18:27:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.16.2.5 2020/09/27 10:33:45 martin Exp $");
 
 #include 
 #include 
@@ -86,7 +86,6 @@ ld_nvme_attach(device_t parent, device_t
 	struct nvme_attach_args *naa = aux;
 	struct nvme_namespace *ns;
 	struct nvm_namespace_format *f;
-	int error;
 
 	ld->sc_dv = self;
 	sc->sc_nvme = nsc;
@@ -95,28 +94,11 @@ ld_nvme_attach(device_t parent, device_t
 	aprint_naive("\n");
 	aprint_normal("\n");
 
-	error = nvme_ns_identify(sc->sc_nvme, sc->sc_nsid);
-	if (error) {
-		aprint_error_dev(self, "couldn't identify namespace\n");
-		return;
-	}
-
 	ns = nvme_ns_get(sc->sc_nvme, sc->sc_nsid);
 	KASSERT(ns);
-	f = &ns->ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
 
-	/*
-	 * NVME1.0e 6.11 Identify command
-	 *
-	 * LBADS values smaller than 9 are not supported, a value
-	 * of zero means that the format is not used.
-	 */
-	if (f->lbads < 9) {
-		if (f->lbads > 0)
-			aprint_error_dev(self,
-			"unsupported logical data size %u\n", f->lbads);
-		return;
-	}
+	f = &ns->ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
+	KASSERT(f->lbads >= 9); /* only valid LBA data sizes allowed here */
 
 	ld->sc_secsize = 1 << f->lbads;
 	ld->sc_secperunit = ns->ident->nsze;

Index: src/sys/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.30.2.7 src/sys/dev/ic/nvme.c:1.30.2.8
--- src/sys/dev/ic/nvme.c:1.30.2.7	Mon Nov 11 17:17:22 2019
+++ src/sys/dev/ic/nvme.c	Sun Sep 27 10:33:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.30.2.7 2019/11/11 17:17:22 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.30.2.8 2020/09/27 10:33:45 martin Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.7 2019/11/11 17:17:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.8 2020/09/27 10:33:45 martin Exp $");
 
 #include 
 #include 
@@ -469,23 +469,52 @@ nvme_rescan(device_t self, const char *a
 {
 	struct nvme_softc *sc = device_private(self);
 	struct nvme_attach_args naa;
+	struct nvm_namespace_format *f;
+	struct nvme_namespace *ns;
 	uint64_t cap;
 	int ioq_entries = nvme_ioq_size;
 	int i;
+	int error;
 
 	cap = nvme_read8(sc, NVME_CAP);
 	if (ioq_entries > NVME_CAP_MQES(cap))
 		ioq_entries = NVME_CAP_MQES(cap);
 
-	for (i = 0; i < sc->sc_nn; i++) {
-		if (sc->sc_namespaces[i].dev)
+	for (i = 1; i <= sc->sc_nn; i++) {
+		if (sc->sc_namespaces[i - 1].dev)
 			continue;
-		memset(&naa, 0, sizeof(naa));
-		naa.naa_nsid = i + 1;
-		naa.naa_qentries = (ioq_entries - 1) * sc->sc_nq;
-		naa.naa_maxphys = sc->sc_mdts;
-		sc->sc_namespaces[i].dev = config_found(sc->sc_dev, &naa,
-		nvme_print);
+
+		/* identify to check for availability */
+		error = nvme_ns_identify(sc, i);
+		if (error) {
+			aprint_error_dev(self, "couldn't identify namespace #%d\n", i);
+			continue;
+		}
+
+		ns = nvme_ns_get(sc, i);
+		KASSERT(ns);
+
+		f = &ns->ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
+
+		/*
+		 * NVME1.0e 6.11 Identify command
+		 *
+		 * LBADS values smaller than 9 are not supported, a value
+		 * of zero means that the format is not used.
+		 */
+		if (f->lbads < 9) {
+			if (f->lbads > 0)
+aprint_error_dev(self,
+		 "unsupported logical data size %u\n", f->lbads);
+ 			continue;
+		}
+
+ 		memset(&naa, 0, sizeof(naa));
+		naa.naa_nsid = i;
+ 		naa.naa_qentries = (ioq_entries - 1) * sc->sc_nq;
+ 		naa.naa_maxphys = sc->sc_mdts;
+		sc->sc_namespaces[i - 1].dev = config_found(sc->sc_dev, &naa,
+ 		nvme_print);
 	}
 	return 0;
 }


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

2020-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 23 14:31:47 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: virtio.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1609):

sys/dev/pci/virtio_pci.c: revision 1.13 (patch)
(applied to sys/dev/pci/virtio.c)

Ensure MSI-X is disabled if allocation of MSI-X interrupts fail.

The virtio device config space moves out from under us when MSI-X
remains enabled, and/or INTx interrupts are masked if we don't ensure
this.

This un-breaks virtio devices that run out of MSI-X interrupts.
Particularly a problem on uniproc x86, where there are only 8 or 9
vectors available, allowing for only about 4 virtio devices to use
MSI-X.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.2 -r1.28.2.3 src/sys/dev/pci/virtio.c

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

Modified files:

Index: src/sys/dev/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.28.2.2 src/sys/dev/pci/virtio.c:1.28.2.3
--- src/sys/dev/pci/virtio.c:1.28.2.2	Sun Sep 20 10:14:20 2020
+++ src/sys/dev/pci/virtio.c	Wed Sep 23 14:31:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $	*/
+/*	$NetBSD: virtio.c,v 1.28.2.3 2020/09/23 14:31:46 martin Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.3 2020/09/23 14:31:46 martin Exp $");
 
 #include 
 #include 
@@ -280,10 +280,13 @@ virtio_setup_interrupts(struct virtio_so
 {
 	device_t self = sc->sc_dev;
 	pci_chipset_tag_t pc = sc->sc_pa.pa_pc;
+	pcitag_t tag = sc->sc_pa.pa_tag;
 	int error;
 	int nmsix;
+	int off;
 	int counts[PCI_INTR_TYPE_SIZE];
 	pci_intr_type_t max_type;
+	pcireg_t ctl;
 
 	nmsix = pci_msix_count(sc->sc_pa.pa_pc, sc->sc_pa.pa_tag);
 	aprint_debug_dev(self, "pci_msix_count=%d\n", nmsix);
@@ -338,6 +341,13 @@ virtio_setup_interrupts(struct virtio_so
 
 		sc->sc_ihs_num = 1;
 		sc->sc_config_offset = VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI;
+
+		error = pci_get_capability(pc, tag, PCI_CAP_MSIX, &off, NULL);
+		if (error != 0) {
+			ctl = pci_conf_read(pc, tag, off + PCI_MSIX_CTL);
+			ctl &= ~PCI_MSIX_CTL_ENABLE;
+			pci_conf_write(pc, tag, off + PCI_MSIX_CTL, ctl);
+		}
 	}
 
 	KASSERT(sc->sc_soft_ih == NULL);



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

2020-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 20 10:14:20 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: virtio.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1608):

sys/dev/pci/virtio_pci.c: revision 1.12

Ensure interrupt handles buffer is zeroed on allocation
Prevents crashes trying to deallocate interrupts at shutdown.

Found by kim and mlelstv, confirmed by me


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.1 -r1.28.2.2 src/sys/dev/pci/virtio.c

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

Modified files:

Index: src/sys/dev/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.28.2.1 src/sys/dev/pci/virtio.c:1.28.2.2
--- src/sys/dev/pci/virtio.c:1.28.2.1	Mon Feb 19 18:19:15 2018
+++ src/sys/dev/pci/virtio.c	Sun Sep 20 10:14:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.28.2.1 2018/02/19 18:19:15 snj Exp $	*/
+/*	$NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.1 2018/02/19 18:19:15 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $");
 
 #include 
 #include 
@@ -309,7 +309,7 @@ virtio_setup_interrupts(struct virtio_so
 	}
 
 	if (pci_intr_type(pc, sc->sc_ihp[0]) == PCI_INTR_TYPE_MSIX) {
-		sc->sc_ihs = kmem_alloc(sizeof(*sc->sc_ihs) * 2,
+		sc->sc_ihs = kmem_zalloc(sizeof(*sc->sc_ihs) * 2,
 		KM_SLEEP);
 
 		error = virtio_setup_msix_interrupts(sc, &sc->sc_pa);
@@ -326,7 +326,7 @@ virtio_setup_interrupts(struct virtio_so
 		sc->sc_ihs_num = 2;
 		sc->sc_config_offset = VIRTIO_CONFIG_DEVICE_CONFIG_MSI;
 	} else if (pci_intr_type(pc, sc->sc_ihp[0]) == PCI_INTR_TYPE_INTX) {
-		sc->sc_ihs = kmem_alloc(sizeof(*sc->sc_ihs) * 1,
+		sc->sc_ihs = kmem_zalloc(sizeof(*sc->sc_ihs) * 1,
 		KM_SLEEP);
 
 		error = virtio_setup_intx_interrupt(sc, &sc->sc_pa);



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

2020-09-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 19 12:20:36 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: ukbdmap.c

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

sys/dev/hid/hidkbdmap.c: revision 1.11 (patch)
(applied to sys/dev/usb/ukbdmap.c)

for jp keymap map also scan code 49 to right bracket to handle ARCHISS model
PR kern/55608 by Shinichi Doyashiki


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.10.1 src/sys/dev/usb/ukbdmap.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/ukbdmap.c
diff -u src/sys/dev/usb/ukbdmap.c:1.31 src/sys/dev/usb/ukbdmap.c:1.31.10.1
--- src/sys/dev/usb/ukbdmap.c:1.31	Sat Apr 23 10:15:32 2016
+++ src/sys/dev/usb/ukbdmap.c	Sat Sep 19 12:20:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukbdmap.c,v 1.31 2016/04/23 10:15:32 skrll Exp $	*/
+/*	$NetBSD: ukbdmap.c,v 1.31.10.1 2020/09/19 12:20:36 martin Exp $	*/
 
 /*
  * Copyright (c) 1999,2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ukbdmap.c,v 1.31 2016/04/23 10:15:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbdmap.c,v 1.31.10.1 2020/09/19 12:20:36 martin Exp $");
 
 #include 
 #include 
@@ -171,7 +171,8 @@ Static const keysym_t ukbd_keydesc_jp[] 
 KC(46),			KS_asciicircum,		KS_asciitilde,
 KC(47),			KS_at,			KS_grave,
 KC(48),			KS_bracketleft,		KS_braceleft,
-KC(50),			KS_bracketright,	KS_braceright,
+KC(49), /* ARCHISS */	KS_bracketright,	KS_braceright,
+KC(50), /* other model */	KS_bracketright,	KS_braceright,
 KC(51),			KS_semicolon,		KS_plus,
 KC(52),			KS_colon,		KS_asterisk,
 KC(53), 			KS_Zenkaku_Hankaku, /* replace grave/tilde */



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

2020-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 16 13:31:20 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-8]: mpt_netbsd.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1605):

sys/dev/ic/mpt_netbsd.c: revision 1.37

max_devices is a 8bit value and zero is interpreted as 256. This value
can be reported by an mpt device emulated by VMware ESXi.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.10.1 src/sys/dev/ic/mpt_netbsd.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/ic/mpt_netbsd.c
diff -u src/sys/dev/ic/mpt_netbsd.c:1.33 src/sys/dev/ic/mpt_netbsd.c:1.33.10.1
--- src/sys/dev/ic/mpt_netbsd.c:1.33	Mon May  2 19:18:29 2016
+++ src/sys/dev/ic/mpt_netbsd.c	Wed Sep 16 13:31:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpt_netbsd.c,v 1.33 2016/05/02 19:18:29 christos Exp $	*/
+/*	$NetBSD: mpt_netbsd.c,v 1.33.10.1 2020/09/16 13:31:20 martin Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.33 2016/05/02 19:18:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.33.10.1 2020/09/16 13:31:20 martin Exp $");
 
 #include "bio.h"
 
@@ -151,7 +151,7 @@ mpt_scsipi_attach(mpt_softc_t *mpt)
 	chan->chan_channel = 0;
 	chan->chan_flags = 0;
 	chan->chan_nluns = 8;
-	chan->chan_ntargets = mpt->mpt_max_devices;
+	chan->chan_ntargets = mpt->mpt_max_devices ? mpt->mpt_max_devices : 256;
 	chan->chan_id = mpt->mpt_ini_id;
 
 	/*



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

2020-09-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 13 12:16:34 UTC 2020

Modified Files:
src/sys/netinet [netbsd-8]: tcp_input.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1604):

sys/netinet/tcp_input.c: revision 1.420

PR/kern 55567
fix the data-only fast path. RCV.UP and SND.WL1 could be left behind
on long sequences of data only packets. pull them along to avoid relative
sequence wraps.
consistent with FreeBSD

addresses second failure mode of PR/kern 55567.
pullup to netbsd-8
pullup to netbsd-9


To generate a diff of this commit:
cvs rdiff -u -r1.357.4.6 -r1.357.4.7 src/sys/netinet/tcp_input.c

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

Modified files:

Index: src/sys/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.357.4.6 src/sys/netinet/tcp_input.c:1.357.4.7
--- src/sys/netinet/tcp_input.c:1.357.4.6	Thu Sep  3 13:40:41 2020
+++ src/sys/netinet/tcp_input.c	Sun Sep 13 12:16:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.357.4.6 2020/09/03 13:40:41 martin Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.357.4.7 2020/09/13 12:16:34 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.6 2020/09/03 13:40:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.7 2020/09/13 12:16:34 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2061,13 +2061,25 @@ after_listen:
 			 * we have enough buffer space to take it.
 			 */
 			tp->rcv_nxt += tlen;
+
+			/*
+			 * Pull rcv_up up to prevent seq wrap relative to
+			 * rcv_nxt.
+			 */
+			tp->rcv_up = tp->rcv_nxt;
+
+			/*
+			 * Pull snd_wl1 up to prevent seq wrap relative to
+			 * th_seq.
+			 */
+			tp->snd_wl1 = th->th_seq;
+
 			tcps = TCP_STAT_GETREF();
 			tcps[TCP_STAT_PREDDAT]++;
 			tcps[TCP_STAT_RCVPACK]++;
 			tcps[TCP_STAT_RCVBYTE] += tlen;
 			TCP_STAT_PUTREF();
 			nd6_hint(tp);
-
 		/*
 		 * Automatic sizing enables the performance of large buffers
 		 * and most of the efficiency of small ones by only allocating



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

2020-09-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep  3 13:40:41 UTC 2020

Modified Files:
src/sys/netinet [netbsd-8]: tcp_input.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1602):

sys/netinet/tcp_input.c: revision 1.419

Fix fast path for uni directional transfers

pure ACK case:
drag snd_wl2 along so only newer
ACKs can update the window size.

also avoids the state where snd_wl2
is eventually larger than th_ack and thus
blocking the window update mechanism and
the connection gets stuck for a lng
time in the zero sized send window state.

see PR/kern 55567

ok thorpej@, also found in FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.357.4.5 -r1.357.4.6 src/sys/netinet/tcp_input.c

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

Modified files:

Index: src/sys/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.357.4.5 src/sys/netinet/tcp_input.c:1.357.4.6
--- src/sys/netinet/tcp_input.c:1.357.4.5	Wed Jul  8 13:48:36 2020
+++ src/sys/netinet/tcp_input.c	Thu Sep  3 13:40:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.357.4.5 2020/07/08 13:48:36 martin Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.357.4.6 2020/09/03 13:40:41 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.5 2020/07/08 13:48:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.6 2020/09/03 13:40:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2009,6 +2009,19 @@ after_listen:
 tp->snd_fack = tp->snd_una;
 if (SEQ_LT(tp->snd_high, tp->snd_una))
 	tp->snd_high = tp->snd_una;
+/*
+ * drag snd_wl2 along so only newer
+ * ACKs can update the window size.
+ * also avoids the state where snd_wl2
+ * is eventually larger than th_ack and thus
+ * blocking the window update mechanism and
+ * the connection gets stuck for a lng
+ * time in the zero sized send window state.
+ *
+ * see PR/kern 55567
+ */
+tp->snd_wl2 = tp->snd_una;
+
 m_freem(m);
 
 /*



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

2020-09-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep  2 12:27:54 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-8]: ixgbe.c ixgbe_82598.c ixgbe_82599.c
ixgbe_phy.c ixgbe_type.h ixgbe_x550.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1601):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
   If an unsupported SFP module is inserted before booting, the driver attach
   failed and there was no way to recover form it without rebooting or
   detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
   We can automatically recover any time by replacing it with a supported
   module.


To generate a diff of this commit:
cvs rdiff -u -r1.88.2.41 -r1.88.2.42 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.8.8.4 -r1.8.8.5 src/sys/dev/pci/ixgbe/ixgbe_82598.c
cvs rdiff -u -r1.14.8.5 -r1.14.8.6 src/sys/dev/pci/ixgbe/ixgbe_82599.c
cvs rdiff -u -r1.11.6.6 -r1.11.6.7 src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.22.2.11 -r1.22.2.12 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.5.6.8 -r1.5.6.9 src/sys/dev/pci/ixgbe/ixgbe_x550.c

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

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.41 src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.42
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.41	Wed Sep  2 12:24:08 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Sep  2 12:27:54 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.41 2020/09/02 12:24:08 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.42 2020/09/02 12:27:54 martin Exp $ */
 
 /**
 
@@ -776,6 +776,7 @@ ixgbe_attach(device_t parent, device_t d
 	pcireg_t	id, subid;
 	const ixgbe_vendor_info_t *ent;
 	struct pci_attach_args *pa = aux;
+	bool unsupported_sfp = false;
 	const char *str;
 	char buf[256];
 
@@ -956,8 +957,8 @@ ixgbe_attach(device_t parent, device_t d
 		error = IXGBE_SUCCESS;
 	} else if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) {
 		aprint_error_dev(dev, "Unsupported SFP+ module detected!\n");
-		error = EIO;
-		goto err_late;
+		unsupported_sfp = true;
+		error = IXGBE_SUCCESS;
 	} else if (error) {
 		aprint_error_dev(dev, "Hardware initialization failed\n");
 		error = EIO;
@@ -1126,13 +1127,6 @@ ixgbe_attach(device_t parent, device_t d
 		"please contact your Intel or hardware representative "
 		"who provided you with this hardware.\n");
 		break;
-	case IXGBE_ERR_SFP_NOT_SUPPORTED:
-		aprint_error_dev(dev, "Unsupported SFP+ Module\n");
-		error = EIO;
-		goto err_late;
-	case IXGBE_ERR_SFP_NOT_PRESENT:
-		aprint_error_dev(dev, "No SFP+ Module found\n");
-		/* falls thru */
 	default:
 		break;
 	}
@@ -1165,16 +1159,22 @@ ixgbe_attach(device_t parent, device_t d
 			oui, model, rev);
 	}
 
-	/* Enable the optics for 82599 SFP+ fiber */
-	ixgbe_enable_tx_laser(hw);
-
 	/* Enable EEE power saving */
 	if (adapter->feat_cap & IXGBE_FEATURE_EEE)
 		hw->mac.ops.setup_eee(hw,
 		adapter->feat_en & IXGBE_FEATURE_EEE);
 
 	/* Enable power to the phy. */
-	ixgbe_set_phy_power(hw, TRUE);
+	if (!unsupported_sfp) {
+		/* Enable the optics for 82599 SFP+ fiber */
+		ixgbe_enable_tx_laser(hw);
+
+		/*
+		 * XXX Currently, ixgbe_set_phy_power() supports only copper
+		 * PHY, so it's not required to test with !unsupported_sfp.
+		 */
+		ixgbe_set_phy_power(hw, TRUE);
+	}
 
 	/* Initialize statistics */
 	ixgbe_update_stats_counters(adapter);
@@ -3860,6 +3860,7 @@ ixgbe_init_locked(struct adapter *adapte
 	u32		txdctl, mhadd;
 	u32		rxdctl, rxctrl;
 	u32		ctrl_ext;
+	bool		unsupported_sfp = false;
 	int		i, j, err;
 
 	/* XXX check IFF_UP and IFF_RUNNING, power-saving state! */
@@ -3867,6 +3868,7 @@ ixgbe_init_locked(struct adapter *adapte
 	KASSERT(mutex_owned(&adapter->core_mtx));
 	INIT_DEBUGOUT("ixgbe_init_locked: begin");
 
+	hw->need_unsupported_sfp_recovery = false;
 	hw->adapter_stopped = FALSE;
 	ixgbe_stop_adapter(hw);
 	callout_stop(&adapter->timer);
@@ -4040,12 +4042,14 @@ ixgbe_init_locked(struct adapter *adapte
 	 */
 	if (hw->phy.type == ixgbe_phy_none) {
 		err = hw->phy.ops.identify(hw);
-		if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
-			device_printf(dev,
-			"Unsupported SFP+ module type was detected.\n");
-			return;
-		}
-	}
+		if (err == IXGBE_ERR_SFP_NOT_SUPPORTED)
+			unsupported_sfp = true;
+	} else if (hw->phy.type == ixgbe_phy_sfp_unsupported)
+		unsupported_sfp = true;
+
+	if (unsupported_sfp)
+		device_printf(dev,
+		"Unsupported SFP+ module type was detected.\n");
 
 	/* Set moderati

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

2020-09-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep  2 12:24:09 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-8]: if_bypass.c ixgbe.c ixgbe_common.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1600):

sys/dev/pci/ixgbe/if_bypass.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe.c: revision 1.246

Fix checking return value of atomic_cas_uint().

This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.

 -

Minor change.
  - Print "X550EM X" instead of "X550EM" for Xeon D devices.
  - Fix typo in comment. Same as FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.2.4.5 -r1.2.4.6 src/sys/dev/pci/ixgbe/if_bypass.c
cvs rdiff -u -r1.88.2.40 -r1.88.2.41 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.13.2.9 -r1.13.2.10 src/sys/dev/pci/ixgbe/ixgbe_common.c

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

Modified files:

Index: src/sys/dev/pci/ixgbe/if_bypass.c
diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.2.4.5 src/sys/dev/pci/ixgbe/if_bypass.c:1.2.4.6
--- src/sys/dev/pci/ixgbe/if_bypass.c:1.2.4.5	Fri Jan 24 18:37:31 2020
+++ src/sys/dev/pci/ixgbe/if_bypass.c	Wed Sep  2 12:24:08 2020
@@ -45,9 +45,9 @@
 static void
 ixgbe_bypass_mutex_enter(struct adapter *adapter)
 {
-	while (atomic_cas_uint(&adapter->bypass.low, 0, 1) == 0)
+	while (atomic_cas_uint(&adapter->bypass.low, 0, 1) != 0)
 		usec_delay(3000);
-	while (atomic_cas_uint(&adapter->bypass.high, 0, 1) == 0)
+	while (atomic_cas_uint(&adapter->bypass.high, 0, 1) != 0)
 		usec_delay(3000);
 	return;
 } /* ixgbe_bypass_mutex_enter */
@@ -58,9 +58,9 @@ ixgbe_bypass_mutex_enter(struct adapter 
 static void
 ixgbe_bypass_mutex_clear(struct adapter *adapter)
 {
-	while (atomic_cas_uint(&adapter->bypass.high, 1, 0) == 0)
+	while (atomic_cas_uint(&adapter->bypass.high, 1, 0) != 1)
 		usec_delay(6000);
-	while (atomic_cas_uint(&adapter->bypass.low, 1, 0) == 0)
+	while (atomic_cas_uint(&adapter->bypass.low, 1, 0) != 1)
 		usec_delay(6000);
 	return;
 } /* ixgbe_bypass_mutex_clear */
@@ -73,7 +73,7 @@ ixgbe_bypass_mutex_clear(struct adapter 
 static void
 ixgbe_bypass_wd_mutex_enter(struct adapter *adapter)
 {
-	while (atomic_cas_uint(&adapter->bypass.high, 0, 1) == 0)
+	while (atomic_cas_uint(&adapter->bypass.high, 0, 1) != 0)
 		usec_delay(3000);
 	return;
 } /* ixgbe_bypass_wd_mutex_enter */
@@ -84,7 +84,7 @@ ixgbe_bypass_wd_mutex_enter(struct adapt
 static void
 ixgbe_bypass_wd_mutex_clear(struct adapter *adapter)
 {
-	while (atomic_cas_uint(&adapter->bypass.high, 1, 0) == 0)
+	while (atomic_cas_uint(&adapter->bypass.high, 1, 0) != 1)
 		usec_delay(6000);
 	return;
 } /* ixgbe_bypass_wd_mutex_clear */
@@ -585,7 +585,7 @@ ixgbe_bp_log(SYSCTLFN_ARGS)
 		return (error);
 
 	/* Keep the log display single-threaded */
-	while (atomic_cas_uint(&adapter->bypass.log, 0, 1) == 0)
+	while (atomic_cas_uint(&adapter->bypass.log, 0, 1) != 0)
 		usec_delay(3000);
 
 	ixgbe_bypass_mutex_enter(adapter);
@@ -713,14 +713,14 @@ ixgbe_bp_log(SYSCTLFN_ARGS)
 
 	status = 0; /* reset */
 	/* Another log command can now run */
-	while (atomic_cas_uint(&adapter->bypass.log, 1, 0) == 0)
+	while (atomic_cas_uint(&adapter->bypass.log, 1, 0) != 1)
 		usec_delay(3000);
 	return (error);
 
 unlock_err:
 	ixgbe_bypass_mutex_clear(adapter);
 	status = 0; /* reset */
-	while (atomic_cas_uint(&adapter->bypass.log, 1, 0) == 0)
+	while (atomic_cas_uint(&adapter->bypass.log, 1, 0) != 1)
 		usec_delay(3000);
 	return (EINVAL);
 } /* ixgbe_bp_log */

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.40 src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.41
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.40	Wed Aug  5 15:58:02 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Sep  2 12:24:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.40 2020/08/05 15:58:02 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.41 2020/09/02 12:24:08 martin Exp $ */
 
 /**
 
@@ -858,7 +858,7 @@ ixgbe_attach(device_t parent, device_t d
 		str = "X550";
 		break;
 	case ixgbe_mac_X550EM_x:
-		str = "X550EM";
+		str = "X550EM X";
 		break;
 	case ixgbe_mac_X550EM_a:
 		str = "X550EM A";

Index: src/sys/dev/pci/ixgbe/ixgbe_common.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_common.c:1.13.2.9 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.13.2.10
--- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.13.2.9	Wed Aug  5 15:58:02 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_common.c	Wed Sep  2 12:24:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_common.c,v 1.13.2.9 2020/08/05 15:58:02 martin Exp $ */
+/* $NetBSD: ixgbe_common.c,v 1.13.2.10 2020/09/02 12:24

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

2020-08-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 28 19:44:22 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: if_atu.c if_axe.c if_axen.c

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

sys/dev/usb/if_atu.c: revision 1.73
sys/dev/usb/if_axe.c: apply patch
sys/dev/usb/if_axen.c: apply patch

atu(4): Reject packets larger than MCLBYTES.


To generate a diff of this commit:
cvs rdiff -u -r1.55.8.3 -r1.55.8.4 src/sys/dev/usb/if_atu.c
cvs rdiff -u -r1.82.6.4 -r1.82.6.5 src/sys/dev/usb/if_axe.c
cvs rdiff -u -r1.11.8.8 -r1.11.8.9 src/sys/dev/usb/if_axen.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/if_atu.c
diff -u src/sys/dev/usb/if_atu.c:1.55.8.3 src/sys/dev/usb/if_atu.c:1.55.8.4
--- src/sys/dev/usb/if_atu.c:1.55.8.3	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_atu.c	Fri Aug 28 19:44:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_atu.c,v 1.55.8.3 2018/08/08 10:28:35 martin Exp $ */
+/*	$NetBSD: if_atu.c,v 1.55.8.4 2020/08/28 19:44:22 martin Exp $ */
 /*	$OpenBSD: if_atu.c,v 1.48 2004/12/30 01:53:21 dlg Exp $ */
 /*
  * Copyright (c) 2003, 2004
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.55.8.3 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.55.8.4 2020/08/28 19:44:22 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1687,6 +1687,10 @@ atu_rxeof(struct usbd_xfer *xfer, void *
 		DPRINTF(("%s: atu_rxeof: too short\n",
 		device_xname(sc->atu_dev)));
 		goto done;
+	} else if (len > MCLBYTES) {
+		DPRINTF(("%s: atu_rxeof: too long\n",
+		device_xname(sc->atu_dev)));
+		goto done;
 	}
 
 	h = (struct atu_rx_hdr *)c->atu_buf;

Index: src/sys/dev/usb/if_axe.c
diff -u src/sys/dev/usb/if_axe.c:1.82.6.4 src/sys/dev/usb/if_axe.c:1.82.6.5
--- src/sys/dev/usb/if_axe.c:1.82.6.4	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_axe.c	Fri Aug 28 19:44:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axe.c,v 1.82.6.4 2018/08/08 10:28:35 martin Exp $	*/
+/*	$NetBSD: if_axe.c,v 1.82.6.5 2020/08/28 19:44:22 martin Exp $	*/
 /*	$OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.82.6.4 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.82.6.5 2020/08/28 19:44:22 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1382,7 +1382,8 @@ axe_rxeof(struct usbd_xfer *xfer, void *
 		}
 
 		if (pktlen > MHLEN - ETHER_ALIGN) {
-			MCLGET(m, M_DONTWAIT);
+			if (pktlen <= MCLBYTES)
+MCLGET(m, M_DONTWAIT);
 			if ((m->m_flags & M_EXT) == 0) {
 m_freem(m);
 ifp->if_ierrors++;

Index: src/sys/dev/usb/if_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.11.8.8 src/sys/dev/usb/if_axen.c:1.11.8.9
--- src/sys/dev/usb/if_axen.c:1.11.8.8	Mon May 13 12:40:13 2019
+++ src/sys/dev/usb/if_axen.c	Fri Aug 28 19:44:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axen.c,v 1.11.8.8 2019/05/13 12:40:13 martin Exp $	*/
+/*	$NetBSD: if_axen.c,v 1.11.8.9 2020/08/28 19:44:22 martin Exp $	*/
 /*	$OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.8 2019/05/13 12:40:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.9 2020/08/28 19:44:22 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1097,6 +1097,12 @@ axen_rxeof(struct usbd_xfer *xfer, void 
 			pkt_count));
 			goto nextpkt;
 		}
+		if (pkt_len > MCLBYTES) {
+			ifp->if_ierrors++;
+			DPRINTF(("%s: oversize frame %d\n",
+			device_xname(sc->axen_dev), pkt_len));
+			goto nextpkt;
+		}
 
 		/* process each packet */
 		/* allocate mbuf */



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

2020-08-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug 19 18:39:19 UTC 2020

Modified Files:
src/sys/uvm [netbsd-8]: uvm_amap.c

Log Message:
Pull up following revision(s) (requested by chs in ticket #1598):

sys/uvm/uvm_amap.c: revision 1.123 (via patch)

fix amap_extend() to handle amaps where we previously failed to allocate
the ppref memory.


To generate a diff of this commit:
cvs rdiff -u -r1.107.32.1 -r1.107.32.2 src/sys/uvm/uvm_amap.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/uvm/uvm_amap.c
diff -u src/sys/uvm/uvm_amap.c:1.107.32.1 src/sys/uvm/uvm_amap.c:1.107.32.2
--- src/sys/uvm/uvm_amap.c:1.107.32.1	Thu Nov  2 21:29:53 2017
+++ src/sys/uvm/uvm_amap.c	Wed Aug 19 18:39:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_amap.c,v 1.107.32.1 2017/11/02 21:29:53 snj Exp $	*/
+/*	$NetBSD: uvm_amap.c,v 1.107.32.2 2020/08/19 18:39:18 martin Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.107.32.1 2017/11/02 21:29:53 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.107.32.2 2020/08/19 18:39:18 martin Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -317,7 +317,7 @@ amap_extend(struct vm_map_entry *entry, 
 	struct vm_amap *amap = entry->aref.ar_amap;
 	int slotoff = entry->aref.ar_pageoff;
 	int slotmapped, slotadd, slotneed, slotadded, slotalloc;
-	int slotadj, slotspace;
+	int slotadj, slotspace, slotendoff;
 	int oldnslots;
 #ifdef UVM_AMAP_PPREF
 	int *newppref, *oldppref;
@@ -355,6 +355,36 @@ amap_extend(struct vm_map_entry *entry, 
 	tofree = NULL;
 
 	/*
+	 * Because this amap only has 1 ref, we know that there is
+	 * only one vm_map_entry pointing to it, and the one entry is
+	 * using slots between slotoff and slotoff + slotmapped.  If
+	 * we have been using ppref then we know that only slots in
+	 * the one map entry's range can have anons, since ppref
+	 * allowed us to free any anons outside that range as other map
+	 * entries which used this amap were removed. But without ppref,
+	 * we couldn't know which slots were still needed by other map
+	 * entries, so we couldn't free any anons as we removed map
+	 * entries, and so any slot from 0 to am_nslot can have an
+	 * anon.  But now that we know there is only one map entry
+	 * left and we know its range, we can free up any anons
+	 * outside that range.  This is necessary because the rest of
+	 * this function assumes that there are no anons in the amap
+	 * outside of the one map entry's range.
+	 */
+
+	slotendoff = slotoff + slotmapped;
+	if (amap->am_ppref == PPREF_NONE) {
+		amap_wiperange(amap, 0, slotoff, &tofree);
+		amap_wiperange(amap, slotendoff, amap->am_nslot - slotendoff, &tofree);
+	}
+	for (i = 0; i < slotoff; i++) {
+		KASSERT(amap->am_anon[i] == NULL);
+	}
+	for (i = slotendoff; i < amap->am_nslot - slotendoff; i++) {
+		KASSERT(amap->am_anon[i] == NULL);
+	}
+
+	/*
 	 * case 1: we already have enough slots in the map and thus
 	 * only need to bump the reference counts on the slots we are
 	 * adding.



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

2020-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 18 09:41:10 UTC 2020

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

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

sys/dev/ipmi.c: revision 1.5
(applied to sys/arch/x86/x86/ipmi.c)

ipmi(4): Fixed a bug that incorrect condition is notified.

When the value obtained from the sensor is below the lower limit of
the critical threshold, it is notified that the value is below the lower
limit of the warning threshold.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.64.10.1 src/sys/arch/x86/x86/ipmi.c

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

Modified files:

Index: src/sys/arch/x86/x86/ipmi.c
diff -u src/sys/arch/x86/x86/ipmi.c:1.64 src/sys/arch/x86/x86/ipmi.c:1.64.10.1
--- src/sys/arch/x86/x86/ipmi.c:1.64	Thu Jul  7 06:55:40 2016
+++ src/sys/arch/x86/x86/ipmi.c	Tue Aug 18 09:41:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipmi.c,v 1.64 2016/07/07 06:55:40 msaitoh Exp $ */
+/*	$NetBSD: ipmi.c,v 1.64.10.1 2020/08/18 09:41:10 martin Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.64 2016/07/07 06:55:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.64.10.1 2020/08/18 09:41:10 martin Exp $");
 
 #include 
 #include 
@@ -1667,14 +1667,14 @@ ipmi_sensor_status(struct ipmi_softc *sc
 		edata->value_cur > psensor->i_limits.sel_warnmax)
 			return ENVSYS_SWARNOVER;
 
-		if (psensor->i_props & PROP_WARNMIN &&
-		edata->value_cur < psensor->i_limits.sel_warnmin)
-			return ENVSYS_SWARNUNDER;
-
 		if (psensor->i_props & PROP_CRITMIN &&
 		edata->value_cur < psensor->i_limits.sel_critmin)
 			return ENVSYS_SCRITUNDER;
 
+		if (psensor->i_props & PROP_WARNMIN &&
+		edata->value_cur < psensor->i_limits.sel_warnmin)
+			return ENVSYS_SWARNUNDER;
+
 		break;
 
 	case IPMI_SENSOR_TYPE_INTRUSION:



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

2020-08-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 11 17:07:55 UTC 2020

Modified Files:
src/sys/dev [netbsd-8]: dev_verbose.h

Log Message:
Additionally pull up following revision(s) (requested by uwe in ticket #1584):

sys/dev/dev_verbose.h: revision 1.4

DEV_VERBOSE_DEFINE - use MODULE_CLASS_DRIVER to match the definition.
Catch up with previous to unbreak autoloading of verbose modules.
PR kern/55535


To generate a diff of this commit:
cvs rdiff -u -r1.2.10.1 -r1.2.10.2 src/sys/dev/dev_verbose.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/dev_verbose.h
diff -u src/sys/dev/dev_verbose.h:1.2.10.1 src/sys/dev/dev_verbose.h:1.2.10.2
--- src/sys/dev/dev_verbose.h:1.2.10.1	Wed Aug  5 14:48:35 2020
+++ src/sys/dev/dev_verbose.h	Tue Aug 11 17:07:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dev_verbose.h,v 1.2.10.1 2020/08/05 14:48:35 martin Exp $ */
+/*	$NetBSD: dev_verbose.h,v 1.2.10.2 2020/08/11 17:07:55 martin Exp $ */
 
 /*
  * Redistribution and use in source and binary forms, with or without
@@ -96,7 +96,7 @@ tag ## _load_verbose(void)		\
 {	\
 	\
 	if (tag ## verbose_loaded == 0)	\
-		module_autoload(# tag "verbose", MODULE_CLASS_MISC);	\
+		module_autoload(# tag "verbose", MODULE_CLASS_DRIVER);	\
 }	\
 	\
 static const char *			\



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

2020-08-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  9 14:17:48 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: mpii.c

Log Message:
Pull up following revision(s) (requested by jnemeth in ticket #1596):

sys/dev/pci/mpii.c: revision 1.25

make this compile without bio(4)


To generate a diff of this commit:
cvs rdiff -u -r1.8.10.5 -r1.8.10.6 src/sys/dev/pci/mpii.c

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

Modified files:

Index: src/sys/dev/pci/mpii.c
diff -u src/sys/dev/pci/mpii.c:1.8.10.5 src/sys/dev/pci/mpii.c:1.8.10.6
--- src/sys/dev/pci/mpii.c:1.8.10.5	Fri Mar 15 14:50:36 2019
+++ src/sys/dev/pci/mpii.c	Sun Aug  9 14:17:48 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.8.10.5 2019/03/15 14:50:36 martin Exp $ */
+/* $NetBSD: mpii.c,v 1.8.10.6 2020/08/09 14:17:48 martin Exp $ */
 /*	OpenBSD: mpii.c,v 1.115 2012/04/11 13:29:14 naddy Exp 	*/
 /*
  * Copyright (c) 2010 Mike Belopuhov 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.8.10.5 2019/03/15 14:50:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.8.10.6 2020/08/09 14:17:48 martin Exp $");
 
 #include "bio.h"
 
@@ -243,8 +243,10 @@ struct mpii_softc {
 	struct workqueue	*sc_evt_ack_wq;
 	struct work		sc_evt_ack_work;
 
+#if NBIO > 0
 	struct sysmon_envsys	*sc_sme;
 	envsys_data_t		*sc_sensors;
+#endif
 };
 
 int	mpii_match(device_t, cfdata_t, void *);



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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 18:26:17 UTC 2020

Modified Files:
src/sys/arch/x86/include [netbsd-8]: specialreg.h

Log Message:
Accidently not commited for ticket #1595:

sys/arch/x86/include/specialreg.h   1.129 via patch

Add six errata for AMD Family 17h (Ryzen etc).


To generate a diff of this commit:
cvs rdiff -u -r1.98.2.20 -r1.98.2.21 src/sys/arch/x86/include/specialreg.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/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.98.2.20 src/sys/arch/x86/include/specialreg.h:1.98.2.21
--- src/sys/arch/x86/include/specialreg.h:1.98.2.20	Wed Aug  5 16:02:53 2020
+++ src/sys/arch/x86/include/specialreg.h	Wed Aug  5 18:26:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.98.2.20 2020/08/05 16:02:53 martin Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.98.2.21 2020/08/05 18:26:17 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -1055,6 +1055,9 @@
 #define 	NB_CFG_INITAPICCPUIDLO	(1ULL << 54)
 
 #define MSR_LS_CFG	0xc0011020
+#define 	LS_CFG_ERRATA_1033	__BIT(4)
+#define 	LS_CFG_ERRATA_793	__BIT(15)
+#define 	LS_CFG_ERRATA_1095	__BIT(57)
 #define 	LS_CFG_DIS_LS2_SQUISH	0x0200
 #define 	LS_CFG_DIS_SSB_F15H	0x0040ULL
 #define 	LS_CFG_DIS_SSB_F16H	0x0002ULL
@@ -1063,6 +1066,7 @@
 #define MSR_IC_CFG	0xc0011021
 #define 	IC_CFG_DIS_SEQ_PREFETCH	0x0800
 #define 	IC_CFG_DIS_IND		0x4000
+#define 	IC_CFG_ERRATA_776	__BIT(26)
 
 #define MSR_DC_CFG	0xc0011022
 #define 	DC_CFG_DIS_CNV_WC_SSO	0x0008
@@ -1077,9 +1081,16 @@
 #define 	BU_CFG_WBPFSMCCHKDIS	0x2000ULL
 #define 	BU_CFG_WBENHWSBDIS	0x0001ULL
 
+#define MSR_FP_CFG	0xc0011028
+#define 	FP_CFG_ERRATA_1049	__BIT(4)
+
 #define MSR_DE_CFG	0xc0011029
 #define 	DE_CFG_ERRATA_721	0x0001
 #define 	DE_CFG_LFENCE_SERIALIZE	__BIT(1)
+#define 	DE_CFG_ERRATA_1021	__BIT(13)
+
+#define MSR_LS_CFG2	0xc001102d
+#define 	LS_CFG2_ERRATA_1091	__BIT(34)
 
 /* AMD Family10h MSRs */
 #define MSR_OSVW_ID_LENGTH		0xc0010140



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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 17:27:48 UTC 2020

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

Log Message:
Pull up the following, requested by msaitoh in ticket #1595:

sys/arch/x86/include/specialreg.h   1.129 via patch
sys/arch/x86/x86/errata.c   1.24-1.26

- Add six errata for AMD Family 17h (Ryzen etc), tested by
  Patrick Welche and mrg@.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.23.10.1 src/sys/arch/x86/x86/errata.c

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

Modified files:

Index: src/sys/arch/x86/x86/errata.c
diff -u src/sys/arch/x86/x86/errata.c:1.23 src/sys/arch/x86/x86/errata.c:1.23.10.1
--- src/sys/arch/x86/x86/errata.c:1.23	Tue Jan  5 10:20:22 2016
+++ src/sys/arch/x86/x86/errata.c	Wed Aug  5 17:27:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: errata.c,v 1.23 2016/01/05 10:20:22 hannken Exp $	*/
+/*	$NetBSD: errata.c,v 1.23.10.1 2020/08/05 17:27:48 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.23 2016/01/05 10:20:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.23.10.1 2020/08/05 17:27:48 martin Exp $");
 
 #include 
 #include 
@@ -70,8 +70,8 @@ typedef enum cpurev {
 	BH_E4, CH_CG, CH_D0, DH_CG, DH_D0, DH_E3, DH_E6, JH_E1,
 	JH_E6, SH_B0, SH_B3, SH_C0, SH_CG, SH_D0, SH_E4, SH_E5,
 	DR_BA, DR_B2, DR_B3, RB_C2, RB_C3, BL_C2, BL_C3, DA_C2,
-	DA_C3, HY_D0, HY_D1, HY_D1_G34R1,  PH_E0, LN_B0,
-	OINK
+	DA_C3, HY_D0, HY_D1, HY_D1_G34R1,  PH_E0, LN_B0, KB_A1,
+	ML_A1, ZP_B1, ZP_B2, PiR_B2, OINK
 } cpurev_t;
 
 static const u_int cpurevs[] = {
@@ -89,7 +89,9 @@ static const u_int cpurevs[] = {
 	RB_C2, 0x0100f42, RB_C3, 0x0100f43, BL_C2, 0x0100f52,
 	BL_C3, 0x0100f53, DA_C2, 0x0100f62, DA_C3, 0x0100f63,
 	HY_D0, 0x0100f80, HY_D1, 0x0100f81, HY_D1_G34R1, 0x0100f91,
-	PH_E0, 0x0100fa0, LN_B0, 0x0300f10,
+	PH_E0, 0x0100fa0, LN_B0, 0x0300f10, KB_A1, 0x0700F01,
+	ML_A1, 0x0730F01, ZP_B1, 0x0800F11, ZP_B2, 0x0800F12,
+	PiR_B2, 0x0800F82,
 	OINK
 };
 
@@ -142,6 +144,22 @@ static const uint8_t x86_errata_set11[] 
 	DA_C3, HY_D0, HY_D1, HY_D1_G34R1,  PH_E0, LN_B0, OINK
 };
 
+static const uint8_t x86_errata_set12[] = {
+	KB_A1, OINK
+};
+
+static const uint8_t x86_errata_set13[] = {
+	ZP_B1, ZP_B2, PiR_B2, OINK
+};
+
+static const uint8_t x86_errata_set14[] = {
+	ZP_B1, OINK
+};
+
+static const uint8_t x86_errata_set15[] = {
+	KB_A1, ML_A1, OINK
+};
+
 static bool x86_errata_setmsr(struct cpu_info *, errata_t *);
 static bool x86_errata_testmsr(struct cpu_info *, errata_t *);
 
@@ -285,6 +303,62 @@ static errata_t errata[] = {
 		721, FALSE, MSR_DE_CFG, x86_errata_set11,
 		x86_errata_setmsr, DE_CFG_ERRATA_721
 	},
+	/*
+	 * 776: Incorrect Processor Branch Prediction for Two Consecutive
+	 * Linear Pages
+	 */
+	{
+		776, FALSE, MSR_IC_CFG, x86_errata_set12,
+		x86_errata_setmsr, IC_CFG_ERRATA_776
+	},
+	/*
+	 * 793: Specific Combination of Writes to Write Combined Memory
+	 * Types and Locked Instructions May Cause Core Hang
+	 */
+	{
+		793, FALSE, MSR_LS_CFG, x86_errata_set15,
+		x86_errata_setmsr, LS_CFG_ERRATA_793
+	},
+	/*
+	 * 1021: Load Operation May Receive Stale Data From Older Store
+	 * Operation
+	 */
+	{
+		1021, FALSE, MSR_DE_CFG, x86_errata_set13,
+		x86_errata_setmsr, DE_CFG_ERRATA_1021
+	},
+	/*
+	 * 1033: A Lock Operation May Cause the System to Hang
+	 */
+	{
+		1033, FALSE, MSR_LS_CFG, x86_errata_set14,
+		x86_errata_setmsr, LS_CFG_ERRATA_1033
+	},
+	/*
+	 * 1049: FCMOV Instruction May Not Execute Correctly
+	 */
+	{
+		1049, FALSE, MSR_FP_CFG, x86_errata_set13,
+		x86_errata_setmsr, FP_CFG_ERRATA_1049
+	},
+#if 0	/* Should we apply this errata? The other OSes don't. */
+	/*
+	 * 1091: Address Boundary Crossing Load Operation May Receive
+	 * Stale Data
+	 */
+	{
+		1091, FALSE, MSR_LS_CFG2, x86_errata_set13,
+		x86_errata_setmsr, LS_CFG2_ERRATA_1091
+	},
+#endif
+	/*
+	 * 1095: Potential Violation of Read Ordering In Lock Operation
+	 * In SMT (Simultaneous Multithreading) Mode
+	 */
+	{
+		1095, FALSE, MSR_LS_CFG, x86_errata_set13,
+		x86_errata_setmsr, LS_CFG_ERRATA_1095
+	},
 };
 
 static bool 



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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 17:22:46 UTC 2020

Modified Files:
src/sys/dev/mii [netbsd-8]: igphy.c igphyreg.h makphy.c makphyreg.h
src/sys/dev/pci [netbsd-8]: if_wm.c if_wmreg.h if_wmvar.h

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1594:

sys/dev/pci/if_wm.c 1.655-1.658, 1.660,
1.662, 1.664-1.668,
1.671-1.674, 1.678,
1.680-1.685 via patch
sys/dev/pci/if_wmreg.c  1.118-1.119 via patch
sys/dev/pci/if_wmvar.c  1.45 via patch
sys/dev/mii/igphy.c 1.35-1.36 via patch
sys/dev/mii/igphyreg.h  1.12-1.13
sys/dev/mii/makphy.c1.66 via patch
sys/dev/mii/makphyreg.h 1.11

- Add SFP support. Module insertion/removal is not supported yet.
  Currently, SFP detection is only done in the driver's attach phase.
- Detect the Media Auto Sense feature. Not supported yet.
- Fix SFF_SFP_ETH_FLAGS_100FX. It's not 0x10 but 0x20.
- Add extra delay in wm_serdes_power_up_link_82575().
- Add Intel I219 LM10-LM15 and V10-V14.
- wm(4) can use workqueue as deferred Rx/Tx handler).
  Set hw.wm*.txrx_workqueue=1 to use workqueue instead of softint.
  The default value of hw.wm*.txrx_workqueue is 0 which use softint
  as before.
- Unset RSS UDP flags like ixg(4) and other OSes. To handle IP
  fragmented UDP, first packet and second packet should be processed
  in the same Rx queue.
- It's useless to not to set PCI_PMCSR_PME_STS bit when writing because
  the bit is W1C. Instead, always write PCI_PMCSR_PME_STS bit to clear
  in case it's already set.
- Actually writing always the checksum offload context descriptor
  makes the HW do extra processing, avoid doing that if possible.
- Fix a bug that the WMREG_EEARBC_I210 register is incorrectly set if
  the system uses iNVM.
- "wmX: 0" on 82542 is difficult to understand, so don't print it.
- Explicitly cast from uint16_t to uint32_t before shifting 16bit left
  when printing Image Unique ID to avoid undefined behavior.
- Set if_baudrate for non-MII device.
- Rename some macros and function.
- KNF. Add comment.


To generate a diff of this commit:
cvs rdiff -u -r1.26.10.1 -r1.26.10.2 src/sys/dev/mii/igphy.c
cvs rdiff -u -r1.10 -r1.10.8.1 src/sys/dev/mii/igphyreg.h
cvs rdiff -u -r1.42.8.4 -r1.42.8.5 src/sys/dev/mii/makphy.c
cvs rdiff -u -r1.6.20.2 -r1.6.20.3 src/sys/dev/mii/makphyreg.h
cvs rdiff -u -r1.508.4.38 -r1.508.4.39 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.98.6.11 -r1.98.6.12 src/sys/dev/pci/if_wmreg.h
cvs rdiff -u -r1.33.6.5 -r1.33.6.6 src/sys/dev/pci/if_wmvar.h

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

Modified files:

Index: src/sys/dev/mii/igphy.c
diff -u src/sys/dev/mii/igphy.c:1.26.10.1 src/sys/dev/mii/igphy.c:1.26.10.2
--- src/sys/dev/mii/igphy.c:1.26.10.1	Tue Aug  1 23:33:18 2017
+++ src/sys/dev/mii/igphy.c	Wed Aug  5 17:22:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: igphy.c,v 1.26.10.1 2017/08/01 23:33:18 snj Exp $	*/
+/*	$NetBSD: igphy.c,v 1.26.10.2 2020/08/05 17:22:46 martin Exp $	*/
 
 /*
  * The Intel copyright applies to the analog register setup, and the
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.26.10.1 2017/08/01 23:33:18 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.26.10.2 2020/08/05 17:22:46 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mii.h"
@@ -274,7 +274,7 @@ igphy_load_dspcode(struct mii_softc *sc)
 
 	delay(2);
 
-	PHY_WRITE(sc, MII_IGPHY_PAGE_SELECT, 0x);
+	PHY_WRITE(sc, IGPHY_PAGE_SELECT, 0x);
 	PHY_WRITE(sc, 0x, 0x0140);
 
 	delay(5000);
@@ -282,7 +282,7 @@ igphy_load_dspcode(struct mii_softc *sc)
 	for (i = 0; !((code[i].reg == 0) && (code[i].val == 0)); i++)
 		IGPHY_WRITE(sc, code[i].reg, code[i].val);
 
-	PHY_WRITE(sc, MII_IGPHY_PAGE_SELECT, 0x);
+	PHY_WRITE(sc, IGPHY_PAGE_SELECT, 0x);
 	PHY_WRITE(sc, 0x, 0x3300);
 
 	delay(2);
@@ -327,9 +327,9 @@ igphy_reset(struct mii_softc *sc)
 	}
 
 	if (igsc->sc_mactype == WM_T_82547) {
-		fused = IGPHY_READ(sc, MII_IGPHY_ANALOG_SPARE_FUSE_STATUS);
+		fused = IGPHY_READ(sc, IGPHY_ANALOG_SPARE_FUSE_STATUS);
 		if ((fused & ANALOG_SPARE_FUSE_ENABLED) == 0) {
-			fused = IGPHY_READ(sc, MII_IGPHY_ANALOG_FUSE_STATUS);
+			fused = IGPHY_READ(sc, IGPHY_ANALOG_FUSE_STATUS);
 
 			fine = fused & ANALOG_FUSE_FINE_MASK;
 			coarse = fused & ANALOG_FUSE_COARSE_MASK;
@@ -344,12 +344,12 @@ igphy_reset(struct mii_softc *sc)
 			(fine & ANALOG_FUSE_FINE_MASK) |
 			(coarse & ANALOG_FUSE_COARSE_MASK);
 
-			IGPHY_WRITE(sc, MII_IGPHY_ANALOG_FUSE_CONTROL, fused);
-			IGPHY_WRITE(sc, MII_IGPHY_ANALOG_FUSE_BYPASS,
+			IGPHY_WRITE(sc, IGPHY_ANALOG_FUSE_CONTROL, fused);
+			IGPHY_

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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 16:20:09 UTC 2020

Modified Files:
src/sys/arch/x86/conf [netbsd-8]: files.x86
src/sys/arch/x86/include [netbsd-8]: apicvar.h cpu.h
src/sys/arch/x86/x86 [netbsd-8]: cpu.c hyperv.c tsc.c
src/sys/arch/xen/conf [netbsd-8]: files.xen

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1593:

sys/arch/x86/conf/files.x86 1.108
sys/arch/x86/include/apicvar.h  1.7 via patch
sys/arch/x86/include/cpu.h  1.121
sys/arch/x86/x86/cpu.c  1.185 via patch
sys/arch/x86/x86/hyperv.c   1.7
sys/arch/x86/x86/tsc.c  1.41
sys/arch/xen/conf/files.xen 1.181

Get TSC frequency from CPUID 0x15 and/or x16 if it's available.
This change fixes a problem that newer Intel processors' timer
counts very slowly.


To generate a diff of this commit:
cvs rdiff -u -r1.88.6.2 -r1.88.6.3 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r1.5 -r1.5.80.1 src/sys/arch/x86/include/apicvar.h
cvs rdiff -u -r1.71.2.8 -r1.71.2.9 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.130.2.9 -r1.130.2.10 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/arch/x86/x86/hyperv.c
cvs rdiff -u -r1.36.22.1 -r1.36.22.2 src/sys/arch/x86/x86/tsc.c
cvs rdiff -u -r1.147.2.3 -r1.147.2.4 src/sys/arch/xen/conf/files.xen

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

Modified files:

Index: src/sys/arch/x86/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.88.6.2 src/sys/arch/x86/conf/files.x86:1.88.6.3
--- src/sys/arch/x86/conf/files.x86:1.88.6.2	Sat Mar  9 17:10:20 2019
+++ src/sys/arch/x86/conf/files.x86	Wed Aug  5 16:20:08 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.x86,v 1.88.6.2 2019/03/09 17:10:20 martin Exp $
+#	$NetBSD: files.x86,v 1.88.6.3 2020/08/05 16:20:08 martin Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -84,6 +84,7 @@ file	arch/x86/x86/efi.c		machdep
 file	arch/x86/x86/errata.c		machdep
 file	arch/x86/x86/genfb_machdep.c	machdep
 file	arch/x86/x86/identcpu.c		machdep
+file	arch/x86/x86/identcpu_subr.c	machdep
 file	arch/x86/x86/i8259.c		machdep
 file	arch/x86/x86/intr.c		machdep
 file	arch/x86/x86/nmi.c		machdep

Index: src/sys/arch/x86/include/apicvar.h
diff -u src/sys/arch/x86/include/apicvar.h:1.5 src/sys/arch/x86/include/apicvar.h:1.5.80.1
--- src/sys/arch/x86/include/apicvar.h:1.5	Mon Apr 28 20:23:40 2008
+++ src/sys/arch/x86/include/apicvar.h	Wed Aug  5 16:20:08 2020
@@ -1,4 +1,4 @@
-/* 	$NetBSD: apicvar.h,v 1.5 2008/04/28 20:23:40 martin Exp $ */
+/* 	$NetBSD: apicvar.h,v 1.5.80.1 2020/08/05 16:20:08 martin Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -46,4 +46,7 @@ struct apic_attach_args {
 
 void apic_format_redir(const char *, const char *, int, u_int32_t, u_int32_t);
 
+/* For lapic.c */
+extern uint32_t lapic_per_second;
+
 #endif /* !_X86_APICVAR_H_ */

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.71.2.8 src/sys/arch/x86/include/cpu.h:1.71.2.9
--- src/sys/arch/x86/include/cpu.h:1.71.2.8	Sat Mar  9 17:10:20 2019
+++ src/sys/arch/x86/include/cpu.h	Wed Aug  5 16:20:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.71.2.8 2019/03/09 17:10:20 martin Exp $	*/
+/*	$NetBSD: cpu.h,v 1.71.2.9 2020/08/05 16:20:08 martin Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -451,6 +451,9 @@ void 	cpu_probe(struct cpu_info *);
 void	cpu_identify(struct cpu_info *);
 void	identify_hypervisor(void);
 
+/* identcpu_subr.c */
+uint64_t cpu_tsc_freq_cpuid(struct cpu_info *);
+
 typedef enum vm_guest {
 	VM_GUEST_NO = 0,
 	VM_GUEST_VM,

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.130.2.9 src/sys/arch/x86/x86/cpu.c:1.130.2.10
--- src/sys/arch/x86/x86/cpu.c:1.130.2.9	Tue Jan 21 16:47:24 2020
+++ src/sys/arch/x86/x86/cpu.c	Wed Aug  5 16:20:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.130.2.9 2020/01/21 16:47:24 martin Exp $	*/
+/*	$NetBSD: cpu.c,v 1.130.2.10 2020/08/05 16:20:08 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130.2.9 2020/01/21 16:47:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130.2.10 2020/08/05 16:20:08 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -1226,16 +1226,25 @@ cpu_shutdown(device_t dv, int how)
 	return cpu_stop(dv);
 }
 
+/* Get the TSC frequency and set it to ci->ci_data.cpu_cc_freq. */
 void
 cpu_get_tsc_freq(struct cpu_info *ci)
 {
-	uint64_t last_tsc;
+	uint64_t freq = 0, last_tsc;
 
 	if (cpu_hascounter()) {
-		last_tsc = cpu_counter_serializing();
-		x86_delay(10);
-		ci->ci_data.

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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 16:14:25 UTC 2020

Modified Files:
src/sys/dev/sdmmc [netbsd-8]: sdhc.c sdhcreg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1592):

sys/dev/sdmmc/sdhc.c: revision 1.107
sys/dev/sdmmc/sdhcreg.h: revision 1.21

Identify SDHC 4.1 and 4.2. From {DragonFly,Free}BSD.


To generate a diff of this commit:
cvs rdiff -u -r1.100.4.1 -r1.100.4.2 src/sys/dev/sdmmc/sdhc.c
cvs rdiff -u -r1.18.10.1 -r1.18.10.2 src/sys/dev/sdmmc/sdhcreg.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/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.100.4.1 src/sys/dev/sdmmc/sdhc.c:1.100.4.2
--- src/sys/dev/sdmmc/sdhc.c:1.100.4.1	Sun Jan  7 09:24:59 2018
+++ src/sys/dev/sdmmc/sdhc.c	Wed Aug  5 16:14:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc.c,v 1.100.4.1 2018/01/07 09:24:59 snj Exp $	*/
+/*	$NetBSD: sdhc.c,v 1.100.4.2 2020/08/05 16:14:25 martin Exp $	*/
 /*	$OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.100.4.1 2018/01/07 09:24:59 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.100.4.2 2020/08/05 16:14:25 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -316,6 +316,12 @@ sdhc_host_found(struct sdhc_softc *sc, b
 	case SDHC_SPEC_VERS_400:
 		aprint_normal("4.0");
 		break;
+	case SDHC_SPEC_VERS_410:
+		aprint_normal("4.1");
+		break;
+	case SDHC_SPEC_VERS_420:
+		aprint_normal("4.2");
+		break;
 	case SDHC_SPEC_NOVERS:
 		hp->specver = -1;
 		aprint_normal("NO-VERS");

Index: src/sys/dev/sdmmc/sdhcreg.h
diff -u src/sys/dev/sdmmc/sdhcreg.h:1.18.10.1 src/sys/dev/sdmmc/sdhcreg.h:1.18.10.2
--- src/sys/dev/sdmmc/sdhcreg.h:1.18.10.1	Sun Jan  7 09:24:59 2018
+++ src/sys/dev/sdmmc/sdhcreg.h	Wed Aug  5 16:14:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhcreg.h,v 1.18.10.1 2018/01/07 09:24:59 snj Exp $	*/
+/*	$NetBSD: sdhcreg.h,v 1.18.10.2 2020/08/05 16:14:25 martin Exp $	*/
 /*	$OpenBSD: sdhcreg.h,v 1.4 2006/07/30 17:20:40 fgsch Exp $	*/
 
 /*
@@ -246,6 +246,8 @@
 #define SDHC_SPEC_VERS_200		0x01
 #define SDHC_SPEC_VERS_300		0x02
 #define SDHC_SPEC_VERS_400		0x03
+#define SDHC_SPEC_VERS_410		0x04
+#define SDHC_SPEC_VERS_420		0x05
 #define SDHC_SPEC_NOVERS		0xff	/* dummy */
 
 /* SDHC_CAPABILITIES decoding */



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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 16:11:56 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: piixpm.c piixpmreg.h

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1591:

sys/dev/pci/piixpm.c1.57-1.59,
1.61-1.63 via patch
sys/dev/pci/piixpmreg.h 1.9-1.12

- Fix number of port for Hudson rev. 0x1f and newer.
- Read SB800_SMB_HOSTC correctly. This register is not in the PCI
  config space but in the I/O space.
- The bit 0 of SB800_SMB_HOSTC is 0 on SMI or 1 on IRQ, so invert the
  check.
- Don't force using SMBUS0SEL register.
- Acquire/release host semaphore to share SMBus between the host and
  the embedded controller (IMC). Without this change, "shutdown -r"
  does power off and not boot on some machines.
- Save/restore port number before selecting port.
- Modify comment.
- Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.52.6.1 -r1.52.6.2 src/sys/dev/pci/piixpm.c
cvs rdiff -u -r1.7.22.1 -r1.7.22.2 src/sys/dev/pci/piixpmreg.h

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

Modified files:

Index: src/sys/dev/pci/piixpm.c
diff -u src/sys/dev/pci/piixpm.c:1.52.6.1 src/sys/dev/pci/piixpm.c:1.52.6.2
--- src/sys/dev/pci/piixpm.c:1.52.6.1	Tue Aug  6 16:02:54 2019
+++ src/sys/dev/pci/piixpm.c	Wed Aug  5 16:11:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpm.c,v 1.52.6.1 2019/08/06 16:02:54 martin Exp $ */
+/* $NetBSD: piixpm.c,v 1.52.6.2 2020/08/05 16:11:56 martin Exp $ */
 /*	$OpenBSD: piixpm.c,v 1.39 2013/10/01 20:06:02 sf Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.52.6.1 2019/08/06 16:02:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.52.6.2 2020/08/05 16:11:56 martin Exp $");
 
 #include 
 #include 
@@ -70,8 +70,11 @@ __KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1
 
 #define PIIXPM_IS_FCHGRP(sc)	(PIIXPM_IS_HUDSON(sc) || PIIXPM_IS_KERNCZ(sc))
 
+#define PIIX_SB800_TIMEOUT 500
+
 struct piixpm_smbus {
 	int			sda;
+	int			sda_save;
 	struct			piixpm_softc *softc;
 };
 
@@ -86,6 +89,7 @@ struct piixpm_softc {
 	bus_space_handle_t	sc_smb_ioh;
 	void *			sc_smb_ih;
 	int			sc_poll;
+	bool			sc_sb800_selen; /* Use SMBUS0SEL */
 
 	pci_chipset_tag_t	sc_pc;
 	pcitag_t		sc_pcitag;
@@ -119,8 +123,8 @@ static bool	piixpm_resume(device_t, cons
 
 static int	piixpm_sb800_init(struct piixpm_softc *);
 static void	piixpm_csb5_reset(void *);
-static int	piixpm_i2c_acquire_bus(void *, int);
-static void	piixpm_i2c_release_bus(void *, int);
+static int	piixpm_i2c_sb800_acquire_bus(void *, int);
+static void	piixpm_i2c_sb800_release_bus(void *, int);
 static int	piixpm_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *,
 size_t, void *, size_t, int);
 
@@ -231,15 +235,10 @@ nopowermanagement:
 	/* SB800 rev 0x40+, AMD HUDSON and newer need special initialization */
 	if (PIIXPM_IS_FCHGRP(sc) || PIIXPM_IS_SB800GRP(sc)) {
 		if (piixpm_sb800_init(sc) == 0) {
-			sc->sc_numbusses = 4;
-
 			/* Read configuration */
-			conf = pci_conf_read(pa->pa_pc, pa->pa_tag,
-			SB800_SMB_HOSTC);
-			DPRINTF(("%s: conf 0x%08x\n", device_xname(self),
-conf));
-
-			usesmi = conf & SB800_SMB_HOSTC_SMI;
+			conf = bus_space_read_1(sc->sc_iot,
+			sc->sc_smb_ioh, SB800_SMB_HOSTC);
+			usesmi = ((conf & SB800_SMB_HOSTC_IRQ) == 0);
 			goto setintr;
 		}
 		aprint_normal_dev(self, "SMBus initialization failed\n");
@@ -328,17 +327,24 @@ piixpm_rescan(device_t self, const char 
 	/* Attach I2C bus */
 
 	for (i = 0; i < sc->sc_numbusses; i++) {
+		struct i2c_controller *tag = &sc->sc_i2c_tags[i];
+
 		if (sc->sc_i2c_device[i])
 			continue;
 		sc->sc_busses[i].sda = i;
 		sc->sc_busses[i].softc = sc;
-		sc->sc_i2c_tags[i].ic_cookie = &sc->sc_busses[i];
-		sc->sc_i2c_tags[i].ic_acquire_bus = piixpm_i2c_acquire_bus;
-		sc->sc_i2c_tags[i].ic_release_bus = piixpm_i2c_release_bus;
-		sc->sc_i2c_tags[i].ic_exec = piixpm_i2c_exec;
+		tag->ic_cookie = &sc->sc_busses[i];
+		if (PIIXPM_IS_SB800GRP(sc) || PIIXPM_IS_FCHGRP(sc)) {
+			tag->ic_acquire_bus = piixpm_i2c_sb800_acquire_bus;
+			tag->ic_release_bus = piixpm_i2c_sb800_release_bus;
+		} else {
+			tag->ic_acquire_bus = NULL;
+			tag->ic_release_bus = NULL;
+		}
+		tag->ic_exec = piixpm_i2c_exec;
 		memset(&iba, 0, sizeof(iba));
 		iba.iba_type = I2C_TYPE_SMBUS;
-		iba.iba_tag = &sc->sc_i2c_tags[i];
+		iba.iba_tag = tag;
 		sc->sc_i2c_device[i] = config_found_ia(self, ifattr, &iba,
 		piixpm_iicbus_print);
 	}
@@ -401,6 +407,12 @@ piixpm_sb800_init(struct piixpm_softc *s
 	uint16_t val, base_addr;
 	bool enabled;
 
+	if (PIIXPM_IS_KERNCZ(sc) ||
+	(PIIXPM_IS_HUDSON(sc) && (sc->sc_rev >= 0x1f)))
+		sc->sc_numbusses = 2;
+	else
+		sc->sc_numbusses = 4;
+
 	/* Fetch SMB base address */
 	if (bus_space_map(iot,
 	SB800_INDIRECTIO_BASE, SB800_INDIREC

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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 16:08:10 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: if_ti.c if_tireg.h

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1590:

sys/dev/pci/if_ti.c 1.103, 1.106, 1.108,
1.116-1.120 via patch
sys/dev/pci/if_tireg.h  1.26

- Use pci_intr_establish_xname()
- Don't clear CFI and priority bit to pass them to the upper layer.
- Add support for Farallon PN9000SX from FreeBSD.
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- Fix typo in comment.
- Style fix.


To generate a diff of this commit:
cvs rdiff -u -r1.101.8.2 -r1.101.8.3 src/sys/dev/pci/if_ti.c
cvs rdiff -u -r1.20 -r1.20.30.1 src/sys/dev/pci/if_tireg.h

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

Modified files:

Index: src/sys/dev/pci/if_ti.c
diff -u src/sys/dev/pci/if_ti.c:1.101.8.2 src/sys/dev/pci/if_ti.c:1.101.8.3
--- src/sys/dev/pci/if_ti.c:1.101.8.2	Mon May 13 12:40:13 2019
+++ src/sys/dev/pci/if_ti.c	Wed Aug  5 16:08:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ti.c,v 1.101.8.2 2019/05/13 12:40:13 martin Exp $ */
+/* $NetBSD: if_ti.c,v 1.101.8.3 2020/08/05 16:08:09 martin Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.101.8.2 2019/05/13 12:40:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.101.8.3 2020/08/05 16:08:09 martin Exp $");
 
 #include "opt_inet.h"
 
@@ -140,6 +140,8 @@ static const struct ti_type ti_devs[] = 
 		"Netgear GA620 1000BASE-T Ethernet" },
 	{ PCI_VENDOR_SGI, PCI_PRODUCT_SGI_TIGON,
 		"Silicon Graphics Gigabit Ethernet" },
+	{ PCI_VENDOR_DEC, PCI_PRODUCT_DEC_PN9000SX,
+		"Farallon PN9000SX Gigabit Ethernet" },
 	{ 0, 0, NULL }
 };
 
@@ -152,8 +154,8 @@ static void ti_txeof_tigon2(struct ti_so
 static void ti_rxeof(struct ti_softc *);
 
 static void ti_stats_update(struct ti_softc *);
-static int ti_encap_tigon1(struct ti_softc *, struct mbuf *, u_int32_t *);
-static int ti_encap_tigon2(struct ti_softc *, struct mbuf *, u_int32_t *);
+static int ti_encap_tigon1(struct ti_softc *, struct mbuf *, uint32_t *);
+static int ti_encap_tigon2(struct ti_softc *, struct mbuf *, uint32_t *);
 
 static int ti_intr(void *);
 static void ti_start(struct ifnet *);
@@ -165,15 +167,15 @@ static void ti_watchdog(struct ifnet *);
 static int ti_ifmedia_upd(struct ifnet *);
 static void ti_ifmedia_sts(struct ifnet *, struct ifmediareq *);
 
-static u_int32_t ti_eeprom_putbyte(struct ti_softc *, int);
-static u_int8_t	ti_eeprom_getbyte(struct ti_softc *, int, u_int8_t *);
+static uint32_t ti_eeprom_putbyte(struct ti_softc *, int);
+static uint8_t	ti_eeprom_getbyte(struct ti_softc *, int, uint8_t *);
 static int ti_read_eeprom(struct ti_softc *, void *, int, int);
 
 static void ti_add_mcast(struct ti_softc *, struct ether_addr *);
 static void ti_del_mcast(struct ti_softc *, struct ether_addr *);
 static void ti_setmulti(struct ti_softc *);
 
-static void ti_mem(struct ti_softc *, u_int32_t, u_int32_t, const void *);
+static void ti_mem(struct ti_softc *, uint32_t, uint32_t, const void *);
 static void ti_loadfw(struct ti_softc *);
 static void ti_cmd(struct ti_softc *, struct ti_cmd_desc *);
 static void ti_cmd_ext(struct ti_softc *, struct ti_cmd_desc *, void *, int);
@@ -205,7 +207,7 @@ CFATTACH_DECL_NEW(ti, sizeof(struct ti_s
 /*
  * Send an instruction or address to the EEPROM, check for ACK.
  */
-static u_int32_t
+static uint32_t
 ti_eeprom_putbyte(struct ti_softc *sc, int byte)
 {
 	int i, ack = 0;
@@ -216,7 +218,7 @@ ti_eeprom_putbyte(struct ti_softc *sc, i
 	TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN);
 
 	/*
-	 * Feed in each bit and stobe the clock.
+	 * Feed in each bit and strobe the clock.
 	 */
 	for (i = 0x80; i; i >>= 1) {
 		if (byte & i) {
@@ -250,11 +252,11 @@ ti_eeprom_putbyte(struct ti_softc *sc, i
  * We have to send two address bytes since the EEPROM can hold
  * more than 256 bytes of data.
  */
-static u_int8_t
-ti_eeprom_getbyte(struct ti_softc *sc, int addr, u_int8_t *dest)
+static uint8_t
+ti_eeprom_getbyte(struct ti_softc *sc, int addr, uint8_t *dest)
 {
 	int		i;
-	u_int8_t		byte = 0;
+	uint8_t		byte = 0;
 
 	EEPROM_START();
 
@@ -327,7 +329,7 @@ ti_read_eeprom(struct ti_softc *sc, void
 {
 	char *dest = destv;
 	int err = 0, i;
-	u_int8_t byte = 0;
+	uint8_t byte = 0;
 
 	for (i = 0; i < cnt; i++) {
 		err = ti_eeprom_getbyte(sc, off + i, &byte);
@@ -344,7 +346,7 @@ ti_read_eeprom(struct ti_softc *sc, void
  * of NIC local memory or (if tbuf is non-NULL) copy data into it.
  */
 static void
-ti_mem(struct ti_softc *sc, u_int32_t addr, u_int32_t len, const void *xbuf)
+ti_mem(struct ti_softc *sc, uint32_t addr, uint32_t len, const void *xbuf)
 {
 	int			segptr, segsize, cnt;
 	const void		*ptr;
@@ -368,11 +370,11 @@ ti_mem(struct

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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 16:05:49 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1589):

sys/arch/x86/x86/coretemp.c: revision 1.37

   Add special handling for model 0x0f stepping >=2 or mode 0x0e to get Tjmax.


To generate a diff of this commit:
cvs rdiff -u -r1.35.10.1 -r1.35.10.2 src/sys/arch/x86/x86/coretemp.c

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

Modified files:

Index: src/sys/arch/x86/x86/coretemp.c
diff -u src/sys/arch/x86/x86/coretemp.c:1.35.10.1 src/sys/arch/x86/x86/coretemp.c:1.35.10.2
--- src/sys/arch/x86/x86/coretemp.c:1.35.10.1	Thu Jul 26 23:23:50 2018
+++ src/sys/arch/x86/x86/coretemp.c	Wed Aug  5 16:05:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: coretemp.c,v 1.35.10.1 2018/07/26 23:23:50 snj Exp $ */
+/* $NetBSD: coretemp.c,v 1.35.10.2 2020/08/05 16:05:49 martin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.35.10.1 2018/07/26 23:23:50 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.35.10.2 2020/08/05 16:05:49 martin Exp $");
 
 #include 
 #include 
@@ -271,6 +271,19 @@ coretemp_tjmax(device_t self)
 	sc->sc_tjmax = 100;
 
 	if ((model == 0x0f && stepping >= 2) || (model == 0x0e)) {
+		/*
+		 * Check MSR_IA32_PLATFORM_ID(0x17) bit 28. It's not documented
+		 * in the datasheet, but the following page describes the
+		 * detail:
+		 *   http://software.intel.com/en-us/articles/
+		 * mobile-intel-core2-processor-detection-table/
+		 *   Was: http://softwarecommunity.intel.com/Wiki/Mobility/
+		 * 720.htm
+		 */
+		if (rdmsr_safe(MSR_IA32_PLATFORM_ID, &msr) != 0)
+			goto notee;
+		if ((model < 0x17) && ((msr & __BIT(28)) == 0))
+			goto notee;
 
 		if (rdmsr_safe(MSR_IA32_EXT_CONFIG, &msr) == EFAULT)
 			return;
@@ -290,6 +303,7 @@ coretemp_tjmax(device_t self)
 		} else
 			sc->sc_tjmax = 90;
 	} else {
+notee:
 		/*
 		 * Attempt to get Tj(max) from IA32_TEMPERATURE_TARGET,
 		 * but only consider the interval [70, 110] C as valid.



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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 16:02:53 UTC 2020

Modified Files:
src/sys/arch/x86/include [netbsd-8]: specialreg.h

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1588:

sys/arch/x86/include/specialreg.h   1.162-1.168 via patch

- AMD CPUID Fn8000_000a %edx bit 20 is "SPEC_CTRL".
- Add some bit definitions of AMD's CPUID Fn8000_001f Encrypted Memory
  features.
- Add AMD INVLPGB/TLBSYNC hypervisor enable in VMCB and TLBSYNC
  intercept bit.
- Add AMD MSR_DE_CFG's bit 1 as DE_CFG_LFENCE_SERIALIZE.
- Add some definitions for Intel:
  - Add CPUID leaf 6 %eax bit 19 for HW_FEEDBACK* and
IA32_PACKAGE_TERM* MSRs.
  - Add CPUID leaf 7 %ecx bit 31 for Protection Keys.
  - Add definition of Load only TLB and Store only TLB.
  - Add IF_PSCHANGE_MC_NO bit of IA32_ARCH_CAPABILITIES
  - Fix HWP_IGNIDL.
- Add CPUID 7 %edx bit 9 "SRBDS_CTRL"
- Modify comment. Style and fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.98.2.19 -r1.98.2.20 src/sys/arch/x86/include/specialreg.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/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.98.2.19 src/sys/arch/x86/include/specialreg.h:1.98.2.20
--- src/sys/arch/x86/include/specialreg.h:1.98.2.19	Wed Apr 15 14:25:09 2020
+++ src/sys/arch/x86/include/specialreg.h	Wed Aug  5 16:02:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.98.2.19 2020/04/15 14:25:09 martin Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.98.2.20 2020/08/05 16:02:53 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -247,10 +247,10 @@
 		? 0 : (CPUID_TO_EXTMODEL(cpuid) << 4)))
 
 /* CPUID Fn0001 %ebx */
-#define	CPUID_BRAND_INDEX	__BITS(7,0)
-#define	CPUID_CLFLUSH_SIZE	__BITS(15,8)
-#define	CPUID_HTT_CORES		__BITS(23,16)
-#define	CPUID_LOCAL_APIC_ID	__BITS(31,24)
+#define CPUID_BRAND_INDEX	__BITS(7,0)
+#define CPUID_CLFLUSH_SIZE	__BITS(15,8)
+#define CPUID_HTT_CORES		__BITS(23,16)
+#define CPUID_LOCAL_APIC_ID	__BITS(31,24)
 
 /*
  * Intel Deterministic Cache Parameter Leaf
@@ -320,6 +320,7 @@
 #define CPUID_DSPM_HWP_PECI   __BIT(16)	/* HWP PECI override */
 #define CPUID_DSPM_HWP_FLEX   __BIT(17)	/* Flexible HWP */
 #define CPUID_DSPM_HWP_FAST   __BIT(18)	/* Fast access for IA32_HWP_REQUEST */
+#define CPUID_DSPM_HW_FEEDBACK __BIT(19) /* HW_FEEDBACK*, IA32_PACKAGE_TERM* */
 #define CPUID_DSPM_HWP_IGNIDL __BIT(20)	/* Ignore Idle Logical Processor HWP */
 
 #define CPUID_DSPM_FLAGS	"\20" \
@@ -327,8 +328,8 @@
 	"\5" "PLN"	"\6" "ECMD"	"\7" "PTM"	"\10" "HWP"	\
 	"\11" "HWP_NOTIFY" "\12" "HWP_ACTWIN" "\13" "HWP_EPP" "\14" "HWP_PLR" \
 			"\16" "HDC"	"\17" "TBM3"	"\20" "HWP_CAP" \
-	"\21" "HWP_PECI" "\22" "HWP_FLEX" "\23" "HWP_FAST"		\
-	"25" "HWP_IGNIDL"
+	"\21" "HWP_PECI" "\22" "HWP_FLEX" "\23" "HWP_FAST" "\24HW_FEEDBACK"   \
+	"\25" "HWP_IGNIDL"
 
 /*
  * Intel/AMD Digital Thermal Sensor and
@@ -341,7 +342,7 @@
 
 /*
  * Intel/AMD Structured Extended Feature leaf Fn_0007
- * %eax == 0: Subleaf 0
+ * %ecx == 0: Subleaf 0
  *	%eax: The Maximum input value for supported subleaf.
  *	%ebx: Feature bits.
  *	%ecx: Feature bits.
@@ -413,6 +414,7 @@
 #define CPUID_SEF_MOVDIRI	__BIT(27) /* MOVDIRI instruction */
 #define CPUID_SEF_MOVDIR64B	__BIT(28) /* MOVDIR64B instruction */
 #define CPUID_SEF_SGXLC		__BIT(30) /* SGX Launch Configuration */
+#define CPUID_SEF_PKS		__BIT(31) /* Protection Keys */
 
 #define CPUID_SEF_FLAGS1	"\177\20" \
 	"b\0PREFETCHWT1\0" "b\1AVX512_VBMI\0" "b\2UMIP\0" "b\3PKU\0"	\
@@ -422,13 +424,14 @@
 	"f\21\5MAWAU\0"			\
 	"b\26RDPID\0"			\
 			"b\31CLDEMOTE\0"		"b\33MOVDIRI\0"	\
-	"b\34MOVDIR64B\0"		"b\36SGXLC\0"
+	"b\34MOVDIR64B\0"		"b\36SGXLC\0"	"b\37PKS\0"
 
 /* %edx */
 #define CPUID_SEF_AVX512_4VNNIW	__BIT(2)
 #define CPUID_SEF_AVX512_4FMAPS	__BIT(3)
 #define CPUID_SEF_FSREP_MOV	__BIT(4)  /* Fast Short REP MOV */
 #define CPUID_SEF_AVX512_VP2INTERSECT __BIT(8)
+#define CPUID_SEF_SRBDS_CTRL	__BIT(9)  /* IA32_MCU_OPT_CTRL */
 #define CPUID_SEF_MD_CLEAR	__BIT(10)
 #define CPUID_SEF_TSX_FORCE_ABORT __BIT(13) /* MSR_TSX_FORCE_ABORT bit 0 */
 #define CPUID_SEF_SERIALIZE	__BIT(14)
@@ -445,7 +448,7 @@
 #define CPUID_SEF_FLAGS2	"\20" \
 "\3" "AVX512_4VNNIW" "\4" "AVX512_4FMAPS" \
 	"\5" "FSREP_MOV"		\
-	"\11" "VP2INTERSECT"	"\13" "MD_CLEAR"			\
+	"\11VP2INTERSECT" "\12SRBDS_CTRL" "\13MD_CLEAR"			\
 			"\16TSX_FORCE_ABORT" "\17SERIALIZE" "\20HYBRID"	\
 	"\21" "TSXLDTRK"		\
 	"\25" "CET_IBT"			\
@@ -561,6 +564,8 @@
 #define CPUID_DATP_TCTYPE_D	1		/*   Data TLB */
 #define CPUID_DATP_TCTYPE_I	2		/*   Instruction TLB */
 #define CPUID_DATP_TCTYPE_U	3		/*   Unified TLB */
+#define CPUID_DATP_TCTYPE_L	4		/*   Load only TLB */
+#define CPUID_DATP_TCTYPE_S	5		/*   Store only TLB */
 #define CPUID_DATP_TCLEVEL	__BITS(7, 5)	/* TLB level (start at 1) */
 #define CP

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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 15:58:03 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-8]: ix_txrx.c ixgbe.c ixgbe.h
ixgbe_82598.c ixgbe_common.c ixgbe_netbsd.c ixgbe_osdep.h
ixgbe_phy.c ixgbe_vf.c ixgbe_x550.c ixv.c

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c   1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h   1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c1.27
sys/dev/pci/ixgbe/ixgbe_vf.c1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c  1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c1.14
sys/dev/pci/ixgbe/ixgbe_phy.c   1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
  was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
  ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
  No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.


To generate a diff of this commit:
cvs rdiff -u -r1.24.2.19 -r1.24.2.20 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.88.2.39 -r1.88.2.40 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.24.6.19 -r1.24.6.20 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.8.8.3 -r1.8.8.4 src/sys/dev/pci/ixgbe/ixgbe_82598.c
cvs rdiff -u -r1.13.2.8 -r1.13.2.9 src/sys/dev/pci/ixgbe/ixgbe_common.c
cvs rdiff -u -r1.6.2.5 -r1.6.2.6 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c
cvs rdiff -u -r1.17.6.6 -r1.17.6.7 src/sys/dev/pci/ixgbe/ixgbe_osdep.h
cvs rdiff -u -r1.11.6.5 -r1.11.6.6 src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.12.8.4 -r1.12.8.5 src/sys/dev/pci/ixgbe/ixgbe_vf.c
cvs rdiff -u -r1.5.6.7 -r1.5.6.8 src/sys/dev/pci/ixgbe/ixgbe_x550.c
cvs rdiff -u -r1.56.2.29 -r1.56.2.30 src/sys/dev/pci/ixgbe/ixv.c

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

Modified files:

Index: src/sys/dev/pci/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.19 src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.20
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.19	Fri Jan 24 18:37:31 2020
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Wed Aug  5 15:58:02 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.24.2.19 2020/01/24 18:37:31 martin Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.24.2.20 2020/08/05 15:58:02 martin Exp $ */
 
 /**
 
@@ -926,7 +926,7 @@ ixgbe_tx_ctx_setup(struct tx_ring *txr, 
 	vlan_macip_lens |= ip_hlen;
 
 	/* No support for offloads for non-L4 next headers */
- 	switch (ipproto) {
+	switch (ipproto) {
 	case IPPROTO_TCP:
 		if (mp->m_pkthdr.csum_flags &
 		(M_CSUM_TCPv4 | M_CSUM_TCPv6))
@@ -1569,7 +1569,6 @@ ixgbe_setup_receive_ring(struct rx_ring 
 		rxbuf->addr = htole64(rxbuf->pmap->dm_segs[0].ds_addr);
 	}
 
-
 	/* Setup our descriptor indices */
 	rxr->next_to_check = 0;
 	rxr->next_to_refresh = 0;
@@ -1625,6 +1624,7 @@ ixgbe_setup_receive_structures(struct ad
 	struct rx_ring *rxr = adapter->rx_rings;
 	intj;
 
+	INIT_DEBUGOUT("ixgbe_setup_receive_structures");
 	for (j = 0; j < adapter->num_queues; j++, rxr++)
 		if (ixgbe_setup_receive_ring(rxr))
 			goto fail;
@@ -2233,7 +2233,7 @@ ixgbe_allocate_queues(struct adapter *ad
 
 	/* First, allocate the top level queue structs */
 	adapter->queues = (struct ix_queue *)malloc(sizeof(struct ix_queue) *
-adapter->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO);
+	adapter->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO);
 if (adapter->queues == NULL) {
 		aprint_error_dev(dev, "Unable to allocate queue memory\n");
 error = ENOMEM;
@@ -2300,7 +2300,7 @@ ixgbe_allocate_queues(struct adapter *ad
 			"Critical Failure setting up transmit buffers\n");
 			error = ENOMEM;
 			goto err_tx_desc;
-	}
+		}
 		if (!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX)) {
 			/* Allocate a buf ring */
 			txr->txr_interq = pcq_create(IXGBE_BR_SIZE, KM_SLEEP);

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.39 src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.40
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.39	Fri Jan 24 18:37:31 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Aug  5 15:58:02 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.39 2020/01/24 18:37:31 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.40 2020/08/05 15:58:02 martin Exp $ */
 
 /

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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 15:54:30 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: ichsmb.c

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1586:

sys/dev/pci/ichsmb.c1.66-1.68 via patch

- Add Comet Lake, Whiskey Lake U and Amber Lake Y support.
- Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.50.6.3 -r1.50.6.4 src/sys/dev/pci/ichsmb.c

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

Modified files:

Index: src/sys/dev/pci/ichsmb.c
diff -u src/sys/dev/pci/ichsmb.c:1.50.6.3 src/sys/dev/pci/ichsmb.c:1.50.6.4
--- src/sys/dev/pci/ichsmb.c:1.50.6.3	Thu Jul 26 20:32:38 2018
+++ src/sys/dev/pci/ichsmb.c	Wed Aug  5 15:54:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichsmb.c,v 1.50.6.3 2018/07/26 20:32:38 snj Exp $	*/
+/*	$NetBSD: ichsmb.c,v 1.50.6.4 2020/08/05 15:54:30 martin Exp $	*/
 /*	$OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.50.6.3 2018/07/26 20:32:38 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.50.6.4 2020/08/05 15:54:30 martin Exp $");
 
 #include 
 #include 
@@ -118,8 +118,10 @@ ichsmb_match(device_t parent, cfdata_t m
 		case PCI_PRODUCT_INTEL_100SERIES_LP_SMB:
 		case PCI_PRODUCT_INTEL_2HS_SMB:
 		case PCI_PRODUCT_INTEL_3HS_SMB:
+		case PCI_PRODUCT_INTEL_3HS_U_SMB:
 		case PCI_PRODUCT_INTEL_CORE4G_M_SMB:
 		case PCI_PRODUCT_INTEL_CORE5G_M_SMB:
+		case PCI_PRODUCT_INTEL_CMTLK_SMB:
 		case PCI_PRODUCT_INTEL_BAYTRAIL_PCU_SMB:
 		case PCI_PRODUCT_INTEL_BSW_PCU_SMB:
 		case PCI_PRODUCT_INTEL_APL_SMB:
@@ -237,7 +239,6 @@ ichsmb_chdet(device_t self, device_t chi
 
 	if (sc->sc_i2c_device == child)
 		sc->sc_i2c_device = NULL;
-
 }
 
 static int
@@ -282,7 +283,7 @@ ichsmb_i2c_exec(void *cookie, i2c_op_t o
 	LPCIB_SMB_HS_INTR | LPCIB_SMB_HS_DEVERR |
 	LPCIB_SMB_HS_BUSERR | LPCIB_SMB_HS_FAILED);
 	bus_space_barrier(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HS, 1,
-	BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);  
+	BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
 
 	/* Wait for bus to be idle */
 	for (retries = 100; retries > 0; retries--) {



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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 14:48:35 UTC 2020

Modified Files:
src/sys/dev [netbsd-8]: dev_verbose.h

Log Message:
Pull up following revision(s) (requested by uwe in ticket #1584):

sys/dev/dev_verbose.h: revision 1.3

DEV_VERBOSE_MODULE_DEFINE - use MODULE_CLASS_DRIVER.

This makes built-in verbose modules available before the start of the
autoconfiguration, when they are needed.  From pgoyette@

PR kern/55535


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.10.1 src/sys/dev/dev_verbose.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/dev_verbose.h
diff -u src/sys/dev/dev_verbose.h:1.2 src/sys/dev/dev_verbose.h:1.2.10.1
--- src/sys/dev/dev_verbose.h:1.2	Fri Nov 13 01:37:19 2015
+++ src/sys/dev/dev_verbose.h	Wed Aug  5 14:48:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dev_verbose.h,v 1.2 2015/11/13 01:37:19 christos Exp $ */
+/*	$NetBSD: dev_verbose.h,v 1.2.10.1 2020/08/05 14:48:35 martin Exp $ */
 
 /*
  * Redistribution and use in source and binary forms, with or without
@@ -79,7 +79,7 @@ tag ## verbose_modcmd(modcmd_t cmd, void
 		return ENOTTY;		\
 	}\
 }	\
-MODULE(MODULE_CLASS_MISC, tag ## verbose, deps)
+MODULE(MODULE_CLASS_DRIVER, tag ## verbose, deps)
 
 #endif /* KERNEL */
 



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

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 19:00:40 UTC 2020

Modified Files:
src/sys/dev/i2c [netbsd-8]: sdtemp.c

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1580:

sys/dev/i2c/sdtemp.c1.35, 1.37-1.39

- Check the return value of iic_acquire_bus() because this function
  may fail.
- Fix typo in comment.
- KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.32.8.1 -r1.32.8.2 src/sys/dev/i2c/sdtemp.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/i2c/sdtemp.c
diff -u src/sys/dev/i2c/sdtemp.c:1.32.8.1 src/sys/dev/i2c/sdtemp.c:1.32.8.2
--- src/sys/dev/i2c/sdtemp.c:1.32.8.1	Thu Mar  8 14:29:12 2018
+++ src/sys/dev/i2c/sdtemp.c	Mon Jul 20 19:00:40 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: sdtemp.c,v 1.32.8.1 2018/03/08 14:29:12 martin Exp $*/
+/*  $NetBSD: sdtemp.c,v 1.32.8.2 2020/07/20 19:00:40 martin Exp $*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.32.8.1 2018/03/08 14:29:12 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.32.8.2 2020/07/20 19:00:40 martin Exp $");
 
 #include 
 #include 
@@ -214,8 +214,13 @@ sdtemp_match(device_t parent, cfdata_t c
 	if ((ia->ia_addr & SDTEMP_ADDRMASK) != SDTEMP_ADDR)
 		return 0;
 
-	/* Verify that we can read the manufacturer ID, Device ID and the capability */
-	iic_acquire_bus(sc.sc_tag, 0);
+	/*
+	 * Verify that we can read the manufacturer ID, Device ID and the
+	 * capability
+	 */
+	error = iic_acquire_bus(sc.sc_tag, 0);
+	if (error)
+		return 0;
 	error = sdtemp_read_16(&sc, SDTEMP_REG_MFG_ID,  &mfgid) |
 		sdtemp_read_16(&sc, SDTEMP_REG_DEV_REV, &devid) |
 		sdtemp_read_16(&sc, SDTEMP_REG_CAPABILITY, &cap);
@@ -234,8 +239,8 @@ sdtemp_match(device_t parent, cfdata_t c
 	}
 
 	/*
-	 * Check by SDTEMP_IS_TSE2004AV() might not be enough, so check the alarm
-	 * capability, too.
+	 * Check by SDTEMP_IS_TSE2004AV() might not be enough, so check the
+	 * alarm capability, too.
 	 */
 	if ((cap & SDTEMP_CAP_HAS_ALARM) == 0)
 		return 0;
@@ -255,7 +260,10 @@ sdtemp_attach(device_t parent, device_t 
 	sc->sc_address = ia->ia_addr;
 	sc->sc_dev = self;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	error = iic_acquire_bus(sc->sc_tag, 0);
+	if (error)
+		return;
+
 	if ((error = sdtemp_read_16(sc, SDTEMP_REG_MFG_ID,  &mfgid)) != 0 ||
 	(error = sdtemp_read_16(sc, SDTEMP_REG_DEV_REV, &devid)) != 0) {
 		iic_release_bus(sc->sc_tag, 0);
@@ -297,7 +305,7 @@ sdtemp_attach(device_t parent, device_t 
 	 * IDT's devices and some Microchip's devices have the resolution
 	 * register in the vendor specific registers area. The devices'
 	 * resolution bits in the capability register are not the maximum
-	 * resolution but the current vaule of the setting.
+	 * resolution but the current value of the setting.
 	 */
 	if (sdtemp_dev_table[i].sdtemp_config != NULL)
 		sdtemp_dev_table[i].sdtemp_config(sc);
@@ -428,7 +436,9 @@ sdtemp_get_limits(struct sysmon_envsys *
 	uint16_t lim;
 
 	*props = 0;
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0) != 0)
+		return;
+
 	if (sdtemp_read_16(sc, SDTEMP_REG_LOWER_LIM, &lim) == 0 && lim != 0) {
 		limits->sel_warnmin = sdtemp_decode_temp(sc, lim);
 		*props |= PROP_WARNMIN;
@@ -458,7 +468,9 @@ sdtemp_set_limits(struct sysmon_envsys *
 		limits = &sc->sc_deflims;
 		props  = &sc->sc_defprops;
 	}
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0) != 0)
+		return;
+
 	if (*props & PROP_WARNMIN) {
 		val = __UK2C(limits->sel_warnmin);
 		(void)sdtemp_write_16(sc, SDTEMP_REG_LOWER_LIM,
@@ -570,7 +582,12 @@ sdtemp_refresh(struct sysmon_envsys *sme
 	uint16_t val;
 	int error;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	error = iic_acquire_bus(sc->sc_tag, 0);
+	if (error) {
+		edata->state = ENVSYS_SINVALID;
+		return;
+	}
+
 	error = sdtemp_read_16(sc, SDTEMP_REG_AMBIENT_TEMP, &val);
 	iic_release_bus(sc->sc_tag, 0);
 
@@ -598,7 +615,7 @@ sdtemp_refresh(struct sysmon_envsys *sme
 }
 
 /*
- * power management functions
+ * Power management functions
  *
  * We go into "shutdown" mode at suspend time, and return to normal
  * mode upon resume.  This reduces power consumption by disabling
@@ -612,7 +629,10 @@ sdtemp_pmf_suspend(device_t dev, const p
 	int error;
 	uint16_t config;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	error = iic_acquire_bus(sc->sc_tag, 0);
+	if (error != 0)
+		return false;
+
 	error = sdtemp_read_16(sc, SDTEMP_REG_CONFIG, &config);
 	if (error == 0) {
 		config |= SDTEMP_CONFIG_SHUTDOWN_MODE;
@@ -629,7 +649,10 @@ sdtemp_pmf_resume(device_t dev, const pm
 	int error;
 	uint16_t config;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	error = iic_acquire_bus(sc->sc_tag, 0);
+	if (error != 0)
+		return false;
+
 	error = sdtemp_read_16(sc, SDTEMP_REG_CONFIG, &config);
 	if (error == 0) {
 		config &= 

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

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:53:56 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: pcidevs

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1579:

sys/dev/pci/pcidevs 1.1392-1.1403, 1.1406-1.1419

- Add Intel Xeon D-1500 NTB-secondary and Xeon D NS QuickData DMA
  channel 0-7.
- Add Intel I219 LM10-LM15 and V10-V14.
- Add AMD Family14h PCIe.
- Add Realtek Killer E3000.
- Add Aquantia AQC 10G network adapters.
- Add Radeon HD4290
- Add Farallon PN9000SX Ethernet.
- NVIDIA 0x036[0-7] are nForce MCP55 LPC Bridge.
- Add VIA VX900 chipset.
- Add some NVIDIA devices.
- Add some Intel UHD Graphics devices.
- Add Intel Comet Lake, Whiskey Lake U and Amber Lake Y devices.
- Modify description of Intel 0x591e from HD Graphics to UHD Graphics.
- Add Intel XMM 7360 LTE Modem.
- Add Western Digital WD Blue SN550 NVMe SSD.
- Add ATI Radeon R5/R6/R7 Graphics.
- Add IDs for Ampere eMAG PCIe Root Ports.
- Add RTL8192EE Wireless LAN 802.11n PCI-E NIC.
- Add ASIX AX99100 Multi I/O (Serial,Parallel,I2C,SPI,LocalBus,GPIO)
  Controller.
- Add a couple of additional device IDs for the AMD Cryptographic
  Coprocessor.
- Remove duplicated entries.


To generate a diff of this commit:
cvs rdiff -u -r1.1289.2.18 -r1.1289.2.19 src/sys/dev/pci/pcidevs

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

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1289.2.18 src/sys/dev/pci/pcidevs:1.1289.2.19
--- src/sys/dev/pci/pcidevs:1.1289.2.18	Mon Jul 20 18:47:16 2020
+++ src/sys/dev/pci/pcidevs	Mon Jul 20 18:53:56 2020
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1289.2.18 2020/07/20 18:47:16 martin Exp $
+$NetBSD: pcidevs,v 1.1289.2.19 2020/07/20 18:53:56 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -651,8 +651,10 @@ vendor SYMPHONY2	0x1c1c	Symphony Labs (2
 vendor HGST		0x1c58	HGST, Inc.
 vendor BEIJING_MEMBLAZE	0x1c5f	Beijing Memblaze Technology Co. Ltd.
 vendor AMAZON		0x1d0f	Amazon.com, Inc.
+vendor AQUANTIA		0x1d6a	Aquantia
 vendor ROCKCHIP		0x1d87	Rockchip
 vendor TEKRAM2		0x1de1	Tekram Technology (2nd PCI Vendor ID)
+vendor AMPERE		0x1def	Ampere Computing
 vendor SUNIX2		0x1fd4	SUNIX Co
 vendor HINT		0x3388	HiNT
 vendor 3DLABS		0x3d3d	3D Labs
@@ -1023,13 +1025,20 @@ product AMD F17_DF_5		0x1464	Family17h D
 product AMD F17_DF_6		0x1465	Family17h Data Fabric
 product AMD F17_DF_7		0x1466	Family17h Data Fabric
 product AMD F17_DF_8		0x1467	Family17h Data Fabric
+product AMD F17_CCP_2		0x1468	Family17h Crypto
 product AMD F17_PCIE_4		0x1470	Family17h PCIe
 product AMD F17_PCIE_5		0x1471	Family17h PCIe
 product AMD F17_7X_RC		0x1480	Family17h/7xh Root Complex
 product AMD F17_7X_IOMMU	0x1481	Family17h/7xh IOMMU
 product AMD F17_7X_RESV_SPP	0x1485	Family17h/7xh Reserved SPP
+product AMD F17_7X_CCP		0x1486	Family17h/7xh Crypto
 product AMD F17_7X_USB3		0x149c	Family17h/7xh USB 3.0 Host Controller
 product AMD F14_RC		0x1510	Family14h Root Complex
+product AMD F14_PCIE_1		0x1512	Family14h PCIe
+product AMD F14_PCIE_2		0x1513	Family14h PCIe
+product AMD F14_PCIE_3		0x1514	Family14h PCIe
+product AMD F14_PCIE_4		0x1515	Family14h PCIe
+product AMD F14_PCIE_5		0x1516	Family14h PCIe
 product AMD F16_HT		0x1530	Family16h HyperTransport Configuration
 product AMD F16_ADDR		0x1531	Family16h Address Map Configuration
 product AMD F16_DRAM		0x1532	Family16h DRAM Configuration
@@ -1103,7 +1112,7 @@ product AMD PCSCSI_PCI		0x2020	PCscsi-PC
 product AMD GEODELX_PCHB	0x2080	Geode LX Host-PCI Bridge
 product AMD GEODELX_VGA 	0x2081	Geode LX VGA Controller
 product AMD GEODELX_AES 	0x2082	Geode LX AES Security Block
-product	AMD CS5536_PCISB	0x208f	CS5536 GeodeLink PCI South Bridge
+product AMD CS5536_PCISB	0x208f	CS5536 GeodeLink PCI South Bridge
 product AMD CS5536_PCIB		0x2090	CS5536 PCI-ISA Bridge
 product AMD CS5536_FLASH	0x2091	CS5536 Flash
 product AMD CS5536_AUDIO	0x2093	CS5536 Audio
@@ -1213,6 +1222,16 @@ product AMI MEGARAID3		0x1960	MegaRAID 3
 product AMI MEGARAID		0x9010	MegaRAID
 product AMI MEGARAID2		0x9060	MegaRAID 2
 
+/* Ampere Computing products */
+product AMPERE EMAG_PCIE_0	0xe005	eMAG PCIe Root Port 0
+product AMPERE EMAG_PCIE_1	0xe006	eMAG PCIe Root Port 1
+product AMPERE EMAG_PCIE_2	0xe007	eMAG PCIe Root Port 2
+product AMPERE EMAG_PCIE_3	0xe008	eMAG PCIe Root Port 3
+product AMPERE EMAG_PCIE_4	0xe009	eMAG PCIe Root Port 4
+product AMPERE EMAG_PCIE_5	0xe00a	eMAG PCIe Root Port 5
+product AMPERE EMAG_PCIE_6	0xe00b	eMAG PCIe Root Port 6
+product AMPERE EMAG_PCIE_7	0xe00c	eMAG PCIe Root Port 7
+
 /* Analog Devices products */
 product ANALOG AD1889	0x1889	AD1889 PCI SoundMAX Controller
 product ANALOG SAFENET	0x2f44	SafeNet Crypto Accelerator ADSP-2141
@@ -1282,6 +1301,24 @@ product APPLE INTREPID2_FW	0x006a	Intrep
 product APPLE INTREPID2_GMAC	0x006b	Intrepid 2 GMAC
 product APPLE BCM5701		0x1645	BCM5701

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

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:55:52 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: pcidevs.h pcidevs_data.h

Log Message:
Regen for ticket #1579


To generate a diff of this commit:
cvs rdiff -u -r1.1281.2.18 -r1.1281.2.19 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1280.2.18 -r1.1280.2.19 src/sys/dev/pci/pcidevs_data.h

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

diffs are larger than 1MB and have been omitted


CVS commit: [netbsd-8] src/sys

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:47:16 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1578):

sys/dev/pci/pcidevs: revision 1.1404
sys/dev/pci/pcidevs: revision 1.1405
sys/arch/x86/pci/rdcpcib.c: revision 1.3

Add more RDC products (Andrius V)

Recognize more rdc devices (Andrius V.)

Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.46.1 src/sys/arch/x86/pci/rdcpcib.c
cvs rdiff -u -r1.1289.2.17 -r1.1289.2.18 src/sys/dev/pci/pcidevs

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

Modified files:

Index: src/sys/arch/x86/pci/rdcpcib.c
diff -u src/sys/arch/x86/pci/rdcpcib.c:1.2 src/sys/arch/x86/pci/rdcpcib.c:1.2.46.1
--- src/sys/arch/x86/pci/rdcpcib.c:1.2	Fri Jul  1 18:22:08 2011
+++ src/sys/arch/x86/pci/rdcpcib.c	Mon Jul 20 18:47:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rdcpcib.c,v 1.2 2011/07/01 18:22:08 dyoung Exp $	*/
+/*	$NetBSD: rdcpcib.c,v 1.2.46.1 2020/07/20 18:47:16 martin Exp $	*/
 
 /*
  * Copyright (c) 2011 Manuel Bouyer.
@@ -31,7 +31,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rdcpcib.c,v 1.2 2011/07/01 18:22:08 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rdcpcib.c,v 1.2.46.1 2020/07/20 18:47:16 martin Exp $");
 
 #include 
 #include 
@@ -88,6 +88,17 @@ CFATTACH_DECL2_NEW(rdcpcib, sizeof(struc
 rdcpcibmatch, rdcpcibattach, rdcpcibdetach, NULL,
 pcibrescan, pcibchilddet);
 
+
+static const struct rdcpcib_device {
+	pcireg_t vendor, product;
+} rdcpcib_devices[] = {
+	{ PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6011_PCIB},
+	{ PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6013_PCIB},
+	{ PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6031_PCIB},
+	{ PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6035_PCIB},
+	{ PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6036_PCIB},
+};
+
 static int
 rdcpcibmatch(device_t parent, cfdata_t match, void *aux)
 {
@@ -97,9 +108,11 @@ rdcpcibmatch(device_t parent, cfdata_t m
 	PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_BRIDGE_ISA)
 		return 0;
 
-	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_RDC &&
-	PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_RDC_PCIB)
+	for (size_t i = 0; i < __arraycount(rdcpcib_devices); i++) {
+		if (PCI_VENDOR(pa->pa_id) == rdcpcib_devices[i].vendor &&
+		PCI_PRODUCT(pa->pa_id) == rdcpcib_devices[i].product)
 			return 10;
+	}
 
 	return 0;
 }

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1289.2.17 src/sys/dev/pci/pcidevs:1.1289.2.18
--- src/sys/dev/pci/pcidevs:1.1289.2.17	Tue Nov 19 10:36:47 2019
+++ src/sys/dev/pci/pcidevs	Mon Jul 20 18:47:16 2020
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1289.2.17 2019/11/19 10:36:47 martin Exp $
+$NetBSD: pcidevs,v 1.1289.2.18 2020/07/20 18:47:16 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -7015,13 +7015,28 @@ product RALINK	RT5390_5	0x539f	RT5390
 product RATOC	REXPCI31	0x0853	REX PCI-31/33 SCSI
 
 /* RDC Semiconductor products */
-product RDC	R1010_IDE	0x1010	R1010 IDE controller
-product RDC	R1011_IDE	0x1011	R1011 IDE controller
-product RDC	R1012_IDE	0x1012	R1012 IDE controller
+product RDC	R1010_IDE	0x1010	R1010 IDE Controller
+product RDC	R1011_IDE	0x1011	R1011 IDE Controller
+product RDC	R1012_IDE	0x1012	R1012 IDE Controller
+product RDC	R1031_PPB	0x1031	R1031 PCI-PCIE Bridge
+product RDC	R1060_USBD	0x1060	R1060 USB Device
+product RDC	R1061_USBD	0x1061	R1061 USB Device
+product RDC	R1070_CAN	0x1070	R1070 CANbus
+product RDC	R1331_MC	0x1331	R1331 Motion Control
+product RDC	R1710_SPI	0x1710	R1710 SPI
+product RDC	R1930_HBRD	0x1930	R1930 Hybrid Function Control Register
+product RDC	R2010_VGA	0x2010	R2010 VGA Controller
+product RDC	R2012_VGA	0x2012	R2012 VGA Controller
+product RDC	R2015_VGA	0x2015	R2015 VGA Controller
+product RDC	R6011_PCIB	0x6011	R6011 PCI-ISA bridge
+product RDC	R6013_PCIB	0x6013	R6013 PCI-ISA bridge
 product RDC	R6021_HB	0x6021	R6021 Host
+product RDC	R6023_HB	0x6023	R6023 Host
 product RDC	R6025_HB	0x6025	R6025 Host
-product RDC	R6031_ISA	0x6031	R6031 PCI-ISA bridge
-product RDC	PCIB		0x6036	R6036 PCI-ISA bridge
+product RDC	R6026_HB	0x6026	R6026 Host
+product RDC	R6031_PCIB	0x6031	R6031 PCI-ISA bridge
+product RDC	R6035_PCIB	0x6035	R6035 PCI-ISA bridge
+product RDC	R6036_PCIB	0x6036	R6036 PCI-ISA bridge
 product RDC	R6040		0x6040	R6040 10/100 Ethernet
 product RDC	R6060_OHCI	0x6060	R6060 USB OHCI
 product RDC	R6061_EHCI	0x6061	R6061 USB EHCI



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

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:43:25 UTC 2020

Modified Files:
src/sys/dev/mii [netbsd-8]: miidevs.h miidevs_data.h

Log Message:
regen for ticket #1577


To generate a diff of this commit:
cvs rdiff -u -r1.128.6.9 -r1.128.6.10 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.116.6.9 -r1.116.6.10 src/sys/dev/mii/miidevs_data.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/mii/miidevs.h
diff -u src/sys/dev/mii/miidevs.h:1.128.6.9 src/sys/dev/mii/miidevs.h:1.128.6.10
--- src/sys/dev/mii/miidevs.h:1.128.6.9	Tue Apr 14 18:11:35 2020
+++ src/sys/dev/mii/miidevs.h	Mon Jul 20 18:43:25 2020
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs.h,v 1.128.6.9 2020/04/14 18:11:35 martin Exp $	*/
+/*	$NetBSD: miidevs.h,v 1.128.6.10 2020/07/20 18:43:25 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.125.6.9 2020/04/14 17:57:17 martin Exp
+ *	NetBSD: miidevs,v 1.125.6.10 2020/07/20 18:42:47 martin Exp
  */
 
 /*-
@@ -616,8 +616,28 @@
 #define	MII_STR_xxVITESSE_VSC8601	"VSC8601 10/100/1000 PHY"
 #define	MII_MODEL_xxVITESSE_VSC8641	0x0003
 #define	MII_STR_xxVITESSE_VSC8641	"Vitesse VSC8641 10/100/1000TX PHY"
+#define	MII_MODEL_xxVITESSE_VSC8504	0x000c
+#define	MII_STR_xxVITESSE_VSC8504	"Vitesse VSC8504 quad 10/100/1000TX PHY"
+#define	MII_MODEL_xxVITESSE_VSC8552	0x000e
+#define	MII_STR_xxVITESSE_VSC8552	"Vitesse VSC8552 dual 10/100/1000TX PHY"
+#define	MII_MODEL_xxVITESSE_VSC8502	0x0012
+#define	MII_STR_xxVITESSE_VSC8502	"Vitesse VSC8502 dual 10/100/1000TX PHY"
 #define	MII_MODEL_xxVITESSE_VSC8501	0x0013
 #define	MII_STR_xxVITESSE_VSC8501	"Vitesse VSC8501 10/100/1000TX PHY"
+#define	MII_MODEL_xxVITESSE_VSC8531	0x0017
+#define	MII_STR_xxVITESSE_VSC8531	"Vitesse VSC8531 10/100/1000TX PHY"
+#define	MII_MODEL_xxVITESSE_VSC8662	0x0026
+#define	MII_STR_xxVITESSE_VSC8662	"Vitesse VSC866[24] dual/quad 1000T 100FX 1000X PHY"
+#define	MII_MODEL_xxVITESSE_VSC8514	0x0027
+#define	MII_STR_xxVITESSE_VSC8514	"Vitesse VSC8514 quad 1000T PHY"
+#define	MII_MODEL_xxVITESSE_VSC8512	0x002e
+#define	MII_STR_xxVITESSE_VSC8512	"Vitesse VSC8512 12port 1000T PHY"
+#define	MII_MODEL_xxVITESSE_VSC8522	0x002f
+#define	MII_STR_xxVITESSE_VSC8522	"Vitesse VSC8522 12port 1000T PHY"
+#define	MII_MODEL_xxVITESSE_VSC8658	0x0035
+#define	MII_STR_xxVITESSE_VSC8658	"Vitesse VSC8658 octal 1000T 100FX 1000X PHY"
+#define	MII_MODEL_xxVITESSE_VSC8541	0x0037
+#define	MII_STR_xxVITESSE_VSC8541	"Vitesse VSC8541 1000T PHY"
 
 /* XaQti Corp. PHYs */
 #define	MII_MODEL_xxXAQTI_XMACII	0x

Index: src/sys/dev/mii/miidevs_data.h
diff -u src/sys/dev/mii/miidevs_data.h:1.116.6.9 src/sys/dev/mii/miidevs_data.h:1.116.6.10
--- src/sys/dev/mii/miidevs_data.h:1.116.6.9	Tue Apr 14 18:11:35 2020
+++ src/sys/dev/mii/miidevs_data.h	Mon Jul 20 18:43:25 2020
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs_data.h,v 1.116.6.9 2020/04/14 18:11:35 martin Exp $	*/
+/*	$NetBSD: miidevs_data.h,v 1.116.6.10 2020/07/20 18:43:25 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.125.6.9 2020/04/14 17:57:17 martin Exp
+ *	NetBSD: miidevs,v 1.125.6.10 2020/07/20 18:42:47 martin Exp
  */
 
 /*-
@@ -246,7 +246,17 @@ struct mii_knowndev mii_knowndevs[] = {
  { MII_OUI_xxVIA, MII_MODEL_xxVIA_VT6103_2, MII_STR_xxVIA_VT6103_2 },
  { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8601, MII_STR_xxVITESSE_VSC8601 },
  { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8641, MII_STR_xxVITESSE_VSC8641 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8504, MII_STR_xxVITESSE_VSC8504 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8552, MII_STR_xxVITESSE_VSC8552 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8502, MII_STR_xxVITESSE_VSC8502 },
  { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8501, MII_STR_xxVITESSE_VSC8501 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8531, MII_STR_xxVITESSE_VSC8531 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8662, MII_STR_xxVITESSE_VSC8662 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8514, MII_STR_xxVITESSE_VSC8514 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8512, MII_STR_xxVITESSE_VSC8512 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8522, MII_STR_xxVITESSE_VSC8522 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8658, MII_STR_xxVITESSE_VSC8658 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8541, MII_STR_xxVITESSE_VSC8541 },
  { MII_OUI_xxXAQTI, MII_MODEL_xxXAQTI_XMACII, MII_STR_xxXAQTI_XMACII },
  { 0, 0, NULL }
 };



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

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:42:47 UTC 2020

Modified Files:
src/sys/dev/mii [netbsd-8]: miidevs

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1577):
sys/dev/mii/miidevs: revision 1.168
  Add some Microsemi (Vitesse) devices.


To generate a diff of this commit:
cvs rdiff -u -r1.125.6.9 -r1.125.6.10 src/sys/dev/mii/miidevs

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

Modified files:

Index: src/sys/dev/mii/miidevs
diff -u src/sys/dev/mii/miidevs:1.125.6.9 src/sys/dev/mii/miidevs:1.125.6.10
--- src/sys/dev/mii/miidevs:1.125.6.9	Tue Apr 14 17:57:17 2020
+++ src/sys/dev/mii/miidevs	Mon Jul 20 18:42:47 2020
@@ -1,4 +1,4 @@
-$NetBSD: miidevs,v 1.125.6.9 2020/04/14 17:57:17 martin Exp $
+$NetBSD: miidevs,v 1.125.6.10 2020/07/20 18:42:47 martin Exp $
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -400,7 +400,17 @@ model xxVIA VT6103_2		0x0034	VT6103 10/1
 /* Vitesse PHYs (Now Microsemi) */
 model xxVITESSE VSC8601		0x0002 VSC8601 10/100/1000 PHY
 model xxVITESSE VSC8641		0x0003 Vitesse VSC8641 10/100/1000TX PHY
+model xxVITESSE VSC8504		0x000c Vitesse VSC8504 quad 10/100/1000TX PHY
+model xxVITESSE VSC8552		0x000e Vitesse VSC8552 dual 10/100/1000TX PHY
+model xxVITESSE VSC8502		0x0012 Vitesse VSC8502 dual 10/100/1000TX PHY
 model xxVITESSE VSC8501		0x0013 Vitesse VSC8501 10/100/1000TX PHY
+model xxVITESSE VSC8531		0x0017 Vitesse VSC8531 10/100/1000TX PHY
+model xxVITESSE VSC8662		0x0026 Vitesse VSC866[24] dual/quad 1000T 100FX 1000X PHY
+model xxVITESSE VSC8514		0x0027 Vitesse VSC8514 quad 1000T PHY
+model xxVITESSE VSC8512		0x002e Vitesse VSC8512 12port 1000T PHY
+model xxVITESSE VSC8522		0x002f Vitesse VSC8522 12port 1000T PHY
+model xxVITESSE VSC8658		0x0035 Vitesse VSC8658 octal 1000T 100FX 1000X PHY
+model xxVITESSE VSC8541		0x0037 Vitesse VSC8541 1000T PHY
 
 /* XaQti Corp. PHYs */
 model xxXAQTI XMACII		0x XaQti Corp. XMAC II gigabit interface



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

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:40:09 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1581):

sys/arch/x86/x86/procfs_machdep.c: revision 1.37
sys/arch/x86/x86/procfs_machdep.c: revision 1.38

  Add AMD protected processor identification number (PPIN).

  Lowercase ppin.


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

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

Modified files:

Index: src/sys/arch/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.10 src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.11
--- src/sys/arch/x86/x86/procfs_machdep.c:1.15.2.10	Wed Apr 15 14:25:09 2020
+++ src/sys/arch/x86/x86/procfs_machdep.c	Mon Jul 20 18:40:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.15.2.10 2020/04/15 14:25:09 martin Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.15.2.11 2020/07/20 18:40:08 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.10 2020/04/15 14:25:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.15.2.11 2020/07/20 18:40:08 martin Exp $");
 
 #include 
 #include 
@@ -155,7 +155,7 @@ static const char * const x86_features[]
 	{ /* (13) AMD 0x8008 ebx */
 	"clzero", "irperf", "xsaveerptr", NULL, "rdpru", NULL, NULL, NULL,
 	NULL, "wbnoinvd", NULL, NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, "ppin",
 	NULL, "virt_ssbd", NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (14) 0x0006 eax */



CVS commit: [netbsd-8] src/sys

2020-07-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jul 17 15:28:08 UTC 2020

Modified Files:
src/sys/compat/common [netbsd-8]: uipc_syscalls_40.c
src/sys/compat/linux/common [netbsd-8]: linux_socket.c
src/sys/compat/linux32/common [netbsd-8]: linux32_socket.c
src/sys/net [netbsd-8]: if.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1576):

sys/net/if.c: revision 1.479
sys/compat/common/uipc_syscalls_40.c: revision 1.23
sys/compat/linux/common/linux_socket.c: revision 1.150
sys/compat/linux32/common/linux32_socket.c: revision 1.31

 Don't accept negative value.


To generate a diff of this commit:
cvs rdiff -u -r1.13.6.3 -r1.13.6.4 src/sys/compat/common/uipc_syscalls_40.c
cvs rdiff -u -r1.138.6.5 -r1.138.6.6 \
src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.27.6.3 -r1.27.6.4 \
src/sys/compat/linux32/common/linux32_socket.c
cvs rdiff -u -r1.394.2.18 -r1.394.2.19 src/sys/net/if.c

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

Modified files:

Index: src/sys/compat/common/uipc_syscalls_40.c
diff -u src/sys/compat/common/uipc_syscalls_40.c:1.13.6.3 src/sys/compat/common/uipc_syscalls_40.c:1.13.6.4
--- src/sys/compat/common/uipc_syscalls_40.c:1.13.6.3	Fri Apr 19 09:12:58 2019
+++ src/sys/compat/common/uipc_syscalls_40.c	Fri Jul 17 15:28:07 2020
@@ -1,9 +1,9 @@
-/*	$NetBSD: uipc_syscalls_40.c,v 1.13.6.3 2019/04/19 09:12:58 martin Exp $	*/
+/*	$NetBSD: uipc_syscalls_40.c,v 1.13.6.4 2020/07/17 15:28:07 martin Exp $	*/
 
 /* written by Pavel Cahyna, 2006. Public domain. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.13.6.3 2019/04/19 09:12:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.13.6.4 2020/07/17 15:28:07 martin Exp $");
 
 /*
  * System call interface to the socket abstraction.
@@ -42,11 +42,14 @@ compat_ifconf(u_long cmd, void *data)
 	int bound;
 	struct psref psref;
 
-	memset(&ifr, 0, sizeof(ifr));
 	if (docopy) {
+		if (ifc->ifc_len < 0)
+			return EINVAL;
+
 		space = ifc->ifc_len;
 		ifrp = ifc->ifc_req;
 	}
+	memset(&ifr, 0, sizeof(ifr));
 
 	bound = curlwp_bind();
 	s = pserialize_read_enter();

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.138.6.5 src/sys/compat/linux/common/linux_socket.c:1.138.6.6
--- src/sys/compat/linux/common/linux_socket.c:1.138.6.5	Tue Jan 21 18:12:54 2020
+++ src/sys/compat/linux/common/linux_socket.c	Fri Jul 17 15:28:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.138.6.5 2020/01/21 18:12:54 martin Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.138.6.6 2020/07/17 15:28:08 martin Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.138.6.5 2020/01/21 18:12:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.138.6.6 2020/07/17 15:28:08 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1156,12 +1156,15 @@ linux_getifconf(struct lwp *l, register_
 	if (error)
 		return error;
 
-	memset(&ifr, 0, sizeof(ifr));
 	docopy = ifc.ifc_req != NULL;
 	if (docopy) {
+		if (ifc.ifc_len < 0)
+			return EINVAL;
+
 		space = ifc.ifc_len;
 		ifrp = ifc.ifc_req;
 	}
+	memset(&ifr, 0, sizeof(ifr));
 
 	bound = curlwp_bind();
 	s = pserialize_read_enter();

Index: src/sys/compat/linux32/common/linux32_socket.c
diff -u src/sys/compat/linux32/common/linux32_socket.c:1.27.6.3 src/sys/compat/linux32/common/linux32_socket.c:1.27.6.4
--- src/sys/compat/linux32/common/linux32_socket.c:1.27.6.3	Fri Apr 19 09:12:58 2019
+++ src/sys/compat/linux32/common/linux32_socket.c	Fri Jul 17 15:28:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_socket.c,v 1.27.6.3 2019/04/19 09:12:58 martin Exp $ */
+/*	$NetBSD: linux32_socket.c,v 1.27.6.4 2020/07/17 15:28:08 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.27.6.3 2019/04/19 09:12:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.27.6.4 2020/07/17 15:28:08 martin Exp $");
 
 #include 
 #include 
@@ -431,12 +431,15 @@ linux32_getifconf(struct lwp *l, registe
 	if (error)
 		return error;
 
-	memset(&ifr, 0, sizeof(ifr));
 	docopy = NETBSD32PTR64(ifc.ifc_req) != NULL;
 	if (docopy) {
+		if (ifc.ifc_len < 0)
+			return EINVAL;
+
 		space = ifc.ifc_len;
 		ifrp = NETBSD32PTR64(ifc.ifc_req);
 	}
+	memset(&ifr, 0, sizeof(ifr));
 
 	bound = curlwp_bind();
 	s = pserialize_read_enter();

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.394.2.18 src/sys/net/if.c:1.394.2.19
--- src/sys/net/if.c:1.394.2.18	Tue Sep 24 18:27:09 2019
+++ src/sys/net/if.c	Fri Jul 17 15:28:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.394.2.18 2019/09/24 18:27:09 martin Exp $	*/
+/*	$NetBSD: if.c,v 1.394.2.19 2020/07/17 15:28:

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

2020-07-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 13 14:35:29 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: ualea.c

Log Message:
Pull up following revision(s) (requested by simonb in ticket #1573):

sys/dev/usb/ualea.c: revision 1.12

Set up the USB xfer for every transfer, not just once in the attach
function.  Caught by DIAGNOSTIC on a similar driver.  Thanks to mrg@
for USB xfer clue and martin@ for testing.


To generate a diff of this commit:
cvs rdiff -u -r1.6.8.1 -r1.6.8.2 src/sys/dev/usb/ualea.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/ualea.c
diff -u src/sys/dev/usb/ualea.c:1.6.8.1 src/sys/dev/usb/ualea.c:1.6.8.2
--- src/sys/dev/usb/ualea.c:1.6.8.1	Wed Jan 31 18:01:54 2018
+++ src/sys/dev/usb/ualea.c	Mon Jul 13 14:35:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ualea.c,v 1.6.8.1 2018/01/31 18:01:54 martin Exp $	*/
+/*	$NetBSD: ualea.c,v 1.6.8.2 2020/07/13 14:35:29 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.6.8.1 2018/01/31 18:01:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.6.8.2 2020/07/13 14:35:29 martin Exp $");
 
 #include 
 #include 
@@ -144,11 +144,6 @@ ualea_attach(device_t parent, device_t s
 		return;
 	}
 
-	/* Setup the xfer to call ualea_xfer_done with sc.  */
-	usbd_setup_xfer(sc->sc_xfer, sc, usbd_get_buffer(sc->sc_xfer),
-	sc->sc_maxpktsize, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT,
-	ualea_xfer_done);
-
 	/* Success!  We are ready to run.  */
 	mutex_enter(&sc->sc_lock);
 	sc->sc_attached = true;
@@ -197,6 +192,11 @@ ualea_xfer(struct ualea_softc *sc)
 	if (sc->sc_needed == 0)
 		return;
 
+	/* Setup the xfer to call ualea_xfer_done with sc.  */
+	usbd_setup_xfer(sc->sc_xfer, sc, usbd_get_buffer(sc->sc_xfer),
+	sc->sc_maxpktsize, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT,
+	ualea_xfer_done);
+
 	/* Issue xfer or complain if we can't.  */
 	/*
 	 * XXX Does USBD_NORMAL_COMPLETION (= 0) make sense here?  The



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

2020-07-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 13 14:13:12 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: vioscsi.c

Log Message:
Pull up following revision(s) (requested by kim in ticket #1572):

sys/dev/pci/vioscsi.c: revision 1.22

Fix off-by-one SCSI target reporting

Use max_target as the controller ID instead of zero, so that the device
located at SCSI ID zero (e.g. a disk) is not obscured through not being
probed by scsi_probe_bus() (which skips the controller ID).

Copy the target requested onto the wire without decrementing it by one.

ok christos@


To generate a diff of this commit:
cvs rdiff -u -r1.19.2.1 -r1.19.2.2 src/sys/dev/pci/vioscsi.c

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

Modified files:

Index: src/sys/dev/pci/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.19.2.1 src/sys/dev/pci/vioscsi.c:1.19.2.2
--- src/sys/dev/pci/vioscsi.c:1.19.2.1	Mon Jul 15 08:23:23 2019
+++ src/sys/dev/pci/vioscsi.c	Mon Jul 13 14:13:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.19.2.1 2019/07/15 08:23:23 martin Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.19.2.2 2020/07/13 14:13:12 martin Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.19.2.1 2019/07/15 08:23:23 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.19.2.2 2020/07/13 14:13:12 martin Exp $");
 
 #include 
 #include 
@@ -198,7 +198,7 @@ vioscsi_attach(device_t parent, device_t
 	chan->chan_channel = 0;
 	chan->chan_ntargets = MIN(max_target, 16);	/* cap reasonably */
 	chan->chan_nluns = MIN(max_lun, 1024);		/* cap reasonably */
-	chan->chan_id = 0;
+	chan->chan_id = max_target;
 	chan->chan_flags = SCSIPI_CHAN_NOSETTLE;
 
 	config_found(self, &sc->sc_channel, scsiprint);
@@ -322,7 +322,7 @@ vioscsi_scsipi_request(struct scsipi_cha
 	}
 
 	req->lun[0] = 1;
-	req->lun[1] = periph->periph_target - 1;
+	req->lun[1] = periph->periph_target;
 	req->lun[2] = 0x40 | ((periph->periph_lun >> 8) & 0x3F);
 	req->lun[3] = periph->periph_lun & 0xFF;
 	memset(req->lun + 4, 0, 4);



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

2020-07-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 13 14:10:25 UTC 2020

Modified Files:
src/sys/dev/scsipi [netbsd-8]: scsiconf.c

Log Message:
Pull up following revision(s) (requested by kim in ticket #1571):

sys/dev/scsipi/scsiconf.c: revision 1.288

Continue scanning a SCSI bus when a LUN is reported not present

This fixes disk attachment under Qemu when there is no disk on LUN 0 on
a SCSI bus but there is a disk on LUN 1. The inquiry for LUN 0 returns
SID_QUAL_LU_NOTPRESENT & T_NODEVICE.  Quirks are only checked if neither
one of those are set, so cannot use a quirk entry.

Use case 1: Proxmox 6 configures each disk on its own bus when using
the "Virtio SCSI single" SCSI controller. However, while the "scsi0"
disk is on LUN 0, the "scsi1" disk is on LUN 1.

Use case 2: A Linode boot profile with multiple disks results in
the first disk ("sda") on LUN 1, while the second disk ("sdb") is
on LUN 0, each on their own bus.


To generate a diff of this commit:
cvs rdiff -u -r1.279.6.1 -r1.279.6.2 src/sys/dev/scsipi/scsiconf.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/scsipi/scsiconf.c
diff -u src/sys/dev/scsipi/scsiconf.c:1.279.6.1 src/sys/dev/scsipi/scsiconf.c:1.279.6.2
--- src/sys/dev/scsipi/scsiconf.c:1.279.6.1	Wed Jun 21 18:18:55 2017
+++ src/sys/dev/scsipi/scsiconf.c	Mon Jul 13 14:10:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsiconf.c,v 1.279.6.1 2017/06/21 18:18:55 snj Exp $	*/
+/*	$NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.1 2017/06/21 18:18:55 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $");
 
 #include 
 #include 
@@ -869,6 +869,8 @@ scsi_probe_device(struct scsibus_softc *
 		break;
 
 	case SID_QUAL_LU_NOTPRESENT:
+		docontinue = 1;
+		/* FALLTHROUGH */
 	case SID_QUAL_reserved:
 	case SID_QUAL_LU_NOT_SUPP:
 		goto bad;



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

2020-07-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jul  8 13:48:36 UTC 2020

Modified Files:
src/sys/netinet [netbsd-8]: tcp_input.c

Log Message:
Apply patch, requested by christos in ticket #1566:

Deduplicate more code and avoid use of uninitialized variables.


To generate a diff of this commit:
cvs rdiff -u -r1.357.4.4 -r1.357.4.5 src/sys/netinet/tcp_input.c

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

Modified files:

Index: src/sys/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.357.4.4 src/sys/netinet/tcp_input.c:1.357.4.5
--- src/sys/netinet/tcp_input.c:1.357.4.4	Tue Jul  7 11:56:57 2020
+++ src/sys/netinet/tcp_input.c	Wed Jul  8 13:48:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.357.4.4 2020/07/07 11:56:57 martin Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.357.4.5 2020/07/08 13:48:36 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.4 2020/07/07 11:56:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.5 2020/07/08 13:48:36 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1272,6 +1272,12 @@ tcp_input(struct mbuf *m, ...)
 	}
 #endif
 
+	IP6_EXTHDR_GET(th, struct tcphdr *, m, toff, sizeof(struct tcphdr));
+	if (th == NULL) {
+		TCP_STATINC(TCP_STAT_RCVSHORT);
+		return;
+	}
+
 	/*
 	 * Enforce alignment requirements that are violated in
 	 * some cases, see kern/50766 for details.
@@ -1301,15 +1307,8 @@ tcp_input(struct mbuf *m, ...)
 	case 4:
 		af = AF_INET;
 		iphlen = sizeof(struct ip);
-		IP6_EXTHDR_GET(th, struct tcphdr *, m, toff,
-			sizeof(struct tcphdr));
-		if (th == NULL) {
-			TCP_STATINC(TCP_STAT_RCVSHORT);
-			return;
-		}
 		/* We do the checksum after PCB lookup... */
 		len = ntohs(ip->ip_len);
-		tlen = len - toff;
 		iptos = ip->ip_tos;
 		break;
 #endif
@@ -1317,13 +1316,6 @@ tcp_input(struct mbuf *m, ...)
 	case 6:
 		iphlen = sizeof(struct ip6_hdr);
 		af = AF_INET6;
-		IP6_EXTHDR_GET(th, struct tcphdr *, m, toff,
-			sizeof(struct tcphdr));
-		if (th == NULL) {
-			TCP_STATINC(TCP_STAT_RCVSHORT);
-			return;
-		}
-
 		/* Be proactive about malicious use of IPv4 mapped address */
 		if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) ||
 		IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) {
@@ -1355,7 +1347,6 @@ tcp_input(struct mbuf *m, ...)
 
 		/* We do the checksum after PCB lookup... */
 		len = m->m_pkthdr.len;
-		tlen = len - toff;
 		iptos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
 		break;
 #endif
@@ -1364,6 +1355,8 @@ tcp_input(struct mbuf *m, ...)
 		return;
 	}
 
+	tlen = len - toff;
+
 	/*
 	 * Check that TCP offset makes sense,
 	 * pull out TCP options and adjust length.		XXX



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

2020-07-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul  7 11:56:57 UTC 2020

Modified Files:
src/sys/netinet [netbsd-8]: tcp_input.c

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

sys/netinet/tcp_input.c: revision 1.418 (via patch)

- always set both ip and ip6, otherwise a kernel assertion can be triggered
- move alignment early so that we do less work


To generate a diff of this commit:
cvs rdiff -u -r1.357.4.3 -r1.357.4.4 src/sys/netinet/tcp_input.c

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

Modified files:

Index: src/sys/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.357.4.3 src/sys/netinet/tcp_input.c:1.357.4.4
--- src/sys/netinet/tcp_input.c:1.357.4.3	Fri Mar 30 11:17:19 2018
+++ src/sys/netinet/tcp_input.c	Tue Jul  7 11:56:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.357.4.3 2018/03/30 11:17:19 martin Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.357.4.4 2020/07/07 11:56:57 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.3 2018/03/30 11:17:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.4 2020/07/07 11:56:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1273,16 +1273,32 @@ tcp_input(struct mbuf *m, ...)
 #endif
 
 	/*
+	 * Enforce alignment requirements that are violated in
+	 * some cases, see kern/50766 for details.
+	 */
+	if (TCP_HDR_ALIGNED_P(th) == 0) {
+		m = m_copyup(m, toff + sizeof(struct tcphdr), 0);
+		if (m == NULL) {
+			TCP_STATINC(TCP_STAT_RCVSHORT);
+			return;
+		}
+		th = (struct tcphdr *)(mtod(m, char *) + toff);
+	}
+	KASSERT(TCP_HDR_ALIGNED_P(th));
+
+	/*
 	 * Get IP and TCP header.
 	 * Note: IP leaves IP header in first mbuf.
 	 */
+#ifdef INET6
+	ip6 = mtod(m, struct ip6_hdr *);
+#endif
+#ifdef INET
 	ip = mtod(m, struct ip *);
+#endif
 	switch (ip->ip_v) {
 #ifdef INET
 	case 4:
-#ifdef INET6
-		ip6 = NULL;
-#endif
 		af = AF_INET;
 		iphlen = sizeof(struct ip);
 		IP6_EXTHDR_GET(th, struct tcphdr *, m, toff,
@@ -1299,10 +1315,8 @@ tcp_input(struct mbuf *m, ...)
 #endif
 #ifdef INET6
 	case 6:
-		ip = NULL;
 		iphlen = sizeof(struct ip6_hdr);
 		af = AF_INET6;
-		ip6 = mtod(m, struct ip6_hdr *);
 		IP6_EXTHDR_GET(th, struct tcphdr *, m, toff,
 			sizeof(struct tcphdr));
 		if (th == NULL) {
@@ -1349,23 +1363,6 @@ tcp_input(struct mbuf *m, ...)
 		m_freem(m);
 		return;
 	}
-	/*
- * Enforce alignment requirements that are violated in
-	 * some cases, see kern/50766 for details.
-	 */
-	if (TCP_HDR_ALIGNED_P(th) == 0) {
-		m = m_copyup(m, toff + sizeof(struct tcphdr), 0);
-		if (m == NULL) {
-			TCP_STATINC(TCP_STAT_RCVSHORT);
-			return;
-		}
-		ip = mtod(m, struct ip *);
-#ifdef INET6
-		ip6 = mtod(m, struct ip6_hdr *);
-#endif
-		th = (struct tcphdr *)(mtod(m, char *) + toff);
-	}
-	KASSERT(TCP_HDR_ALIGNED_P(th));
 
 	/*
 	 * Check that TCP offset makes sense,
@@ -1601,7 +1598,6 @@ findpcb:
 			m_freem(in6p->in6p_options);
 			in6p->in6p_options = 0;
 		}
-		KASSERT(ip6 != NULL);
 		ip6_savecontrol(in6p, &in6p->in6p_options, ip6, m);
 	}
 #endif



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

2020-06-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jun 30 17:41:01 UTC 2020

Modified Files:
src/sys/dev/acpi [netbsd-8]: acpi_display.c

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

sys/dev/acpi/acpi_display.c: revision 1.18

Only need to set brightness if reading the initial state fails
to sync firmware and the driver. Avoids black screen at boot time.

Thanks to jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.16.2.1 src/sys/dev/acpi/acpi_display.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/acpi/acpi_display.c
diff -u src/sys/dev/acpi/acpi_display.c:1.16 src/sys/dev/acpi/acpi_display.c:1.16.2.1
--- src/sys/dev/acpi/acpi_display.c:1.16	Thu Jun  1 02:45:09 2017
+++ src/sys/dev/acpi/acpi_display.c	Tue Jun 30 17:41:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_display.c,v 1.16 2017/06/01 02:45:09 chs Exp $	*/
+/*	$NetBSD: acpi_display.c,v 1.16.2.1 2020/06/30 17:41:01 martin Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.16 2017/06/01 02:45:09 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.16.2.1 2020/06/30 17:41:01 martin Exp $");
 
 #include 
 #include 
@@ -647,8 +647,8 @@ acpidisp_out_attach(device_t parent, dev
 		 * Synchronize ACPI and driver brightness levels, and
 		 * check that brightness control is working.
 		 */
-		(void)acpidisp_get_brightness(osc, &bc->bc_current);
-		if (acpidisp_set_brightness(osc, bc->bc_current)) {
+		if (acpidisp_get_brightness(osc, &bc->bc_current) &&
+		acpidisp_set_brightness(osc, bc->bc_current)) {
 			kmem_free(bc->bc_level,
 			bc->bc_level_count * sizeof(*bc->bc_level));
 			kmem_free(bc, sizeof(*bc));



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

2020-06-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun 20 16:05:06 UTC 2020

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

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

sys/arch/x86/x86/cpu_rng.c: revision 1.16

Use x86_read_psl/x86_disable_intr/x86_read_psl to defer interrupts.

Using x86_disable_intr/x86_enable_intr causes a bit of a snag when we
try it early at boot before we're ready to handle interrupts, because
it has the effect of enabling interrupts!

Fixes instant reset at boot on VIA CPUs.  The instant reset on boot
is new since the entropy rework, which initialized the x86 CPU RNG
earlier than before, but in principle this could also cause other
problems while not early at boot too.

XXX pullup


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.12.1 src/sys/arch/x86/x86/cpu_rng.c

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

Modified files:

Index: src/sys/arch/x86/x86/cpu_rng.c
diff -u src/sys/arch/x86/x86/cpu_rng.c:1.5 src/sys/arch/x86/x86/cpu_rng.c:1.5.12.1
--- src/sys/arch/x86/x86/cpu_rng.c:1.5	Mon Feb 29 00:17:54 2016
+++ src/sys/arch/x86/x86/cpu_rng.c	Sat Jun 20 16:05:06 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_rng.c,v 1.5 2016/02/29 00:17:54 riastradh Exp $ */
+/* $NetBSD: cpu_rng.c,v 1.5.12.1 2020/06/20 16:05:06 martin Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -136,6 +136,7 @@ exhausted:
 static size_t
 cpu_rng_via(cpu_rng_t *out)
 {
+	u_long psl;
 	uint32_t creg0, rndsts;
 
 	/*
@@ -149,9 +150,9 @@ cpu_rng_via(cpu_rng_t *out)
 	 * even if such a fault is generated.
 	 *
 	 * XXX can this really happen if we don't use "rep xstorrng"?
-	 *
 	 */
 	kpreempt_disable();
+	psl = x86_read_psl();
 	x86_disable_intr();
 	creg0 = rcr0();
 	lcr0(creg0 & ~(CR0_EM|CR0_TS)); /* Permit access to SIMD/FPU path */
@@ -165,7 +166,7 @@ cpu_rng_via(cpu_rng_t *out)
 	: "=a" (rndsts), "+D" (out) : "d" (0) : "memory");
 	/* Put CR0 back how it was */
 	lcr0(creg0);
-	x86_enable_intr();
+	x86_write_psl(psl);
 	kpreempt_enable();
 
 	/*



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

2020-06-16 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Jun 16 10:28:29 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: if_run.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #1559):
sys/dev/usb/if_run.c: revision 1.41
Better bounds checking for oversized packets, to avoid kernel memory
corruption. Pointed out by Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.2 -r1.22.2.3 src/sys/dev/usb/if_run.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/if_run.c
diff -u src/sys/dev/usb/if_run.c:1.22.2.2 src/sys/dev/usb/if_run.c:1.22.2.3
--- src/sys/dev/usb/if_run.c:1.22.2.2	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_run.c	Tue Jun 16 10:28:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_run.c,v 1.22.2.2 2018/08/08 10:28:35 martin Exp $	*/
+/*	$NetBSD: if_run.c,v 1.22.2.3 2020/06/16 10:28:29 bouyer Exp $	*/
 /*	$OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.22.2.2 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.22.2.3 2020/06/16 10:28:29 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2255,7 +2255,8 @@ run_rx_frame(struct run_softc *sc, uint8
 		return;
 	}
 	if (len > MHLEN) {
-		MCLGET(m, M_DONTWAIT);
+		if (__predict_true(len <= MCLBYTES))
+			MCLGET(m, M_DONTWAIT);
 		if (__predict_false(!(m->m_flags & M_EXT))) {
 			ifp->if_ierrors++;
 			m_freem(m);



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

2020-06-16 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Jun 16 10:27:04 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: if_otus.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #1558):
sys/dev/usb/if_otus.c: revision 1.45 via patch
Stricter bounds check for some packet length we get from the usb chip,
to make sure we do not corrupt kernel memory.
Pointed out by Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.31.2.2 -r1.31.2.3 src/sys/dev/usb/if_otus.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/if_otus.c
diff -u src/sys/dev/usb/if_otus.c:1.31.2.2 src/sys/dev/usb/if_otus.c:1.31.2.3
--- src/sys/dev/usb/if_otus.c:1.31.2.2	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_otus.c	Tue Jun 16 10:27:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_otus.c,v 1.31.2.2 2018/08/08 10:28:35 martin Exp $	*/
+/*	$NetBSD: if_otus.c,v 1.31.2.3 2020/06/16 10:27:03 bouyer Exp $	*/
 /*	$OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.31.2.2 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.31.2.3 2020/06/16 10:27:03 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1745,6 +1745,10 @@ otus_sub_rxeof(struct otus_softc *sc, ui
 	}
 	/* Compute MPDU's length. */
 	mlen = len - AR_PLCP_HDR_LEN - sizeof(*tail);
+	if (__predict_false(mlen < IEEE80211_CRC_LEN)) {
+		ifp->if_ierrors++;
+		return;
+	}
 	mlen -= IEEE80211_CRC_LEN;	/* strip 802.11 FCS */
 	/* Make sure there's room for an 802.11 header. */
 	/*
@@ -1765,7 +1769,8 @@ otus_sub_rxeof(struct otus_softc *sc, ui
 		return;
 	}
 	if (align + mlen > MHLEN) {
-		MCLGET(m, M_DONTWAIT);
+		if (__predict_true(align + mlen <= MCLBYTES))
+			MCLGET(m, M_DONTWAIT);
 		if (__predict_false(!(m->m_flags & M_EXT))) {
 			ifp->if_ierrors++;
 			m_freem(m);



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

2020-06-16 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Jun 16 10:23:04 UTC 2020

Modified Files:
src/sys/arch/mac68k/dev [netbsd-8]: ams.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1557):
sys/arch/mac68k/dev/ams.c: revision 1.23
Fix inverted Y-axis value passed to wsmouse_input(9).
Note this is what src/sys/arch/macppc/dev/ams.c does as
"upward (moving the mouse forward) is positive" as noted in wsmouse(9):
 http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/macppc/dev/ams.c#rev1.4
Reported and tested by @NonameInsect on his SE/30 and Xorg server.
Should be pulled up to netbsd-8 and netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.22.1 src/sys/arch/mac68k/dev/ams.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/dev/ams.c
diff -u src/sys/arch/mac68k/dev/ams.c:1.22 src/sys/arch/mac68k/dev/ams.c:1.22.22.1
--- src/sys/arch/mac68k/dev/ams.c:1.22	Sat Oct 19 16:23:17 2013
+++ src/sys/arch/mac68k/dev/ams.c	Tue Jun 16 10:23:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ams.c,v 1.22 2013/10/19 16:23:17 martin Exp $	*/
+/*	$NetBSD: ams.c,v 1.22.22.1 2020/06/16 10:23:04 bouyer Exp $	*/
 
 /*
  * Copyright (C) 1998	Colin Wood
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ams.c,v 1.22 2013/10/19 16:23:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ams.c,v 1.22.22.1 2020/06/16 10:23:04 bouyer Exp $");
 
 #include 
 #include 
@@ -506,7 +506,7 @@ ms_processevent(adb_event_t *event, stru
 		if (amsc->sc_wsmousedev != NULL) /* wsmouse is attached? */
 			wsmouse_input(amsc->sc_wsmousedev,
 			new_event.u.m.buttons,
-			new_event.u.m.dx, new_event.u.m.dy, 0, 0,
+			new_event.u.m.dx, -new_event.u.m.dy, 0, 0,
 			WSMOUSE_INPUT_DELTA);
 #else
 		/* do nothing */ ;



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

2020-06-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun  7 17:08:12 UTC 2020

Modified Files:
src/sys/kern [netbsd-8]: subr_pcu.c

Log Message:
Pull up following revision(s) (requested by thorpej in ticket #949):

sys/kern/subr_pcu.c: revision 1.22

Relax the KASSERT() in pcu_discard_all() to allow non-curlwp if it is
in LSIDL state, which can happen if the new LWP is exiting before it's
ever run, e.g. if an error occurs in _lwp_create(2).


To generate a diff of this commit:
cvs rdiff -u -r1.20.6.1 -r1.20.6.2 src/sys/kern/subr_pcu.c

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

Modified files:

Index: src/sys/kern/subr_pcu.c
diff -u src/sys/kern/subr_pcu.c:1.20.6.1 src/sys/kern/subr_pcu.c:1.20.6.2
--- src/sys/kern/subr_pcu.c:1.20.6.1	Tue Oct 24 09:14:59 2017
+++ src/sys/kern/subr_pcu.c	Sun Jun  7 17:08:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pcu.c,v 1.20.6.1 2017/10/24 09:14:59 snj Exp $	*/
+/*	$NetBSD: subr_pcu.c,v 1.20.6.2 2020/06/07 17:08:12 martin Exp $	*/
 
 /*-
  * Copyright (c) 2011, 2014 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pcu.c,v 1.20.6.1 2017/10/24 09:14:59 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcu.c,v 1.20.6.2 2020/06/07 17:08:12 martin Exp $");
 
 #include 
 #include 
@@ -130,7 +130,12 @@ pcu_discard_all(lwp_t *l)
 {
 	const uint32_t pcu_valid = l->l_pcu_valid;
 
-	KASSERT(l == curlwp || ((l->l_flag & LW_SYSTEM) && pcu_valid == 0));
+	/*
+	 * The check for LSIDL here is to catch the case where the LWP exits
+	 * due to an error in the LWP creation path before it ever runs.
+	 */
+	KASSERT(l == curlwp || l->l_stat == LSIDL ||
+		((l->l_flag & LW_SYSTEM) && pcu_valid == 0));
 
 	if (__predict_true(pcu_valid == 0)) {
 		/* PCUs are not in use. */



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

2020-06-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun  7 16:41:24 UTC 2020

Modified Files:
src/sys/dev/sysmon [netbsd-8]: sysmon_envsys.c

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

sys/dev/sysmon/sysmon_envsys.c: revision 1.145

Don't queue sysmon refresh until the rndsource is attached.

Using the rndsource, as refreshing the sensors will do, is not
allowed until _after_ rnd_source_attach.

XXX pullup-7
XXX pullup-8
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.139.10.1 -r1.139.10.2 src/sys/dev/sysmon/sysmon_envsys.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/sysmon/sysmon_envsys.c
diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.139.10.1 src/sys/dev/sysmon/sysmon_envsys.c:1.139.10.2
--- src/sys/dev/sysmon/sysmon_envsys.c:1.139.10.1	Sat Sep 23 17:22:48 2017
+++ src/sys/dev/sysmon/sysmon_envsys.c	Sun Jun  7 16:41:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysmon_envsys.c,v 1.139.10.1 2017/09/23 17:22:48 snj Exp $	*/
+/*	$NetBSD: sysmon_envsys.c,v 1.139.10.2 2020/06/07 16:41:24 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.139.10.1 2017/09/23 17:22:48 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.139.10.2 2020/06/07 16:41:24 martin Exp $");
 
 #include 
 #include 
@@ -824,16 +824,6 @@ out:
 	if (error == 0) {
 		nevent = 0;
 
-		if (sme->sme_flags & SME_INIT_REFRESH) {
-			sysmon_task_queue_sched(0, sme_initial_refresh, sme);
-			DPRINTF(("%s: scheduled initial refresh for '%s'\n",
-__func__, sme->sme_name));
-		}
-		SLIST_FOREACH(evdv, &sme_evdrv_list, evdrv_head) {
-			sysmon_task_queue_sched(0,
-			sme_event_drvadd, evdv->evdrv);
-			nevent++;
-		}
 		/*
 		 * Hook the sensor into rnd(4) entropy pool if requested
 		 */
@@ -889,6 +879,17 @@ out:
 rnd_type, rnd_flag);
 			}
 		}
+
+		if (sme->sme_flags & SME_INIT_REFRESH) {
+			sysmon_task_queue_sched(0, sme_initial_refresh, sme);
+			DPRINTF(("%s: scheduled initial refresh for '%s'\n",
+__func__, sme->sme_name));
+		}
+		SLIST_FOREACH(evdv, &sme_evdrv_list, evdrv_head) {
+			sysmon_task_queue_sched(0,
+			sme_event_drvadd, evdv->evdrv);
+			nevent++;
+		}
 		DPRINTF(("%s: driver '%s' registered (nsens=%d nevent=%d)\n",
 		__func__, sme->sme_name, sme->sme_nsensors, nevent));
 	}



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

2020-06-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun  7 12:23:43 UTC 2020

Modified Files:
src/sys/arch/powerpc/oea [netbsd-8]: pmap.c

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

sys/arch/powerpc/oea/pmap.c: revision 1.96

Stop returning while PMAP_LOCK() (= KERNEL_LOCK(1, NULL)) is held.
Kernel freeze with heavy load is significantly mitigated (fixed?),
in which I could not even enter DDB from console.

XXX
There is still inconsistency in usage of two PVO pools.
I will send-pr later.

XXX
pullup to netbsd-[987]


To generate a diff of this commit:
cvs rdiff -u -r1.94.8.1 -r1.94.8.2 src/sys/arch/powerpc/oea/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/powerpc/oea/pmap.c
diff -u src/sys/arch/powerpc/oea/pmap.c:1.94.8.1 src/sys/arch/powerpc/oea/pmap.c:1.94.8.2
--- src/sys/arch/powerpc/oea/pmap.c:1.94.8.1	Tue Feb 27 09:07:33 2018
+++ src/sys/arch/powerpc/oea/pmap.c	Sun Jun  7 12:23:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.94.8.1 2018/02/27 09:07:33 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.94.8.2 2020/06/07 12:23:43 martin Exp $	*/
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.94.8.1 2018/02/27 09:07:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.94.8.2 2020/06/07 12:23:43 martin Exp $");
 
 #define	PMAP_NOOPNAMES
 
@@ -991,6 +991,7 @@ pmap_pte_spill(struct pmap *pm, vaddr_t 
 			}
 			source_pvo = pvo;
 			if (exec && !PVO_EXECUTABLE_P(source_pvo)) {
+PMAP_UNLOCK();
 return 0;
 			}
 			if (victim_pvo != NULL)
@@ -2162,6 +2163,7 @@ pmap_extract(pmap_t pm, vaddr_t va, padd
 return true;
 			}
 		}
+		PMAP_UNLOCK();
 		return false;
 #elif defined (PMAP_OEA64_BRIDGE)
 	if (va >= SEGMENT_LENGTH)



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

2020-05-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May 31 10:27:26 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1551):

sys/dev/usb/usb.c: revision 1.187

Don't allow open of /dev/usb if there are no attached busses.
PR kern/55303 mutex_vector_enter,512: uninitialized lock


To generate a diff of this commit:
cvs rdiff -u -r1.165.6.5 -r1.165.6.6 src/sys/dev/usb/usb.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/usb.c
diff -u src/sys/dev/usb/usb.c:1.165.6.5 src/sys/dev/usb/usb.c:1.165.6.6
--- src/sys/dev/usb/usb.c:1.165.6.5	Sat Nov 16 16:30:09 2019
+++ src/sys/dev/usb/usb.c	Sun May 31 10:27:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.c,v 1.165.6.5 2019/11/16 16:30:09 martin Exp $	*/
+/*	$NetBSD: usb.c,v 1.165.6.6 2020/05/31 10:27:26 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.165.6.5 2019/11/16 16:30:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.165.6.6 2020/05/31 10:27:26 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -179,6 +179,11 @@ Static void	usb_create_event_thread(devi
 Static void	usb_event_thread(void *);
 Static void	usb_task_thread(void *);
 
+/*
+ * Count of USB busses
+ */
+int nusbbusses = 0;
+
 #define USB_MAX_EVENTS 100
 struct usb_event_q {
 	struct usb_event ue;
@@ -331,6 +336,9 @@ usb_doattach(device_t self)
 
 	USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
 
+	/* Protected by KERNEL_LOCK */
+	nusbbusses++;
+
 	sc->sc_bus->ub_usbctl = self;
 	sc->sc_port.up_power = USB_MAX_POWER;
 
@@ -639,6 +647,9 @@ usbopen(dev_t dev, int flag, int mode, s
 	int unit = minor(dev);
 	struct usb_softc *sc;
 
+	if (nusbbusses == 0)
+		return ENXIO;
+
 	if (unit == USB_DEV_MINOR) {
 		if (usb_dev_open)
 			return EBUSY;



CVS commit: [netbsd-8] src/sys

2020-05-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May 25 17:48:16 UTC 2020

Modified Files:
src/sys/kern [netbsd-8]: kern_time.c
src/sys/netinet [netbsd-8]: igmp.c

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

sys/netinet/igmp.c: revision 1.70
sys/kern/kern_time.c: revision 1.204

igmp_sendpkt() expects ip_output() to set 'imo.imo_multicast_ttl' into
'ip->ip_ttl'; but ip_output() won't if the target is not a multicast
address, meaning that the uninitialized 'ip->ip_ttl' byte gets sent to
the network. This leaks one byte of kernel heap.

Fix this by filling 'ip->ip_ttl' with a TTL of one.
Found by KMSAN.

 -

Fix uninitialized memory access. Found by KMSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.189.8.5 -r1.189.8.6 src/sys/kern/kern_time.c
cvs rdiff -u -r1.64.6.2 -r1.64.6.3 src/sys/netinet/igmp.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_time.c
diff -u src/sys/kern/kern_time.c:1.189.8.5 src/sys/kern/kern_time.c:1.189.8.6
--- src/sys/kern/kern_time.c:1.189.8.5	Sun Feb 24 10:49:53 2019
+++ src/sys/kern/kern_time.c	Mon May 25 17:48:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.189.8.5 2019/02/24 10:49:53 martin Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.189.8.6 2020/05/25 17:48:16 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.5 2019/02/24 10:49:53 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.6 2020/05/25 17:48:16 martin Exp $");
 
 #include 
 #include 
@@ -354,8 +354,12 @@ again:
 		struct timespec rmtend;
 		struct timespec t0;
 		struct timespec *t;
+		int err;
+
+		err = clock_gettime1(clock_id, &rmtend);
+		if (err != 0)
+			return err;
 
-		(void)clock_gettime1(clock_id, &rmtend);
 		t = (rmt != NULL) ? rmt : &t0;
 		if (flags & TIMER_ABSTIME) {
 			timespecsub(rqt, &rmtend, t);

Index: src/sys/netinet/igmp.c
diff -u src/sys/netinet/igmp.c:1.64.6.2 src/sys/netinet/igmp.c:1.64.6.3
--- src/sys/netinet/igmp.c:1.64.6.2	Fri Jul 13 14:26:47 2018
+++ src/sys/netinet/igmp.c	Mon May 25 17:48:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: igmp.c,v 1.64.6.2 2018/07/13 14:26:47 martin Exp $	*/
+/*	$NetBSD: igmp.c,v 1.64.6.3 2020/05/25 17:48:16 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.64.6.2 2018/07/13 14:26:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.64.6.3 2020/05/25 17:48:16 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -620,6 +620,7 @@ igmp_sendpkt(struct in_multi *inm, int t
 	ip->ip_tos = 0;
 	ip->ip_len = htons(sizeof(struct ip) + IGMP_MINLEN);
 	ip->ip_off = htons(0);
+	ip->ip_ttl = IP_DEFAULT_MULTICAST_TTL;
 	ip->ip_p = IPPROTO_IGMP;
 	ip->ip_src = zeroin_addr;
 	ip->ip_dst = inm->inm_addr;



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

2020-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May 13 12:39:20 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by yamaguchi in ticket #1547):

sys/arch/x86/pci/if_vmx.c: revision 1.60

Fix the wrong logic about making the number of vmx(4) TX/RX queue
be power of two

reviewed by nonaka@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.19.6.7 -r1.19.6.8 src/sys/arch/x86/pci/if_vmx.c

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

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.19.6.7 src/sys/arch/x86/pci/if_vmx.c:1.19.6.8
--- src/sys/arch/x86/pci/if_vmx.c:1.19.6.7	Thu Dec 26 20:23:39 2019
+++ src/sys/arch/x86/pci/if_vmx.c	Wed May 13 12:39:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.19.6.7 2019/12/26 20:23:39 martin Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.19.6.8 2020/05/13 12:39:20 martin Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,12 +19,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.19.6.7 2019/12/26 20:23:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.19.6.8 2020/05/13 12:39:20 martin Exp $");
 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -398,23 +399,11 @@ CFATTACH_DECL3_NEW(vmx, sizeof(struct vm
 static int
 vmxnet3_calc_queue_size(int n)
 {
-	int v, q;
 
-	v = n;
-	while (v != 0) {
-		if (powerof2(n) != 0)
-			break;
-		v /= 2;
-		q = rounddown2(n, v);
-		if (q != 0) {
-			n = q;
-			break;
-		}
-	}
-	if (n == 0)
-		n = 1;
+	if (__predict_false(n <= 0))
+		return 1;
 
-	return n;
+	return (1U << (fls32(n) - 1));
 }
 
 static inline void



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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:35:57 UTC 2020

Modified Files:
src/sys/kern [netbsd-8]: subr_cprng.c

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

sys/kern/subr_cprng.c: revision 1.34

Disable rngtest on output of cprng_strong.

We already do a self-test for correctenss of Hash_DRBG output;
applying rngtest to it does nothing but give everyone warning fatigue
about spurious rngtest failures.


To generate a diff of this commit:
cvs rdiff -u -r1.27.10.2 -r1.27.10.3 src/sys/kern/subr_cprng.c

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

Modified files:

Index: src/sys/kern/subr_cprng.c
diff -u src/sys/kern/subr_cprng.c:1.27.10.2 src/sys/kern/subr_cprng.c:1.27.10.3
--- src/sys/kern/subr_cprng.c:1.27.10.2	Mon Nov 25 16:03:08 2019
+++ src/sys/kern/subr_cprng.c	Thu Apr 30 15:35:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cprng.c,v 1.27.10.2 2019/11/25 16:03:08 martin Exp $ */
+/*	$NetBSD: subr_cprng.c,v 1.27.10.3 2020/04/30 15:35:57 martin Exp $ */
 
 /*-
  * Copyright (c) 2011-2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.27.10.2 2019/11/25 16:03:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.27.10.3 2020/04/30 15:35:57 martin Exp $");
 
 #include 
 #include 
@@ -49,9 +49,6 @@ __KERNEL_RCSID(0, "$NetBSD: subr_cprng.c
 #include 
 #include 
 #include 
-#if DIAGNOSTIC
-#include 
-#endif
 
 #include 
 
@@ -66,9 +63,6 @@ static void	cprng_strong_generate(struct
 static void	cprng_strong_reseed(struct cprng_strong *);
 static void	cprng_strong_reseed_from(struct cprng_strong *, const void *,
 		size_t, bool);
-#if DIAGNOSTIC
-static void	cprng_strong_rngtest(struct cprng_strong *);
-#endif
 
 static rndsink_callback_t	cprng_strong_rndsink_callback;
 
@@ -450,48 +444,8 @@ cprng_strong_reseed_from(struct cprng_st
 		/* XXX Fix nist_hash_drbg API so this can't happen.  */
 		panic("cprng %s: NIST Hash_DRBG reseed failed",
 		cprng->cs_name);
-
-#if DIAGNOSTIC
-	cprng_strong_rngtest(cprng);
-#endif
 }
 
-#if DIAGNOSTIC
-/*
- * Generate some output and apply a statistical RNG test to it.
- */
-static void
-cprng_strong_rngtest(struct cprng_strong *cprng)
-{
-
-	KASSERT(mutex_owned(&cprng->cs_lock));
-
-	/* XXX Switch to a pool cache instead?  */
-	rngtest_t *const rt = kmem_intr_alloc(sizeof(*rt), KM_NOSLEEP);
-	if (rt == NULL)
-		/* XXX Warn?  */
-		return;
-
-	(void)strlcpy(rt->rt_name, cprng->cs_name, sizeof(rt->rt_name));
-
-	if (nist_hash_drbg_generate(&cprng->cs_drbg, rt->rt_b,
-		sizeof(rt->rt_b), NULL, 0))
-		panic("cprng %s: NIST Hash_DRBG failed after reseed",
-		cprng->cs_name);
-
-	if (rngtest(rt)) {
-		printf("cprng %s: failed statistical RNG test\n",
-		cprng->cs_name);
-		/* XXX Not clear that this does any good...  */
-		cprng->cs_ready = false;
-		rndsink_schedule(cprng->cs_rndsink);
-	}
-
-	explicit_memset(rt, 0, sizeof(*rt)); /* paranoia */
-	kmem_intr_free(rt, sizeof(*rt));
-}
-#endif
-
 /*
  * Feed entropy from an rndsink request into the CPRNG for which the
  * request was issued.



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

2020-04-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Apr 25 10:54:23 UTC 2020

Modified Files:
src/sys/arch/hppa/hppa [netbsd-8]: trap.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1542):

sys/arch/hppa/hppa/trap.c: revision 1.115

Fix KASSERT that has been incorrect since revision 1.85 from 10 years
ago.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.107.10.1 src/sys/arch/hppa/hppa/trap.c

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

Modified files:

Index: src/sys/arch/hppa/hppa/trap.c
diff -u src/sys/arch/hppa/hppa/trap.c:1.107 src/sys/arch/hppa/hppa/trap.c:1.107.10.1
--- src/sys/arch/hppa/hppa/trap.c:1.107	Mon Mar  2 11:05:12 2015
+++ src/sys/arch/hppa/hppa/trap.c	Sat Apr 25 10:54:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.107 2015/03/02 11:05:12 martin Exp $	*/
+/*	$NetBSD: trap.c,v 1.107.10.1 2020/04/25 10:54:23 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.107 2015/03/02 11:05:12 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.107.10.1 2020/04/25 10:54:23 martin Exp $");
 
 /* #define INTRDEBUG */
 /* #define TRAPDEBUG */
@@ -850,7 +850,7 @@ do_onfault:
 		}
 
 		/* Never call uvm_fault in interrupt context. */
-		KASSERT(curcpu()->ci_cpl == 0);
+		KASSERT(curcpu()->ci_intr_depth == 0);
 
 		onfault = pcb->pcb_onfault;
 		pcb->pcb_onfault = 0;



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

2020-04-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Apr 24 16:15:24 UTC 2020

Modified Files:
src/sys/dev/dkwedge [netbsd-8]: dk.c

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

sys/dev/dkwedge/dk.c: revision 1.98

Update sc->sc_parent->dk_rawvp while the lock named dk_rawlock held
to prevent a race condition

Fixes PR kern/55026

OKed by mlelstv@, thanks


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.96.6.1 src/sys/dev/dkwedge/dk.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/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.96 src/sys/dev/dkwedge/dk.c:1.96.6.1
--- src/sys/dev/dkwedge/dk.c:1.96	Sun Mar  5 23:07:12 2017
+++ src/sys/dev/dkwedge/dk.c	Fri Apr 24 16:15:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dk.c,v 1.96 2017/03/05 23:07:12 mlelstv Exp $	*/
+/*	$NetBSD: dk.c,v 1.96.6.1 2020/04/24 16:15:24 martin Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.96 2017/03/05 23:07:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.96.6.1 2020/04/24 16:15:24 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1152,21 +1152,23 @@ dkopen(dev_t dev, int flags, int fmt, st
 static int
 dklastclose(struct dkwedge_softc *sc)
 {
-	int error = 0, doclose;
+	struct vnode *vp;
+	int error = 0;
 
-	doclose = 0;
+	vp = NULL;
 	if (sc->sc_parent->dk_rawopens > 0) {
-		if (--sc->sc_parent->dk_rawopens == 0)
-			doclose = 1;
+		if (--sc->sc_parent->dk_rawopens == 0) {
+			KASSERT(sc->sc_parent->dk_rawvp != NULL);
+			vp = sc->sc_parent->dk_rawvp;
+			sc->sc_parent->dk_rawvp = NULL;
+		}
 	}
 
 	mutex_exit(&sc->sc_parent->dk_rawlock);
 	mutex_exit(&sc->sc_dk.dk_openlock);
 
-	if (doclose) {
-		KASSERT(sc->sc_parent->dk_rawvp != NULL);
-		dk_close_parent(sc->sc_parent->dk_rawvp, FREAD | FWRITE);
-		sc->sc_parent->dk_rawvp = NULL;
+	if (vp) {
+		dk_close_parent(vp, FREAD | FWRITE);
 	}
 
 	return error;



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

2020-04-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Apr 24 16:07:05 UTC 2020

Modified Files:
src/sys/arch/hp300/hp300 [netbsd-8]: machdep.c

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

sys/arch/hp300/hp300/machdep.c: revision 1.233

Fix garbages in dmesg caused by uninitialized variables slipped in r1.228.

Noticed in HP9000/362 dmesg:
 https://dmesgd.nycbug.org/index.cgi?do=view&id=5459

Should be pulled up to netbsd-8 and netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.229.20.1 src/sys/arch/hp300/hp300/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/hp300/hp300/machdep.c
diff -u src/sys/arch/hp300/hp300/machdep.c:1.229 src/sys/arch/hp300/hp300/machdep.c:1.229.20.1
--- src/sys/arch/hp300/hp300/machdep.c:1.229	Sun Apr 20 04:12:54 2014
+++ src/sys/arch/hp300/hp300/machdep.c	Fri Apr 24 16:07:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.229 2014/04/20 04:12:54 tsutsui Exp $	*/
+/*	$NetBSD: machdep.c,v 1.229.20.1 2020/04/24 16:07:04 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.229 2014/04/20 04:12:54 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.229.20.1 2020/04/24 16:07:04 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -433,6 +433,7 @@ identifycpu(void)
 	/*
 	 * ...and the FPU type.
 	 */
+	fpu[0] = '\0';
 	switch (fputype) {
 	case FPU_68040:
 		strlcpy(fpu, "+FPU", sizeof(fpu));
@@ -458,6 +459,7 @@ identifycpu(void)
 	/*
 	 * ...and finally, the cache type.
 	 */
+	cache[0] = '\0';
 	if (cputype == CPU_68040)
 		snprintf(cache, sizeof(cache),
 		", 4k on-chip physical I/D caches");



CVS commit: [netbsd-8] src/sys/compat/ossaudio

2020-04-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 22 18:15:12 UTC 2020

Modified Files:
src/sys/compat/ossaudio [netbsd-8]: ossaudio.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1535):

sys/compat/ossaudio/ossaudio.c: revision 1.83

ossaudio: Avoid giving userland uninitialized memory. Noticed by maxv.

The uninitalized field in this structure is `fillers`, an array that
simply reserves space for later changes in OSSv4, which this version
of the OSS compat layer (specifically for Linux applications) makes no
effort to implement.


To generate a diff of this commit:
cvs rdiff -u -r1.70.6.2 -r1.70.6.3 src/sys/compat/ossaudio/ossaudio.c

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

Modified files:

Index: src/sys/compat/ossaudio/ossaudio.c
diff -u src/sys/compat/ossaudio/ossaudio.c:1.70.6.2 src/sys/compat/ossaudio/ossaudio.c:1.70.6.3
--- src/sys/compat/ossaudio/ossaudio.c:1.70.6.2	Tue Jan 21 18:12:54 2020
+++ src/sys/compat/ossaudio/ossaudio.c	Wed Apr 22 18:15:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.70.6.2 2020/01/21 18:12:54 martin Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.70.6.3 2020/04/22 18:15:12 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.70.6.2 2020/01/21 18:12:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.70.6.3 2020/04/22 18:15:12 martin Exp $");
 
 #include 
 #include 
@@ -1075,6 +1075,7 @@ oss_ioctl_mixer(struct lwp *lwp, const s
 			__func__, error));
 			goto out;
 		}
+		memset(&omi, 0, sizeof omi);
 		omi.modify_counter = 1;
 		strncpy(omi.id, adev.name, sizeof omi.id);
 		strncpy(omi.name, adev.name, sizeof omi.name);



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

2020-04-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 21 16:58:57 UTC 2020

Modified Files:
src/sys/arch/macppc/stand/ofwboot [netbsd-8]: Locore.c
src/sys/arch/powerpc/oea [netbsd-8]: ofw_consinit.c

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

sys/arch/macppc/stand/ofwboot/Locore.c: revision 1.34 (via patch)
sys/arch/powerpc/oea/ofw_consinit.c: revision 1.18

When boot up with auto-boot? == true, some systems do not provide stdout
if the normal output is screen.

Open screen explicitly as stdout in this case, both for ofwboot and kernel,
which fixes problems with auto-boot? == true for Mac mini G4:
- messages from ofwboot do not appear
- kernel freeze during early boot stage

Taken from OpenBSD:
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/macppc/macppc/ofw_machdep.c#rev1.3
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/macppc/stand/Locore.c#rev1.3

XXX
pullup to netbsd-9 and -8


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.10.1 src/sys/arch/macppc/stand/ofwboot/Locore.c
cvs rdiff -u -r1.17 -r1.17.10.1 src/sys/arch/powerpc/oea/ofw_consinit.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/macppc/stand/ofwboot/Locore.c
diff -u src/sys/arch/macppc/stand/ofwboot/Locore.c:1.29 src/sys/arch/macppc/stand/ofwboot/Locore.c:1.29.10.1
--- src/sys/arch/macppc/stand/ofwboot/Locore.c:1.29	Fri Apr 22 18:25:41 2016
+++ src/sys/arch/macppc/stand/ofwboot/Locore.c	Tue Apr 21 16:58:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: Locore.c,v 1.29 2016/04/22 18:25:41 christos Exp $	*/
+/*	$NetBSD: Locore.c,v 1.29.10.1 2020/04/21 16:58:56 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -621,6 +621,11 @@ setup(void)
 	OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) !=
 	sizeof(stdout))
 		OF_exit();
+
+	if (stdout == 0) {
+		/* screen should be console, but it is not open */
+		stdout = OF_open("screen");
+	}
 }
 
 void

Index: src/sys/arch/powerpc/oea/ofw_consinit.c
diff -u src/sys/arch/powerpc/oea/ofw_consinit.c:1.17 src/sys/arch/powerpc/oea/ofw_consinit.c:1.17.10.1
--- src/sys/arch/powerpc/oea/ofw_consinit.c:1.17	Sun Feb 14 18:12:30 2016
+++ src/sys/arch/powerpc/oea/ofw_consinit.c	Tue Apr 21 16:58:57 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_consinit.c,v 1.17 2016/02/14 18:12:30 dholland Exp $ */
+/* $NetBSD: ofw_consinit.c,v 1.17.10.1 2020/04/21 16:58:57 martin Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_consinit.c,v 1.17 2016/02/14 18:12:30 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_consinit.c,v 1.17.10.1 2020/04/21 16:58:57 martin Exp $");
 
 #include 
 #include 
@@ -458,6 +458,10 @@ ofwoea_bootstrap_console(void)
 	if (OF_getprop(chosen, "stdin", &stdin,
 	sizeof(stdin)) != sizeof(stdin))
 		goto nocons;
+	if (stdout == 0) {
+		 /* screen should be console, but it is not open */
+		 stdout = OF_open("screen");
+	}
 	node = OF_instance_to_package(stdout);
 	console_node = node;
 	console_instance = stdout;



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

2020-04-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 15 14:44:52 UTC 2020

Modified Files:
src/sys/dev/wsfb [netbsd-8]: genfb.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1532):

sys/dev/wsfb/genfb.c: revision 1.72

  Get genfb's address offset correctly when the value >= 4G. OK's by jmcneill.

  Tested on Intel BXNUC10I3FNK (Comet Lake U).


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.61.2.1 src/sys/dev/wsfb/genfb.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/wsfb/genfb.c
diff -u src/sys/dev/wsfb/genfb.c:1.61 src/sys/dev/wsfb/genfb.c:1.61.2.1
--- src/sys/dev/wsfb/genfb.c:1.61	Thu Jun  1 02:45:12 2017
+++ src/sys/dev/wsfb/genfb.c	Wed Apr 15 14:44:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfb.c,v 1.61 2017/06/01 02:45:12 chs Exp $ */
+/*	$NetBSD: genfb.c,v 1.61.2.1 2020/04/15 14:44:52 martin Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.61 2017/06/01 02:45:12 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.61.2.1 2020/04/15 14:44:52 martin Exp $");
 
 #include 
 #include 
@@ -95,7 +95,7 @@ genfb_init(struct genfb_softc *sc)
 {
 	prop_dictionary_t dict;
 	uint64_t cmap_cb, pmf_cb, mode_cb, bl_cb, br_cb, fbaddr;
-	uint32_t fboffset;
+	uint64_t fboffset;
 	bool console;
 
 	dict = device_properties(sc->sc_dev);
@@ -117,13 +117,12 @@ genfb_init(struct genfb_softc *sc)
 		return;
 	}
 
-	/* XXX should be a 64bit value */
-	if (!prop_dictionary_get_uint32(dict, "address", &fboffset)) {
+	if (!prop_dictionary_get_uint64(dict, "address", &fboffset)) {
 		GPRINTF("no address property\n");
 		return;
 	}
 
-	sc->sc_fboffset = fboffset;
+	sc->sc_fboffset = (bus_addr_t)fboffset;
 
 	sc->sc_fbaddr = NULL;
 	if (prop_dictionary_get_uint64(dict, "virtual_address", &fbaddr)) {



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

2020-04-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 15 14:27:54 UTC 2020

Modified Files:
src/sys/netinet6 [netbsd-8]: nd6_rtr.c

Log Message:
Pull up following revision(s) (requested by kim in ticket #1531):

sys/netinet6/nd6_rtr.c: revision 1.148

Fix default route selection

The primary issue was that in revision 1.79 a check was added in the
nd6_defrouter_select() search loop to ignore the entry if RA processing
is enabled on its interface.  In practice this results in all entries
being ignored.

This fix reverses the condition, so that an entry is ignored when RA
processing is NOT enabled on its interface.  Further, the entry is
only ignored for being selected as the default router.  The currently
installed router must be identified regardless of the (current) status
of its interface, so that we can delete the route before installing a
new one.

I also added error logging when adding or deleting a route fails. This
should help the administrator (or kernel developer) in noticing possible
problems.

Finally, if deleting a route fails, the corresponding default route
entry no longer has its "installed" flag cleared, so that deletion will
be retried.  At a minimum, this will cause repeated messages about the
failed deletion as opposed to only getting repeated messages about the
installation of a new default route failing.

Fixes PR kern/55091 and also PR bin/54997 as far as the behaviour
observed with ndp(8).


To generate a diff of this commit:
cvs rdiff -u -r1.135.6.4 -r1.135.6.5 src/sys/netinet6/nd6_rtr.c

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

Modified files:

Index: src/sys/netinet6/nd6_rtr.c
diff -u src/sys/netinet6/nd6_rtr.c:1.135.6.4 src/sys/netinet6/nd6_rtr.c:1.135.6.5
--- src/sys/netinet6/nd6_rtr.c:1.135.6.4	Wed Aug 15 12:09:58 2018
+++ src/sys/netinet6/nd6_rtr.c	Wed Apr 15 14:27:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6_rtr.c,v 1.135.6.4 2018/08/15 12:09:58 martin Exp $	*/
+/*	$NetBSD: nd6_rtr.c,v 1.135.6.5 2020/04/15 14:27:54 martin Exp $	*/
 /*	$KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.135.6.4 2018/08/15 12:09:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.135.6.5 2020/04/15 14:27:54 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -495,6 +495,11 @@ defrouter_addreq(struct nd_defrouter *ne
 	if (error == 0) {
 		nd6_numroutes++;
 		newdr->installed = 1;
+	} else {
+		char ip6buf[INET6_ADDRSTRLEN];
+		log(LOG_ERR, "defrouter_addreq: "
+		"error %d adding default router %s on %s\n",
+		error, IN6_PRINT(ip6buf, &newdr->rtaddr), newdr->ifp->if_xname);
 	}
 #ifndef NET_MPSAFE
 	splx(s);
@@ -604,10 +609,15 @@ defrouter_delreq(struct nd_defrouter *dr
 
 	error = rtrequest_newmsg(RTM_DELETE, &def.sa, &gw.sa, &mask.sa,
 	RTF_GATEWAY);
-	if (error == 0)
+	if (error == 0) {
 		nd6_numroutes--;
-
-	dr->installed = 0;
+		dr->installed = 0;
+	} else {
+		char ip6buf[INET6_ADDRSTRLEN];
+		log(LOG_ERR, "defrouter_delreq: "
+		"error %d deleting default router %s on %s\n",
+		error, IN6_PRINT(ip6buf, &dr->rtaddr), dr->ifp->if_xname);
+	}
 }
 
 /*
@@ -683,14 +693,6 @@ nd6_defrouter_select(void)
 	 * the ordering rule of the list described in defrtrlist_update().
 	 */
 	ND_DEFROUTER_LIST_FOREACH(dr) {
-		ndi = ND_IFINFO(dr->ifp);
-		if (nd6_accepts_rtadv(ndi))
-			continue;
-
-		if (selected_dr == NULL &&
-		nd6_is_llinfo_probreach(dr))
-			selected_dr = dr;
-
 		if (dr->installed && !installed_dr)
 			installed_dr = dr;
 		else if (dr->installed && installed_dr) {
@@ -698,6 +700,14 @@ nd6_defrouter_select(void)
 			log(LOG_ERR, "nd6_defrouter_select: more than one router"
 			" is installed\n");
 		}
+
+		ndi = ND_IFINFO(dr->ifp);
+		if (!nd6_accepts_rtadv(ndi))
+			continue;
+
+		if (selected_dr == NULL &&
+		nd6_is_llinfo_probreach(dr))
+			selected_dr = dr;
 	}
 	/*
 	 * If none of the default routers was found to be reachable,



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

2020-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 14 18:11:35 UTC 2020

Modified Files:
src/sys/dev/mii [netbsd-8]: miidevs.h miidevs_data.h

Log Message:
Regen for ticket #1529


To generate a diff of this commit:
cvs rdiff -u -r1.128.6.8 -r1.128.6.9 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.116.6.8 -r1.116.6.9 src/sys/dev/mii/miidevs_data.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/mii/miidevs.h
diff -u src/sys/dev/mii/miidevs.h:1.128.6.8 src/sys/dev/mii/miidevs.h:1.128.6.9
--- src/sys/dev/mii/miidevs.h:1.128.6.8	Mon Nov 25 15:57:49 2019
+++ src/sys/dev/mii/miidevs.h	Tue Apr 14 18:11:35 2020
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs.h,v 1.128.6.8 2019/11/25 15:57:49 martin Exp $	*/
+/*	$NetBSD: miidevs.h,v 1.128.6.9 2020/04/14 18:11:35 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.125.6.8 2019/11/25 15:57:23 martin Exp
+ *	NetBSD: miidevs,v 1.125.6.9 2020/04/14 17:57:17 martin Exp
  */
 
 /*-
@@ -60,10 +60,12 @@
 #define	MII_OUI_TRIDIUM	0x0001f0	/* Tridium */
 #define	MII_OUI_DATATRACK	0x0002c6	/* Data Track Technology */
 #define	MII_OUI_AGERE	0x00053d	/* Agere */
+#define	MII_OUI_QUAKE	0x000897	/* Quake Technologies */
 #define	MII_OUI_BANKSPEED	0x0006b8	/* Bankspeed Pty */
 #define	MII_OUI_NETEXCELL	0x0008bb	/* NetExcell */
 #define	MII_OUI_NETAS	0x0009c3	/* Netas */
 #define	MII_OUI_BROADCOM2	0x000af7	/* Broadcom Corporation */
+#define	MII_OUI_AELUROS	0x000b25	/* Aeluros */
 #define	MII_OUI_RALINK	0x000c43	/* Ralink Technology */
 #define	MII_OUI_ASIX	0x000ec6	/* ASIX */
 #define	MII_OUI_BROADCOM	0x001018	/* Broadcom Corporation */
@@ -71,13 +73,11 @@
 #define	MII_OUI_ALTIMA	0x0010a9	/* Altima Communications */
 #define	MII_OUI_ENABLESEMI	0x0010dd	/* Enable Semiconductor */
 #define	MII_OUI_SUNPLUS	0x001105	/* Sunplus Technology */
-#define	MII_OUI_ATHEROS	0x001374	/* Atheros */
 #define	MII_OUI_TERANETICS	0x0014a6	/* Teranetics */
 #define	MII_OUI_RALINK2	0x0017a5	/* Ralink Technology */
 #define	MII_OUI_AQUANTIA	0x0017b6	/* Aquantia Corporation */
 #define	MII_OUI_BROADCOM3	0x001be9	/* Broadcom Corporation */
 #define	MII_OUI_LEVEL1	0x00207b	/* Level 1 */
-#define	MII_OUI_VIA	0x004063	/* VIA Technologies */
 #define	MII_OUI_MARVELL	0x005043	/* Marvell Semiconductor */
 #define	MII_OUI_QUALSEMI	0x006051	/* Quality Semiconductor */
 #define	MII_OUI_AMLOGIC	0x006051	/* Amlogic */
@@ -89,7 +89,6 @@
 #define	MII_OUI_TSC	0x00c039	/* TDK Semiconductor */
 #define	MII_OUI_MYSON	0x00c0b4	/* Myson Technology */
 #define	MII_OUI_ATTANSIC	0x00c82e	/* Attansic Technology */
-#define	MII_OUI_RDC	0x00d02d	/* RDC Semiconductor */
 #define	MII_OUI_JMICRON	0x00d831	/* JMicron */
 #define	MII_OUI_PMCSIERRA	0x00e004	/* PMC-Sierra */
 #define	MII_OUI_SIS	0x00e006	/* Silicon Integrated Systems */
@@ -104,6 +103,7 @@
 /* Unregistered or wrong OUI */
 #define	MII_OUI_yyREALTEK	0x04	/* Realtek */
 #define	MII_OUI_yyAMD	0x58	/* Advanced Micro Devices */
+#define	MII_OUI_xxVIA	0x0002c6	/* VIA Technologies */
 #define	MII_OUI_xxMYSON	0x00032d	/* Myson Technology */
 #define	MII_OUI_xxTSC	0x00039c	/* TDK Semiconductor */
 #define	MII_OUI_xxASIX	0x000674	/* Asix Semiconductor */
@@ -122,6 +122,7 @@
 #define	MII_OUI_xxVITESSE	0x008083	/* Vitesse Semiconductor */
 #define	MII_OUI_xxPMCSIERRA2	0x009057	/* PMC-Sierra */
 #define	MII_OUI_xxCICADA	0x00c08f	/* Cicada Semiconductor */
+#define	MII_OUI_xxRDC	0x00d02d	/* RDC Semiconductor */
 #define	MII_OUI_xxNATSEMI	0x1000e8	/* National Semiconductor */
 #define	MII_OUI_xxLEVEL1	0x782000	/* Level 1 */
 #define	MII_OUI_xxXAQTI	0xace000	/* XaQti Corp. */
@@ -133,8 +134,10 @@
 /*
  * Agere PHYs
  */
-#define	MII_MODEL_AGERE_ET1011	0x0004
-#define	MII_STR_AGERE_ET1011	"Agere ET1011 10/100/1000baseT PHY"
+#define	MII_MODEL_AGERE_ET1011	0x0001
+#define	MII_STR_AGERE_ET1011	"ET1011 10/100/1000baseT PHY"
+#define	MII_MODEL_AGERE_ET1011C	0x0004
+#define	MII_STR_AGERE_ET1011C	"ET1011C 10/100/1000baseT PHY"
 
 /* Asix semiconductor PHYs */
 #define	MII_MODEL_xxASIX_AX88X9X	0x0031
@@ -166,13 +169,7 @@
 #define	MII_MODEL_xxAMLOGIC_GXL	0x
 #define	MII_STR_xxAMLOGIC_GXL	"Meson GXL internal PHY"
 
-/* Atheros PHYs */
-#define	MII_MODEL_ATHEROS_F1	0x0001
-#define	MII_STR_ATHEROS_F1	"F1 10/100/1000 PHY"
-#define	MII_MODEL_ATHEROS_F2	0x0002
-#define	MII_STR_ATHEROS_F2	"F2 10/100 PHY"
-
-/* Attansic PHYs */
+/* Attansic/Atheros PHYs */
 #define	MII_MODEL_ATTANSIC_L1	0x0001
 #define	MII_STR_ATTANSIC_L1	"L1 10/100/1000 PHY"
 #define	MII_MODEL_ATTANSIC_L2	0x0002
@@ -300,6 +297,8 @@
 #define	MII_STR_BROADCOM3_BCM53125	"BCM53125 1000BASE-T switch"
 #define	MII_MODEL_BROADCOM3_BCM5720C	0x0036
 #define	MII_STR_BROADCOM3_BCM5720C	"BCM5720C 1000BASE-T media interface"
+#define	MII_MODEL_BROADCOM4_BCM54213PE	0x000a
+#define	MII_STR_BROADCOM4_BCM54213PE	"BCM54213PE 1000BASE-T media interface"
 #defin

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

2020-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 14 17:57:17 UTC 2020

Modified Files:
src/sys/dev/mii [netbsd-8]: atphy.c brgphy.c etphy.c miidevs rdcphy.c

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1529:

sys/dev/mii/miidevs 1.154, 1.162-1.167
sys/dev/mii/atphy.c 1.28 via patch
sys/dev/mii/brgphy.c1.87 via patch
sys/dev/mii/etphy.c 1.5, 1.6 via patch
sys/dev/mii/rdcphy.c1.6, 1.8 via patch

- Add support Broadcom BCM54213PE and some new RDC devices.
- Rename RDC to xxRDC.
- Use xxVIA instead of VIA.
- etphy(4):
  - Rename ET1011 to ET1011C and add ET1011 support.
  - Use mii_phy_flowstatus() to reflect flow status from negotiated
result.
- Use static.
- KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.18.8.1 -r1.18.8.2 src/sys/dev/mii/atphy.c
cvs rdiff -u -r1.76.20.2 -r1.76.20.3 src/sys/dev/mii/brgphy.c
cvs rdiff -u -r1.1 -r1.1.54.1 src/sys/dev/mii/etphy.c \
src/sys/dev/mii/rdcphy.c
cvs rdiff -u -r1.125.6.8 -r1.125.6.9 src/sys/dev/mii/miidevs

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

Modified files:

Index: src/sys/dev/mii/atphy.c
diff -u src/sys/dev/mii/atphy.c:1.18.8.1 src/sys/dev/mii/atphy.c:1.18.8.2
--- src/sys/dev/mii/atphy.c:1.18.8.1	Thu Nov 21 14:06:16 2019
+++ src/sys/dev/mii/atphy.c	Tue Apr 14 17:57:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: atphy.c,v 1.18.8.1 2019/11/21 14:06:16 martin Exp $ */
+/*	$NetBSD: atphy.c,v 1.18.8.2 2020/04/14 17:57:17 martin Exp $ */
 /*	$OpenBSD: atphy.c,v 1.1 2008/09/25 20:47:16 brad Exp $	*/
 
 /*-
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.18.8.1 2019/11/21 14:06:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.18.8.2 2020/04/14 17:57:17 martin Exp $");
 
 #include 
 #include 
@@ -91,8 +91,6 @@ const struct mii_phy_funcs atphy_funcs =
 };
 
 static const struct mii_phydesc atphys[] = {
-	{ MII_OUI_ATHEROS,	MII_MODEL_ATHEROS_F1,
-	  MII_STR_ATHEROS_F1 },
 	{ MII_OUI_ATTANSIC,	MII_MODEL_ATTANSIC_L1,
 	  MII_STR_ATTANSIC_L1 },
 	{ MII_OUI_ATTANSIC,	MII_MODEL_ATTANSIC_L2,

Index: src/sys/dev/mii/brgphy.c
diff -u src/sys/dev/mii/brgphy.c:1.76.20.2 src/sys/dev/mii/brgphy.c:1.76.20.3
--- src/sys/dev/mii/brgphy.c:1.76.20.2	Mon May 13 12:40:13 2019
+++ src/sys/dev/mii/brgphy.c	Tue Apr 14 17:57:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: brgphy.c,v 1.76.20.2 2019/05/13 12:40:13 martin Exp $	*/
+/*	$NetBSD: brgphy.c,v 1.76.20.3 2020/04/14 17:57:17 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.76.20.2 2019/05/13 12:40:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.76.20.3 2020/04/14 17:57:17 martin Exp $");
 
 #include 
 #include 
@@ -246,6 +246,9 @@ static const struct mii_phydesc brgphys[
 	{ MII_OUI_BROADCOM3,		MII_MODEL_BROADCOM3_BCM57780,
 	  MII_STR_BROADCOM3_BCM57780 },
 
+	{ MII_OUI_BROADCOM4,		MII_MODEL_BROADCOM4_BCM54213PE,
+	  MII_STR_BROADCOM4_BCM54213PE },
+
 	{ MII_OUI_BROADCOM4,		MII_MODEL_BROADCOM4_BCM5725C,
 	  MII_STR_BROADCOM4_BCM5725C },
 

Index: src/sys/dev/mii/etphy.c
diff -u src/sys/dev/mii/etphy.c:1.1 src/sys/dev/mii/etphy.c:1.1.54.1
--- src/sys/dev/mii/etphy.c:1.1	Sat Nov 13 00:47:24 2010
+++ src/sys/dev/mii/etphy.c	Tue Apr 14 17:57:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: etphy.c,v 1.1 2010/11/13 00:47:24 jnemeth Exp $	*/
+/*	$NetBSD: etphy.c,v 1.1.54.1 2020/04/14 17:57:17 martin Exp $	*/
 /*	$OpenBSD: etphy.c,v 1.4 2008/04/02 20:12:58 brad Exp $	*/
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: etphy.c,v 1.1 2010/11/13 00:47:24 jnemeth Exp $");
+__KERNEL_RCSID(0, "$NetBSD: etphy.c,v 1.1.54.1 2020/04/14 17:57:17 martin Exp $");
 
 #include 
 #include 
@@ -77,19 +77,21 @@ __KERNEL_RCSID(0, "$NetBSD: etphy.c,v 1.
 #define ETPHY_SR_FDX		0x0080
 
 
-int	etphy_service(struct mii_softc *, struct mii_data *, int);
-void	etphy_attach(device_t, device_t, void *);
-int	etphy_match(device_t, cfdata_t, void *);
-void	etphy_reset(struct mii_softc *);
-void	etphy_status(struct mii_softc *);
+static int	etphy_service(struct mii_softc *, struct mii_data *, int);
+static void	etphy_attach(device_t, device_t, void *);
+static int	etphy_match(device_t, cfdata_t, void *);
+static void	etphy_reset(struct mii_softc *);
+static void	etphy_status(struct mii_softc *);
 
-const struct mii_phy_funcs etphy_funcs = {
+static const struct mii_phy_funcs etphy_funcs = {
 	etphy_service, etphy_status, etphy_reset,
 };
 
 static const struct mii_phydesc etphys[] = {
 	{ MII_OUI_AGERE,	MII_MODEL_AGERE_ET1011,
 	  MII_STR_AGERE_ET1011 },
+	{ MII_OUI_AGERE,	MII_MODEL_AGERE_ET1011C,
+	  MII_STR_AGERE_ET1011C },
 	{ 0,			0,
 	  NULL },
 };
@@ -135,7 +137,7 @@ static const stru

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

2020-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 14 17:39:28 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-8]: spdmem.c spdmemvar.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1528):

sys/dev/ic/spdmemvar.h: revision 1.15
sys/dev/ic/spdmemvar.h: revision 1.16
sys/dev/ic/spdmem.c: revision 1.31
sys/dev/ic/spdmem.c: revision 1.32
sys/dev/ic/spdmem.c: revision 1.33
sys/dev/ic/spdmem.c: revision 1.34
sys/dev/ic/spdmem.c: revision 1.35

Fix spelling of symeti^Hric

  Print DDR3's row and column correctly.

KNF. No functional change.

- Define some new parameters of DDR3 SPD ROM.
- Use fine timebase parameters for time calculation on DDR3. This change
   makes PC3- value more correctly on newer DDR3.

Calculate DDR3's tRAS correctly.

  Fix unused area size found by pgoyette@.


To generate a diff of this commit:
cvs rdiff -u -r1.24.6.2 -r1.24.6.3 src/sys/dev/ic/spdmem.c
cvs rdiff -u -r1.13.6.1 -r1.13.6.2 src/sys/dev/ic/spdmemvar.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/ic/spdmem.c
diff -u src/sys/dev/ic/spdmem.c:1.24.6.2 src/sys/dev/ic/spdmem.c:1.24.6.3
--- src/sys/dev/ic/spdmem.c:1.24.6.2	Thu Jan  3 11:23:54 2019
+++ src/sys/dev/ic/spdmem.c	Tue Apr 14 17:39:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: spdmem.c,v 1.24.6.2 2019/01/03 11:23:54 martin Exp $ */
+/* $NetBSD: spdmem.c,v 1.24.6.3 2020/04/14 17:39:28 martin Exp $ */
 
 /*
  * Copyright (c) 2007 Nicolas Joly
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.24.6.2 2019/01/03 11:23:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.24.6.3 2020/04/14 17:39:28 martin Exp $");
 
 #include 
 #include 
@@ -340,12 +340,12 @@ spdmem_common_attach(struct spdmem_softc
 	device_xname(self), NULL, NULL, 0, NULL, 0,
 	CTL_HW, CTL_CREATE, CTL_EOL);
 	if (node != NULL && spd_len != 0)
-sysctl_createv(&sc->sc_sysctl_log, 0, NULL, NULL,
-0,
-CTLTYPE_STRUCT, "spd_data",
+		sysctl_createv(&sc->sc_sysctl_log, 0, NULL, NULL,
+		0,
+		CTLTYPE_STRUCT, "spd_data",
 		SYSCTL_DESCR("raw spd data"), NULL,
-0, s, spd_len,
-CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
+		0, s, spd_len,
+		CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
 
 	/*
 	 * Decode and print key SPD contents
@@ -411,7 +411,7 @@ spdmem_common_attach(struct spdmem_softc
 			strlcat(sc->sc_type, " NVDIMM hybrid",
 			SPDMEM_TYPE_MAXLEN);
 	}
-	
+
 	if (node != NULL)
 		sysctl_createv(&sc->sc_sysctl_log, 0, NULL, NULL,
 		0,
@@ -615,7 +615,7 @@ decode_sdram(const struct sysctlnode *no
 		freq = 0;
 	switch (freq) {
 		/*
-		 * Must check cycle time since some PC-133 DIMMs 
+		 * Must check cycle time since some PC-133 DIMMs
 		 * actually report PC-100
 		 */
 	case 100:
@@ -756,6 +756,30 @@ print_part(const char *part, size_t pnsi
 	aprint_normal(": %.*s\n", (int)(p - part), part);
 }
 
+static u_int
+ddr3_value_pico(struct spdmem *s, uint8_t txx_mtb, uint8_t txx_ftb)
+{
+	u_int mtb, ftb; /* in picoseconds */
+	intmax_t signed_txx_ftb;
+	u_int val;
+
+	mtb = (u_int)s->sm_ddr3.ddr3_mtb_dividend * 1000 /
+	s->sm_ddr3.ddr3_mtb_divisor;
+	ftb = (u_int)s->sm_ddr3.ddr3_ftb_dividend * 1000 /
+	s->sm_ddr3.ddr3_ftb_divisor;
+
+	/* tXX_ftb is signed value */
+	signed_txx_ftb = (int8_t)txx_ftb;
+	val = txx_mtb * mtb +
+	((txx_ftb > 127) ? signed_txx_ftb : txx_ftb) * ftb / 1000;
+
+	return val;
+}
+
+#define __DDR3_VALUE_PICO(s, field)\
+	ddr3_value_pico(s, s->sm_ddr3.ddr3_##field##_mtb,	\
+	s->sm_ddr3.ddr3_##field##_ftb)
+
 static void
 decode_ddr3(const struct sysctlnode *node, device_t self, struct spdmem *s)
 {
@@ -786,10 +810,7 @@ decode_ddr3(const struct sysctlnode *nod
 		(s->sm_ddr3.ddr3_chipwidth + 2);
 	dimm_size = (1 << dimm_size) * (s->sm_ddr3.ddr3_physbanks + 1);
 
-	cycle_time = (1000 * s->sm_ddr3.ddr3_mtb_dividend + 
-			(s->sm_ddr3.ddr3_mtb_divisor / 2)) /
-		 s->sm_ddr3.ddr3_mtb_divisor;
-	cycle_time *= s->sm_ddr3.ddr3_tCKmin;
+	cycle_time = __DDR3_VALUE_PICO(s, tCKmin);
 	bits = 1 << (s->sm_ddr3.ddr3_datawidth + 3);
 	decode_size_speed(self, node, dimm_size, cycle_time, 2, bits, FALSE,
 			  "PC3", 0);
@@ -797,17 +818,21 @@ decode_ddr3(const struct sysctlnode *nod
 	aprint_verbose_dev(self,
 	"%d rows, %d cols, %d log. banks, %d phys. banks, "
 	"%d.%03dns cycle time\n",
-	s->sm_ddr3.ddr3_rows + 9, s->sm_ddr3.ddr3_cols + 12,
+	s->sm_ddr3.ddr3_rows + 12, s->sm_ddr3.ddr3_cols + 9,
 	1 << (s->sm_ddr3.ddr3_logbanks + 3),
 	s->sm_ddr3.ddr3_physbanks + 1,
 	cycle_time/1000, cycle_time % 1000);
 
-#define	__DDR3_CYCLES(field) (s->sm_ddr3.field / s->sm_ddr3.ddr3_tCKmin)
+#define	__DDR3_CYCLES(val)		\
+	((val / cycle_time) + ((val % cycle_time) ? 1 : 0))
 
-	

CVS commit: [netbsd-8] src/sys

2020-03-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 29 12:10:37 UTC 2020

Modified Files:
src/sys/dev/scsipi [netbsd-8]: cd.c
src/sys/kern [netbsd-8]: subr_disk.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1527):

sys/dev/scsipi/cd.c: revision 1.343
sys/kern/subr_disk.c: revision 1.130

Avoid division by zero if label isn't valid.
Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.
Fixes PR kern/55104


To generate a diff of this commit:
cvs rdiff -u -r1.340.6.1 -r1.340.6.2 src/sys/dev/scsipi/cd.c
cvs rdiff -u -r1.119.2.2 -r1.119.2.3 src/sys/kern/subr_disk.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/scsipi/cd.c
diff -u src/sys/dev/scsipi/cd.c:1.340.6.1 src/sys/dev/scsipi/cd.c:1.340.6.2
--- src/sys/dev/scsipi/cd.c:1.340.6.1	Wed Jun 21 18:18:55 2017
+++ src/sys/dev/scsipi/cd.c	Sun Mar 29 12:10:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.340.6.1 2017/06/21 18:18:55 snj Exp $	*/
+/*	$NetBSD: cd.c,v 1.340.6.2 2020/03/29 12:10:37 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.340.6.1 2017/06/21 18:18:55 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.340.6.2 2020/03/29 12:10:37 martin Exp $");
 
 #include 
 #include 
@@ -401,8 +401,8 @@ cd_firstopen(device_t self, dev_t dev, i
 else
 silent = 0;
 
-	/* make cdclose() loud again */
-	cd->flags &= ~CDF_EJECTED;
+	/* make cdclose() silent */
+	cd->flags |= CDF_EJECTED;
 
 	/* Check that it is still responding and ok. */
 	error = scsipi_test_unit_ready(periph,
@@ -419,8 +419,11 @@ cd_firstopen(device_t self, dev_t dev, i
 		if (error == EINVAL)
 			error = EIO;
 	}
-	if (error)
+	if (error) {
+		if (part == RAW_PART)
+			goto out;
 		goto bad;
+	}
 
 	/* Lock the pack in. */
 	error = scsipi_prevent(periph, SPAMR_PREVENT_DT,
@@ -448,6 +451,9 @@ cd_firstopen(device_t self, dev_t dev, i
 		SC_DEBUG(periph, SCSIPI_DB3, ("Params loaded "));
 
 		cd_set_geometry(cd);
+
+		/* make cdclose() loud again */
+		cd->flags &= ~CDF_EJECTED;
 	}
 
 	periph->periph_flags |= PERIPH_OPEN;
@@ -519,7 +525,8 @@ cd_lastclose(device_t self)
 	struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
 	int silent;
 
-	if (cd->flags & CDF_EJECTED)
+	if ((cd->flags & CDF_EJECTED) != 0 ||
+	(periph->periph_flags & PERIPH_MEDIA_LOADED) == 0)
 		silent = XS_CTL_SILENT;
 	else
 		silent = 0;
@@ -1213,6 +1220,14 @@ cdioctl(dev_t dev, u_long cmd, void *add
 		return (EIO);
 
 	switch (cmd) {
+	case DIOCTUR: {
+		/* test unit ready */
+		error = scsipi_test_unit_ready(cd->sc_periph, XS_CTL_SILENT);
+		*((int*)addr) = (error == 0);
+		if (error == ENODEV || error == EIO || error == 0)
+			return 0;   
+		return error;
+	}
 	case CDIOCPLAYTRACKS: {
 		/* PLAY_MSF command */
 		struct ioc_play_track *args = addr;
@@ -1447,15 +1462,18 @@ static void
 cd_label(device_t self, struct disklabel *lp)
 {
 	struct cd_softc *cd = device_private(self);
+	struct scsipi_periph *periph = cd->sc_periph;
 	struct cd_formatted_toc toc;
-	int lastsession;
+	int lastsession = 0;
 
 	strncpy(lp->d_typename, "optical media", 16);
 	lp->d_rpm = 300;
-	lp->d_flags |= D_REMOVABLE | D_SCSI_MMC;
+	lp->d_flags |= D_REMOVABLE;
 
-	if (cdreadmsaddr(cd, &toc, &lastsession) != 0)
-		lastsession = 0;
+	if ((periph->periph_flags & PERIPH_MEDIA_LOADED) != 0) {
+		lp->d_flags |= D_SCSI_MMC;
+		(void) cdreadmsaddr(cd, &toc, &lastsession);
+	}
 
 	lp->d_partitions[0].p_offset = 0;
 	lp->d_partitions[0].p_size = lp->d_secperunit;

Index: src/sys/kern/subr_disk.c
diff -u src/sys/kern/subr_disk.c:1.119.2.2 src/sys/kern/subr_disk.c:1.119.2.3
--- src/sys/kern/subr_disk.c:1.119.2.2	Fri Nov  1 09:29:25 2019
+++ src/sys/kern/subr_disk.c	Sun Mar 29 12:10:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_disk.c,v 1.119.2.2 2019/11/01 09:29:25 martin Exp $	*/
+/*	$NetBSD: subr_disk.c,v 1.119.2.3 2020/03/29 12:10:37 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.119.2.2 2019/11/01 09:29:25 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.119.2.3 2020/03/29 12:10:37 martin Exp $");
 
 #include 
 #include 
@@ -429,6 +429,10 @@ int
 disk_read_sectors(void (*strat)(struct buf *), const struct disklabel *lp,
 struct buf *bp, unsigned int sector, int count)
 {
+
+	if ((lp->d_secsize / DEV_BSIZE) == 0 || lp->d_secpercyl == 0)
+		return EINVAL;
+
 	bp->b_blkno = btodb((off_t)sector * lp->d_secsize);
 	bp->b_bcount = count * lp->d_secsize;
 	bp->b_flags = (bp->b_flags & ~B_WRITE) | B_READ;



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

2020-03-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 29 11:38:13 UTC 2020

Modified Files:
src/sys/arch/i386/stand/misc [netbsd-8]: Makefile
Removed Files:
src/sys/arch/i386/stand/misc [netbsd-8]: rawr32.exe.uue

Log Message:
Remove outdated Rawrite32 copy


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.52.1 src/sys/arch/i386/stand/misc/Makefile
cvs rdiff -u -r1.7 -r0 src/sys/arch/i386/stand/misc/rawr32.exe.uue

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

Modified files:

Index: src/sys/arch/i386/stand/misc/Makefile
diff -u src/sys/arch/i386/stand/misc/Makefile:1.7 src/sys/arch/i386/stand/misc/Makefile:1.7.52.1
--- src/sys/arch/i386/stand/misc/Makefile:1.7	Wed Oct 27 18:29:46 2010
+++ src/sys/arch/i386/stand/misc/Makefile	Sun Mar 29 11:38:12 2020
@@ -1,8 +1,7 @@
-#	$NetBSD: Makefile,v 1.7 2010/10/27 18:29:46 martin Exp $
+#	$NetBSD: Makefile,v 1.7.52.1 2020/03/29 11:38:12 martin Exp $
 
 MISC_FILES=	rawrite.c
 UUDECODE_FILES=	pfdisk.doc pfdisk.exe pfdisktc.zip \
-		rawr32.exe \
 		rawrite.doc rawrite.exe
 
 .include 



  1   2   3   4   5   6   7   8   9   10   >