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

2020-10-09 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sat Oct 10 03:29:48 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: if_scx.c

Log Message:
reorder functions for better relevance


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/sociox/if_scx.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/sociox/if_scx.c
diff -u src/sys/arch/arm/sociox/if_scx.c:1.22 src/sys/arch/arm/sociox/if_scx.c:1.23
--- src/sys/arch/arm/sociox/if_scx.c:1.22	Sat Mar 28 13:15:24 2020
+++ src/sys/arch/arm/sociox/if_scx.c	Sat Oct 10 03:29:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_scx.c,v 1.22 2020/03/28 13:15:24 nisimura Exp $	*/
+/*	$NetBSD: if_scx.c,v 1.23 2020/10/10 03:29:48 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,35 +29,24 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NOT_MP_SAFE	0
 
 /*
  * Socionext SC2A11 SynQuacer NetSec GbE driver
  *
- *   (possibly incorrect notes to be removed eventually)
- * - 32 byte descriptor for 64 bit paddr design.
- * - multiple rings seems available. There are special descriptor fields
- *   to designify ring number from which to arrive or to which go.
- * - memory mapped EEPROM to hold MAC address. The rest of the area is
- *   occupied by a set of ucode for two DMA engines and one packet engine.
- * - The size of frame address filter is 16 plus 16.
- * - The first slot is my own station address. Always enabled to perform
- *   to identify oneself.
- * - 1~15 are for supplimental MAC addresses. Independently enabled for
- *   use. Good to catch multicast. Byte-wise selective match available.
- *   Use the mask to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }.
- * - 16~32 might be exact match without byte-mask.
- * - The size of multicast hash filter store is 64 bit.
- * - Socionext/Linaro "NetSec" code contains some constants left unexplained.
- *   Fortunately, Intel/Altera CycloneV PDFs describe every detail of
- *   "such the instance of" DW EMAC IP and most of them are likely applicable
- *   to SC2A11 GbE.
- * - not known "NetSec" instanciates DW timestamp or builds its own.
- * - DW EMAC implmentation (0x20) is known 0x10.36
+ * Multiple Tx and Rx queues exist inside and dedicated descriptor
+ * fields specifies which queue is to use. Three internal micro-processors
+ * to handle incoming frames, outgoing frames and packet data crypto
+ * processing. uP programs are stored in an external flash memory and
+ * have to be loaded by device driver.
+ * NetSec uses Synopsys DesignWare Core EMAC.  DWC implmentation
+ * regiter (0x20) is known to have 0x10.36 and feature register (0x1058)
+ * to report XX.XX.
  */
 
+#define NOT_MP_SAFE	0
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.22 2020/03/28 13:15:24 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.23 2020/10/10 03:29:48 nisimura Exp $");
 
 #include 
 #include 
@@ -84,8 +73,47 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #include 
 #include 
 
+/* Socionext SC2A11 descriptor format */
+struct tdes {
+	uint32_t t0, t1, t2, t3;
+};
+
+struct rdes {
+	uint32_t r0, r1, r2, r3;
+};
+
+#define T0_OWN		(1U<<31)	/* desc is ready to Tx */
+#define T0_EOD		(1U<<30)	/* end of descriptor array */
+#define T0_DRID		(24)		/* 29:24 D-RID */
+#define T0_PT		(1U<<21)	/* 23:21 PT */
+#define T0_TRID		(16)		/* 20:16 T-RID */
+#define T0_FS		(1U<<9)		/* first segment of frame */
+#define T0_LS		(1U<<8)		/* last segment of frame */
+#define T0_CSUM		(1U<<7)		/* enable check sum offload */
+#define T0_SGOL		(1U<<6)		/* enable TCP segment offload */
+#define T0_TRS		(1U<<4)		/* 5:4 TRS */
+#define T0_IOC		(0)		/* XXX TBD interrupt when completed */
+/* T1 segment address 63:32 */
+/* T2 segment address 31:0 */
+/* T3 31:16 TCP segment length, 15:0 segment length to transmit */
+
+#define R0_OWN		(1U<<31)	/* desc is empty */
+#define R0_EOD		(1U<<30)	/* end of descriptor array */
+#define R0_SRID		(24)		/* 29:24 S-RID */
+#define R0_FR		(1U<<23)	/* FR */
+#define R0_ER		(1U<<21)	/* Rx error indication */
+#define R0_ERR		(3U<<16)	/* 18:16 receive error code */
+#define R0_TDRID	(14)		/* 15:14 TD-RID */
+#define R0_FS		(1U<<9)		/* first segment of frame */
+#define R0_LS		(1U<<8)		/* last segment of frame */
+#define R0_CSUM		(3U<<6)		/* 7:6 checksum status */
+#define R0_CERR		(2U<<6)		/* 0 (undone), 1 (found ok), 2 (bad) */
+/* R1 frame address 63:32 */
+/* R2 frame address 31:0 */
+/* R3 31:16 received frame length, 15:0 buffer length to receive */
+
 /*
- * SC2A11 register block 0x100-0x1204?
+ * SC2A11 NetSec registers. 0x100 - 1204
  */
 #define SWRESET		0x104
 #define COMINIT		0x120
@@ -98,7 +126,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define xINTBEN		0x23c		/* INT_B enable */
 #define xINTB_SET	0x240		/* bit to set */
 #define xINTB_CLR	0x244		/* bit to clr */
