CVS commit: src/share/man/man8

2018-11-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Nov  7 07:49:10 UTC 2018

Modified Files:
src/share/man/man8: MAKEDEV.8

Log Message:
regen for nvmm


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/share/man/man8/MAKEDEV.8

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

Modified files:

Index: src/share/man/man8/MAKEDEV.8
diff -u src/share/man/man8/MAKEDEV.8:1.50 src/share/man/man8/MAKEDEV.8:1.51
--- src/share/man/man8/MAKEDEV.8:1.50	Sun Nov  4 12:48:01 2018
+++ src/share/man/man8/MAKEDEV.8	Wed Nov  7 07:49:10 2018
@@ -6,7 +6,7 @@
 .\" *** DO NOT EDIT - any changes will be lost!!!
 .\" *** --
 .\"
-.\" $NetBSD: MAKEDEV.8,v 1.50 2018/11/04 12:48:01 maxv Exp $
+.\" $NetBSD: MAKEDEV.8,v 1.51 2018/11/07 07:49:10 maxv Exp $
 .\"
 .\" Copyright (c) 2001, 2003, 2007, 2008 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -35,7 +35,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November  1, 2018
+.Dd November  2, 2018
 .Dt MAKEDEV 8
 .Os
 .Sh NAME
@@ -785,6 +785,8 @@ Non-Volatile Memory Host Controller Inte
 .Xr \&nvme 4
 . It Ar nvme#ns*
 Non-Volatile Memory namespace
+. It Ar nvmm
+NetBSD Virtual Machine Monitor
 . It Ar openfirm
 OpenFirmware accessor
 . It Ar pad#



CVS commit: src

2018-11-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Nov  7 07:43:08 UTC 2018

Modified Files:
src/distrib/sets/lists/comp: md.amd64
src/distrib/sets/lists/modules: md.amd64
src/etc: MAKEDEV.tmpl
src/sys/conf: files majors
src/sys/dev: Makefile
src/sys/modules: Makefile
Added Files:
src/sys/dev/nvmm: Makefile files.nvmm nvmm.c nvmm.h nvmm_internal.h
nvmm_ioctl.h
src/sys/dev/nvmm/x86: Makefile nvmm_x86.h nvmm_x86_svm.c
nvmm_x86_svmfunc.S
src/sys/modules/nvmm: Makefile nvmm.ioconf

Log Message:
Add NVMM - for NetBSD Virtual Machine Monitor -, a kernel driver that
provides support for hardware-accelerated virtualization on NetBSD.

It is made of an MI frontend, to which MD backends can be plugged. One
MD backend is implemented, x86-SVM, for x86 AMD CPUs.

We install

/usr/include/dev/nvmm/nvmm.h
/usr/include/dev/nvmm/nvmm_ioctl.h
/usr/include/dev/nvmm/{arch}/nvmm_{arch}.h

And the kernel module. For now, the only architecture where we do that
is amd64 (arch=x86).

NVMM is not enabled by default in amd64-GENERIC, but is instead easily
modloadable.

Sent to tech-kern@ a month ago. Validated with kASan, and optimized
with tprof.


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/distrib/sets/lists/comp/md.amd64
cvs rdiff -u -r1.77 -r1.78 src/distrib/sets/lists/modules/md.amd64
cvs rdiff -u -r1.195 -r1.196 src/etc/MAKEDEV.tmpl
cvs rdiff -u -r1.1215 -r1.1216 src/sys/conf/files
cvs rdiff -u -r1.79 -r1.80 src/sys/conf/majors
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/dev/nvmm/Makefile src/sys/dev/nvmm/files.nvmm \
src/sys/dev/nvmm/nvmm.c src/sys/dev/nvmm/nvmm.h \
src/sys/dev/nvmm/nvmm_internal.h src/sys/dev/nvmm/nvmm_ioctl.h
cvs rdiff -u -r0 -r1.1 src/sys/dev/nvmm/x86/Makefile \
src/sys/dev/nvmm/x86/nvmm_x86.h src/sys/dev/nvmm/x86/nvmm_x86_svm.c \
src/sys/dev/nvmm/x86/nvmm_x86_svmfunc.S
cvs rdiff -u -r1.209 -r1.210 src/sys/modules/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/nvmm/Makefile \
src/sys/modules/nvmm/nvmm.ioconf

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/comp/md.amd64
diff -u src/distrib/sets/lists/comp/md.amd64:1.259 src/distrib/sets/lists/comp/md.amd64:1.260
--- src/distrib/sets/lists/comp/md.amd64:1.259	Tue Jul 17 18:55:24 2018
+++ src/distrib/sets/lists/comp/md.amd64	Wed Nov  7 07:43:07 2018
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.259 2018/07/17 18:55:24 joerg Exp $
+# $NetBSD: md.amd64,v 1.260 2018/11/07 07:43:07 maxv Exp $
 
 ./usr/include/amd64comp-c-include
 ./usr/include/amd64/ansi.h			comp-c-include
@@ -677,6 +677,11 @@
 ./usr/include/ieeefp.hcomp-c-include
 ./usr/include/mm_malloc.h			comp-obsolete		obsolete
 ./usr/include/mmintrin.h			comp-obsolete		obsolete
+./usr/include/dev/nvmmcomp-c-include
+./usr/include/dev/nvmm/nvmm.h			comp-c-include
+./usr/include/dev/nvmm/nvmm_ioctl.h		comp-c-include
+./usr/include/dev/nvmm/x86			comp-c-include
+./usr/include/dev/nvmm/x86/nvmm_x86.h		comp-c-include
 ./usr/include/pmmintrin.h			comp-obsolete		obsolete
 ./usr/include/x64_64comp-obsolete		obsolete
 ./usr/include/x64_64/ansi.h			comp-obsolete		obsolete

Index: src/distrib/sets/lists/modules/md.amd64
diff -u src/distrib/sets/lists/modules/md.amd64:1.77 src/distrib/sets/lists/modules/md.amd64:1.78
--- src/distrib/sets/lists/modules/md.amd64:1.77	Tue Aug 28 09:42:10 2018
+++ src/distrib/sets/lists/modules/md.amd64	Wed Nov  7 07:43:07 2018
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.77 2018/08/28 09:42:10 martin Exp $
+# $NetBSD: md.amd64,v 1.78 2018/11/07 07:43:07 maxv Exp $
 #
 # NOTE that there are two sets of files here:
 # @MODULEDIR@ and amd64-xen
@@ -141,6 +141,8 @@
 ./@MODULEDIR@/mt2131/mt2131.kmod		base-kernel-modules	kmod
 ./@MODULEDIR@/nvmebase-obsolete		obsolete
 ./@MODULEDIR@/nvme/nvme.kmod			base-obsolete		obsolete
+./@MODULEDIR@/nvmmbase-kernel-modules	kmod
+./@MODULEDIR@/nvmm/nvmm.kmod			base-kernel-modules	kmod
 ./@MODULEDIR@/nxt2kbase-kernel-modules	kmod
 ./@MODULEDIR@/nxt2k/nxt2k.kmod			base-kernel-modules	kmod
 ./@MODULEDIR@/odcmbase-kernel-modules	kmod

Index: src/etc/MAKEDEV.tmpl
diff -u src/etc/MAKEDEV.tmpl:1.195 src/etc/MAKEDEV.tmpl:1.196
--- src/etc/MAKEDEV.tmpl:1.195	Sun Nov  4 12:48:01 2018
+++ src/etc/MAKEDEV.tmpl	Wed Nov  7 07:43:07 2018
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#	$NetBSD: MAKEDEV.tmpl,v 1.195 2018/11/04 12:48:01 maxv Exp $
+#	$NetBSD: MAKEDEV.tmpl,v 1.196 2018/11/07 07:43:07 maxv Exp $
 #
 # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -258,6 +258,7 @@
 #	nsmb*	SMB requester
 #	nvme*	Non-Volatile Memory Host Controller Interface device driver
 #	nvme*ns* Non-Volatile Memory namespace
+#	nvmm	NetBSD Virtual Machine Monitor
 #	openfirm OpenFirmware accessor
 #	pad*	Pseudo-audio device drive

CVS commit: src/sys/arch/x86

2018-11-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Nov  7 07:14:51 UTC 2018

Modified Files:
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: pmap.c x86_tlb.c

Log Message:
Add two pmap fields, will be used by NVMM.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.309 -r1.310 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/x86/x86_tlb.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/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.88 src/sys/arch/x86/include/pmap.h:1.89
--- src/sys/arch/x86/include/pmap.h:1.88	Wed Aug 29 16:26:25 2018
+++ src/sys/arch/x86/include/pmap.h	Wed Nov  7 07:14:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.88 2018/08/29 16:26:25 maxv Exp $	*/
+/*	$NetBSD: pmap.h,v 1.89 2018/11/07 07:14:51 maxv Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -258,6 +258,10 @@ struct pmap {
 	 ptp mapped */
 	uint64_t pm_ncsw;		/* for assertions */
 	struct vm_page *pm_gc_ptp;	/* pages from pmap g/c */
