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

2020-07-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jul 20 05:50:56 UTC 2020

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

Log Message:
Revert previous, to unbreak the build (NVMM declares the macro too).

There are hundreds of MSRs, we're not going to list them all, especially
when the majority are unused.


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/arch/x86/include/specialreg.h

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

Modified files:

Index: src/sys/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.169 src/sys/arch/x86/include/specialreg.h:1.170
--- src/sys/arch/x86/include/specialreg.h:1.169	Sun Jul 19 16:17:00 2020
+++ src/sys/arch/x86/include/specialreg.h	Mon Jul 20 05:50:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.169 2020/07/19 16:17:00 jdolecek Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.170 2020/07/20 05:50:55 maxv Exp $	*/
 
 /*
  * Copyright (c) 2014-2020 The NetBSD Foundation, Inc.
@@ -865,9 +865,6 @@
 #define 	APICBASE_PHYSADDR	0xf000	/* physical address */
 #define MSR_EBL_CR_POWERON	0x02a
 #define MSR_EBC_FREQUENCY_ID	0x02c	/* PIV only */
-#define MSR_IA32_FEATURE_CONTROL	0x03a
-#define 	IA32_FEATURE_CONTROL_ENABLE_VMXON_INSIDE_SMX	0x0002
-#define 	IA32_FEATURE_CONTROL_ENABLE_VMXON_OUTSIDE_SMX	0x0004
 #define MSR_IA32_SPEC_CTRL	0x048
 #define 	IA32_SPEC_CTRL_IBRS	0x01
 #define 	IA32_SPEC_CTRL_STIBP	0x02



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

2020-07-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Jul 20 03:26:07 UTC 2020

Modified Files:
src/sys/arch/mips/mips: cpu_subr.c

Log Message:
Less magic numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/mips/mips/cpu_subr.c

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

Modified files:

Index: src/sys/arch/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.50 src/sys/arch/mips/mips/cpu_subr.c:1.51
--- src/sys/arch/mips/mips/cpu_subr.c:1.50	Sun Jul 19 09:30:08 2020
+++ src/sys/arch/mips/mips/cpu_subr.c	Mon Jul 20 03:26:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_subr.c,v 1.50 2020/07/19 09:30:08 simonb Exp $	*/
+/*	$NetBSD: cpu_subr.c,v 1.51 2020/07/20 03:26:07 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.50 2020/07/19 09:30:08 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.51 2020/07/20 03:26:07 simonb Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -122,14 +122,16 @@ struct cpu_info *
 cpu_info_alloc(struct pmap_tlb_info *ti, cpuid_t cpu_id, cpuid_t cpu_package_id,
 	cpuid_t cpu_core_id, cpuid_t cpu_smt_id)
 {
+	const int exc_step = 1 << MIPS_EBASE_EXC_BASE_SHIFT;
 
 	KASSERT(cpu_id < MAXCPUS);
 
 #ifdef MIPS64_OCTEON
-	vaddr_t exc_page = MIPS_UTLB_MISS_EXC_VEC + 0x1000*cpu_id;
-	__CTASSERT(sizeof(struct cpu_info) + sizeof(struct pmap_tlb_info) <= 0x1000 - 0x280);
+	vaddr_t exc_page = MIPS_UTLB_MISS_EXC_VEC + exc_step * cpu_id;
+	__CTASSERT(sizeof(struct cpu_info) + sizeof(struct pmap_tlb_info)
+	<= exc_step - 0x280);
 
-	struct cpu_info * const ci = ((struct cpu_info *)(exc_page + 0x1000)) - 1;
+	struct cpu_info * const ci = ((struct cpu_info *)(exc_page + exc_step)) - 1;
 	memset((void *)exc_page, 0, PAGE_SIZE);
 
 	if (ti == NULL) {



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

2020-07-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Jul 20 03:24:59 UTC 2020

Modified Files:
src/sys/arch/mips/mips: locore_octeon.S

Log Message:
Remove check/limit for only 2 cores.
Use MIPS_EBASE_CPUNUM instead of magic numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/mips/mips/locore_octeon.S

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

Modified files:

Index: src/sys/arch/mips/mips/locore_octeon.S
diff -u src/sys/arch/mips/mips/locore_octeon.S:1.10 src/sys/arch/mips/mips/locore_octeon.S:1.11
--- src/sys/arch/mips/mips/locore_octeon.S:1.10	Wed Jul 27 09:32:35 2016
+++ src/sys/arch/mips/mips/locore_octeon.S	Mon Jul 20 03:24:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore_octeon.S,v 1.10 2016/07/27 09:32:35 skrll Exp $	*/
+/*	$NetBSD: locore_octeon.S,v 1.11 2020/07/20 03:24:59 simonb Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-RCSID("$NetBSD: locore_octeon.S,v 1.10 2016/07/27 09:32:35 skrll Exp $")
+RCSID("$NetBSD: locore_octeon.S,v 1.11 2020/07/20 03:24:59 simonb Exp $")
 
 #include "cpunode.h"			/* for NWDOG */
 #include "opt_cputype.h"