-/* 0x00c-048 */		/* pkt,tls,s0,s1 SR/IE/SET/CLR */
+/* 0x00c - 048 

CVS commit: src/sys

2020-10-09 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Oct 10 03:05:04 UTC 2020

Modified Files:
src/sys/arch/alpha/alpha: clock.c cpu.c interrupt.c ipifuncs.c
src/sys/arch/alpha/include: alpha.h cpu_counter.h intr.h
src/sys/kern: kern_cctr.c
src/sys/sys: cctr.h

Log Message:
Fix cycle counter-based time keeping on Alpha in MP environments by using
a simpler calibration algorithm for the CC timecounter.  Proposed in 2018
by Naruaki Etomi:

https://mail-index.netbsd.org/tech-kern/2018/01/14/msg022940.html

This patch is largely based on the proposed change, but avoids changing
any other timecounter logic, and re-factors things a bit to keep them
as MI as possible.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/alpha/alpha/clock.c
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/alpha/alpha/cpu.c
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/alpha/alpha/interrupt.c
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/alpha/alpha/ipifuncs.c
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/alpha/include/alpha.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/include/cpu_counter.h
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/alpha/include/intr.h
cvs rdiff -u -r1.10 -r1.11 src/sys/kern/kern_cctr.c
cvs rdiff -u -r1.3 -r1.4 src/sys/sys/cctr.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/alpha/alpha/clock.c
diff -u src/sys/arch/alpha/alpha/clock.c:1.45 src/sys/arch/alpha/alpha/clock.c:1.46
--- src/sys/arch/alpha/alpha/clock.c:1.45	Tue Sep 29 01:33:00 2020
+++ src/sys/arch/alpha/alpha/clock.c	Sat Oct 10 03:05:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.45 2020/09/29 01:33:00 thorpej Exp $ */
+/* $NetBSD: clock.c,v 1.46 2020/10/10 03:05:04 thorpej Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.45 2020/09/29 01:33:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.46 2020/10/10 03:05:04 thorpej Exp $");
 
 #include 
 #include 
@@ -59,6 +59,8 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.
 void (*clock_init)(void *);
 void *clockdev;
 
+int	alpha_use_cctr;		/* != 0 if we're using the PCC timecounter */
+
 void
 clockattach(void (*fns)(void *), void *dev)
 {
@@ -111,6 +113,7 @@ cpu_initclocks(void)
 	if (! alpha_is_qemu) {
 		const uint64_t pcc_freq = cpu_frequency(curcpu());
 		cc_init(NULL, pcc_freq, "PCC", PCC_QUAL);
+		alpha_use_cctr = 1;
 	}
 
 	/*

Index: src/sys/arch/alpha/alpha/cpu.c
diff -u src/sys/arch/alpha/alpha/cpu.c:1.101 src/sys/arch/alpha/alpha/cpu.c:1.102
--- src/sys/arch/alpha/alpha/cpu.c:1.101	Tue Sep 29 01:33:00 2020
+++ src/sys/arch/alpha/alpha/cpu.c	Sat Oct 10 03:05:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.101 2020/09/29 01:33:00 thorpej Exp $ */
+/* $NetBSD: cpu.c,v 1.102 2020/10/10 03:05:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.101 2020/09/29 01:33:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.102 2020/10/10 03:05:04 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -602,7 +602,9 @@ cpu_hatch(struct cpu_info *ci)
 	ALPHA_TBIA();
 	alpha_pal_imb();
 
-	cc_calibrate_cpu(ci);
+	if (alpha_use_cctr) {
+		cc_init_secondary(ci);
+	}
 
 	cpu_initclocks_secondary();
 }

Index: src/sys/arch/alpha/alpha/interrupt.c
diff -u src/sys/arch/alpha/alpha/interrupt.c:1.91 src/sys/arch/alpha/alpha/interrupt.c:1.92
--- src/sys/arch/alpha/alpha/interrupt.c:1.91	Sat Sep 26 21:07:48 2020
+++ src/sys/arch/alpha/alpha/interrupt.c	Sat Oct 10 03:05:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: interrupt.c,v 1.91 2020/09/26 21:07:48 thorpej Exp $ */
+/* $NetBSD: interrupt.c,v 1.92 2020/10/10 03:05:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.91 2020/09/26 21:07:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.92 2020/10/10 03:05:04 thorpej Exp $");
 
 #include 
 #include 
@@ -228,6 +228,12 @@ interrupt(unsigned long a0, unsigned lon
 			 */
 			(*platform.clockintr)((struct clockframe *)framep);
 
+#if defined(MULTIPROCESSOR)
+			if (alpha_use_cctr) {
+cc_hardclock(ci);
+			}
+#endif /* MULTIPROCESSOR */
+
 			/*
 			 * If it's time to call the scheduler clock,
 			 * do so.

Index: src/sys/arch/alpha/alpha/ipifuncs.c
diff -u src/sys/arch/alpha/alpha/ipifuncs.c:1.53 src/sys/arch/alpha/alpha/ipifuncs.c:1.54
--- src/sys/arch/alpha/alpha/ipifuncs.c:1.53	Thu Sep  3 02:03:14 2020
+++ src/sys/arch/alpha/alpha/ipifuncs.c	Sat Oct 10 03:05:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ipifuncs.c,v 1.53 2020/09/03 02:03:14 thorpej Exp $ */
+/* $NetBSD: ipifuncs.c,v 1.54 2020/10/10 03:05:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 

CVS commit: src/sys/kern

2020-10-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Oct 10 00:10:06 UTC 2020

Modified Files:
src/sys/kern: core_elf32.c

Log Message:
Use correct note types for register storage in 32-bit core files for
architecture on which 64- and 32-bit ABIs use different values for
PT_GET{,FP}REGS, i.e., aarch64{,eb}.

Now, 32-bit GDB works fine for core files generated by aarch64{,eb}
kernel.

Should be no functional changes for ports other than aarch64{,eb}.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/kern/core_elf32.c

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

Modified files:

Index: src/sys/kern/core_elf32.c
diff -u src/sys/kern/core_elf32.c:1.64 src/sys/kern/core_elf32.c:1.65
--- src/sys/kern/core_elf32.c:1.64	Sat May 30 16:12:56 2020
+++ src/sys/kern/core_elf32.c	Sat Oct 10 00:10:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: core_elf32.c,v 1.64 2020/05/30 16:12:56 thorpej Exp $	*/
+/*	$NetBSD: core_elf32.c,v 1.65 2020/10/10 00:10:06 rin Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.64 2020/05/30 16:12:56 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.65 2020/10/10 00:10:06 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd32.h"
@@ -65,6 +65,10 @@ __KERNEL_RCSID(1, "$NetBSD: core_elf32.c
 
 #include 
 
+#ifdef COMPAT_NETBSD32
+#include 
+#endif
+
 struct writesegs_state {
 	Elf_Phdr *psections;
 	proc_t   *p;
@@ -510,8 +514,13 @@ ELFNAMEEND(coredump_note)(struct lwp *l,
 	if (error)
 		goto out;
 
-	ELFNAMEEND(coredump_savenote)(ns, PT_GETREGS, d->name, >intreg,
-	sizeof(d->intreg));
+	ELFNAMEEND(coredump_savenote)(ns,
+#if ELFSIZE == 32 && defined(PT32_GETREGS)
+	PT32_GETREGS,
+#else
+	PT_GETREGS,
+#endif
+	d->name, >intreg, sizeof(d->intreg));
 
 #ifdef PT_GETFPREGS
 	freglen = sizeof(d->freg);
@@ -519,8 +528,13 @@ ELFNAMEEND(coredump_note)(struct lwp *l,
 	if (error)
 		goto out;
 
-	ELFNAMEEND(coredump_savenote)(ns, PT_GETFPREGS, d->name, >freg,
-	freglen);
+	ELFNAMEEND(coredump_savenote)(ns,
+#  if ELFSIZE == 32 && defined(PT32_GETFPREGS)
+	PT32_GETFPREGS,
+#  else
+	PT_GETFPREGS,
+#  endif
+	d->name, >freg, freglen);
 #endif
 
 #ifdef COREDUMP_MACHDEP_LWP_NOTES



CVS commit: src/share/mk

2020-10-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Oct  9 23:58:50 UTC 2020

Modified Files:
src/share/mk: bsd.own.mk

Log Message:
Build GDB for aarch64eb; it works just fine as far as I can see.


To generate a diff of this commit:
cvs rdiff -u -r1.1224 -r1.1225 src/share/mk/bsd.own.mk

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

Modified files:

Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.1224 src/share/mk/bsd.own.mk:1.1225
--- src/share/mk/bsd.own.mk:1.1224	Fri Oct  9 05:41:16 2020
+++ src/share/mk/bsd.own.mk	Fri Oct  9 23:58:50 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.1224 2020/10/09 05:41:16 mrg Exp $
+#	$NetBSD: bsd.own.mk,v 1.1225 2020/10/09 23:58:50 rin Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -829,8 +829,6 @@ MKGCC:= no
 MKGCC:= no
 .endif
 
-# No GDB support for aarch64eb
-MKGDB.aarch64eb=no
 MKGDB.or1k=	no
 MKGDB.riscv32=	no
 MKGDB.riscv64=	no



CVS commit: src/sys/compat/netbsd32

2020-10-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Oct 10 00:03:53 UTC 2020

Modified Files:
src/sys/compat/netbsd32: netbsd32_syscall.h netbsd32_syscallargs.h
netbsd32_syscalls.c netbsd32_syscalls_autoload.c netbsd32_sysent.c
netbsd32_systrace_args.c

Log Message:
regen for getrandom(2)


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/compat/netbsd32/netbsd32_syscall.h
cvs rdiff -u -r1.153 -r1.154 src/sys/compat/netbsd32/netbsd32_syscallargs.h \
src/sys/compat/netbsd32/netbsd32_syscalls.c
cvs rdiff -u -r1.33 -r1.34 \
src/sys/compat/netbsd32/netbsd32_syscalls_autoload.c
cvs rdiff -u -r1.152 -r1.153 src/sys/compat/netbsd32/netbsd32_sysent.c
cvs rdiff -u -r1.44 -r1.45 src/sys/compat/netbsd32/netbsd32_systrace_args.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_syscall.h
diff -u src/sys/compat/netbsd32/netbsd32_syscall.h:1.154 src/sys/compat/netbsd32/netbsd32_syscall.h:1.155
--- src/sys/compat/netbsd32/netbsd32_syscall.h:1.154	Sat May 16 18:31:48 2020
+++ src/sys/compat/netbsd32/netbsd32_syscall.h	Sat Oct 10 00:03:52 2020
@@ -1,10 +1,10 @@
-/* $NetBSD: netbsd32_syscall.h,v 1.154 2020/05/16 18:31:48 christos Exp $ */
+/* $NetBSD: netbsd32_syscall.h,v 1.155 2020/10/10 00:03:52 rin Exp $ */
 
 /*
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.137 2020/04/26 19:18:36 thorpej Exp
+ * created from	NetBSD: syscalls.master,v 1.139 2020/10/10 00:00:54 rin Exp
  */
 
 #ifndef _NETBSD32_SYS_SYSCALL_H_
@@ -271,6 +271,9 @@
 /* syscall: "netbsd32_dup2" ret: "int" args: "int" "int" */
 #define	NETBSD32_SYS_netbsd32_dup2	90
 
+/* syscall: "netbsd32_getrandom" ret: "netbsd32_ssize_t" args: "netbsd32_voidp" "netbsd32_size_t" "unsigned int" */
+#define	NETBSD32_SYS_netbsd32_getrandom	91
+
 /* syscall: "netbsd32_fcntl" ret: "int" args: "int" "int" "..." */
 #define	NETBSD32_SYS_netbsd32_fcntl	92
 

Index: src/sys/compat/netbsd32/netbsd32_syscallargs.h
diff -u src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.153 src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.154
--- src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.153	Sat May 16 18:31:48 2020
+++ src/sys/compat/netbsd32/netbsd32_syscallargs.h	Sat Oct 10 00:03:52 2020
@@ -1,10 +1,10 @@
-/* $NetBSD: netbsd32_syscallargs.h,v 1.153 2020/05/16 18:31:48 christos Exp $ */
+/* $NetBSD: netbsd32_syscallargs.h,v 1.154 2020/10/10 00:03:52 rin Exp $ */
 
 /*
  * System call argument lists.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.137 2020/04/26 19:18:36 thorpej Exp
+ * created from	NetBSD: syscalls.master,v 1.139 2020/10/10 00:00:54 rin Exp
  */
 
 #ifndef _NETBSD32_SYS_SYSCALLARGS_H_
@@ -471,6 +471,13 @@ struct netbsd32_dup2_args {
 };
 check_syscall_args(netbsd32_dup2)
 
+struct netbsd32_getrandom_args {
+	syscallarg(netbsd32_voidp) buf;
+	syscallarg(netbsd32_size_t) buflen;
+	syscallarg(unsigned int) flags;
+};
+check_syscall_args(netbsd32_getrandom)
+
 struct netbsd32_fcntl_args {
 	syscallarg(int) fd;
 	syscallarg(int) cmd;
@@ -2928,6 +2935,8 @@ int	compat_43_sys_getdtablesize(struct l
 
 int	netbsd32_dup2(struct lwp *, const struct netbsd32_dup2_args *, register_t *);
 
+int	netbsd32_getrandom(struct lwp *, const struct netbsd32_getrandom_args *, register_t *);
+
 int	netbsd32_fcntl(struct lwp *, const struct netbsd32_fcntl_args *, register_t *);
 
 int	compat_50_netbsd32_select(struct lwp *, const struct compat_50_netbsd32_select_args *, register_t *);
Index: src/sys/compat/netbsd32/netbsd32_syscalls.c
diff -u src/sys/compat/netbsd32/netbsd32_syscalls.c:1.153 src/sys/compat/netbsd32/netbsd32_syscalls.c:1.154
--- src/sys/compat/netbsd32/netbsd32_syscalls.c:1.153	Sat May 16 18:31:48 2020
+++ src/sys/compat/netbsd32/netbsd32_syscalls.c	Sat Oct 10 00:03:53 2020
@@ -1,14 +1,14 @@
-/* $NetBSD: netbsd32_syscalls.c,v 1.153 2020/05/16 18:31:48 christos Exp $ */
+/* $NetBSD: netbsd32_syscalls.c,v 1.154 2020/10/10 00:03:53 rin Exp $ */
 
 /*
  * System call names.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.137 2020/04/26 19:18:36 thorpej Exp
+ * created from	NetBSD: syscalls.master,v 1.139 2020/10/10 00:00:54 rin Exp
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscalls.c,v 1.153 2020/05/16 18:31:48 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscalls.c,v 1.154 2020/10/10 00:03:53 rin Exp $");
 
 #if defined(_KERNEL_OPT)
 #if defined(_KERNEL_OPT)
@@ -121,7 +121,7 @@ const char *const netbsd32_syscallnames[
 	/*  88 */	"compat_43_netbsd32_osethostname",
 	/*  89 */	"compat_43_ogetdtablesize",
 	/*  90 */	"netbsd32_dup2",
-	/*  91 */	"#91 (unimplemented getdopt)",
+	/*  91 */	"netbsd32_getrandom",
 	/*  92 */	"netbsd32_fcntl",
 	/*  93 */	"compat_50_netbsd32_select",
 	/* 

CVS commit: src/sys/compat/netbsd32

2020-10-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Oct 10 00:00:54 UTC 2020

Modified Files:
src/sys/compat/netbsd32: netbsd32_netbsd.c syscalls.master

Log Message:
Teach about getrandom(2) to COMPAT_NETBSD32.


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/sys/compat/netbsd32/netbsd32_netbsd.c
cvs rdiff -u -r1.138 -r1.139 src/sys/compat/netbsd32/syscalls.master

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_netbsd.c
diff -u src/sys/compat/netbsd32/netbsd32_netbsd.c:1.229 src/sys/compat/netbsd32/netbsd32_netbsd.c:1.230
--- src/sys/compat/netbsd32/netbsd32_netbsd.c:1.229	Sat May 16 18:31:48 2020
+++ src/sys/compat/netbsd32/netbsd32_netbsd.c	Sat Oct 10 00:00:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_netbsd.c,v 1.229 2020/05/16 18:31:48 christos Exp $	*/
+/*	$NetBSD: netbsd32_netbsd.c,v 1.230 2020/10/10 00:00:54 rin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001, 2008, 2018 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.229 2020/05/16 18:31:48 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.230 2020/10/10 00:00:54 rin Exp $");
 
 /*
  * below are all the standard NetBSD system calls, in the 32bit
@@ -2607,6 +2607,22 @@ netbsd32__pset_bind(struct lwp *l,
 	return sys__pset_bind(l, , retval);
 }
 
+int
+netbsd32_getrandom(struct lwp *l, const struct netbsd32_getrandom_args *uap,
+register_t *retval)
+{
+	/* {
+		syscallarg(netbsd32_voidp)	buf;
+		syscallarg(netbsd32_size_t)	buflen;
+		syscallarg(unsigned)		flags;
+	} */
+	struct sys_getrandom_args ua;
+
+	NETBSD32TOP_UAP(buf, void *);
+	NETBSD32TOX_UAP(buflen, size_t);
+	NETBSD32TO64_UAP(flags);
+	return sys_getrandom(l, , retval);
+}
 
 /*
  * MI indirect system call support.

Index: src/sys/compat/netbsd32/syscalls.master
diff -u src/sys/compat/netbsd32/syscalls.master:1.138 src/sys/compat/netbsd32/syscalls.master:1.139
--- src/sys/compat/netbsd32/syscalls.master:1.138	Sat May 16 18:31:48 2020
+++ src/sys/compat/netbsd32/syscalls.master	Sat Oct 10 00:00:54 2020
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.138 2020/05/16 18:31:48 christos Exp $
+	$NetBSD: syscalls.master,v 1.139 2020/10/10 00:00:54 rin Exp $
 
 ;	from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp
 ;	@(#)syscalls.master	8.2 (Berkeley) 1/13/94
@@ -235,7 +235,9 @@
 89	COMPAT_43 MODULAR compat_43	\
 			{ int|sys||getdtablesize(void); } ogetdtablesize
 90	STD		{ int|netbsd32||dup2(int from, int to); }
-91	UNIMPL		getdopt
+91	STD		{ netbsd32_ssize_t|netbsd32||getrandom( \
+			netbsd32_voidp buf, netbsd32_size_t buflen, \
+			unsigned int flags); }
 92	STD		{ int|netbsd32||fcntl(int fd, int cmd, \
 			... netbsd32_voidp arg); }
 93	COMPAT_50 MODULAR compat_netbsd32_50	\



CVS commit: src/external/gpl3/gdb.old/lib/libbfd

2020-10-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Oct  9 23:55:48 UTC 2020

Modified Files:
src/external/gpl3/gdb.old/lib/libbfd: Makefile

Log Message:
Adjust for aarch64eb; it needs elf32-aarch64.c.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/gpl3/gdb.old/lib/libbfd/Makefile

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

Modified files:

Index: src/external/gpl3/gdb.old/lib/libbfd/Makefile
diff -u src/external/gpl3/gdb.old/lib/libbfd/Makefile:1.8 src/external/gpl3/gdb.old/lib/libbfd/Makefile:1.9
--- src/external/gpl3/gdb.old/lib/libbfd/Makefile:1.8	Mon Sep 14 00:40:37 2020
+++ src/external/gpl3/gdb.old/lib/libbfd/Makefile	Fri Oct  9 23:55:48 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2020/09/14 00:40:37 christos Exp $
+#	$NetBSD: Makefile,v 1.9 2020/10/09 23:55:48 rin Exp $
 
 .include 
 .include "../Makefile.inc"
@@ -22,7 +22,7 @@ DPSRCS+=	elf32-target.h elf64-target.h t
 		elf32-ia64.c elf64-ia64.c elf64-aarch64.c \
 		peigen.c pex64igen.c
 CLEANFILES+=	elf32-target.h elf64-target.h targmatch.h \
-		elf32-ia64.c elf64-ia64.c elf64-aarch64.c \
+		elf32-ia64.c elf64-ia64.c elf64-aarch64.c elf32-aarch64.c \
 		peigen.c pex64igen.c
 
 .PATH: ${DIST}/bfd
@@ -54,6 +54,10 @@ elf64-ia64.c: elfxx-ia64.c
 	${_MKTARGET_CREATE}
 	${TOOL_SED} -e s/NN/64/g < $> > $@
 
+elf32-aarch64.c: elfnn-aarch64.c
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e s/NN/32/g < $> > $@
+
 elf64-aarch64.c: elfnn-aarch64.c
 	${_MKTARGET_CREATE}
 	${TOOL_SED} -e s/NN/64/g < $> > $@



CVS commit: src/tools/gdb

2020-10-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Oct  9 23:48:42 UTC 2020

Modified Files:
src/tools/gdb: mknative-gdb.old

Log Message:
Correct target directory; src/external/gpl3/gdb.old not gdb.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tools/gdb/mknative-gdb.old

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

Modified files:

Index: src/tools/gdb/mknative-gdb.old
diff -u src/tools/gdb/mknative-gdb.old:1.1 src/tools/gdb/mknative-gdb.old:1.2
--- src/tools/gdb/mknative-gdb.old:1.1	Thu Sep 17 02:14:48 2020
+++ src/tools/gdb/mknative-gdb.old	Fri Oct  9 23:48:42 2020
@@ -1,8 +1,8 @@
 #!/bin/sh
-#	$NetBSD: mknative-gdb.old,v 1.1 2020/09/17 02:14:48 christos Exp $
+#	$NetBSD: mknative-gdb.old,v 1.2 2020/10/09 23:48:42 rin Exp $
 #
 # Shell script for generating all the constants needed for a native
-# platform build of src/external/gpl3/gdb
+# platform build of src/external/gpl3/gdb.old
 #
 
 # initialise
@@ -12,7 +12,7 @@ _TOP=$3
 _PLATFORM=$4
 _MACHINE_SUBDIR=$5
 _VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ 	]*,,'`
-_GDB=external/gpl3/gdb
+_GDB=external/gpl3/gdb.old
 
 . $_TOP/tools/gcc/mknative.common
 



CVS commit: src/tools/gdb

2020-10-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Oct  9 23:44:46 UTC 2020

Modified Files:
src/tools/gdb: README.mknative

Log Message:
Nowadays, mknative-gdb puts files into external/gpl3/gdb/lib,
instead of external/gpl3/gdb/bin/gdb.

Also, we need to nbmake-MACHINE in external/gpl3/gdb in order to
build dependent libraries correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tools/gdb/README.mknative

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

Modified files:

Index: src/tools/gdb/README.mknative
diff -u src/tools/gdb/README.mknative:1.6 src/tools/gdb/README.mknative:1.7
--- src/tools/gdb/README.mknative:1.6	Fri Jun 21 07:05:02 2019
+++ src/tools/gdb/README.mknative	Fri Oct  9 23:44:46 2020
@@ -1,4 +1,4 @@
-$NetBSD: README.mknative,v 1.6 2019/06/21 07:05:02 maya Exp $
+$NetBSD: README.mknative,v 1.7 2020/10/09 23:44:46 rin Exp $
 
 This file describes how to use the cross-compiler to generate the
 native files for GDB on a target platform.
@@ -34,11 +34,11 @@ work.
native-to-NetBSD GDB on a cross host, and mknative pulls glue data
from this.
 
-   NOTE: this step writes files under src/external/gpl3/gdb/bin/gdb, so you
+   NOTE: this step writes files under src/external/gpl3/gdb/lib, so you
need to do it in a writable src tree!
 
 6. Try out a full build using "nbmake-MACHINE" in
-   src/external/gpl3/gdb/bin; the result should include a native GDB.
+   src/external/gpl3/gdb; the result should include a native GDB.
 
 7. If all is well, commit the glue files and directories added to
-   src/external/gpl3/gdb/bin/gdb.
+   src/external/gpl3/gdb/lib.



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

2020-10-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  9 21:14:05 UTC 2020

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

Log Message:
Don't do extra work finding the power of 2 for values we are not going to
use. Explain that cpu_hatch has not been called yet, so no cpu_probe either
so the cache info is 0 for AP's.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/sys/arch/x86/x86/cpu.c

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

Modified files:

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.198 src/sys/arch/x86/x86/cpu.c:1.199
--- src/sys/arch/x86/x86/cpu.c:1.198	Sun Aug  9 11:32:44 2020
+++ src/sys/arch/x86/x86/cpu.c	Fri Oct  9 17:14:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.198 2020/08/09 15:32:44 christos Exp $	*/
+/*	$NetBSD: cpu.c,v 1.199 2020/10/09 21:14:05 christos Exp $	*/
 
 /*
  * Copyright (c) 2000-2020 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.198 2020/08/09 15:32:44 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.199 2020/10/09 21:14:05 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -274,11 +274,17 @@ cpu_pcpuarea_init(struct cpu_info *ci)
 static void
 cpu_vm_init(struct cpu_info *ci)
 {
-	int ncolors = 2, i;
+	unsigned int ncolors = 2;
 
-	for (i = CAI_ICACHE; i <= CAI_L2CACHE; i++) {
+	/*
+	 * XXX: for AP's the cache info has not been initialized yet
+	 * but that does not matter because uvm only pays attention at
+	 * the maximum only. We should fix it once cpus have different
+	 * cache sizes.
+	 */
+	for (unsigned int i = CAI_ICACHE; i <= CAI_L2CACHE; i++) {
 		struct x86_cache_info *cai;
-		int tcolors;
+		unsigned int tcolors;
 
 		cai = >ci_cinfo[i];
 
@@ -293,24 +299,27 @@ cpu_vm_init(struct cpu_info *ci)
 		default:
 			tcolors /= cai->cai_associativity;
 		}
-		ncolors = uimax(ncolors, tcolors);
-		/*
-		 * If the desired number of colors is not a power of
-		 * two, it won't be good.  Find the greatest power of
-		 * two which is an even divisor of the number of colors,
-		 * to preserve even coloring of pages.
-		 */
-		if (ncolors & (ncolors - 1) ) {
-			int try, picked = 1;
-			for (try = 1; try < ncolors; try *= 2) {
-if (ncolors % try == 0) picked = try;
-			}
-			if (picked == 1) {
-panic("desired number of cache colors %d is "
-" > 1, but not even!", ncolors);
-			}
-			ncolors = picked;
+		if (tcolors <= ncolors)
+			continue;
+		ncolors = tcolors;
+	}
+
+	/*
+	 * If the desired number of colors is not a power of
+	 * two, it won't be good.  Find the greatest power of
+	 * two which is an even divisor of the number of colors,
+	 * to preserve even coloring of pages.
+	 */
+	if (ncolors & (ncolors - 1) ) {
+		unsigned int try, picked = 1;
+		for (try = 1; try < ncolors; try *= 2) {
+			if (ncolors % try == 0) picked = try;
+		}
+		if (picked == 1) {
+			panic("desired number of cache colors %u is "
+			" > 1, but not even!", ncolors);
 		}
+		ncolors = picked;
 	}
 
 	/*



CVS commit: src/lib/libc/atomic

2020-10-09 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Oct  9 19:41:03 UTC 2020

Modified Files:
src/lib/libc/atomic: membar_ops.3

Log Message:
Add italic correction to _Atomic-qualified.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/atomic/membar_ops.3

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

Modified files:

Index: src/lib/libc/atomic/membar_ops.3
diff -u src/lib/libc/atomic/membar_ops.3:1.7 src/lib/libc/atomic/membar_ops.3:1.8
--- src/lib/libc/atomic/membar_ops.3:1.7	Fri Oct  9 17:36:16 2020
+++ src/lib/libc/atomic/membar_ops.3	Fri Oct  9 19:41:02 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: membar_ops.3,v 1.7 2020/10/09 17:36:16 riastradh Exp $
+.\"	$NetBSD: membar_ops.3,v 1.8 2020/10/09 19:41:02 uwe Exp $
 .\"
 .\" Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -89,7 +89,7 @@ memory operations \(em that is, all load
 memory \(em are affected by
 .Nm ,
 not just C11 atomic operations on
-.Vt _Atomic Ns -qualified
+.Vt _Atomic\^ Ns -qualified
 objects.
 .Bl -tag -width abcd
 .It Fn membar_enter



CVS commit: src/doc

2020-10-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  9 19:05:57 UTC 2020

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
new tzcode


To generate a diff of this commit:
cvs rdiff -u -r1.1750 -r1.1751 src/doc/3RDPARTY
cvs rdiff -u -r1.2744 -r1.2745 src/doc/CHANGES

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1750 src/doc/3RDPARTY:1.1751
--- src/doc/3RDPARTY:1.1750	Thu Oct  8 00:30:04 2020
+++ src/doc/3RDPARTY	Fri Oct  9 15:05:57 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1750 2020/10/08 04:30:04 kre Exp $
+#	$NetBSD: 3RDPARTY,v 1.1751 2020/10/09 19:05:57 christos Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1409,7 +1409,7 @@ Notes:
 Added changes from a5 -> a12 manually.
 
 Package:	tz
-Version:	tzcode2020a / tzdata2020b
+Version:	tzcode2020b / tzdata2020b
 Current Vers:	tzcode2020b / tzdata2020b
 Maintainer:	Paul Eggert 
 Archive Site:	ftp://ftp.iana.org/tz/releases/

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2744 src/doc/CHANGES:1.2745
--- src/doc/CHANGES:1.2744	Thu Oct  8 00:30:04 2020
+++ src/doc/CHANGES	Fri Oct  9 15:05:57 2020
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2744 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2745 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -291,3 +291,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	vether(4): Imported from OpenBSD. [roy 20200927]
 	dhcpcd: Update to version 9.3.0 [roy 20201005]
 	tzdata updated to 2020b  [kre 20201008]
+	tzcode: Updated to 2020b. [christos 20201009]



CVS commit: src/lib/libc

2020-10-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  9 18:38:48 UTC 2020

Modified Files:
src/lib/libc: shlib_version
src/lib/libc/time: Makefile NEWS README strftime.3 strftime.c
theory.html tz-art.html tz-how-to.html tz-link.html tzselect.8
version zic.8 zic.c

Log Message:
Merge tzcode2020b (except we keep tzsetwall(3) for now for compatibility,
and we were "slim" already)

Support for zic's long-obsolete '-y YEARISTYPE' option has been
removed and, with it, so has support for the TYPE field in Rule
lines, which is now reserved for compatibility with earlier zic.
These features were previously deprecated in release 2015f.
(Thanks to Tim Parenti.)

zic now defaults to '-b slim' instead of to '-b fat'.

zic's new '-l -' and '-p -' options uninstall any existing
localtime and posixrules files, respectively.

The undocumented and ineffective tzsetwall function has been
removed.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/lib/libc/shlib_version
cvs rdiff -u -r1.45 -r1.46 src/lib/libc/time/Makefile
cvs rdiff -u -r1.30 -r1.31 src/lib/libc/time/NEWS
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/time/README
cvs rdiff -u -r1.35 -r1.36 src/lib/libc/time/strftime.3
cvs rdiff -u -r1.47 -r1.48 src/lib/libc/time/strftime.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/time/theory.html
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/time/tz-art.html
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/time/tz-how-to.html \
src/lib/libc/time/tz-link.html
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/time/tzselect.8
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/time/version
cvs rdiff -u -r1.34 -r1.35 src/lib/libc/time/zic.8
cvs rdiff -u -r1.76 -r1.77 src/lib/libc/time/zic.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/libc/shlib_version
diff -u src/lib/libc/shlib_version:1.290 src/lib/libc/shlib_version:1.291
--- src/lib/libc/shlib_version:1.290	Sat Oct  3 14:34:15 2020
+++ src/lib/libc/shlib_version	Fri Oct  9 14:38:48 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: shlib_version,v 1.290 2020/10/03 18:34:15 christos Exp $
+#	$NetBSD: shlib_version,v 1.291 2020/10/09 18:38:48 christos Exp $
 #	Remember to update distrib/sets/lists/base/shl.* when changing
 #
 # things we wish to do on next major version bump:
@@ -52,5 +52,6 @@
 # - move environ and __ps_strings from crt0.o into libc.
 # - move statfs() to libcompat since we have statvfs()
 # - the syscall stubs for the (obsolete) lfs syscalls should be removed
+# - remove tzsetwall(3), upstream has removed it
 major=12
 minor=218

Index: src/lib/libc/time/Makefile
diff -u src/lib/libc/time/Makefile:1.45 src/lib/libc/time/Makefile:1.46
--- src/lib/libc/time/Makefile:1.45	Mon May 25 10:52:48 2020
+++ src/lib/libc/time/Makefile	Fri Oct  9 14:38:48 2020
@@ -22,13 +22,13 @@ BUGEMAIL=	t...@iana.org
 #	DATAFORM=	main
 # To wait even longer for new features, use:
 #	DATAFORM=	rearguard
+# Rearguard users might also want "ZFLAGS = -b fat"; see below.
 DATAFORM=		main
 
 # Change the line below for your timezone (after finding the one you want in
 # one of the $(TDATA) source files, or adding it to a source file).
 # Alternatively, if you discover you've got the wrong timezone, you can just
-#	zic -l rightzone
-# to correct things.
+# 'zic -l -' to remove it, or 'zic -l rightzone' to change it.
 # Use the command
 #	make zonenames
 # to get a list of the values you can use for LOCALTIME.
@@ -37,33 +37,30 @@ LOCALTIME=	GMT
 
 # The POSIXRULES macro controls interpretation of nonstandard and obsolete
 # POSIX-like TZ settings like TZ='EET-2EEST' that lack DST transition rules.
-# In the reference implementation, if you want something other than Eastern
-# United States time as a template for handling these settings, you can
-# change the line below (after finding the timezone you want in the
-# one of the $(TDATA) source files, or adding it to a source file).
-# A setting like TZ='EET-2EEST' is supposed to use the rules in the
-# template file to determine "spring forward" and "fall back" days and
-# times; the environment variable itself specifies UT offsets of standard and
-# daylight saving time.
-# Alternatively, if you discover you've got the wrong timezone, you can just
-#	zic -p rightzone
-# to correct things.
-# Use the command
-#	make zonenames
-# to get a list of the values you can use for POSIXRULES.
+# Such a setting uses the rules in a template file to determine
+# "spring forward" and "fall back" days and times; the environment
+# variable itself specifies UT offsets of standard and daylight saving time.
 #
-# If POSIXRULES is empty, no template is installed; this is the intended
-# future default for POSIXRULES.
+# If POSIXRULES is '-', no template is installed; this is the default.
 #
-# Nonempty POSIXRULES is obsolete and should not be relied on, because:
+# Any other value for POSIXRULES is obsolete and should not be relied on, as:
 # * It does 

CVS commit: src/usr.sbin/sysinst

2020-10-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  9 18:33:00 UTC 2020

Modified Files:
src/usr.sbin/sysinst: bsddisklabel.c defs.h label.c part_edit.c

Log Message:
When MD code requests a reserved area (at the start of the disk)
make sure to properly account for the "lost" space during all calculations
and especially when expanding the main partition to fill the disk.

Avoid using the global "pm" or a passed device descriptons when we are
passing disk limits explicitly anyway.

Simplify/fix a few rounding calculations.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/sysinst/bsddisklabel.c
cvs rdiff -u -r1.64 -r1.65 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/sysinst/label.c
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/sysinst/part_edit.c

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

Modified files:

Index: src/usr.sbin/sysinst/bsddisklabel.c
diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.49 src/usr.sbin/sysinst/bsddisklabel.c:1.50
--- src/usr.sbin/sysinst/bsddisklabel.c:1.49	Mon Oct  5 12:28:45 2020
+++ src/usr.sbin/sysinst/bsddisklabel.c	Fri Oct  9 18:33:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bsddisklabel.c,v 1.49 2020/10/05 12:28:45 martin Exp $	*/
+/*	$NetBSD: bsddisklabel.c,v 1.50 2020/10/09 18:33:00 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -501,7 +501,7 @@ fill_ptn_menu(struct partition_usage_set
 	m++;
 
 	/* calculate free space */
-	free_space = pset->parts->free_space;
+	free_space = pset->parts->free_space - pset->reserved_space;
 	for (i = 0; i < pset->parts->num_part; i++) {
 		if (!pset->parts->pscheme->get_part_info(pset->parts, i,
 		))
@@ -936,6 +936,12 @@ fill_defaults(struct partition_usage_set
 
 	memset(wanted, 0, sizeof(*wanted));
 	wanted->parts = parts;
+	if (ptstart > parts->disk_start)
+		wanted->reserved_space = ptstart - parts->disk_start;
+	if ((ptstart + ptsize) < (parts->disk_start+parts->disk_size))
+		wanted->reserved_space +=
+		(parts->disk_start+parts->disk_size) -
+		(ptstart + ptsize);
 	wanted->num = __arraycount(default_parts_init);
 	wanted->infos = calloc(wanted->num, sizeof(*wanted->infos));
 	if (wanted->infos == NULL) {
@@ -1110,7 +1116,7 @@ fill_defaults(struct partition_usage_set
 	 * adjustments, so we don't present the user inherently
 	 * impossible defaults.
 	 */
-	free_space = parts->free_space;
+	free_space = parts->free_space - wanted->reserved_space;
 	required = 0;
 	if (root < wanted->num)
 		required += wanted->infos[root].size;
@@ -1200,7 +1206,7 @@ sort_and_sync_parts(struct partition_usa
 	size_t i, j, no;
 	part_id pno;
 
-	pset->cur_free_space = pset->parts->free_space;
+	pset->cur_free_space = pset->parts->free_space - pset->reserved_space;
 
 	/* count non-empty entries that are not in pset->parts */
 	no = pset->parts->num_part;
@@ -1336,8 +1342,8 @@ normalize_clones(struct part_usage_info 
 #endif
 
 static void
-apply_settings_to_partitions(struct pm_devs *p, struct disk_partitions *parts,
-struct partition_usage_set *wanted, daddr_t start, daddr_t size)
+apply_settings_to_partitions(struct disk_partitions *parts,
+struct partition_usage_set *wanted, daddr_t start, daddr_t xsize)
 {
 	size_t i, exp_ndx = ~0U;
 	daddr_t planned_space = 0, nsp, from, align;
@@ -1361,7 +1367,6 @@ apply_settings_to_partitions(struct pm_d
 	}
 
 	align = wanted->parts->pscheme->get_part_alignment(wanted->parts);
-
 	/*
 	 * Pass one: calculate space available for expanding
 	 * the marked partition.
@@ -1391,15 +1396,21 @@ apply_settings_to_partitions(struct pm_d
 	 * but check size limits.
 	 */
 	if (exp_ndx < wanted->num) {
+		daddr_t free_space =
+		parts->free_space - roundup(wanted->reserved_space, align);
+		free_space -= planned_space;
+		daddr_t new_size = wanted->infos[exp_ndx].size;
+		if (free_space > 0)
+			new_size += free_space;
+
 		if (wanted->infos[exp_ndx].limit > 0 &&
-		(wanted->infos[exp_ndx].size + parts->free_space
-		- planned_space) > wanted->infos[exp_ndx].limit) {
+		(new_size + wanted->infos[exp_ndx].cur_start)
+		 > wanted->infos[exp_ndx].limit) {
 			wanted->infos[exp_ndx].size =
 			wanted->infos[exp_ndx].limit
 			- wanted->infos[exp_ndx].cur_start;
 		} else {
-			wanted->infos[exp_ndx].size +=
-			parts->free_space - planned_space;
+			wanted->infos[exp_ndx].size = new_size;
 		}
 	}
 
@@ -1433,7 +1444,7 @@ apply_settings_to_partitions(struct pm_d
 		}
 	}
 
-	from = p->ptstart > 0 ? pm->ptstart : -1;
+	from = start > 0 ? start : -1;
 	/*
 	 * First add all outer partitions - we need to align those exactly
 	 * with the inner counterpart later.
@@ -1477,16 +1488,20 @@ apply_settings_to_partitions(struct pm_d
 			want->cur_part_id = new_part_id;
 
 			want->flags |= PUIFLG_ADD_INNER|PUIFLG_IS_OUTER;
-			from = rounddown(infos[i].start + 
-			infos[i].size+outer_align, outer_align);
+			from = 

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

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

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

Log Message:
Add tests for x87 FPU registers

Reviewed by kamil


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

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

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.26 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.27
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.26	Fri Oct  9 17:43:07 2020
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Fri Oct  9 17:43:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.26 2020/10/09 17:43:07 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.27 2020/10/09 17:43:30 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -2186,6 +2186,21 @@ union x86_test_register {
 	uint32_t u32;
 };
 
+struct x86_test_fpu_registers {
+	struct {
+		uint64_t mantissa;
+		uint16_t sign_exp;
+	} __aligned(16) st[8];
+
+	uint16_t cw;
+	uint16_t sw;
+	uint16_t tw;
+	uint8_t tw_abridged;
+	uint16_t opcode;
+	union fp_addr ip;
+	union fp_addr dp;
+};
+
 enum x86_test_regset {
 	TEST_GPREGS,
 	TEST_FPREGS,
@@ -2201,6 +2216,7 @@ enum x86_test_registers {
 	GPREGS_64,
 	GPREGS_64_R8,
 	/* TEST_FPREGS/TEST_XMMREGS */
+	FPREGS_FPU,
 	FPREGS_MM,
 	FPREGS_XMM,
 	/* TEST_XSTATE */
@@ -2419,6 +2435,79 @@ static __inline void set_gp64_r8_regs(co
 #endif
 }
 
+static __inline void get_fpu_regs(struct x86_test_fpu_registers *out)
+{
+	struct save87 fsave;
+	struct fxsave fxsave;
+
+	__CTASSERT(sizeof(out->st[0]) == 16);
+
+	__asm__ __volatile__(
+		"finit\n\t"
+		"int3\n\t"
+#if defined(__x86_64__)
+		"fxsave64 %2\n\t"
+#else
+		"fxsave %2\n\t"
+#endif
+		"fnstenv %1\n\t"
+		"fnclex\n\t"
+		"fstpt 0x00(%0)\n\t"
+		"fstpt 0x10(%0)\n\t"
+		"fstpt 0x20(%0)\n\t"
+		"fstpt 0x30(%0)\n\t"
+		"fstpt 0x40(%0)\n\t"
+		"fstpt 0x50(%0)\n\t"
+		"fstpt 0x60(%0)\n\t"
+		"fstpt 0x70(%0)\n\t"
+		:
+		: "a"(out->st), "m"(fsave), "m"(fxsave)
+		: "st", "memory"
+	);
+
+	FORKEE_ASSERT(fsave.s87_cw == fxsave.fx_cw);
+	FORKEE_ASSERT(fsave.s87_sw == fxsave.fx_sw);
+
+	/* fsave contains full tw */
+	out->cw = fsave.s87_cw;
+	out->sw = fsave.s87_sw;
+	out->tw = fsave.s87_tw;
+	out->tw_abridged = fxsave.fx_tw;
+	out->opcode = fxsave.fx_opcode;
+	out->ip = fxsave.fx_ip;
+	out->dp = fxsave.fx_dp;
+}
+
+/* used as single-precision float */
+uint32_t x86_test_zero = 0;
+
+static __inline void set_fpu_regs(const struct x86_test_fpu_registers *data)
+{
+	__CTASSERT(sizeof(data->st[0]) == 16);
+
+	__asm__ __volatile__(
+		"finit\n\t"
+		"fldcw %1\n\t"
+		/* load on stack in reverse order to make it easier to read */
+		"fldt 0x70(%0)\n\t"
+		"fldt 0x60(%0)\n\t"
+		"fldt 0x50(%0)\n\t"
+		"fldt 0x40(%0)\n\t"
+		"fldt 0x30(%0)\n\t"
+		"fldt 0x20(%0)\n\t"
+		"fldt 0x10(%0)\n\t"
+		"fldt 0x00(%0)\n\t"
+		/* free st7 */
+		"ffree %%st(7)\n\t"
+		/* this should trigger a divide-by-zero */
+		"fdivs (%2)\n\t"
+		"int3\n\t"
+		:
+		: "a"(>st), "m"(data->cw), "b"(_test_zero)
+		: "st"
+	);
+}
+
 __attribute__((target("mmx")))
 static __inline void get_mm_regs(union x86_test_register out[])
 {
@@ -2712,6 +2801,54 @@ x86_register_test(enum x86_test_regset r
 		   0x262524232221201F, 0x2E2D2C2B2A292827, }},
 	};
 
+	const struct x86_test_fpu_registers expected_fpu = {
+		.st = {
+			{0x8000, 0x4000}, /* +2.0 */
+			{0x3f00, 0x}, /* 1.654785e-4932 */
+			{0x, 0x}, /* +0 */
+			{0x, 0x8000}, /* -0 */
+			{0x8000, 0x7fff}, /* +inf */
+			{0x8000, 0x}, /* -inf */
+			{0xc000, 0x}, /* nan */
+			/* st(7) will be freed to test tag word better */
+			{0x, 0x}, /* +0 */
+		},
+		/*  0011 0111 1011
+		 * PU OZDI -- unmask divide-by-zero exc.
+		 *   RR - reserved
+		 *PC  64-bit precision
+		 *  RC -- round to nearest
+		 *I - allow interrupts (unused)
+		 */
+		.cw = 0x037b,
+		/* 1000  1000 0100
+		 *SPU OZDI -- divide-by-zero exception
+		 *   I -- interrupt (exception handling)
+		 *  CCCC  condition codes
+		 *   TO P --- top register is 0
+		 * B  FPU is busy
+		 */
+		.sw = 0x8084,
+		/* 1110 1010 0101 1000
+		 * R7R6 R5R4 R3R2 R1R0
+		 *  nz -- non-zero (+2.0)
+		 *sp  special (denormal)
+		 *   zrzr --- zeroes
+		 *   sp spsp  specials (NaN + infinities)
+		 * em --- empty register
+		 */
+		.tw = 0xea58,
+		/* 0111  -- registers 0 to 6 are used */
+		.tw_abridged = 0x7f,
+		/* FDIV */
+		.opcode = 0x0033,
+		/* random bits for IP/DP write 

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

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

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

Log Message:
Rename MM_REG macro to ST_MAN, and cover fpr/xstate with it

Rename the MM_REG macro to ST_MAN, to make it clearer that it gets
mantissa of ST registers which overlaps with MM registers but can be
also used to read ST registers (to be used in the next commit).  Extend
it to cover the difference between GETFPREGS and GETXSTATE,
and therefore avoid additional condition on i386.

Reviewed by kamil.


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

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

Modified files:

Index: src/tests/lib/libc/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.25 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.26
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.25	Fri Apr 24 03:25:20 2020
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Fri Oct  9 17:43:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.25 2020/04/24 03:25:20 thorpej Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.26 2020/10/09 17:43:07 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -3089,9 +3089,13 @@ x86_register_test(enum x86_test_regset r
 	}
 
 #if defined(__x86_64__)
-#define MM_REG(n) fpr.fxstate.fx_87_ac[n].r.f87_mantissa
+#define ST_MAN(n) fxs->fx_87_ac[n].r.f87_mantissa
 #else
-#define MM_REG(n) fpr.fstate.s87_ac[n].f87_mantissa
+#define ST_MAN(n) *(			\
+regset == TEST_FPREGS		\
+? _ac[n].f87_mantissa\
+: >fx_87_ac[n].r.f87_mantissa	\
+)
 #endif
 
 	switch (regmode) {
@@ -3155,33 +3159,14 @@ x86_register_test(enum x86_test_regset r
 #endif
 			break;
 		case FPREGS_MM:
-			if (regset == TEST_FPREGS) {
-ATF_CHECK_EQ(MM_REG(0), expected[0].u64);
-ATF_CHECK_EQ(MM_REG(1), expected[1].u64);
-ATF_CHECK_EQ(MM_REG(2), expected[2].u64);
-ATF_CHECK_EQ(MM_REG(3), expected[3].u64);
-ATF_CHECK_EQ(MM_REG(4), expected[4].u64);
-ATF_CHECK_EQ(MM_REG(5), expected[5].u64);
-ATF_CHECK_EQ(MM_REG(6), expected[6].u64);
-ATF_CHECK_EQ(MM_REG(7), expected[7].u64);
-			} else {
-ATF_CHECK_EQ(fxs->fx_87_ac[0].r.f87_mantissa,
-			expected[0].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[1].r.f87_mantissa,
-			expected[1].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[2].r.f87_mantissa,
-			expected[2].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[3].r.f87_mantissa,
-			expected[3].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[4].r.f87_mantissa,
-			expected[4].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[5].r.f87_mantissa,
-			expected[5].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[6].r.f87_mantissa,
-			expected[6].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[7].r.f87_mantissa,
-			expected[7].u64);
-			}
+			ATF_CHECK_EQ(ST_MAN(0), expected[0].u64);
+			ATF_CHECK_EQ(ST_MAN(1), expected[1].u64);
+			ATF_CHECK_EQ(ST_MAN(2), expected[2].u64);
+			ATF_CHECK_EQ(ST_MAN(3), expected[3].u64);
+			ATF_CHECK_EQ(ST_MAN(4), expected[4].u64);
+			ATF_CHECK_EQ(ST_MAN(5), expected[5].u64);
+			ATF_CHECK_EQ(ST_MAN(6), expected[6].u64);
+			ATF_CHECK_EQ(ST_MAN(7), expected[7].u64);
 			break;
 		case FPREGS_YMM:
 			ATF_CHECK(!memcmp(_ymm_hi128.xs_ymm[0],
@@ -3300,33 +3285,14 @@ x86_register_test(enum x86_test_regset r
 #endif
 			break;
 		case FPREGS_MM:
-			if (regset == TEST_FPREGS) {
-MM_REG(0) = expected[0].u64;
-MM_REG(1) = expected[1].u64;
-MM_REG(2) = expected[2].u64;
-MM_REG(3) = expected[3].u64;
-MM_REG(4) = expected[4].u64;
-MM_REG(5) = expected[5].u64;
-MM_REG(6) = expected[6].u64;
-MM_REG(7) = expected[7].u64;
-			} else {
-fxs->fx_87_ac[0].r.f87_mantissa =
-expected[0].u64;
-fxs->fx_87_ac[1].r.f87_mantissa =
-expected[1].u64;
-fxs->fx_87_ac[2].r.f87_mantissa =
-expected[2].u64;
-fxs->fx_87_ac[3].r.f87_mantissa =
-expected[3].u64;
-fxs->fx_87_ac[4].r.f87_mantissa =
-expected[4].u64;
-fxs->fx_87_ac[5].r.f87_mantissa =
-expected[5].u64;
-fxs->fx_87_ac[6].r.f87_mantissa =
-expected[6].u64;
-fxs->fx_87_ac[7].r.f87_mantissa =
-expected[7].u64;
-			}
+			ST_MAN(0) = expected[0].u64;
+			ST_MAN(1) = expected[1].u64;
+			ST_MAN(2) = expected[2].u64;
+			ST_MAN(3) = expected[3].u64;
+			ST_MAN(4) = expected[4].u64;
+			ST_MAN(5) = expected[5].u64;
+			ST_MAN(6) = expected[6].u64;
+			ST_MAN(7) = expected[7].u64;
 			break;
 		case FPREGS_YMM:
 			memcpy(_ymm_hi128.xs_ymm[0],
@@ -3431,7 +3397,7 @@ x86_register_test(enum x86_test_regset r
 		break;
 	}
 
-#undef MM_REG
+#undef ST_MAN
 
 	DPRINTF("Before resuming the child process where it left off and "
 	"without signal to be sent\n");



CVS commit: src/lib/libc/atomic

2020-10-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Oct  9 17:36:16 UTC 2020

Modified Files:
src/lib/libc/atomic: membar_ops.3

Log Message:
Reword advice about when not to use membar_exit.

With help from skrll and pgoyette.

While here, change the example so it doesn't violate the advice just
given.  Still not a great example -- abusing UINT_MAX for a reference
count is kinda sketchy, but it'll serve for now.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/atomic/membar_ops.3

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

Modified files:

Index: src/lib/libc/atomic/membar_ops.3
diff -u src/lib/libc/atomic/membar_ops.3:1.6 src/lib/libc/atomic/membar_ops.3:1.7
--- src/lib/libc/atomic/membar_ops.3:1.6	Thu Sep  3 00:00:06 2020
+++ src/lib/libc/atomic/membar_ops.3	Fri Oct  9 17:36:16 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: membar_ops.3,v 1.6 2020/09/03 00:00:06 riastradh Exp $
+.\"	$NetBSD: membar_ops.3,v 1.7 2020/10/09 17:36:16 riastradh Exp $
 .\"
 .\" Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -140,28 +140,40 @@ A
 followed by a store implies a
 .Em store-release
 operation in the language of C11.
-For a regular store, rather than an atomic read/modify/write store, you
-should use
-.Xr atomic_store_release 9
-instead of
 .Fn membar_exit
-followed by the store.
+should only be used before atomic read/modify/write, such as
+.Xr atomic_inc_uint 3 .
+For regular stores, instead of
+.Li "membar_exit(); *p = x" ,
+you should use
+.Li "atomic_store_release(p, x)" .
 .Pp
 .Fn membar_exit
-is typically used in code that implements locking primitives to ensure
-that a lock protects its data, and is typically paired with
-.Fn membar_enter .
+is typically paired with
+.Fn membar_enter ,
+and is typically used in code that implements locking or reference
+counting primitives.
+Releasing a lock or reference count should use
+.Fn membar_exit ,
+and acquiring a lock or handling an object after draining references
+should use
+.Fn membar_enter ,
+so that whatever happened before releasing will also have happened
+before acquiring.
 For example:
 .Bd -literal -offset abcdefgh
-/* thread A */
+/* thread A -- release a reference */
 obj->state.mumblefrotz = 42;
 KASSERT(valid(>state));
 membar_exit();
-obj->lock = 0;
+atomic_dec_uint(>refcnt);
 
-/* thread B */
-if (atomic_cas_uint(>lock, 0, 1) != 0)
-	return;
+/*
+ * thread B -- busy-wait until last reference is released,
+ * then lock it by setting refcnt to UINT_MAX
+ */
+while (atomic_cas_uint(>refcnt, 0, -1) != 0)
+	continue;
 membar_enter();
 KASSERT(valid(>state));
 obj->state.mumblefrotz--;
@@ -169,11 +181,11 @@ obj->state.mumblefrotz--;
 .Pp
 In this example,
 .Em if
-the
+the load in
 .Fn atomic_cas_uint
-operation in thread B witnesses the store
-.Li "obj->lock = 0"
-from thread A,
+in thread B witnesses the store in
+.Fn atomic_dec_uint
+in thread A setting the reference count to zero,
 .Em then
 everything in thread A before the
 .Fn membar_exit



CVS commit: src/external/mit/xorg/server/xorg-server/hw/xfree86/xorgos

2020-10-09 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Oct  9 17:01:29 UTC 2020

Modified Files:
src/external/mit/xorg/server/xorg-server/hw/xfree86/xorgos: Makefile

Log Message:
build ppc_video.c etc. on hppa


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 \
src/external/mit/xorg/server/xorg-server/hw/xfree86/xorgos/Makefile

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

Modified files:

Index: src/external/mit/xorg/server/xorg-server/hw/xfree86/xorgos/Makefile
diff -u src/external/mit/xorg/server/xorg-server/hw/xfree86/xorgos/Makefile:1.47 src/external/mit/xorg/server/xorg-server/hw/xfree86/xorgos/Makefile:1.48
--- src/external/mit/xorg/server/xorg-server/hw/xfree86/xorgos/Makefile:1.47	Mon Dec 31 11:14:05 2018
+++ src/external/mit/xorg/server/xorg-server/hw/xfree86/xorgos/Makefile	Fri Oct  9 17:01:29 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.47 2018/12/31 11:14:05 mrg Exp $
+#	$NetBSD: Makefile,v 1.48 2020/10/09 17:01:29 macallan Exp $
 
 .include "../../../Makefile.serverlib"
 .include "../../../Makefile.servermod"
@@ -35,7 +35,8 @@ CPPFLAGS.${_FN}+=	-DPCVT_SUPPORT -DWSCON
 .endfor
 .endif
 
-.if ${MACHINE} == "macppc" || ${MACHINE} == "prep" || ${MACHINE} == "bebox" || ${MACHINE} == "ofppc" || ${MACHINE} == "ibmnws"
+.if ${MACHINE} == "macppc" || ${MACHINE} == "prep" || ${MACHINE} == "bebox" || ${MACHINE} == "ofppc" || \
+	${MACHINE} == "ibmnws" || ${MACHINE} == "hppa"
 SRCS.bsd+=	ppc_video.c pm_noop.c lnx_agp.c
 .for _FN in ${SRCS.bsd}
 CPPFLAGS.${_FN}=	-DWSCONS_SUPPORT -DPCVT_SUPPORT -DUSESTDRES -DHAVE_SYSV_IPC



CVS commit: xsrc/external/mit/libpciaccess/dist/src

2020-10-09 Thread Jared D. McNeill
Module Name:xsrc
Committed By:   jmcneill
Date:   Fri Oct  9 10:48:18 UTC 2020

Modified Files:
xsrc/external/mit/libpciaccess/dist/src: netbsd_pci.c

Log Message:
Oops, avoid shadow declaration (fixes pci_system_netbsd_count_buses)


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 \
xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c

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/libpciaccess/dist/src/netbsd_pci.c
diff -u xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.19 xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.20
--- xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.19	Thu Oct  8 23:04:34 2020
+++ xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c	Fri Oct  9 10:48:18 2020
@@ -924,7 +924,7 @@ pci_system_netbsd_open_device(int unit)
 static int
 pci_system_netbsd_count_buses(void)
 {
-	int pcifd, nbuses;
+	int pcifd;
 
 	do {
 		pcifd = pci_system_netbsd_open_device(nbuses);



CVS commit: src/sys/compat/common

2020-10-09 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct  9 10:41:53 UTC 2020

Modified Files:
src/sys/compat/common: tty_43.c

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

Passing a negative value to these legacy compat ioctls results in
left shift on a negative value which is undefined behaviour and results
in the tty (at least, possibly other things) locking up.

The argument to the ioctl should always be > 0. Return EINVAL otherwise.

While here, adjustments to code style to match current guidelines.

Found by UBSan.

Reported-by: syzbot+39cd551a05298b222...@syzkaller.appspotmail.com


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

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

Modified files:

Index: src/sys/compat/common/tty_43.c
diff -u src/sys/compat/common/tty_43.c:1.37 src/sys/compat/common/tty_43.c:1.38
--- src/sys/compat/common/tty_43.c:1.37	Sat Aug  8 19:04:58 2020
+++ src/sys/compat/common/tty_43.c	Fri Oct  9 10:41:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty_43.c,v 1.37 2020/08/08 19:04:58 christos Exp $	*/
+/*	$NetBSD: tty_43.c,v 1.38 2020/10/09 10:41:53 nia Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tty_43.c,v 1.37 2020/08/08 19:04:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_43.c,v 1.38 2020/10/09 10:41:53 nia Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -220,20 +220,24 @@ compat_43_ttioctl(struct tty *tp, u_long
 	case TIOCLBIC:
 	case TIOCLSET: {
 		struct termios term;
-		int flags;
+		int argbits, flags;
+
+		argbits = *(int *)data;
+		if (argbits < 0)
+			return EINVAL;
 
 		mutex_spin_enter(_lock);
 		term = tp->t_termios;
 		flags = ttcompatgetflags(tp);
 		switch (com) {
 		case TIOCLSET:
-			tp->t_flags = (flags&0x) | (*(int *)data<<16);
+			tp->t_flags = (flags & 0x) | (argbits << 16);
 			break;
 		case TIOCLBIS:
-			tp->t_flags = flags | (*(int *)data<<16);
+			tp->t_flags = flags | (argbits << 16);
 			break;
 		case TIOCLBIC:
-			tp->t_flags = flags & ~(*(int *)data<<16);
+			tp->t_flags = flags & ~(argbits << 16);
 			break;
 		}
 		ttcompatsetlflags(tp, );



CVS commit: xsrc/external/bsd/font-spleen-misc

2020-10-09 Thread Frederic Cambus
Module Name:xsrc
Committed By:   fcambus
Date:   Fri Oct  9 09:29:23 UTC 2020

Added Files:
xsrc/external/bsd/font-spleen-misc: LICENSE spleen-12x24.bdf
spleen-16x32.bdf spleen-32x64.bdf spleen-5x8.bdf spleen-6x12.bdf
spleen-8x16.bdf

Log Message:
Initial import of font-spleen-misc-1.8.2.

Discussed with nia@.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 xsrc/external/bsd/font-spleen-misc/LICENSE \
xsrc/external/bsd/font-spleen-misc/spleen-12x24.bdf \
xsrc/external/bsd/font-spleen-misc/spleen-16x32.bdf \
xsrc/external/bsd/font-spleen-misc/spleen-32x64.bdf \
xsrc/external/bsd/font-spleen-misc/spleen-5x8.bdf \
xsrc/external/bsd/font-spleen-misc/spleen-6x12.bdf \
xsrc/external/bsd/font-spleen-misc/spleen-8x16.bdf

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

diffs are larger than 1MB and have been omitted


CVS commit: src/sys/kern

2020-10-09 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct  9 09:03:55 UTC 2020

Modified Files:
src/sys/kern: tty.c

Log Message:
tty: Avoid undefined behaviour (left shift of 1 by 31 places overflows int)

The valid sizes of the tty input and output queues (according to the man page)
are between 1024 and 65536 and input values are converted to a power of two.

The check on the validity of the range is done after the input values are
converted, however, which means that a hostile program can attempt to set
the queue size to a negative value, and cause integer overflow before
the range is validated.

Detected by UBSan

Reported-by: syzbot+521b73969fd233c49...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.289 -r1.290 src/sys/kern/tty.c

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

Modified files:

Index: src/sys/kern/tty.c
diff -u src/sys/kern/tty.c:1.289 src/sys/kern/tty.c:1.290
--- src/sys/kern/tty.c:1.289	Wed Aug 26 16:36:32 2020
+++ src/sys/kern/tty.c	Fri Oct  9 09:03:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.c,v 1.289 2020/08/26 16:36:32 maxv Exp $	*/
+/*	$NetBSD: tty.c,v 1.290 2020/10/09 09:03:55 nia Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.289 2020/08/26 16:36:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.290 2020/10/09 09:03:55 nia Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -226,7 +226,7 @@ int tty_qsize = TTY_MINQSIZE;
 static int
 tty_get_qsize(int *qsize, int newsize)
 {
-	if (newsize == 0)
+	if (newsize <= 0)
 		return EINVAL;
 
 	newsize = 1 << ilog2(newsize);	/* Make it a power of two */



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2020-10-09 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Fri Oct  9 08:18:01 UTC 2020

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: dmu_tx.c

Log Message:
PR kern/55705:
don't attempt to sleep for negative time, we are late anyway - avoids 
DIAGNOSTIC panic


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.5 src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.6
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c:1.5	Mon Mar  9 15:37:46 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/dmu_tx.c	Fri Oct  9 08:18:01 2020
@@ -1153,6 +1153,9 @@ dmu_tx_delay(dmu_tx_t *tx, uint64_t dirt
 #ifdef __NetBSD__
 	int timo = (wakeup - now) * hz / 10;
 
+	if (timo < 0)
+		return;
+
 	if (timo == 0)
 		timo = 1;
 	kpause("dmu_tx_delay", false, timo, NULL);



CVS commit: src/sys/netinet

2020-10-09 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Oct  9 08:10:41 UTC 2020

Modified Files:
src/sys/netinet: ip_carp.c

Log Message:
carp: Remove media, software should use link status.

carp literally has no media just like ppp, vlan, etc.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/netinet/ip_carp.c

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

Modified files:

Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.110 src/sys/netinet/ip_carp.c:1.111
--- src/sys/netinet/ip_carp.c:1.110	Thu Feb  6 23:30:20 2020
+++ src/sys/netinet/ip_carp.c	Fri Oct  9 08:10:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_carp.c,v 1.110 2020/02/06 23:30:20 thorpej Exp $	*/
+/*	$NetBSD: ip_carp.c,v 1.111 2020/10/09 08:10:41 roy Exp $	*/
 /*	$OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.110 2020/02/06 23:30:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.111 2020/10/09 08:10:41 roy Exp $");
 
 /*
  * TODO:
@@ -67,7 +67,6 @@ __KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -116,7 +115,6 @@ struct carp_softc {
 #define	sc_carpdev	sc_ac.ec_if.if_carpdev
 	int ah_cookie;
 	int lh_cookie;
-	struct ifmedia  sc_im;	/* ifmedia for link status */
 	struct ip_moptions sc_imo;
 #ifdef INET6
 	struct ip6_moptions sc_im6o;
@@ -228,8 +226,6 @@ static int	carp_clone_destroy(struct ifn
 static int	carp_ether_addmulti(struct carp_softc *, struct ifreq *);
 static int	carp_ether_delmulti(struct carp_softc *, struct ifreq *);
 static void	carp_ether_purgemulti(struct carp_softc *);
-static int  carp_mediachange(struct ifnet *ifp);
-static void	carp_mediastatus(struct ifnet *ifp, struct ifmediareq *imr);
 static void	carp_update_link_state(struct carp_softc *sc);
 
 static void	sysctl_net_inet_carp_setup(struct sysctllog **);
@@ -890,8 +886,6 @@ carp_clone_create(struct if_clone *ifc, 
 
 		return rv;
 	}
-	ifmedia_init(>sc_im, 0, carp_mediachange, carp_mediastatus);
-	sc->sc_im.ifm_media = IFM_CARP;
 	ether_ifattach(ifp, NULL);
 	carp_set_enaddr(sc);
 	/* Overwrite ethernet defaults */
@@ -910,7 +904,6 @@ carp_clone_destroy(struct ifnet *ifp)
 	carpdetach(ifp->if_softc);
 	ether_ifdetach(ifp);
 	if_detach(ifp);
-	ifmedia_fini(>sc_im);
 	callout_destroy(>sc_ad_tmo);
 	callout_destroy(>sc_md_tmo);
 	callout_destroy(>sc_md6_tmo);
@@ -2173,10 +2166,6 @@ carp_ioctl(struct ifnet *ifp, u_long cmd
 			error = 0;
 		break;
 
-case SIOCGIFMEDIA:
-		error = ifmedia_ioctl(ifp, ifr, >sc_im, cmd);
-		break;
-
 	default:
 		error = ether_ioctl(ifp, cmd, data);
 	}
@@ -2212,28 +2201,6 @@ carp_output(struct ifnet *ifp, struct mb
 	}
 }
 
-static int
-carp_mediachange(struct ifnet *ifp)
-{
-return (0);
-}
-
-static void
-carp_mediastatus(struct ifnet *ifp, struct ifmediareq *imr)
-{
-switch (ifp->if_link_state) {
-case LINK_STATE_UP:
-imr->ifm_status = IFM_AVALID | IFM_ACTIVE;
-break;
-case LINK_STATE_DOWN:
-imr->ifm_status = IFM_AVALID;
-break;
-default:
-imr->ifm_status = 0;
-break;
-}
-}
-
 static void
 carp_set_state(struct carp_softc *sc, int state)
 {



CVS commit: src/usr.bin/make/unit-tests

2020-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  9 07:03:20 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varmod-ifelse.mk

Log Message:
make(1): add test for parsing the :? variable modifier


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-ifelse.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-ifelse.mk
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.3 src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.3	Fri Oct  2 20:34:59 2020
+++ src/usr.bin/make/unit-tests/varmod-ifelse.mk	Fri Oct  9 07:03:20 2020
@@ -1,12 +1,19 @@
-# $NetBSD: varmod-ifelse.mk,v 1.3 2020/10/02 20:34:59 rillig Exp $
+# $NetBSD: varmod-ifelse.mk,v 1.4 2020/10/09 07:03:20 rillig Exp $
 #
 # Tests for the ${cond:?then:else} variable modifier, which evaluates either
 # the then-expression or the else-expression, depending on the condition.
 
 # TODO: Implementation
 
-# TODO: Test another modifier after ifelse; does not work, it becomes part
-# of the else branch.
+# When the :? is parsed, it is greedy.  The else branch spans all the
+# text, up until the closing character '}', even if the text looks like
+# another modifier.
+.if ${1:?then:else:Q} != "then"
+.  error
+.endif
+.if ${0:?then:else:Q} != "else:Q"
+.  error
+.endif
 
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-10-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  9 06:44:42 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: archive.exp archive.mk

Log Message:
make(1): use consistent order in .OODATE in test archive.mk


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/archive.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/archive.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/archive.exp
diff -u src/usr.bin/make/unit-tests/archive.exp:1.6 src/usr.bin/make/unit-tests/archive.exp:1.7
--- src/usr.bin/make/unit-tests/archive.exp:1.6	Thu Oct  8 18:37:26 2020
+++ src/usr.bin/make/unit-tests/archive.exp	Fri Oct  9 06:44:42 2020
@@ -13,7 +13,7 @@ archive.mk
 modmisc.mk
 varmisc.mk
 
-Making list-archive-wildcard out-of-date ternary.mk archive-suffix.mk archive.mk
+Making list-archive-wildcard out-of-date archive-suffix.mk archive.mk ternary.mk
 list-archive-wildcard: archive-suffix.mk
 list-archive-wildcard: archive.mk
 list-archive-wildcard: ternary.mk

Index: src/usr.bin/make/unit-tests/archive.mk
diff -u src/usr.bin/make/unit-tests/archive.mk:1.9 src/usr.bin/make/unit-tests/archive.mk:1.10
--- src/usr.bin/make/unit-tests/archive.mk:1.9	Thu Oct  8 18:37:26 2020
+++ src/usr.bin/make/unit-tests/archive.mk	Fri Oct  9 06:44:42 2020
@@ -1,4 +1,4 @@
-# $NetBSD: archive.mk,v 1.9 2020/10/08 18:37:26 rillig Exp $
+# $NetBSD: archive.mk,v 1.10 2020/10/09 06:44:42 rillig Exp $
 #
 # Very basic demonstration of handling archives, based on the description
 # in PSD.doc/tutorial.ms.
@@ -35,7 +35,7 @@ create-archive: ${ARCHIVE} pre post
 # Arch_ParseArchive is called, the dependency line is already fully expanded.
 #
 ${ARCHIVE}: $${:Ulibprog.a}(archive.mk modmisc.mk $${:Uvarmisc.mk}) pre post
-	ar cru ${.TARGET} ${.OODATE}
+	ar cru ${.TARGET} ${.OODATE:O}
 	ranlib ${.TARGET}
 
 list-archive: ${ARCHIVE} pre post
@@ -57,6 +57,6 @@ remove-archive: pre post
 	rm -f ${ARCHIVE}
 
 pre: .USEBEFORE
-	@echo Making ${.TARGET} ${.OODATE:C,.+,out-of-date,W} ${.OODATE}
+	@echo Making ${.TARGET} ${.OODATE:C,.+,out-of-date,W} ${.OODATE:O}
 post: .USE
 	@echo