+
+	/* Used by NVMM. */
+	void (*pm_tlb_flush)(struct pmap *);
+	void *pm_data;
 };
 
 /* macro to access pm_pdirpa slots */

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.309 src/sys/arch/x86/x86/pmap.c:1.310
--- src/sys/arch/x86/x86/pmap.c:1.309	Wed Oct 31 06:26:26 2018
+++ src/sys/arch/x86/x86/pmap.c	Wed Nov  7 07:14:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.309 2018/10/31 06:26:26 maxv Exp $	*/
+/*	$NetBSD: pmap.c,v 1.310 2018/11/07 07:14:51 maxv Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.309 2018/10/31 06:26:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.310 2018/11/07 07:14:51 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -2378,6 +2378,7 @@ pmap_create(void)
 #endif
 	pmap->pm_flags = 0;
 	pmap->pm_gc_ptp = NULL;
+	pmap->pm_tlb_flush = NULL;
 
 	kcpuset_create(&pmap->pm_cpus, true);
 	kcpuset_create(&pmap->pm_kernel_cpus, true);

Index: src/sys/arch/x86/x86/x86_tlb.c
diff -u src/sys/arch/x86/x86/x86_tlb.c:1.2 src/sys/arch/x86/x86/x86_tlb.c:1.3
--- src/sys/arch/x86/x86/x86_tlb.c:1.2	Sat May 19 16:51:32 2018
+++ src/sys/arch/x86/x86/x86_tlb.c	Wed Nov  7 07:14:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_tlb.c,v 1.2 2018/05/19 16:51:32 jakllsch Exp $	*/
+/*	$NetBSD: x86_tlb.c,v 1.3 2018/11/07 07:14:51 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008-2012 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.2 2018/05/19 16:51:32 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.3 2018/11/07 07:14:51 maxv Exp $");
 
 #include 
 #include 
@@ -227,6 +227,11 @@ pmap_tlb_shootdown(struct pmap *pm, vadd
 	KASSERT((pte & PG_G) == 0 || pm == pmap_kernel());
 #endif
 
+	if (__predict_false(pm->pm_tlb_flush != NULL)) {
+		(*pm->pm_tlb_flush)(pm);
+		return;
+	}
+
 	/*
 	 * If tearing down the pmap, do nothing.  We will flush later
 	 * when we are ready to recycle/destroy it.



CVS commit: src

2018-11-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Nov  7 06:47:38 UTC 2018

Modified Files:
src/lib/libm/arch/aarch64: fenv.c
src/sys/arch/aarch64/aarch64: fpu.c
src/sys/arch/aarch64/include: armreg.h

Log Message:
When hardware subnormal support is available, disable flush-to-zero.

Similarly, when hardware NaN propagation is available, disable
default-NaN substitution.

This enables IEEE 754 semantics on any hardware that supports it by
default.  Programs that want flush-to-zero or default-NaN substitution
can enable them explicitly.

ok ryo@


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/arch/aarch64/fenv.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/aarch64/fpu.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/include/armreg.h

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

Modified files:

Index: src/lib/libm/arch/aarch64/fenv.c
diff -u src/lib/libm/arch/aarch64/fenv.c:1.3 src/lib/libm/arch/aarch64/fenv.c:1.4
--- src/lib/libm/arch/aarch64/fenv.c:1.3	Wed Mar 22 23:11:08 2017
+++ src/lib/libm/arch/aarch64/fenv.c	Wed Nov  7 06:47:38 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.3 2017/03/22 23:11:08 chs Exp $ */
+/* $NetBSD: fenv.c,v 1.4 2018/11/07 06:47:38 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: fenv.c,v 1.3 2017/03/22 23:11:08 chs Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.4 2018/11/07 06:47:38 riastradh Exp $");
 
 #include "namespace.h"
 
@@ -63,7 +63,7 @@ __weak_alias(feupdateenv,_feupdateenv)
 
 const fenv_t __fe_dfl_env = {
 	.__fpsr = 0,
-	.__fpcr = FPCR_FZ|FPCR_DN|FPCR_RN,
+	.__fpcr = __SHIFTIN(FPCR_RN, FPCR_RMODE),
 };
 
 /*

Index: src/sys/arch/aarch64/aarch64/fpu.c
diff -u src/sys/arch/aarch64/aarch64/fpu.c:1.2 src/sys/arch/aarch64/aarch64/fpu.c:1.3
--- src/sys/arch/aarch64/aarch64/fpu.c:1.2	Sun Apr  1 04:35:03 2018
+++ src/sys/arch/aarch64/aarch64/fpu.c	Wed Nov  7 06:47:38 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.2 2018/04/01 04:35:03 ryo Exp $ */
+/* $NetBSD: fpu.c,v 1.3 2018/11/07 06:47:38 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: fpu.c,v 1.2 2018/04/01 04:35:03 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: fpu.c,v 1.3 2018/11/07 06:47:38 riastradh Exp $");
 
 #include 
 #include 
@@ -75,10 +75,62 @@ fpu_state_load(lwp_t *l, unsigned int fl
 	KASSERT(l == curlwp);
 
 	if (__predict_false((flags & PCU_VALID) == 0)) {
+		uint64_t mvfr1 = reg_mvfr1_el1_read();
+		bool fp16 = false;
+		uint32_t fpcr = 0;
+
+		/*
+		 * Determine whether ARMv8.2-FP16 binary16
+		 * floating-point arithmetic is supported.
+		 */
+		switch (__SHIFTOUT(mvfr1, MVFR1_FPHP)) {
+		case MVFR1_FPHP_HALF_ARITH:
+			fp16 = true;
+			break;
+		}
+
+		/* Rounding mode: round to nearest, ties to even.  */
+		fpcr |= __SHIFTIN(FPCR_RN, FPCR_RMODE);
+
+		/* NaN propagation or default NaN.   */
+		switch (__SHIFTOUT(mvfr1, MVFR1_FPDNAN)) {
+		case MVFR1_FPDNAN_NAN:
+			/*
+			 * IEEE 754 NaN propagation supported.  Don't
+			 * enable default NaN mode.
+			 */
+			break;
+		default:
+			/*
+			 * IEEE 754 NaN propagation not supported, so
+			 * enable default NaN mode.
+			 */
+			fpcr |= FPCR_DN;
+		}
+
+		/* Subnormal arithmetic or flush-to-zero.  */
+		switch (__SHIFTOUT(mvfr1, MVFR1_FPFTZ)) {
+		case MVFR1_FPFTZ_DENORMAL:
+			/*
+			 * IEEE 754 subnormal arithmetic supported.
+			 * Don't enable flush-to-zero mode.
+			 */
+			break;
+		default:
+			/*
+			 * IEEE 754 subnormal arithmetic not supported,
+			 * so enable flush-to-zero mode.  If FP16 is
+			 * supported, also enable flush-to-zero for
+			 * binary16 arithmetic.
+			 */
+			fpcr |= FPCR_FZ;
+			if (fp16)
+fpcr |= FPCR_FZ16;
+		}
+
 		/* initialize fpregs */
 		memset(&pcb->pcb_fpregs, 0, sizeof(pcb->pcb_fpregs));
