CVS commit: src/sys/dev/pci

2017-02-14 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Feb 15 06:53:55 UTC 2017

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

Log Message:
- Print Data Select and Data Scale in pci_conf_print_pcipm_cap().
- The Message Data register of MSI cap is not 32bit but 16bit.
- When the PCIE_LCAP_MAX_SPEED bitfiled is 0, it means it supports 2.5GT/s only.
- Print link de-emphasis value by "-X dB".
- Print Completion Timeout Ranges Supported filed with alphabets.
- Print TPH Completer Supported fileld's meaning.
- Print PCIE_DCAP2_MAX_EETLP correctly. 0 means 4 End-End TLP Prefixes.
- If the Supported Link Speed Vector is 0, the Link Capability 2 register is not
  implemented. Don't decode LCAP2 when the vector is 0.
- The ACS's Egress Control Vector is 32bit, so print with 0x%08x.
- Print SR-IOV's device ID.
- Use __SHIFTOUT() to avoid using magic number.
- Prefix "0x" for hexadecimal value.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/pci/pcireg.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/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.156 src/sys/dev/pci/pci_subr.c:1.157
--- src/sys/dev/pci/pci_subr.c:1.156	Wed Dec 28 06:57:27 2016
+++ src/sys/dev/pci/pci_subr.c	Wed Feb 15 06:53:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.156 2016/12/28 06:57:27 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.157 2017/02/15 06:53:55 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.156 2016/12/28 06:57:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.157 2017/02/15 06:53:55 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -1082,12 +1082,16 @@ pci_conf_print_pcipm_cap(const pcireg_t 
 	onoff("No soft reset", pmcsr, PCI_PMCSR_NO_SOFTRST);
 	printf("  PME# assertion: %sabled\n",
 	(pmcsr & PCI_PMCSR_PME_EN) ? "en" : "dis");
+	printf("  Data Select: %d\n",
+	__SHIFTOUT(pmcsr, PCI_PMCSR_DATASEL_MASK));
+	printf("  Data Scale: %d\n",
+	__SHIFTOUT(pmcsr, PCI_PMCSR_DATASCL_MASK));
 	onoff("PME# status", pmcsr, PCI_PMCSR_PME_STS);
 	printf("Bridge Support Extensions register: 0x%02x\n",
 	(reg >> 16) & 0xff);
 	onoff("B2/B3 support", reg, PCI_PMCSR_B2B3_SUPPORT);
 	onoff("Bus Power/Clock Control Enable", reg, PCI_PMCSR_BPCC_EN);
-	printf("Data register: 0x%02x\n", (reg >> 24) & 0xff);
+	printf("Data register: 0x%02x\n", __SHIFTOUT(reg, PCI_PMCSR_DATA));
 	
 }
 
@@ -1122,7 +1126,8 @@ pci_conf_print_msi_cap(const pcireg_t *r
 		printf("Message Address %sregister: 0x%08x\n",
 		"(upper) ", *regs++);
 	}
-	printf("Message Data register: 0x%08x\n", *regs++);
+	printf("Message Data register: 0x%04x\n", *regs & 0x);
+	regs++;
 	if (ctl & PCI_MSI_CTL_PERVEC_MASK) {
 		printf("Vector Mask register: 0x%08x\n", *regs++);
 		printf("Vector Pending register: 0x%08x\n", *regs++);
@@ -1478,17 +1483,16 @@ pci_print_pcie_compl_timeout(uint32_t va
 	}
 }
 
-static const char * const pcie_linkspeeds[] = {"2.5", "5.0", "8.0"};
+static const char * const pcie_linkspeeds[] = {"2.5", "2.5", "5.0", "8.0"};
 
 static void
 pci_print_pcie_linkspeed(pcireg_t val)
 {
 
-	/* Start from 1 */
-	if (val < 1 || val > __arraycount(pcie_linkspeeds))
+	if (val > __arraycount(pcie_linkspeeds))
 		printf("unknown value (%u)\n", val);
 	else
-		printf("%sGT/s\n", pcie_linkspeeds[val - 1]);
+		printf("%sGT/s\n", pcie_linkspeeds[val]);
 }
 
 static void
@@ -1500,13 +1504,28 @@ pci_print_pcie_linkspeedvector(pcireg_t 
 	for (i = 0; i < 16; i++)
 		if (((val >> i) & 0x01) != 0) {
 			if (i >= __arraycount(pcie_linkspeeds))
-printf(" unknown vector (%x)", 1 << i);
+printf(" unknown vector (0x%x)", 1 << i);
 			else
 printf(" %sGT/s", pcie_linkspeeds[i]);
 		}
 }
 
 static void
+pci_print_pcie_link_deemphasis(pcireg_t val)
+{
+	switch (val) {
+	case 0:
+		printf("-6dB");
+		break;
+	case 1:
+		printf("-3.5dB");
+		break;
+	default:
+		printf("(reserved value)");
+	}
+}
+
+static void
 pci_conf_print_pcie_cap(const pcireg_t *regs, int capoff)
 {
 	pcireg_t reg; /* for each register */
@@ -1515,11 +1534,12 @@ pci_conf_print_pcie_cap(const pcireg_t *
 	bool check_slot = false;
 	bool check_rootport = false;
 	unsigned int pciever;
+	unsigned int i;
 
 	printf("\n  PCI Express Capabilities Register\n");
 	/* Capability Register */
 	reg = regs[o2i(capoff)];
-	printf("Capability register: %04x\n", reg >> 16);
+	printf("Capability register: 0x%04x\n", reg >> 16);
 	pciever = (unsigned int)((reg & 0x000f) >> 16);
 	printf("  Capability version: %u\n", pciever);
 	printf("  Device type: ");
@@ -1564,7 +1584,7 @@ pci_conf_print_pcie_cap(const pcireg_t *
 		break;
 	}
 	onoff("Slot implemented", reg, PCIE_XCAP_SI);
-	

CVS commit: src/sys/dev

2017-02-14 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Wed Feb 15 02:55:53 UTC 2017

Modified Files:
src/sys/dev: audiobell.c

Log Message:
Remove stray closef.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/audiobell.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/audiobell.c
diff -u src/sys/dev/audiobell.c:1.14 src/sys/dev/audiobell.c:1.15
--- src/sys/dev/audiobell.c:1.14	Fri Feb 10 21:03:15 2017
+++ src/sys/dev/audiobell.c	Wed Feb 15 02:55:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiobell.c,v 1.14 2017/02/10 21:03:15 nat Exp $	*/
+/*	$NetBSD: audiobell.c,v 1.15 2017/02/15 02:55:53 nat Exp $	*/
 
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audiobell.c,v 1.14 2017/02/10 21:03:15 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audiobell.c,v 1.15 2017/02/15 02:55:53 nat Exp $");
 
 #include 
 #include 
@@ -197,5 +197,4 @@ audiobell(void *v, u_int pitch, u_int pe
 out:
 	if (buf != NULL) free(buf, M_TEMP);
 	audioclose(fp);
-	closef(fp);
 }



CVS commit: src/usr.sbin/inetd

2017-02-14 Thread Roland Dowdeswell
Module Name:src
Committed By:   elric
Date:   Wed Feb 15 02:48:31 UTC 2017

Modified Files:
src/usr.sbin/inetd: inetd.c

Log Message:
Increase buffer size reported to strlcpy() to be one larger than the
length of the string we copy in so that there is space for the '\0'.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/usr.sbin/inetd/inetd.c

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

Modified files:

Index: src/usr.sbin/inetd/inetd.c
diff -u src/usr.sbin/inetd/inetd.c:1.122 src/usr.sbin/inetd/inetd.c:1.123
--- src/usr.sbin/inetd/inetd.c:1.122	Sat Apr  5 23:36:10 2014
+++ src/usr.sbin/inetd/inetd.c	Wed Feb 15 02:48:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: inetd.c,v 1.122 2014/04/05 23:36:10 khorben Exp $	*/
+/*	$NetBSD: inetd.c,v 1.123 2017/02/15 02:48:31 elric Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)inetd.c	8.4 (Berkeley) 4/13/94";
 #else
-__RCSID("$NetBSD: inetd.c,v 1.122 2014/04/05 23:36:10 khorben Exp $");
+__RCSID("$NetBSD: inetd.c,v 1.123 2017/02/15 02:48:31 elric Exp $");
 #endif
 #endif /* not lint */
 
@@ -850,7 +850,7 @@ config(void)
 			}
 			(void)unlink(sep->se_service);
 			strlcpy(sep->se_ctrladdr_un.sun_path,
-			sep->se_service, n);
+			sep->se_service, n + 1);
 			sep->se_ctrladdr_un.sun_family = AF_LOCAL;
 			sep->se_ctrladdr_size = (int)(n +
 			sizeof(sep->se_ctrladdr_un) -



CVS commit: src/sys/net

2017-02-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 15 01:48:44 UTC 2017

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

Log Message:
Avoid if_dl and if_sadl to be NULL

Calling if_deactivate_sadl and then if_sadl_setrefs exposes NULL-ed if_dl
and if_sadl to users for a moment. It's harmful because users expect that
they're always non-NULL. Fix it.

Note that a race condition still remains; if_dl and if_sald aren't updated
atomically so a user can see different data from if_dl and if_sadl.
Fortunately none uses both if_dl and if_sadl at the same time, so the race
condition doesn't hurt nobody for now. (In the first place exposing one
data with two ways is problematic?)