@@ -37,7 +37,7 @@ RCSID("$NetBSD: locore_octeon.S,v 1.10 2
 #include 
 #include 
 
-RCSID("$NetBSD: locore_octeon.S,v 1.10 2016/07/27 09:32:35 skrll Exp $")
+RCSID("$NetBSD: locore_octeon.S,v 1.11 2020/07/20 03:24:59 simonb Exp $")
 
 #include "assym.h"
 
@@ -122,27 +122,18 @@ NESTED_NOPROFILE(octeon_cpu_spinup, 0, r
 	// modified to refer to that CPU's cpu_info structure.
 	//
 	mfc0	s1, MIPS_COP_0_EBASE	# get EBASE
-	ext	s0, s1, 0, 10		# fetch cpunum (MIPSNNR2)
-	ins	s1, zero, 0, 10		# clear it (MIPSNNR2)
-	ins	s1, s0, 12, 10		# insert cpunum as exception address
+	andi	s0, s1, MIPS_EBASE_CPUNUM # fetch cpunum
+	# insert cpunum as exception address base:
+	ins	s1, s0, MIPS_EBASE_EXC_BASE_SHIFT, MIPS_EBASE_CPUNUM_WIDTH
 	ehb
 	mtc0	s1, MIPS_COP_0_EBASE	# set EBASE
 	COP0_SYNC
 
-	// we only can deal with 2 cores
-	li	v0, 1
-	beq	s0, v0, 2f
-	 nop
-	// spin if this isn't cpu 1
-1:	wait
-	b	1b
-	 nop
-
 	// Indicate this CPU was started by u-boot
-2:	PTR_LA	t0, _C_LABEL(cpus_booted) # get addr for kcpuset
-3:	sync
+	PTR_LA	t0, _C_LABEL(cpus_booted) # get addr for kcpuset
+1:	sync
 	PTR_L	a0, (t0)		# get kcpuset
-	beqz	a0, 3b			# loop until not NULL
+	beqz	a0, 1b			# loop until not NULL
 	 nop
 	jal	_C_LABEL(kcpuset_atomic_set)
 	 move	a1, s0			# pass it our cpu number
@@ -151,9 +142,9 @@ NESTED_NOPROFILE(octeon_cpu_spinup, 0, r
 	PTR_LA	a1, _C_LABEL(cpuid_infos)
 	dsll	v0, s0, PTR_SCALESHIFT	# cpunum -> array index
 	PTR_ADD	t0, a1, v0		# add to array start
-4:	sync
+1:	sync
 	PTR_L	a1, (t0)		# get cpu_info pointer
-	beqz	a1, 4b			# loop until non-NULL
+	beqz	a1, 1b			# loop until non-NULL
 	 nop
 
 	j	_C_LABEL(cpu_trampoline)
@@ -175,7 +166,7 @@ NESTED_NOPROFILE(octeon_reset_vector, 0,
 	ehb# hazard barrier
 #ifdef MULTIPROCESSOR
 	mfc0	k0, MIPS_COP_0_EBASE	# get EBASE
-	ext	k0, k0, 0, 10		# select cpunum
+	andi	k0, k0, MIPS_EBASE_CPUNUM # fetch cpunum
 	dsll	k0, k0, PTR_SCALESHIFT	# cpunum -> array index
 	PTR_LA	k1, _C_LABEL(cpuid_infos)
 	PTR_ADDU k1, k1, k0		# add to array start



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

2020-07-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Jul 20 03:23:43 UTC 2020

Modified Files:
src/sys/arch/mips/mips: locore.S

Log Message:
Use MIPS_EBASE_CPUNUM instead of magic numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.222 -r1.223 src/sys/arch/mips/mips/locore.S

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

Modified files:

Index: src/sys/arch/mips/mips/locore.S
diff -u src/sys/arch/mips/mips/locore.S:1.222 src/sys/arch/mips/mips/locore.S:1.223
--- src/sys/arch/mips/mips/locore.S:1.222	Wed Jan  8 20:59:19 2020
+++ src/sys/arch/mips/mips/locore.S	Mon Jul 20 03:23:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.222 2020/01/08 20:59:19 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.223 2020/07/20 03:23:42 simonb Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -63,7 +63,7 @@
 #include 
 #include 
 
-RCSID("$NetBSD: locore.S,v 1.222 2020/01/08 20:59:19 skrll Exp $")
+RCSID("$NetBSD: locore.S,v 1.223 2020/07/20 03:23:42 simonb Exp $")
 
 #include "assym.h"
 
@@ -119,7 +119,7 @@ _C_LABEL(kernel_text):
 	//
 	mfc0	a0, MIPS_COP_0_EBASE		# EBASE
 	COP0_SYNC
-	ext	a1, a0, 0, 10			# get CPU number
+	andia1, a0, MIPS_EBASE_CPUNUM	# fetch cpunum
 	beqz	a1, 2f# normal startup if 0
 	 nop
 #ifdef MULTIPROCESSOR



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

2020-07-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Jul 20 03:22:39 UTC 2020

Modified Files:
src/sys/arch/mips/mips: genassym.cf

Log Message:
Expose MIPS_EBASE_CPUNUM.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/mips/mips/genassym.cf

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

Modified files:

Index: src/sys/arch/mips/mips/genassym.cf
diff -u src/sys/arch/mips/mips/genassym.cf:1.69 src/sys/arch/mips/mips/genassym.cf:1.70
--- src/sys/arch/mips/mips/genassym.cf:1.69	Thu Feb 20 08:27:39 2020
+++ src/sys/arch/mips/mips/genassym.cf	Mon Jul 20 03:22:39 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.69 2020/02/20 08:27:39 skrll Exp $
+#	$NetBSD: genassym.cf,v 1.70 2020/07/20 03:22:39 simonb Exp $
 #
 # Copyright (c) 1992, 1993
 #	The Regents of the University of California.  All rights reserved.
@@ -185,6 +185,8 @@ define	V_MIPS3_PG_ASID		ilog2(__LOWEST_S
 define	S_MIPS3_PG_ASID		ilog2(MIPS3_PG_ASID+1)
 endif
 
+define	MIPS_EBASE_CPUNUM	MIPS_EBASE_CPUNUM
+
 define	TF_SIZ			sizeof(struct trapframe)
 define	TF_REG_ZERO		offsetof(struct trapframe, tf_regs[_R_ZERO])
 define	TF_REG_AST		offsetof(struct trapframe, tf_regs[_R_AST])



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

2020-07-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Jul 20 03:17:44 UTC 2020

Modified Files:
src/sys/arch/mips/include: cpuregs.h

Log Message:
Expose the width of the MIPS_EBASE_CPUNUM bitfield for asm code.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/mips/include/cpuregs.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/mips/include/cpuregs.h
diff -u src/sys/arch/mips/include/cpuregs.h:1.101 src/sys/arch/mips/include/cpuregs.h:1.102
--- src/sys/arch/mips/include/cpuregs.h:1.101	Mon Jul 20 01:10:38 2020
+++ src/sys/arch/mips/include/cpuregs.h	Mon Jul 20 03:17:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuregs.h,v 1.101 2020/07/20 01:10:38 simonb Exp $	*/
+/*	$NetBSD: cpuregs.h,v 1.102 2020/07/20 03:17:44 simonb Exp $	*/
 
 /*
  * Copyright (c) 2009 Miodrag Vallat.
@@ -836,6 +836,7 @@
 #define	MIPS_EBASE_EXC_BASE_SHIFT	12
 #define	MIPS_EBASE_EXC_BASE		__BITS(29, MIPS_EBASE_EXC_BASE_SHIFT)
 #define	MIPS_EBASE_CPUNUM		__BITS(9, 0)
+#define	MIPS_EBASE_CPUNUM_WIDTH		10	/* used by asm code */
 
 /*
  * Hints for the prefetch instruction



CVS commit: src/sys/arch/evbsh3/conf

2020-07-19 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Jul 20 02:04:43 UTC 2020

Modified Files:
src/sys/arch/evbsh3/conf: NEXTVOD

Log Message:
Use COPY_SYMTAB to get kernel symbols.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbsh3/conf/NEXTVOD

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/evbsh3/conf/NEXTVOD
diff -u src/sys/arch/evbsh3/conf/NEXTVOD:1.1 src/sys/arch/evbsh3/conf/NEXTVOD:1.2
--- src/sys/arch/evbsh3/conf/NEXTVOD:1.1	Sun Jul 19 23:44:36 2020
+++ src/sys/arch/evbsh3/conf/NEXTVOD	Mon Jul 20 02:04:43 2020
@@ -1,4 +1,4 @@
-# $NetBSD: NEXTVOD,v 1.1 2020/07/19 23:44:36 uwe Exp $
+# $NetBSD: NEXTVOD,v 1.2 2020/07/20 02:04:43 uwe Exp $
 
 # This config and related files are placeholders/boilerplate for work
 # in progress.  Not expected to compile.
@@ -6,7 +6,7 @@
 include "arch/evbsh3/conf/std.nextvod"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
-#ident 		"NEXTVOD-$Revision: 1.1 $"
+#ident 		"NEXTVOD-$Revision: 1.2 $"
 
 maxusers	32		# estimated number of users
 
@@ -88,6 +88,9 @@ options 	SCSIVERBOSE	# human readable SC
 #options 	MEMORY_DISK_ROOT_SIZE=3074	# size of memory disk, in blocks
 #options 	MEMORY_DISK_RBFLAGS=RB_SINGLE	# boot in single-user mode
 
+#makeoptions 	DEBUG="-g"	# compile full symbol table
+makeoptions	COPY_SYMTAB=1
+
 # Kernel root file system and dump configuration.
 config		netbsd	root on ? type ?
 



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

2020-07-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Jul 20 01:10:38 UTC 2020

Modified Files:
src/sys/arch/mips/include: cpuregs.h

Log Message:
Add an extra bitfield in MIPS_COP_0_EBASE.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/arch/mips/include/cpuregs.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/mips/include/cpuregs.h
diff -u src/sys/arch/mips/include/cpuregs.h:1.100 src/sys/arch/mips/include/cpuregs.h:1.101
--- src/sys/arch/mips/include/cpuregs.h:1.100	Mon Jul 13 09:00:40 2020
+++ src/sys/arch/mips/include/cpuregs.h	Mon Jul 20 01:10:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuregs.h,v 1.100 2020/07/13 09:00:40 simonb Exp $	*/
+/*	$NetBSD: cpuregs.h,v 1.101 2020/07/20 01:10:38 simonb Exp $	*/
 
 /*
  * Copyright (c) 2009 Miodrag Vallat.
@@ -833,6 +833,8 @@
 /*
  * Bits defined for EBASE (CP0 register 15, select 1).
  */
+#define	MIPS_EBASE_EXC_BASE_SHIFT	12
+#define	MIPS_EBASE_EXC_BASE		__BITS(29, MIPS_EBASE_EXC_BASE_SHIFT)
 #define	MIPS_EBASE_CPUNUM		__BITS(9, 0)
 
 /*



CVS commit: src/sys/arch/evbsh3/nextvod

2020-07-19 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Jul 20 01:06:33 UTC 2020

Modified Files:
src/sys/arch/evbsh3/nextvod: stasc.c

Log Message:
Implement cngetc to be able to talk to DDB.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbsh3/nextvod/stasc.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/evbsh3/nextvod/stasc.c
diff -u src/sys/arch/evbsh3/nextvod/stasc.c:1.1 src/sys/arch/evbsh3/nextvod/stasc.c:1.2
--- src/sys/arch/evbsh3/nextvod/stasc.c:1.1	Sun Jul 19 23:44:36 2020
+++ src/sys/arch/evbsh3/nextvod/stasc.c	Mon Jul 20 01:06:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: stasc.c,v 1.1 2020/07/19 23:44:36 uwe Exp $ */
+/* $NetBSD: stasc.c,v 1.2 2020/07/20 01:06:33 uwe Exp $ */
 /*
  * Copyright (c) 2020 Valery Ushakov
  * All rights reserved.
@@ -28,7 +28,7 @@
  * STMicroelectronics ST40 Asynchronous Serial Controller
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: stasc.c,v 1.1 2020/07/19 23:44:36 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: stasc.c,v 1.2 2020/07/20 01:06:33 uwe Exp $");
 
 #include 
 #include 
@@ -54,6 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: stasc.c,v 1.
 #define ASC_RETRIES_OFFSET	0x28
 
 #define ASC_TX_BUFF	(*(volatile uint32_t *)(STM_ASC_BASE + ASC_TX_BUFF_OFFSET))
+#define ASC_RX_BUFF	(*(volatile uint32_t *)(STM_ASC_BASE + ASC_RX_BUFF_OFFSET))
 #define ASC_INT_EN	(*(volatile uint32_t *)(STM_ASC_BASE + ASC_INT_EN_OFFSET))
 #define ASC_INT_STA	(*(volatile uint32_t *)(STM_ASC_BASE + ASC_INT_STA_OFFSET))
 
@@ -183,22 +184,39 @@ stasc_cninit(struct consdev *cp)
 int
 stasc_cngetc(dev_t dev)
 {
-	return -1;
+	int s = splserial();
+	uint32_t status;
+	int c;
+
+	/* don't block if Rx buffer is empty */
+	status = ASC_INT_STA;
+	if (!ISSET(status, ASC_INT_STA_RBF)) {
+		splx(s);
+		return -1;
+	}
+
+	/* can read the character now */
+	c = ASC_RX_BUFF;
+	splx(s);
+	return (unsigned char)c;
 }
 
 
 void
 stasc_cnputc(dev_t dev, int c)
 {
-	uint32_t status;
+	int s = splserial();
+	uint32_t timo, status;
 
-	/* wait for Tx FULL to become zero */
+	/* wait for Tx Full to become clear */
+	timo = 15;
 	do {
 		status = ASC_INT_STA;
-	} while ((status & ASC_INT_STA_TF) != 0);
+	} while (ISSET(status, ASC_INT_STA_TF) && --timo);
 
 	/* can write the character now */
 	ASC_TX_BUFF = c;
+	splx(s);
 }
 
 



CVS commit: src/sys/arch/evbsh3

2020-07-19 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Jul 19 23:44:36 UTC 2020

Added Files:
src/sys/arch/evbsh3/conf: NEXTVOD files.nextvod mk.nextvod std.nextvod
src/sys/arch/evbsh3/nextvod: clock_machdep.c nextvod.c stasc.c

Log Message:
Add placeholders/boilerplate for NextVoD.

STMicroelectronics support needs to be written for both the CPU and
devices.  This config and related files is absolute bare bones to get
a scaffolding kernel to compile to actually work on that support.
Don't hold your breath.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbsh3/conf/NEXTVOD \
src/sys/arch/evbsh3/conf/files.nextvod \
src/sys/arch/evbsh3/conf/mk.nextvod src/sys/arch/evbsh3/conf/std.nextvod
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbsh3/nextvod/clock_machdep.c \
src/sys/arch/evbsh3/nextvod/nextvod.c src/sys/arch/evbsh3/nextvod/stasc.c

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

Added files:

Index: src/sys/arch/evbsh3/conf/NEXTVOD
diff -u /dev/null src/sys/arch/evbsh3/conf/NEXTVOD:1.1
--- /dev/null	Sun Jul 19 23:44:36 2020
+++ src/sys/arch/evbsh3/conf/NEXTVOD	Sun Jul 19 23:44:36 2020
@@ -0,0 +1,178 @@
+# $NetBSD: NEXTVOD,v 1.1 2020/07/19 23:44:36 uwe Exp $
+
+# This config and related files are placeholders/boilerplate for work
+# in progress.  Not expected to compile.
+
+include "arch/evbsh3/conf/std.nextvod"
+
+options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
+#ident 		"NEXTVOD-$Revision: 1.1 $"
+
+maxusers	32		# estimated number of users
+
+
+# Standard system options
+options 	INSECURE	# disable kernel security levels
+
+options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
+options 	NTP		# NTP phase/frequency locked loop
+options 	KTRACE		# system call tracing via ktrace(1)
+
+options 	SYSVMSG		# System V message queues
+options 	SYSVSEM		# System V semaphores
+options 	SYSVSHM		# System V shared memory
+
+#options 	MODULAR		# new style module(7) framework
+#options 	MODULAR_DEFAULT_AUTOLOAD
+
+options 	USERCONF	# userconf(4) support
+#options 	PIPE_SOCKETPAIR	# smaller, but slower pipe(2)
+#options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
+
+
+# Diagnostic/debugging support options
+#options 	DIAGNOSTIC	# cheap kernel consistency checks
+#options 	DEBUG		# expensive debugging checks/support
+options 	DDB		# in-kernel debugger
+#options 	DDB_ONPANIC=0	# don't go into ddb on panic.
+options 	DDB_HISTORY_SIZE=512	# enable history editing in DDB
+#options 	DDB_COMMANDONENTER="bt"
+
+
+# File systems
+#file-system 	FFS		# UFS
+file-system 	MFS		# memory file system
+file-system 	NFS		# Network File System client
+file-system 	KERNFS		# /kern
+file-system 	PROCFS		# /proc
+file-system	PTYFS		# /dev/pts/N support
+
+# File system options
+#options 	WAPBL		# File system journaling support
+#options 	UFS_ACL		# UFS Access Control Lists
+options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
+options 	NFS_BOOT_DHCP	# Support DHCP NFS root
+
+
+# Networking options
+#options 	GATEWAY		# packet forwarding
+options 	INET		# IP + ICMP + TCP + UDP
+options 	INET6		# IPV6
+#options 	IPSEC		# IP security
+#options 	IPSEC_DEBUG	# debug for IP security
+#options 	MROUTING	# IP multicast routing
+#options 	PIM		# Protocol Independent Multicast
+#options 	NETATALK	# AppleTalk networking protocols
+#options 	PPP_BSDCOMP	# BSD-Compress compression support for PPP
+#options 	PPP_DEFLATE	# Deflate compression support for PPP
+#options 	PPP_FILTER	# Active filter support for PPP (requires bpf)
+#options 	TCP_DEBUG	# Record last TCP_NDEBUG packets with SO_DEBUG
+#options 	TCP_SIGNATURE	# Enable RFC-2385 TCP md5 signatures
+
+# These options enable verbose messages for several subsystems.
+# Warning, these may compile large string tables into the kernel!
+#options 	ACPIVERBOSE	# verbose ACPI configuration messages
+#options 	MIIVERBOSE	# verbose PHY autoconfig messages
+options 	PCIVERBOSE	# verbose PCI device autoconfig messages
+#options 	PCI_CONFIG_DUMP	# verbosely dump PCI config space
+#options 	PCMCIAVERBOSE	# verbose PCMCIA configuration messages
+options 	SCSIVERBOSE	# human readable SCSI error messages
+#options 	USBVERBOSE	# verbose USB device autoconfig messages
+#options 	HDAUDIOVERBOSE	# verbose HDAUDIO driver messages
+
+
+# Enable the hooks used for initializing the root memory-disk.
+#options 	MEMORY_DISK_HOOKS
+#options 	MEMORY_DISK_IS_ROOT	# force root on memory disk
+#options 	MEMORY_DISK_SERVER=0	# no userspace memory disk support
+#options 	MEMORY_DISK_ROOT_SIZE=3074	# size of memory disk, in blocks
+#options 	MEMORY_DISK_RBFLAGS=RB_SINGLE	# boot in single-user mode
+
+# Kernel root file system and dump configuration.
+config		netbsd	root on ? type ?
+
+
+#
+# Device configuration
+#
+mainbus0 at root
+
+shb* at mainbus?
+
+# serial (console)
+stasc0 at mainbus?
+
+
+# Pseudo-Devices
+
+pseudo-device	swcrypto		# software crypto 

CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 22:22:01 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): remove unnecessary UNCONST


To generate a diff of this commit:
cvs rdiff -u -r1.276 -r1.277 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.276 src/usr.bin/make/var.c:1.277
--- src/usr.bin/make/var.c:1.276	Sun Jul 19 22:04:27 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 22:22:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.276 2020/07/19 22:04:27 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.277 2020/07/19 22:22:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.276 2020/07/19 22:04:27 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.277 2020/07/19 22:22:01 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.276 2020/07/19 22:04:27 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.277 2020/07/19 22:22:01 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1225,7 +1225,7 @@ VarMatch(GNode *ctx MAKE_ATTR_UNUSED, Va
  *
  *---
  */
-static char *
+static const char *
 Str_SYSVMatch(const char *word, const char *pattern, size_t *len,
 Boolean *hasPercent)
 {
@@ -1237,7 +1237,7 @@ Str_SYSVMatch(const char *word, const ch
 if (*p == '\0') {
 	/* Null pattern is the whole string */
 	*len = strlen(w);
-	return UNCONST(w);
+	return w;
 }
 
 if ((m = strchr(p, '%')) != NULL) {
@@ -1256,19 +1256,19 @@ Str_SYSVMatch(const char *word, const ch
 	if (*++p == '\0') {
 	/* No more pattern, return the rest of the string */
 	*len = strlen(w);
-	return UNCONST(w);
+	return w;
 	}
 }
 
 m = w;
 
 /* Find a matching tail */
-do
+do {
 	if (strcmp(p, w) == 0) {
 	*len = w - m;
-	return UNCONST(m);
+	return m;
 	}
-while (*w++ != '\0');
+} while (*w++ != '\0');
 
 return NULL;
 }



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 22:04:28 UTC 2020

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: sysv.exp sysv.mk

Log Message:
make(1): make ampersand in ${VAR:from=to&} an ordinary character

In SysV substitutions, wildcards are expressed with % instead of &.  The
& is not mentioned in the manual page, and having another wildcard for
the whole word would be such an obscure feature that not even pkgsrc uses
it.  The easiest way to discover this feature had been to read the source
code of make(1) or to use a fuzzer and accidentally stumble upon this
edge case.


To generate a diff of this commit:
cvs rdiff -u -r1.275 -r1.276 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/sysv.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/sysv.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/var.c
diff -u src/usr.bin/make/var.c:1.275 src/usr.bin/make/var.c:1.276
--- src/usr.bin/make/var.c:1.275	Sun Jul 19 21:30:49 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 22:04:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.275 2020/07/19 21:30:49 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.276 2020/07/19 22:04:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.275 2020/07/19 21:30:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.276 2020/07/19 22:04:27 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.275 2020/07/19 21:30:49 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.276 2020/07/19 22:04:27 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1308,22 +1308,27 @@ Str_SYSVSubst(Buffer *buf, const char *p
 }
 
 
+typedef struct {
+const char *lhs;
+const char *rhs;
+} VarSYSVSubstArgs;
+
 /* Callback function for VarModify to implement the :%.from=%.to modifier. */
 static Boolean
-VarSYSVMatch(GNode *ctx, Var_Parse_State *vpstate,
+VarSYSVSubst(GNode *ctx, Var_Parse_State *vpstate,
 	 const char *word, Boolean addSpace, Buffer *buf,
 	 void *data)
 {
-size_t len;
-const char *ptr;
-Boolean hasPercent;
-VarPattern *pat = data;
+const VarSYSVSubstArgs *args = data;
 
 if (addSpace && vpstate->varSpace != '\0')
 	Buf_AddByte(buf, vpstate->varSpace);
 
-if ((ptr = Str_SYSVMatch(word, pat->lhs, , )) != NULL) {
-	char *varexp = Var_Subst(NULL, pat->rhs, ctx, VARE_WANTRES);
+size_t len;
+Boolean hasPercent;
+const char *ptr = Str_SYSVMatch(word, args->lhs, , );
+if (ptr != NULL) {
+	char *varexp = Var_Subst(NULL, args->rhs, ctx, VARE_WANTRES);
 	Str_SYSVSubst(buf, varexp, ptr, len, hasPercent);
 	free(varexp);
 } else {
@@ -3167,15 +3172,7 @@ ApplyModifier_Remember(ApplyModifiersSta
 static int
 ApplyModifier_SysV(ApplyModifiersState *st)
 {
-/*
- * This can either be a bogus modifier or a System-V
- * substitution command.
- */
-VarPattern  pattern;
-/* FIXME: SysV modifiers have nothing to do with :S or :C pattern matching */
-Boolean eqFound = FALSE;
-
-pattern.pflags = 0;
+Boolean eqFound = FALSE;
 
 /*
  * First we make a pass through the string trying
@@ -3200,20 +3197,19 @@ ApplyModifier_SysV(ApplyModifiersState *
 
 st->delim = '=';
 st->cp = st->tstr;
+VarPatternFlags pflags = 0;
 /* FIXME: There's no point in having a single $ at the end of a
  * SysV substitution since that will not be interpreted as an
  * anchor anyway. */
-pattern.lhs = ParseModifierPart(
-	st->ctxt, >cp, st->delim, st->eflags,
-	, , NULL);
-if (pattern.lhs == NULL)
+char *lhs = ParseModifierPart(st->ctxt, >cp, st->delim, st->eflags,
+  , NULL, NULL);
+if (lhs == NULL)
 	return 'c';
 
 st->delim = st->endc;
-pattern.rhs = ParseModifierPart(
-	st->ctxt, >cp, st->delim, st->eflags,
-	NULL, , );
-if (pattern.rhs == NULL)
+char *rhs = ParseModifierPart(st->ctxt, >cp, st->delim, st->eflags,
+  NULL, NULL, NULL);
+if (rhs == NULL)
 	return 'c';
 
 /*
@@ -3222,14 +3218,15 @@ ApplyModifier_SysV(ApplyModifiersState *
  */
 st->termc = *--st->cp;
 st->delim = '\0';
-if (pattern.leftLen == 0 && *st->nstr == '\0') {
+if (lhs[0] == '\0' && *st->nstr == '\0') {
 	st->newStr = st->nstr;	/* special case */
 } else {
-	st->newStr = VarModify(
-	st->ctxt, >parsestate, st->nstr, VarSYSVMatch, );
+	VarSYSVSubstArgs args = { lhs, rhs };
+	st->newStr = VarModify(st->ctxt, >parsestate, st->nstr,
+			   VarSYSVSubst, );
 }
-free(UNCONST(pattern.lhs));
-free(UNCONST(pattern.rhs));
+free(lhs);
+free(rhs);
 return '=';
 }
 #endif

Index: src/usr.bin/make/unit-tests/sysv.exp
diff -u 

CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 21:30:50 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): don't call VarSubstitute unnecessarily


To generate a diff of this commit:
cvs rdiff -u -r1.274 -r1.275 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.274 src/usr.bin/make/var.c:1.275
--- src/usr.bin/make/var.c:1.274	Sun Jul 19 21:14:56 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 21:30:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.274 2020/07/19 21:14:56 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.275 2020/07/19 21:30:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.274 2020/07/19 21:14:56 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.275 2020/07/19 21:30:49 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.274 2020/07/19 21:14:56 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.275 2020/07/19 21:30:49 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2736,6 +2736,17 @@ ApplyModifier_Regex(ApplyModifiersState 
 }
 #endif
 
+static Boolean
+VarModify_Copy(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
+	  const char *word, Boolean addSpace, Buffer *buf,
+	  void *data MAKE_ATTR_UNUSED)
+{
+if (addSpace && vpstate->varSpace != '\0')
+	Buf_AddByte(buf, vpstate->varSpace);
+Buf_AddBytes(buf, strlen(word), word);
+return TRUE;
+}
+
 /* :tA, :tu, :tl, etc. */
 static Boolean
 ApplyModifier_To(ApplyModifiersState *st)
@@ -2744,7 +2755,6 @@ ApplyModifier_To(ApplyModifiersState *st
 if (st->tstr[1] != st->endc && st->tstr[1] != ':') {
 	if (st->tstr[1] == 's') {
 	/* Use the char (if any) at st->tstr[2] as the word separator. */
-	VarPattern pattern;
 
 	if (st->tstr[2] != st->endc &&
 		(st->tstr[3] == st->endc || st->tstr[3] == ':')) {
@@ -2796,18 +2806,8 @@ ApplyModifier_To(ApplyModifiersState *st
 	}
 
 	st->termc = *st->cp;
-
-	/*
-	 * We cannot be certain that VarModify will be used - even if there
-	 * is a subsequent modifier, so do a no-op VarSubstitute now to for
-	 * str to be re-expanded without the spaces.
-	 */
-	pattern.pflags = VARP_SUB_ONE;
-	pattern.lhs = pattern.rhs = "\032";
-	pattern.leftLen = pattern.rightLen = 1;
-
-	st->newStr = VarModify(
-		st->ctxt, >parsestate, st->nstr, VarSubstitute, );
+	st->newStr = VarModify(st->ctxt, >parsestate, st->nstr,
+   VarModify_Copy, NULL);
 	} else if (st->tstr[2] == st->endc || st->tstr[2] == ':') {
 	/* Check for two-character options: ":tu", ":tl" */
 	if (st->tstr[1] == 'A') {	/* absolute path */



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 21:14:56 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): remove wrong VarPattern from ApplyModifier_Exclam


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.273 src/usr.bin/make/var.c:1.274
--- src/usr.bin/make/var.c:1.273	Sun Jul 19 21:10:34 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 21:14:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.273 2020/07/19 21:10:34 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.274 2020/07/19 21:14:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.273 2020/07/19 21:10:34 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.274 2020/07/19 21:14:56 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.273 2020/07/19 21:10:34 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.274 2020/07/19 21:14:56 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2469,26 +2469,23 @@ ApplyModifier_Path(ApplyModifiersState *
 static Boolean
 ApplyModifier_Exclam(ApplyModifiersState *st)
 {
-const char *emsg;
-VarPattern pattern;
-
-pattern.pflags = 0;
-
 st->delim = '!';
-emsg = NULL;
 st->cp = ++st->tstr;
-pattern.rhs = ParseModifierPart(
-	st->ctxt, >cp, st->delim, st->eflags,
-	NULL, , NULL);
-if (pattern.rhs == NULL)
+char *cmd = ParseModifierPart(st->ctxt, >cp, st->delim, st->eflags,
+  NULL, NULL, NULL);
+if (cmd == NULL)
 	return FALSE;
+
+const char *emsg = NULL;
 if (st->eflags & VARE_WANTRES)
-	st->newStr = Cmd_Exec(pattern.rhs, );
+	st->newStr = Cmd_Exec(cmd, );
 else
 	st->newStr = varNoError;
-free(UNCONST(pattern.rhs));
+free(cmd);
+
 if (emsg)
 	Error(emsg, st->nstr);
+
 st->termc = *st->cp;
 st->delim = '\0';
 if (st->v->flags & VAR_JUNK)



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 21:10:35 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): remove wrong VarPattern from ApplyModifier_Assign


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.272 src/usr.bin/make/var.c:1.273
--- src/usr.bin/make/var.c:1.272	Sun Jul 19 20:56:34 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 21:10:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.272 2020/07/19 20:56:34 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.273 2020/07/19 21:10:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.272 2020/07/19 20:56:34 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.273 2020/07/19 21:10:34 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.272 2020/07/19 20:56:34 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.273 2020/07/19 21:10:34 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3060,10 +3060,6 @@ ApplyModifier_Assign(ApplyModifiersState
 	return 'd';		/* "::" */
 
 GNode *v_ctxt;		/* context where v belongs */
-const char *emsg;
-char *sv_name;
-VarPattern pattern;
-int how;
 VarPatternFlags pflags;
 /* FIXME: Assign has nothing to do with VarPatternFlags */
 
@@ -3071,7 +3067,7 @@ ApplyModifier_Assign(ApplyModifiersState
 	return 'b';
 
 v_ctxt = st->ctxt;
-sv_name = NULL;
+char *sv_name = NULL;
 ++st->tstr;
 if (st->v->flags & VAR_JUNK) {
 	/*
@@ -3087,7 +3083,7 @@ ApplyModifier_Assign(ApplyModifiersState
 	VarFreeEnv(gv, TRUE);
 }
 
-switch ((how = *st->tstr)) {
+switch (op[0]) {
 case '+':
 case '?':
 case '!':
@@ -3098,46 +3094,46 @@ ApplyModifier_Assign(ApplyModifiersState
 	break;
 }
 st->delim = st->startc == PROPEN ? PRCLOSE : BRCLOSE;
-pattern.pflags = 0;
 
 pflags = (st->eflags & VARE_WANTRES) ? 0 : VAR_NOSUBST;
-pattern.rhs = ParseModifierPart(
-	st->ctxt, >cp, st->delim, st->eflags,
-	, , NULL);
+char *val = ParseModifierPart(st->ctxt, >cp, st->delim, st->eflags,
+  , NULL, NULL);
 if (st->v->flags & VAR_JUNK) {
 	/* restore original name */
 	free(st->v->name);
 	st->v->name = sv_name;
 }
-if (pattern.rhs == NULL)
+if (val == NULL)
 	return 'c';
 
 st->termc = *--st->cp;
 st->delim = '\0';
 
 if (st->eflags & VARE_WANTRES) {
-	switch (how) {
+	switch (op[0]) {
 	case '+':
-	Var_Append(st->v->name, pattern.rhs, v_ctxt);
+	Var_Append(st->v->name, val, v_ctxt);
 	break;
-	case '!':
-	st->newStr = Cmd_Exec(pattern.rhs, );
+	case '!': {
+	const char *emsg;
+	st->newStr = Cmd_Exec(val, );
 	if (emsg)
 		Error(emsg, st->nstr);
 	else
 		Var_Set(st->v->name, st->newStr, v_ctxt);
 	free(st->newStr);
 	break;
+	}
 	case '?':
 	if ((st->v->flags & VAR_JUNK) == 0)
 		break;
 	/* FALLTHROUGH */
 	default:
-	Var_Set(st->v->name, pattern.rhs, v_ctxt);
+	Var_Set(st->v->name, val, v_ctxt);
 	break;
 	}
 }
-free(UNCONST(pattern.rhs));
+free(val);
 st->newStr = varNoError;
 return 0;
 }



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

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 21:03:55 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: cond-short.mk

Log Message:
make(1): add test for assignment operators in conditions


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-short.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/cond-short.mk
diff -u src/usr.bin/make/unit-tests/cond-short.mk:1.7 src/usr.bin/make/unit-tests/cond-short.mk:1.8
--- src/usr.bin/make/unit-tests/cond-short.mk:1.7	Thu Jul  9 22:34:09 2020
+++ src/usr.bin/make/unit-tests/cond-short.mk	Sun Jul 19 21:03:55 2020
@@ -1,4 +1,4 @@
-# $NetBSD: cond-short.mk,v 1.7 2020/07/09 22:34:09 sjg Exp $
+# $NetBSD: cond-short.mk,v 1.8 2020/07/19 21:03:55 rillig Exp $
 #
 # Demonstrates that in conditions, the right-hand side of an && or ||
 # is only evaluated if it can actually influence the result.
@@ -66,6 +66,19 @@ VAR=	# empty again, for the following te
 .if 0 && !empty(:U${:!echo "unexpected exclam modifier" 1>&2 !})
 .endif
 
+# Irrelevant assignment modifiers are skipped as well.
+.if 0 && ${1 2 3:L:@i@${FIRST::?=$i}@}
+.endif
+.if 0 && ${1 2 3:L:@i@${LAST::=$i}@}
+.endif
+.if 0 && ${1 2 3:L:@i@${APPENDED::+=$i}@}
+.endif
+.if 0 && ${echo.1 echo.2 echo.3:L:@i@${RAN::!=${i:C,.*,&; & 1>\&2,:S,., ,g}}@}
+.endif
+.if defined(FIRST) || defined(LAST) || defined(APPENDED) || defined(RAN)
+.warning first=${FIRST} last=${LAST} appended=${APPENDED} ran=${RAN}
+.endif
+
 # The || operator.
 
 .if 1 || ${echo "unexpected or" 1>&2 :L:sh}



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 20:56:34 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): flatten ApplyModifier_Assign


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.271 src/usr.bin/make/var.c:1.272
--- src/usr.bin/make/var.c:1.271	Sun Jul 19 19:27:08 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 20:56:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.271 2020/07/19 19:27:08 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.272 2020/07/19 20:56:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.271 2020/07/19 19:27:08 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.272 2020/07/19 20:56:34 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.271 2020/07/19 19:27:08 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.272 2020/07/19 20:56:34 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3053,93 +3053,93 @@ ApplyModifier_IfElse(ApplyModifiersState
 static int
 ApplyModifier_Assign(ApplyModifiersState *st)
 {
-if (st->tstr[1] == '=' ||
-	(st->tstr[2] == '=' &&
-	 (st->tstr[1] == '!' || st->tstr[1] == '+' || st->tstr[1] == '?'))) {
-	GNode *v_ctxt;		/* context where v belongs */
-	const char *emsg;
-	char *sv_name;
-	VarPattern pattern;
-	int how;
-	VarPatternFlags pflags;
-	/* FIXME: Assign has nothing to do with VarPatternFlags */
+const char *op = st->tstr + 1;
+if (!(op[0] == '=' ||
+	(op[1] == '=' &&
+	 (op[0] == '!' || op[0] == '+' || op[0] == '?'
+	return 'd';		/* "::" */
 
-	if (st->v->name[0] == 0)
-	return 'b';
+GNode *v_ctxt;		/* context where v belongs */
+const char *emsg;
+char *sv_name;
+VarPattern pattern;
+int how;
+VarPatternFlags pflags;
+/* FIXME: Assign has nothing to do with VarPatternFlags */
 
-	v_ctxt = st->ctxt;
-	sv_name = NULL;
-	++st->tstr;
-	if (st->v->flags & VAR_JUNK) {
-	/*
-	 * We need to bmake_strdup() it incase
-	 * ParseModifierPart() recurses.
-	 */
-	sv_name = st->v->name;
-	st->v->name = bmake_strdup(st->v->name);
-	} else if (st->ctxt != VAR_GLOBAL) {
-	Var *gv = VarFind(st->v->name, st->ctxt, 0);
-	if (gv == NULL)
-		v_ctxt = VAR_GLOBAL;
-	else
-		VarFreeEnv(gv, TRUE);
-	}
+if (st->v->name[0] == 0)
+	return 'b';
+
+v_ctxt = st->ctxt;
+sv_name = NULL;
+++st->tstr;
+if (st->v->flags & VAR_JUNK) {
+	/*
+	 * We need to bmake_strdup() it incase ParseModifierPart() recurses.
+	 */
+	sv_name = st->v->name;
+	st->v->name = bmake_strdup(st->v->name);
+} else if (st->ctxt != VAR_GLOBAL) {
+	Var *gv = VarFind(st->v->name, st->ctxt, 0);
+	if (gv == NULL)
+	v_ctxt = VAR_GLOBAL;
+	else
+	VarFreeEnv(gv, TRUE);
+}
+
+switch ((how = *st->tstr)) {
+case '+':
+case '?':
+case '!':
+	st->cp = >tstr[2];
+	break;
+default:
+	st->cp = ++st->tstr;
+	break;
+}
+st->delim = st->startc == PROPEN ? PRCLOSE : BRCLOSE;
+pattern.pflags = 0;
 
-	switch ((how = *st->tstr)) {
+pflags = (st->eflags & VARE_WANTRES) ? 0 : VAR_NOSUBST;
+pattern.rhs = ParseModifierPart(
+	st->ctxt, >cp, st->delim, st->eflags,
+	, , NULL);
+if (st->v->flags & VAR_JUNK) {
+	/* restore original name */
+	free(st->v->name);
+	st->v->name = sv_name;
+}
+if (pattern.rhs == NULL)
+	return 'c';
+
+st->termc = *--st->cp;
+st->delim = '\0';
+
+if (st->eflags & VARE_WANTRES) {
+	switch (how) {
 	case '+':
-	case '?':
+	Var_Append(st->v->name, pattern.rhs, v_ctxt);
+	break;
 	case '!':
-	st->cp = >tstr[2];
+	st->newStr = Cmd_Exec(pattern.rhs, );
+	if (emsg)
+		Error(emsg, st->nstr);
+	else
+		Var_Set(st->v->name, st->newStr, v_ctxt);
+	free(st->newStr);
 	break;
+	case '?':
+	if ((st->v->flags & VAR_JUNK) == 0)
+		break;
+	/* FALLTHROUGH */
 	default:
-	st->cp = ++st->tstr;
+	Var_Set(st->v->name, pattern.rhs, v_ctxt);
 	break;
 	}
-	st->delim = st->startc == PROPEN ? PRCLOSE : BRCLOSE;
-	pattern.pflags = 0;
-
-	pflags = (st->eflags & VARE_WANTRES) ? 0 : VAR_NOSUBST;
-	pattern.rhs = ParseModifierPart(
-	st->ctxt, >cp, st->delim, st->eflags,
-	, , NULL);
-	if (st->v->flags & VAR_JUNK) {
-	/* restore original name */
-	free(st->v->name);
-	st->v->name = sv_name;
-	}
-	if (pattern.rhs == NULL)
-	return 'c';
-
-	st->termc = *--st->cp;
-	st->delim = '\0';
-
-	if (st->eflags & VARE_WANTRES) {
-	switch (how) {
-	case '+':
-		Var_Append(st->v->name, pattern.rhs, v_ctxt);
-		break;
-	case '!':
-		st->newStr = Cmd_Exec(pattern.rhs, );
-		if (emsg)
-		Error(emsg, st->nstr);
-		

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

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 20:49:45 UTC 2020

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

Log Message:
make(1): add tests for the ::= modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/modmisc.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/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.18 src/usr.bin/make/unit-tests/modmisc.exp:1.19
--- src/usr.bin/make/unit-tests/modmisc.exp:1.18	Sun Jul 19 19:36:20 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp	Sun Jul 19 20:49:44 2020
@@ -70,4 +70,12 @@ make: No subexpression \2
 mod-C-limits:22-missing:1 6
 mod-C-limits:22-ok:1 33 556
 mod-C-limits:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest
+mod-assign: first=1.
+mod-assign: last=3.
+mod-assign: appended=1 2 3.
+1
+2
+3
+mod-assign: ran:3.
+mod-assign: global: 1, 3, 1 2 3, 3.
 exit status 0

Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.15 src/usr.bin/make/unit-tests/modmisc.mk:1.16
--- src/usr.bin/make/unit-tests/modmisc.mk:1.15	Sun Jul 19 19:36:20 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk	Sun Jul 19 20:49:44 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.15 2020/07/19 19:36:20 rillig Exp $
+# $Id: modmisc.mk,v 1.16 2020/07/19 20:49:44 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -19,6 +19,7 @@ all:	modvar modvarloop modsysv mod-HTE e
 all:	mod-S mod-C mod-at-varname mod-at-resolve mod-at-dollar
 all:	mod-subst-dollar mod-loop-dollar
 all:	mod-C-limits
+all:	mod-assign
 
 modsysv:
 	@echo "The answer is ${libfoo.a:L:libfoo.a=42}"
@@ -145,3 +146,13 @@ mod-C-limits:
 	# The :C modifier only handles single-digit capturing groups,
 	# which is more than enough for daily use.
 	@echo $@:capture:${:UabcdefghijABCDEFGHIJrest:C,(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.),\9\8\7\6\5\4\3\2\1\0\10\11\12,}
+
+# Just a bit of basic code coverage for the obscure ::= assignment modifiers.
+mod-assign:
+	@echo $@: ${1 2 3:L:@i@${FIRST::?=$i}@} first=${FIRST}.
+	@echo $@: ${1 2 3:L:@i@${LAST::=$i}@} last=${LAST}.
+	@echo $@: ${1 2 3:L:@i@${APPENDED::+=$i}@} appended=${APPENDED}.
+	@echo $@: ${echo.1 echo.2 echo.3:L:@i@${RAN::!=${i:C,.*,&; & 1>\&2,:S,., ,g}}@} ran:${RAN}.
+	# The assignments happen in the global scope and thus are
+	# preserved even after the shell command has been run.
+	@echo $@: global: ${FIRST:Q}, ${LAST:Q}, ${APPENDED:Q}, ${RAN:Q}.



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

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 20:37:57 UTC 2020

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

Log Message:
make(1): fix date in comment in unit test


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmisc.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/varmisc.mk
diff -u src/usr.bin/make/unit-tests/varmisc.mk:1.10 src/usr.bin/make/unit-tests/varmisc.mk:1.11
--- src/usr.bin/make/unit-tests/varmisc.mk:1.10	Thu Jul  2 09:44:51 2020
+++ src/usr.bin/make/unit-tests/varmisc.mk	Sun Jul 19 20:37:57 2020
@@ -1,4 +1,4 @@
-# $Id: varmisc.mk,v 1.10 2020/07/02 09:44:51 rillig Exp $
+# $Id: varmisc.mk,v 1.11 2020/07/19 20:37:57 rillig Exp $
 #
 # Miscellaneous variable tests.
 
@@ -74,7 +74,7 @@ manok:
 	@echo MAN=${MAN}
 
 # This is an expanded variant of the above .for loop.
-# Between 2020-08-28 and 2020-07-02 this paragraph generated a wrong
+# Between 2020-06-28 and 2020-07-02 this paragraph generated a wrong
 # error message "Variable VARNAME is recursive".
 # When evaluating the !empty expression, the ${:U1} was not expanded and
 # thus resulted in the seeming definition VARNAME=${VARNAME}, which is



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

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 19:36:20 UTC 2020

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

Log Message:
make(1): add tests for maximum number of capturing groups in :C


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/modmisc.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/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.17 src/usr.bin/make/unit-tests/modmisc.exp:1.18
--- src/usr.bin/make/unit-tests/modmisc.exp:1.17	Sun Jul 19 19:27:08 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp	Sun Jul 19 19:36:20 2020
@@ -69,4 +69,5 @@ make: No subexpression \2
 make: No subexpression \2
 mod-C-limits:22-missing:1 6
 mod-C-limits:22-ok:1 33 556
+mod-C-limits:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest
 exit status 0

Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.14 src/usr.bin/make/unit-tests/modmisc.mk:1.15
--- src/usr.bin/make/unit-tests/modmisc.mk:1.14	Sun Jul 19 17:24:22 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk	Sun Jul 19 19:36:20 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.14 2020/07/19 17:24:22 rillig Exp $
+# $Id: modmisc.mk,v 1.15 2020/07/19 19:36:20 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -142,3 +142,6 @@ mod-C-limits:
 	@echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q}
 	@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}
 	@echo $@:22-ok:${:U1 23 456:C,(.)(.),\2\2,:Q}
+	# The :C modifier only handles single-digit capturing groups,
+	# which is more than enough for daily use.
+	@echo $@:capture:${:UabcdefghijABCDEFGHIJrest:C,(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.),\9\8\7\6\5\4\3\2\1\0\10\11\12,}



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 19:27:08 UTC 2020

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: modmisc.exp

Log Message:
make(1): fix off-by-one error in :C modifier

Previously this off-by-one error had invoked undefined behavior.
Until today there was no corresponding unit test though.


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/usr.bin/make/var.c
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/modmisc.exp

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/var.c
diff -u src/usr.bin/make/var.c:1.270 src/usr.bin/make/var.c:1.271
--- src/usr.bin/make/var.c:1.270	Sun Jul 19 18:35:53 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 19:27:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.270 2020/07/19 18:35:53 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.271 2020/07/19 19:27:08 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.270 2020/07/19 18:35:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.271 2020/07/19 19:27:08 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.270 2020/07/19 18:35:53 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.271 2020/07/19 19:27:08 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1578,7 +1578,7 @@ VarRESubstitute(GNode *ctx MAKE_ATTR_UNU
 		rp++;
 		}
 
-		if (n > pat->nsub) {
+		if (n >= pat->nsub) {
 		Error("No subexpression %s", [0]);
 		subbuf = "";
 		sublen = 0;

Index: src/usr.bin/make/unit-tests/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.16 src/usr.bin/make/unit-tests/modmisc.exp:1.17
--- src/usr.bin/make/unit-tests/modmisc.exp:1.16	Sun Jul 19 17:24:22 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp	Sun Jul 19 19:27:08 2020
@@ -52,6 +52,10 @@ mod-loop-dollar:$${word}$:
 mod-loop-dollar:$$5$$:
 mod-loop-dollar:$$${word}$$:
 mod-C-limits:00-ok:1 2323 45456
+make: No subexpression \1
+make: No subexpression \1
+make: No subexpression \1
+make: No subexpression \1
 mod-C-limits:11-missing:1 6
 mod-C-limits:11-ok:1 22 446
 make: No subexpression \2
@@ -59,6 +63,10 @@ make: No subexpression \2
 make: No subexpression \2
 make: No subexpression \2
 mod-C-limits:22-missing:1 6
+make: No subexpression \2
+make: No subexpression \2
+make: No subexpression \2
+make: No subexpression \2
 mod-C-limits:22-missing:1 6
 mod-C-limits:22-ok:1 33 556
 exit status 0



CVS commit: xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k

2020-07-19 Thread Izumi Tsutsui
Module Name:xsrc
Committed By:   tsutsui
Date:   Sun Jul 19 19:11:05 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k: x68kKbd.c

Log Message:
Sync with xorg-server.old: Remove #ifdef XKB conditional.

> It has been mandatory on Xorg:
>  
> https://cgit.freedesktop.org/xorg/xserver/commit/?id=40877c6680863bd6a8475f2bb0c54df55bcf0b0e


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.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/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c
diff -u xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c:1.5 xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c:1.6
--- xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c:1.5	Sat Jul 18 15:37:02 2020
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c	Sun Jul 19 19:11:05 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: x68kKbd.c,v 1.5 2020/07/18 15:37:02 tsutsui Exp $ */
+/* $NetBSD: x68kKbd.c,v 1.6 2020/07/19 19:11:05 tsutsui Exp $ */
 /*-
  * Copyright (c) 1996 Yasushi Yamasaki
  * All rights reserved.
@@ -382,12 +382,10 @@ x68kKbdCtrl(DeviceIntPtr pDev, KeybdCtrl
 {
 X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate;
 
-#ifdef XKB
 if (pPriv->leds != ctrl->leds) {
 x68kSetLeds(pPriv, (u_char)ctrl->leds);
 	pPriv->leds = ctrl->leds;
 }
-#endif
 }
 
 /*-



CVS commit: xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k

2020-07-19 Thread Izumi Tsutsui
Module Name:xsrc
Committed By:   tsutsui
Date:   Sun Jul 19 19:05:20 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k: x68kKbd.c

Log Message:
Remove #ifdef XKB conditional.

It has been mandatory on Xorg:
 
https://cgit.freedesktop.org/xorg/xserver/commit/?id=40877c6680863bd6a8475f2bb0c54df55bcf0b0e


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kKbd.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/xorg-server.old/dist/hw/netbsd/x68k/x68kKbd.c
diff -u xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kKbd.c:1.2 xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kKbd.c:1.3
--- xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kKbd.c:1.2	Fri Apr 10 16:49:36 2020
+++ xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kKbd.c	Sun Jul 19 19:05:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: x68kKbd.c,v 1.2 2020/04/10 16:49:36 tsutsui Exp $ */
+/* $NetBSD: x68kKbd.c,v 1.3 2020/07/19 19:05:20 tsutsui Exp $ */
 /*-
  * Copyright (c) 1996 Yasushi Yamasaki
  * All rights reserved.
@@ -378,12 +378,10 @@ x68kKbdCtrl(DeviceIntPtr pDev, KeybdCtrl
 {
 X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate;
 
-#ifdef XKB
 if (pPriv->leds != ctrl->leds) {
 x68kSetLeds(pPriv, (u_char)ctrl->leds);
 	pPriv->leds = ctrl->leds;
 }
-#endif
 }
 
 /*-



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 18:35:54 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): fix double free introduced this morning in r1.258


To generate a diff of this commit:
cvs rdiff -u -r1.269 -r1.270 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.269 src/usr.bin/make/var.c:1.270
--- src/usr.bin/make/var.c:1.269	Sun Jul 19 17:43:36 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 18:35:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.269 2020/07/19 17:43:36 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.270 2020/07/19 18:35:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.269 2020/07/19 17:43:36 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.270 2020/07/19 18:35:53 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.269 2020/07/19 17:43:36 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.270 2020/07/19 18:35:53 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3042,7 +3042,7 @@ ApplyModifier_IfElse(ApplyModifiersState
 	free(else_expr);
 } else {
 	st->newStr = else_expr;
-	free(else_expr);
+	free(then_expr);
 }
 if (st->v->flags & VAR_JUNK)
 	st->v->flags |= VAR_KEEP;



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 17:43:36 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): remove redundant loop control variable


To generate a diff of this commit:
cvs rdiff -u -r1.268 -r1.269 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.268 src/usr.bin/make/var.c:1.269
--- src/usr.bin/make/var.c:1.268	Sun Jul 19 17:40:30 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 17:43:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.268 2020/07/19 17:40:30 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.269 2020/07/19 17:43:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.268 2020/07/19 17:40:30 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.269 2020/07/19 17:43:36 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.268 2020/07/19 17:40:30 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.269 2020/07/19 17:43:36 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1455,32 +1455,21 @@ VarSubstitute(GNode *ctx MAKE_ATTR_UNUSE
 	 * addSpace is set FALSE as soon as a space is added to the
 	 * buffer.
 	 */
-	Boolean done;
-	int origSize;
-
-	done = FALSE;
-	origSize = Buf_Size(buf);
-	while (!done) {
-		cp = Str_FindSubstring(word, pattern->lhs);
-		if (cp != NULL) {
-		if (addSpace && (((cp - word) + pattern->rightLen) != 0)) {
-			Buf_AddByte(buf, vpstate->varSpace);
-			addSpace = FALSE;
-		}
-		Buf_AddBytes(buf, cp - word, word);
-		Buf_AddBytes(buf, pattern->rightLen, pattern->rhs);
-		wordLen -= (cp - word) + pattern->leftLen;
-		word = cp + pattern->leftLen;
-		if (wordLen == 0) {
-			done = TRUE;
-		}
-		if ((pattern->pflags & VARP_SUB_GLOBAL) == 0) {
-			done = TRUE;
-		}
-		pattern->pflags |= VARP_SUB_MATCHED;
-		} else {
-		done = TRUE;
+	int origSize = Buf_Size(buf);
+	while ((cp = Str_FindSubstring(word, pattern->lhs)) != NULL) {
+		if (addSpace && (((cp - word) + pattern->rightLen) != 0)) {
+		Buf_AddByte(buf, vpstate->varSpace);
+		addSpace = FALSE;
 		}
+		Buf_AddBytes(buf, cp - word, word);
+		Buf_AddBytes(buf, pattern->rightLen, pattern->rhs);
+		wordLen -= (cp - word) + pattern->leftLen;
+		word = cp + pattern->leftLen;
+		if (wordLen == 0)
+		break;
+		if ((pattern->pflags & VARP_SUB_GLOBAL) == 0)
+		break;
+		pattern->pflags |= VARP_SUB_MATCHED;
 	}
 	if (wordLen != 0) {
 		if (addSpace && vpstate->varSpace != '\0') {



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 17:40:30 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): rename ApplyModifiersState.flags to eflags

There are just too many variables called "flags" in this file, and their
constants must not accidentally overlap.


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.267 src/usr.bin/make/var.c:1.268
--- src/usr.bin/make/var.c:1.267	Sun Jul 19 16:48:48 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 17:40:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.267 2020/07/19 16:48:48 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.268 2020/07/19 17:40:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.267 2020/07/19 16:48:48 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.268 2020/07/19 17:40:30 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.267 2020/07/19 16:48:48 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.268 2020/07/19 17:40:30 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2274,7 +2274,7 @@ typedef struct {
 int endc;
 Var *v;
 GNode *ctxt;
-int flags;
+VarEvalFlags eflags;
 int *lengthPtr;
 void **freePtr;
 
@@ -2310,19 +2310,19 @@ ApplyModifier_At(ApplyModifiersState *st
 st->cp = ++st->tstr;
 st->delim = '@';
 loop.tvar = ParseModifierPart(
-	st->ctxt, >cp, st->delim, st->flags, , NULL, NULL);
+	st->ctxt, >cp, st->delim, st->eflags, , NULL, NULL);
 if (loop.tvar == NULL)
 	return FALSE;
 
 loop.str = ParseModifierPart(
-	st->ctxt, >cp, st->delim, st->flags, , NULL, NULL);
+	st->ctxt, >cp, st->delim, st->eflags, , NULL, NULL);
 if (loop.str == NULL)
 	return FALSE;
 
 st->termc = *st->cp;
 st->delim = '\0';
 
-loop.eflags = st->flags & (VARE_UNDEFERR | VARE_WANTRES);
+loop.eflags = st->eflags & (VARE_UNDEFERR | VARE_WANTRES);
 st->newStr = VarModify(
 	st->ctxt, >parsestate, st->nstr, VarLoopExpand, );
 Var_Delete(loop.tvar, st->ctxt);
@@ -2336,19 +2336,19 @@ static void
 ApplyModifier_Defined(ApplyModifiersState *st)
 {
 Buffer buf;			/* Buffer for patterns */
-int nflags;
+VarEvalFlags neflags;
 
-if (st->flags & VARE_WANTRES) {
-	int wantres;
+if (st->eflags & VARE_WANTRES) {
+	Boolean wantres;
 	if (*st->tstr == 'U')
 	wantres = ((st->v->flags & VAR_JUNK) != 0);
 	else
 	wantres = ((st->v->flags & VAR_JUNK) == 0);
-	nflags = st->flags & ~VARE_WANTRES;
+	neflags = st->eflags & ~VARE_WANTRES;
 	if (wantres)
-	nflags |= VARE_WANTRES;
+	neflags |= VARE_WANTRES;
 } else
-	nflags = st->flags;
+	neflags = st->eflags;
 
 /*
  * Pass through tstr looking for 1) escaped delimiters,
@@ -2375,7 +2375,7 @@ ApplyModifier_Defined(ApplyModifiersStat
 	int	len;
 	void*freeIt;
 
-	cp2 = Var_Parse(st->cp, st->ctxt, nflags, , );
+	cp2 = Var_Parse(st->cp, st->ctxt, neflags, , );
 	Buf_AddBytes(, strlen(cp2), cp2);
 	free(freeIt);
 	st->cp += len - 1;
@@ -2388,7 +2388,7 @@ ApplyModifier_Defined(ApplyModifiersStat
 
 if (st->v->flags & VAR_JUNK)
 	st->v->flags |= VAR_KEEP;
-if (nflags & VARE_WANTRES) {
+if (neflags & VARE_WANTRES) {
 	st->newStr = Buf_Destroy(, FALSE);
 } else {
 	st->newStr = st->nstr;
@@ -2489,11 +2489,11 @@ ApplyModifier_Exclam(ApplyModifiersState
 emsg = NULL;
 st->cp = ++st->tstr;
 pattern.rhs = ParseModifierPart(
-	st->ctxt, >cp, st->delim, st->flags,
+	st->ctxt, >cp, st->delim, st->eflags,
 	NULL, , NULL);
 if (pattern.rhs == NULL)
 	return FALSE;
-if (st->flags & VARE_WANTRES)
+if (st->eflags & VARE_WANTRES)
 	st->newStr = Cmd_Exec(pattern.rhs, );
 else
 	st->newStr = varNoError;
@@ -2602,19 +2602,15 @@ ApplyModifier_Match(ApplyModifiersState 
 if (needSubst) {
 	/* pattern contains embedded '$', so use Var_Subst to expand it. */
 	cp2 = pattern;
-	pattern = Var_Subst(NULL, cp2, st->ctxt, st->flags);
+	pattern = Var_Subst(NULL, cp2, st->ctxt, st->eflags);
 	free(cp2);
 }
 if (DEBUG(VAR))
 	fprintf(debug_file, "Pattern[%s] for [%s] is [%s]\n",
 	st->v->name, st->nstr, pattern);
-if (*st->tstr == 'M') {
-	st->newStr = VarModify(st->ctxt, >parsestate, st->nstr, VarMatch,
-			   pattern);
-} else {
-	st->newStr = VarModify(st->ctxt, >parsestate, st->nstr, VarNoMatch,
-			   pattern);
-}
+VarModifyCallback callback = st->tstr[0] == 'M' ? VarMatch : VarNoMatch;
+st->newStr = VarModify(st->ctxt, >parsestate, st->nstr, callback,
+			   pattern);
 free(pattern);
 }
 
@@ -2641,13 +2637,13 @@ 

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

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 17:24:22 UTC 2020

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

Log Message:
make(1): demonstrate off-by-one bug in :C modifier


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/modmisc.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/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.15 src/usr.bin/make/unit-tests/modmisc.exp:1.16
--- src/usr.bin/make/unit-tests/modmisc.exp:1.15	Sun Jul 19 15:16:22 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp	Sun Jul 19 17:24:22 2020
@@ -51,4 +51,14 @@ mod-loop-dollar:$3$:
 mod-loop-dollar:$${word}$:
 mod-loop-dollar:$$5$$:
 mod-loop-dollar:$$${word}$$:
+mod-C-limits:00-ok:1 2323 45456
+mod-C-limits:11-missing:1 6
+mod-C-limits:11-ok:1 22 446
+make: No subexpression \2
+make: No subexpression \2
+make: No subexpression \2
+make: No subexpression \2
+mod-C-limits:22-missing:1 6
+mod-C-limits:22-missing:1 6
+mod-C-limits:22-ok:1 33 556
 exit status 0

Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.13 src/usr.bin/make/unit-tests/modmisc.mk:1.14
--- src/usr.bin/make/unit-tests/modmisc.mk:1.13	Sun Jul 19 15:16:22 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk	Sun Jul 19 17:24:22 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.13 2020/07/19 15:16:22 rillig Exp $
+# $Id: modmisc.mk,v 1.14 2020/07/19 17:24:22 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -18,6 +18,7 @@ MOD_SEP=S,:, ,g
 all:	modvar modvarloop modsysv mod-HTE emptyvar undefvar
 all:	mod-S mod-C mod-at-varname mod-at-resolve mod-at-dollar
 all:	mod-subst-dollar mod-loop-dollar
+all:	mod-C-limits
 
 modsysv:
 	@echo "The answer is ${libfoo.a:L:libfoo.a=42}"
@@ -133,3 +134,11 @@ mod-loop-dollar:
 	@echo $@:${:U4:@word@{word}@:Q}:
 	@echo $@:${:U5:@word@${word}$@:Q}:
 	@echo $@:${:U6:@word@$${word}$$@:Q}:
+
+mod-C-limits:
+	@echo $@:00-ok:${:U1 23 456:C,..,\0\0,:Q}
+	@echo $@:11-missing:${:U1 23 456:C,..,\1\1,:Q}
+	@echo $@:11-ok:${:U1 23 456:C,(.).,\1\1,:Q}
+	@echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q}
+	@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}
+	@echo $@:22-ok:${:U1 23 456:C,(.)(.),\2\2,:Q}



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 16:48:48 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): clean up VarLoop structure


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.266 src/usr.bin/make/var.c:1.267
--- src/usr.bin/make/var.c:1.266	Sun Jul 19 16:22:44 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 16:48:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.266 2020/07/19 16:22:44 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.267 2020/07/19 16:48:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.266 2020/07/19 16:22:44 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.267 2020/07/19 16:48:48 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.266 2020/07/19 16:22:44 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.267 2020/07/19 16:48:48 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -278,12 +278,9 @@ typedef struct {
 
 /* struct passed as 'void *' to VarLoopExpand() for ":@tvar@str@" */
 typedef struct {
-GNode	*ctxt;		/* variable context */
-char	*tvar;		/* name of temp var */
-int		tvarLen;
+char	*tvar;		/* name of temporary variable */
 char	*str;		/* string to expand */
-int		strLen;
-VarEvalFlags flags;
+VarEvalFlags eflags;
 } VarLoop;
 
 #ifndef NO_REGEX
@@ -1647,22 +1644,16 @@ VarRESubstitute(GNode *ctx MAKE_ATTR_UNU
 #endif
 
 
-/* Callback function for VarModify to implement the :@var@...@ modifier of
- * ODE make. We set the temp variable named in pattern.lhs to word and
- * expand pattern.rhs. */
+/* Callback for VarModify to implement the :@var@...@ modifier of ODE make. */
 static Boolean
-VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSED,
-	  Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
-	  const char *word, Boolean addSpace, Buffer *buf,
-	  void *data)
+VarLoopExpand(GNode *ctx, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
+	  const char *word, Boolean addSpace, Buffer *buf, void *data)
 {
 VarLoop *loop = data;
-char *s;
-int slen;
 
 if (*word) {
-	Var_Set_with_flags(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT);
-	s = Var_Subst(NULL, loop->str, loop->ctxt, loop->flags);
+	Var_Set_with_flags(loop->tvar, word, ctx, VAR_NO_EXPORT);
+	char *s = Var_Subst(NULL, loop->str, ctx, loop->eflags);
 	if (DEBUG(VAR)) {
 	fprintf(debug_file,
 		"VarLoopExpand: in \"%s\", replace \"%s\" with \"%s\" "
@@ -1672,7 +1663,8 @@ VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSE
 	if (s != NULL && *s != '\0') {
 	if (addSpace && *s != '\n')
 		Buf_AddByte(buf, ' ');
-	Buf_AddBytes(buf, (slen = strlen(s)), s);
+	size_t slen = strlen(s);
+	Buf_AddBytes(buf, slen, s);
 	addSpace = (slen > 0 && s[slen - 1] != '\n');
 	}
 	free(s);
@@ -2278,7 +2270,7 @@ VarStrftime(const char *fmt, int zulu, t
 
 typedef struct {
 /* const parameters */
-int startc;
+int startc;			/* '\0' or '{' or '(' */
 int endc;
 Var *v;
 GNode *ctxt;
@@ -2318,22 +2310,19 @@ ApplyModifier_At(ApplyModifiersState *st
 st->cp = ++st->tstr;
 st->delim = '@';
 loop.tvar = ParseModifierPart(
-	st->ctxt, >cp, st->delim, st->flags,
-	, , NULL);
+	st->ctxt, >cp, st->delim, st->flags, , NULL, NULL);
 if (loop.tvar == NULL)
 	return FALSE;
 
 loop.str = ParseModifierPart(
-	st->ctxt, >cp, st->delim, st->flags,
-	, , NULL);
+	st->ctxt, >cp, st->delim, st->flags, , NULL, NULL);
 if (loop.str == NULL)
 	return FALSE;
 
 st->termc = *st->cp;
 st->delim = '\0';
 
-loop.flags = st->flags & (VARE_UNDEFERR | VARE_WANTRES);
-loop.ctxt = st->ctxt;
+loop.eflags = st->flags & (VARE_UNDEFERR | VARE_WANTRES);
 st->newStr = VarModify(
 	st->ctxt, >parsestate, st->nstr, VarLoopExpand, );
 Var_Delete(loop.tvar, st->ctxt);
@@ -3049,8 +3038,7 @@ ApplyModifier_IfElse(ApplyModifiersState
 if (then_expr == NULL)
 	return FALSE;
 
-/* BROPEN or PROPEN */
-st->delim = st->endc;
+st->delim = st->endc;	/* BRCLOSE or PRCLOSE */
 char *else_expr = ParseModifierPart(
 	st->ctxt, >cp, st->delim, st->flags, _flags, NULL, NULL);
 if (else_expr == NULL)



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 16:22:44 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): remove unused parameter from ParseModifierPart


To generate a diff of this commit:
cvs rdiff -u -r1.265 -r1.266 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.265 src/usr.bin/make/var.c:1.266
--- src/usr.bin/make/var.c:1.265	Sun Jul 19 16:08:24 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 16:22:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.265 2020/07/19 16:08:24 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.266 2020/07/19 16:22:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.265 2020/07/19 16:08:24 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.266 2020/07/19 16:22:44 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.265 2020/07/19 16:08:24 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.266 2020/07/19 16:22:44 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2039,9 +2039,9 @@ VarRange(const char *str, int ac)
  * set the VARP_MATCH_END bit of mpflags.
  */
 static char *
-ParseModifierPart(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
-	  VarEvalFlags eflags, const char **tstr, int delim,
-	  VarPatternFlags *mpflags, int *length, VarPattern *pattern)
+ParseModifierPart(GNode *ctxt, const char **tstr, int delim,
+		  VarEvalFlags eflags, VarPatternFlags *mpflags,
+		  int *length, VarPattern *pattern)
 {
 const char *cp;
 char *rstr;
@@ -2318,13 +2318,13 @@ ApplyModifier_At(ApplyModifiersState *st
 st->cp = ++st->tstr;
 st->delim = '@';
 loop.tvar = ParseModifierPart(
-	st->ctxt, >parsestate, st->flags, >cp, st->delim,
+	st->ctxt, >cp, st->delim, st->flags,
 	, , NULL);
 if (loop.tvar == NULL)
 	return FALSE;
 
 loop.str = ParseModifierPart(
-	st->ctxt, >parsestate, st->flags, >cp, st->delim,
+	st->ctxt, >cp, st->delim, st->flags,
 	, , NULL);
 if (loop.str == NULL)
 	return FALSE;
@@ -2500,7 +2500,7 @@ ApplyModifier_Exclam(ApplyModifiersState
 emsg = NULL;
 st->cp = ++st->tstr;
 pattern.rhs = ParseModifierPart(
-	st->ctxt, >parsestate, st->flags, >cp, st->delim,
+	st->ctxt, >cp, st->delim, st->flags,
 	NULL, , NULL);
 if (pattern.rhs == NULL)
 	return FALSE;
@@ -2652,13 +2652,13 @@ ApplyModifier_Subst(ApplyModifiersState 
 
 st->cp = st->tstr;
 pattern.lhs = ParseModifierPart(
-	st->ctxt, >parsestate, st->flags, >cp, st->delim,
+	st->ctxt, >cp, st->delim, st->flags,
 	, , NULL);
 if (pattern.lhs == NULL)
 	return FALSE;
 
 pattern.rhs = ParseModifierPart(
-	st->ctxt, >parsestate, st->flags, >cp, st->delim,
+	st->ctxt, >cp, st->delim, st->flags,
 	NULL, , );
 if (pattern.rhs == NULL)
 	return FALSE;
@@ -2711,15 +2711,13 @@ ApplyModifier_Regex(ApplyModifiersState 
 
 st->cp = st->tstr;
 
-re = ParseModifierPart(
-	st->ctxt, >parsestate, st->flags, >cp, st->delim,
-	NULL, NULL, NULL);
+re = ParseModifierPart(st->ctxt, >cp, st->delim, st->flags,
+			   NULL, NULL, NULL);
 if (re == NULL)
 	return FALSE;
 
-pattern.replace = ParseModifierPart(
-	st->ctxt, >parsestate, st->flags, >cp, st->delim,
-	NULL, NULL, NULL);
+pattern.replace = ParseModifierPart(st->ctxt, >cp, st->delim,
+	st->flags, NULL, NULL, NULL);
 if (pattern.replace == NULL) {
 	free(re);
 	return FALSE;
@@ -2882,20 +2880,10 @@ ApplyModifier_To(ApplyModifiersState *st
 static int
 ApplyModifier_Words(ApplyModifiersState *st)
 {
-/*
- * Look for the closing ']', recursively
- * expanding any embedded variables.
- *
- * estr is a pointer to the expanded result,
- * which we must free().
- */
-char *estr;
-
 st->cp = st->tstr + 1;	/* point to char after '[' */
 st->delim = ']';		/* look for closing ']' */
-estr = ParseModifierPart(
-	st->ctxt, >parsestate, st->flags, >cp, st->delim,
-	NULL, NULL, NULL);
+char *estr = ParseModifierPart(st->ctxt, >cp, st->delim, st->flags,
+   NULL, NULL, NULL);
 if (estr == NULL)
 	return 'c';		/* report missing ']' */
 /* now st->cp points just after the closing ']' */
@@ -3057,16 +3045,14 @@ ApplyModifier_IfElse(ApplyModifiersState
 st->cp = ++st->tstr;
 st->delim = ':';
 char *then_expr = ParseModifierPart(
-	st->ctxt, >parsestate, st->flags, >cp, st->delim,
-	_flags, NULL, NULL);
+	st->ctxt, >cp, st->delim, st->flags, _flags, NULL, NULL);
 if (then_expr == NULL)
 	return FALSE;
 
 /* BROPEN or PROPEN */
 st->delim = st->endc;
 char *else_expr = ParseModifierPart(
-	st->ctxt, >parsestate, st->flags, >cp, st->delim,
-	_flags, NULL, NULL);
+	st->ctxt, >cp, st->delim, 

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

2020-07-19 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Jul 19 16:20:36 UTC 2020

Modified Files:
src/sys/arch/xen/x86: pintr.c

Log Message:
add #ifdef __HAVE_PCI_MSI_MSIX so this still compiles with NO_PCI_MSI_MSIX


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/xen/x86/pintr.c

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

Modified files:

Index: src/sys/arch/xen/x86/pintr.c
diff -u src/sys/arch/xen/x86/pintr.c:1.18 src/sys/arch/xen/x86/pintr.c:1.19
--- src/sys/arch/xen/x86/pintr.c:1.18	Sun Jul 19 14:27:07 2020
+++ src/sys/arch/xen/x86/pintr.c	Sun Jul 19 16:20:36 2020
@@ -103,7 +103,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.18 2020/07/19 14:27:07 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.19 2020/07/19 16:20:36 jdolecek Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -164,6 +164,7 @@ short irq2port[NR_EVENT_CHANNELS] = {0};
 
 #if defined(DOM0OPS) || NPCI > 0
 
+#ifdef __HAVE_PCI_MSI_MSIX
 static int
 xen_map_msi_pirq(struct pic *pic, int count, int *gsi)
 {
@@ -223,6 +224,7 @@ xen_pci_msi_probe(struct pic *pic, int c
 
 	return ret;
 }
+#endif /* __HAVE_PCI_MSI_MSIX */
 
 /*
  * This function doesn't "allocate" anything. It merely translates our



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

2020-07-19 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Jul 19 16:17:00 UTC 2020

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

Log Message:
add definition for MSR_IA32_FEATURE_CONTROL, just for information


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/sys/arch/x86/include/specialreg.h

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

Modified files:

Index: src/sys/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.168 src/sys/arch/x86/include/specialreg.h:1.169
--- src/sys/arch/x86/include/specialreg.h:1.168	Thu Jun 18 16:27:24 2020
+++ src/sys/arch/x86/include/specialreg.h	Sun Jul 19 16:17:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.168 2020/06/18 16:27:24 maxv Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.169 2020/07/19 16:17:00 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2014-2020 The NetBSD Foundation, Inc.
@@ -865,6 +865,9 @@
 #define 	APICBASE_PHYSADDR	0xf000	/* physical address */
 #define MSR_EBL_CR_POWERON	0x02a
 #define MSR_EBC_FREQUENCY_ID	0x02c	/* PIV only */
+#define MSR_IA32_FEATURE_CONTROL	0x03a
+#define 	IA32_FEATURE_CONTROL_ENABLE_VMXON_INSIDE_SMX	0x0002
+#define 	IA32_FEATURE_CONTROL_ENABLE_VMXON_OUTSIDE_SMX	0x0004
 #define MSR_IA32_SPEC_CTRL	0x048
 #define 	IA32_SPEC_CTRL_IBRS	0x01
 #define 	IA32_SPEC_CTRL_STIBP	0x02



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 16:08:24 UTC 2020

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-edge.mk

Log Message:
make(1): rename VarGetPattern to ParseModifierPart


To generate a diff of this commit:
cvs rdiff -u -r1.264 -r1.265 src/usr.bin/make/var.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-edge.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/var.c
diff -u src/usr.bin/make/var.c:1.264 src/usr.bin/make/var.c:1.265
--- src/usr.bin/make/var.c:1.264	Sun Jul 19 15:51:51 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 16:08:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.264 2020/07/19 15:51:51 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.265 2020/07/19 16:08:24 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.264 2020/07/19 15:51:51 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.265 2020/07/19 16:08:24 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.264 2020/07/19 15:51:51 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.265 2020/07/19 16:08:24 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -243,9 +243,9 @@ typedef enum {
 VARP_MATCH_START	= 0x08,	/* Match at start of word */
 VARP_MATCH_END	= 0x10,	/* Match at end of word */
 
-/* FIXME: This constant doesn't belong here. It is not related to
- * pattern matching, and VarGetPattern is badly named as well. */
-VAR_NOSUBST	= 0x20		/* don't expand vars in VarGetPattern */
+/* FIXME: This constant doesn't belong here.
+ * It is not related to pattern matching. */
+VAR_NOSUBST	= 0x20		/* don't expand vars in ParseModifierPart */
 } VarPatternFlags;
 
 typedef enum {
@@ -2023,30 +2023,23 @@ VarRange(const char *str, int ac)
 
 
 /*-
- *---
- * VarGetPattern --
- *	During the parsing of a part of a modifier such as :S or :@,
- *	pass through the tstr looking for 1) escaped delimiters,
- *	'$'s and backslashes (place the escaped character in
- *	uninterpreted) and 2) unescaped $'s that aren't before
- *	the delimiter (expand the variable substitution unless flags
- *	has VAR_NOSUBST set).
- *	Return the expanded string or NULL if the delimiter was missing
- *	If pattern is specified, handle escaped ampersands, and replace
- *	unescaped ampersands with the lhs of the pattern.
- *
- * Results:
- *	A string of all the words modified appropriately.
- *	If length is specified, return the string length of the buffer
- *	If flags is specified and the last character of the pattern is a
- *	$ set the VAR_MATCH_END bit of flags.
- *
- * Side Effects:
- *	None.
- *---
+ * Parse a text part of a modifier such as the "from" and "to" in :S/from/to/
+ * or the :@ modifier. Nested variables in the text are expanded unless
+ * VAR_NOSUBST is set.
+ *
+ * The text part is parsed until the next delimiter.  To escape the delimiter,
+ * a backslash or a dollar, put a backslash before it.
+ *
+ * Return the expanded string or NULL if the delimiter was missing.
+ * If pattern is specified, handle escaped ampersands and replace unescaped
+ * ampersands with the lhs of the pattern (for the :S and :C modifiers).
+ *
+ * If length is specified, return the string length of the buffer.
+ * If mpflags is specified and the last character of the pattern is a $,
+ * set the VARP_MATCH_END bit of mpflags.
  */
 static char *
-VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
+ParseModifierPart(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
 	  VarEvalFlags eflags, const char **tstr, int delim,
 	  VarPatternFlags *mpflags, int *length, VarPattern *pattern)
 {
@@ -2324,13 +2317,13 @@ ApplyModifier_At(ApplyModifiersState *st
 
 st->cp = ++st->tstr;
 st->delim = '@';
-loop.tvar = VarGetPattern(
+loop.tvar = ParseModifierPart(
 	st->ctxt, >parsestate, st->flags, >cp, st->delim,
 	, , NULL);
 if (loop.tvar == NULL)
 	return FALSE;
 
-loop.str = VarGetPattern(
+loop.str = ParseModifierPart(
 	st->ctxt, >parsestate, st->flags, >cp, st->delim,
 	, , NULL);
 if (loop.str == NULL)
@@ -2506,7 +2499,7 @@ ApplyModifier_Exclam(ApplyModifiersState
 st->delim = '!';
 emsg = NULL;
 st->cp = ++st->tstr;
-pattern.rhs = VarGetPattern(
+pattern.rhs = ParseModifierPart(
 	st->ctxt, >parsestate, st->flags, >cp, st->delim,
 	NULL, , NULL);
 if (pattern.rhs == NULL)
@@ -2658,13 +2651,13 @@ ApplyModifier_Subst(ApplyModifiersState 
 }
 
 st->cp = st->tstr;
-pattern.lhs = VarGetPattern(
+pattern.lhs = ParseModifierPart(
 	st->ctxt, 

CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 15:51:51 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): eliminate unused local variables


To generate a diff of this commit:
cvs rdiff -u -r1.263 -r1.264 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.263 src/usr.bin/make/var.c:1.264
--- src/usr.bin/make/var.c:1.263	Sun Jul 19 15:47:10 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 15:51:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.263 2020/07/19 15:47:10 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.264 2020/07/19 15:51:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.263 2020/07/19 15:47:10 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.264 2020/07/19 15:51:51 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.263 2020/07/19 15:47:10 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.264 2020/07/19 15:51:51 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3063,19 +3063,17 @@ ApplyModifier_IfElse(ApplyModifiersState
 
 st->cp = ++st->tstr;
 st->delim = ':';
-int then_len;
 char *then_expr = VarGetPattern(
 	st->ctxt, >parsestate, st->flags, >cp, st->delim,
-	_flags, _len, NULL);
+	_flags, NULL, NULL);
 if (then_expr == NULL)
 	return FALSE;
 
 /* BROPEN or PROPEN */
 st->delim = st->endc;
-int else_len;
 char *else_expr = VarGetPattern(
 	st->ctxt, >parsestate, st->flags, >cp, st->delim,
-	_flags, _len, NULL);
+	_flags, NULL, NULL);
 if (else_expr == NULL)
 	return FALSE;
 



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 15:47:10 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): eliminate macro from VarGetPattern


To generate a diff of this commit:
cvs rdiff -u -r1.262 -r1.263 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.262 src/usr.bin/make/var.c:1.263
--- src/usr.bin/make/var.c:1.262	Sun Jul 19 14:05:39 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 15:47:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.262 2020/07/19 14:05:39 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.263 2020/07/19 15:47:10 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.262 2020/07/19 14:05:39 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.263 2020/07/19 15:47:10 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.262 2020/07/19 14:05:39 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.263 2020/07/19 15:47:10 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2060,10 +2060,6 @@ VarGetPattern(GNode *ctxt, Var_Parse_Sta
 if (length == NULL)
 	length = 
 
-#define IS_A_MATCH(cp, delim) \
-((cp[0] == '\\') && ((cp[1] == delim) ||  \
- (cp[1] == '\\') || (cp[1] == '$') || (pattern && (cp[1] == '&'
-
 /*
  * Skim through until the matching delimiter is found;
  * pick up variable substitutions on the way. Also allow
@@ -2071,7 +2067,9 @@ VarGetPattern(GNode *ctxt, Var_Parse_Sta
  * touch other backslashes.
  */
 for (cp = *tstr; *cp && (*cp != delim); cp++) {
-	if (IS_A_MATCH(cp, delim)) {
+	Boolean is_escaped = cp[0] == '\\' && (cp[1] == delim ||
+	cp[1] == '\\' || cp[1] == '$' || (pattern && cp[1] == '&'));
+	if (is_escaped) {
 	Buf_AddByte(, cp[1]);
 	cp++;
 	} else if (*cp == '$') {



CVS commit: src/usr.bin/make

2020-07-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jul 19 15:42:25 UTC 2020

Modified Files:
src/usr.bin/make: hash.c

Log Message:
Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/hash.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.bin/make/hash.c
diff -u src/usr.bin/make/hash.c:1.23 src/usr.bin/make/hash.c:1.24
--- src/usr.bin/make/hash.c:1.23	Sat Jul 18 21:37:38 2020
+++ src/usr.bin/make/hash.c	Sun Jul 19 15:42:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.23 2020/07/18 21:37:38 sjg Exp $	*/
+/*	$NetBSD: hash.c,v 1.24 2020/07/19 15:42:25 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: hash.c,v 1.23 2020/07/18 21:37:38 sjg Exp $";
+static char rcsid[] = "$NetBSD: hash.c,v 1.24 2020/07/19 15:42:25 riastradh Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)hash.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: hash.c,v 1.23 2020/07/18 21:37:38 sjg Exp $");
+__RCSID("$NetBSD: hash.c,v 1.24 2020/07/19 15:42:25 riastradh Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -242,7 +242,7 @@ Hash_FindEntry(Hash_Table *t, const char
 	chainlen = 0;
 	for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) {
 		chainlen++;
-		if (e->namehash == h && strcmp(e->name, p) == 0) 
+		if (e->namehash == h && strcmp(e->name, p) == 0)
 			break;
 	}
 	if (chainlen > t->maxlen)



CVS commit: src/crypto/external/bsd/openssl/dist/crypto

2020-07-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jul 19 15:33:08 UTC 2020

Modified Files:
src/crypto/external/bsd/openssl/dist/crypto: ppccap.c

Log Message:
Expand on importance of not using fpu for crypto if there's no fpu.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 \
src/crypto/external/bsd/openssl/dist/crypto/ppccap.c

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

Modified files:

Index: src/crypto/external/bsd/openssl/dist/crypto/ppccap.c
diff -u src/crypto/external/bsd/openssl/dist/crypto/ppccap.c:1.17 src/crypto/external/bsd/openssl/dist/crypto/ppccap.c:1.18
--- src/crypto/external/bsd/openssl/dist/crypto/ppccap.c:1.17	Wed Jul 15 08:14:41 2020
+++ src/crypto/external/bsd/openssl/dist/crypto/ppccap.c	Sun Jul 19 15:33:08 2020
@@ -374,8 +374,11 @@ void OPENSSL_cpuid_setup(void)
 size_t len = sizeof(val);
 
 /*
- * If machdep.fpu_present == 0, FPU is absent and emulated by software.
- * Avoid using it for better performance.
+ * If machdep.fpu_present == 0, FPU is absent and emulated by
+ * software.  In that case, using FPU instructions hurts rather
+ * than helps performance, and the software is unlikely to run in
+ * constant time so it would expose us to timing side channel
+ * attacks.  So don't do it!
  */
 error = sysctlbyname("machdep.fpu_present", , , NULL, 0);
 if (error != 0 || (error == 0 && val != 0))



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

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 15:16:22 UTC 2020

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

Log Message:
make(1): add test for stray dollar signs in :@ modifier


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/modmisc.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/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.14 src/usr.bin/make/unit-tests/modmisc.exp:1.15
--- src/usr.bin/make/unit-tests/modmisc.exp:1.14	Sat Jul  4 22:17:09 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp	Sun Jul 19 15:16:22 2020
@@ -32,6 +32,9 @@ make: Unclosed substitution for  (, miss
 :x__ 3 x__ 3:
 :+one+ +two+ +three+:
 mod-at-resolve:w1d2d3w w2i3w w1i2d3 2i${RES3}w w1d2d3 2i${RES3} 1i${RES2}w:
+mod-at-dollar:(1) (2) (3).
+mod-at-dollar:(1) (2) (3).
+mod-at-dollar:() () ().
 mod-subst-dollar:$1:
 mod-subst-dollar:$2:
 mod-subst-dollar:$3:

Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.12 src/usr.bin/make/unit-tests/modmisc.mk:1.13
--- src/usr.bin/make/unit-tests/modmisc.mk:1.12	Sat Jul  4 18:54:18 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk	Sun Jul 19 15:16:22 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.12 2020/07/04 18:54:18 rillig Exp $
+# $Id: modmisc.mk,v 1.13 2020/07/19 15:16:22 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -16,7 +16,7 @@ MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/u
 MOD_SEP=S,:, ,g
 
 all:	modvar modvarloop modsysv mod-HTE emptyvar undefvar
-all:	mod-S mod-C mod-at-varname mod-at-resolve
+all:	mod-S mod-C mod-at-varname mod-at-resolve mod-at-dollar
 all:	mod-subst-dollar mod-loop-dollar
 
 modsysv:
@@ -95,6 +95,14 @@ RES3=		3
 mod-at-resolve:
 	@echo $@:${RESOLVE:@v@w${v}w@:Q}:
 
+# As of 2020-07-19, the variable name of the :@ modifier may end with one
+# or two dollar signs, which are silently ignored.  There's no point in
+# allowing a dollar sign in that position.
+mod-at-dollar:
+	@echo $@:${1 2 3:L:@v$@($v)@:Q}.
+	@echo $@:${1 2 3:L:@v$$@($v)@:Q}.
+	@echo $@:${1 2 3:L:@v$$$@($v)@:Q}.
+
 # No matter how many dollar characters there are, they all get merged
 # into a single dollar by the :S modifier.
 mod-subst-dollar:



CVS commit: src/sbin/brconfig

2020-07-19 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Jul 19 14:43:35 UTC 2020

Modified Files:
src/sbin/brconfig: brconfig.8

Log Message:
Remove unused Pp. Sort SEE ALSO.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/brconfig/brconfig.8

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

Modified files:

Index: src/sbin/brconfig/brconfig.8
diff -u src/sbin/brconfig/brconfig.8:1.19 src/sbin/brconfig/brconfig.8:1.20
--- src/sbin/brconfig/brconfig.8:1.19	Sun Jul 19 14:39:42 2020
+++ src/sbin/brconfig/brconfig.8	Sun Jul 19 14:43:35 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: brconfig.8,v 1.19 2020/07/19 14:39:42 maxv Exp $
+.\"	$NetBSD: brconfig.8,v 1.20 2020/07/19 14:43:35 wiz Exp $
 .\"
 .\" Copyright 2001 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -84,7 +84,6 @@ All other operations require that a brid
 If a bridge is specified with no sub-commands,
 the status of that bridge is displayed.
 The following sub-commands are available:
-.Pp
 .Bl -tag -width indent
 .It Cm up
 Start forwarding packets on the bridge.
@@ -256,8 +255,8 @@ create
 .Xr bridge 4 ,
 .Xr pf 4 ,
 .Xr ifconfig.if 5 ,
-.Xr ifconfig 8 ,
 .Xr npf 7 ,
+.Xr ifconfig 8 ,
 .Xr pfil 9
 .Sh HISTORY
 The



CVS commit: src/sbin/brconfig

2020-07-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jul 19 14:39:42 UTC 2020

Modified Files:
src/sbin/brconfig: brconfig.8

Log Message:
sync with reality


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/brconfig/brconfig.8

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

Modified files:

Index: src/sbin/brconfig/brconfig.8
diff -u src/sbin/brconfig/brconfig.8:1.18 src/sbin/brconfig/brconfig.8:1.19
--- src/sbin/brconfig/brconfig.8:1.18	Mon Jan  5 00:36:23 2015
+++ src/sbin/brconfig/brconfig.8	Sun Jul 19 14:39:42 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: brconfig.8,v 1.18 2015/01/05 00:36:23 msaitoh Exp $
+.\"	$NetBSD: brconfig.8,v 1.19 2020/07/19 14:39:42 maxv Exp $
 .\"
 .\" Copyright 2001 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -33,7 +33,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 5, 2015
+.Dd July 19, 2020
 .Dt BRCONFIG 8
 .Os
 .Sh NAME
@@ -152,9 +152,7 @@ The current implementation passes
 all ARP and RARP packets through the bridge
 while filtering IP and IPv6 packets through the configured packet
 filter, such as
-.Xr ipf 4
-or
-.Xr pf 4 .
+.Xr npf 7 .
 Other packet types are blocked.
 .It Cm learn Ar interface
 Mark an interface as a
@@ -259,7 +257,7 @@ create
 .Xr pf 4 ,
 .Xr ifconfig.if 5 ,
 .Xr ifconfig 8 ,
-.Xr ipf 8 ,
+.Xr npf 7 ,
 .Xr pfil 9
 .Sh HISTORY
 The



CVS commit: src

2020-07-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jul 19 14:31:31 UTC 2020

Modified Files:
src/sys/arch/amd64/conf: ALL GENERIC
src/sys/arch/x86/x86: x86_machdep.c
src/tests/lib/libi386: t_user_ldt.c

Log Message:
Compile USER_LDT by default, but, put it behind a privileged sysctl that
defaults to disabled. To enable:

# sysctl -w machdep.user_ldt=1


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.572 -r1.573 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.144 -r1.145 src/sys/arch/x86/x86/x86_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libi386/t_user_ldt.c

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

Modified files:

Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.156 src/sys/arch/amd64/conf/ALL:1.157
--- src/sys/arch/amd64/conf/ALL:1.156	Tue Jul 14 00:45:52 2020
+++ src/sys/arch/amd64/conf/ALL	Sun Jul 19 14:31:31 2020
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.156 2020/07/14 00:45:52 yamaguchi Exp $
+# $NetBSD: ALL,v 1.157 2020/07/19 14:31:31 maxv Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,14 +17,14 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.156 $"
+#ident		"ALL-$Revision: 1.157 $"
 
 maxusers	64		# estimated number of users
 
 makeoptions	USE_SSP=yes
 
 # CPU-related options.
-#options 	USER_LDT	# user-settable LDT; used by WINE
+options 	USER_LDT	# User-settable LDT, used by Wine
 options 	X86EMU		# 386 Real Mode emulator
 #options 	PAE		# PAE mode (36 bits physical addressing)
 makeoptions	SPECTRE_V2_GCC_MITIGATION=1	# GCC Spectre variant 2

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.572 src/sys/arch/amd64/conf/GENERIC:1.573
--- src/sys/arch/amd64/conf/GENERIC:1.572	Tue Jul 14 01:05:06 2020
+++ src/sys/arch/amd64/conf/GENERIC	Sun Jul 19 14:31:31 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.572 2020/07/14 01:05:06 yamaguchi Exp $
+# $NetBSD: GENERIC,v 1.573 2020/07/19 14:31:31 maxv Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.572 $"
+#ident		"GENERIC-$Revision: 1.573 $"
 
 maxusers	64		# estimated number of users
 
@@ -74,7 +74,7 @@ options 	USERCONF	# userconf(4) support
 options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 
 # CPU-related options
-#options 	USER_LDT	# User-settable LDT, used by Wine
+options 	USER_LDT	# User-settable LDT, used by Wine
 options 	SVS		# Separate Virtual Space
 options 	PCPU_IDT	# Per CPU IDTs
 

Index: src/sys/arch/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.144 src/sys/arch/x86/x86/x86_machdep.c:1.145
--- src/sys/arch/x86/x86/x86_machdep.c:1.144	Sat Jul  4 21:02:16 2020
+++ src/sys/arch/x86/x86/x86_machdep.c	Sun Jul 19 14:31:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_machdep.c,v 1.144 2020/07/04 21:02:16 chs Exp $	*/
+/*	$NetBSD: x86_machdep.c,v 1.145 2020/07/19 14:31:31 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.144 2020/07/04 21:02:16 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.145 2020/07/19 14:31:31 maxv Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -95,6 +95,8 @@ void (*x86_cpu_idle)(void);
 static bool x86_cpu_idle_ipi;
 static char x86_cpu_idle_text[16];
 
+static bool x86_user_ldt_enabled __read_mostly = false;
+
 #ifdef XEN
 
 #include 
@@ -1178,9 +1180,14 @@ x86_listener_cb(kauth_cred_t cred, kauth
 
 	switch (action) {
 	case KAUTH_MACHDEP_IOPERM_GET:
+		result = KAUTH_RESULT_ALLOW;
+		break;
+
 	case KAUTH_MACHDEP_LDT_GET:
 	case KAUTH_MACHDEP_LDT_SET:
-		result = KAUTH_RESULT_ALLOW;
+		if (x86_user_ldt_enabled) {
+			result = KAUTH_RESULT_ALLOW;
+		}
 		break;
 
 	default:
@@ -1432,6 +1439,13 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc
 		   CTL_CREATE, CTL_EOL);
 #endif
 
+	sysctl_createv(clog, 0, NULL, NULL,
+		   CTLFLAG_READWRITE,
+		   CTLTYPE_BOOL, "user_ldt",
+		   SYSCTL_DESCR("Whether USER_LDT is enabled"),
+		   NULL, 0, _user_ldt_enabled, 0,
+		   CTL_MACHDEP, CTL_CREATE, CTL_EOL);
+
 #ifndef XENPV
 	void sysctl_speculation_init(struct sysctllog **);
 	sysctl_speculation_init(clog);

Index: src/tests/lib/libi386/t_user_ldt.c
diff -u src/tests/lib/libi386/t_user_ldt.c:1.4 src/tests/lib/libi386/t_user_ldt.c:1.5
--- src/tests/lib/libi386/t_user_ldt.c:1.4	Fri Jul  3 16:07:52 2020
+++ src/tests/lib/libi386/t_user_ldt.c	Sun Jul 19 14:31:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_user_ldt.c,v 1.4 2020/07/03 16:07:52 maxv Exp $	*/
+/*	$NetBSD: t_user_ldt.c,v 1.5 2020/07/19 14:31:31 maxv Exp $	*/
 
 

CVS commit: src/sys/arch

2020-07-19 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Jul 19 14:27:07 UTC 2020

Modified Files:
src/sys/arch/x86/pci: pci_msi_machdep.c
src/sys/arch/xen/include: intr.h
src/sys/arch/xen/x86: pintr.c

Log Message:
for Xen MSI, fallback to INTx when PHYSDEVOP_map_pirq fails for the device

apparently Xen requires VT-d to be enabled in BIOS for PHYSDEVOP_map_pirq
to work, this change makes it work on systems with VT-d disabled or missing

adresses the panic part of PR port-xen/55285 by Patrick Welche


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/pci/pci_msi_machdep.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/xen/include/intr.h
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/xen/x86/pintr.c

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

Modified files:

Index: src/sys/arch/x86/pci/pci_msi_machdep.c
diff -u src/sys/arch/x86/pci/pci_msi_machdep.c:1.13 src/sys/arch/x86/pci/pci_msi_machdep.c:1.14
--- src/sys/arch/x86/pci/pci_msi_machdep.c:1.13	Fri Jul 28 14:26:50 2017
+++ src/sys/arch/x86/pci/pci_msi_machdep.c	Sun Jul 19 14:27:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_msi_machdep.c,v 1.13 2017/07/28 14:26:50 maxv Exp $	*/
+/*	$NetBSD: pci_msi_machdep.c,v 1.14 2020/07/19 14:27:07 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.13 2017/07/28 14:26:50 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.14 2020/07/19 14:27:07 jdolecek Exp $");
 
 #include "opt_intrdebug.h"
 #include "ioapic.h"
@@ -175,6 +175,14 @@ pci_msi_alloc_common(pci_intr_handle_t *
 		return EINVAL;
 	}
 
+#ifdef XENPV
+	if (xen_pci_msi_probe(msi_pic, *count)) {
+		DPRINTF(("xen_pci_msi_probe() failed\n"));
+		msipic_destruct_msi_pic(msi_pic);
+		return EINVAL;
+	}
+#endif
+
 	vectors = NULL;
 	while (*count > 0) {
 		vectors = pci_msi_alloc_vectors(msi_pic, NULL, count);
@@ -262,6 +270,14 @@ pci_msix_alloc_common(pci_intr_handle_t 
 	if (msix_pic == NULL)
 		return EINVAL;
 
+#ifdef XENPV
+	if (xen_pci_msi_probe(msix_pic, *count)) {
+		DPRINTF(("xen_pci_msi_probe() failed\n"));
+		msipic_destruct_msix_pic(msix_pic);
+		return EINVAL;
+	}
+#endif
+
 	vectors = NULL;
 	while (*count > 0) {
 		vectors = pci_msi_alloc_vectors(msix_pic, table_indexes, count);

Index: src/sys/arch/xen/include/intr.h
diff -u src/sys/arch/xen/include/intr.h:1.57 src/sys/arch/xen/include/intr.h:1.58
--- src/sys/arch/xen/include/intr.h:1.57	Fri May 15 07:42:58 2020
+++ src/sys/arch/xen/include/intr.h	Sun Jul 19 14:27:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.57 2020/05/15 07:42:58 jdolecek Exp $	*/
+/*	$NetBSD: intr.h,v 1.58 2020/07/19 14:27:07 jdolecek Exp $	*/
 /*	NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp	*/
 
 /*-
@@ -72,6 +72,7 @@ int xen_intr_biglock_wrapper(void *);
 
 #if defined(DOM0OPS) || NPCI > 0
 int xen_pic_to_gsi(struct pic *, int);
+int xen_pci_msi_probe(struct pic *, int);
 #endif /* defined(DOM0OPS) || NPCI > 0 */
 
 #ifdef MULTIPROCESSOR

Index: src/sys/arch/xen/x86/pintr.c
diff -u src/sys/arch/xen/x86/pintr.c:1.17 src/sys/arch/xen/x86/pintr.c:1.18
--- src/sys/arch/xen/x86/pintr.c:1.17	Sat May 23 14:51:19 2020
+++ src/sys/arch/xen/x86/pintr.c	Sun Jul 19 14:27:07 2020
@@ -103,7 +103,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.17 2020/05/23 14:51:19 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.18 2020/07/19 14:27:07 jdolecek Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -163,6 +163,67 @@ short irq2port[NR_EVENT_CHANNELS] = {0};
 #endif
 
 #if defined(DOM0OPS) || NPCI > 0
+
+static int
+xen_map_msi_pirq(struct pic *pic, int count, int *gsi)
+{
+	struct physdev_map_pirq map_irq;
+	const struct msipic_pci_info *i = msipic_get_pci_info(pic);
+	int ret;
+
+	if (count == -1)
+		count = i->mp_veccnt;
+	KASSERT(count > 0);
+
+	memset(_irq, 0, sizeof(map_irq));
+	map_irq.domid = DOMID_SELF;
+	map_irq.type = MAP_PIRQ_TYPE_MSI_SEG;
+	map_irq.index = -1;
+	map_irq.pirq = -1;
+	map_irq.bus = i->mp_bus;
+ 	map_irq.devfn = (i->mp_dev << 3) | i->mp_fun;
+	map_irq.entry_nr = count;
+	if (pic->pic_type == PIC_MSI && i->mp_veccnt > 1) {
+		map_irq.type = MAP_PIRQ_TYPE_MULTI_MSI;
+	} else if (pic->pic_type == PIC_MSIX) {
+		map_irq.table_base = i->mp_table_base;
+	}
+
+	ret = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, _irq);
+
+	if (ret == 0) {
+		KASSERT(map_irq.entry_nr == count);
+		*gsi = map_irq.pirq;
+	}
+
+	return ret;
+}
+
+/*
+ * Check if we can map MSI interrupt. The Xen call fails if VT-d is not
+ * available or disabled.
+ */
+int
+xen_pci_msi_probe(struct pic *pic, int count)
+{
+	int pirq, ret;
+
+	ret = xen_map_msi_pirq(pic, count, );
+
+	if (ret == 0) {
+		struct physdev_unmap_pirq unmap_irq;
+		unmap_irq.domid = DOMID_SELF;
+		unmap_irq.pirq = pirq;
+		
+		(void)HYPERVISOR_physdev_op(PHYSDEVOP_unmap_pirq, _irq);
+	} else {
+		

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

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 14:23:02 UTC 2020

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

Log Message:
make(1): add test for ampersand in SysV substitution modifier


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/sysv.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/sysv.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/sysv.exp
diff -u src/usr.bin/make/unit-tests/sysv.exp:1.4 src/usr.bin/make/unit-tests/sysv.exp:1.5
--- src/usr.bin/make/unit-tests/sysv.exp:1.4	Fri Jul  3 19:29:25 2020
+++ src/usr.bin/make/unit-tests/sysv.exp	Sun Jul 19 14:23:02 2020
@@ -13,4 +13,6 @@ asam.c
 a.c.c
 
 ax:Q b c d eb
+bcd.e
+a.bcd.e
 exit status 0

Index: src/usr.bin/make/unit-tests/sysv.mk
diff -u src/usr.bin/make/unit-tests/sysv.mk:1.5 src/usr.bin/make/unit-tests/sysv.mk:1.6
--- src/usr.bin/make/unit-tests/sysv.mk:1.5	Fri Jul  3 19:29:25 2020
+++ src/usr.bin/make/unit-tests/sysv.mk	Sun Jul 19 14:23:02 2020
@@ -1,4 +1,6 @@
-# $Id: sysv.mk,v 1.5 2020/07/03 19:29:25 rillig Exp $
+# $Id: sysv.mk,v 1.6 2020/07/19 14:23:02 rillig Exp $
+
+all: foo fun sam bla words ampersand
 
 FOO ?=
 FOOBAR = ${FOO:=bar}
@@ -11,8 +13,6 @@ FUN = ${B}${S}fun
 SUN = the Sun
 
 # we expect nothing when FOO is empty
-all: foo fun sam bla words
-
 foo:
 	@echo FOOBAR = ${FOOBAR}
 .if empty(FOO)
@@ -46,3 +46,11 @@ bla:
 # It is part of the replacement string.
 words:
 	@echo a${a b c d e:L:%a=x:Q}b
+
+# As of 2020-07-19, an ampersand can be used in the replacement part
+# of a SysV substitution modifier.  This can either be an intentional
+# feature or an implementation mistake, as it is not mentioned in the
+# manual page.
+ampersand:
+	@echo ${:U${a.bcd.e:L:a.%=%}:Q}
+	@echo ${:U${a.bcd.e:L:a.%=&}:Q}



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 14:05:39 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): replace ApplyModifiersState field with local variable


To generate a diff of this commit:
cvs rdiff -u -r1.261 -r1.262 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.261 src/usr.bin/make/var.c:1.262
--- src/usr.bin/make/var.c:1.261	Sun Jul 19 13:21:56 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 14:05:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.261 2020/07/19 13:21:56 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.262 2020/07/19 14:05:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.261 2020/07/19 13:21:56 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.262 2020/07/19 14:05:39 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.261 2020/07/19 13:21:56 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.262 2020/07/19 14:05:39 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2302,8 +2302,6 @@ typedef struct {
 const char *cp;		/* Secondary pointer into str (place marker
  * for tstr) */
 char termc;			/* Character which terminated scan */
-int cnt;			/* Used to count brace pairs when variable in
- * in parens or braces */
 char delim;
 int modifier;		/* that we are processing */
 Var_Parse_State parsestate;	/* Flags passed to helper functions */
@@ -3244,16 +3242,16 @@ ApplyModifier_SysV(ApplyModifiersState *
  * it must be: =)
  */
 st->cp = st->tstr;
-st->cnt = 1;
-while (*st->cp != '\0' && st->cnt) {
+int nest = 1;
+while (*st->cp != '\0' && nest > 0) {
 	if (*st->cp == '=') {
 	eqFound = TRUE;
 	/* continue looking for st->endc */
 	} else if (*st->cp == st->endc)
-	st->cnt--;
+	nest--;
 	else if (*st->cp == st->startc)
-	st->cnt++;
-	if (st->cnt)
+	nest++;
+	if (nest > 0)
 	st->cp++;
 }
 if (*st->cp != st->endc || !eqFound)
@@ -3388,7 +3386,7 @@ ApplyModifiers(char *nstr, const char *t
 ApplyModifiersState st = {
 	startc, endc, v, ctxt, flags, lengthPtr, freePtr,
 	nstr, tstr, tstr, tstr,
-	'\0', 0, '\0', 0, {' ', FALSE}, NULL
+	'\0', '\0', 0, {' ', FALSE}, NULL
 };
 
 while (*st.tstr && *st.tstr != st.endc) {



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

2020-07-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jul 19 13:58:27 UTC 2020

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

Log Message:
we're already in an #ifdef USER_LDT block, so no need to #ifdef again


To generate a diff of this commit:
cvs rdiff -u -r1.400 -r1.401 src/sys/arch/x86/x86/pmap.c

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

Modified files:

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.400 src/sys/arch/x86/x86/pmap.c:1.401
--- src/sys/arch/x86/x86/pmap.c:1.400	Tue Jul 14 00:45:53 2020
+++ src/sys/arch/x86/x86/pmap.c	Sun Jul 19 13:58:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.400 2020/07/14 00:45:53 yamaguchi Exp $	*/
+/*	$NetBSD: pmap.c,v 1.401 2020/07/19 13:58:26 maxv Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.400 2020/07/14 00:45:53 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.401 2020/07/19 13:58:26 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -3326,7 +3326,7 @@ pmap_ldt_xcall(void *arg1, void *arg2)
 	kpreempt_disable();
 	pm = arg1;
 	if (curcpu()->ci_pmap == pm) {
-#if defined(SVS) && defined(USER_LDT)
+#if defined(SVS)
 		if (svs_enabled) {
 			svs_ldt_sync(pm);
 		} else



CVS commit: src/sys

2020-07-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jul 19 13:55:09 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: netbsd32_machdep_13.c
src/sys/arch/i386/include: pmap.h
src/sys/arch/x86/include: cpu.h
src/sys/arch/xen/x86: xen_pmap.c
src/sys/compat/linux/arch/i386: linux_exec_machdep.c

Log Message:
don't include opt_user_ldt.h when it is not needed


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amd64/amd64/netbsd32_machdep_13.c
cvs rdiff -u -r1.125 -r1.126 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r1.127 -r1.128 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/xen/x86/xen_pmap.c
cvs rdiff -u -r1.18 -r1.19 \
src/sys/compat/linux/arch/i386/linux_exec_machdep.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/netbsd32_machdep_13.c
diff -u src/sys/arch/amd64/amd64/netbsd32_machdep_13.c:1.3 src/sys/arch/amd64/amd64/netbsd32_machdep_13.c:1.4
--- src/sys/arch/amd64/amd64/netbsd32_machdep_13.c:1.3	Wed Nov 13 16:11:27 2019
+++ src/sys/arch/amd64/amd64/netbsd32_machdep_13.c	Sun Jul 19 13:55:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep_13.c,v 1.3 2019/11/13 16:11:27 pgoyette Exp $	*/
+/*	$NetBSD: netbsd32_machdep_13.c,v 1.4 2020/07/19 13:55:09 maxv Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,12 +36,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_13.c,v 1.3 2019/11/13 16:11:27 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_13.c,v 1.4 2020/07/19 13:55:09 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
 #include "opt_execfmt.h"
-#include "opt_user_ldt.h"
 #include "opt_mtrr.h"
 #endif
 

Index: src/sys/arch/i386/include/pmap.h
diff -u src/sys/arch/i386/include/pmap.h:1.125 src/sys/arch/i386/include/pmap.h:1.126
--- src/sys/arch/i386/include/pmap.h:1.125	Fri May 15 22:17:45 2020
+++ src/sys/arch/i386/include/pmap.h	Sun Jul 19 13:55:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.125 2020/05/15 22:17:45 ad Exp $	*/
+/*	$NetBSD: pmap.h,v 1.126 2020/07/19 13:55:09 maxv Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -64,7 +64,6 @@
 #define	_I386_PMAP_H_
 
 #if defined(_KERNEL_OPT)
-#include "opt_user_ldt.h"
 #include "opt_xen.h"
 #endif
 

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.127 src/sys/arch/x86/include/cpu.h:1.128
--- src/sys/arch/x86/include/cpu.h:1.127	Tue Jul 14 00:45:53 2020
+++ src/sys/arch/x86/include/cpu.h	Sun Jul 19 13:55:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.127 2020/07/14 00:45:53 yamaguchi Exp $	*/
+/*	$NetBSD: cpu.h,v 1.128 2020/07/19 13:55:09 maxv Exp $	*/
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -48,9 +48,6 @@
 #if defined(_KERNEL_OPT)
 #include "opt_xen.h"
 #include "opt_svs.h"
-#ifdef i386
-#include "opt_user_ldt.h"
-#endif
 #endif
 
 /*

Index: src/sys/arch/xen/x86/xen_pmap.c
diff -u src/sys/arch/xen/x86/xen_pmap.c:1.37 src/sys/arch/xen/x86/xen_pmap.c:1.38
--- src/sys/arch/xen/x86/xen_pmap.c:1.37	Tue Jan  7 13:48:01 2020
+++ src/sys/arch/xen/x86/xen_pmap.c	Sun Jul 19 13:55:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_pmap.c,v 1.37 2020/01/07 13:48:01 ad Exp $	*/
+/*	$NetBSD: xen_pmap.c,v 1.38 2020/07/19 13:55:09 maxv Exp $	*/
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -101,9 +101,8 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.37 2020/01/07 13:48:01 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.38 2020/07/19 13:55:09 maxv Exp $");
 
-#include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"

Index: src/sys/compat/linux/arch/i386/linux_exec_machdep.c
diff -u src/sys/compat/linux/arch/i386/linux_exec_machdep.c:1.18 src/sys/compat/linux/arch/i386/linux_exec_machdep.c:1.19
--- src/sys/compat/linux/arch/i386/linux_exec_machdep.c:1.18	Sat Aug 12 07:21:57 2017
+++ src/sys/compat/linux/arch/i386/linux_exec_machdep.c	Sun Jul 19 13:55:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_exec_machdep.c,v 1.18 2017/08/12 07:21:57 maxv Exp $	*/
+/*	$NetBSD: linux_exec_machdep.c,v 1.19 2020/07/19 13:55:08 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,11 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_exec_machdep.c,v 1.18 2017/08/12 07:21:57 maxv Exp $");
-
-#if defined(_KERNEL_OPT)
-#include "opt_user_ldt.h"
-#endif
+__KERNEL_RCSID(0, "$NetBSD: linux_exec_machdep.c,v 1.19 2020/07/19 13:55:08 maxv Exp $");
 
 #include 
 #include 



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 13:21:56 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): rename flags for :S and :C pattern matching

Renaming these flags makes it obvious that VarPattern is used in a few
places where it doesn't belong.  These will be fixed in follow-up
commits.


To generate a diff of this commit:
cvs rdiff -u -r1.260 -r1.261 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.260 src/usr.bin/make/var.c:1.261
--- src/usr.bin/make/var.c:1.260	Sun Jul 19 12:51:06 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 13:21:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.260 2020/07/19 12:51:06 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.261 2020/07/19 13:21:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.260 2020/07/19 12:51:06 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.261 2020/07/19 13:21:56 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.260 2020/07/19 12:51:06 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.261 2020/07/19 13:21:56 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -235,14 +235,18 @@ static int var_exportedVars = VAR_EXPORT
  */
 #define VAR_EXPORT_LITERAL	2
 
+/* Flags for pattern matching in the :S and :C modifiers */
 typedef enum {
-	VAR_SUB_GLOBAL	= 0x01,	/* Apply substitution globally */
-	VAR_SUB_ONE	= 0x02,	/* Apply substitution to one word */
-	VAR_SUB_MATCHED	= 0x04,	/* There was a match */
-	VAR_MATCH_START	= 0x08,	/* Match at start of word */
-	VAR_MATCH_END	= 0x10,	/* Match at end of word */
-	VAR_NOSUBST	= 0x20	/* don't expand vars in VarGetPattern */
-} VarPattern_Flags;
+VARP_SUB_GLOBAL	= 0x01,	/* Apply substitution globally */
+VARP_SUB_ONE	= 0x02,	/* Apply substitution to one word */
+VARP_SUB_MATCHED	= 0x04,	/* There was a match */
+VARP_MATCH_START	= 0x08,	/* Match at start of word */
+VARP_MATCH_END	= 0x10,	/* Match at end of word */
+
+/* FIXME: This constant doesn't belong here. It is not related to
+ * pattern matching, and VarGetPattern is badly named as well. */
+VAR_NOSUBST	= 0x20		/* don't expand vars in VarGetPattern */
+} VarPatternFlags;
 
 typedef enum {
 	VAR_NO_EXPORT	= 0x01	/* do not export */
@@ -269,7 +273,7 @@ typedef struct {
 int		  leftLen;	/* Length of string */
 const char   *rhs;		/* Replacement string (w/ &'s removed) */
 int		  rightLen;	/* Length of replacement */
-VarPattern_Flags flags;
+VarPatternFlags pflags;
 } VarPattern;
 
 /* struct passed as 'void *' to VarLoopExpand() for ":@tvar@str@" */
@@ -289,7 +293,7 @@ typedef struct {
 int		   nsub;
 regmatch_t 	  *matches;
 char 	  *replace;
-int		   flags;
+VarPatternFlags pflags;
 } VarREPattern;
 #endif
 
@@ -1360,18 +1364,18 @@ VarSubstitute(GNode *ctx MAKE_ATTR_UNUSE
 const char *cp;		/* General pointer */
 VarPattern *pattern = data;
 
-if ((pattern->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) !=
-	(VAR_SUB_ONE|VAR_SUB_MATCHED)) {
+if ((pattern->pflags & (VARP_SUB_ONE | VARP_SUB_MATCHED)) !=
+	(VARP_SUB_ONE | VARP_SUB_MATCHED)) {
 	/*
 	 * Still substituting -- break it down into simple anchored cases
 	 * and if none of them fits, perform the general substitution case.
 	 */
-	if ((pattern->flags & VAR_MATCH_START) &&
+	if ((pattern->pflags & VARP_MATCH_START) &&
 	(strncmp(word, pattern->lhs, pattern->leftLen) == 0)) {
 	/*
 	 * Anchored at start and beginning of word matches pattern
 	 */
-	if ((pattern->flags & VAR_MATCH_END) &&
+	if ((pattern->pflags & VARP_MATCH_END) &&
 	(wordLen == pattern->leftLen)) {
 		/*
 		 * Also anchored at end and matches to the end (word
@@ -1385,8 +1389,8 @@ VarSubstitute(GNode *ctx MAKE_ATTR_UNUSE
 		addSpace = TRUE;
 		Buf_AddBytes(buf, pattern->rightLen, pattern->rhs);
 		}
-		pattern->flags |= VAR_SUB_MATCHED;
-	} else if (pattern->flags & VAR_MATCH_END) {
+		pattern->pflags |= VARP_SUB_MATCHED;
+	} else if (pattern->pflags & VARP_MATCH_END) {
 		/*
 		 * Doesn't match to end -- copy word wholesale
 		 */
@@ -1404,14 +1408,14 @@ VarSubstitute(GNode *ctx MAKE_ATTR_UNUSE
 		Buf_AddBytes(buf, pattern->rightLen, pattern->rhs);
 		Buf_AddBytes(buf, wordLen - pattern->leftLen,
 			 (word + pattern->leftLen));
-		pattern->flags |= VAR_SUB_MATCHED;
+		pattern->pflags |= VARP_SUB_MATCHED;
 	}
-	} else if (pattern->flags & VAR_MATCH_START) {
+	} else if (pattern->pflags & VARP_MATCH_START) {
 	/*
 	 * Had to match at start of word and didn't -- copy whole word.
 	 */
 	goto nosub;
-	} else if (pattern->flags & VAR_MATCH_END) {
+	} else if 

CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 12:51:06 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): convert VarFind flags to typed enum


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.259 src/usr.bin/make/var.c:1.260
--- src/usr.bin/make/var.c:1.259	Sun Jul 19 12:26:17 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 12:51:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.259 2020/07/19 12:26:17 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.260 2020/07/19 12:51:06 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.259 2020/07/19 12:26:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.260 2020/07/19 12:51:06 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.259 2020/07/19 12:26:17 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.260 2020/07/19 12:51:06 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -189,9 +189,11 @@ GNode  *VAR_INTERNAL;	/* variabl
 GNode  *VAR_GLOBAL;	/* variables from the makefile */
 GNode  *VAR_CMD;	/* variables defined on the command-line */
 
-#define FIND_CMD	0x1	/* look in VAR_CMD when searching */
-#define FIND_GLOBAL	0x2	/* look in VAR_GLOBAL as well */
-#define FIND_ENV  	0x4	/* look in the environment also */
+typedef enum {
+FIND_CMD		= 0x01,	/* look in VAR_CMD when searching */
+FIND_GLOBAL		= 0x02,	/* look in VAR_GLOBAL as well */
+FIND_ENV		= 0x04	/* look in the environment also */
+} VarFindFlags;
 
 typedef enum {
 VAR_IN_USE		= 0x01,	/* Variable's value is currently being used.
@@ -311,10 +313,9 @@ typedef struct {
  * Input:
  *	name		name to find
  *	ctxt		context in which to find it
- *	flags		FIND_GLOBAL set means to look in the
- *			VAR_GLOBAL context as well. FIND_CMD set means
- *			to look in the VAR_CMD context also. FIND_ENV
- *			set means to look in the environment
+ *	flags		FIND_GLOBAL	look in VAR_GLOBAL as well
+ *			FIND_CMD	look in VAR_CMD as well
+ *			FIND_ENV	look in the environment as well
  *
  * Results:
  *	A pointer to the structure describing the desired variable or
@@ -325,7 +326,7 @@ typedef struct {
  *---
  */
 static Var *
-VarFind(const char *name, GNode *ctxt, int flags)
+VarFind(const char *name, GNode *ctxt, VarFindFlags flags)
 {
 Hash_Entry 	*var;
 Var			*v;
@@ -1011,7 +1012,7 @@ Var_Append(const char *name, const char 
 	name = expanded_name;
 }
 
-v = VarFind(name, ctxt, ctxt == VAR_GLOBAL ? (FIND_CMD|FIND_ENV) : 0);
+v = VarFind(name, ctxt, ctxt == VAR_GLOBAL ? (FIND_CMD | FIND_ENV) : 0);
 
 if (v == NULL) {
 	Var_Set(name, val, ctxt);
@@ -1064,7 +1065,7 @@ Var_Exists(const char *name, GNode *ctxt
 
 if ((cp = strchr(name, '$')) != NULL)
 	cp = Var_Subst(NULL, name, ctxt, VARE_WANTRES);
-v = VarFind(cp ? cp : name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV);
+v = VarFind(cp ? cp : name, ctxt, FIND_CMD | FIND_GLOBAL | FIND_ENV);
 free(cp);
 if (v == NULL)
 	return FALSE;



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 12:35:30 UTC 2020

Modified Files:
src/usr.bin/make: cond.c main.c meta.c

Log Message:
make(1): clean up unnecessary snprintf and multi-line function calls


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/make/cond.c
cvs rdiff -u -r1.281 -r1.282 src/usr.bin/make/main.c
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/make/meta.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.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.80 src/usr.bin/make/cond.c:1.81
--- src/usr.bin/make/cond.c:1.80	Sun Jul 19 12:26:17 2020
+++ src/usr.bin/make/cond.c	Sun Jul 19 12:35:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.80 2020/07/19 12:26:17 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.81 2020/07/19 12:35:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.80 2020/07/19 12:26:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.81 2020/07/19 12:35:30 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.80 2020/07/19 12:26:17 rillig Exp $");
+__RCSID("$NetBSD: cond.c,v 1.81 2020/07/19 12:35:30 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -283,13 +283,10 @@ CondGetArg(Boolean doEval, char **linePt
 	 * variable, so we don't do it too. Nor do we return an error,
 	 * though perhaps we should...
 	 */
-	char  	*cp2;
 	int		len;
 	void	*freeIt;
-
-	cp2 = Var_Parse(cp, VAR_CMD, VARE_UNDEFERR|
-			(doEval ? VARE_WANTRES : 0),
-			, );
+	VarEvalFlags eflags = VARE_UNDEFERR | (doEval ? VARE_WANTRES : 0);
+	char *cp2 = Var_Parse(cp, VAR_CMD, eflags, , );
 	Buf_AddBytes(, strlen(cp2), cp2);
 	free(freeIt);
 	cp += len;

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.281 src/usr.bin/make/main.c:1.282
--- src/usr.bin/make/main.c:1.281	Sun Jul 19 12:26:17 2020
+++ src/usr.bin/make/main.c	Sun Jul 19 12:35:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.281 2020/07/19 12:26:17 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.282 2020/07/19 12:35:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.281 2020/07/19 12:26:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.282 2020/07/19 12:35:30 rillig Exp $";
 #else
 #include 
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.281 2020/07/19 12:26:17 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.282 2020/07/19 12:35:30 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2039,8 +2039,6 @@ void
 PrintOnError(GNode *gn, const char *s)
 {
 static GNode *en = NULL;
-char tmp[64];
-char *cp;
 
 /* we generally want to keep quiet if a sub-make died */
 if (dieQuietly(gn, -1))
@@ -2061,9 +2059,8 @@ PrintOnError(GNode *gn, const char *s)
 	Var_Delete(".ERROR_CMD", VAR_GLOBAL);
 	Lst_ForEach(gn->commands, addErrorCMD, gn);
 }
-strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}",
-	sizeof(tmp) - 1);
-cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARE_WANTRES);
+const char *expr = "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}";
+char *cp = Var_Subst(NULL, expr, VAR_GLOBAL, VARE_WANTRES);
 if (cp) {
 	if (*cp)
 	printf("%s", cp);
@@ -2085,17 +2082,14 @@ void
 Main_ExportMAKEFLAGS(Boolean first)
 {
 static int once = 1;
-char tmp[64];
-char *s;
 
 if (once != first)
 	return;
 once = 0;
 
-strncpy(tmp, "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}",
-	sizeof(tmp));
-s = Var_Subst(NULL, tmp, VAR_CMD, VARE_WANTRES);
-if (s && *s) {
+const char *expr = "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}";
+char *s = Var_Subst(NULL, expr, VAR_CMD, VARE_WANTRES);
+if (s != NULL && s[0] != '\0') {
 #ifdef POSIX
 	setenv("MAKEFLAGS", s, 1);
 #else

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.87 src/usr.bin/make/meta.c:1.88
--- src/usr.bin/make/meta.c:1.87	Sun Jul 19 12:26:17 2020
+++ src/usr.bin/make/meta.c	Sun Jul 19 12:35:30 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.87 2020/07/19 12:26:17 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.88 2020/07/19 12:35:30 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -1011,12 +1011,9 @@ meta_ignore(GNode *gn, const char *p)
 }
 
 if (metaIgnorePatterns) {
-	char *pm;
-
 	Var_Set(".p.", p, gn);
-	pm = Var_Subst(NULL,
-		   "${" MAKE_META_IGNORE_PATTERNS ":@m@${.p.:M$m}@}",
-		   gn, VARE_WANTRES);
+	const char *expr = "${" MAKE_META_IGNORE_PATTERNS ":@m@${.p.:M$m}@}";
+	

CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 12:26:17 UTC 2020

Modified Files:
src/usr.bin/make: arch.c compat.c cond.c for.c job.c main.c make.c
meta.c nonints.h parse.c suff.c var.c

Log Message:
make(1): rename Varf_Flags to VarEvalFlags

In var.c there are lots of different flag types.  To make any accidental
mixture obvious, each flag group gets its own prefix.

The only flag group that is visible outside of var.c is concerned with
evaluating variables, therefore the "e", which replaces the former "f"
that probably just meant "flag".


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/make/arch.c
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/make/compat.c
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/make/cond.c src/usr.bin/make/nonints.h
cvs rdiff -u -r1.54 -r1.55 src/usr.bin/make/for.c
cvs rdiff -u -r1.201 -r1.202 src/usr.bin/make/job.c
cvs rdiff -u -r1.280 -r1.281 src/usr.bin/make/main.c
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/make/make.c
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/make/meta.c
cvs rdiff -u -r1.236 -r1.237 src/usr.bin/make/parse.c
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/make/suff.c
cvs rdiff -u -r1.258 -r1.259 src/usr.bin/make/var.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.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.73 src/usr.bin/make/arch.c:1.74
--- src/usr.bin/make/arch.c:1.73	Fri Jul  3 08:02:55 2020
+++ src/usr.bin/make/arch.c	Sun Jul 19 12:26:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.73 2020/07/03 08:02:55 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.74 2020/07/19 12:26:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.73 2020/07/03 08:02:55 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.74 2020/07/19 12:26:17 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.73 2020/07/03 08:02:55 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.74 2020/07/19 12:26:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -259,7 +259,7 @@ Arch_ParseArchive(char **linePtr, Lst no
 	void	*freeIt;
 	char	*result;
 
-	result = Var_Parse(cp, ctxt, VARF_UNDEFERR|VARF_WANTRES,
+	result = Var_Parse(cp, ctxt, VARE_UNDEFERR|VARE_WANTRES,
 			   , );
 	free(freeIt);
 
@@ -275,7 +275,7 @@ Arch_ParseArchive(char **linePtr, Lst no
 
 *cp++ = '\0';
 if (subLibName) {
-	libName = Var_Subst(NULL, libName, ctxt, VARF_UNDEFERR|VARF_WANTRES);
+	libName = Var_Subst(NULL, libName, ctxt, VARE_UNDEFERR|VARE_WANTRES);
 }
 
 
@@ -301,7 +301,7 @@ Arch_ParseArchive(char **linePtr, Lst no
 		void	*freeIt;
 		char	*result;
 
-		result = Var_Parse(cp, ctxt, VARF_UNDEFERR|VARF_WANTRES,
+		result = Var_Parse(cp, ctxt, VARE_UNDEFERR|VARE_WANTRES,
    , );
 		free(freeIt);
 
@@ -356,7 +356,7 @@ Arch_ParseArchive(char **linePtr, Lst no
 	size_t   sz;
 
 	memName = Var_Subst(NULL, memName, ctxt,
-VARF_UNDEFERR|VARF_WANTRES);
+VARE_UNDEFERR|VARE_WANTRES);
 
 	/*
 	 * Now form an archive spec and recurse to deal with nested

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.113 src/usr.bin/make/compat.c:1.114
--- src/usr.bin/make/compat.c:1.113	Fri Jul  3 08:13:23 2020
+++ src/usr.bin/make/compat.c	Sun Jul 19 12:26:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.113 2020/07/03 08:13:23 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.114 2020/07/19 12:26:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.113 2020/07/03 08:13:23 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.114 2020/07/19 12:26:17 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.113 2020/07/03 08:13:23 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.114 2020/07/19 12:26:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -235,7 +235,7 @@ CompatRunCommand(void *cmdp, void *gnp)
 doIt = FALSE;
 
 cmdNode = Lst_Member(gn->commands, cmd);
-cmdStart = Var_Subst(NULL, cmd, gn, VARF_WANTRES);
+cmdStart = Var_Subst(NULL, cmd, gn, VARE_WANTRES);
 
 /*
  * brk_string will return an argv with a NULL in av[0], thus causing

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.79 src/usr.bin/make/cond.c:1.80
--- src/usr.bin/make/cond.c:1.79	Thu Jul  9 22:34:08 2020
+++ src/usr.bin/make/cond.c	Sun Jul 19 12:26:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.79 2020/07/09 22:34:08 sjg Exp $	*/
+/*	$NetBSD: cond.c,v 1.80 2020/07/19 12:26:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the 

CVS commit: src/sys/arch/arm

2020-07-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul 19 11:47:48 UTC 2020

Modified Files:
src/sys/arch/arm/arm: armv6_start.S
src/sys/arch/arm/include: asan.h

Log Message:
Fix RPI boot which needs more early stack

XXX centralise INIT_ARM_STACK_{SHIFT,SIZE}
XXX how to protect against this breaking again?


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/arm/armv6_start.S
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/include/asan.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/arm/arm/armv6_start.S
diff -u src/sys/arch/arm/arm/armv6_start.S:1.20 src/sys/arch/arm/arm/armv6_start.S:1.21
--- src/sys/arch/arm/arm/armv6_start.S:1.20	Fri Jul 10 12:25:08 2020
+++ src/sys/arch/arm/arm/armv6_start.S	Sun Jul 19 11:47:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: armv6_start.S,v 1.20 2020/07/10 12:25:08 skrll Exp $	*/
+/*	$NetBSD: armv6_start.S,v 1.21 2020/07/19 11:47:47 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2017, 2018 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
 #include 
 #include "assym.h"
 
-#define INIT_ARM_STACK_SHIFT	9
+#define INIT_ARM_STACK_SHIFT	10
 #define INIT_ARM_STACK_SIZE	(1 << INIT_ARM_STACK_SHIFT)
 
 #if defined(CONSADDR) && defined(CONADDR)

Index: src/sys/arch/arm/include/asan.h
diff -u src/sys/arch/arm/include/asan.h:1.2 src/sys/arch/arm/include/asan.h:1.3
--- src/sys/arch/arm/include/asan.h:1.2	Fri Jul 10 12:45:15 2020
+++ src/sys/arch/arm/include/asan.h	Sun Jul 19 11:47:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.2 2020/07/10 12:45:15 skrll Exp $	*/
+/*	$NetBSD: asan.h,v 1.3 2020/07/19 11:47:48 skrll Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@ kasan_md_unsupported(vaddr_t addr)
  * that VA = PA + KERNEL_BASE.
  */
 
-#define KASAN_NEARLYPAGES	2
+#define KASAN_NEARLYPAGES	3
 
 static bool __md_early __read_mostly;
 static size_t __md_nearlypages __attribute__((__section__(".data")));
@@ -165,7 +165,7 @@ kasan_md_shadow_map_page(vaddr_t va)
 /*
  * Map the init stacks of the BP and APs. We will map the rest in kasan_init.
  */
-#define INIT_ARM_STACK_SHIFT	9
+#define INIT_ARM_STACK_SHIFT	10
 #define INIT_ARM_STACK_SIZE	(1 << INIT_ARM_STACK_SHIFT)
 
 static void



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 10:38:02 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): clean up handling of :? modifier

The VarPattern type had nothing to do with parsing conditions.


To generate a diff of this commit:
cvs rdiff -u -r1.257 -r1.258 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.257 src/usr.bin/make/var.c:1.258
--- src/usr.bin/make/var.c:1.257	Sun Jul 19 10:28:44 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 10:38:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.257 2020/07/19 10:28:44 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.258 2020/07/19 10:38:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.257 2020/07/19 10:28:44 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.258 2020/07/19 10:38:02 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.257 2020/07/19 10:28:44 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.258 2020/07/19 10:38:02 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3043,60 +3043,53 @@ ApplyModifier_Order(ApplyModifiersState 
 static Boolean
 ApplyModifier_IfElse(ApplyModifiersState *st)
 {
-VarPattern pattern;
 Boolean value;
 int cond_rc;
-VarPattern_Flags lhs_flags, rhs_flags;
+VarPattern_Flags then_flags, else_flags;
 
 /* find ':', and then substitute accordingly */
 if (st->flags & VARF_WANTRES) {
 	cond_rc = Cond_EvalExpression(NULL, st->v->name, , 0, FALSE);
-	if (cond_rc == COND_INVALID) {
-	lhs_flags = rhs_flags = VAR_NOSUBST;
-	} else if (value) {
-	lhs_flags = 0;
-	rhs_flags = VAR_NOSUBST;
-	} else {
-	lhs_flags = VAR_NOSUBST;
-	rhs_flags = 0;
-	}
+	then_flags = cond_rc != COND_INVALID && value ? 0 : VAR_NOSUBST;
+	else_flags = cond_rc != COND_INVALID && !value ? 0 : VAR_NOSUBST;
 } else {
 	/* we are just consuming and discarding */
 	cond_rc = value = 0;
-	lhs_flags = rhs_flags = VAR_NOSUBST;
+	then_flags = else_flags = VAR_NOSUBST;
 }
-pattern.flags = 0;
 
 st->cp = ++st->tstr;
 st->delim = ':';
-pattern.lhs = VarGetPattern(
+int then_len;
+char *then_expr = VarGetPattern(
 	st->ctxt, >parsestate, st->flags, >cp, st->delim,
-	_flags, , NULL);
-if (pattern.lhs == NULL)
+	_flags, _len, NULL);
+if (then_expr == NULL)
 	return FALSE;
 
 /* BROPEN or PROPEN */
 st->delim = st->endc;
-pattern.rhs = VarGetPattern(
+int else_len;
+char *else_expr = VarGetPattern(
 	st->ctxt, >parsestate, st->flags, >cp, st->delim,
-	_flags, , NULL);
-if (pattern.rhs == NULL)
+	_flags, _len, NULL);
+if (else_expr == NULL)
 	return FALSE;
 
 st->termc = *--st->cp;
 st->delim = '\0';
 if (cond_rc == COND_INVALID) {
 	Error("Bad conditional expression `%s' in %s?%s:%s",
-	st->v->name, st->v->name, pattern.lhs, pattern.rhs);
+	st->v->name, st->v->name, then_expr, else_expr);
 	return FALSE;
 }
 
 if (value) {
-	st->newStr = UNCONST(pattern.lhs);
-	free(UNCONST(pattern.rhs));
+	st->newStr = then_expr;
+	free(else_expr);
 } else {
-	st->newStr = UNCONST(pattern.rhs);
-	free(UNCONST(pattern.lhs));
+	st->newStr = else_expr;
+	free(else_expr);
 }
 if (st->v->flags & VAR_JUNK)
 	st->v->flags |= VAR_KEEP;



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 10:28:44 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): clean up code in var.c

* use canonical comparison to zero in more cases
* omit unnecessary snprintf for string literal concatenation
* omit a few redundant parentheses and braces


To generate a diff of this commit:
cvs rdiff -u -r1.256 -r1.257 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.256 src/usr.bin/make/var.c:1.257
--- src/usr.bin/make/var.c:1.256	Sun Jul 19 09:26:18 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 10:28:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.256 2020/07/19 09:26:18 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.257 2020/07/19 10:28:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.256 2020/07/19 09:26:18 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.257 2020/07/19 10:28:44 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.256 2020/07/19 09:26:18 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.257 2020/07/19 10:28:44 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -339,29 +339,29 @@ VarFind(const char *name, GNode *ctxt, i
 if (*name == '.' && isupper((unsigned char) name[1])) {
 	switch (name[1]) {
 	case 'A':
-	if (!strcmp(name, ".ALLSRC"))
+	if (strcmp(name, ".ALLSRC") == 0)
 		name = ALLSRC;
-	if (!strcmp(name, ".ARCHIVE"))
+	if (strcmp(name, ".ARCHIVE") == 0)
 		name = ARCHIVE;
 	break;
 	case 'I':
-	if (!strcmp(name, ".IMPSRC"))
+	if (strcmp(name, ".IMPSRC") == 0)
 		name = IMPSRC;
 	break;
 	case 'M':
-	if (!strcmp(name, ".MEMBER"))
+	if (strcmp(name, ".MEMBER") == 0)
 		name = MEMBER;
 	break;
 	case 'O':
-	if (!strcmp(name, ".OODATE"))
+	if (strcmp(name, ".OODATE") == 0)
 		name = OODATE;
 	break;
 	case 'P':
-	if (!strcmp(name, ".PREFIX"))
+	if (strcmp(name, ".PREFIX") == 0)
 		name = PREFIX;
 	break;
 	case 'T':
-	if (!strcmp(name, ".TARGET"))
+	if (strcmp(name, ".TARGET") == 0)
 		name = TARGET;
 	break;
 	}
@@ -396,7 +396,7 @@ VarFind(const char *name, GNode *ctxt, i
 	char *env;
 
 	if ((env = getenv(name)) != NULL) {
-	int		len;
+	int len;
 
 	v = bmake_malloc(sizeof(Var));
 	v->name = bmake_strdup(name);
@@ -449,7 +449,7 @@ VarFind(const char *name, GNode *ctxt, i
 static Boolean
 VarFreeEnv(Var *v, Boolean destroy)
 {
-if ((v->flags & VAR_FROM_ENV) == 0)
+if (!(v->flags & VAR_FROM_ENV))
 	return FALSE;
 free(v->name);
 Buf_Destroy(>val, destroy);
@@ -482,7 +482,7 @@ VarAdd(const char *name, const char *val
 
 v = bmake_malloc(sizeof(Var));
 
-len = val ? strlen(val) : 0;
+len = val != NULL ? strlen(val) : 0;
 Buf_Init(>val, len + 1);
 Buf_AddBytes(>val, len, val);
 
@@ -491,7 +491,7 @@ VarAdd(const char *name, const char *val
 h = Hash_CreateEntry(>context, name, NULL);
 Hash_SetValue(h, v);
 v->name = h->name;
-if (DEBUG(VAR) && (ctxt->flags & INTERNAL) == 0) {
+if (DEBUG(VAR) && !(ctxt->flags & INTERNAL)) {
 	fprintf(debug_file, "%s:%s = %s\n", ctxt->name, name, val);
 }
 }
@@ -512,24 +512,21 @@ Var_Delete(const char *name, GNode *ctxt
 Hash_Entry 	  *ln;
 char *cp;
 
-if (strchr(name, '$')) {
+if (strchr(name, '$') != NULL) {
 	cp = Var_Subst(NULL, name, VAR_GLOBAL, VARF_WANTRES);
 } else {
-	cp = (char *)name;
+	cp = UNCONST(name);
 }
 ln = Hash_FindEntry(>context, cp);
 if (DEBUG(VAR)) {
 	fprintf(debug_file, "%s:delete %s%s\n",
 	ctxt->name, cp, ln ? "" : " (not found)");
 }
-if (cp != name) {
+if (cp != name)
 	free(cp);
-}
 if (ln != NULL) {
-	Var 	  *v;
-
-	v = (Var *)Hash_GetValue(ln);
-	if ((v->flags & VAR_EXPORTED)) {
+	Var *v = (Var *)Hash_GetValue(ln);
+	if (v->flags & VAR_EXPORTED) {
 	unsetenv(v->name);
 	}
 	if (strcmp(MAKE_EXPORTED, v->name) == 0) {
@@ -578,9 +575,8 @@ Var_Export1(const char *name, int flags)
 	}
 }
 v = VarFind(name, VAR_GLOBAL, 0);
-if (v == NULL) {
+if (v == NULL)
 	return 0;
-}
 if (!parent &&
 	(v->flags & (VAR_EXPORTED|VAR_REEXPORT)) == VAR_EXPORTED) {
 	return 0;			/* nothing to do */
@@ -673,9 +669,8 @@ Var_ExportVars(void)
 	val = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
 	if (*val) {
 	av = brk_string(val, , FALSE, );
-	for (i = 0; i < ac; i++) {
+	for (i = 0; i < ac; i++)
 		Var_Export1(av[i], 0);
-	}
 	free(as);
 	free(av);
 	}
@@ -748,11 +743,11 @@ Var_Export(char *str, int isExport)
 }
 
 
+extern char **environ;
+
 /*
  * This is called when .unexport[-env] is seen.
  */
-extern char **environ;
-
 void
 

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

2020-07-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Jul 19 09:30:08 UTC 2020

Modified Files:
src/sys/arch/mips/mips: cpu_subr.c

Log Message:
A little KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/mips/mips/cpu_subr.c

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

Modified files:

Index: src/sys/arch/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.49 src/sys/arch/mips/mips/cpu_subr.c:1.50
--- src/sys/arch/mips/mips/cpu_subr.c:1.49	Fri Jul 17 21:59:30 2020
+++ src/sys/arch/mips/mips/cpu_subr.c	Sun Jul 19 09:30:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_subr.c,v 1.49 2020/07/17 21:59:30 jmcneill Exp $	*/
+/*	$NetBSD: cpu_subr.c,v 1.50 2020/07/19 09:30:08 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.49 2020/07/17 21:59:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.50 2020/07/19 09:30:08 simonb Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -122,6 +122,7 @@ struct cpu_info *
 cpu_info_alloc(struct pmap_tlb_info *ti, cpuid_t cpu_id, cpuid_t cpu_package_id,
 	cpuid_t cpu_core_id, cpuid_t cpu_smt_id)
 {
+
 	KASSERT(cpu_id < MAXCPUS);
 
 #ifdef MIPS64_OCTEON
@@ -207,6 +208,7 @@ cpu_hwrena_setup(void)
 {
 #if (MIPS32R2 + MIPS64R2) > 0
 	const int cp0flags = mips_options.mips_cpu->cpu_cp0flags;
+
 	if ((cp0flags & MIPS_CP0FL_USE) == 0)
 		return;
 
@@ -401,6 +403,7 @@ cpu_getmcontext(struct lwp *l, mcontext_
 int
 cpu_mcontext_validate(struct lwp *l, const mcontext_t *mcp)
 {
+
 	/* XXX:  Do we validate the addresses?? */
 	return 0;
 }
@@ -483,6 +486,7 @@ cpu_setmcontext(struct lwp *l, const mco
 void
 cpu_need_resched(struct cpu_info *ci, struct lwp *l, int flags)
 {
+
 	KASSERT(kpreempt_disabled());
 
 	if ((flags & RESCHED_KPREEMPT) != 0) {
@@ -507,12 +511,14 @@ cpu_need_resched(struct cpu_info *ci, st
 uint32_t
 cpu_clkf_usermode_mask(void)
 {
+
 	return CPUISMIPS3 ? MIPS_SR_KSU_USER : MIPS_SR_KU_PREV;
 }
 
 void
 cpu_signotify(struct lwp *l)
 {
+
 	KASSERT(kpreempt_disabled());
 #ifdef __HAVE_FAST_SOFTINTS
 	KASSERT(lwp_locked(l, NULL));
@@ -530,6 +536,7 @@ cpu_signotify(struct lwp *l)
 void
 cpu_need_proftick(struct lwp *l)
 {
+
 	KASSERT(kpreempt_disabled());
 	KASSERT(l->l_cpu == curcpu());
 
@@ -541,6 +548,7 @@ cpu_need_proftick(struct lwp *l)
 bool
 cpu_kpreempt_enter(uintptr_t where, int s)
 {
+
 	KASSERT(kpreempt_disabled());
 
 #if 0
@@ -580,6 +588,7 @@ cpu_kpreempt_exit(uintptr_t where)
 bool
 cpu_kpreempt_disabled(void)
 {
+
 	/*
 	 * Any elevated IPL disables preemption.
 	 */
@@ -624,6 +633,7 @@ cpu_intr_p(void)
 void
 cpu_broadcast_ipi(int tag)
 {
+
 	// No reason to remove ourselves since multicast_ipi will do that for us
 	cpu_multicast_ipi(cpus_running, tag);
 }
@@ -769,6 +779,7 @@ void
 cpu_pause_others(void)
 {
 	struct cpu_info * const ci = curcpu();
+
 	if (cold || kcpuset_match(cpus_running, ci->ci_data.cpu_kcpuset))
 		return;
 
@@ -788,6 +799,7 @@ cpu_pause_others(void)
 void
 cpu_resume(cpuid_t cii)
 {
+
 	if (__predict_false(cold))
 		return;
 
@@ -807,6 +819,7 @@ cpu_resume(cpuid_t cii)
 void
 cpu_resume_others(void)
 {
+
 	if (__predict_false(cold))
 		return;
 
@@ -957,6 +970,7 @@ cpu_boot_secondary_processors(void)
 {
 	CPU_INFO_ITERATOR cii;
 	struct cpu_info *ci;
+
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		if (CPU_IS_PRIMARY(ci))
 			continue;
@@ -990,6 +1004,7 @@ xc_send_ipi(struct cpu_info *ci)
 void
 cpu_ipi(struct cpu_info *ci)
 {
+
 	(*mips_locoresw.lsw_send_ipi)(ci, IPI_GENERIC);
 }
 
@@ -1011,6 +1026,7 @@ cpu_vmspace_exec(lwp_t *l, vaddr_t start
 	 * well before setreg gets called.
 	 */
 	uint32_t sr = mips_cp0_status_read();
+
 	if (end != (uint32_t) end) {
 		mips_cp0_status_write(sr | MIPS3_SR_UX);
 	} else {
@@ -1022,6 +1038,7 @@ cpu_vmspace_exec(lwp_t *l, vaddr_t start
 int
 cpu_lwp_setprivate(lwp_t *l, void *v)
 {
+
 #if (MIPS32R2 + MIPS64R2) > 0
 	if (l == curlwp && MIPS_HAS_USERLOCAL) {
 		mipsNN_cp0_userlocal_write(v);
@@ -1058,6 +1075,7 @@ cpuwatch_free(cpu_watchpoint_t *cwp)
 {
 #ifdef DIAGNOSTIC
 	struct cpu_info * const ci = curcpu();
+
 	KASSERT(cwp >= >ci_cpuwatch_tab[0] &&
 		cwp <= >ci_cpuwatch_tab[ci->ci_cpuwatch_count-1]);
 #endif



CVS commit: src/usr.bin/make

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 09:26:19 UTC 2020

Modified Files:
src/usr.bin/make: nonints.h str.c var.c

Log Message:
make(1): move SysV string matching to var.c

This kind of string matching is only used in variable modifiers, and only
if this feature is enabled by SYSVVARSUB.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/make/str.c
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/make/var.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.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.78 src/usr.bin/make/nonints.h:1.79
--- src/usr.bin/make/nonints.h:1.78	Fri Jul  3 07:40:13 2020
+++ src/usr.bin/make/nonints.h	Sun Jul 19 09:26:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.78 2020/07/03 07:40:13 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.79 2020/07/19 09:26:18 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -138,8 +138,6 @@ char *str_concat(const char *, const cha
 char **brk_string(const char *, int *, Boolean, char **);
 char *Str_FindSubstring(const char *, const char *);
 Boolean Str_Match(const char *, const char *);
-char *Str_SYSVMatch(const char *, const char *, size_t *, Boolean *);
-void Str_SYSVSubst(Buffer *, char *, char *, size_t, Boolean);
 
 /* suff.c */
 void Suff_ClearSuffixes(void);

Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.51 src/usr.bin/make/str.c:1.52
--- src/usr.bin/make/str.c:1.51	Fri Jul  3 07:40:13 2020
+++ src/usr.bin/make/str.c	Sun Jul 19 09:26:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.51 2020/07/03 07:40:13 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.52 2020/07/19 09:26:18 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.51 2020/07/03 07:40:13 rillig Exp $";
+static char rcsid[] = "$NetBSD: str.c,v 1.52 2020/07/19 09:26:18 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)str.c	5.8 (Berkeley) 6/1/90";
 #else
-__RCSID("$NetBSD: str.c,v 1.51 2020/07/03 07:40:13 rillig Exp $");
+__RCSID("$NetBSD: str.c,v 1.52 2020/07/19 09:26:18 rillig Exp $");
 #endif
 #endif/* not lint */
 #endif
@@ -423,107 +423,3 @@ Str_Match(const char *str, const char *p
 		str++;
 	}
 }
-
-/*-
- *---
- * Str_SYSVMatch --
- *	Check word against pattern for a match (% is wild),
- *
- * Input:
- *	word		Word to examine
- *	pattern		Pattern to examine against
- *	len		Number of characters to substitute
- *
- * Results:
- *	Returns the beginning position of a match or null. The number
- *	of characters matched is returned in len.
- *
- * Side Effects:
- *	None
- *
- *---
- */
-char *
-Str_SYSVMatch(const char *word, const char *pattern, size_t *len,
-Boolean *hasPercent)
-{
-const char *p = pattern;
-const char *w = word;
-const char *m;
-
-*hasPercent = FALSE;
-if (*p == '\0') {
-	/* Null pattern is the whole string */
-	*len = strlen(w);
-	return UNCONST(w);
-}
-
-if ((m = strchr(p, '%')) != NULL) {
-	*hasPercent = TRUE;
-	if (*w == '\0') {
-		/* empty word does not match pattern */
-		return NULL;
-	}
-	/* check that the prefix matches */
-	for (; p != m && *w && *w == *p; w++, p++)
-	 continue;
-
-	if (p != m)
-	return NULL;	/* No match */
-
-	if (*++p == '\0') {
-	/* No more pattern, return the rest of the string */
-	*len = strlen(w);
-	return UNCONST(w);
-	}
-}
-
-m = w;
-
-/* Find a matching tail */
-do
-	if (strcmp(p, w) == 0) {
-	*len = w - m;
-	return UNCONST(m);
-	}
-while (*w++ != '\0');
-
-return NULL;
-}
-
-
-/*-
- *---
- * Str_SYSVSubst --
- *	Substitute '%' on the pattern with len characters from src.
- *	If the pattern does not contain a '%' prepend len characters
- *	from src.
- *
- * Results:
- *	None
- *
- * Side Effects:
- *	Places result on buf
- *
- *---
- */
-void
-Str_SYSVSubst(Buffer *buf, char *pat, char *src, size_t len,
-Boolean lhsHasPercent)
-{
-char *m;
-
-if ((m = strchr(pat, '%')) != NULL && lhsHasPercent) {
-	/* Copy the prefix */
-	Buf_AddBytes(buf, m - pat, pat);
-	/* skip the % */
-	pat = m + 1;
-}
-if (m != NULL || !lhsHasPercent) {
-	/* Copy the pattern */
-	Buf_AddBytes(buf, len, src);
-}
-
-/* append the rest */
-Buf_AddBytes(buf, strlen(pat), pat);
-}

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.255 src/usr.bin/make/var.c:1.256
--- src/usr.bin/make/var.c:1.255	Sat Jul  4 17:41:04 2020
+++ src/usr.bin/make/var.c	Sun Jul 19 09:26:18 2020
@@ -1,4 +1,4 @@

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

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 09:13:22 UTC 2020

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

Log Message:
make(1): add more tests for :ts modifier


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/modts.exp \
src/usr.bin/make/unit-tests/modts.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/modts.exp
diff -u src/usr.bin/make/unit-tests/modts.exp:1.3 src/usr.bin/make/unit-tests/modts.exp:1.4
--- src/usr.bin/make/unit-tests/modts.exp:1.3	Sun Jul 19 07:08:09 2020
+++ src/usr.bin/make/unit-tests/modts.exp	Sun Jul 19 09:13:22 2020
@@ -39,6 +39,7 @@ B.${AAA:ts}="Baaa" == Baaa?
 :ts :S => aaxBbxaaxbbxaaxbb
 :ts :S space=> axa a axc
 :ts :S space :M => axaxaxaxc
-:ts :S=> axa a axc
-:ts :S :@ => axa a axc
+:ts :S   => axa a axc
+:ts :S :@=> axa a axc
+:ts :S :@ :M => axaxaxaxc
 exit status 0
Index: src/usr.bin/make/unit-tests/modts.mk
diff -u src/usr.bin/make/unit-tests/modts.mk:1.3 src/usr.bin/make/unit-tests/modts.mk:1.4
--- src/usr.bin/make/unit-tests/modts.mk:1.3	Sun Jul 19 07:08:09 2020
+++ src/usr.bin/make/unit-tests/modts.mk	Sun Jul 19 09:13:22 2020
@@ -56,5 +56,8 @@ mod-ts-space:
 	# Not all modifiers behave this way though.  Some of them always use
 	# a space as word separator instead of the :ts separator.
 	# This seems like an oversight during implementation.
-	@${PRINT} ':ts :S=> '${a ababa c:L:tsx:S,b, ,g:Q}
-	@${PRINT} ':ts :S :@ => '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:Q}
+	@${PRINT} ':ts :S   => '${a ababa c:L:tsx:S,b, ,g:Q}
+	@${PRINT} ':ts :S :@=> '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:Q}
+
+	# A final :M* modifier applies the :ts separator again, though.
+	@${PRINT} ':ts :S :@ :M => '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:M*:Q}



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

2020-07-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Jul 19 08:58:35 UTC 2020

Modified Files:
src/sys/arch/mips/cavium: octeon_cpunode.c

Log Message:
KNF whitespace nits.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/mips/cavium/octeon_cpunode.c

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

Modified files:

Index: src/sys/arch/mips/cavium/octeon_cpunode.c
diff -u src/sys/arch/mips/cavium/octeon_cpunode.c:1.14 src/sys/arch/mips/cavium/octeon_cpunode.c:1.15
--- src/sys/arch/mips/cavium/octeon_cpunode.c:1.14	Fri Jul 17 21:59:30 2020
+++ src/sys/arch/mips/cavium/octeon_cpunode.c	Sun Jul 19 08:58:35 2020
@@ -29,7 +29,7 @@
 #define __INTR_PRIVATE
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.14 2020/07/17 21:59:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.15 2020/07/19 08:58:35 simonb Exp $");
 
 #include "locators.h"
 #include "cpunode.h"
@@ -100,7 +100,7 @@ cpunode_mainbus_print(void *aux, const c
 int
 cpunode_mainbus_match(device_t parent, cfdata_t cf, void *aux)
 {
-	
+
 	return 1;
 }
 
@@ -223,6 +223,7 @@ octeon_cpu_init(struct cpu_info *ci)
 static void
 octeon_cpu_run(struct cpu_info *ci)
 {
+
 	octeon_intr_init(ci);
 
 	mips3_initclocks();
@@ -402,12 +403,14 @@ static void
 wdog_cpunode_poke(void *arg)
 {
 	struct cpu_softc *cpu = arg;
+
 	mips3_sd(cpu->cpu_pp_poke, 0);
 }
 
 static int
 wdog_cpunode_tickle(struct sysmon_wdog *smw)
 {
+
 	wdog_cpunode_poke(curcpu()->ci_softc);
 #ifdef MULTIPROCESSOR
 	// We need to send IPIs to the other CPUs to poke their wdog.



CVS commit: src/sys/arch/evbmips/cavium

2020-07-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Jul 19 08:53:24 UTC 2020

Modified Files:
src/sys/arch/evbmips/cavium: machdep.c

Log Message:
Reserve space for all CPU cores (incorrect logic).
Reserve a full page for each core, not incorrect 4096 (from skrll@).


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/evbmips/cavium/machdep.c

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

Modified files:

Index: src/sys/arch/evbmips/cavium/machdep.c
diff -u src/sys/arch/evbmips/cavium/machdep.c:1.19 src/sys/arch/evbmips/cavium/machdep.c:1.20
--- src/sys/arch/evbmips/cavium/machdep.c:1.19	Sun Jul 19 06:31:13 2020
+++ src/sys/arch/evbmips/cavium/machdep.c	Sun Jul 19 08:53:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.19 2020/07/19 06:31:13 simonb Exp $	*/
+/*	$NetBSD: machdep.c,v 1.20 2020/07/19 08:53:24 simonb Exp $	*/
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -114,7 +114,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.19 2020/07/19 06:31:13 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.20 2020/07/19 08:53:24 simonb Exp $");
 
 #include 
 #include 
@@ -371,8 +371,10 @@ mach_init_memory(void)
 	physmem = btoc(octeon_btinfo.obt_dram_size * 1024 * 1024);
 
 #ifdef MULTIPROCESSOR
-	const u_int cores = mipsNN_cp0_ebase_read() & MIPS_EBASE_CPUNUM;
-	mem_clusters[0].start = cores * 4096;
+	const uint64_t fuse = octeon_xkphys_read_8(CIU_FUSE);
+	const int cores = popcount64(fuse);
+	mem_clusters[0].start += cores * PAGE_SIZE;
+	mem_clusters[0].size  -= cores * PAGE_SIZE;
 #endif
 
 	/*



CVS commit: src/sys/arch

2020-07-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jul 19 07:35:08 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/amd64/include: frameasm.h
src/sys/arch/i386/i386: cpufunc.S
src/sys/arch/x86/include: pmap.h
src/sys/arch/x86/x86: svs.c

Log Message:
Revert most of ad's movs/stos change. Instead do a lot simpler: declare
svs_quad_copy() used by SVS only, with no need for instrumentation, because
SVS is disabled when sanitizers are on.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/amd64/include/frameasm.h
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/i386/i386/cpufunc.S
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x86/x86/svs.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.63 src/sys/arch/amd64/amd64/cpufunc.S:1.64
--- src/sys/arch/amd64/amd64/cpufunc.S:1.63	Wed Jun 24 18:09:37 2020
+++ src/sys/arch/amd64/amd64/cpufunc.S	Sun Jul 19 07:35:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.63 2020/06/24 18:09:37 maxv Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.64 2020/07/19 07:35:08 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -446,10 +446,13 @@ ENTRY(outl)
 	ret
 END(outl)
 
-ENTRY(x86_movs)
+/*
+ * Used by SVS only, to make an atomic but fast copy. Doesn't have
+ * sanitizer instrumentation, but sanitizers disable SVS, so no problem.
+ */
+ENTRY(svs_quad_copy)
 	movq	%rdx,%rcx
-	KMSAN_REP_STOS(8)
 	rep
 	movsq
 	ret
-END(x86_movs)
+END(svs_quad_copy)

Index: src/sys/arch/amd64/include/frameasm.h
diff -u src/sys/arch/amd64/include/frameasm.h:1.51 src/sys/arch/amd64/include/frameasm.h:1.52
--- src/sys/arch/amd64/include/frameasm.h:1.51	Sun Jun 21 16:53:37 2020
+++ src/sys/arch/amd64/include/frameasm.h	Sun Jul 19 07:35:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: frameasm.h,v 1.51 2020/06/21 16:53:37 bouyer Exp $	*/
+/*	$NetBSD: frameasm.h,v 1.52 2020/07/19 07:35:08 maxv Exp $	*/
 
 #ifndef _AMD64_MACHINE_FRAMEASM_H
 #define _AMD64_MACHINE_FRAMEASM_H
@@ -276,33 +276,11 @@
 	popq	%rdx			; \
 	popq	%rcx			; \
 	popq	%rax
-#define KMSAN_REP_STOS(scale)	\
-	pushq	%rax			; \
-	pushq	%rcx			; \
-	pushq	%rdx			; \
-	pushq	%rsi			; \
-	pushq	%rdi			; \
-	pushq	%r8			; \
-	pushq	%r9			; \
-	pushq	%r10			; \
-	pushq	%r11			; \
-	leaq	(,%rcx,scale),%rsi	; \
-	callq	_C_LABEL(__msan_instrument_asm_store); \
-	popq	%r11			; \
-	popq	%r10			; \
-	popq	%r9			; \
-	popq	%r8			; \
-	popq	%rdi			; \
-	popq	%rsi			; \
-	popq	%rdx			; \
-	popq	%rcx			; \
-	popq	%rax
 #else
 #define KMSAN_ENTER		/* nothing */
 #define KMSAN_LEAVE		/* nothing */
 #define KMSAN_INIT_ARG(sz)	/* nothing */
 #define KMSAN_INIT_RET(sz)	/* nothing */
-#define	KMSAN_REP_STOS(scale)	/* nothing */
 #endif
 
 #ifdef KCOV

Index: src/sys/arch/i386/i386/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.48 src/sys/arch/i386/i386/cpufunc.S:1.49
--- src/sys/arch/i386/i386/cpufunc.S:1.48	Wed Jun 24 18:09:37 2020
+++ src/sys/arch/i386/i386/cpufunc.S	Sun Jul 19 07:35:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.48 2020/06/24 18:09:37 maxv Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.49 2020/07/19 07:35:08 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2020 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.48 2020/06/24 18:09:37 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.49 2020/07/19 07:35:08 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -353,19 +353,3 @@ ENTRY(outl)
 	outl	%eax, %dx
 	ret
 END(outl)
-
-ENTRY(x86_movs)
-	pushl	%ebp
-	movl	%esp,%ebp
-	pushl	%edi
-	pushl	%esi
-	movl	8(%ebp),%edi
-	movl	12(%ebp),%esi
-	movl	16(%ebp),%ecx
-	rep
-	movsl
-	popl	%esi
-	popl	%edi
-	leave
-	ret
-END(x86_movs)

Index: src/sys/arch/x86/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.124 src/sys/arch/x86/include/pmap.h:1.125
--- src/sys/arch/x86/include/pmap.h:1.124	Tue Jul 14 00:45:53 2020
+++ src/sys/arch/x86/include/pmap.h	Sun Jul 19 07:35:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.124 2020/07/14 00:45:53 yamaguchi Exp $	*/
+/*	$NetBSD: pmap.h,v 1.125 2020/07/19 07:35:08 maxv Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -612,7 +612,7 @@ extern vaddr_t pmap_direct_end;
 
 #endif /* __HAVE_DIRECT_MAP */
 
-void	x86_movs(void *, void *, long);
+void	svs_quad_copy(void *, void *, long);
 
 #endif /* _KERNEL */
 

Index: src/sys/arch/x86/x86/svs.c
diff -u src/sys/arch/x86/x86/svs.c:1.38 src/sys/arch/x86/x86/svs.c:1.39
--- src/sys/arch/x86/x86/svs.c:1.38	Tue Jul 14 00:45:53 2020
+++ src/sys/arch/x86/x86/svs.c	Sun Jul 19 07:35:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: svs.c,v 1.38 2020/07/14 00:45:53 yamaguchi Exp $	*/
+/*	$NetBSD: svs.c,v 

CVS commit: src/sys/crypto/aes/arch/arm

2020-07-19 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Jul 19 07:32:43 UTC 2020

Modified Files:
src/sys/crypto/aes/arch/arm: aes_armv8_64.S

Log Message:
fix build with clang/llvm.

clang aarch64 assembler doesn't accept optional number of lanes of vector 
register.
(but ARMARM says that an assembler must accept it)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/crypto/aes/arch/arm/aes_armv8_64.S

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

Modified files:

Index: src/sys/crypto/aes/arch/arm/aes_armv8_64.S
diff -u src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.4 src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.5
--- src/sys/crypto/aes/arch/arm/aes_armv8_64.S:1.4	Tue Jun 30 23:06:02 2020
+++ src/sys/crypto/aes/arch/arm/aes_armv8_64.S	Sun Jul 19 07:32:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aes_armv8_64.S,v 1.4 2020/06/30 23:06:02 riastradh Exp $	*/
+/*	$NetBSD: aes_armv8_64.S,v 1.5 2020/07/19 07:32:43 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -238,8 +238,8 @@ ENTRY(aesarmv8_setenckey192)
 	 */
 
 	/* v1.4s := (nrk[0], nrk[1], nrk[1], nrk[1]) */
-	dup	v1.4s, v5.4s[3]
-	mov	v1.4s[0], v5.4s[2]
+	dup	v1.4s, v5.s[3]
+	mov	v1.s[0], v5.s[2]
 
 	/*
 	 * v6.4s := (0, 0, rklo[0], rklo[1])
@@ -257,7 +257,7 @@ ENTRY(aesarmv8_setenckey192)
 	 * and v5.4s = (rk[2], rk[3], xxx, xxx).  Set
 	 * v2.4s := (rk[0], rk[1], rk[2], rk[3])
 	 */
-	mov	v2.2d[1], v5.2d[0]
+	mov	v2.d[1], v5.d[0]
 
 	/* store two round keys */
 	stp	q2, q3, [x0], #0x20
@@ -325,7 +325,7 @@ ENTRY(aesarmv8_setenckey192)
 	ext	v5.16b, v0.16b, v4.16b, #12
 
 	/* v2.4s := (nnrk[3], nnrk[3], xxx, xxx) */
-	dup	v2.4s, v1.4s[3]
+	dup	v2.4s, v1.s[3]
 
 	/*
 	 * v2.4s := (nnnrklo[0] = nnrk[3] ^ nrk[2],



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

2020-07-19 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Jul 19 07:18:07 UTC 2020

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

Log Message:
fix build error with LLVM.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S
diff -u src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S:1.6 src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S:1.7
--- src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S:1.6	Wed Jul  1 07:59:16 2020
+++ src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S	Sun Jul 19 07:18:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc_asm_armv8.S,v 1.6 2020/07/01 07:59:16 ryo Exp $	*/
+/*	$NetBSD: cpufunc_asm_armv8.S,v 1.7 2020/07/19 07:18:07 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2014 Robin Randhawa
@@ -43,18 +43,18 @@
  * Macro to handle the cache. This takes the start address in x0, length
  * in x1. It will corrupt x2-x5.
  */
-.macro cache_handle_range dcop = 0, icop = 0
+.macro cache_handle_range dcop = "", icop = ""
 	mrs	x3, ctr_el0
 	mov	x4, #4			/* size of word */
-.if \dcop != 0
+.ifnb \dcop
 	ubfx	x2, x3, #16, #4		/* x2 = D cache shift */
 	lsl	x2, x4, x2		/* x2 = D cache line size */
 .endif
-.if \icop != 0
+.ifnb \icop
 	and	x3, x3, #15		/* x3 = I cache shift */
 	lsl	x3, x4, x3		/* x3 = I cache line size */
 .endif
-.if \dcop != 0
+.ifnb \dcop
 	sub	x4, x2, #1		/* Get the address mask */
 	and	x4, x0, x4		/* Get the low bits of the address */
 	add	x5, x1, x4		/* Add these to the size */
@@ -66,7 +66,7 @@
 	b.hi	1b			/* Check if we are done */
 	dsb	ish
 .endif
-.if \icop != 0
+.ifnb \icop
 	sub	x4, x3, #1		/* Get the address mask */
 	and	x4, x0, x4		/* Get the low bits of the address */
 	add	x5, x1, x4		/* Add these to the size */



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

2020-07-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 07:08:10 UTC 2020

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

Log Message:
make(1): demonstrate inconsistent :ts behavior among modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/modts.exp \
src/usr.bin/make/unit-tests/modts.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/modts.exp
diff -u src/usr.bin/make/unit-tests/modts.exp:1.2 src/usr.bin/make/unit-tests/modts.exp:1.3
--- src/usr.bin/make/unit-tests/modts.exp:1.2	Mon Mar  7 20:20:35 2016
+++ src/usr.bin/make/unit-tests/modts.exp	Sun Jul 19 07:08:09 2020
@@ -36,4 +36,9 @@ LIST:ts/x:tu="\X:tu}"
 FU_mod-ts="a/b/cool"
 FU_mod-ts:ts:T="cool" == cool?
 B.${AAA:ts}="Baaa" == Baaa?
+:ts :S => aaxBbxaaxbbxaaxbb
+:ts :S space=> axa a axc
+:ts :S space :M => axaxaxaxc
+:ts :S=> axa a axc
+:ts :S :@ => axa a axc
 exit status 0
Index: src/usr.bin/make/unit-tests/modts.mk
diff -u src/usr.bin/make/unit-tests/modts.mk:1.2 src/usr.bin/make/unit-tests/modts.mk:1.3
--- src/usr.bin/make/unit-tests/modts.mk:1.2	Mon Mar  7 20:20:35 2016
+++ src/usr.bin/make/unit-tests/modts.mk	Sun Jul 19 07:08:09 2020
@@ -7,7 +7,7 @@ FU_mod-ts = a / b / cool
 AAA= a a a
 B.aaa= Baaa
 
-all:   mod-ts
+all:   mod-ts mod-ts-space
 
 # Use print or printf iff they are builtin.
 # XXX note that this causes problems, when make decides 
@@ -42,3 +42,19 @@ mod-ts:
 	@${PRINT} 'FU_$@="${FU_${@:ts}:ts}"'
 	@${PRINT} 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
 	@${PRINT} 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?'
+
+mod-ts-space:
+	# After the :ts modifier, the whole string is interpreted as a single
+	# word since all spaces have been replaced with x.
+	@${PRINT} ':ts :S => '${aa bb aa bb aa bb:L:tsx:S,b,B,:Q}
+
+	# The :ts modifier also applies to word separators that are added
+	# afterwards.
+	@${PRINT} ':ts :S space=> '${a ababa c:L:tsx:S,b, ,g:Q}
+	@${PRINT} ':ts :S space :M => '${a ababa c:L:tsx:S,b, ,g:M*:Q}
+
+	# Not all modifiers behave this way though.  Some of them always use
+	# a space as word separator instead of the :ts separator.
+	# This seems like an oversight during implementation.
+	@${PRINT} ':ts :S=> '${a ababa c:L:tsx:S,b, ,g:Q}
+	@${PRINT} ':ts :S :@ => '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:Q}



CVS commit: src/sys/dev/nvmm/x86

2020-07-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jul 19 06:56:10 UTC 2020

Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c

Log Message:
Switch to fpu_kern_enter/leave, to prevent clobbering, now that the kernel
itself uses the fpu.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/nvmm/x86/nvmm_x86_svm.c \
src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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

Modified files:

Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.64 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.65
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.64	Sun Jul 19 06:36:37 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c	Sun Jul 19 06:56:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_svm.c,v 1.64 2020/07/19 06:36:37 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_svm.c,v 1.65 2020/07/19 06:56:09 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.64 2020/07/19 06:36:37 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.65 2020/07/19 06:56:09 maxv Exp $");
 
 #include 
 #include 
@@ -1219,7 +1219,7 @@ svm_vcpu_guest_fpu_enter(struct nvmm_cpu
 {
 	struct svm_cpudata *cpudata = vcpu->cpudata;
 
-	fpu_save();
+	fpu_kern_enter();
 	fpu_area_restore(>gfpu, svm_xcr0_mask);
 
 	if (svm_xcr0_mask != 0) {
@@ -1239,6 +1239,7 @@ svm_vcpu_guest_fpu_leave(struct nvmm_cpu
 	}
 
 	fpu_area_save(>gfpu, svm_xcr0_mask);
+	fpu_kern_leave();
 }
 
 static void
Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.64 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.65
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.64	Sun Jul 19 06:36:37 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Sun Jul 19 06:56:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.64 2020/07/19 06:36:37 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.65 2020/07/19 06:56:09 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.64 2020/07/19 06:36:37 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.65 2020/07/19 06:56:09 maxv Exp $");
 
 #include 
 #include 
@@ -1875,7 +1875,7 @@ vmx_vcpu_guest_fpu_enter(struct nvmm_cpu
 {
 	struct vmx_cpudata *cpudata = vcpu->cpudata;
 
-	fpu_save();
+	fpu_kern_enter();
 	fpu_area_restore(>gfpu, vmx_xcr0_mask);
 
 	if (vmx_xcr0_mask != 0) {
@@ -1895,6 +1895,7 @@ vmx_vcpu_guest_fpu_leave(struct nvmm_cpu
 	}
 
 	fpu_area_save(>gfpu, vmx_xcr0_mask);
+	fpu_kern_leave();
 }
 
 static void



CVS commit: src/sys/dev/nvmm/x86

2020-07-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jul 19 06:36:38 UTC 2020

Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_svmfunc.S nvmm_x86_vmx.c
nvmm_x86_vmxfunc.S

Log Message:
The TLB flush IPIs do not respect the IPL, so enforcing IPL_HIGH has no
effect. Disable interrupts earlier instead. This prevents a possible race
against such IPIs.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/nvmm/x86/nvmm_x86_svm.c \
src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/nvmm/x86/nvmm_x86_svmfunc.S \
src/sys/dev/nvmm/x86/nvmm_x86_vmxfunc.S

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

Modified files:

Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.63 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.64
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.63	Fri Jul  3 16:09:54 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c	Sun Jul 19 06:36:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_svm.c,v 1.63 2020/07/03 16:09:54 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_svm.c,v 1.64 2020/07/19 06:36:37 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.63 2020/07/03 16:09:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.64 2020/07/19 06:36:37 maxv Exp $");
 
 #include 
 #include 
@@ -56,6 +56,18 @@ __KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm
 
 int svm_vmrun(paddr_t, uint64_t *);
 
+static inline void
+svm_clgi(void)
+{
+	asm volatile ("clgi" ::: "memory");
+}
+
+static inline void
+svm_stgi(void)
+{
+	asm volatile ("stgi" ::: "memory");
+}
+
 #define	MSR_VM_HSAVE_PA	0xC0010117
 
 /* -- */
@@ -1347,7 +1359,7 @@ svm_vcpu_run(struct nvmm_machine *mach, 
 	struct svm_cpudata *cpudata = vcpu->cpudata;
 	struct vmcb *vmcb = cpudata->vmcb;
 	uint64_t machgen;
-	int hcpu, s;
+	int hcpu;
 
 	if (__predict_false(svm_vcpu_event_commit(vcpu) != 0)) {
 		return EINVAL;
@@ -1382,11 +1394,11 @@ svm_vcpu_run(struct nvmm_machine *mach, 
 			svm_vmcb_cache_flush(vmcb, VMCB_CTRL_VMCB_CLEAN_I);
 		}
 
-		s = splhigh();
+		svm_clgi();
 		machgen = svm_htlb_flush(machdata, cpudata);
 		svm_vmrun(cpudata->vmcb_pa, cpudata->gprs);
 		svm_htlb_flush_ack(cpudata, machgen);
-		splx(s);
+		svm_stgi();
 
 		svm_vmcb_cache_default(vmcb);
 
Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.63 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.64
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.63	Sat Jul 18 20:56:53 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Sun Jul 19 06:36:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.63 2020/07/18 20:56:53 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.64 2020/07/19 06:36:37 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.63 2020/07/18 20:56:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.64 2020/07/19 06:36:37 maxv Exp $");
 
 #include 
 #include 
@@ -178,6 +178,18 @@ vmx_vmclear(paddr_t *pa)
 	);
 }
 
+static inline void
+vmx_cli(void)
+{
+	asm volatile ("cli" ::: "memory");
+}
+
+static inline void
+vmx_sti(void)
+{
+	asm volatile ("sti" ::: "memory");
+}
+
 #define MSR_IA32_FEATURE_CONTROL	0x003A
 #define		IA32_FEATURE_CONTROL_LOCK	__BIT(0)
 #define		IA32_FEATURE_CONTROL_IN_SMX	__BIT(1)
@@ -2043,7 +2055,7 @@ vmx_vcpu_run(struct nvmm_machine *mach, 
 	uint64_t exitcode;
 	uint64_t intstate;
 	uint64_t machgen;
-	int hcpu, s, ret;
+	int hcpu, ret;
 	bool launched;
 
 	vmx_vmcs_enter(vcpu);
@@ -2088,7 +2100,7 @@ vmx_vcpu_run(struct nvmm_machine *mach, 
 			cpudata->gtsc_want_update = false;
 		}
 
-		s = splhigh();
+		vmx_cli();
 		machgen = vmx_htlb_flush(machdata, cpudata);
 		lcr2(cpudata->gcr2);
 		if (launched) {
@@ -2098,7 +2110,7 @@ vmx_vcpu_run(struct nvmm_machine *mach, 
 		}
 		cpudata->gcr2 = rcr2();
 		vmx_htlb_flush_ack(cpudata, machgen);
-		splx(s);
+		vmx_sti();
 
 		if (__predict_false(ret != 0)) {
 			vmx_exit_invalid(exit, -1);

Index: src/sys/dev/nvmm/x86/nvmm_x86_svmfunc.S
diff -u src/sys/dev/nvmm/x86/nvmm_x86_svmfunc.S:1.3 src/sys/dev/nvmm/x86/nvmm_x86_svmfunc.S:1.4
--- src/sys/dev/nvmm/x86/nvmm_x86_svmfunc.S:1.3	Wed Apr 24 18:45:15 2019
+++ src/sys/dev/nvmm/x86/nvmm_x86_svmfunc.S	Sun Jul 19 06:36:37 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: nvmm_x86_svmfunc.S,v 1.3 2019/04/24 18:45:15 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_svmfunc.S,v 1.4 2020/07/19 06:36:37 maxv Exp $	*/
 
 /*
- * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -136,9 +136,6 @@ ENTRY(svm_vmrun)
 	/* Save the Host GPRs. */
 	HOST_SAVE_GPRS
 
-	/* 

CVS commit: src/sys/arch/evbmips/cavium

2020-07-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Jul 19 06:31:13 UTC 2020

Modified Files:
src/sys/arch/evbmips/cavium: machdep.c

Log Message:
Call fdtbus_intr_init() during startup.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/evbmips/cavium/machdep.c

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

Modified files:

Index: src/sys/arch/evbmips/cavium/machdep.c
diff -u src/sys/arch/evbmips/cavium/machdep.c:1.18 src/sys/arch/evbmips/cavium/machdep.c:1.19
--- src/sys/arch/evbmips/cavium/machdep.c:1.18	Thu Jul 16 11:49:37 2020
+++ src/sys/arch/evbmips/cavium/machdep.c	Sun Jul 19 06:31:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.18 2020/07/16 11:49:37 jmcneill Exp $	*/
+/*	$NetBSD: machdep.c,v 1.19 2020/07/19 06:31:13 simonb Exp $	*/
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -114,7 +114,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.18 2020/07/16 11:49:37 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.19 2020/07/19 06:31:13 simonb Exp $");
 
 #include 
 #include 
@@ -154,6 +154,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 
 #include 
+#include 
 
 static void	mach_init_vector(void);
 static void	mach_init_bus_space(void);
@@ -459,6 +460,8 @@ cpu_startup(void)
 	 * that memory allocation is now safe.
 	 */
 	octeon_configuration.mc_mallocsafe = 1;
+
+	fdtbus_intr_init();
 }
 
 void