CVS commit: src/sys/dev/pci

2020-10-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Oct 16 05:53:40 UTC 2020

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

Log Message:
 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.690 -r1.691 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.690 src/sys/dev/pci/if_wm.c:1.691
--- src/sys/dev/pci/if_wm.c:1.690	Thu Sep 24 08:00:59 2020
+++ src/sys/dev/pci/if_wm.c	Fri Oct 16 05:53:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.690 2020/09/24 08:00:59 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.691 2020/10/16 05:53:39 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.690 2020/09/24 08:00:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.691 2020/10/16 05:53:39 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2862,7 +2862,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: src/sys/arch/aarch64/aarch64

2020-10-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Oct 15 23:15:36 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: trap.c

Log Message:
Byte-swapping instructions for arm and thumb on aarch64eb;
instructions are stored in little-endian byte-order for BE8,
an only valid binary format for ILP32BE executables.

XXX
Apply similar fixes to armv7{,hf}eb.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/aarch64/aarch64/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/aarch64/aarch64/trap.c
diff -u src/sys/arch/aarch64/aarch64/trap.c:1.37 src/sys/arch/aarch64/aarch64/trap.c:1.38
--- src/sys/arch/aarch64/aarch64/trap.c:1.37	Mon Sep 14 10:53:02 2020
+++ src/sys/arch/aarch64/aarch64/trap.c	Thu Oct 15 23:15:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.37 2020/09/14 10:53:02 ryo Exp $ */
+/* $NetBSD: trap.c,v 1.38 2020/10/15 23:15:36 rin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.37 2020/09/14 10:53:02 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.38 2020/10/15 23:15:36 rin Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -532,6 +532,12 @@ int
 fetch_arm_insn(uint64_t pc, uint64_t spsr, uint32_t *insn)
 {
 
+	/*
+	 * Instructions are stored in little endian for BE8,
+	 * only a valid binary format for ILP32EB. Therefore,
+	 * we need byte-swapping before decoding on aarch64eb.
+	 */
+
 	/* THUMB? */
 	if (spsr & SPSR_A32_T) {
 		uint16_t *p = (uint16_t *)(pc & ~1UL); /* XXX */
@@ -539,6 +545,7 @@ fetch_arm_insn(uint64_t pc, uint64_t sps
 
 		if (ufetch_16(p, ))
 			return -1;
+		LE16TOH(hi);
 
 		if (!THUMB_32BIT(hi)) {
 			/* 16-bit Thumb instruction */
@@ -549,6 +556,7 @@ fetch_arm_insn(uint64_t pc, uint64_t sps
 		/* 32-bit Thumb instruction */
 		if (ufetch_16(p + 1, ))
 			return -1;
+		LE16TOH(lo);
 
 		*insn = ((uint32_t)hi << 16) | lo;
 		return 4;
@@ -556,6 +564,7 @@ fetch_arm_insn(uint64_t pc, uint64_t sps
 
 	if (ufetch_32((uint32_t *)pc, insn))
 		return -1;
+	LE32TOH(*insn);
 
 	return 4;
 }



CVS commit: src/sys/arch/aarch64/aarch64

2020-10-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Oct 15 23:10:06 UTC 2020

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

Log Message:
Call netbsd32_adjust_limits() in netbsd32_setregs() for sure,
as done for amd64 and sparc64.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/aarch64/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/aarch64/aarch64/netbsd32_machdep.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.15 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.16
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.15	Thu Oct 15 22:41:02 2020
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep.c	Thu Oct 15 23:10:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.15 2020/10/15 22:41:02 rin Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.16 2020/10/15 23:10:06 rin Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.15 2020/10/15 22:41:02 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.16 2020/10/15 23:10:06 rin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -64,6 +64,8 @@ netbsd32_setregs(struct lwp *l, struct e
 	struct proc * const p = l->l_proc;
 	struct trapframe * const tf = l->l_md.md_utf;
 
+	netbsd32_adjust_limits(p);
+
 	aarch64_setregs_ptrauth(l, false);
 
 	p->p_flag |= PK_32;



CVS commit: src/sys/compat/netbsd32

2020-10-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Oct 15 23:06:06 UTC 2020

Modified Files:
src/sys/compat/netbsd32: netbsd32_wait.c

Log Message:
wait4(2): make error paths match with that of native wait4(2):

https://nxr.netbsd.org/xref/src/sys/kern/kern_exit.c#720


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/compat/netbsd32/netbsd32_wait.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/netbsd32/netbsd32_wait.c
diff -u src/sys/compat/netbsd32/netbsd32_wait.c:1.23 src/sys/compat/netbsd32/netbsd32_wait.c:1.24
--- src/sys/compat/netbsd32/netbsd32_wait.c:1.23	Fri Sep 23 14:09:39 2016
+++ src/sys/compat/netbsd32/netbsd32_wait.c	Thu Oct 15 23:06:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_wait.c,v 1.23 2016/09/23 14:09:39 skrll Exp $	*/
+/*	$NetBSD: netbsd32_wait.c,v 1.24 2020/10/15 23:06:06 rin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_wait.c,v 1.23 2016/09/23 14:09:39 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_wait.c,v 1.24 2020/10/15 23:06:06 rin Exp $");
 
 #include 
 #include 
@@ -66,14 +66,15 @@ netbsd32___wait450(struct lwp *l, const 
 	if (pid == 0)
 		return error;
 
-	if (SCARG_P32(uap, rusage)) {
+	if (SCARG_P32(uap, status))
+		error = copyout(, SCARG_P32(uap, status),
+		sizeof(status));
+
+	if (SCARG_P32(uap, rusage) && error == 0) {
 		netbsd32_from_rusage(, );
 		error = copyout(, SCARG_P32(uap, rusage), sizeof(ru32));
 	}
 
-	if (error == 0 && SCARG_P32(uap, status))
-		error = copyout(, SCARG_P32(uap, status), sizeof(status));
-
 	return error;
 }
 



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

2020-10-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Oct 15 22:59:50 UTC 2020

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

Log Message:
Apply fix in rev 1.2 for core_dump_procinfo to aarch64 and arm:

http://cvsweb.netbsd.org/bsdweb.cgi/src/tests/lib/libc/sys/t_ptrace_core_wait.h#rev1.2

> For powerpc, program counter is not automatically incremented by trap
> instruction. We cannot increment PC in the trap handler, which breaks
> applications depending on this behavior, e.g., GDB.

This statement is true for aarch64 and arm.

Also, use PTRACE_BREAKPOINT_SIZE instead of hard-coded 4 to address
instruction next to PC.

OK ryo


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_core_wait.h

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

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_core_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.3
--- src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.2	Wed Jun 24 04:47:10 2020
+++ src/tests/lib/libc/sys/t_ptrace_core_wait.h	Thu Oct 15 22:59:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_core_wait.h,v 1.2 2020/06/24 04:47:10 rin Exp $	*/
+/*	$NetBSD: t_ptrace_core_wait.h,v 1.3 2020/10/15 22:59:50 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -207,21 +207,27 @@ ATF_TC_BODY(core_dump_procinfo, tc)
 
 	DPRINTF("Before resuming the child process where it left off and "
 	"without signal to be sent\n");
-#ifndef __powerpc__
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-#else
+
+#if defined(__aarch64__) || defined(__arm__) || defined(__powerpc__)
 	/*
-	 * For powerpc, program counter is not automatically incremented by
-	 * a trap instruction. We cannot increment PC in the trap handler,
+	 * For these archs, program counter is not automatically incremented
+	 * by a trap instruction. We cannot increment PC in the trap handler,
 	 * which breaks applications depending on this behavior, e.g., GDB.
-	 * Therefore, we need to pass (PC + 4) instead of (void *)1 (== PC)
-	 * to PT_CONTINUE here.
+	 * Therefore, we need to pass PC++ instead of (void *)1 (== PC) to
+	 * PT_CONTINUE here.
 	 */
 	struct reg r;
 
 	SYSCALL_REQUIRE(ptrace(PT_GETREGS, child, , 0) != -1);
-	SYSCALL_REQUIRE(
-	ptrace(PT_CONTINUE, child, (void *)(r.pc + 4), 0) != -1);
+	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child,
+#  if defined(__aarch64__) || defined(__arm__)
+	(void *)(r.r_pc + PTRACE_BREAKPOINT_SIZE),
+#  elif defined(__powerpc__)
+	(void *)(r.pc + PTRACE_BREAKPOINT_SIZE),
+#  endif
+	0) != -1);
+#else
+	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 #endif
 
 	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);



CVS commit: src/sys/arch/aarch64/aarch64

2020-10-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Oct 15 22:52:08 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: vm_machdep.c

Log Message:
Fix clone(2) for COMPAT_NETBSD32.

(1) Set r13 (sp for arm32 processes) appropriately when stack is
specified to fork1().

(2) For arm32 processes, align stack to 8-byte boundary, instead of
16-byte for native aarch64 processes, to match our 32-bit ABI:

https://nxr.netbsd.org/xref/src/sys/arch/arm/arm32/vm_machdep.c#150

Note that sp alignment checking is disabled in aarch32 mode, and
this works fine with AARCH64_EL0_STACK_ALIGNMENT_CHECK option.

OK ryo


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/aarch64/aarch64/vm_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/aarch64/aarch64/vm_machdep.c
diff -u src/sys/arch/aarch64/aarch64/vm_machdep.c:1.8 src/sys/arch/aarch64/aarch64/vm_machdep.c:1.9
--- src/sys/arch/aarch64/aarch64/vm_machdep.c:1.8	Sat May 23 18:08:59 2020
+++ src/sys/arch/aarch64/aarch64/vm_machdep.c	Thu Oct 15 22:52:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.8 2020/05/23 18:08:59 ryo Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.9 2020/10/15 22:52:08 rin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -29,10 +29,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_compat_netbsd32.h"
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.8 2020/05/23 18:08:59 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.9 2020/10/15 22:52:08 rin Exp $");
 
 #include 
 #include 
@@ -143,11 +144,19 @@ cpu_lwp_fork(struct lwp *l1, struct lwp 
 	*utf = *l1->l_md.md_utf;
 
 	/*
-	 * If specified, give the child a different stack
-	 * (make sure it's 16-byte aligned).
+	 * If specified, give the child a different stack (make sure it's
+	 * 16- or 8-byte aligned for 64- or 32-bit processes, respectively).
 	 */
-	if (stack != NULL)
-		utf->tf_sp = ((vaddr_t)(stack) + stacksize) & -16;
+	if (stack != NULL) {
+		utf->tf_sp = (vaddr_t)(stack) + stacksize;
+#ifdef COMPAT_NETBSD32
+		if (__predict_false(l2->l_proc->p_flag & PK_32)) {
+			utf->tf_sp &= -8;
+			utf->tf_reg[13] = utf->tf_sp;
+		} else
+#endif
+			utf->tf_sp &= -16;
+	}
 
 	/* build a new switchframe */
 	struct trapframe * const ktf = utf - 1;



CVS commit: src/sys/arch/aarch64/aarch64

2020-10-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Oct 15 22:41:02 UTC 2020

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

Log Message:
For rev 1.14 and before, netbsd32_process_write_regs() returns EINVAL
if non-modifiable bits are set in CPSR.

Instead, mask out non-modifiable bits and make this function success
regardless of value in CPSR. New behavior matches that of arm:

https://nxr.netbsd.org/xref/src/sys/arch/arm/arm/process_machdep.c#187

This fixes lib/libc/sys/t_ptrace_wait*:access_regs6 tests, in which
register contents retrieved by PT_GETREGS are set back by PT_SETREGS.

No new regression is observed in full ATF run.

OK ryo


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/aarch64/aarch64/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/aarch64/aarch64/netbsd32_machdep.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.14 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.15
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.14	Thu Jul  2 13:04:46 2020
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep.c	Thu Oct 15 22:41:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.14 2020/07/02 13:04:46 rin Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.15 2020/10/15 22:41:02 rin Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.14 2020/07/02 13:04:46 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.15 2020/10/15 22:41:02 rin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -198,8 +198,7 @@ netbsd32_process_write_regs(struct lwp *
 	if ((p->p_flag & PK_32) == 0)
 		return EINVAL;
 
-	if ((regs->r_cpsr & ~(SPSR_NZCV | SPSR_A32_T)) != 0 ||
-	regs->r_pc >= VM_MAXUSER_ADDRESS32 ||
+	if (regs->r_pc >= VM_MAXUSER_ADDRESS32 ||
 	regs->r_sp >= VM_MAXUSER_ADDRESS32)
 		return EINVAL;
 
@@ -209,7 +208,7 @@ netbsd32_process_write_regs(struct lwp *
 	tf->tf_reg[14] = regs->r_lr;		/* r14 = lr */
 	tf->tf_pc = regs->r_pc;			/* r15 = pc */
 	tf->tf_spsr &= ~(SPSR_NZCV | SPSR_A32_T);
-	tf->tf_spsr |= regs->r_cpsr;
+	tf->tf_spsr |= regs->r_cpsr & (SPSR_NZCV | SPSR_A32_T);
 
 	/* THUMB CODE? */
 	if (regs->r_pc & 1)



CVS commit: src/sys/arch/aarch64/aarch64

2020-10-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Oct 15 22:30:34 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: fault.c

Log Message:
For cpu_jump_onfault() in data_abort_handler(), stop returning
hard-coded EFAULT and use return value from uvm_fault() instead.

There are some paths that do not call uvm_fault():

(1) For fatalabort case, use EFAULT as before.
(2) When va range is invalid, use EFAULT instead of EINVAL.

These change fixes bytes_transfer_eof_* tests in
sys/lib/libc/sys/t_ptrace_wait*.

Note that without (2) above, some tests like
sys/lib/libc/sys/t_wait:write_error become newly failing.

I've confirmed that there's no new regression in full ATF run.

OK ryo


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/aarch64/fault.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/aarch64/aarch64/fault.c
diff -u src/sys/arch/aarch64/aarch64/fault.c:1.19 src/sys/arch/aarch64/aarch64/fault.c:1.20
--- src/sys/arch/aarch64/aarch64/fault.c:1.19	Sun Aug  9 07:26:20 2020
+++ src/sys/arch/aarch64/aarch64/fault.c	Thu Oct 15 22:30:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: fault.c,v 1.19 2020/08/09 07:26:20 skrll Exp $	*/
+/*	$NetBSD: fault.c,v 1.20 2020/10/15 22:30:34 rin Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.19 2020/08/09 07:26:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.20 2020/10/15 22:30:34 rin Exp $");
 
 #include "opt_compat_netbsd32.h"
 #include "opt_ddb.h"
@@ -134,7 +134,7 @@ data_abort_handler(struct trapframe *tf,
 	vaddr_t va;
 	uint32_t esr, fsc, rw;
 	vm_prot_t ftype;
-	int error = 0, len;
+	int error = EFAULT, len;
 	const bool user = IS_SPSR_USER(tf->tf_spsr) ? true : false;
 	bool is_pan_trap = false;
 
@@ -169,10 +169,8 @@ data_abort_handler(struct trapframe *tf,
 		map = >p_vmspace->vm_map;
 		UVMHIST_LOG(pmaphist, "use user vm_map %p (kernel_map=%p)",
 		   map, kernel_map, 0, 0);
-	} else {
-		error = EINVAL;
+	} else
 		goto do_fault;
-	}
 
 	if ((eclass == ESR_EC_INSN_ABT_EL0) || (eclass == ESR_EC_INSN_ABT_EL1))
 		ftype = VM_PROT_EXECUTE;
@@ -223,7 +221,7 @@ data_abort_handler(struct trapframe *tf,
 	if (curcpu()->ci_intr_depth == 0) {
 		fb = cpu_disable_onfault();
 		if (fb != NULL) {
-			cpu_jump_onfault(tf, fb, EFAULT);
+			cpu_jump_onfault(tf, fb, error);
 			return;
 		}
 	}



CVS commit: src/distrib/sets/lists/tests

2020-10-15 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Thu Oct 15 22:15:08 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: md.amd64 md.i386 mi

Log Message:
Move the new x86 test into x86-specific lists


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/distrib/sets/lists/tests/md.amd64
cvs rdiff -u -r1.5 -r1.6 src/distrib/sets/lists/tests/md.i386
cvs rdiff -u -r1.940 -r1.941 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/tests/md.amd64
diff -u src/distrib/sets/lists/tests/md.amd64:1.13 src/distrib/sets/lists/tests/md.amd64:1.14
--- src/distrib/sets/lists/tests/md.amd64:1.13	Thu Aug 27 15:32:00 2020
+++ src/distrib/sets/lists/tests/md.amd64	Thu Oct 15 22:15:08 2020
@@ -1,4 +1,5 @@
-# $NetBSD: md.amd64,v 1.13 2020/08/27 15:32:00 riastradh Exp $
+# $NetBSD: md.amd64,v 1.14 2020/10/15 22:15:08 mgorny Exp $
+./usr/libdata/debug/usr/tests/sys/x86		tests-sys-debug	compattestfile,atf
 ./usr/tests/kernel/arch/x86/Atffile		tests-obsolete	obsolete
 ./usr/tests/kernel/arch/x86/Kyuafile		tests-obsolete	obsolete
 ./usr/tests/kernel/arch/x86/t_ptrace_wait	tests-obsolete	obsolete
@@ -15,3 +16,7 @@
 ./usr/tests/modules/t_x86_pte			tests-sys-tests	atf,kmod,rump
 ./usr/tests/modules/x86_pte_tester		tests-sys-tests	atf,kmod,rump
 ./usr/tests/modules/x86_pte_tester/x86_pte_tester.kmod tests-sys-tests	atf,kmod,rump
+./usr/tests/sys/x86tests-sys-tests	compattestfile,atf
+./usr/tests/sys/x86/Atffile			tests-sys-tests	compattestfile,atf
+./usr/tests/sys/x86/Kyuafile			tests-sys-tests	compattestfile,atf,kyua
+./usr/tests/sys/x86/t_convert_xmm_s87		tests-sys-tests	compattestfile,atf

Index: src/distrib/sets/lists/tests/md.i386
diff -u src/distrib/sets/lists/tests/md.i386:1.5 src/distrib/sets/lists/tests/md.i386:1.6
--- src/distrib/sets/lists/tests/md.i386:1.5	Sun Apr  2 01:49:52 2017
+++ src/distrib/sets/lists/tests/md.i386	Thu Oct 15 22:15:08 2020
@@ -1,4 +1,5 @@
-# $NetBSD: md.i386,v 1.5 2017/04/02 01:49:52 kamil Exp $
+# $NetBSD: md.i386,v 1.6 2020/10/15 22:15:08 mgorny Exp $
+./usr/libdata/debug/usr/tests/sys/x86		tests-sys-debug	compattestfile,atf
 ./usr/tests/kernel/arch/x86/Atffile		tests-obsolete	obsolete
 ./usr/tests/kernel/arch/x86/Kyuafile		tests-obsolete	obsolete
 ./usr/tests/kernel/arch/x86/t_ptrace_wait	tests-obsolete	obsolete
@@ -7,3 +8,7 @@
 ./usr/tests/kernel/arch/x86/t_ptrace_wait6	tests-obsolete	obsolete
 ./usr/tests/kernel/arch/x86/t_ptrace_waitid	tests-obsolete	obsolete
 ./usr/tests/kernel/arch/x86/t_ptrace_waitpid	tests-obsolete	obsolete
+./usr/tests/sys/x86tests-sys-tests	compattestfile,atf
+./usr/tests/sys/x86/Atffile			tests-sys-tests	compattestfile,atf
+./usr/tests/sys/x86/Kyuafile			tests-sys-tests	compattestfile,atf,kyua
+./usr/tests/sys/x86/t_convert_xmm_s87		tests-sys-tests	compattestfile,atf

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.940 src/distrib/sets/lists/tests/mi:1.941
--- src/distrib/sets/lists/tests/mi:1.940	Thu Oct 15 17:44:44 2020
+++ src/distrib/sets/lists/tests/mi	Thu Oct 15 22:15:08 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.940 2020/10/15 17:44:44 mgorny Exp $
+# $NetBSD: mi,v 1.941 2020/10/15 22:15:08 mgorny Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -191,7 +191,6 @@
 ./usr/libdata/debug/usr/tests/sys/netatalk		tests-sys-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/sys/netinet		tests-sys-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/sys/netinet6		tests-sys-debug		compattestfile,atf
-./usr/libdata/debug/usr/tests/sys/x86			tests-sys-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/syscall			tests-obsolete		obsolete
 ./usr/libdata/debug/usr/tests/usr.bin			tests-usr.bin-debug	compattestfile,atf
 ./usr/libdata/debug/usr/tests/usr.bin/cpio		tests-usr.bin-debug	compattestfile,atf
@@ -4138,10 +4137,6 @@
 ./usr/tests/sys/rc/h_argstests-sys-tests		compattestfile,atf
 ./usr/tests/sys/rc/h_simpletests-sys-tests		compattestfile,atf
 ./usr/tests/sys/rc/t_rc_d_clitests-sys-tests		compattestfile,atf
-./usr/tests/sys/x86	tests-sys-tests		compattestfile,atf
-./usr/tests/sys/x86/Atffiletests-sys-tests		compattestfile,atf
-./usr/tests/sys/x86/Kyuafiletests-sys-tests		compattestfile,atf,kyua
-./usr/tests/sys/x86/t_convert_xmm_s87			tests-sys-tests		compattestfile,atf
 ./usr/tests/syscall	tests-obsolete		obsolete
 ./usr/tests/syscall/Atffiletests-obsolete		obsolete
 ./usr/tests/syscall/t_accesstests-obsolete		obsolete



CVS commit: src/sys/arch/aarch64/aarch64

2020-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 15 21:14:15 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: bus_space.c

Log Message:
Reduce scope of memory barriers use in bus_space_barrier() implementation.

Instead of always "dsb sy", use "dsb ishld" for reads, "dsb ishst" for
writes, and "dsh ish" for reads and writes.

Ok skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/bus_space.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/aarch64/aarch64/bus_space.c
diff -u src/sys/arch/aarch64/aarch64/bus_space.c:1.10 src/sys/arch/aarch64/aarch64/bus_space.c:1.11
--- src/sys/arch/aarch64/aarch64/bus_space.c:1.10	Sat Sep  5 16:44:54 2020
+++ src/sys/arch/aarch64/aarch64/bus_space.c	Thu Oct 15 21:14:15 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.10 2020/09/05 16:44:54 jakllsch Exp $ */
+/* $NetBSD: bus_space.c,v 1.11 2020/10/15 21:14:15 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: bus_space.c,v 1.10 2020/09/05 16:44:54 jakllsch Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bus_space.c,v 1.11 2020/10/15 21:14:15 jmcneill Exp $");
 
 #include 
 #include 
@@ -38,6 +38,7 @@ __KERNEL_RCSID(1, "$NetBSD: bus_space.c,
 #include 
 #include 
 
+#include 
 
 /* Prototypes for all the bus_space structure functions */
 bs_protos(generic)
@@ -612,8 +613,17 @@ generic_bs_barrier(void *t, bus_space_ha
 {
 	flags &= BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE;
 
-	if (flags != 0)
-		__asm __volatile ("dmb sy" ::: "memory");
+	switch (flags) {
+	case BUS_SPACE_BARRIER_READ:
+		dmb(ishld);
+		break;
+	case BUS_SPACE_BARRIER_WRITE:
+		dmb(ishst);
+		break;
+	case BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE:
+		dmb(ish);
+		break;
+	}
 }
 
 void *



CVS commit: [netbsd-9] src/doc

2020-10-15 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Oct 15 19:39:03 UTC 2020

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

Log Message:
ticket 1113


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.123 -r1.1.2.124 src/doc/CHANGES-9.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-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.123 src/doc/CHANGES-9.1:1.1.2.124
--- src/doc/CHANGES-9.1:1.1.2.123	Thu Oct 15 12:07:11 2020
+++ src/doc/CHANGES-9.1	Thu Oct 15 19:39:02 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.123 2020/10/15 12:07:11 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.124 2020/10/15 19:39:02 bouyer Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -5193,3 +5193,101 @@ xsrc/external/mit/xf86-input-mouse/dist/
 	them to the X server.
 	[jmcneill, ticket #1112]
 
+usr.sbin/sysinst/Makefile.inc			1.34
+usr.sbin/sysinst/arch/acorn32/md.c		1.7
+usr.sbin/sysinst/arch/alpha/md.c		1.9
+usr.sbin/sysinst/arch/amd64/md.h		1.9
+usr.sbin/sysinst/arch/amiga/md.c		1.6
+usr.sbin/sysinst/arch/arc/md.c			1.13
+usr.sbin/sysinst/arch/atari/md.c		1.7
+usr.sbin/sysinst/arch/bebox/md.c		1.9
+usr.sbin/sysinst/arch/cats/md.c			1.5
+usr.sbin/sysinst/arch/cobalt/md.c		1.13,1.14
+usr.sbin/sysinst/arch/cobalt/md.h		1.6
+usr.sbin/sysinst/arch/dummy/md.c		1.6
+usr.sbin/sysinst/arch/emips/md.c		1.9
+usr.sbin/sysinst/arch/evbarm/Makefile		1.3
+usr.sbin/sysinst/arch/evbarm/md.c		1.17-1.19
+usr.sbin/sysinst/arch/evbarm/md.h		1.6,1.7
+usr.sbin/sysinst/arch/evbarm/msg.md.en		1.2
+usr.sbin/sysinst/arch/evbmips/md.c		1.9
+usr.sbin/sysinst/arch/evbppc/md.c		1.9
+usr.sbin/sysinst/arch/evbsh3/md.c		1.6
+usr.sbin/sysinst/arch/ews4800mips/md.c		1.7
+usr.sbin/sysinst/arch/hp300/md.c		1.11
+usr.sbin/sysinst/arch/hpcarm/md.c		1.9
+usr.sbin/sysinst/arch/hpcmips/md.c		1.9
+usr.sbin/sysinst/arch/hpcsh/md.c		1.10
+usr.sbin/sysinst/arch/hppa/md.c			1.8
+usr.sbin/sysinst/arch/i386/md.c			1.31,1.32
+usr.sbin/sysinst/arch/i386/md.h			1.8
+usr.sbin/sysinst/arch/landisk/md.c		1.14
+usr.sbin/sysinst/arch/luna68k/md.c		1.9
+usr.sbin/sysinst/arch/mac68k/Makefile		1.3
+usr.sbin/sysinst/arch/mac68k/md.c		1.10
+usr.sbin/sysinst/arch/macppc/md.c		1.6
+usr.sbin/sysinst/arch/mipsco/md.c		1.8
+usr.sbin/sysinst/arch/mvme68k/md.c		1.11
+usr.sbin/sysinst/arch/news68k/md.c		1.7
+usr.sbin/sysinst/arch/newsmips/md.c		1.6
+usr.sbin/sysinst/arch/ofppc/md.c		1.11,1.12
+usr.sbin/sysinst/arch/playstation2/md.c		1.9
+usr.sbin/sysinst/arch/pmax/md.c			1.8
+usr.sbin/sysinst/arch/prep/md.c			1.13
+usr.sbin/sysinst/arch/sandpoint/md.c		1.9
+usr.sbin/sysinst/arch/sgimips/md.c		1.9
+usr.sbin/sysinst/arch/shark/md.c		1.6
+usr.sbin/sysinst/arch/sparc/md.c		1.6
+usr.sbin/sysinst/arch/sparc64/md.c		1.6
+usr.sbin/sysinst/arch/vax/md.c			1.7
+usr.sbin/sysinst/arch/x68k/md.c			1.11
+usr.sbin/sysinst/arch/zaurus/md.c		1.9,1.10
+usr.sbin/sysinst/bsddisklabel.c			1.40-1.56
+usr.sbin/sysinst/defs.h1.56-1.61,1.63-1.67
+usr.sbin/sysinst/disklabel.c			1.36-1.42
+usr.sbin/sysinst/disks.c			1.66-1.71
+usr.sbin/sysinst/gpt.c1.19-1.22
+usr.sbin/sysinst/install.c			1.15-1.19
+usr.sbin/sysinst/label.c			1.21-1.30
+usr.sbin/sysinst/main.c1.21-1.25
+usr.sbin/sysinst/mbr.c1.32-1.36
+usr.sbin/sysinst/mbr.h1.5,1.6
+usr.sbin/sysinst/msg.mi.de			1.23,1.24
+usr.sbin/sysinst/msg.mi.en			1.30-1.32
+usr.sbin/sysinst/msg.mi.es			1.24-1.26
+usr.sbin/sysinst/msg.mi.fr			1.28-1.31
+usr.sbin/sysinst/msg.mi.pl			1.31,1.32
+usr.sbin/sysinst/part_edit.c			1.17
+usr.sbin/sysinst/part_edit.c			1.18-1.24
+usr.sbin/sysinst/partitions.c			1.11
+usr.sbin/sysinst/partitions.h			1.16-1.19
+usr.sbin/sysinst/target.c			1.13,1.14
+usr.sbin/sysinst/util.c1.43,1.44,1.46-1.48
+
+	Various updates to the installer:
+	 - PR misc/54886: bump threshold for automatic/default creation of a
+	   tmpfs /tmp to 384 MB ram.
+	 - fix partition size limit checks.
+	 - For all non-root partitions default to FFSv2.
+	 - PR 55202: disable swapping if we started it due to low ram.
+	 - PR 55572: avoid crash when answering the mount point prompt
+	   for a previously empty mount point with an emptry sting.
+	 - Fix display of timezone selection menu.
+	 - PR 55377: mark boot partitions in the partition size display.
+	 - PR 55379: avoid creating bogus /etc/fstab lines for /dev/cd* if
+	   no cdrom is available.
+	 - PR 55381: try to deal with moved (but not yet saved) partitions when
+	   calculating free space
+	 - PR 55382: make ext2 partitions show up in the outer (MBR) partition
+	   table.
+	 - PR 55384: fix disk reservation in machine dependend support code.
+	 - When creating a MSDOS file system marked to need newfs, always
+	   newfs it (instead of trying to preserve existing MSDOS file
+	   systems, which sometimes went wrong).
+	 - PR 55536: offer to delete partition tables and replace them with
+	   some other partitioning scheme.
+	 - PR 

CVS commit: src/sys/arch/sh3/sh3

2020-10-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 15 18:58:59 UTC 2020

Modified Files:
src/sys/arch/sh3/sh3: process_machdep.c

Log Message:
Add missing 'error' declaration


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sh3/sh3/process_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/sh3/sh3/process_machdep.c
diff -u src/sys/arch/sh3/sh3/process_machdep.c:1.23 src/sys/arch/sh3/sh3/process_machdep.c:1.24
--- src/sys/arch/sh3/sh3/process_machdep.c:1.23	Thu Oct 15 17:37:36 2020
+++ src/sys/arch/sh3/sh3/process_machdep.c	Thu Oct 15 18:58:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.23 2020/10/15 17:37:36 mgorny Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.24 2020/10/15 18:58:59 martin Exp $	*/
 
 /*
  * Copyright (c) 1993 The Regents of the University of California.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.23 2020/10/15 17:37:36 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.24 2020/10/15 18:58:59 martin Exp $");
 
 #include 
 #include 
@@ -188,7 +188,7 @@ ptrace_machdep_dorequest(struct lwp *l, 
 {
 	struct uio uio;
 	struct iovec iov;
-	int write = 0;
+	int write = 0, error;
 
 	switch (req) {
 	default:



CVS commit: src/sys/arch/powerpc/powerpc

2020-10-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 15 18:57:16 UTC 2020

Modified Files:
src/sys/arch/powerpc/powerpc: process_machdep.c

Log Message:
Add missing 'error' declaration


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/powerpc/powerpc/process_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/powerpc/powerpc/process_machdep.c
diff -u src/sys/arch/powerpc/powerpc/process_machdep.c:1.40 src/sys/arch/powerpc/powerpc/process_machdep.c:1.41
--- src/sys/arch/powerpc/powerpc/process_machdep.c:1.40	Thu Oct 15 17:37:36 2020
+++ src/sys/arch/powerpc/powerpc/process_machdep.c	Thu Oct 15 18:57:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.40 2020/10/15 17:37:36 mgorny Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.41 2020/10/15 18:57:16 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.40 2020/10/15 17:37:36 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.41 2020/10/15 18:57:16 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -193,7 +193,7 @@ ptrace_machdep_dorequest(struct lwp *l, 
 {
 	struct uio uio;
 	struct iovec iov;
-	int write = 0;
+	int write = 0, error;
 
 	switch (req) {
 	case PT_SETVECREGS:



CVS commit: src

2020-10-15 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Thu Oct 15 17:44:45 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/etc/mtree: NetBSD.dist.tests
src/tests/sys: Makefile
Added Files:
src/tests/sys/x86: Makefile t_convert_xmm_s87.c

Log Message:
Add tests for process_xmm_to_s87() and process_s87_to_xmm()


To generate a diff of this commit:
cvs rdiff -u -r1.939 -r1.940 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.180 -r1.181 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.4 -r1.5 src/tests/sys/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/sys/x86/Makefile \
src/tests/sys/x86/t_convert_xmm_s87.c

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.939 src/distrib/sets/lists/tests/mi:1.940
--- src/distrib/sets/lists/tests/mi:1.939	Thu Oct  8 19:09:08 2020
+++ src/distrib/sets/lists/tests/mi	Thu Oct 15 17:44:44 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.939 2020/10/08 19:09:08 rillig Exp $
+# $NetBSD: mi,v 1.940 2020/10/15 17:44:44 mgorny Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -191,6 +191,7 @@
 ./usr/libdata/debug/usr/tests/sys/netatalk		tests-sys-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/sys/netinet		tests-sys-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/sys/netinet6		tests-sys-debug		compattestfile,atf
+./usr/libdata/debug/usr/tests/sys/x86			tests-sys-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/syscall			tests-obsolete		obsolete
 ./usr/libdata/debug/usr/tests/usr.bin			tests-usr.bin-debug	compattestfile,atf
 ./usr/libdata/debug/usr/tests/usr.bin/cpio		tests-usr.bin-debug	compattestfile,atf
@@ -4137,6 +4138,10 @@
 ./usr/tests/sys/rc/h_argstests-sys-tests		compattestfile,atf
 ./usr/tests/sys/rc/h_simpletests-sys-tests		compattestfile,atf
 ./usr/tests/sys/rc/t_rc_d_clitests-sys-tests		compattestfile,atf
+./usr/tests/sys/x86	tests-sys-tests		compattestfile,atf
+./usr/tests/sys/x86/Atffiletests-sys-tests		compattestfile,atf
+./usr/tests/sys/x86/Kyuafiletests-sys-tests		compattestfile,atf,kyua
+./usr/tests/sys/x86/t_convert_xmm_s87			tests-sys-tests		compattestfile,atf
 ./usr/tests/syscall	tests-obsolete		obsolete
 ./usr/tests/syscall/Atffiletests-obsolete		obsolete
 ./usr/tests/syscall/t_accesstests-obsolete		obsolete

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.180 src/etc/mtree/NetBSD.dist.tests:1.181
--- src/etc/mtree/NetBSD.dist.tests:1.180	Wed Sep 30 20:20:53 2020
+++ src/etc/mtree/NetBSD.dist.tests	Thu Oct 15 17:44:44 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.180 2020/09/30 20:20:53 roy Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.181 2020/10/15 17:44:44 mgorny Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -171,6 +171,7 @@
 ./usr/libdata/debug/usr/tests/sys/netatalk
 ./usr/libdata/debug/usr/tests/sys/netinet
 ./usr/libdata/debug/usr/tests/sys/netinet6
+./usr/libdata/debug/usr/tests/sys/x86
 ./usr/libdata/debug/usr/tests/usr.bin
 ./usr/libdata/debug/usr/tests/usr.bin/cpio
 ./usr/libdata/debug/usr/tests/usr.bin/id
@@ -402,6 +403,7 @@
 ./usr/tests/sys/netinet
 ./usr/tests/sys/netinet6
 ./usr/tests/sys/rc
+./usr/tests/sys/x86
 ./usr/tests/usr.bin
 ./usr/tests/usr.bin/awk
 ./usr/tests/usr.bin/basename

Index: src/tests/sys/Makefile
diff -u src/tests/sys/Makefile:1.4 src/tests/sys/Makefile:1.5
--- src/tests/sys/Makefile:1.4	Tue Jun 30 20:32:11 2020
+++ src/tests/sys/Makefile	Thu Oct 15 17:44:44 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2020/06/30 20:32:11 riastradh Exp $
+# $NetBSD: Makefile,v 1.5 2020/10/15 17:44:44 mgorny Exp $
 
 .include 
 
@@ -10,5 +10,8 @@ TESTS_SUBDIRS+=	netatalk
 TESTS_SUBDIRS+=	netinet
 TESTS_SUBDIRS+=	netinet6
 TESTS_SUBDIRS+=	rc
+.if ${MACHINE} == amd64 || ${MACHINE} == i386
+TESTS_SUBDIRS+=	x86
+.endif
 
 .include 

Added files:

Index: src/tests/sys/x86/Makefile
diff -u /dev/null src/tests/sys/x86/Makefile:1.1
--- /dev/null	Thu Oct 15 17:44:45 2020
+++ src/tests/sys/x86/Makefile	Thu Oct 15 17:44:44 2020
@@ -0,0 +1,11 @@
+# $NetBSD: Makefile,v 1.1 2020/10/15 17:44:44 mgorny Exp $
+#
+
+.include 
+
+TESTSDIR=	${TESTSBASE}/sys/x86
+CPPFLAGS+=	-I${NETBSDSRCDIR}/sys
+
+TESTS_C=	t_convert_xmm_s87
+
+.include 
Index: src/tests/sys/x86/t_convert_xmm_s87.c
diff -u /dev/null src/tests/sys/x86/t_convert_xmm_s87.c:1.1
--- /dev/null	Thu Oct 15 17:44:45 2020
+++ src/tests/sys/x86/t_convert_xmm_s87.c	Thu Oct 15 17:44:44 2020
@@ -0,0 +1,211 @@
+/*	$NetBSD: t_convert_xmm_s87.c,v 1.1 2020/10/15 17:44:44 mgorny Exp $	*/
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Michał Górny for Moritz Systems Technology Company Sp. z o.o.
+ *
+ * Redistribution and use in 

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

2020-10-15 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Thu Oct 15 17:43:30 UTC 2020

Modified Files:
src/sys/arch/x86/x86: convert_xmm_s87.c

Log Message:
Remove unnecessary  include


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/x86/convert_xmm_s87.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/convert_xmm_s87.c
diff -u src/sys/arch/x86/x86/convert_xmm_s87.c:1.6 src/sys/arch/x86/x86/convert_xmm_s87.c:1.7
--- src/sys/arch/x86/x86/convert_xmm_s87.c:1.6	Thu Oct 15 17:43:08 2020
+++ src/sys/arch/x86/x86/convert_xmm_s87.c	Thu Oct 15 17:43:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: convert_xmm_s87.c,v 1.6 2020/10/15 17:43:08 mgorny Exp $	*/
+/*	$NetBSD: convert_xmm_s87.c,v 1.7 2020/10/15 17:43:30 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -30,11 +30,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: convert_xmm_s87.c,v 1.6 2020/10/15 17:43:08 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: convert_xmm_s87.c,v 1.7 2020/10/15 17:43:30 mgorny Exp $");
 
 
 #include 
-#include 
 #include 
 
 void



CVS commit: src

2020-10-15 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Thu Oct 15 17:43:09 UTC 2020

Modified Files:
src/sys/arch/x86/x86: convert_xmm_s87.c
src/tests/lib/libc/sys: t_ptrace_x86_wait.h

Log Message:
Fix s87_tw reconstruction to correctly indicate register states

Fix the code reconstructing s87_tw (full tag word) from fx_sw (abridged
tag word) to correctly represent all register states.  The previous code
only distinguished between empty/non-empty registers, and assigned
'regular value' to all non-empty registers.  The new code explicitly
distinguishes the two other tag word values: empty and special.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/x86/convert_xmm_s87.c
cvs rdiff -u -r1.27 -r1.28 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

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

Modified files:

Index: src/sys/arch/x86/x86/convert_xmm_s87.c
diff -u src/sys/arch/x86/x86/convert_xmm_s87.c:1.5 src/sys/arch/x86/x86/convert_xmm_s87.c:1.6
--- src/sys/arch/x86/x86/convert_xmm_s87.c:1.5	Thu Oct 15 17:42:31 2020
+++ src/sys/arch/x86/x86/convert_xmm_s87.c	Thu Oct 15 17:43:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: convert_xmm_s87.c,v 1.5 2020/10/15 17:42:31 mgorny Exp $	*/
+/*	$NetBSD: convert_xmm_s87.c,v 1.6 2020/10/15 17:43:08 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: convert_xmm_s87.c,v 1.5 2020/10/15 17:42:31 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: convert_xmm_s87.c,v 1.6 2020/10/15 17:43:08 mgorny Exp $");
 
 
 #include 
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: convert_xmm_
 void
 process_xmm_to_s87(const struct fxsave *sxmm, struct save87 *s87)
 {
-	unsigned int tag, ab_tag;
+	unsigned int tag, ab_tag, st;
 	const struct fpaccfx *fx_reg;
 	struct fpacc87 *s87_reg;
 	int i;
@@ -95,12 +95,28 @@ process_xmm_to_s87(const struct fxsave *
 		return;
 	}
 
+	/* For ST(i), i = fpu_reg - top, we start with fpu_reg=7. */
+	st = 7 - ((sxmm->fx_sw >> 11) & 7);
 	tag = 0;
-	/* Separate bits of abridged tag word with zeros */
-	for (i = 0x80; i != 0; tag <<= 1, i >>= 1)
-		tag |= ab_tag & i;
-	/* Replicate and invert so that 0 => 0b11 and 1 => 0b00 */
-	s87->s87_tw = (tag | tag >> 1) ^ 0x;
+	for (i = 0x80; i != 0; i >>= 1) {
+		tag <<= 2;
+		if (ab_tag & i) {
+			unsigned int exp;
+			/* Non-empty - we need to check ST(i) */
+			fx_reg = >fx_87_ac[st];
+			exp = fx_reg->r.f87_exp_sign & 0x7fff;
+			if (exp == 0) {
+if (fx_reg->r.f87_mantissa == 0)
+	tag |= 1; /* Zero */
+else
+	tag |= 2; /* Denormal */
+			} else if (exp == 0x7fff)
+tag |= 2; /* Infinity or NaN */
+		} else
+			tag |= 3; /* Empty */
+		st = (st - 1) & 7;
+	}
+	s87->s87_tw = tag;
 }
 
 void

Index: src/tests/lib/libc/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.27 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.28
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.27	Fri Oct  9 17:43:30 2020
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Thu Oct 15 17:43:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.27 2020/10/09 17:43:30 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.28 2020/10/15 17:43:09 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -3367,10 +3367,8 @@ x86_register_test(enum x86_test_regset r
 expected_fpu.cw);
 ATF_CHECK_EQ(fpr.fstate.s87_sw,
 expected_fpu.sw);
-#if 0 /* TODO: translation from FXSAVE is broken */
 ATF_CHECK_EQ(fpr.fstate.s87_tw,
 expected_fpu.tw);
-#endif
 ATF_CHECK_EQ(fpr.fstate.s87_opcode,
 expected_fpu.opcode);
 ATF_CHECK_EQ(fpr.fstate.s87_ip.fa_32.fa_off,



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

2020-10-15 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Thu Oct 15 17:42:31 UTC 2020

Added Files:
src/sys/arch/x86/x86: convert_xmm_s87.c

Log Message:
Revert "Merge convert_xmm_s87.c into fpu.c"

I am going to add ATF tests for these two functions, and having them
in a separate file will make it more convenient to build and run them
in userspace.


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

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

Added files:

Index: src/sys/arch/x86/x86/convert_xmm_s87.c
diff -u /dev/null src/sys/arch/x86/x86/convert_xmm_s87.c:1.5
--- /dev/null	Thu Oct 15 17:42:31 2020
+++ src/sys/arch/x86/x86/convert_xmm_s87.c	Thu Oct 15 17:42:31 2020
@@ -0,0 +1,156 @@
+/*	$NetBSD: convert_xmm_s87.c,v 1.5 2020/10/15 17:42:31 mgorny Exp $	*/
+
+/*-
+ * Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum; by Jason R. Thorpe of Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: convert_xmm_s87.c,v 1.5 2020/10/15 17:42:31 mgorny Exp $");
+
+
+#include 
+#include 
+#include 
+
+void
+process_xmm_to_s87(const struct fxsave *sxmm, struct save87 *s87)
+{
+	unsigned int tag, ab_tag;
+	const struct fpaccfx *fx_reg;
+	struct fpacc87 *s87_reg;
+	int i;
+
+	/*
+	 * For historic reasons core dumps and ptrace all use the old save87
+	 * layout.  Convert the important parts.
+	 * getucontext gets what we give it.
+	 * setucontext should return something given by getucontext, but
+	 * we are (at the moment) willing to change it.
+	 *
+	 * It really isn't worth setting the 'tag' bits to 01 (zero) or
+	 * 10 (NaN etc) since the processor will set any internal bits
+	 * correctly when the value is loaded (the 287 believed them).
+	 *
+	 * Additionally the s87_tw and s87_tw are 'indexed' by the actual
+	 * register numbers, whereas the registers themselves have ST(0)
+	 * first. Pairing the values and tags can only be done with
+	 * reference to the 'top of stack'.
+	 *
+	 * If any x87 registers are used, they will typically be from
+	 * r7 downwards - so the high bits of the tag register indicate
+	 * used registers. The conversions are not optimised for this.
+	 *
+	 * The ABI we use requires the FP stack to be empty on every
+	 * function call. I think this means that the stack isn't expected
+	 * to overflow - overflow doesn't drop a core in my testing.
+	 *
+	 * Note that this code writes to all of the 's87' structure that
+	 * actually gets written to userspace.
+	 */
+
+	/* FPU control/status */
+	s87->s87_cw = sxmm->fx_cw;
+	s87->s87_sw = sxmm->fx_sw;
+	/* tag word handled below */
+	s87->s87_ip = sxmm->fx_ip;
+	s87->s87_opcode = sxmm->fx_opcode;
+	s87->s87_dp = sxmm->fx_dp;
+
+	/* FP registers (in stack order) */
+	fx_reg = sxmm->fx_87_ac;
+	s87_reg = s87->s87_ac;
+	for (i = 0; i < 8; fx_reg++, s87_reg++, i++)
+		*s87_reg = fx_reg->r;
+
+	/* Tag word and registers. */
+	ab_tag = sxmm->fx_tw & 0xff;	/* Bits set if valid */
+	if (ab_tag == 0) {
+		/* none used */
+		s87->s87_tw = 0x;
+		return;
+	}
+
+	tag = 0;
+	/* Separate bits of abridged tag word with zeros */
+	for (i = 0x80; i != 0; tag <<= 1, i >>= 1)
+		tag |= ab_tag & i;
+	/* Replicate and invert so that 0 => 0b11 and 1 => 0b00 */
+	s87->s87_tw = (tag | tag >> 1) ^ 0x;
+}
+
+void
+process_s87_to_xmm(const struct save87 *s87, struct fxsave *sxmm)
+{
+	unsigned int tag, ab_tag;
+	struct fpaccfx *fx_reg;
+	const struct fpacc87 *s87_reg;
+	int i;
+
+	/*
+	 

CVS commit: src/sys/arch

2020-10-15 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Thu Oct 15 17:40:14 UTC 2020

Modified Files:
src/sys/arch/amd64/conf: files.amd64
src/sys/arch/i386/conf: files.i386
src/sys/arch/x86/include: fpu.h
src/sys/arch/x86/x86: fpu.c

Log Message:
Revert "Merge convert_xmm_s87.c into fpu.c"

I am going to add ATF tests for these two functions, and having them
in a separate file will make it more convenient to build and run them
in userspace.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/amd64/conf/files.amd64
cvs rdiff -u -r1.404 -r1.405 src/sys/arch/i386/conf/files.i386
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/x86/include/fpu.h
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/x86/x86/fpu.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/conf/files.amd64
diff -u src/sys/arch/amd64/conf/files.amd64:1.116 src/sys/arch/amd64/conf/files.amd64:1.117
--- src/sys/arch/amd64/conf/files.amd64:1.116	Sat Apr 25 15:26:16 2020
+++ src/sys/arch/amd64/conf/files.amd64	Thu Oct 15 17:40:13 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.amd64,v 1.116 2020/04/25 15:26:16 bouyer Exp $
+#	$NetBSD: files.amd64,v 1.117 2020/10/15 17:40:13 mgorny Exp $
 #
 # new style config file for amd64 architecture
 #
@@ -51,6 +51,7 @@ file	arch/amd64/amd64/process_machdep.c	
 file	arch/amd64/amd64/trap.c			machdep
 file	arch/x86/x86/fpu.c			machdep
 file	arch/x86/x86/dbregs.c			machdep
+file	arch/x86/x86/convert_xmm_s87.c		machdep
 file	arch/x86/x86/spectre.c			machdep & !xenpv
 file	arch/amd64/amd64/lock_stubs.S		machdep
 file	dev/cons.cmachdep

Index: src/sys/arch/i386/conf/files.i386
diff -u src/sys/arch/i386/conf/files.i386:1.404 src/sys/arch/i386/conf/files.i386:1.405
--- src/sys/arch/i386/conf/files.i386:1.404	Mon Jun 29 23:32:24 2020
+++ src/sys/arch/i386/conf/files.i386	Thu Oct 15 17:40:14 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i386,v 1.404 2020/06/29 23:32:24 riastradh Exp $
+#	$NetBSD: files.i386,v 1.405 2020/10/15 17:40:14 mgorny Exp $
 #
 # new style config file for i386 architecture
 #
@@ -69,6 +69,7 @@ file	arch/i386/i386/machdep.c
 file 	arch/i386/i386/longrun.c
 file	arch/i386/i386/mtrr_k6.c	mtrr
 file	arch/i386/i386/process_machdep.c
+file	arch/x86/x86/convert_xmm_s87.c
 file	arch/i386/i386/trap.c
 file	dev/cons.c
 file	arch/x86/x86/fpu.c

Index: src/sys/arch/x86/include/fpu.h
diff -u src/sys/arch/x86/include/fpu.h:1.21 src/sys/arch/x86/include/fpu.h:1.22
--- src/sys/arch/x86/include/fpu.h:1.21	Sun Jun 14 16:12:05 2020
+++ src/sys/arch/x86/include/fpu.h	Thu Oct 15 17:40:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.h,v 1.21 2020/06/14 16:12:05 riastradh Exp $	*/
+/*	$NetBSD: fpu.h,v 1.22 2020/10/15 17:40:14 mgorny Exp $	*/
 
 #ifndef	_X86_FPU_H_
 #define	_X86_FPU_H_
@@ -24,6 +24,9 @@ void fpu_set_default_cw(struct lwp *, un
 void fputrap(struct trapframe *);
 void fpudna(struct trapframe *);
 
+void process_xmm_to_s87(const struct fxsave *, struct save87 *);
+void process_s87_to_xmm(const struct save87 *, struct fxsave *);
+
 void fpu_clear(struct lwp *, unsigned int);
 void fpu_sigreset(struct lwp *);
 

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.74 src/sys/arch/x86/x86/fpu.c:1.75
--- src/sys/arch/x86/x86/fpu.c:1.74	Sun Aug  2 18:23:33 2020
+++ src/sys/arch/x86/x86/fpu.c	Thu Oct 15 17:40:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.74 2020/08/02 18:23:33 riastradh Exp $	*/
+/*	$NetBSD: fpu.c,v 1.75 2020/10/15 17:40:14 mgorny Exp $	*/
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.74 2020/08/02 18:23:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.75 2020/10/15 17:40:14 mgorny Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -663,126 +663,6 @@ fpu_sigreset(struct lwp *l)
 	}
 }
 
-/* -- */
-
-static void
-process_xmm_to_s87(const struct fxsave *sxmm, struct save87 *s87)
-{
-	unsigned int tag, ab_tag;
-	const struct fpaccfx *fx_reg;
-	struct fpacc87 *s87_reg;
-	int i;
-
-	/*
-	 * For historic reasons core dumps and ptrace all use the old save87
-	 * layout.  Convert the important parts.
-	 * getucontext gets what we give it.
-	 * setucontext should return something given by getucontext, but
-	 * we are (at the moment) willing to change it.
-	 *
-	 * It really isn't worth setting the 'tag' bits to 01 (zero) or
-	 * 10 (NaN etc) since the processor will set any internal bits
-	 * correctly when the value is loaded (the 287 believed them).
-	 *
-	 * Additionally the s87_tw and s87_tw are 'indexed' by the actual
-	 * register numbers, whereas the registers themselves have ST(0)
-	 * first. Pairing the values and tags can only be done with
-	 * reference to the 'top of stack'.
-	 *
-	 * If any x87 registers are used, they will typically be from
-	 * r7 downwards - so 

CVS commit: src/sys/sys

2020-10-15 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Thu Oct 15 17:38:41 UTC 2020

Modified Files:
src/sys/sys: param.h

Log Message:
9.99.74 changes ptrace_machdep_dorequest() to fix LWP support


To generate a diff of this commit:
cvs rdiff -u -r1.676 -r1.677 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/sys/param.h
diff -u src/sys/sys/param.h:1.676 src/sys/sys/param.h:1.677
--- src/sys/sys/param.h:1.676	Wed Sep 16 13:42:05 2020
+++ src/sys/sys/param.h	Thu Oct 15 17:38:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.676 2020/09/16 13:42:05 roy Exp $	*/
+/*	$NetBSD: param.h,v 1.677 2020/10/15 17:38:41 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999007300	/* NetBSD 9.99.73 */
+#define	__NetBSD_Version__	999007400	/* NetBSD 9.99.74 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys

2020-10-15 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Thu Oct 15 17:37:36 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: process_machdep.c
src/sys/arch/i386/i386: process_machdep.c
src/sys/arch/powerpc/include: ptrace.h
src/sys/arch/powerpc/powerpc: process_machdep.c
src/sys/arch/sh3/include: ptrace.h
src/sys/arch/sh3/sh3: process_machdep.c
src/sys/kern: sys_ptrace_common.c
src/sys/sys: ptrace.h

Log Message:
Fix the machine-dependent ptrace requests to respect LWP number

Fix the machine-dependent ptrace register-related requests (e.g.
PT_GETXMMREGS, PT_GETXSTATE on x86) to correctly respect the LWP number
passed as the data argument.  Before this change, these requests
did not operate on the requested LWP of a multithreaded program.

This change required moving ptrace_update_lwp() out of unit scope,
and changing ptrace_machdep_dorequest() function to take a pointer
to pointer as the second argument, consistently with ptrace_regs().

I am planning to extend the ATF ptrace() register tests in the future
to check for regressions in multithreaded programs, as time permits.

Reviewed by kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/amd64/amd64/process_machdep.c
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/i386/i386/process_machdep.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/powerpc/include/ptrace.h
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/powerpc/powerpc/process_machdep.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sh3/include/ptrace.h
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sh3/sh3/process_machdep.c
cvs rdiff -u -r1.83 -r1.84 src/sys/kern/sys_ptrace_common.c
cvs rdiff -u -r1.70 -r1.71 src/sys/sys/ptrace.h

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

Modified files:

Index: src/sys/arch/amd64/amd64/process_machdep.c
diff -u src/sys/arch/amd64/amd64/process_machdep.c:1.47 src/sys/arch/amd64/amd64/process_machdep.c:1.48
--- src/sys/arch/amd64/amd64/process_machdep.c:1.47	Wed Nov 27 09:16:58 2019
+++ src/sys/arch/amd64/amd64/process_machdep.c	Thu Oct 15 17:37:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.47 2019/11/27 09:16:58 rin Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.48 2020/10/15 17:37:35 mgorny Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.47 2019/11/27 09:16:58 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.48 2020/10/15 17:37:35 mgorny Exp $");
 
 #include "opt_xen.h"
 #include 
@@ -307,7 +307,7 @@ process_machdep_write_xstate(struct lwp 
 int
 ptrace_machdep_dorequest(
 struct lwp *l,
-struct lwp *lt,
+struct lwp **lt,
 int req,
 void *addr,
 int data
@@ -326,7 +326,9 @@ ptrace_machdep_dorequest(
 		/* FALLTHROUGH */
 	case PT_GETXSTATE:
 		/* write = false done above. */
-		if (!process_machdep_validfpu(lt->l_proc))
+		if ((error = ptrace_update_lwp((*lt)->l_proc, lt, data)) != 0)
+			return error;
+		if (!process_machdep_validfpu((*lt)->l_proc))
 			return EINVAL;
 		if (__predict_false(l->l_proc->p_flag & PK_32)) {
 			struct netbsd32_iovec user_iov;
@@ -357,7 +359,7 @@ ptrace_machdep_dorequest(
 		uio.uio_resid = iov.iov_len;
 		uio.uio_rw = write ? UIO_WRITE : UIO_READ;
 		uio.uio_vmspace = vm;
-		error = process_machdep_doxstate(l, lt, );
+		error = process_machdep_doxstate(l, *lt, );
 		uvmspace_free(vm);
 		return error;
 
@@ -367,8 +369,10 @@ ptrace_machdep_dorequest(
 		/* FALLTHROUGH */
 	case PT_GETXMMREGS:		/* only for COMPAT_NETBSD32 */
 		/* write = false done above. */
+		if ((error = ptrace_update_lwp((*lt)->l_proc, lt, data)) != 0)
+			return error;
 		MODULE_HOOK_CALL(netbsd32_process_doxmmregs_hook,
-		(l, lt, addr, write), EINVAL, error);
+		(l, *lt, addr, write), EINVAL, error);
 		return error;
 	}
 

Index: src/sys/arch/i386/i386/process_machdep.c
diff -u src/sys/arch/i386/i386/process_machdep.c:1.94 src/sys/arch/i386/i386/process_machdep.c:1.95
--- src/sys/arch/i386/i386/process_machdep.c:1.94	Tue Aug  6 02:04:43 2019
+++ src/sys/arch/i386/i386/process_machdep.c	Thu Oct 15 17:37:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.94 2019/08/06 02:04:43 kamil Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.95 2020/10/15 17:37:35 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.94 2019/08/06 02:04:43 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.95 2020/10/15 17:37:35 mgorny Exp $");
 
 #include "opt_ptrace.h"
 
@@ -273,7 +273,7 @@ process_machdep_write_xmmregs(struct lwp
 int
 ptrace_machdep_dorequest(
 struct lwp *l,
-struct lwp *lt,
+struct lwp **lt,
 int req,
 void *addr,
 int data
@@ -293,7 +293,9 @@ ptrace_machdep_dorequest(
 		/* FALLTHROUGH */
 	case 

CVS commit: [netbsd-9] src/doc

2020-10-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 15 12:07:11 UTC 2020

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

Log Message:
Ticket #1112


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.122 -r1.1.2.123 src/doc/CHANGES-9.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-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.122 src/doc/CHANGES-9.1:1.1.2.123
--- src/doc/CHANGES-9.1:1.1.2.122	Mon Oct 12 10:27:57 2020
+++ src/doc/CHANGES-9.1	Thu Oct 15 12:07:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.122 2020/10/12 10:27:57 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.123 2020/10/15 12:07:11 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -5181,3 +5181,15 @@ external/cddl/osnet/sys/sys/cred.h		1.8
 	Fix PR kern/55675: ZFS mounts do not work with setuid programs.
 	[hannken, ticket #]
 
+sys/dev/usb/ums.c1.94,1.99
+xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c 1.6
+xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h	1.7
+
+	ums(4):
+	- Initialize tcpalib for ums devices.
+	- For absolute pointers, report min/max X and Y values using
+	  WSMOUSEIO_[SG]CALIBCOORDS ioctl.
+	Scale absolute positions to screen resolution before passing
+	them to the X server.
+	[jmcneill, ticket #1112]
+



CVS commit: [netbsd-9] xsrc/external/mit/xf86-input-mouse/dist/src

2020-10-15 Thread Martin Husemann
Module Name:xsrc
Committed By:   martin
Date:   Thu Oct 15 12:05:46 UTC 2020

Modified Files:
xsrc/external/mit/xf86-input-mouse/dist/src [netbsd-9]: bsd_mouse.c
mouse.h

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #1112):

external/mit/xf86-input-mouse/dist/src/bsd_mouse.c: revision 1.6
external/mit/xf86-input-mouse/dist/src/mouse.h: revision 1.7

If we get an absolute pointer event and we can query the min/max X and Y
values reported and it is in raw mode, use the screen dimensions to scale
the coordinates to fit the screen before feeding the event to the X server.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.4.1 \
xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c
cvs rdiff -u -r1.6 -r1.6.12.1 \
xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h

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

Modified files:

Index: xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c
diff -u xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c:1.5 xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c:1.5.4.1
--- xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c:1.5	Wed Jul 22 09:42:15 2015
+++ xsrc/external/mit/xf86-input-mouse/dist/src/bsd_mouse.c	Thu Oct 15 12:05:46 2020
@@ -384,6 +384,42 @@ FindDevice(InputInfoPtr pInfo, const cha
 #define NUMEVENTS 64
 
 static void
+wsconsAutoCalibrate(InputInfoPtr pInfo)
+{
+MouseDevPtr pMse;
+int width, height;
+struct wsmouse_calibcoords cal;
+
+pMse = pInfo->private;
+width = screenInfo.screens[pMse->screenNo]->width;
+height = screenInfo.screens[pMse->screenNo]->height;
+
+if (width != pMse->lastScreenWidth || height != pMse->lastScreenHeight) {
+if (ioctl(pInfo->fd, WSMOUSEIO_GCALIBCOORDS, ) == 0 &&
+cal.minx != cal.maxy && cal.miny != cal.maxy) {
+
+xf86Msg(X_INFO, "%s: auto-calibrating abs pointer for %dx%d screen\n",
+pInfo->name, width, height);
+
+pMse->minX = cal.minx;
+pMse->minY = cal.miny;
+pMse->maxX = cal.maxx;
+pMse->maxY = cal.maxy;
+pMse->translateAbs =
+cal.samplelen == WSMOUSE_CALIBCOORDS_RESET;
+}
+pMse->lastScreenWidth = width;
+pMse->lastScreenHeight = height;
+}
+}
+
+static int
+wsconsTranslate(InputInfoPtr pInfo, int scrRange, int rawMin, int rawMax, int rawVal)
+{
+return ((rawVal - rawMin) * scrRange) / (rawMax - rawMin);
+}
+
+static void
 wsconsReadInput(InputInfoPtr pInfo)
 {
 MouseDevPtr pMse;
@@ -394,6 +430,9 @@ wsconsReadInput(InputInfoPtr pInfo)
 
 pMse = pInfo->private;
 
+if (pMse->autoCalibrate)
+wsconsAutoCalibrate(pInfo);
+
 XisbBlockDuration(pMse->buffer, -1);
 pBuf = (unsigned char *)eventList;
 n = 0;
@@ -434,11 +473,17 @@ wsconsReadInput(InputInfoPtr pInfo)
 #endif
 	case WSCONS_EVENT_MOUSE_ABSOLUTE_X:
 	x = event->value;
+if (pMse->translateAbs)
+x = wsconsTranslate(pInfo, pMse->lastScreenWidth,
+pMse->minX, pMse->maxX, x);
 	xf86PostMotionEvent(pInfo->dev, TRUE, 0, 1, x);
 	++event;
 	continue;
 	case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
 	y = event->value;
+if (pMse->translateAbs)
+y = wsconsTranslate(pInfo, pMse->lastScreenWidth,
+pMse->minY, pMse->maxY, y);
 	xf86PostMotionEvent(pInfo->dev, TRUE, 1, 1, y);
 	++event;
 	continue;
@@ -480,6 +525,19 @@ wsconsPreInit(InputInfoPtr pInfo, const 
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
 pInfo->flags |= XI86_CONFIGURED;
 #endif
+
+pMse->autoCalibrate = xf86SetBoolOption(pInfo->options, "AutoCalibrate", TRUE);
+xf86Msg(X_CONFIG, "%s: auto calibration %sabled\n",
+pInfo->name, pMse->autoCalibrate ? "en" : "dis"); 
+
+pMse->screenNo = xf86SetIntOption(pInfo->options, "ScreenNo", 0);
+if (pMse->screenNo >= screenInfo.numScreens ||
+pMse->screenNo < 0) {
+pMse->screenNo = 0;
+}
+xf86Msg(X_CONFIG, "%s: associated screen: %d\n",
+pInfo->name, pMse->screenNo); 
+
 return TRUE;
 }
 #endif

Index: xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h
diff -u xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h:1.6 xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h:1.6.12.1
--- xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h:1.6	Wed Jun  5 07:11:16 2013
+++ xsrc/external/mit/xf86-input-mouse/dist/src/mouse.h	Thu Oct 15 12:05:46 2020
@@ -262,6 +262,15 @@ typedef struct _MouseDevRec {
 int doubleClickOldSourceState;
 int lastMappedButtons;
 int buttonMap[MSE_MAXBUTTONS];
+int autoCalibrate;
+int lastScreenWidth;
+int lastScreenHeight;
+int   

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

2020-10-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 15 12:03:23 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #1112):

sys/dev/usb/ums.c: revision 1.94
sys/dev/usb/ums.c: revision 1.99

Initialize tcpalib for ums devices.

In r1.3 of src/sys/dev/hid/hidms.c, tpcalib is used for any hidms
device reporting absolute coordinates. So ums devices reporting
absolute coordinates also need to initialize tcpalib - do it for
all ums devices. An uninitialized tcpalib stops a mouse with
absolute coordinates from "moving".

For absolute pointers, report min/max X and Y values using
WSMOUSEIO_[SG]CALIBCOORDS ioctl.


To generate a diff of this commit:
cvs rdiff -u -r1.93.2.3 -r1.93.2.4 src/sys/dev/usb/ums.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/ums.c
diff -u src/sys/dev/usb/ums.c:1.93.2.3 src/sys/dev/usb/ums.c:1.93.2.4
--- src/sys/dev/usb/ums.c:1.93.2.3	Tue Jan 21 19:54:55 2020
+++ src/sys/dev/usb/ums.c	Thu Oct 15 12:03:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ums.c,v 1.93.2.3 2020/01/21 19:54:55 martin Exp $	*/
+/*	$NetBSD: ums.c,v 1.93.2.4 2020/10/15 12:03:23 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2017 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.93.2.3 2020/01/21 19:54:55 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.93.2.4 2020/10/15 12:03:23 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -137,6 +137,8 @@ ums_attach(device_t parent, device_t sel
 {
 	struct ums_softc *sc = device_private(self);
 	struct uhidev_attach_arg *uha = aux;
+	struct hid_data *d;
+	struct hid_item item;
 	int size, error;
 	void *desc;
 	uint32_t quirks;
@@ -203,6 +205,36 @@ ums_attach(device_t parent, device_t sel
 		sc->sc_alwayson = true;
 	}
 
+	tpcalib_init(>sc_ms.sc_tpcalib);
+
+	/* calibrate the pointer if it reports absolute events */
+	if (sc->sc_ms.flags & HIDMS_ABS) {
+		memset(>sc_ms.sc_calibcoords, 0, sizeof(sc->sc_ms.sc_calibcoords));
+		sc->sc_ms.sc_calibcoords.maxx = 0;
+		sc->sc_ms.sc_calibcoords.maxy = 0;
+		sc->sc_ms.sc_calibcoords.samplelen = WSMOUSE_CALIBCOORDS_RESET;
+		d = hid_start_parse(desc, size, hid_input);
+		if (d != NULL) {
+			while (hid_get_item(d, )) {
+if (item.kind != hid_input
+|| HID_GET_USAGE_PAGE(item.usage) != HUP_GENERIC_DESKTOP
+|| item.report_ID != sc->sc_hdev.sc_report_id)
+	continue;
+if (HID_GET_USAGE(item.usage) == HUG_X) {
+	sc->sc_ms.sc_calibcoords.minx = item.logical_minimum;
+	sc->sc_ms.sc_calibcoords.maxx = item.logical_maximum;
+}
+if (HID_GET_USAGE(item.usage) == HUG_Y) {
+	sc->sc_ms.sc_calibcoords.miny = item.logical_minimum;
+	sc->sc_ms.sc_calibcoords.maxy = item.logical_maximum;
+}
+			}
+			hid_end_parse(d);
+		}
+	tpcalib_ioctl(>sc_ms.sc_tpcalib, WSMOUSEIO_SCALIBCOORDS,
+	(void *)>sc_ms.sc_calibcoords, 0, 0);
+	}
+
 	hidms_attach(self, >sc_ms, _accessops);
 
 	if (sc->sc_alwayson) {
@@ -315,10 +347,18 @@ ums_disable(void *v)
 
 Static int
 ums_ioctl(void *v, u_long cmd, void *data, int flag,
-struct lwp * p)
+struct lwp *l)
 
 {
 	struct ums_softc *sc = v;
+	int error;
+
+	if (sc->sc_ms.flags & HIDMS_ABS) {
+		error = tpcalib_ioctl(>sc_ms.sc_tpcalib, cmd, data,
+		flag, l);
+		if (error != EPASSTHROUGH)
+			return error;
+	}
 
 	switch (cmd) {
 	case WSMOUSEIO_GTYPE:



CVS commit: src/sys/net

2020-10-15 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Oct 15 10:20:44 UTC 2020

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

Log Message:
net: remove IFEF_NO_LINK_STATE_CHANGE

This flag was only set for virtual interfaces.
All virtual interfaces have a means of knowing if they are going to work
or not and as such now support link state changes.

If we want this flag back, it should be used as an indicator that
the interfaces does not support link state changes that userland can use
so it can make a decision on what to do when the link state is UNKNOWN.


To generate a diff of this commit:
cvs rdiff -u -r1.483 -r1.484 src/sys/net/if.c
cvs rdiff -u -r1.288 -r1.289 src/sys/net/if.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.c
diff -u src/sys/net/if.c:1.483 src/sys/net/if.c:1.484
--- src/sys/net/if.c:1.483	Sun Sep 27 19:16:28 2020
+++ src/sys/net/if.c	Thu Oct 15 10:20:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.483 2020/09/27 19:16:28 roy Exp $	*/
+/*	$NetBSD: if.c,v 1.484 2020/10/15 10:20:44 roy Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.483 2020/09/27 19:16:28 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.484 2020/10/15 10:20:44 roy Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2277,10 +2277,6 @@ if_link_state_change(struct ifnet *ifp, 
 {
 	int idx;
 
-	KASSERTMSG(if_is_link_state_changeable(ifp),
-	"%s: IFEF_NO_LINK_STATE_CHANGE must not be set, but if_extflags=0x%x",
-	ifp->if_xname, ifp->if_extflags);
-
 	/* Ensure change is to a valid state */
 	switch (link_state) {
 	case LINK_STATE_UNKNOWN:	/* FALLTHROUGH */

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.288 src/sys/net/if.h:1.289
--- src/sys/net/if.h:1.288	Sun Sep 27 19:16:28 2020
+++ src/sys/net/if.h	Thu Oct 15 10:20:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.288 2020/09/27 19:16:28 roy Exp $	*/
+/*	$NetBSD: if.h,v 1.289 2020/10/15 10:20:44 roy Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -457,7 +457,6 @@ typedef struct ifnet {
 #define	IFF_MULTICAST	0x8000		/* supports multicast */
 
 #define	IFEF_MPSAFE			__BIT(0)	/* handlers can run in parallel (see below) */
-#define	IFEF_NO_LINK_STATE_CHANGE	__BIT(1)	/* doesn't use link state interrupts */
 
 /*
  * The guidelines for converting an interface to IFEF_MPSAFE are as follows
@@ -537,13 +536,6 @@ if_start_lock(struct ifnet *ifp)
 	}
 }
 
-static __inline bool
-if_is_link_state_changeable(struct ifnet *ifp)
-{
-
-	return ((ifp->if_extflags & IFEF_NO_LINK_STATE_CHANGE) == 0);
-}
-
 #define KERNEL_LOCK_IF_IFP_MPSAFE(ifp)	\
 	do { if (if_is_mpsafe(ifp)) { KERNEL_LOCK(1, NULL); } } while (0)
 #define KERNEL_UNLOCK_IF_IFP_MPSAFE(ifp)\



CVS commit: src/sys/net

2020-10-15 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Oct 15 10:09:50 UTC 2020

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

Log Message:
wg: with no peers, the link status is DOWN, otherwise UP

This mirrors the recent changes to gif(4) where the link is UP when a
tunnel is set, otherwise DOWN.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/net/if_wg.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_wg.c
diff -u src/sys/net/if_wg.c:1.60 src/sys/net/if_wg.c:1.61
--- src/sys/net/if_wg.c:1.60	Mon Sep 14 04:57:20 2020
+++ src/sys/net/if_wg.c	Thu Oct 15 10:09:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wg.c,v 1.60 2020/09/14 04:57:20 riastradh Exp $	*/
+/*	$NetBSD: if_wg.c,v 1.61 2020/10/15 10:09:49 roy Exp $	*/
 
 /*
  * Copyright (C) Ryota Ozaki 
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.60 2020/09/14 04:57:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.61 2020/10/15 10:09:49 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq_enabled.h"
@@ -3509,6 +3509,8 @@ wg_destroy_peer_name(struct wg_softc *wg
 		garbage_bypubkey = thmap_stage_gc(wg->wg_peers_bypubkey);
 		WG_PEER_WRITER_REMOVE(wgp);
 		wg->wg_npeers--;
+		if (wg->wg_npeers == 0)
+			if_link_state_change(>wg_if, LINK_STATE_DOWN);
 		mutex_enter(wgp->wgp_lock);
 		pserialize_perform(wgp->wgp_psz);
 		mutex_exit(wgp->wgp_lock);
@@ -3536,8 +3538,7 @@ wg_if_attach(struct wg_softc *wg)
 	wg->wg_if.if_addrlen = 0;
 	wg->wg_if.if_mtu = WG_MTU;
 	wg->wg_if.if_flags = IFF_MULTICAST;
-	wg->wg_if.if_extflags = IFEF_NO_LINK_STATE_CHANGE;
-	wg->wg_if.if_extflags |= IFEF_MPSAFE;
+	wg->wg_if.if_extflags = IFEF_MPSAFE;
 	wg->wg_if.if_ioctl = wg_ioctl;
 	wg->wg_if.if_output = wg_output;
 	wg->wg_if.if_init = wg_init;
@@ -3556,6 +3557,7 @@ wg_if_attach(struct wg_softc *wg)
 	if (error != 0)
 		return error;
 
+	wg->wg_if.if_link_state = LINK_STATE_DOWN;
 	if_alloc_sadl(>wg_if);
 	if_register(>wg_if);
 
@@ -4381,6 +4383,8 @@ wg_ioctl_add_peer(struct wg_softc *wg, s
 	wg->wg_npeers++;
 	mutex_exit(wg->wg_lock);
 
+	if_link_state_change(>wg_if, LINK_STATE_UP);
+
 out:
 	kmem_free(buf, ifd->ifd_len + 1);
 	return error;



CVS commit: src/libexec/httpd

2020-10-15 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Oct 15 09:54:22 UTC 2020

Modified Files:
src/libexec/httpd: bozohttpd.8

Log Message:
New sentence, new line. Fix xref.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/libexec/httpd/bozohttpd.8

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

Modified files:

Index: src/libexec/httpd/bozohttpd.8
diff -u src/libexec/httpd/bozohttpd.8:1.86 src/libexec/httpd/bozohttpd.8:1.87
--- src/libexec/httpd/bozohttpd.8:1.86	Thu Oct 15 04:21:53 2020
+++ src/libexec/httpd/bozohttpd.8	Thu Oct 15 09:54:22 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bozohttpd.8,v 1.86 2020/10/15 04:21:53 mrg Exp $
+.\"	$NetBSD: bozohttpd.8,v 1.87 2020/10/15 09:54:22 wiz Exp $
 .\"
 .\"	$eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $
 .\"
@@ -127,7 +127,8 @@ Enables CGI/1.1 interface for
 .Em ~user
 translation.
 Note that enabling this support implies that users can run commands
-as the web server user. This may have security implications.
+as the web server user.
+This may have security implications.
 .It Fl e
 Causes
 .Nm
@@ -141,7 +142,8 @@ Stops the
 .Fl b
 flag from detaching
 .Nm
-from the tty and going into the background. This implies the
+from the tty and going into the background.
+This implies the
 .Fl b
 flag.
 .It Fl G
@@ -809,7 +811,7 @@ provided chroot and change-to-user suppo
 .An Jukka Ruohonen
 .Aq Mt jru...@netbsd.org
 provided support for
-.Xr blocklist 8
+.Xr blocklistd 8
 .It
 .An Jared McNeill
 .Aq Mt jmcne...@netbsd.org



CVS commit: src/sys/dev/usb

2020-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 15 09:37:41 UTC 2020

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

Log Message:
Rename xhci_op_barrier to xhci_barrier and remove offset/length parameters.
Barriers will be applied to the entire XHCI register space.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/dev/usb/xhci.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/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.134 src/sys/dev/usb/xhci.c:1.135
--- src/sys/dev/usb/xhci.c:1.134	Fri Aug 21 20:46:03 2020
+++ src/sys/dev/usb/xhci.c	Thu Oct 15 09:37:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.134 2020/08/21 20:46:03 jakllsch Exp $	*/
+/*	$NetBSD: xhci.c,v 1.135 2020/10/15 09:37:40 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.134 2020/08/21 20:46:03 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.135 2020/10/15 09:37:40 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -312,6 +312,12 @@ xhci_write_4(const struct xhci_softc * c
 }
 #endif /* unused */
 
+static inline void
+xhci_barrier(const struct xhci_softc * const sc, int flags)
+{
+	bus_space_barrier(sc->sc_iot, sc->sc_ioh, 0, sc->sc_ios, flags);
+}
+
 static inline uint32_t
 xhci_cap_read_4(const struct xhci_softc * const sc, bus_size_t offset)
 {
@@ -369,13 +375,6 @@ xhci_op_write_8(const struct xhci_softc 
 	}
 }
 
-static inline void
-xhci_op_barrier(const struct xhci_softc * const sc, bus_size_t offset,
-bus_size_t len, int flags)
-{
-	bus_space_barrier(sc->sc_iot, sc->sc_obh, offset, len, flags);
-}
-
 static inline uint32_t
 xhci_rt_read_4(const struct xhci_softc * const sc, bus_size_t offset)
 {
@@ -1229,7 +1228,7 @@ xhci_init(struct xhci_softc *sc)
 	xhci_op_write_8(sc, XHCI_CRCR, xhci_ring_trbp(sc->sc_cr, 0) |
 	sc->sc_cr->xr_cs);
 
-	xhci_op_barrier(sc, 0, 4, BUS_SPACE_BARRIER_WRITE);
+	xhci_barrier(sc, BUS_SPACE_BARRIER_WRITE);
 
 	HEXDUMP("eventst", KERNADDR(>sc_eventst_dma, 0),
 	XHCI_ERSTE_SIZE * XHCI_EVENT_RING_SEGMENTS);



CVS commit: src/sys/dev/fdt

2020-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 15 09:33:44 UTC 2020

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

Log Message:
Initialise xhci_softc sc_ios


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/fdt/dwc3_fdt.c

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

Modified files:

Index: src/sys/dev/fdt/dwc3_fdt.c
diff -u src/sys/dev/fdt/dwc3_fdt.c:1.10 src/sys/dev/fdt/dwc3_fdt.c:1.11
--- src/sys/dev/fdt/dwc3_fdt.c:1.10	Thu Mar 26 00:21:27 2020
+++ src/sys/dev/fdt/dwc3_fdt.c	Thu Oct 15 09:33:44 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc3_fdt.c,v 1.10 2020/03/26 00:21:27 thorpej Exp $ */
+/* $NetBSD: dwc3_fdt.c,v 1.11 2020/10/15 09:33:44 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.10 2020/03/26 00:21:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc3_fdt.c,v 1.11 2020/10/15 09:33:44 jmcneill Exp $");
 
 #include 
 #include 
@@ -278,6 +278,7 @@ dwc3_fdt_attach(device_t parent, device_
 	sc->sc_dev = self;
 	sc->sc_bus.ub_hcpriv = sc;
 	sc->sc_bus.ub_dmatag = faa->faa_dmat;
+	sc->sc_ios = size;
 	sc->sc_iot = faa->faa_bst;
 	if (bus_space_map(sc->sc_iot, addr, size, 0, >sc_ioh) != 0) {
 		aprint_error(": couldn't map registers\n");



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

2020-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 15 09:33:17 UTC 2020

Modified Files:
src/sys/arch/arm/nvidia: tegra_xusb.c

Log Message:
Initialise xhci_softc sc_ios


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/nvidia/tegra_xusb.c

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

Modified files:

Index: src/sys/arch/arm/nvidia/tegra_xusb.c
diff -u src/sys/arch/arm/nvidia/tegra_xusb.c:1.20 src/sys/arch/arm/nvidia/tegra_xusb.c:1.21
--- src/sys/arch/arm/nvidia/tegra_xusb.c:1.20	Sat Aug 29 19:06:17 2020
+++ src/sys/arch/arm/nvidia/tegra_xusb.c	Thu Oct 15 09:33:17 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_xusb.c,v 1.20 2020/08/29 19:06:17 jakllsch Exp $ */
+/* $NetBSD: tegra_xusb.c,v 1.21 2020/10/15 09:33:17 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2016 Jonathan A. Kollasch
@@ -30,7 +30,7 @@
 #include "opt_tegra.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_xusb.c,v 1.20 2020/08/29 19:06:17 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_xusb.c,v 1.21 2020/10/15 09:33:17 jmcneill Exp $");
 
 #include 
 #include 
@@ -243,6 +243,7 @@ tegra_xusb_attach(device_t parent, devic
 		return;
 	}
 	DPRINTF(sc->sc_dev, "mapped %#" PRIxBUSADDR "\n", addr);
+	sc->sc_ios = size;
 
 	if (fdtbus_get_reg_byname(faa->faa_phandle, "fpci", , ) != 0) {
 		aprint_error(": couldn't get registers\n");



CVS commit: src/sys/arch/mips/cavium/dev

2020-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 15 09:32:40 UTC 2020

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_xhci.c

Log Message:
Initialise xhci_softc sc_ios


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/cavium/dev/octeon_xhci.c

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

Modified files:

Index: src/sys/arch/mips/cavium/dev/octeon_xhci.c
diff -u src/sys/arch/mips/cavium/dev/octeon_xhci.c:1.2 src/sys/arch/mips/cavium/dev/octeon_xhci.c:1.3
--- src/sys/arch/mips/cavium/dev/octeon_xhci.c:1.2	Fri Jul 17 08:06:02 2020
+++ src/sys/arch/mips/cavium/dev/octeon_xhci.c	Thu Oct 15 09:32:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_xhci.c,v 1.2 2020/07/17 08:06:02 simonb Exp $ */
+/*	$NetBSD: octeon_xhci.c,v 1.3 2020/10/15 09:32:40 jmcneill Exp $ */
 /*	$OpenBSD: octxhci.c,v 1.4 2019/09/29 04:32:23 visa Exp $	*/
 
 /*
@@ -115,6 +115,7 @@ octxhci_attach(device_t parent, device_t
 	sc->sc_bus.ub_hcpriv = sc;
 	sc->sc_bus.ub_dmatag = faa->faa_dmat;
 	sc->sc_iot = _bus_tag;
+	sc->sc_ios = size;
 
 	child = of_find_bycompat(phandle, "synopsys,dwc3");
 	if (child == -1) {



CVS commit: src/distrib/evbarm

2020-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 15 08:59:57 UTC 2020

Modified Files:
src/distrib/evbarm: Makefile

Log Message:
Only add iso_image target for aarch64


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/distrib/evbarm/Makefile

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

Modified files:

Index: src/distrib/evbarm/Makefile
diff -u src/distrib/evbarm/Makefile:1.13 src/distrib/evbarm/Makefile:1.14
--- src/distrib/evbarm/Makefile:1.13	Sun Oct 11 14:24:50 2020
+++ src/distrib/evbarm/Makefile	Thu Oct 15 08:59:57 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.13 2020/10/11 14:24:50 jmcneill Exp $
+#	$NetBSD: Makefile,v 1.14 2020/10/15 08:59:57 jmcneill Exp $
 
 .include 
 .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
@@ -22,8 +22,10 @@ release: check_RELEASEDIR .WAIT ${MDECBO
 	${RELEASE_INSTALL} ${MDECBOOT} ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation
 .endif
 
+.if ${MACHINE_ARCH} == "aarch64"
 iso_image:
 	${MAKEDIRTARGET} isoimage iso_image
+.endif
 
 install_image:
 	${MAKEDIRTARGET} installimage install_image



CVS commit: src/sys/arch/aarch64/aarch64

2020-10-15 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Oct 15 08:37:20 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: vectors.S

Log Message:
slightly optimized loop for trap_doast() calls


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/aarch64/aarch64/vectors.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/aarch64/aarch64/vectors.S
diff -u src/sys/arch/aarch64/aarch64/vectors.S:1.20 src/sys/arch/aarch64/aarch64/vectors.S:1.21
--- src/sys/arch/aarch64/aarch64/vectors.S:1.20	Tue Oct  6 06:26:46 2020
+++ src/sys/arch/aarch64/aarch64/vectors.S	Thu Oct 15 08:37:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vectors.S,v 1.20 2020/10/06 06:26:46 skrll Exp $	*/
+/*	$NetBSD: vectors.S,v 1.21 2020/10/15 08:37:20 ryo Exp $	*/
 
 #include 
 #include 
@@ -10,7 +10,7 @@
 #include "opt_ddb.h"
 #include "opt_dtrace.h"
 
-RCSID("$NetBSD: vectors.S,v 1.20 2020/10/06 06:26:46 skrll Exp $")
+RCSID("$NetBSD: vectors.S,v 1.21 2020/10/15 08:37:20 ryo Exp $")
 
 	ARMV8_DEFINE_OPTIONS
 
@@ -255,26 +255,26 @@ ENTRY_NP(el0_trap)
 	nop/* dummy for DDB backtrace (for lr-4) */
 #endif
 ENTRY_NP(el0_trap_exit)
-	DISABLE_INTERRUPT		/* make sure I|F marked */
+
+	adr	lr, 1f			/* return address from trap_doast */
 1:
 	/* while (curlwp->l_md.md_astpending != 0) { */
-	mrs	x8, tpidr_el1
-	ldr	w9, [x8, #L_MD_ASTPENDING]
-	cbz	w9, 9f
+	DISABLE_INTERRUPT		/* make sure I|F marked */
+	mrs	x9, tpidr_el1
+	ldr	w8, [x9, #L_MD_ASTPENDING]
+	cbz	w8, 9f
 
 	/* curlwp->l_md.md_astpending = 0; */
-	str	xzr, [x8, #L_MD_ASTPENDING]
+	str	xzr, [x9, #L_MD_ASTPENDING]
 
 	/*  trap_doast(tf); */
 	ENABLE_INTERRUPT
 	mov	x0, sp
-	bl	_C_LABEL(trap_doast)
-	DISABLE_INTERRUPT
-	b	1b
+	b	_C_LABEL(trap_doast)	/* tail call (return to 1b) */
 	/* } */
 9:
 
-	mrs	x9, tpidr_el1
+	/* x9 is tpidr_el1 */
 	ldr	x23, [x9, #L_MD_CPACR]
 	msr	cpacr_el1, x23		/* FP unit EL0 handover */
 	isb/* necessary? */



CVS commit: src/etc/rc.d

2020-10-15 Thread Kimmo Suominen
Module Name:src
Committed By:   kim
Date:   Thu Oct 15 07:05:27 UTC 2020

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

Log Message:
Update "rtsol" keyword: leave IPv6 autoconf on

There is no need to turn off ipv6_autoconf or dhcp6 in dhcpcd to match
the previous behaviour with in-kernel RA processing.


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

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

Modified files:

Index: src/etc/rc.d/network
diff -u src/etc/rc.d/network:1.83 src/etc/rc.d/network:1.84
--- src/etc/rc.d/network:1.83	Sun Oct 11 22:38:48 2020
+++ src/etc/rc.d/network	Thu Oct 15 07:05:27 2020
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: network,v 1.83 2020/10/11 22:38:48 kim Exp $
+# $NetBSD: network,v 1.84 2020/10/15 07:05:27 kim Exp $
 #
 
 # PROVIDE: network
@@ -327,8 +327,7 @@ network_start_interfaces()
 if ! checkyesno dhcpcd; then
 	/sbin/dhcpcd -n -f /dev/null \
 		--background --persistent \
-		--noipv4 --nodhcp6 \
-		--ipv6ra_noautoconf \
+		--noipv4 \
 		${dhcpcd_flags} $int
 fi
 ;;