To generate a diff of this commit:
cvs rdiff -u -r1.377 -r1.378 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/net/if.c
diff -u src/sys/net/if.c:1.377 src/sys/net/if.c:1.378
--- src/sys/net/if.c:1.377	Fri Feb 10 20:56:21 2017
+++ src/sys/net/if.c	Wed Feb 15 01:48:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.377 2017/02/10 20:56:21 christos Exp $	*/
+/*	$NetBSD: if.c,v 1.378 2017/02/15 01:48:44 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.377 2017/02/10 20:56:21 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.378 2017/02/15 01:48:44 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -518,6 +518,23 @@ if_deactivate_sadl(struct ifnet *ifp)
 	ifafree(ifa);
 }
 
+static void
+if_replace_sadl(struct ifnet *ifp, struct ifaddr *ifa)
+{
+	struct ifaddr *old;
+
+	KASSERT(ifp->if_dl != NULL);
+
+	old = ifp->if_dl;
+
+	ifaref(ifa);
+	/* XXX Update if_dl and if_sadl atomically */
+	ifp->if_dl = ifa;
+	ifp->if_sadl = satosdl(ifa->ifa_addr);
+
+	ifafree(old);
+}
+
 void
 if_activate_sadl(struct ifnet *ifp, struct ifaddr *ifa0,
 const struct sockaddr_dl *sdl)