-		pcb->pcb_fpregs.fpcr =
-		FPCR_DN | FPCR_FZ | __SHIFTIN(FPCR_RN, FPCR_RMODE);
+		pcb->pcb_fpregs.fpcr = fpcr;
 
 		curcpu()->ci_vfp_use.ev_count++;
 	} else {

Index: src/sys/arch/aarch64/include/armreg.h
diff -u src/sys/arch/aarch64/include/armreg.h:1.19 src/sys/arch/aarch64/include/armreg.h:1.20
--- src/sys/arch/aarch64/include/armreg.h:1.19	Fri Oct 12 01:28:58 2018
+++ src/sys/arch/aarch64/include/armreg.h	Wed Nov  7 06:47:38 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: armreg.h,v 1.19 2018/10/12 01:28:58 ryo Exp $ */
+/* $NetBSD: armreg.h,v 1.20 2018/11/07 06:47:38 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -102,6 +102,7 @@ AARCH64REG_WRITE_INLINE(fpcr)
 #define	 FPCR_RM		2		//  Round towards Minus infinity
 #define	 FPCR_RZ		3		//  Round towards Zero
 #define	FPCR_STRIDE		__BITS(21,20)
+#define	FPCR_FZ16		__BIT(19)	// Flush-To-Zero for FP16
 #define	FPCR_LEN		__BITS(18,16)
 #define	FPCR_IDE		__BIT(15)	// Input Denormal Exception enable
 #define	FPCR_IXE		__BIT(12)	// IneXact Exception enable
@@ -30

Re: CVS commit: src/sys/sys

2018-11-06 Thread John Nemeth
On Nov 6,  4:26pm, "Maya Rashish" wrote:
} 
} Module Name:  src
} Committed By: maya
} Date: Tue Nov  6 16:26:44 UTC 2018
} 
} Modified Files:
}   src/sys/sys: stdint.h types.h
} 
} Log Message:
} Guard from type redefinition (needed by pre-C11 C) in a safer way.

 Why was this committed with only one day of discussion?  When
you post something for discussion, allowing only one day is extremely
inappropriate!  It is appropriate to state when you intend to make
the commit which be an ABSOLUTE MINIMUM of one week.  Please revert
and allow for proper discussion.

}-- End of excerpt from "Maya Rashish"


CVS commit: src

2018-11-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Nov  7 04:00:13 UTC 2018

Modified Files:
src/lib/libm: Makefile
src/tests/lib/libm: t_cos.c t_sin.c t_tan.c

Log Message:
Disable x87 implementations of sin, cos, tan.

The x87 hardware uses a bad approximation to pi for argument
reduction, and consequently yields bad answers for inputs near pi or
pi/2.

Tweak one tanf test whose doubly rounded output is a little too far
from the correct answer on the doubly rounded input.


To generate a diff of this commit:
cvs rdiff -u -r1.204 -r1.205 src/lib/libm/Makefile
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_cos.c \
src/tests/lib/libm/t_sin.c
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_tan.c

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

Modified files:

Index: src/lib/libm/Makefile
diff -u src/lib/libm/Makefile:1.204 src/lib/libm/Makefile:1.205
--- src/lib/libm/Makefile:1.204	Wed Jun 13 08:19:36 2018
+++ src/lib/libm/Makefile	Wed Nov  7 04:00:12 2018
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.204 2018/06/13 08:19:36 kamil Exp $
+#  $NetBSD: Makefile,v 1.205 2018/11/07 04:00:12 riastradh Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -123,14 +123,14 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_expf.S e_fmod.S e_log.S \
 	e_logf.S e_log10.S e_log10f.S e_log2.S e_log2f.S e_remainder.S \
 	e_remainderf.S e_scalb.S e_scalbf.S e_sqrt.S e_sqrtf.S s_atan.S \
-	s_atanf.S s_ceil.S s_ceilf.S s_copysign.S s_copysignf.S s_cos.S \
-	s_cosf.S s_finite.S s_finitef.S s_floor.S s_floorf.S \
+	s_atanf.S s_ceil.S s_ceilf.S s_copysign.S s_copysignf.S \
+	s_finite.S s_finitef.S s_floor.S s_floorf.S \
 	s_log1p.S s_log1pf.S s_logb.S s_logbf.S s_logbl.S \
 	s_rint.S s_rintf.S s_scalbn.S s_scalbnf.S s_significand.S \
-	s_significandf.S s_sin.S s_sinf.S s_tan.S s_tanf.S lrint.S 
+	s_significandf.S lrint.S
 # do not pick up the i387 asm version for the following functions;
 # it is incorrect
-.for f in modf ilogb ilogbl ilogbf
+.for f in cos cosf modf ilogb ilogbl ilogbf sin sinf tan tanf
 s_${f}.o s_${f}.pico s_${f}.po s_${f}.go s_${f}.d: s_${f}.c
 .endfor
 

Index: src/tests/lib/libm/t_cos.c
diff -u src/tests/lib/libm/t_cos.c:1.5 src/tests/lib/libm/t_cos.c:1.6
--- src/tests/lib/libm/t_cos.c:1.5	Wed Nov  7 03:59:36 2018
+++ src/tests/lib/libm/t_cos.c	Wed Nov  7 04:00:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_cos.c,v 1.5 2018/11/07 03:59:36 riastradh Exp $ */
+/* $NetBSD: t_cos.c,v 1.6 2018/11/07 04:00:13 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -34,12 +34,6 @@
 #include 
 #include 
 
-#if defined(__i386__) || defined(__x86_64__)
-const int TRIG_BUSTED = 1;
-#else
-const int TRIG_BUSTED = 0;
-#endif
-
 static const struct {
 	int		angle;
 	double		x;
@@ -86,15 +80,11 @@ ATF_TC_BODY(cos_angles, tc)
 		double cos_theta = angles[i].y;
 
 		assert(cos_theta != 0);
-		if (TRIG_BUSTED && fabs(cos_theta) < 2*DBL_EPSILON)
-			atf_tc_expect_fail("cos near +/-pi/2 is busted");
 		if (!(fabs((cos(theta) - cos_theta)/cos_theta) <= eps)) {
 			atf_tc_fail_nonfatal("cos(%d deg = %.17g) = %.17g"
 			" != %.17g",
 			deg, theta, cos(theta), cos_theta);
 		}
-		if (TRIG_BUSTED && fabs(cos_theta) < 2*DBL_EPSILON)
-			atf_tc_expect_pass();
 	}
 }
 
Index: src/tests/lib/libm/t_sin.c
diff -u src/tests/lib/libm/t_sin.c:1.5 src/tests/lib/libm/t_sin.c:1.6
--- src/tests/lib/libm/t_sin.c:1.5	Wed Nov  7 03:59:36 2018
+++ src/tests/lib/libm/t_sin.c	Wed Nov  7 04:00:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sin.c,v 1.5 2018/11/07 03:59:36 riastradh Exp $ */
+/* $NetBSD: t_sin.c,v 1.6 2018/11/07 04:00:13 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -34,12 +34,6 @@
 #include 
 #include 
 
-#if defined(__i386__) || defined(__x86_64__)
-const int TRIG_BUSTED = 1;
-#else
-const int TRIG_BUSTED = 0;
-#endif
-
 static const struct {
 	int		angle;
 	double		x;
@@ -93,19 +87,11 @@ ATF_TC_BODY(sin_angles, tc)
 			ok = (fabs((sin(theta) - sin_theta)/sin_theta) <= eps);
 		}
 
-		if (TRIG_BUSTED &&
-		sin_theta != 0 &&
-		fabs(sin_theta) < 2*DBL_EPSILON)
-			atf_tc_expect_fail("sin near +/- pi is busted");
 		if (!ok) {
 			atf_tc_fail_nonfatal("sin(%d deg = %.17g) = %.17g"
 			" != %.17g",
 			deg, theta, sin(theta), sin_theta);
 		}
-		if (TRIG_BUSTED &&
-		sin_theta != 0 &&
-		fabs(sin_theta) < 2*DBL_EPSILON)
-			atf_tc_expect_pass();
 	}
 }
 

Index: src/tests/lib/libm/t_tan.c
diff -u src/tests/lib/libm/t_tan.c:1.6 src/tests/lib/libm/t_tan.c:1.7
--- src/tests/lib/libm/t_tan.c:1.6	Wed Nov  7 03:59:36 2018
+++ src/tests/lib/libm/t_tan.c	Wed Nov  7 04:00:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_tan.c,v 1.6 2018/11/07 03:59:36 riastradh Exp $ */
+/* $NetBSD: t_tan.c,v 1.7 2018/11/07 04:00:13 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -34,12 +34,6 @@
 #i

CVS commit: src/tests/lib/libm

2018-11-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Nov  7 03:59:37 UTC 2018

Modified Files:
src/tests/lib/libm: t_acos.c t_asin.c t_cbrt.c t_cos.c t_cosh.c t_exp.c
t_ldexp.c t_libm.h t_log.c t_scalbn.c t_sin.c t_sinh.c t_sqrt.c
t_tan.c

Log Message:
Fix up libm tests.

- Fix up last few digits of a lot of known-answer tests.

  Confirmed with GNU mpfr to 200 bits of precision and cross-checked
  with whatever libm Ubuntu ships with.

- Test relative error, not absolute error.

- Set bounds in terms of *_EPSILON, not magic numbers.

  *_EPSILON is twice the largest relative error of a correctly
  rounded operation, and equal to the largest relative error of an
  operation with up to 1ulp error.

  Most of the operations we're testing are not correctly rounded, but
  they ought to be no more than 1ulp away.  For the few cases where
  that's not a priori clear (like comparing cbrt and pow(x, 1/3)),
  use twice *_EPSILON to allow some leeway.

- Write the success condition positively as error <= eps.

  This comes out false if the result is a NaN, meaning failure.  In
  contrast, if we write error > eps for the _failure_ condition, then
  if the result is a NaN, it will also come out false, but meaning
  success, which is not what we want.

- Fix the trigonometric test cases near bad spots.

  sin(pi - d) for nonzero d is not zero; it is d + O(d^3).  pi is not
  a floating-point number, so these results should be approximately
  the nonzero error of our approximation to pi.  Likewise with
  cos(pi/2 - d) and tan(pi + d).

  (Yes, I know the sin _function_ is ill-conditioned near pi so you
  shouldn't pass approximate inputs near there, but that's separate
  from whether a sin _implementation_ gives an answer that is wrong
  by quintillions of ulps.)

  Since on x86 (i386 and amd64 alike) we currently use x87 hardware
  trigonometric instructions, which are bad, these are marked xfail
  on x86 for now until we switch to software implementations (coming
  soon to a repository near you).

- Use %.8g, %.17g, %.35g to print float, double, long double in failures.

  This should be enough to identify the problematic outputs and/or
  reproduce the computation, even if long double is binary128 with
  115 bits of precision.

If there are any new libm test failures after this, tell me what
architecture you're on and send me the atf output and I'll try to
figure it out.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libm/t_acos.c
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libm/t_asin.c \
src/tests/lib/libm/t_cbrt.c
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libm/t_cos.c \
src/tests/lib/libm/t_sin.c
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libm/t_cosh.c \
src/tests/lib/libm/t_libm.h src/tests/lib/libm/t_sinh.c
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libm/t_exp.c
cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libm/t_ldexp.c
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libm/t_log.c
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libm/t_scalbn.c
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_sqrt.c
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libm/t_tan.c

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/libm/t_acos.c
diff -u src/tests/lib/libm/t_acos.c:1.10 src/tests/lib/libm/t_acos.c:1.11
--- src/tests/lib/libm/t_acos.c:1.10	Wed Mar  5 20:14:46 2014
+++ src/tests/lib/libm/t_acos.c	Wed Nov  7 03:59:36 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_acos.c,v 1.10 2014/03/05 20:14:46 dsl Exp $ */
+/* $NetBSD: t_acos.c,v 1.11 2018/11/07 03:59:36 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@ ATF_LIBM_TEST(acos_inrange, "Test acos/a
 		{  0,M_PI / 2,  },
 		{  0.1,  1.47062890567, },
 		{  0.5,  1.047197551196598, },
-		{  0.99, 0.141539473324427, },
+		{  0.99, 0.1415394733244273, },
 	};
 	unsigned int i;
 

Index: src/tests/lib/libm/t_asin.c
diff -u src/tests/lib/libm/t_asin.c:1.3 src/tests/lib/libm/t_asin.c:1.4
--- src/tests/lib/libm/t_asin.c:1.3	Mon Mar  3 10:39:08 2014
+++ src/tests/lib/libm/t_asin.c	Wed Nov  7 03:59:36 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_asin.c,v 1.3 2014/03/03 10:39:08 martin Exp $ */
+/* $NetBSD: t_asin.c,v 1.4 2018/11/07 03:59:36 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,6 +30,7 @@
  */
 
 #include 
+#include 
 #include 
 
 static const struct {
@@ -117,13 +118,14 @@ ATF_TC_HEAD(asin_inrange, tc)
 
 ATF_TC_BODY(asin_inrange, tc)
 {
-	const double eps = 1.0e-15;
-	double y;
+	const double eps = DBL_EPSILON;
 	size_t i;
 
 	for (i = 0; i < __arraycount(values); i++) {
-		y = asin(values[i].x);
-		if (fabs(y - values[i].y) > eps)
+		double x = values[i].x;
+		double y = values[i].y;
+
+		if (!(fabs((asin(x) - y)/y) <= eps))
 			atf_tc_fail_nonfatal("asin(%g) != %g",
 values[i].x, values[i].y);
 	}
@@ -230,16 +232,23 @@ ATF_TC_HEAD(asinf_inrange, tc)
 
 A

CVS commit: src/tests/lib/libm

2018-11-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Nov  7 03:56:18 UTC 2018

Modified Files:
src/tests/lib/libm: Makefile

Log Message:
Build libm tests with -fno-builtin.

This way they test libm, not whatever the compiler does.

We should _also_ have automatic integration tests for what the
compiler does, as a separate thing.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/tests/lib/libm/Makefile

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/libm/Makefile
diff -u src/tests/lib/libm/Makefile:1.44 src/tests/lib/libm/Makefile:1.45
--- src/tests/lib/libm/Makefile:1.44	Wed Jun 20 03:51:27 2018
+++ src/tests/lib/libm/Makefile	Wed Nov  7 03:56:18 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.44 2018/06/20 03:51:27 maya Exp $
+# $NetBSD: Makefile,v 1.45 2018/11/07 03:56:18 riastradh Exp $
 
 .include 
 
@@ -7,6 +7,7 @@ TESTSDIR=	${TESTSBASE}/lib/libm
 .if ${MACHINE} == "alpha"
 COPTS+=	-mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i
 .endif
+COPTS+=	-fno-builtin
 
 CPPFLAGS.t_fenv.c+=	-D__TEST_FENV
 CPPFLAGS.t_fe_round.c+=	-D__TEST_FENV



CVS commit: src/tools/binutils

2018-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov  7 01:14:19 UTC 2018

Modified Files:
src/tools/binutils: Makefile mknative-binutils

Log Message:
Adjust for 2.31.1


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/tools/binutils/Makefile
cvs rdiff -u -r1.9 -r1.10 src/tools/binutils/mknative-binutils

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

Modified files:

Index: src/tools/binutils/Makefile
diff -u src/tools/binutils/Makefile:1.28 src/tools/binutils/Makefile:1.29
--- src/tools/binutils/Makefile:1.28	Tue May  1 15:59:46 2018
+++ src/tools/binutils/Makefile	Tue Nov  6 20:14:19 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.28 2018/05/01 19:59:46 christos Exp $
+#	$NetBSD: Makefile,v 1.29 2018/11/07 01:14:19 christos Exp $
 
 .include 
 
@@ -67,6 +67,7 @@ native-binutils: .native/.configure_done
 			--build=`${GNUHOSTDIST}/config.guess` \
 			--host=${MACHINE_GNU_PLATFORM} \
 			--target=${MACHINE_GNU_PLATFORM} \
+			--disable-initfini-array \
 			${BRANDING} \
 		)
 	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \

Index: src/tools/binutils/mknative-binutils
diff -u src/tools/binutils/mknative-binutils:1.9 src/tools/binutils/mknative-binutils:1.10
--- src/tools/binutils/mknative-binutils:1.9	Tue Oct  1 11:41:17 2013
+++ src/tools/binutils/mknative-binutils	Tue Nov  6 20:14:19 2018
@@ -1,5 +1,5 @@
 #!/bin/sh
-#	$NetBSD: mknative-binutils,v 1.9 2013/10/01 15:41:17 skrll Exp $
+#	$NetBSD: mknative-binutils,v 1.10 2018/11/07 01:14:19 christos Exp $
 #
 # Shell script for generating all the constants needed for a native
 # platform build of src/external/gpl3/binutils
@@ -22,7 +22,7 @@ get_libbfd () {
 	{
 		getvars bfd/Makefile \
 			libbfd_la_DEPENDENCIES libbfd_la_OBJECTS DEFS \
-			INCLUDES TDEFAULTS
+			INCLUDES TDEFAULTS HAVEVECS
 	} | write_mk external/gpl3/binutils/lib/libbfd/arch/$MACHINE_ARCH/defs.mk
 
 	write_c external/gpl3/binutils/lib/libbfd/arch/$MACHINE_ARCH/bfd.h <$_TMPDIR/bfd/bfd.h
@@ -96,6 +96,7 @@ get_binutils () {
 DEFS INCLUDES as_new_OBJECTS as_new_LDADD | 
 	sed	-e s/G_as_new_OBJECTS/G_OBJS/ \
 		-e s/G_as_new_LDADD=/G_OBJS+=/ \
+		-e s@config/@@ \
 		-e 's/\.\..*a//' |
 	write_mk external/gpl3/binutils/usr.bin/gas/arch/$MACHINE_ARCH/defs.mk
 



CVS commit: src/external/gpl3/binutils

2018-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov  7 01:13:57 UTC 2018

Modified Files:
src/external/gpl3/binutils/dist: config.guess config.sub configure
configure.ac
src/external/gpl3/binutils/dist/bfd: ChangeLog Makefile.am Makefile.in
aoutx.h archive.c archures.c bfd-in2.h bfd.c coff-alpha.c
coffcode.h config.bfd configure configure.ac configure.host
dwarf2.c elf-bfd.h elf-eh-frame.c elf.c elf32-arm.c elf32-avr.c
elf32-hppa.c elf32-i386.c elf32-m68k.c elf32-or1k.c elf32-ppc.c
elf32-sh.c elf32-vax.c elf64-alpha.c elf64-mips.c elf64-ppc.c
elf64-x86-64.c elflink.c elfn32-mips.c elfnn-riscv.c elfxx-mips.c
elfxx-riscv.c elfxx-riscv.h elfxx-sparc.c libbfd.h linker.c reloc.c
syms.c targets.c version.h
src/external/gpl3/binutils/dist/bfd/doc: Makefile.in bfdt.texi
bfdver.texi reloc.texi
src/external/gpl3/binutils/dist/binutils: ChangeLog Makefile.in NEWS
aclocal.m4 ar.c arsup.c bucomm.c configure objcopy.c readelf.c
strings.c
src/external/gpl3/binutils/dist/binutils/doc: Makefile.am Makefile.in
addr2line.1 ar.1 binutils.info binutils.texi cxxfilt.man dlltool.1
elfedit.1 nm.1 objcopy.1 objdump.1 ranlib.1 readelf.1 size.1
strings.1 strip.1 windmc.1 windres.1
src/external/gpl3/binutils/dist/cpu: or1kcommon.cpu
src/external/gpl3/binutils/dist/gas: ChangeLog Makefile.am Makefile.in
configure configure.ac configure.tgt write.c
src/external/gpl3/binutils/dist/gas/config: obj-elf.c tc-arm.c
tc-m68k.c tc-mips.c tc-ppc.c tc-riscv.c tc-riscv.h tc-sparc.c
src/external/gpl3/binutils/dist/gas/doc: Makefile.am Makefile.in as.1
as.info c-mips.texi
src/external/gpl3/binutils/dist/gold: Makefile.am
src/external/gpl3/binutils/dist/gprof: corefile.c gprof.1 gprof.info
src/external/gpl3/binutils/dist/include: bfdlink.h dis-asm.h
src/external/gpl3/binutils/dist/include/elf: common.h mips.h ppc.h
riscv.h
src/external/gpl3/binutils/dist/include/opcode: mips.h ppc.h
riscv-opc.h riscv.h
src/external/gpl3/binutils/dist/ld: ChangeLog Makefile.am Makefile.in
configure configure.ac configure.host configure.tgt genscripts.sh
ldctor.c ldemul.c ldexp.c ldgram.c ldlang.c ldlang.h ldlex.c
ldlex.h ldlex.l ldmain.c lexsup.c
src/external/gpl3/binutils/dist/ld/emulparams: elf32bmipn32-defs.sh
elf32lriscv-defs.sh elf32lriscv.sh elf64lriscv-defs.sh
elf64lriscv.sh
src/external/gpl3/binutils/dist/ld/emultempl: aarch64elf.em armelf.em
beos.em elf32.em mmo.em pe.em pep.em riscvelf.em spuelf.em
xtensaelf.em
src/external/gpl3/binutils/dist/ld/scripttempl: elf.sc
src/external/gpl3/binutils/dist/libiberty: configure configure.ac
src/external/gpl3/binutils/dist/opcodes: ChangeLog Makefile.am
Makefile.in configure disassemble.c mips-dis.c mips-opc.c
or1k-asm.c or1k-desc.c or1k-dis.c or1k-ibld.c ppc-dis.c ppc-opc.c
riscv-dis.c riscv-opc.c sparc-dis.c
src/external/gpl3/binutils/lib/libbfd: Makefile
src/external/gpl3/binutils/lib/libbfd/arch/x86_64: bfd.h bfd_stdint.h
bfdver.h config.h defs.mk
src/external/gpl3/binutils/lib/libiberty/arch/x86_64: config.h
src/external/gpl3/binutils/lib/libopcodes/arch/x86_64: config.h
src/external/gpl3/binutils/usr.bin/common/arch/x86_64: config.h defs.mk
src/external/gpl3/binutils/usr.bin/gas/arch/x86_64: config.h defs.mk
src/external/gpl3/binutils/usr.bin/gprof/arch/x86_64: defs.mk gconfig.h
src/external/gpl3/binutils/usr.bin/ld/arch/x86_64: config.h defs.mk
ldemul-list.h
Removed Files:
src/external/gpl3/binutils/dist/bfd: aout-adobe.c aout-arm.c
aout-sparcle.c aout0.c aoutf1.h armnetbsd.c bout.c cf-sparclynx.c
coff-apollo.c coff-aux.c coff-h8300.c coff-h8500.c coff-i860.c
coff-i960.c coff-m68k.c coff-m88k.c coff-sparc.c coff-svm68k.c
coff-u68k.c coff-w65.c coff-we32k.c cpu-h8500.c cpu-i370.c
cpu-i860.c cpu-i960.c cpu-m88k.c cpu-w65.c cpu-we32k.c demo64.c
elf32-i370.c elf32-i860.c elf32-i960.c elf32-m88k.c
elf32-sh-symbian.c elf32-sh64-com.c elf32-sh64.c elf32-sh64.h
elf64-sh64.c epoc-pe-arm.c epoc-pei-arm.c freebsd.h hp300bsd.c
hp300hpux.c i386dynix.c i386freebsd.c i386linux.c i386mach3.c
i386netbsd.c i386os9k.c ieee.c libieee.h libnlm.h liboasys.h
m68k4knetbsd.c m68klinux.c m68knetbsd.c m88kmach3.c m88kopenbsd.c
mipsbsd.c newsos3.c nlm-target.h nlm.c nlm32-alpha.c nlm32-i386.c
nlm32-ppc.c nlm32-sparc.c nlm32.c nlm64.c nlmcode.h nlmswap.h

CVS commit: src/external/gpl2/groff/dist

2018-11-06 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Tue Nov  6 22:01:16 UTC 2018

Modified Files:
src/external/gpl2/groff/dist: configure

Log Message:
Test for other exit cases.
It might be worth regenerating configure with modern autoconf.

Reviewed by 
Closes PR toolchain/53314


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/gpl2/groff/dist/configure

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

Modified files:

Index: src/external/gpl2/groff/dist/configure
diff -u src/external/gpl2/groff/dist/configure:1.1.1.1 src/external/gpl2/groff/dist/configure:1.2
--- src/external/gpl2/groff/dist/configure:1.1.1.1	Wed Jan 13 18:41:45 2016
+++ src/external/gpl2/groff/dist/configure	Tue Nov  6 22:01:16 2018
@@ -2511,6 +2511,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c
'extern "C" void std::exit (int); using std::exit;' \
'extern "C" void exit (int) throw ();' \
'extern "C" void exit (int);' \
+   'extern "C" [[noreturn]] void exit (int);' \
+   'extern "C" _Noreturn void exit (int);' \
'void exit (int);'
 do
   cat >conftest.$ac_ext <<_ACEOF
@@ -2977,6 +2979,8 @@ for ac_declaration in \
'extern "C" void std::exit (int); using std::exit;' \
'extern "C" void exit (int) throw ();' \
'extern "C" void exit (int);' \
+   'extern "C" [[noreturn]] void exit (int);' \
+   'extern "C" _Noreturn void exit (int);' \
'void exit (int);'
 do
   cat >conftest.$ac_ext <<_ACEOF



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

2018-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov  6 17:55:04 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_sendrecv.c

Log Message:
Add a test to enable rerror handling.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/sys/t_sendrecv.c

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_sendrecv.c
diff -u src/tests/lib/libc/sys/t_sendrecv.c:1.4 src/tests/lib/libc/sys/t_sendrecv.c:1.5
--- src/tests/lib/libc/sys/t_sendrecv.c:1.4	Wed Aug 22 02:31:37 2018
+++ src/tests/lib/libc/sys/t_sendrecv.c	Tue Nov  6 12:55:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_sendrecv.c,v 1.4 2018/08/22 06:31:37 christos Exp $	*/
+/*	$NetBSD: t_sendrecv.c,v 1.5 2018/11/06 17:55:04 christos Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_sendrecv.c,v 1.4 2018/08/22 06:31:37 christos Exp $");
+__RCSID("$NetBSD: t_sendrecv.c,v 1.5 2018/11/06 17:55:04 christos Exp $");
 
 #include 
 #include 
@@ -44,11 +44,6 @@ __RCSID("$NetBSD: t_sendrecv.c,v 1.4 201
 #include 
 #include 
 
-ATF_TC(sendrecv_basic);
-ATF_TC_HEAD(sendrecv_basic, tc)
-{
-	atf_tc_set_md_var(tc, "descr", "A basic test of sendrecv(2)");
-}
 
 #define COUNT 100
 
@@ -78,7 +73,7 @@ sender(int fd)
 			continue;
 		printf(">>%zd %d %ju\n", n, errno, p.seq);
 		ATF_REQUIRE_MSG(errno == ENOBUFS, "send %s", strerror(errno));
-		sched_yield();
+//		sched_yield();
 	}
 	printf("sender done\n");
 }
@@ -110,17 +105,23 @@ receiver(int fd)
 	} while (p.seq < COUNT);
 }
 
-ATF_TC_BODY(sendrecv_basic, tc)
+static void
+sendrecv(int rerror)
 {
 	int fd[2], error;
 	struct sigaction sa;
 
-//	atf_tc_fail("does not terminate");
-
 	error = socketpair(AF_UNIX, SOCK_DGRAM, 0, fd);
 //	error = pipe(fd);
 	ATF_REQUIRE_MSG(error != -1, "socketpair failed (%s)", strerror(errno));
 
+	for (size_t i = 0; i < __arraycount(fd); i++) {
+		error = setsockopt(fd[i], SOL_SOCKET, SO_RERROR, &rerror,
+		sizeof(rerror));
+		ATF_REQUIRE_MSG(error != -1,
+		"setsockopt(SO_RERROR) failed (%s)", strerror(errno));
+	}
+
 	memset(&sa, 0, sizeof(sa));
 	sa.sa_flags = 0;
 	sa.sa_handler = &handle_sigchld;
@@ -146,10 +147,35 @@ ATF_TC_BODY(sendrecv_basic, tc)
 	}
 }
 
+ATF_TC(sendrecv_basic);
+
+ATF_TC_HEAD(sendrecv_basic, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "A basic test of send/recv(2)");
+}
+
+ATF_TC_BODY(sendrecv_basic, tc)
+{
+	sendrecv(0);
+}
+
+ATF_TC(sendrecv_rerror);
+
+ATF_TC_HEAD(sendrecv_rerror, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test send/recv(2) with receiver error");
+}
+
+ATF_TC_BODY(sendrecv_rerror, tc)
+{
+	sendrecv(1);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
 	ATF_TP_ADD_TC(tp, sendrecv_basic);
+	ATF_TP_ADD_TC(tp, sendrecv_rerror);
 
 	return atf_no_error();
 }



CVS commit: src/sys/sys

2018-11-06 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Nov  6 16:26:44 UTC 2018

Modified Files:
src/sys/sys: stdint.h types.h

Log Message:
Guard from type redefinition (needed by pre-C11 C) in a safer way.

The existing way causes problems like:
https://mail-index.netbsd.org/tech-pkg/2018/10/25/msg020395.html
https://mail-index.netbsd.org/tech-userlevel/2018/09/08/msg011381.html


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/sys/stdint.h
cvs rdiff -u -r1.101 -r1.102 src/sys/sys/types.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/stdint.h
diff -u src/sys/sys/stdint.h:1.7 src/sys/sys/stdint.h:1.8
--- src/sys/sys/stdint.h:1.7	Mon Apr 22 21:26:48 2013
+++ src/sys/sys/stdint.h	Tue Nov  6 16:26:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: stdint.h,v 1.7 2013/04/22 21:26:48 joerg Exp $	*/
+/*	$NetBSD: stdint.h,v 1.8 2018/11/06 16:26:44 maya Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
@@ -35,54 +35,54 @@
 #include 
 #include 
 
-#ifndef	int8_t
+#ifndef	_BSD_INT8_T_
 typedef	__int8_t	int8_t;
-#define	int8_t		__int8_t
+#define	_BSD_INT8_T_
 #endif
 
-#ifndef	uint8_t
+#ifndef	_BSD_UINT8_T_
 typedef	__uint8_t	uint8_t;
-#define	uint8_t		__uint8_t
+#define	_BSD_UINT8_T_
 #endif
 
-#ifndef	int16_t
+#ifndef	_BSD_INT16_T_
 typedef	__int16_t	int16_t;
-#define	int16_t		__int16_t
+#define	_BSD_INT16_T_
 #endif
 
-#ifndef	uint16_t
+#ifndef	_BSD_UINT16_T_
 typedef	__uint16_t	uint16_t;
-#define	uint16_t	__uint16_t
+#define	_BSD_UINT16_T_
 #endif
 
-#ifndef	int32_t
+#ifndef	_BSD_INT32_T_
 typedef	__int32_t	int32_t;
-#define	int32_t		__int32_t
+#define	_BSD_INT32_T_
 #endif
 
-#ifndef	uint32_t
+#ifndef	_BSD_UINT32_T_
 typedef	__uint32_t	uint32_t;
-#define	uint32_t	__uint32_t
+#define	_BSD_UINT32_T_
 #endif
 
-#ifndef	int64_t
+#ifndef	_BSD_INT64_T_
 typedef	__int64_t	int64_t;
-#define	int64_t		__int64_t
+#define	_BSD_INT64_T_
 #endif
 
-#ifndef	uint64_t
+#ifndef	_BSD_UINT64_T_
 typedef	__uint64_t	uint64_t;
-#define	uint64_t	__uint64_t
+#define	_BSD_UINT64_T_
 #endif
 
-#ifndef	intptr_t
+#ifndef	_BSD_INTPTR_T_
 typedef	__intptr_t	intptr_t;
-#define	intptr_t	__intptr_t
+#define	_BSD_INTPTR_T_
 #endif
 
-#ifndef	uintptr_t
+#ifndef	_BSD_UINTPTR_T_
 typedef	__uintptr_t	uintptr_t;
-#define	uintptr_t	__uintptr_t
+#define	_BSD_UINTPTR_T_
 #endif
 
 #include 

Index: src/sys/sys/types.h
diff -u src/sys/sys/types.h:1.101 src/sys/sys/types.h:1.102
--- src/sys/sys/types.h:1.101	Tue Jul 10 07:40:42 2018
+++ src/sys/sys/types.h	Tue Nov  6 16:26:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.101 2018/07/10 07:40:42 martin Exp $	*/
+/*	$NetBSD: types.h,v 1.102 2018/11/06 16:26:44 maya Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993, 1994
@@ -50,44 +50,44 @@
 
 #include 
 
-#ifndef	int8_t
+#ifndef	_BSD_INT8_T_
 typedef	__int8_t	int8_t;
-#define	int8_t		__int8_t
+#define	_BSD_INT8_T_
 #endif
 
-#ifndef	uint8_t
+#ifndef	_BSD_UINT8_T_
 typedef	__uint8_t	uint8_t;
-#define	uint8_t		__uint8_t
+#define	_BSD_UINT8_T_
 #endif
 
-#ifndef	int16_t
+#ifndef	_BSD_INT16_T_
 typedef	__int16_t	int16_t;
-#define	int16_t		__int16_t
+#define	_BSD_INT16_T_
 #endif
 
-#ifndef	uint16_t
+#ifndef	_BSD_UINT16_T_
 typedef	__uint16_t	uint16_t;
-#define	uint16_t	__uint16_t
+#define	_BSD_UINT16_T_
 #endif
 
-#ifndef	int32_t
+#ifndef	_BSD_INT32_T_
 typedef	__int32_t	int32_t;
-#define	int32_t		__int32_t
+#define	_BSD_INT32_T_
 #endif
 
-#ifndef	uint32_t
+#ifndef	_BSD_UINT32_T_
 typedef	__uint32_t	uint32_t;
-#define	uint32_t	__uint32_t
+#define	_BSD_UINT32_T_
 #endif
 
-#ifndef	int64_t
+#ifndef	_BSD_INT64_T_
 typedef	__int64_t	int64_t;
-#define	int64_t		__int64_t
+#define	_BSD_INT64_T_
 #endif
 
-#ifndef	uint64_t
+#ifndef	_BSD_UINT64_T_
 typedef	__uint64_t	uint64_t;
-#define	uint64_t	__uint64_t
+#define	_BSD_UINT64_T_
 #endif
 
 typedef	uint8_t		u_int8_t;



CVS commit: src/sys/dev/sdmmc

2018-11-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  6 16:01:39 UTC 2018

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

Log Message:
Increase kthread priority to PRI_SOFTBIO.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/sdmmc/sdmmc.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/sdmmc/sdmmc.c
diff -u src/sys/dev/sdmmc/sdmmc.c:1.35 src/sys/dev/sdmmc/sdmmc.c:1.36
--- src/sys/dev/sdmmc/sdmmc.c:1.35	Tue Mar  6 07:41:55 2018
+++ src/sys/dev/sdmmc/sdmmc.c	Tue Nov  6 16:01:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc.c,v 1.35 2018/03/06 07:41:55 mlelstv Exp $	*/
+/*	$NetBSD: sdmmc.c,v 1.36 2018/11/06 16:01:38 jmcneill Exp $	*/
 /*	$OpenBSD: sdmmc.c,v 1.18 2009/01/09 10:58:38 jsg Exp $	*/
 
 /*
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.35 2018/03/06 07:41:55 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.36 2018/11/06 16:01:38 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -246,7 +246,7 @@ sdmmc_doattach(device_t dev)
 {
 	struct sdmmc_softc *sc = device_private(dev);
 
-	if (kthread_create(PRI_BIO, 0, NULL,
+	if (kthread_create(PRI_SOFTBIO, 0, NULL,
 	sdmmc_task_thread, sc, &sc->sc_tskq_lwp, "%s", device_xname(dev))) {
 		aprint_error_dev(dev, "couldn't create task thread\n");
 	}



CVS commit: [netbsd-8] src/doc

2018-11-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov  6 14:48:37 UTC 2018

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

Log Message:
Tickets #1080 - #1082


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.48 -r1.1.2.49 src/doc/CHANGES-8.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-8.1
diff -u src/doc/CHANGES-8.1:1.1.2.48 src/doc/CHANGES-8.1:1.1.2.49
--- src/doc/CHANGES-8.1:1.1.2.48	Sun Nov  4 11:15:10 2018
+++ src/doc/CHANGES-8.1	Tue Nov  6 14:48:37 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.1,v 1.1.2.48 2018/11/04 11:15:10 martin Exp $
+# $NetBSD: CHANGES-8.1,v 1.1.2.49 2018/11/06 14:48:37 martin Exp $
 
 A complete list of changes from the NetBSD 8.0 release to the NetBSD 8.1
 release:
@@ -1589,4 +1589,26 @@ sys/netinet6/udp6_usrreq.c			1.142
 	Fix error path in ip6 source address selection.
 	[mlelstv, ticket #1079]
 
+sys/net/if.c	1.438,1.439
+sys/net/if.c	1.440
+sys/net/route.c	1.214-1.216
+sys/net/route.h	1.120
+sys/netinet/if_arp.c1.276
+sys/netinet6/in6.c1.270
+sys/netinet6/nd6.c1.251
+
+	Avoid race conditions on ifaddr and rtentry changes.
+	[ozaki-r, ticket #1080]
+
+sys/netinet6/udp6_usrreq.c			1.143
+	(applied to udp6_output.c due to code refactoring)
+
+	Restore the length check of a sockaddr passed from userland at
+	udp6_output.
+	[ozaki-r, ticket #1081]
+
+sys/fs/puffs/puffs_vnops.c			1.213
+
+	Fix use after RECLAIM in PUFFS filesystems.
+	[manu, ticket #1082]
 



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

2018-11-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov  6 14:47:38 UTC 2018

Modified Files:
src/sys/fs/puffs [netbsd-8]: puffs_vnops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #1082):

sys/fs/puffs/puffs_vnops.c: revision 1.213

Fix use after RECLAIM in PUFFS filesystems

>From hannken@

When puffs_cookie2vnode() misses an entry and vrele() it operations
puffs_vnop_reclaim() and puffs_vnop_fsync() get called with a VNON
vnode.

Do not notify the server in this case as the cookie is stale.


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.211.2.1 src/sys/fs/puffs/puffs_vnops.c

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

Modified files:

Index: src/sys/fs/puffs/puffs_vnops.c
diff -u src/sys/fs/puffs/puffs_vnops.c:1.211 src/sys/fs/puffs/puffs_vnops.c:1.211.2.1
--- src/sys/fs/puffs/puffs_vnops.c:1.211	Fri May 26 14:21:01 2017
+++ src/sys/fs/puffs/puffs_vnops.c	Tue Nov  6 14:47:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: puffs_vnops.c,v 1.211 2017/05/26 14:21:01 riastradh Exp $	*/
+/*	$NetBSD: puffs_vnops.c,v 1.211.2.1 2018/11/06 14:47:38 martin Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.211 2017/05/26 14:21:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.211.2.1 2018/11/06 14:47:38 martin Exp $");
 
 #include 
 #include 
@@ -1467,6 +1467,10 @@ puffs_vnop_reclaim(void *v)
 		notifyserver = false;
 	}
 
+	/* See the comment on top of puffs_vnop_inactive(). */
+	if (vp->v_type == VNON)
+		notifyserver = false;
+
 	/*
 	 * purge info from kernel before issueing FAF, since we
 	 * don't really know when we'll get around to it after
@@ -1720,6 +1724,11 @@ puffs_vnop_fsync(void *v)
 	pn = VPTOPP(vp);
 	KASSERT(pn != NULL);
 	pmp = MPTOPUFFSMP(vp->v_mount);
+
+	/* See the comment on top of puffs_vnop_inactive(). */
+	if (vp->v_type == VNON)
+		return 0;
+
 	if (ap->a_flags & FSYNC_WAIT) {
 		mutex_enter(&pn->pn_sizemtx);
 	} else {



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

2018-11-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov  6 14:44:23 UTC 2018

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

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #1081):

sys/netinet6/udp6_usrreq.c: revision 1.143
(applied to udp6_output.c, due to refactoring in -current)

Restore the length check of a sockaddr passed from userland at udp6_output

A sockaddr with invalid length could be passed to the network stack resulting in
a kernel panic like this:

panic: sockaddr_copy: source too long, 28 < 128 bytes
fatal breakpoint trap in supervisor mode
trap type 1 code 0 rip 0x80216c35 cs 0x8 rflags 0x246
cr2 0x7f7ff7ef3000 ilevel 0x4 rsp 0x80003308b690
curlwp 0xfe803e11ca40 pid 48.1 lowest kstack 0x8000330852c0
Stopped in pid 48.1 (a.out) at  netbsd:breakpoint+0x5:  leave
db{1}> bt
breakpoint() at netbsd:breakpoint+0x5
vpanic() at netbsd:vpanic+0x140
panic() at netbsd:panic+0x3c
sockaddr_copy() at netbsd:sockaddr_copy+0x95
rtcache_setdst() at netbsd:rtcache_setdst+0x73
rtcache_lookup2() at netbsd:rtcache_lookup2+0x56
in6_selectroute() at netbsd:in6_selectroute+0x184
in6_selectsrc() at netbsd:in6_selectsrc+0x119
udp6_output() at netbsd:udp6_output+0x25e
udp6_send_wrapper() at netbsd:udp6_send_wrapper+0x8a
sosend() at netbsd:sosend+0x7bf
do_sys_sendmsg_so() at netbsd:do_sys_sendmsg_so+0x28e
do_sys_sendmsg() at netbsd:do_sys_sendmsg+0x89
sys_sendto() at netbsd:sys_sendto+0x5c
syscall() at netbsd:syscall+0x1ed
--- syscall (number 133) ---
7f7ff790173a:

Reported by Paul Ripke


To generate a diff of this commit:
cvs rdiff -u -r1.55.6.1 -r1.55.6.2 src/sys/netinet6/udp6_output.c

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

Modified files:

Index: src/sys/netinet6/udp6_output.c
diff -u src/sys/netinet6/udp6_output.c:1.55.6.1 src/sys/netinet6/udp6_output.c:1.55.6.2
--- src/sys/netinet6/udp6_output.c:1.55.6.1	Sun Nov  4 11:14:09 2018
+++ src/sys/netinet6/udp6_output.c	Tue Nov  6 14:44:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: udp6_output.c,v 1.55.6.1 2018/11/04 11:14:09 martin Exp $	*/
+/*	$NetBSD: udp6_output.c,v 1.55.6.2 2018/11/06 14:44:22 martin Exp $	*/
 /*	$KAME: udp6_output.c,v 1.43 2001/10/15 09:19:52 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: udp6_output.c,v 1.55.6.1 2018/11/04 11:14:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp6_output.c,v 1.55.6.2 2018/11/06 14:44:22 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -139,6 +139,10 @@ udp6_output(struct in6pcb * const in6p, 
 
 	if (addr6) {
 		sin6 = addr6;
+		if (sin6->sin6_len != sizeof(*sin6)) {
+			error = EINVAL;
+			goto release;
+		}
 		if (sin6->sin6_family != AF_INET6) {
 			error = EAFNOSUPPORT;
 			goto release;



CVS commit: [netbsd-8] src/sys

2018-11-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov  6 14:38:58 UTC 2018

Modified Files:
src/sys/net [netbsd-8]: if.c route.c route.h
src/sys/netinet [netbsd-8]: if_arp.c
src/sys/netinet6 [netbsd-8]: in6.c nd6.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #1080):

sys/netinet6/nd6.c: revision 1.251
sys/netinet/if_arp.c: revision 1.276
sys/net/if.c: revision 1.438
sys/net/if.c: revision 1.439
sys/net/route.c: revision 1.214
sys/net/route.c: revision 1.215
sys/net/route.c: revision 1.216
sys/netinet6/in6.c: revision 1.270
sys/net/route.h: revision 1.120
sys/net/if.c: revision 1.440

Remove a wrong assertion in ifaref

 -

Doing ifref on an ifa with IFA_DESTROYING is not a problem; the reference should
be dropped during the destruction of the ifa.

 -

Use atomic operations for ifa_refcnt

 -

Avoid a dangling pointer during rt_replace_ifa

 -

Avoid double rt_replace_ifa on rtrequest1(RTM_ADD)

Some callers of rtrequest1(RTM_ADD) adjust rt_ifa of an rtentry created by
rtrequest1 that may change rt_ifa (in ifa_rtrequest) with another ifa that is
different from requested one.  It's wasteful and even worse introduces a race
condition.  rtrequest1 should just use a passed ifa as is if a caller hopes so.

 -

Use rt_update framework on updating a rtentry


To generate a diff of this commit:
cvs rdiff -u -r1.394.2.14 -r1.394.2.15 src/sys/net/if.c
cvs rdiff -u -r1.194.6.11 -r1.194.6.12 src/sys/net/route.c
cvs rdiff -u -r1.112.4.4 -r1.112.4.5 src/sys/net/route.h
cvs rdiff -u -r1.250.2.8 -r1.250.2.9 src/sys/netinet/if_arp.c
cvs rdiff -u -r1.245.2.11 -r1.245.2.12 src/sys/netinet6/in6.c
cvs rdiff -u -r1.232.2.8 -r1.232.2.9 src/sys/netinet6/nd6.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.394.2.14 src/sys/net/if.c:1.394.2.15
--- src/sys/net/if.c:1.394.2.14	Mon Aug 27 07:49:11 2018
+++ src/sys/net/if.c	Tue Nov  6 14:38:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.394.2.14 2018/08/27 07:49:11 martin Exp $	*/
+/*	$NetBSD: if.c,v 1.394.2.15 2018/11/06 14:38:58 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.394.2.14 2018/08/27 07:49:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.394.2.15 2018/11/06 14:38:58 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1777,8 +1777,8 @@ ifa_psref_init(struct ifaddr *ifa)
 void
 ifaref(struct ifaddr *ifa)
 {
-	KASSERT(!ISSET(ifa->ifa_flags, IFA_DESTROYING));
-	ifa->ifa_refcnt++;
+
+	atomic_inc_uint(&ifa->ifa_refcnt);
 }
 
 void
@@ -1787,7 +1787,7 @@ ifafree(struct ifaddr *ifa)
 	KASSERT(ifa != NULL);
 	KASSERT(ifa->ifa_refcnt > 0);
 
-	if (--ifa->ifa_refcnt == 0) {
+	if (atomic_dec_uint_nv(&ifa->ifa_refcnt) == 0) {
 		free(ifa, M_IFADDR);
 	}
 }
@@ -2177,7 +2177,8 @@ link_rtrequest(int cmd, struct rtentry *
 	struct psref psref;
 
 	if (cmd != RTM_ADD || (ifa = rt->rt_ifa) == NULL ||
-	(ifp = ifa->ifa_ifp) == NULL || (dst = rt_getkey(rt)) == NULL)
+	(ifp = ifa->ifa_ifp) == NULL || (dst = rt_getkey(rt)) == NULL ||
+	ISSET(info->rti_flags, RTF_DONTCHANGEIFA))
 		return;
 	if ((ifa = ifaof_ifpforaddr_psref(dst, ifp, &psref)) != NULL) {
 		rt_replace_ifa(rt, ifa);
@@ -2431,6 +2432,9 @@ p2p_rtrequest(int req, struct rtentry *r
 
 		rt->rt_ifp = lo0ifp;
 
+		if (ISSET(info->rti_flags, RTF_DONTCHANGEIFA))
+			break;
+
 		IFADDR_READER_FOREACH(ifa, ifp) {
 			if (equal(rt_getkey(rt), ifa->ifa_addr))
 break;

Index: src/sys/net/route.c
diff -u src/sys/net/route.c:1.194.6.11 src/sys/net/route.c:1.194.6.12
--- src/sys/net/route.c:1.194.6.11	Fri Sep  7 12:31:30 2018
+++ src/sys/net/route.c	Tue Nov  6 14:38:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.194.6.11 2018/09/07 12:31:30 martin Exp $	*/
+/*	$NetBSD: route.c,v 1.194.6.12 2018/11/06 14:38:58 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.194.6.11 2018/09/07 12:31:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.194.6.12 2018/11/06 14:38:58 martin Exp $");
 
 #include 
 #ifdef RTFLUSH_DEBUG
@@ -406,6 +406,11 @@ rt_ifa_connected(const struct rtentry *r
 void
 rt_replace_ifa(struct rtentry *rt, struct ifaddr *ifa)
 {
+	struct ifaddr *old;
+
+	if (rt->rt_ifa == ifa)
+		return;
+
 	if (rt->rt_ifa &&
 	rt->rt_ifa != ifa &&
 	rt->rt_ifa->ifa_flags & IFA_ROUTE &&
@@ -424,8 +429,9 @@ rt_replace_ifa(struct rtentry *rt, struc
 	}
 
 	ifaref(ifa);
-	ifafree(rt->rt_ifa);
+	old = rt->rt_ifa;
 	rt_set_ifa1(rt, ifa);
+	ifafree(old);
 }
 
 static void
@@ -1236,7 +1242,7 @@ rtrequest1(int req, struct rt_addrinfo *
 		if (rt == NULL)
 			senderr(ENOBUFS);
 		memset(rt, 0, sizeof(*r

CVS commit: src/tests/lib/libcurses/check_files

2018-11-06 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Nov  6 09:43:25 UTC 2018

Modified Files:
src/tests/lib/libcurses/check_files: background1.chk

Log Message:
Correct background check file for fixed curses behaviour.
This fixes lib/53676.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/check_files/background1.chk

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/libcurses/check_files/background1.chk
diff -u src/tests/lib/libcurses/check_files/background1.chk:1.1 src/tests/lib/libcurses/check_files/background1.chk:1.2
--- src/tests/lib/libcurses/check_files/background1.chk:1.1	Sun Apr 10 09:55:09 2011
+++ src/tests/lib/libcurses/check_files/background1.chk	Tue Nov  6 09:43:25 2018
@@ -1 +1 @@
-smulcup2;1Xcup3;1Xcup4;1Xcup5;1Xcup6;1Xcup7;1Xcup8;1Xcup9;1Xcup10;1Xcup11;1Xcup12;1XA
 AAAcup13;1Xcup14;1Xcup15;1Xcup16;1Xcup17;1Xcup18;1Xcup19;1Xcup20;1Xcup21;1Xcup22;1Xcup23;1XAA
 AAcup24;1XAAAcup1;1Xrmul
\ No newline at end of file
+smulcup2;1Xcup3;1Xcup4;1Xcup5;1Xcup6;1Xcup7;1Xcup8;1Xcup9;1Xcup10;1Xcup11;1Xcup12;1XA
 AAAcup13;1Xcup14;1Xcup15;1Xcup16;1Xcup17;1Xcup18;1Xcup19;1Xcup20;1Xcup21;1Xcup22;1Xcup23;1X

CVS commit: src/share/man/man4

2018-11-06 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Nov  6 09:14:08 UTC 2018

Modified Files:
src/share/man/man4: pms.4

Log Message:
Update man page to document z-axis emulation.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/share/man/man4/pms.4

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

Modified files:

Index: src/share/man/man4/pms.4
diff -u src/share/man/man4/pms.4:1.31 src/share/man/man4/pms.4:1.32
--- src/share/man/man4/pms.4:1.31	Sun Feb  4 18:17:59 2018
+++ src/share/man/man4/pms.4	Tue Nov  6 09:14:08 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: pms.4,v 1.31 2018/02/04 18:17:59 christos Exp $
+.\" $NetBSD: pms.4,v 1.32 2018/11/06 09:14:08 blymn Exp $
 .\"
 .\" Copyright (c) 1993 Christopher G. Demetriou
 .\" All rights reserved.
@@ -144,12 +144,15 @@ If set to 1, two-finger events generate 
 If set to 2, two-finger events generate a middle button click.
 .It Dv hw.synaptics.scale_x
 .It Dv hw.synaptics.scale_y
+.It Dv hw.synaptics.scale_z
 Scale factor used to divide movement deltas derived from Synaptics
-coordinates (0-6143) to yield more reasonable values (default 16).
+coordinates (0-6143) to yield more reasonable values (default 16 for x
+and y, 1 for z).
 .It Dv hw.synaptics.max_speed_x
 .It Dv hw.synaptics.max_speed_y
+.It Dv hw.synaptics.max_speed_z
 Limits pointer rate of change (after scaling) per reported movement
-event (default 32).
+event (default 32 for x and y, 2 for z).
 .It Dv hw.synaptics.movement_threshold
 Movements of less than this value (in Synaptics coordinates) are
 ignored (default 4).
@@ -175,6 +178,29 @@ event.
 For completeness, the region between the left hand side of the clickpad,
 button2_edge and button_boundary will be reported as a button1 event
 as will any clicks that occur outside the button emulation region.
+.It Dv hw.synaptics.finger_scroll-min
+The minimum finger width at which the driver will start reporting
+vertical movements as Z axis events.
+Effectively, this emulates a mouse scroll wheel by the user using two
+fingers together on the click pad.
+The default value is 5, this value cannot be less than 5 due to the way
+the clickpad reports finger width.
+.It Dv hw.synaptics.finger_scroll-max
+The maximum finger width at which the driver will report finger
+movement as Z axis events.
+The default value is 12 and cannot be greater than 14.
+.It Dv hw.synaptics.finger_scroll-hysteresis
+This defines the number of packets to continue with the Z axis emulation.
+Due to the nature of the clickpad maintaining constant contact can be
+difficult.
+This hysteresis value prevents the driver flipping between two finger
+scroll and normal mouse movement erratically.
+Each time a valid finger scroll width is detected the packet count is
+reset.
+If this variable is set too high then mouse movements will be interpreted
+as Z-axis events after the two finger scoll has finished.
+If the variable is set too low then there will be mouse movements observed
+during the two finger scroll.
 .El
 .Pp
 The following



CVS commit: src/sys/dev/pckbport

2018-11-06 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Nov  6 09:13:17 UTC 2018

Modified Files:
src/sys/dev/pckbport: synaptics.c synapticsvar.h

Log Message:
Add double finger scroll feature.  If the detected width is between a
defined range then report y movement as z-axis.  Effectively emulating
a mouse scroll wheel.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pckbport/synapticsvar.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/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.43 src/sys/dev/pckbport/synaptics.c:1.44
--- src/sys/dev/pckbport/synaptics.c:1.43	Tue Nov  6 08:55:02 2018
+++ src/sys/dev/pckbport/synaptics.c	Tue Nov  6 09:13:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.43 2018/11/06 08:55:02 blymn Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.44 2018/11/06 09:13:17 blymn Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.43 2018/11/06 08:55:02 blymn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.44 2018/11/06 09:13:17 blymn Exp $");
 
 #include 
 #include 
@@ -115,9 +115,14 @@ static int synaptics_button3 = SYNAPTICS
 static int synaptics_two_fingers_emul = 0;
 static int synaptics_scale_x = 16;
 static int synaptics_scale_y = 16;
+static int synaptics_scale_z = 1;
 static int synaptics_max_speed_x = 32;
 static int synaptics_max_speed_y = 32;
+static int synaptics_max_speed_z = 2;
 static int synaptics_movement_threshold = 4;
+static int synaptics_fscroll_min = 5;
+static int synaptics_fscroll_max = 12;
+static int synaptics_dz_hold = 30;
 static int synaptics_movement_enable = 1;
 
 /* Sysctl nodes. */
@@ -138,9 +143,14 @@ static int synaptics_finger_low_nodenum;
 static int synaptics_two_fingers_emul_nodenum;
 static int synaptics_scale_x_nodenum;
 static int synaptics_scale_y_nodenum;
+static int synaptics_scale_z_nodenum;
 static int synaptics_max_speed_x_nodenum;
 static int synaptics_max_speed_y_nodenum;
+static int synaptics_max_speed_z_nodenum;
 static int synaptics_movement_threshold_nodenum;
+static int synaptics_finger_scroll_min_nodenum;
+static int synaptics_finger_scroll_max_nodenum;
+static int synaptics_dz_hold_nodenum;
 static int synaptics_movement_enable_nodenum;
 
 static int
@@ -424,7 +434,7 @@ pms_synaptics_enable(void *vsc)
 	struct pms_softc *psc = vsc;
 	struct synaptics_softc *sc = &psc->u.synaptics;
 	u_char enable_modes;
-	int res;
+	int res, i;
 
 	if (sc->flags & SYN_FLAG_HAS_PASSTHROUGH) {
 		/*
@@ -452,7 +462,7 @@ pms_synaptics_enable(void *vsc)
  	*/
 	synaptics_poll_cmd(psc, PMS_DEV_DISABLE, 0);
 	/* a couple of set scales to clear out pending commands */
-	for (int i = 0; i < 2; i++)
+	for (i = 0; i < 2; i++)
 		synaptics_poll_cmd(psc, PMS_SET_SCALE11, 0);
 
 	res = synaptics_special_write(psc, SYNAPTICS_CMD_SET_MODE2, enable_modes);
@@ -460,7 +470,7 @@ pms_synaptics_enable(void *vsc)
 		aprint_error("synaptics: set mode error\n");
 
 	/* a couple of set scales to clear out pending commands */
-	for (int i = 0; i < 2; i++)
+	for (i = 0; i < 2; i++)
 		synaptics_poll_cmd(psc, PMS_SET_SCALE11, 0);
 
 	/* Set advanced gesture mode */
@@ -476,10 +486,11 @@ pms_synaptics_enable(void *vsc)
 	sc->gesture_tap_packet = 0;
 	sc->gesture_type = 0;
 	sc->gesture_buttons = 0;
-	sc->rem_x[0] = sc->rem_y[0] = 0;
-	sc->rem_x[1] = sc->rem_y[1] = 0;
-	sc->movement_history[0] = 0;
-	sc->movement_history[1] = 0;
+	sc->dz_hold = 0;
+	for (i = 0; i < SYN_MAX_FINGERS; i++) {
+		sc->rem_x[i] = sc->rem_y[i] = sc->rem_z[i] = 0;
+		sc->movement_history[i] = 0;
+	}
 	sc->button_history = 0;
 }
 
@@ -673,6 +684,18 @@ pms_sysctl_synaptics(struct sysctllog **
 
 	if ((rc = sysctl_createv(clog, 0, NULL, &node,
 	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+	CTLTYPE_INT, "scale_z",
+	SYSCTL_DESCR("Sroll wheel emulation scale factor"),
+	pms_sysctl_synaptics_verify, 0,
+	&synaptics_scale_z,
+	0, CTL_HW, root_num, CTL_CREATE,
+	CTL_EOL)) != 0)
+		goto err;
+
+	synaptics_scale_z_nodenum = node->sysctl_num;
+
+	if ((rc = sysctl_createv(clog, 0, NULL, &node,
+	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
 	CTLTYPE_INT, "max_speed_x",
 	SYSCTL_DESCR("Horizontal movement maximum speed"),
 	pms_sysctl_synaptics_verify, 0,
@@ -697,6 +720,18 @@ pms_sysctl_synaptics(struct sysctllog **
 
 	if ((rc = sysctl_createv(clog, 0, NULL, &node,
 	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+	CTLTYPE_INT, "max_speed_z",
+	SYSCTL_DESCR("Scroll wheel emulation maximum speed"),
+	pms_sysctl_synaptics_verify, 0,
+	&synaptics_max_speed_z,
+	0, CTL_HW, root_num, CTL_CREATE,
+	CTL_EOL)) != 0)
+		goto err;
+
+	synaptics_max_speed_z_nodenum = node->sysctl_num;
+
+	if ((rc = sysctl_createv(clog, 0, NULL, &node,
+	CTLFLAG_PERMANENT |

CVS commit: src/sys/dev/pckbport

2018-11-06 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Tue Nov  6 08:55:02 UTC 2018

Modified Files:
src/sys/dev/pckbport: synaptics.c

Log Message:
Fix clamping of deltas so it works for both positive and negative deltas.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/pckbport/synaptics.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/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.42 src/sys/dev/pckbport/synaptics.c:1.43
--- src/sys/dev/pckbport/synaptics.c:1.42	Sat Jul 14 00:47:33 2018
+++ src/sys/dev/pckbport/synaptics.c	Tue Nov  6 08:55:02 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.42 2018/07/14 00:47:33 maya Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.43 2018/11/06 08:55:02 blymn Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.42 2018/07/14 00:47:33 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.43 2018/11/06 08:55:02 blymn Exp $");
 
 #include 
 #include 
@@ -1485,10 +1485,10 @@ synaptics_movement(struct synaptics_soft
 	/*
 	 * Clamp deltas to specified maximums.
 	 */
-	if (dx > synaptics_max_speed_x)
-		dx = synaptics_max_speed_x;
-	if (dy > synaptics_max_speed_y)
-		dy = synaptics_max_speed_y;
+	if (abs(dx) > synaptics_max_speed_x)
+		dx = ((dx >= 0)? 1 : -1) * synaptics_max_speed_x;
+	if (abs(dy) > synaptics_max_speed_y)
+		dy = ((dy >= 0)? 1 : -1) * synaptics_max_speed_y;
 
 	*dxp = dx;
 	*dyp = dy;