@@ -526,11 +543,11 @@ if_activate_sadl(struct ifnet *ifp, stru
 	struct ifaddr *ifa;
 	int bound = curlwp_bind();
 
-	s = splsoftnet();
+	KASSERT(ifa_held(ifa0));
 
-	if_deactivate_sadl(ifp);
+	s = splsoftnet();
 
-	if_sadl_setrefs(ifp, ifa0);
+	if_replace_sadl(ifp, ifa0);
 
 	ss = pserialize_read_enter();
 	IFADDR_READER_FOREACH(ifa, ifp) {



CVS commit: src/doc

2017-02-14 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Feb 14 18:38:07 UTC 2017

Modified Files:
src/doc: TODO.ptrace

Log Message:
Add new entry to TODO.ptrace

research ipkdb(4)

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/doc/TODO.ptrace

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

Modified files:

Index: src/doc/TODO.ptrace
diff -u src/doc/TODO.ptrace:1.20 src/doc/TODO.ptrace:1.21
--- src/doc/TODO.ptrace:1.20	Mon Feb 13 15:29:18 2017
+++ src/doc/TODO.ptrace	Tue Feb 14 18:38:07 2017
@@ -1,4 +1,4 @@
-$NetBSD: TODO.ptrace,v 1.20 2017/02/13 15:29:18 kamil Exp $
+$NetBSD: TODO.ptrace,v 1.21 2017/02/14 18:38:07 kamil Exp $
 
 Items we (currently) plan to finish in the ptrace(2) field:
 
@@ -29,6 +29,7 @@ Items we (currently) plan to finish in t
  - add ATF tests for PT_SYSCALL and PT_SYSCALLEMU
  - research support PT_SYSCALL & PT_STEP combined like in Linux
  - fix more calls for netbsd32 compat
+ - research ipkdb(4)
 
 and of course: fix as many bugs as possible.
 



CVS commit: [netbsd-6] src/doc

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 17:01:55 UTC 2017

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

Log Message:
1433


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

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

Modified files:

Index: src/doc/CHANGES-6.2
diff -u src/doc/CHANGES-6.2:1.1.2.270 src/doc/CHANGES-6.2:1.1.2.271
--- src/doc/CHANGES-6.2:1.1.2.270	Sun Feb  5 07:10:10 2017
+++ src/doc/CHANGES-6.2	Tue Feb 14 17:01:55 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.2,v 1.1.2.270 2017/02/05 07:10:10 snj Exp $
+# $NetBSD: CHANGES-6.2,v 1.1.2.271 2017/02/14 17:01:55 snj Exp $
 
 A complete list of changes from the 6.1 release until the 6.2 release:
 
@@ -15456,3 +15456,8 @@ sys/netinet/if_arp.c1.238, 1.239 via
 	Add checks on the ARP header
 	[maxv, ticket #1432]
 
+sys/compat/linux/arch/amd64/linux_machdep.c	1.50, 1.51
+
+	Don't let userland choose %rip.
+	[maxv, ticket #1433]
+



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

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 16:58:20 UTC 2017

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

Log Message:
1433


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

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

Modified files:

Index: src/doc/CHANGES-6.0.7
diff -u src/doc/CHANGES-6.0.7:1.1.2.81 src/doc/CHANGES-6.0.7:1.1.2.82
--- src/doc/CHANGES-6.0.7:1.1.2.81	Sun Feb  5 06:11:37 2017
+++ src/doc/CHANGES-6.0.7	Tue Feb 14 16:58:20 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.0.7,v 1.1.2.81 2017/02/05 06:11:37 snj Exp $
+# $NetBSD: CHANGES-6.0.7,v 1.1.2.82 2017/02/14 16:58:20 snj Exp $
 
 A complete list of changes from the NetBSD 6.0.6 release to the NetBSD 6.0.7
 release:
@@ -9377,3 +9377,8 @@ sys/netinet/if_arp.c1.238, 1.239 via
 	Add checks on the ARP header
 	[maxv, ticket #1432]
 
+sys/compat/linux/arch/amd64/linux_machdep.c	1.50, 1.51
+
+	Don't let userland choose %rip.
+	[maxv, ticket #1433]
+



CVS commit: [netbsd-6-1] src/sys/compat/linux/arch/amd64

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 16:58:44 UTC 2017

Modified Files:
src/sys/compat/linux/arch/amd64 [netbsd-6-1]: linux_machdep.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1433):
sys/compat/linux/arch/amd64/linux_machdep.c: 1.50, 1.51
Don't let userland choose %rip. This is the Intel Sysret vulnerability
again.
--
Make sure %rip is in userland. This is harmless, since the return to
userland is made with iret instead of sysret in this path. While here, use
size_t.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.39.12.1 \
src/sys/compat/linux/arch/amd64/linux_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/compat/linux/arch/amd64/linux_machdep.c
diff -u src/sys/compat/linux/arch/amd64/linux_machdep.c:1.39 src/sys/compat/linux/arch/amd64/linux_machdep.c:1.39.12.1
--- src/sys/compat/linux/arch/amd64/linux_machdep.c:1.39	Fri Nov 18 04:07:43 2011
+++ src/sys/compat/linux/arch/amd64/linux_machdep.c	Tue Feb 14 16:58:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_machdep.c,v 1.39 2011/11/18 04:07:43 christos Exp $ */
+/*	$NetBSD: linux_machdep.c,v 1.39.12.1 2017/02/14 16:58:44 snj Exp $ */
 
 /*-
  * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.39 2011/11/18 04:07:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.39.12.1 2017/02/14 16:58:44 snj Exp $");
 
 #include 
 #include 
@@ -254,7 +254,12 @@ linux_sendsig(const ksiginfo_t *ksi, con
 	if (error != 0) {
 		sigexit(l, SIGILL);
 		return;
-	}	
+	}
+
+	if ((vaddr_t)catcher >= VM_MAXUSER_ADDRESS) {
+		sigexit(l, SIGILL);
+		return;
+	}
 
 	linux_buildcontext(l, catcher, sp);
 	tf->tf_rdi = sigframe.info.lsi_signo;
@@ -485,7 +490,7 @@ linux_usertrap(struct lwp *l, vaddr_t tr
 {
 	struct trapframe *tf = arg;
 	uint64_t retaddr;
-	int vsyscallnr;
+	size_t vsyscallnr;
 
 	/*
 	 * Check for a vsyscall. %rip must be the fault address,
@@ -515,6 +520,8 @@ linux_usertrap(struct lwp *l, vaddr_t tr
 	 */
 	if (copyin((void *)tf->tf_rsp, , sizeof retaddr) != 0)
 		return 0;
+	if ((vaddr_t)retaddr >= VM_MAXUSER_ADDRESS)
+		return 0;
 	tf->tf_rip = retaddr;
 	tf->tf_rax = linux_vsyscall_to_syscall[vsyscallnr];
 	tf->tf_rsp += 8;	/* "pop" the return address */



CVS commit: [netbsd-6-0] src/sys/compat/linux/arch/amd64

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 16:57:57 UTC 2017

Modified Files:
src/sys/compat/linux/arch/amd64 [netbsd-6-0]: linux_machdep.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1433):
sys/compat/linux/arch/amd64/linux_machdep.c: 1.50, 1.51
Don't let userland choose %rip. This is the Intel Sysret vulnerability
again.
--
Make sure %rip is in userland. This is harmless, since the return to
userland is made with iret instead of sysret in this path. While here, use
size_t.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.39.10.1 \
src/sys/compat/linux/arch/amd64/linux_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/compat/linux/arch/amd64/linux_machdep.c
diff -u src/sys/compat/linux/arch/amd64/linux_machdep.c:1.39 src/sys/compat/linux/arch/amd64/linux_machdep.c:1.39.10.1
--- src/sys/compat/linux/arch/amd64/linux_machdep.c:1.39	Fri Nov 18 04:07:43 2011
+++ src/sys/compat/linux/arch/amd64/linux_machdep.c	Tue Feb 14 16:57:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_machdep.c,v 1.39 2011/11/18 04:07:43 christos Exp $ */
+/*	$NetBSD: linux_machdep.c,v 1.39.10.1 2017/02/14 16:57:57 snj Exp $ */
 
 /*-
  * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.39 2011/11/18 04:07:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.39.10.1 2017/02/14 16:57:57 snj Exp $");
 
 #include 
 #include 
@@ -254,7 +254,12 @@ linux_sendsig(const ksiginfo_t *ksi, con
 	if (error != 0) {
 		sigexit(l, SIGILL);
 		return;
-	}	
+	}
+
+	if ((vaddr_t)catcher >= VM_MAXUSER_ADDRESS) {
+		sigexit(l, SIGILL);
+		return;
+	}
 
 	linux_buildcontext(l, catcher, sp);
 	tf->tf_rdi = sigframe.info.lsi_signo;
@@ -485,7 +490,7 @@ linux_usertrap(struct lwp *l, vaddr_t tr
 {
 	struct trapframe *tf = arg;
 	uint64_t retaddr;
-	int vsyscallnr;
+	size_t vsyscallnr;
 
 	/*
 	 * Check for a vsyscall. %rip must be the fault address,
@@ -515,6 +520,8 @@ linux_usertrap(struct lwp *l, vaddr_t tr
 	 */
 	if (copyin((void *)tf->tf_rsp, , sizeof retaddr) != 0)
 		return 0;
+	if ((vaddr_t)retaddr >= VM_MAXUSER_ADDRESS)
+		return 0;
 	tf->tf_rip = retaddr;
 	tf->tf_rax = linux_vsyscall_to_syscall[vsyscallnr];
 	tf->tf_rsp += 8;	/* "pop" the return address */



CVS commit: [netbsd-7] src/doc

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 16:54:50 UTC 2017

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

Log Message:
1358, 1359


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.150 -r1.1.2.151 src/doc/CHANGES-7.1

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

Modified files:

Index: src/doc/CHANGES-7.1
diff -u src/doc/CHANGES-7.1:1.1.2.150 src/doc/CHANGES-7.1:1.1.2.151
--- src/doc/CHANGES-7.1:1.1.2.150	Sun Feb 12 22:09:51 2017
+++ src/doc/CHANGES-7.1	Tue Feb 14 16:54:50 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1,v 1.1.2.150 2017/02/12 22:09:51 snj Exp $
+# $NetBSD: CHANGES-7.1,v 1.1.2.151 2017/02/14 16:54:50 snj Exp $
 
 A complete list of changes from the NetBSD 7.0 release to the NetBSD 7.1
 release:
@@ -7978,3 +7978,14 @@ libexec/httpd/testsuite/test-simple		1.3
 	-  no longer sends encoding header for compressed form
 	[mrg, ticket #1357]
 
+sys/miscfs/procfs/procfs_map.c			1.45
+
+	Maps don't change that frequently between reads, so don't give
+	up and do what linux does (support reading from an offset).
+	[chs, ticket #1358]
+
+sys/compat/linux/arch/amd64/linux_machdep.c	1.50, 1.51
+
+	Don't let userland choose %rip.
+	[maxv, ticket #1359]
+



CVS commit: [netbsd-6] src/sys/compat/linux/arch/amd64

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 16:59:31 UTC 2017

Modified Files:
src/sys/compat/linux/arch/amd64 [netbsd-6]: linux_machdep.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1433):
sys/compat/linux/arch/amd64/linux_machdep.c: 1.50, 1.51
Don't let userland choose %rip. This is the Intel Sysret vulnerability
again.
--
Make sure %rip is in userland. This is harmless, since the return to
userland is made with iret instead of sysret in this path. While here, use
size_t.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.39.6.1 \
src/sys/compat/linux/arch/amd64/linux_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/compat/linux/arch/amd64/linux_machdep.c
diff -u src/sys/compat/linux/arch/amd64/linux_machdep.c:1.39 src/sys/compat/linux/arch/amd64/linux_machdep.c:1.39.6.1
--- src/sys/compat/linux/arch/amd64/linux_machdep.c:1.39	Fri Nov 18 04:07:43 2011
+++ src/sys/compat/linux/arch/amd64/linux_machdep.c	Tue Feb 14 16:59:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_machdep.c,v 1.39 2011/11/18 04:07:43 christos Exp $ */
+/*	$NetBSD: linux_machdep.c,v 1.39.6.1 2017/02/14 16:59:31 snj Exp $ */
 
 /*-
  * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.39 2011/11/18 04:07:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.39.6.1 2017/02/14 16:59:31 snj Exp $");
 
 #include 
 #include 
@@ -254,7 +254,12 @@ linux_sendsig(const ksiginfo_t *ksi, con
 	if (error != 0) {
 		sigexit(l, SIGILL);
 		return;
-	}	
+	}
+
+	if ((vaddr_t)catcher >= VM_MAXUSER_ADDRESS) {
+		sigexit(l, SIGILL);
+		return;
+	}
 
 	linux_buildcontext(l, catcher, sp);
 	tf->tf_rdi = sigframe.info.lsi_signo;
@@ -485,7 +490,7 @@ linux_usertrap(struct lwp *l, vaddr_t tr
 {
 	struct trapframe *tf = arg;
 	uint64_t retaddr;
-	int vsyscallnr;
+	size_t vsyscallnr;
 
 	/*
 	 * Check for a vsyscall. %rip must be the fault address,
@@ -515,6 +520,8 @@ linux_usertrap(struct lwp *l, vaddr_t tr
 	 */
 	if (copyin((void *)tf->tf_rsp, , sizeof retaddr) != 0)
 		return 0;
+	if ((vaddr_t)retaddr >= VM_MAXUSER_ADDRESS)
+		return 0;
 	tf->tf_rip = retaddr;
 	tf->tf_rax = linux_vsyscall_to_syscall[vsyscallnr];
 	tf->tf_rsp += 8;	/* "pop" the return address */



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

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 16:59:08 UTC 2017

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

Log Message:
1433


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

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

Modified files:

Index: src/doc/CHANGES-6.1.6
diff -u src/doc/CHANGES-6.1.6:1.1.2.79 src/doc/CHANGES-6.1.6:1.1.2.80
--- src/doc/CHANGES-6.1.6:1.1.2.79	Sun Feb  5 06:15:28 2017
+++ src/doc/CHANGES-6.1.6	Tue Feb 14 16:59:08 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.1.6,v 1.1.2.79 2017/02/05 06:15:28 snj Exp $
+# $NetBSD: CHANGES-6.1.6,v 1.1.2.80 2017/02/14 16:59:08 snj Exp $
 
 A complete list of changes from the NetBSD 6.1.5 release to the NetBSD 6.1.6
 release:
@@ -9097,3 +9097,8 @@ sys/netinet/if_arp.c1.238, 1.239 via
 	Add checks on the ARP header
 	[maxv, ticket #1432]
 
+sys/compat/linux/arch/amd64/linux_machdep.c	1.50, 1.51
+
+	Don't let userland choose %rip.
+	[maxv, ticket #1433]
+



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

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 16:56:05 UTC 2017

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

Log Message:
1359


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

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

Modified files:

Index: src/doc/CHANGES-7.0.3
diff -u src/doc/CHANGES-7.0.3:1.1.2.25 src/doc/CHANGES-7.0.3:1.1.2.26
--- src/doc/CHANGES-7.0.3:1.1.2.25	Sun Feb 12 22:03:49 2017
+++ src/doc/CHANGES-7.0.3	Tue Feb 14 16:56:05 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.25 2017/02/12 22:03:49 snj Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.26 2017/02/14 16:56:05 snj Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -370,3 +370,8 @@ libexec/httpd/testsuite/test-simple		1.3
 	- no longer sends encoding header for compressed formats
 	[mrg, ticket #1357]
 
+sys/compat/linux/arch/amd64/linux_machdep.c	1.50, 1.51
+
+	Don't let userland choose %rip.
+	[maxv, ticket #1359]
+



CVS commit: [netbsd-7-0] src/sys/compat/linux/arch/amd64

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 16:55:27 UTC 2017

Modified Files:
src/sys/compat/linux/arch/amd64 [netbsd-7-0]: linux_machdep.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1359):
sys/compat/linux/arch/amd64/linux_machdep.c: 1.50, 1.51
Don't let userland choose %rip. This is the Intel Sysret vulnerability
again.
--
Make sure %rip is in userland. This is harmless, since the return to
userland is made with iret instead of sysret in this path. While here, use
size_t.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.48.8.1 \
src/sys/compat/linux/arch/amd64/linux_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/compat/linux/arch/amd64/linux_machdep.c
diff -u src/sys/compat/linux/arch/amd64/linux_machdep.c:1.48 src/sys/compat/linux/arch/amd64/linux_machdep.c:1.48.8.1
--- src/sys/compat/linux/arch/amd64/linux_machdep.c:1.48	Wed Feb 19 20:50:56 2014
+++ src/sys/compat/linux/arch/amd64/linux_machdep.c	Tue Feb 14 16:55:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_machdep.c,v 1.48 2014/02/19 20:50:56 dsl Exp $ */
+/*	$NetBSD: linux_machdep.c,v 1.48.8.1 2017/02/14 16:55:27 snj Exp $ */
 
 /*-
  * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.48 2014/02/19 20:50:56 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.48.8.1 2017/02/14 16:55:27 snj Exp $");
 
 #include 
 #include 
@@ -230,7 +230,12 @@ linux_sendsig(const ksiginfo_t *ksi, con
 	if (error != 0) {
 		sigexit(l, SIGILL);
 		return;
-	}	
+	}
+
+	if ((vaddr_t)catcher >= VM_MAXUSER_ADDRESS) {
+		sigexit(l, SIGILL);
+		return;
+	}
 
 	linux_buildcontext(l, catcher, sp);
 	tf->tf_rdi = sigframe.info.lsi_signo;
@@ -448,7 +453,7 @@ linux_usertrap(struct lwp *l, vaddr_t tr
 {
 	struct trapframe *tf = arg;
 	uint64_t retaddr;
-	int vsyscallnr;
+	size_t vsyscallnr;
 
 	/*
 	 * Check for a vsyscall. %rip must be the fault address,
@@ -478,6 +483,8 @@ linux_usertrap(struct lwp *l, vaddr_t tr
 	 */
 	if (copyin((void *)tf->tf_rsp, , sizeof retaddr) != 0)
 		return 0;
+	if ((vaddr_t)retaddr >= VM_MAXUSER_ADDRESS)
+		return 0;
 	tf->tf_rip = retaddr;
 	tf->tf_rax = linux_vsyscall_to_syscall[vsyscallnr];
 	tf->tf_rsp += 8;	/* "pop" the return address */



CVS commit: [netbsd-7] src/sys/compat/linux/arch/amd64

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 16:54:25 UTC 2017

Modified Files:
src/sys/compat/linux/arch/amd64 [netbsd-7]: linux_machdep.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1359):
sys/compat/linux/arch/amd64/linux_machdep.c: revisions 1.50, 1.51
Don't let userland choose %rip. This is the Intel Sysret vulnerability
again.
--
Make sure %rip is in userland. This is harmless, since the return to
userland is made with iret instead of sysret in this path. While here, use
size_t.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.48.4.1 \
src/sys/compat/linux/arch/amd64/linux_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/compat/linux/arch/amd64/linux_machdep.c
diff -u src/sys/compat/linux/arch/amd64/linux_machdep.c:1.48 src/sys/compat/linux/arch/amd64/linux_machdep.c:1.48.4.1
--- src/sys/compat/linux/arch/amd64/linux_machdep.c:1.48	Wed Feb 19 20:50:56 2014
+++ src/sys/compat/linux/arch/amd64/linux_machdep.c	Tue Feb 14 16:54:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_machdep.c,v 1.48 2014/02/19 20:50:56 dsl Exp $ */
+/*	$NetBSD: linux_machdep.c,v 1.48.4.1 2017/02/14 16:54:24 snj Exp $ */
 
 /*-
  * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.48 2014/02/19 20:50:56 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.48.4.1 2017/02/14 16:54:24 snj Exp $");
 
 #include 
 #include 
@@ -230,7 +230,12 @@ linux_sendsig(const ksiginfo_t *ksi, con
 	if (error != 0) {
 		sigexit(l, SIGILL);
 		return;
-	}	
+	}
+
+	if ((vaddr_t)catcher >= VM_MAXUSER_ADDRESS) {
+		sigexit(l, SIGILL);
+		return;
+	}
 
 	linux_buildcontext(l, catcher, sp);
 	tf->tf_rdi = sigframe.info.lsi_signo;
@@ -448,7 +453,7 @@ linux_usertrap(struct lwp *l, vaddr_t tr
 {
 	struct trapframe *tf = arg;
 	uint64_t retaddr;
-	int vsyscallnr;
+	size_t vsyscallnr;
 
 	/*
 	 * Check for a vsyscall. %rip must be the fault address,
@@ -478,6 +483,8 @@ linux_usertrap(struct lwp *l, vaddr_t tr
 	 */
 	if (copyin((void *)tf->tf_rsp, , sizeof retaddr) != 0)
 		return 0;
+	if ((vaddr_t)retaddr >= VM_MAXUSER_ADDRESS)
+		return 0;
 	tf->tf_rip = retaddr;
 	tf->tf_rax = linux_vsyscall_to_syscall[vsyscallnr];
 	tf->tf_rsp += 8;	/* "pop" the return address */



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

2017-02-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Feb 14 16:50:31 UTC 2017

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

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


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.4.1 src/sys/miscfs/procfs/procfs_map.c

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

Modified files:

Index: src/sys/miscfs/procfs/procfs_map.c
diff -u src/sys/miscfs/procfs/procfs_map.c:1.44 src/sys/miscfs/procfs/procfs_map.c:1.44.4.1
--- src/sys/miscfs/procfs/procfs_map.c:1.44	Tue Mar 18 18:20:43 2014
+++ src/sys/miscfs/procfs/procfs_map.c	Tue Feb 14 16:50:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_map.c,v 1.44 2014/03/18 18:20:43 riastradh Exp $	*/
+/*	$NetBSD: procfs_map.c,v 1.44.4.1 2017/02/14 16:50:31 snj Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_map.c,v 1.44 2014/03/18 18:20:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_map.c,v 1.44.4.1 2017/02/14 16:50:31 snj Exp $");
 
 #include 
 #include 
@@ -126,15 +126,6 @@ procfs_domap(struct lwp *curl, struct pr
 	if (uio->uio_rw != UIO_READ)
 		return EOPNOTSUPP;
 
-	if (uio->uio_offset != 0) {
-		/*
-		 * we return 0 here, so that the second read returns EOF
-		 * we don't support reading from an offset because the
-		 * map could have changed between the two reads.
-		 */
-		return 0;
-	}
-
 	error = 0;
 
 	if (linuxmode != 0)
@@ -220,7 +211,16 @@ again:
 	vm_map_unlock_read(map);
 	uvmspace_free(vm);
 
-	error = uiomove(buffer, pos, uio);
+	/*
+	 * We support reading from an offset, because linux does.
+	 * The map could have changed between the two reads, and
+	 * that could result in junk, but typically it does not.
+	 */
+	if (uio->uio_offset < pos)
+		error = uiomove(buffer + uio->uio_offset,
+		pos - uio->uio_offset, uio);
+	else
+		error = 0;
 out:
 	if (path != NULL)
 		free(path, M_TEMP);



CVS commit: src/sys

2017-02-14 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Feb 14 13:29:09 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: efimemory.c
src/sys/arch/x86/acpi: acpi_machdep.c
src/sys/arch/x86/include: efi.h
src/sys/arch/x86/x86: efi.c x86_machdep.c
src/sys/external/bsd/gnu-efi/dist/inc: efidef.h

Log Message:
Handle persistent memory. Currently only debug output.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/efimemory.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/acpi/acpi_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/include/efi.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/x86/efi.c
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/x86/x86/x86_machdep.c
cvs rdiff -u -r1.1.1.1 -r1.2 src/sys/external/bsd/gnu-efi/dist/inc/efidef.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/i386/stand/efiboot/efimemory.c
diff -u src/sys/arch/i386/stand/efiboot/efimemory.c:1.3 src/sys/arch/i386/stand/efiboot/efimemory.c:1.4
--- src/sys/arch/i386/stand/efiboot/efimemory.c:1.3	Sat Feb 11 10:13:46 2017
+++ src/sys/arch/i386/stand/efiboot/efimemory.c	Tue Feb 14 13:29:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efimemory.c,v 1.3 2017/02/11 10:13:46 nonaka Exp $	*/
+/*	$NetBSD: efimemory.c,v 1.4 2017/02/14 13:29:09 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -35,7 +35,15 @@ static const char *memtypes[] = {
 	"available",
 	"reserved",
 	"ACPI reclaimable",
-	"ACPI NVS"
+	"ACPI NVS",
+	"unusable",
+	"disabled",
+	"Persistent",
+	"undefined (8)",
+	"undefined (9)",
+	"undefined (10)",
+	"undefined (11)",
+	"Persistent (Legacy)"
 };
 
 static const char *efimemtypes[] = {
@@ -53,6 +61,7 @@ static const char *efimemtypes[] = {
 	"MemoryMappedIO",
 	"MemoryMappedIOPortSpace",
 	"PalCode",
+	"PersistentMemory",
 };
 
 static int
@@ -74,6 +83,9 @@ getmemtype(EFI_MEMORY_DESCRIPTOR *md)
 	case EfiACPIMemoryNVS:
 		return BIM_NVS;
 
+	case EfiPersistentMemory:
+		return BIM_PMEM;
+
 	case EfiReservedMemoryType:
 	case EfiRuntimeServicesCode:
 	case EfiRuntimeServicesData:
@@ -82,9 +94,9 @@ getmemtype(EFI_MEMORY_DESCRIPTOR *md)
 	case EfiMemoryMappedIOPortSpace:
 	case EfiPalCode:
 	case EfiMaxMemoryType:
+	default:
 		return BIM_Reserved;
 	}
-	return BIM_Reserved;
 }
 
 EFI_MEMORY_DESCRIPTOR *

Index: src/sys/arch/x86/acpi/acpi_machdep.c
diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.17 src/sys/arch/x86/acpi/acpi_machdep.c:1.18
--- src/sys/arch/x86/acpi/acpi_machdep.c:1.17	Tue Feb 14 13:23:50 2017
+++ src/sys/arch/x86/acpi/acpi_machdep.c	Tue Feb 14 13:29:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.17 2017/02/14 13:23:50 nonaka Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.18 2017/02/14 13:29:09 nonaka Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.17 2017/02/14 13:23:50 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.18 2017/02/14 13:29:09 nonaka Exp $");
 
 #include 
 #include 
@@ -395,6 +395,8 @@ acpi_md_mcfg_validate(uint64_t addr, int
 		(type == BIM_Reserved) ?  "Reserved" :
 		(type == BIM_ACPI) ? "ACPI" :
 		(type == BIM_NVS) ? "NVS" :
+		(type == BIM_PMEM) ? "Persistent" :
+		(type == BIM_PRAM) ? "Persistent (Legacy)" :
 		"unknown");
 
 		switch (type) {

Index: src/sys/arch/x86/include/efi.h
diff -u src/sys/arch/x86/include/efi.h:1.4 src/sys/arch/x86/include/efi.h:1.5
--- src/sys/arch/x86/include/efi.h:1.4	Tue Feb 14 13:23:50 2017
+++ src/sys/arch/x86/include/efi.h	Tue Feb 14 13:29:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: efi.h,v 1.4 2017/02/14 13:23:50 nonaka Exp $   */
+/* $NetBSD: efi.h,v 1.5 2017/02/14 13:29:09 nonaka Exp $   */
 
 /*-
  * Copyright (c) 2004 Marcel Moolenaar
@@ -74,6 +74,7 @@ struct efi_md {
 #defineEFI_MD_TYPE_IOMEM   11  /* Memory-mapped I/O. */
 #defineEFI_MD_TYPE_IOPORT  12  /* I/O port space. */
 #defineEFI_MD_TYPE_PALCODE 13  /* PAL */
+#defineEFI_MD_TYPE_PMEM14  /* Persistent memory. */
uint32_t__pad;
uint64_tmd_phys;
uint64_tmd_virt;

Index: src/sys/arch/x86/x86/efi.c
diff -u src/sys/arch/x86/x86/efi.c:1.7 src/sys/arch/x86/x86/efi.c:1.8
--- src/sys/arch/x86/x86/efi.c:1.7	Tue Feb 14 13:23:50 2017
+++ src/sys/arch/x86/x86/efi.c	Tue Feb 14 13:29:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efi.c,v 1.7 2017/02/14 13:23:50 nonaka Exp $	*/
+/*	$NetBSD: efi.c,v 1.8 2017/02/14 13:29:09 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.7 2017/02/14 13:23:50 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.8 2017/02/14 13:29:09 nonaka Exp $");
 
 #include 
 #include 
@@ -320,6 +320,9 @@ efi_getbiosmemtype(uint32_t type, uint64
 	

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

2017-02-14 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Feb 14 13:25:22 UTC 2017

Modified Files:
src/sys/arch/x86/include: bootinfo.h

Log Message:
x86: add e820 memory type.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/x86/include/bootinfo.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/bootinfo.h
diff -u src/sys/arch/x86/include/bootinfo.h:1.25 src/sys/arch/x86/include/bootinfo.h:1.26
--- src/sys/arch/x86/include/bootinfo.h:1.25	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/x86/include/bootinfo.h	Tue Feb 14 13:25:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.h,v 1.25 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: bootinfo.h,v 1.26 2017/02/14 13:25:22 nonaka Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -119,6 +119,10 @@ struct bi_memmap_entry {
 #define	BIM_Reserved	2	/* in use or reserved by the system */
 #define	BIM_ACPI	3	/* ACPI Reclaim memory */
 #define	BIM_NVS		4	/* ACPI NVS memory */
+#define	BIM_Unusable	5	/* errors have been detected */
+#define	BIM_Disabled	6	/* not enabled */
+#define	BIM_PMEM	7	/* Persistent memory */
+#define	BIM_PRAM	12	/* legacy NVDIMM (OEM defined) */
 
 struct btinfo_memmap {
 	struct btinfo_common common;



CVS commit: src/sys/arch/x86

2017-02-14 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Feb 14 13:23:50 UTC 2017

Modified Files:
src/sys/arch/x86/acpi: acpi_machdep.c
src/sys/arch/x86/include: efi.h
src/sys/arch/x86/x86: efi.c x86_machdep.c

Log Message:
x86: make btinfo_memmap from btinfo_efimemmap for to reduce mem_cluster_cnt.

should fix PR/51953.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/acpi/acpi_machdep.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/include/efi.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/x86/efi.c
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/x86/x86/x86_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/acpi/acpi_machdep.c
diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.16 src/sys/arch/x86/acpi/acpi_machdep.c:1.17
--- src/sys/arch/x86/acpi/acpi_machdep.c:1.16	Thu Feb  9 11:56:40 2017
+++ src/sys/arch/x86/acpi/acpi_machdep.c	Tue Feb 14 13:23:50 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.16 2017/02/09 11:56:40 nonaka Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.17 2017/02/14 13:23:50 nonaka Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.16 2017/02/09 11:56:40 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.17 2017/02/14 13:23:50 nonaka Exp $");
 
 #include 
 #include 
@@ -366,62 +366,36 @@ acpi_md_ncpus(void)
 static bool
 acpi_md_mcfg_validate(uint64_t addr, int bus_start, int *bus_end)
 {
-	union {
-		struct btinfo_common *common;
-		struct btinfo_memmap *bios;
-		struct btinfo_efimemmap *efi;
-	} bim;
+	struct btinfo_memmap *bim;
 	uint64_t size, mapaddr, mapsize;
 	uint32_t type;
-	int i, n, num;
-	bool efimemmap;
+	int i, n;
 
-	bim.common = lookup_bootinfo(BTINFO_EFIMEMMAP);
-	if (bim.common == NULL) {
-		bim.common = lookup_bootinfo(BTINFO_MEMMAP);
-		if (bim.common == NULL)
-			return false;
-	}
-	efimemmap = bim.common->type == BTINFO_EFIMEMMAP;
-	num = efimemmap ? bim.efi->num : bim.bios->num;
+#ifndef XEN
+	if (lookup_bootinfo(BTINFO_EFIMEMMAP) != NULL)
+		bim = efi_get_e820memmap();
+	else
+#endif
+		bim = lookup_bootinfo(BTINFO_MEMMAP);
+	if (bim == NULL)
+		return false;
 
 	size = *bus_end - bus_start + 1;
 	size *= ACPIMCFG_SIZE_PER_BUS;
-	for (i = 0; i < num; i++) {
-#ifndef XEN
-		if (efimemmap) {
-			struct efi_md *md = (struct efi_md *)
-			(bim.efi->memmap + bim.efi->size * i);
-			mapaddr = md->md_phys;
-			mapsize = md->md_pages * EFI_PAGE_SIZE;
-			type = efi_getbiosmemtype(md->md_type, md->md_attr);
-
-			aprint_debug("MCFG: MEMMAP: "
-			"p0x%016" PRIx64 "-0x%016" PRIx64
-			", v0x%016" PRIx64 "-0x%016" PRIx64
-			", size=0x%016" PRIx64 ", attr=0x%016" PRIx64
-			", type=%d(%s)\n",
-			mapaddr, mapaddr + mapsize - 1,
-			md->md_virt, md->md_virt + mapsize - 1,
-			size, md->md_attr, md->md_type,
-			efi_getmemtype_str(md->md_type));
-		} else
-#endif
-		{
-			mapaddr = bim.bios->entry[i].addr;
-			mapsize = bim.bios->entry[i].size;
-			type = bim.bios->entry[i].type;
-
-			aprint_debug("MCFG: MEMMAP: 0x%016" PRIx64
-			"-0x%016" PRIx64 ", size=0x%016" PRIx64
-			", type=%d(%s)\n",
-			mapaddr, mapaddr + mapsize - 1, mapsize, type,
-			(type == BIM_Memory) ?  "Memory" :
-			(type == BIM_Reserved) ?  "Reserved" :
-			(type == BIM_ACPI) ? "ACPI" :
-			(type == BIM_NVS) ? "NVS" :
-			"unknown");
-		}
+	for (i = 0; i < bim->num; i++) {
+		mapaddr = bim->entry[i].addr;
+		mapsize = bim->entry[i].size;
+		type = bim->entry[i].type;
+
+		aprint_debug("MCFG: MEMMAP: 0x%016" PRIx64
+		"-0x%016" PRIx64 ", size=0x%016" PRIx64
+		", type=%d(%s)\n",
+		mapaddr, mapaddr + mapsize - 1, mapsize, type,
+		(type == BIM_Memory) ?  "Memory" :
+		(type == BIM_Reserved) ?  "Reserved" :
+		(type == BIM_ACPI) ? "ACPI" :
+		(type == BIM_NVS) ? "NVS" :
+		"unknown");
 
 		switch (type) {
 		case BIM_ACPI:

Index: src/sys/arch/x86/include/efi.h
diff -u src/sys/arch/x86/include/efi.h:1.3 src/sys/arch/x86/include/efi.h:1.4
--- src/sys/arch/x86/include/efi.h:1.3	Thu Feb  9 11:56:40 2017
+++ src/sys/arch/x86/include/efi.h	Tue Feb 14 13:23:50 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: efi.h,v 1.3 2017/02/09 11:56:40 nonaka Exp $   */
+/* $NetBSD: efi.h,v 1.4 2017/02/14 13:23:50 nonaka Exp $   */
 
 /*-
  * Copyright (c) 2004 Marcel Moolenaar
@@ -165,6 +165,9 @@ paddr_tefi_getcfgtblpa(const
 void  *efi_getcfgtbl(const struct uuid*);
 intefi_getbiosmemtype(uint32_t, uint64_t);
 const char*efi_getmemtype_str(uint32_t);
+struct btinfo_memmap;
+struct btinfo_memmap *efi_get_e820memmap(void);
+
 /*
 void efi_boot_finish(void);
 int efi_boot_minimal(uint64_t);

Index: src/sys/arch/x86/x86/efi.c
diff -u src/sys/arch/x86/x86/efi.c:1.6 src/sys/arch/x86/x86/efi.c:1.7
--- src/sys/arch/x86/x86/efi.c:1.6	Thu 

CVS commit: src

2017-02-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb 14 09:59:16 UTC 2017

Modified Files:
src/crypto/external/bsd/openssh/lib: Makefile
src/doc: HACKS

Log Message:
also compile poly1305.c with -O0 on vax to address ssh login failure from/to
some hosts


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/crypto/external/bsd/openssh/lib/Makefile
cvs rdiff -u -r1.181 -r1.182 src/doc/HACKS

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

Modified files:

Index: src/crypto/external/bsd/openssh/lib/Makefile
diff -u src/crypto/external/bsd/openssh/lib/Makefile:1.20 src/crypto/external/bsd/openssh/lib/Makefile:1.21
--- src/crypto/external/bsd/openssh/lib/Makefile:1.20	Tue Feb 14 09:00:03 2017
+++ src/crypto/external/bsd/openssh/lib/Makefile	Tue Feb 14 09:59:16 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.20 2017/02/14 09:00:03 rin Exp $
+#	$NetBSD: Makefile,v 1.21 2017/02/14 09:59:16 rin Exp $
 
 .include 
 
@@ -117,7 +117,8 @@ COPTS.channels.c+=	-fno-strict-aliasing
 
 # XXX
 .if ${MACHINE} == "vax"
-COPTS.umac.c+=-O0
+COPTS.poly1305.c+=	-O0
+COPTS.umac.c+=		-O0
 .endif
 
 .include 

Index: src/doc/HACKS
diff -u src/doc/HACKS:1.181 src/doc/HACKS:1.182
--- src/doc/HACKS:1.181	Tue Feb 14 09:07:35 2017
+++ src/doc/HACKS	Tue Feb 14 09:59:16 2017
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.181 2017/02/14 09:07:35 rin Exp $
+# $NetBSD: HACKS,v 1.182 2017/02/14 09:59:16 rin Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -549,12 +549,13 @@ port	vax
 	kcah
 
 	hack	libssh miscompile
-	date	Tue Feb 14 17:58:06 JST 2017
+	cdate	Tue Feb 14 17:58:06 JST 2017
+	mdate	Tue Feb 14 18:57:39 JST 2017
 	who	rin
 	file	crypto/external/bsd/openssh/lib/Makefile : 1.20
 	descr
-		umac.c is miscompiled, which results in login failure to/from
-		external hosts via ssh.
+		poly1305.c and umac.c are miscompiled, which results in login
+		failure to/from external hosts via ssh.
 	kcah
 
 	hack	mandoc miscompile



CVS commit: src/sys/dev

2017-02-14 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue Feb 14 09:41:29 UTC 2017

Modified Files:
src/sys/dev: audio.c

Log Message:
Don't call grow_mixer_states with sc_intr_lock held.

Addresses PR kern/51965.


To generate a diff of this commit:
cvs rdiff -u -r1.305 -r1.306 src/sys/dev/audio.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/audio.c
diff -u src/sys/dev/audio.c:1.305 src/sys/dev/audio.c:1.306
--- src/sys/dev/audio.c:1.305	Mon Feb 13 04:47:59 2017
+++ src/sys/dev/audio.c	Tue Feb 14 09:41:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.305 2017/02/13 04:47:59 ozaki-r Exp $	*/
+/*	$NetBSD: audio.c,v 1.306 2017/02/14 09:41:29 nat Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.305 2017/02/13 04:47:59 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.306 2017/02/14 09:41:29 nat Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -2169,6 +2169,7 @@ audio_open(dev_t dev, struct audio_softc
 
 	DPRINTF(("audio_open: done sc_mode = 0x%x\n", vc->sc_mode));
 
+	grow_mixer_states(sc, 2);
 	mutex_enter(sc->sc_intr_lock);
 	if (flags & FREAD)
 		sc->sc_recopens++;
@@ -2176,7 +2177,6 @@ audio_open(dev_t dev, struct audio_softc
 	chan->dev = dev;
 	chan->chan = n;
 	chan->deschan = n;
-	grow_mixer_states(sc, 2);
 	SIMPLEQ_INSERT_TAIL(>sc_audiochan, chan, entries);
 	mutex_exit(sc->sc_intr_lock);
 



CVS commit: src/sys/arch

2017-02-14 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Feb 14 09:11:05 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: trap.c
src/sys/arch/x86/x86: sys_machdep.c

Log Message:
Add most of my USER_LDT code for amd64, but disable it and put a comment
about why Wine still does not work.

Nothing changes, but at least it is a step forward.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/x86/x86/sys_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/amd64/amd64/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.89 src/sys/arch/amd64/amd64/trap.c:1.90
--- src/sys/arch/amd64/amd64/trap.c:1.89	Wed Jan 18 05:11:59 2017
+++ src/sys/arch/amd64/amd64/trap.c	Tue Feb 14 09:11:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.89 2017/01/18 05:11:59 kamil Exp $	*/
+/*	$NetBSD: trap.c,v 1.90 2017/02/14 09:11:05 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.89 2017/01/18 05:11:59 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.90 2017/02/14 09:11:05 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -373,6 +373,10 @@ kernelfault:
 			break;
 		case 0x848e:	/* mov 0xa8(%rsp),%es (8e 84 24 a8 00 00 00) */
 		case 0x9c8e:	/* mov 0xb0(%rsp),%ds (8e 9c 24 b0 00 00 00) */
+#ifdef USER_LDT
+		case 0xa48e:	/* mov 0xa0(%rsp),%fs (8e a4 24 a0 00 00 00) */
+		case 0xac8e:	/* mov 0x98(%rsp),%gs (8e ac 24 98 00 00 00) */
+#endif
 			/*
 			 * We faulted loading one of the user segment registers.
 			 * The stack frame containing the user registers is

Index: src/sys/arch/x86/x86/sys_machdep.c
diff -u src/sys/arch/x86/x86/sys_machdep.c:1.31 src/sys/arch/x86/x86/sys_machdep.c:1.32
--- src/sys/arch/x86/x86/sys_machdep.c:1.31	Sun Feb  5 10:42:21 2017
+++ src/sys/arch/x86/x86/sys_machdep.c	Tue Feb 14 09:11:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_machdep.c,v 1.31 2017/02/05 10:42:21 maxv Exp $	*/
+/*	$NetBSD: sys_machdep.c,v 1.32 2017/02/14 09:11:05 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.31 2017/02/05 10:42:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.32 2017/02/14 09:11:05 maxv Exp $");
 
 #include "opt_mtrr.h"
 #include "opt_perfctrs.h"
@@ -68,8 +68,23 @@ __KERNEL_RCSID(0, "$NetBSD: sys_machdep.
 #include 
 
 #ifdef __x86_64__
-/* Need to be checked. */
+/*
+ * The code for USER_LDT on amd64 is mostly functional, but it is still not
+ * enabled.
+ *
+ * On amd64 we are allowing only 8-byte-sized entries in the LDT, and we are
+ * not allowing the user to overwrite the existing entries (below LDT_SIZE).
+ * Note that USER_LDT is used only by 32bit applications, under compat_netbsd32.
+ * This is theoretically enough for Wine to work.
+ *
+ * However, letting segment registers have different location breaks amd64's
+ * Thread Local Storage: %fs and %gs must be reloaded when returning to
+ * userland. See the tech-kern@ archive from February 2017. A patch has been
+ * proposed to fix that, but Wine still randomly crashes; it is not clear
+ * whether the issues come from Wine, from netbsd32 or from the patch itself.
+ */
 #undef	USER_LDT
+/* Need to be checked. */
 #undef	PERFCTRS
 #undef	IOPERM
 #else
@@ -168,14 +183,23 @@ x86_get_ldt1(struct lwp *l, struct x86_g
 	ua->start + ua->num > 8192)
 		return (EINVAL);
 
+#ifdef __x86_64__
+	if (ua->start * sizeof(union descriptor) < LDT_SIZE)
+		return EINVAL;
+#endif
+
 	mutex_enter(_lock);
 
 	if (pmap->pm_ldt != NULL) {
 		nldt = pmap->pm_ldt_len / sizeof(*lp);
 		lp = pmap->pm_ldt;
 	} else {
+#ifdef __x86_64__
+		nldt = LDT_SIZE / sizeof(*lp);
+#else
 		nldt = NLDT;
-		lp = ldtstore;
+#endif
+		lp = (union descriptor *)ldtstore;
 	}
 
 	if (ua->start > nldt) {
@@ -244,6 +268,12 @@ x86_set_ldt1(struct lwp *l, struct x86_s
 	size_t old_len, new_len;
 	union descriptor *old_ldt, *new_ldt;
 
+#ifdef __x86_64__
+	const size_t min_ldt_size = LDT_SIZE;
+#else
+	const size_t min_ldt_size = NLDT * sizeof(union descriptor);
+#endif
+
 	error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_LDT_SET,
 	NULL, NULL, NULL, NULL);
 	if (error)
@@ -253,6 +283,11 @@ x86_set_ldt1(struct lwp *l, struct x86_s
 	ua->start + ua->num > 8192)
 		return (EINVAL);
 
+#ifdef __x86_64__
+	if (ua->start * sizeof(union descriptor) < LDT_SIZE)
+		return EINVAL;
+#endif
+
 	/* Check descriptors for access violations. */
 	for (i = 0; i < ua->num; i++) {
 		union descriptor *desc = [i];
@@ -261,6 +296,12 @@ x86_set_ldt1(struct lwp *l, struct x86_s
 		case SDT_SYSNULL:
 			desc->sd.sd_p = 0;
 			break;
+#ifdef __x86_64__
+		case SDT_SYS286CGT:
+		case SDT_SYS386CGT:
+			/* We don't allow these on amd64. */
+			return EACCES;

CVS commit: src/doc

2017-02-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb 14 09:07:35 UTC 2017

Modified Files:
src/doc: HACKS

Log Message:
correct grammar


To generate a diff of this commit:
cvs rdiff -u -r1.180 -r1.181 src/doc/HACKS

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

Modified files:

Index: src/doc/HACKS
diff -u src/doc/HACKS:1.180 src/doc/HACKS:1.181
--- src/doc/HACKS:1.180	Tue Feb 14 09:05:17 2017
+++ src/doc/HACKS	Tue Feb 14 09:07:35 2017
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.180 2017/02/14 09:05:17 rin Exp $
+# $NetBSD: HACKS,v 1.181 2017/02/14 09:07:35 rin Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -553,8 +553,8 @@ port	vax
 	who	rin
 	file	crypto/external/bsd/openssh/lib/Makefile : 1.20
 	descr
-		umac.c is miscompiled, which results in login to/from external
-		hosts via ssh fails.
+		umac.c is miscompiled, which results in login failure to/from
+		external hosts via ssh.
 	kcah
 
 	hack	mandoc miscompile



CVS commit: src

2017-02-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb 14 09:05:18 UTC 2017

Modified Files:
src/doc: HACKS
src/external/bsd/mdocml/lib/libmandoc: Makefile

Log Message:
add hack for libmandoc on vax:
mandoc(1) receives SIGILL in in_line_argn() from mdoc_macro.c


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/doc/HACKS
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/mdocml/lib/libmandoc/Makefile

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

Modified files:

Index: src/doc/HACKS
diff -u src/doc/HACKS:1.179 src/doc/HACKS:1.180
--- src/doc/HACKS:1.179	Tue Feb 14 09:00:03 2017
+++ src/doc/HACKS	Tue Feb 14 09:05:17 2017
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.179 2017/02/14 09:00:03 rin Exp $
+# $NetBSD: HACKS,v 1.180 2017/02/14 09:05:17 rin Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -557,6 +557,14 @@ port	vax
 		hosts via ssh fails.
 	kcah
 
+	hack	mandoc miscompile
+	date	Tue Feb 14 18:03:05 JST 2017
+	who	rin
+	file	external/bsd/mdocml/lib/libmandoc/Makefile : 1.8
+	descr
+		mandoc(1) receives SIGILL in in_line_argn() from mdoc_macro.c.
+	kcah
+
 port	arm
 
 	hack	gcc-unsigned-compare

Index: src/external/bsd/mdocml/lib/libmandoc/Makefile
diff -u src/external/bsd/mdocml/lib/libmandoc/Makefile:1.7 src/external/bsd/mdocml/lib/libmandoc/Makefile:1.8
--- src/external/bsd/mdocml/lib/libmandoc/Makefile:1.7	Fri Jul 15 19:40:42 2016
+++ src/external/bsd/mdocml/lib/libmandoc/Makefile	Tue Feb 14 09:05:17 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2016/07/15 19:40:42 christos Exp $
+# $NetBSD: Makefile,v 1.8 2017/02/14 09:05:17 rin Exp $
 
 LIBISPRIVATE=	yes
 
@@ -36,4 +36,9 @@ tbl_opts.c
 
 MAN=	mandoc.3
 
+# XXX
+.if ${MACHINE} == "vax"
+COPTS.mdoc_macro.c+=-O0
+.endif
+
 .include 



CVS commit: src/sys/arch/amd64/amd64

2017-02-14 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Feb 14 09:03:48 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: netbsd32_machdep.c

Log Message:
Check %eip with USER_LDT too.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/arch/amd64/amd64/netbsd32_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/amd64/amd64/netbsd32_machdep.c
diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.102 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.103
--- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.102	Thu Feb  9 08:38:25 2017
+++ src/sys/arch/amd64/amd64/netbsd32_machdep.c	Tue Feb 14 09:03:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.102 2017/02/09 08:38:25 maxv Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.103 2017/02/14 09:03:48 maxv Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.102 2017/02/09 08:38:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.103 2017/02/14 09:03:48 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1064,10 +1064,11 @@ cpu_mcontext32_validate(struct lwp *l, c
 		if (!VALID_USER_DSEL32(gr[_REG32_DS]) ||
 		!VALID_USER_DSEL32(gr[_REG32_SS]))
 			return EINVAL;
-		if (gr[_REG32_EIP] >= VM_MAXUSER_ADDRESS32)
-			return EINVAL;
 	}
 
+	if (gr[_REG32_EIP] >= VM_MAXUSER_ADDRESS32)
+		return EINVAL;
+
 	return 0;
 }
 



CVS commit: src

2017-02-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb 14 09:00:04 UTC 2017

Modified Files:
src/crypto/external/bsd/openssh/lib: Makefile
src/doc: HACKS

Log Message:
add hack for libssh on vax


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/crypto/external/bsd/openssh/lib/Makefile
cvs rdiff -u -r1.178 -r1.179 src/doc/HACKS

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

Modified files:

Index: src/crypto/external/bsd/openssh/lib/Makefile
diff -u src/crypto/external/bsd/openssh/lib/Makefile:1.19 src/crypto/external/bsd/openssh/lib/Makefile:1.20
--- src/crypto/external/bsd/openssh/lib/Makefile:1.19	Tue Aug  2 13:45:13 2016
+++ src/crypto/external/bsd/openssh/lib/Makefile	Tue Feb 14 09:00:03 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.19 2016/08/02 13:45:13 christos Exp $
+#	$NetBSD: Makefile,v 1.20 2017/02/14 09:00:03 rin Exp $
 
 .include 
 
@@ -115,4 +115,9 @@ COPTS.${f}.c+=	-Wno-pointer-sign
 # XXX
 COPTS.channels.c+=	-fno-strict-aliasing
 
+# XXX
+.if ${MACHINE} == "vax"
+COPTS.umac.c+=-O0
+.endif
+
 .include 

Index: src/doc/HACKS
diff -u src/doc/HACKS:1.178 src/doc/HACKS:1.179
--- src/doc/HACKS:1.178	Mon Feb 13 22:31:09 2017
+++ src/doc/HACKS	Tue Feb 14 09:00:03 2017
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.178 2017/02/13 22:31:09 rin Exp $
+# $NetBSD: HACKS,v 1.179 2017/02/14 09:00:03 rin Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -548,6 +548,15 @@ port	vax
 		to the PR. As a workaround, compile dse.c with -O0.
 	kcah
 
+	hack	libssh miscompile
+	date	Tue Feb 14 17:58:06 JST 2017
+	who	rin
+	file	crypto/external/bsd/openssh/lib/Makefile : 1.20
+	descr
+		umac.c is miscompiled, which results in login to/from external
+		hosts via ssh fails.
+	kcah
+
 port	arm
 
 	hack	gcc-unsigned-compare



CVS commit: src/tests/net/if

2017-02-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Feb 14 08:43:06 UTC 2017

Modified Files:
src/tests/net/if: Makefile t_ifconfig.sh

Log Message:
Add tests for ifconfig up/down


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/net/if/Makefile
cvs rdiff -u -r1.15 -r1.16 src/tests/net/if/t_ifconfig.sh

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

Modified files:

Index: src/tests/net/if/Makefile
diff -u src/tests/net/if/Makefile:1.6 src/tests/net/if/Makefile:1.7
--- src/tests/net/if/Makefile:1.6	Mon Aug  8 14:54:27 2016
+++ src/tests/net/if/Makefile	Tue Feb 14 08:43:06 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.6 2016/08/08 14:54:27 pgoyette Exp $
+# $NetBSD: Makefile,v 1.7 2017/02/14 08:43:06 ozaki-r Exp $
 #
 
 .include 
@@ -6,8 +6,10 @@
 TESTSDIR=	${TESTSBASE}/net/if
 
 TESTS_C=	t_compat
-TESTS_SH=	t_ifconf
-TESTS_SH+=	t_ifconfig
+.for name in ifconf ifconfig
+TESTS_SH+=		t_${name}
+TESTS_SH_SRC_t_${name}=	../net_common.sh t_${name}.sh
+.endfor
 
 PROGS=		ifconf
 MAN.ifconf=	# empty

Index: src/tests/net/if/t_ifconfig.sh
diff -u src/tests/net/if/t_ifconfig.sh:1.15 src/tests/net/if/t_ifconfig.sh:1.16
--- src/tests/net/if/t_ifconfig.sh:1.15	Fri Jan 20 08:35:33 2017
+++ src/tests/net/if/t_ifconfig.sh	Tue Feb 14 08:43:06 2017
@@ -1,4 +1,4 @@
-# $NetBSD: t_ifconfig.sh,v 1.15 2017/01/20 08:35:33 ozaki-r Exp $
+# $NetBSD: t_ifconfig.sh,v 1.16 2017/02/14 08:43:06 ozaki-r Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -324,10 +324,137 @@ ifconfig_parameters_cleanup()
 	env RUMP_SERVER=${RUMP_SERVER2} rump.halt
 }
 
+ifconfig_up_down_common()
+{
+	local family=$1
+	local ip=$2
+
+	if [ $family = inet6 ]; then
+		rump_server_start $RUMP_SERVER1 netinet6
+	else
+		rump_server_start $RUMP_SERVER1
+	fi
+	rump_server_add_iface $RUMP_SERVER1 shmif0 bus1
+
+	export RUMP_SERVER=$RUMP_SERVER1
+	rump.ifconfig shmif0
+
+	# Set the same number of trials to make the following test
+	# work for both IPv4 and IPv6
+	if [ $family = inet6 ]; then
+		atf_check -s exit:0 -o ignore \
+		rump.sysctl -w net.inet6.ip6.dad_count=3
+	else
+		atf_check -s exit:0 -o ignore \
+		rump.sysctl -w net.inet.ip.dad_count=3
+	fi
+
+	#
+	# Assign an address and up the interface at once
+	#
+	atf_check -s exit:0 rump.ifconfig shmif0 $family $ip/24 up
+	# UP
+	atf_check -s exit:0 \
+	-o match:'shmif0.*UP.*RUNNING' rump.ifconfig shmif0
+	# The address is TENTATIVE
+	atf_check -s exit:0 \
+	-o match:"$ip.*TENTATIVE" rump.ifconfig shmif0
+	# Waiting for DAD completion
+	atf_check -s exit:0 rump.ifconfig -w 10
+	# The address left TENTATIVE
+	atf_check -s exit:0 \
+	-o not-match:"$ip.*TENTATIVE" rump.ifconfig shmif0
+
+	#
+	# ifconfig down
+	#
+	atf_check -s exit:0 rump.ifconfig shmif0 down
+	atf_check -s exit:0 \
+	-o not-match:'shmif0.*UP.*RUNNING' rump.ifconfig shmif0
+	# The address becomes DETATCHED
+	atf_check -s exit:0 \
+	-o match:"$ip.*DETACHED" rump.ifconfig shmif0
+	# ifconfig up
+	atf_check -s exit:0 rump.ifconfig shmif0 up
+	# The address becomes TENTATIVE
+	atf_check -s exit:0 \
+	-o match:"$ip.*TENTATIVE" rump.ifconfig shmif0
+	# Waiting for DAD completion
+	atf_check -s exit:0 rump.ifconfig -w 10
+	# The address left TENTATIVE
+	atf_check -s exit:0 \
+	-o not-match:"$ip.*TENTATIVE" rump.ifconfig shmif0
+
+	# Clean up
+	atf_check -s exit:0 rump.ifconfig shmif0 $family $ip delete
+
+	#
+	# Assign an address
+	#
+	atf_check -s exit:0 rump.ifconfig shmif0 $family $ip/24
+	# UP automatically
+	atf_check -s exit:0 \
+	-o match:'shmif0.*UP.*RUNNING' rump.ifconfig shmif0
+	# Need some delay
+	sleep 1
+	# The IP becomes TENTATIVE
+	atf_check -s exit:0 \
+	-o match:"$ip.*TENTATIVE" rump.ifconfig shmif0
+	# Waiting for DAD completion
+	atf_check -s exit:0 rump.ifconfig -w 10
+	# The address left TENTATIVE
+	atf_check -s exit:0 \
+	-o not-match:"$ip.*TENTATIVE" rump.ifconfig shmif0
+
+	rump_server_destroy_ifaces
+}
+
+atf_test_case ifconfig_up_down_ipv4 cleanup
+ifconfig_up_down_ipv4_head()
+{
+	atf_set "descr" "tests of interface up/down (IPv4)"
+	atf_set "require.progs" "rump_server"
+}
+
+ifconfig_up_down_ipv4_body()
+{
+
+	ifconfig_up_down_common inet 10.0.0.1
+}
+
+ifconfig_up_down_ipv4_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
+atf_test_case ifconfig_up_down_ipv6 cleanup
+ifconfig_up_down_ipv6_head()
+{
+	atf_set "descr" "tests of interface up/down (IPv6)"
+	atf_set "require.progs" "rump_server"
+}
+
+ifconfig_up_down_ipv6_body()
+{
+
+	ifconfig_up_down_common inet6 fc00::1
+}
+
+ifconfig_up_down_ipv6_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
 atf_init_test_cases()
 {
 
 	atf_add_test_case ifconfig_create_destroy
 	atf_add_test_case ifconfig_options
 	atf_add_test_case ifconfig_parameters
+	atf_add_test_case ifconfig_up_down_ipv4
+	atf_add_test_case ifconfig_up_down_ipv6
 }