CVS commit: src/sys

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb 26 07:27:14 UTC 2023

Modified Files:
src/sys/rump/librump/rumpkern: emul.c
src/sys/uvm: uvm_extern.h uvm_km.c

Log Message:
nkmempages should be size_t


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/sys/rump/librump/rumpkern/emul.c
cvs rdiff -u -r1.232 -r1.233 src/sys/uvm/uvm_extern.h
cvs rdiff -u -r1.163 -r1.164 src/sys/uvm/uvm_km.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/rump/librump/rumpkern/emul.c
diff -u src/sys/rump/librump/rumpkern/emul.c:1.196 src/sys/rump/librump/rumpkern/emul.c:1.197
--- src/sys/rump/librump/rumpkern/emul.c:1.196	Thu Apr 30 03:28:19 2020
+++ src/sys/rump/librump/rumpkern/emul.c	Sun Feb 26 07:27:14 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: emul.c,v 1.196 2020/04/30 03:28:19 riastradh Exp $	*/
+/*	$NetBSD: emul.c,v 1.197 2023/02/26 07:27:14 skrll Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.196 2020/04/30 03:28:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.197 2023/02/26 07:27:14 skrll Exp $");
 
 #include 
 #include 
@@ -57,7 +57,7 @@ void (*rump_vfs_fini)(void) = (void *)nu
  */
 #define PHYSMEM 512*256
 psize_t physmem = PHYSMEM;
-int nkmempages = PHYSMEM/2; /* from le chapeau */
+size_t nkmempages = PHYSMEM/2; /* from le chapeau */
 #undef PHYSMEM
 
 struct vnode *rootvp;

Index: src/sys/uvm/uvm_extern.h
diff -u src/sys/uvm/uvm_extern.h:1.232 src/sys/uvm/uvm_extern.h:1.233
--- src/sys/uvm/uvm_extern.h:1.232	Mon May 31 10:57:02 2021
+++ src/sys/uvm/uvm_extern.h	Sun Feb 26 07:27:14 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_extern.h,v 1.232 2021/05/31 10:57:02 riastradh Exp $	*/
+/*	$NetBSD: uvm_extern.h,v 1.233 2023/02/26 07:27:14 skrll Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -840,7 +840,7 @@ bool			uvn_needs_writefault_p(struct uvm
 
 /* kern_malloc.c */
 void			kmeminit_nkmempages(void);
-extern int		nkmempages;
+extern size_t		nkmempages;
 
 #endif /* _KERNEL */
 

Index: src/sys/uvm/uvm_km.c
diff -u src/sys/uvm/uvm_km.c:1.163 src/sys/uvm/uvm_km.c:1.164
--- src/sys/uvm/uvm_km.c:1.163	Sun Feb 12 16:28:32 2023
+++ src/sys/uvm/uvm_km.c	Sun Feb 26 07:27:14 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_km.c,v 1.163 2023/02/12 16:28:32 andvar Exp $	*/
+/*	$NetBSD: uvm_km.c,v 1.164 2023/02/26 07:27:14 skrll Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -152,7 +152,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.163 2023/02/12 16:28:32 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.164 2023/02/26 07:27:14 skrll Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -201,7 +201,7 @@ static struct vm_map		kernel_map_store;
 static struct vm_map_entry	kernel_image_mapent_store;
 static struct vm_map_entry	kernel_kmem_mapent_store;
 
-int nkmempages = 0;
+size_t nkmempages = 0;
 vaddr_t kmembase;
 vsize_t kmemsize;
 
@@ -216,7 +216,7 @@ vmem_t *kmem_va_arena;
 void
 kmeminit_nkmempages(void)
 {
-	int npages;
+	size_t npages;
 
 	if (nkmempages != 0) {
 		/*



CVS commit: src/sys

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb 26 07:27:14 UTC 2023

Modified Files:
src/sys/rump/librump/rumpkern: emul.c
src/sys/uvm: uvm_extern.h uvm_km.c

Log Message:
nkmempages should be size_t


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/sys/rump/librump/rumpkern/emul.c
cvs rdiff -u -r1.232 -r1.233 src/sys/uvm/uvm_extern.h
cvs rdiff -u -r1.163 -r1.164 src/sys/uvm/uvm_km.c

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



CVS commit: src/sys

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb 26 07:13:55 UTC 2023

Modified Files:
src/sys/arch/mips/mips: cpu_subr.c
src/sys/arch/riscv/riscv: trap.c
src/sys/kern: kern_cpu.c
src/sys/uvm/pmap: pmap.c

Log Message:
ci_data.cpu_kcpuset -> ci_kcpuset

NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/mips/mips/cpu_subr.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/riscv/riscv/trap.c
cvs rdiff -u -r1.93 -r1.94 src/sys/kern/kern_cpu.c
cvs rdiff -u -r1.74 -r1.75 src/sys/uvm/pmap/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/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.62 src/sys/arch/mips/mips/cpu_subr.c:1.63
--- src/sys/arch/mips/mips/cpu_subr.c:1.62	Wed Jul 20 10:07:49 2022
+++ src/sys/arch/mips/mips/cpu_subr.c	Sun Feb 26 07:13:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_subr.c,v 1.62 2022/07/20 10:07:49 riastradh Exp $	*/
+/*	$NetBSD: cpu_subr.c,v 1.63 2023/02/26 07:13:54 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.62 2022/07/20 10:07:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.63 2023/02/26 07:13:54 skrll Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -656,11 +656,11 @@ cpu_multicast_ipi(const kcpuset_t *kcp, 
 	struct cpu_info * const ci = curcpu();
 	kcpuset_t *kcp2 = ci->ci_multicastcpus;
 
-	if (kcpuset_match(cpus_running, ci->ci_data.cpu_kcpuset))
+	if (kcpuset_match(cpus_running, ci->ci_kcpuset))
 		return;
 
 	kcpuset_copy(kcp2, kcp);
-	kcpuset_remove(kcp2, ci->ci_data.cpu_kcpuset);
+	kcpuset_remove(kcp2, ci->ci_kcpuset);
 	for (cpuid_t cii; (cii = kcpuset_ffs(kcp2)) != 0; ) {
 		kcpuset_clear(kcp2, --cii);
 		(void)cpu_send_ipi(cpu_lookup(cii), tag);
@@ -729,13 +729,13 @@ cpu_halt_others(void)
 	kcpuset_t *kcp;
 
 	// If we are the only CPU running, there's nothing to do.
-	if (kcpuset_match(cpus_running, curcpu()->ci_data.cpu_kcpuset))
+	if (kcpuset_match(cpus_running, curcpu()->ci_kcpuset))
 		return;
 
 	// Get all running CPUs
 	kcpuset_clone(, cpus_running);
 	// Remove ourself
-	kcpuset_remove(kcp, curcpu()->ci_data.cpu_kcpuset);
+	kcpuset_remove(kcp, curcpu()->ci_kcpuset);
 	// Remove any halted CPUs
 	kcpuset_remove(kcp, cpus_halted);
 	// If there are CPUs left, send the IPIs
@@ -792,13 +792,13 @@ cpu_pause_others(void)
 {
 	struct cpu_info * const ci = curcpu();
 
-	if (cold || kcpuset_match(cpus_running, ci->ci_data.cpu_kcpuset))
+	if (cold || kcpuset_match(cpus_running, ci->ci_kcpuset))
 		return;
 
 	kcpuset_t *kcp = ci->ci_ddbcpus;
 
 	kcpuset_copy(kcp, cpus_running);
-	kcpuset_remove(kcp, ci->ci_data.cpu_kcpuset);
+	kcpuset_remove(kcp, ci->ci_kcpuset);
 	kcpuset_remove(kcp, cpus_paused);
 
 	cpu_broadcast_ipi(IPI_SUSPEND);

Index: src/sys/arch/riscv/riscv/trap.c
diff -u src/sys/arch/riscv/riscv/trap.c:1.19 src/sys/arch/riscv/riscv/trap.c:1.20
--- src/sys/arch/riscv/riscv/trap.c:1.19	Sat Oct 15 06:41:43 2022
+++ src/sys/arch/riscv/riscv/trap.c	Sun Feb 26 07:13:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.19 2022/10/15 06:41:43 simonb Exp $	*/
+/*	$NetBSD: trap.c,v 1.20 2023/02/26 07:13:55 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #define	__PMAP_PRIVATE
 #define	__UFETCHSTORE_PRIVATE
 
-__RCSID("$NetBSD: trap.c,v 1.19 2022/10/15 06:41:43 simonb Exp $");
+__RCSID("$NetBSD: trap.c,v 1.20 2023/02/26 07:13:55 skrll Exp $");
 
 #include 
 #include 
@@ -296,7 +296,7 @@ trap_pagefault_fixup(struct trapframe *t
 
 	if (attr & VM_PAGEMD_EXECPAGE)
 		pmap_md_page_syncicache(VM_PAGE_TO_MD(pg),
-		curcpu()->ci_data.cpu_kcpuset);
+		curcpu()->ci_kcpuset);
 
 	return true;
 }

Index: src/sys/kern/kern_cpu.c
diff -u src/sys/kern/kern_cpu.c:1.93 src/sys/kern/kern_cpu.c:1.94
--- src/sys/kern/kern_cpu.c:1.93	Thu Oct  8 09:16:13 2020
+++ src/sys/kern/kern_cpu.c	Sun Feb 26 07:13:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_cpu.c,v 1.93 2020/10/08 09:16:13 rin Exp $	*/
+/*	$NetBSD: kern_cpu.c,v 1.94 2023/02/26 07:13:55 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.93 2020/10/08 09:16:13 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.94 2023/02/26 07:13:55 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_cpu_ucode.h"
@@ -137,8 +137,8 @@ mi_cpu_attach(struct cpu_info *ci)
 	/*
 	 * Create a convenience cpuset of just ourselves.
 	 */
-	kcpuset_create(>ci_data.cpu_kcpuset, true);
-	kcpuset_set(ci->ci_data.cpu_kcpuset, cpu_index(ci));
+	kcpuset_create(>ci_kcpuset, true);
+	kcpuset_set(ci->ci_kcpuset, cpu_index(ci));
 
 	TAILQ_INIT(>ci_data.cpu_ld_locks);
 	__cpu_simple_lock_init(>ci_data.cpu_ld_lock);

Index: src/sys/uvm/pmap/pmap.c
diff -u 

CVS commit: src/sys

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb 26 07:13:55 UTC 2023

Modified Files:
src/sys/arch/mips/mips: cpu_subr.c
src/sys/arch/riscv/riscv: trap.c
src/sys/kern: kern_cpu.c
src/sys/uvm/pmap: pmap.c

Log Message:
ci_data.cpu_kcpuset -> ci_kcpuset

NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/mips/mips/cpu_subr.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/riscv/riscv/trap.c
cvs rdiff -u -r1.93 -r1.94 src/sys/kern/kern_cpu.c
cvs rdiff -u -r1.74 -r1.75 src/sys/uvm/pmap/pmap.c

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



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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 26 06:08:06 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-no-match.mk varmod-order-shuffle.mk
varmod-order.exp varmod-order.mk

Log Message:
tests/make: extend tests for expression modifiers, especially ':N'


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-no-match.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-order-shuffle.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-order.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-order.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-no-match.mk
diff -u src/usr.bin/make/unit-tests/varmod-no-match.mk:1.2 src/usr.bin/make/unit-tests/varmod-no-match.mk:1.3
--- src/usr.bin/make/unit-tests/varmod-no-match.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varmod-no-match.mk	Sun Feb 26 06:08:06 2023
@@ -1,9 +1,97 @@
-# $NetBSD: varmod-no-match.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varmod-no-match.mk,v 1.3 2023/02/26 06:08:06 rillig Exp $
 #
-# Tests for the :N variable modifier, which filters words that do not match
-# the given pattern.
+# Tests for the expression modifier ':N', which filters words that do not
+# match the given pattern.
+
+
+# Keep all words except for 'two'.
+.if ${:U one two three :Ntwo} != "one three"
+.  error
+.endif
+
+# Keep all words except those starting with 't'.
+# See varmod-match.mk for the details of pattern matching.
+.if ${:U one two three four six :Nt*} != "one four six"
+.  error
+.endif
+
+
+# Idiom: normalize whitespace
+#
+# The modifier ':N' can be used with an empty pattern.  As that pattern never
+# matches a word, the only effect is that the string is split into words and
+# then joined again, thereby normalizing whitespace around and between the
+# words.  And even though the 'N' in ':N' might serve as a mnemonic for
+# "normalize whitespace", this idiom is not used in practice, resorting to the
+# much more common ':M*' to "select all words" instead.
+.if ${:U :N} != ""
+.  error
+.endif
+.if ${:U onetwo three :N} != "one two three"
+.  error
+.endif
+.if ${:U onetwo three :M*} != "one two three"
+.  error
+.endif
+
+
+# Idiom: single-word expression equals any of several words or patterns
+#
+# If an expression is guaranteed to consist of a single word, the modifier
+# ':N' can be chained to compare the expression to several words or even
+# patterns in a sequence.  If one of the patterns matches, the final
+# expression will be the empty string.
+#
+.if ${:U word :None:Ntwo:Nthree} != ""
+#  good
+.else
+.  error
+.endif
+.if ${:U two :None:Ntwo:Nthree} != ""
+.  error
+.else
+#  good
+.endif
+#
+# The modifier ':N' is seldom used in general since positive matches with ':M'
+# are easier to grasp.  Chaining the ':N' modifier is even more difficult to
+# grasp due to the many negations involved.
+#
+# The final '!= ""' adds to the confusion because at first glance, the
+# condition may look like '${VAR} != ""', which for a single-word variable is
+# always true.
+#
+# The '!= ""' can be omitted if the expression cannot have the numeric value
+# 0, which is common in practice.  In that form, each ':N' can be pronounced
+# as 'neither' or 'nor', which makes the expression sound more natural.
+#
+.if ${:U word :None:Ntwo:Nthree}
+#  good
+.else
+.  error
+.endif
+.if ${:U two :None:Ntwo:Nthree}
+.  error
+.else
+#  good
+.endif
+#
+# Replacing the '${...} != ""' with '!empty(...)' doesn't improve the
+# situation as the '!' adds another level of negations, and the word 'empty'
+# is a negation on its own, thereby creating a triple negation.  Furthermore,
+# due to the '!empty', the expression to be evaluated no longer starts with
+# '$' and is thus more difficult to spot quickly.
+#
+.if !empty(:U word :None:Ntwo:Nthree)
+#  good
+.else
+.  error
+.endif
+.if !empty(:U two :None:Ntwo:Nthree)
+.  error
+.else
+#  good
+.endif
 
-# TODO: Implementation
 
 all:
-	@:;

Index: src/usr.bin/make/unit-tests/varmod-order-shuffle.mk
diff -u src/usr.bin/make/unit-tests/varmod-order-shuffle.mk:1.7 src/usr.bin/make/unit-tests/varmod-order-shuffle.mk:1.8
--- src/usr.bin/make/unit-tests/varmod-order-shuffle.mk:1.7	Tue Aug  3 04:46:49 2021
+++ src/usr.bin/make/unit-tests/varmod-order-shuffle.mk	Sun Feb 26 06:08:06 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-order-shuffle.mk,v 1.7 2021/08/03 04:46:49 rillig Exp $
+# $NetBSD: varmod-order-shuffle.mk,v 1.8 2023/02/26 06:08:06 rillig Exp $
 #
 # Tests for the :Ox variable modifier, which returns the words of the
 # variable, shuffled.
@@ -6,8 +6,9 @@
 # The variable modifier :Ox is available since 2005-06-01.
 #
 # As of 2020-08-16, make uses random(3) seeded by the current time in seconds.
-# This makes the random numbers completely 

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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 26 06:08:06 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-no-match.mk varmod-order-shuffle.mk
varmod-order.exp varmod-order.mk

Log Message:
tests/make: extend tests for expression modifiers, especially ':N'


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-no-match.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-order-shuffle.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-order.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-order.mk

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



CVS commit: src/usr.bin/make

2023-02-25 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Feb 25 22:52:22 UTC 2023

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

Log Message:
meta.c: use macro to access job->bm

and if job is NULL use Mybm.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 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.



CVS commit: src/usr.bin/make

2023-02-25 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Feb 25 22:52:22 UTC 2023

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

Log Message:
meta.c: use macro to access job->bm

and if job is NULL use Mybm.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 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/meta.c
diff -u src/usr.bin/make/meta.c:1.202 src/usr.bin/make/meta.c:1.203
--- src/usr.bin/make/meta.c:1.202	Tue Feb 14 21:38:31 2023
+++ src/usr.bin/make/meta.c	Sat Feb 25 22:52:21 2023
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.202 2023/02/14 21:38:31 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.203 2023/02/25 22:52:21 sjg Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -99,6 +99,8 @@ extern char**environ;
 # define strsep(s, d) stresep((s), (d), '\0')
 #endif
 
+#define BM(job) (job != NULL) ? >bm : 
+
 /*
  * Filemon is a kernel module which snoops certain syscalls.
  *
@@ -642,11 +644,7 @@ meta_job_start(Job *job, GNode *gn)
 {
 BuildMon *pbm;
 
-if (job != NULL) {
-	pbm = >bm;
-} else {
-	pbm = 
-}
+pbm = BM(job);
 pbm->mfp = meta_create(pbm, gn);
 #ifdef USE_FILEMON_ONCE
 /* compat mode we open the filemon dev once per command */
@@ -673,11 +671,7 @@ meta_job_child(Job *job MAKE_ATTR_UNUSED
 #ifdef USE_FILEMON
 BuildMon *pbm;
 
-if (job != NULL) {
-	pbm = >bm;
-} else {
-	pbm = 
-}
+pbm = BM(job);
 if (pbm->mfp != NULL) {
 	close(fileno(pbm->mfp));
 	if (useFilemon && pbm->filemon != NULL) {
@@ -698,11 +692,7 @@ meta_job_parent(Job *job MAKE_ATTR_UNUSE
 #if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
 BuildMon *pbm;
 
-if (job != NULL) {
-	pbm = >bm;
-} else {
-	pbm = 
-}
+pbm = BM(job);
 if (useFilemon && pbm->filemon != NULL) {
 	filemon_setpid_parent(pbm->filemon, pid);
 }
@@ -715,11 +705,7 @@ meta_job_fd(Job *job MAKE_ATTR_UNUSED)
 #if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
 BuildMon *pbm;
 
-if (job != NULL) {
-	pbm = >bm;
-} else {
-	pbm = 
-}
+pbm = BM(job);
 if (useFilemon && pbm->filemon != NULL) {
 	return filemon_readfd(pbm->filemon);
 }
@@ -733,11 +719,7 @@ meta_job_event(Job *job MAKE_ATTR_UNUSED
 #if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
 BuildMon *pbm;
 
-if (job != NULL) {
-	pbm = >bm;
-} else {
-	pbm = 
-}
+pbm = BM(job);
 if (useFilemon && pbm->filemon != NULL) {
 	return filemon_process(pbm->filemon);
 }
@@ -751,13 +733,9 @@ meta_job_error(Job *job, GNode *gn, bool
 char cwd[MAXPATHLEN];
 BuildMon *pbm;
 
-if (job != NULL) {
-	pbm = >bm;
-	if (gn == NULL)
+pbm = BM(job);
+if (job != NULL && gn == NULL)
 	gn = job->node;
-} else {
-	pbm = 
-}
 if (pbm->mfp != NULL) {
 	fprintf(pbm->mfp, "\n*** Error code %d%s\n",
 		status, ignerr ? "(ignored)" : "");
@@ -779,11 +757,7 @@ meta_job_output(Job *job, char *cp, cons
 {
 BuildMon *pbm;
 
-if (job != NULL) {
-	pbm = >bm;
-} else {
-	pbm = 
-}
+pbm = BM(job);
 if (pbm->mfp != NULL) {
 	if (metaVerbose) {
 	static char *meta_prefix = NULL;
@@ -851,11 +825,7 @@ meta_job_finish(Job *job)
 int error = 0;
 int x;
 
-if (job != NULL) {
-	pbm = >bm;
-} else {
-	pbm = 
-}
+pbm = BM(job);
 if (pbm->mfp != NULL) {
 	error = meta_cmd_finish(pbm);
 	x = fclose(pbm->mfp);



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

2023-02-25 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Feb 25 19:37:33 UTC 2023

Modified Files:
src/tests/usr.bin/make: t_make.sh

Log Message:
t_make skip varname-dot-make-meta-ignore_*

The meta-ignore tests will likely not work in this environment
so skip them.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/make/t_make.sh

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

Modified files:

Index: src/tests/usr.bin/make/t_make.sh
diff -u src/tests/usr.bin/make/t_make.sh:1.16 src/tests/usr.bin/make/t_make.sh:1.17
--- src/tests/usr.bin/make/t_make.sh:1.16	Thu Jan 19 23:26:15 2023
+++ src/tests/usr.bin/make/t_make.sh	Sat Feb 25 19:37:33 2023
@@ -1,4 +1,4 @@
-# $NetBSD: t_make.sh,v 1.16 2023/01/19 23:26:15 rillig Exp $
+# $NetBSD: t_make.sh,v 1.17 2023/02/25 19:37:33 sjg Exp $
 #
 # Copyright (c) 2008, 2010, 2014, 2023 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -71,6 +71,10 @@ atf_init_test_cases()
 		basename="${filename##*/}"
 		basename="${basename%.mk}"
 
+		case "${basename}" in
+		varname-dot-make-meta-ignore*) continue;; # won't work
+		esac
+
 		atfname=${basename}
 		while :; do
 			case "${atfname}" in



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

2023-02-25 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Feb 25 19:37:33 UTC 2023

Modified Files:
src/tests/usr.bin/make: t_make.sh

Log Message:
t_make skip varname-dot-make-meta-ignore_*

The meta-ignore tests will likely not work in this environment
so skip them.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/make/t_make.sh

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



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

2023-02-25 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Feb 25 19:30:32 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: Makefile meta-ignore.inc
varname-dot-make-meta-ignore_filter.exp
varname-dot-make-meta-ignore_paths.exp
varname-dot-make-meta-ignore_patterns.exp

Log Message:
make: meta-ignore tests will not work if TMPDIR is /tmp

Since /tmp and /var/tmp are always part of .MAKE.META.IGNORE_PATHS
the varname-dot-make-meta-ignore_* tests will not work
if TMPDIR is either (or subdir) of those.


To generate a diff of this commit:
cvs rdiff -u -r1.332 -r1.333 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/meta-ignore.inc
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.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/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.332 src/usr.bin/make/unit-tests/Makefile:1.333
--- src/usr.bin/make/unit-tests/Makefile:1.332	Thu Feb 23 05:20:45 2023
+++ src/usr.bin/make/unit-tests/Makefile	Sat Feb 25 19:30:32 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.332 2023/02/23 05:20:45 sjg Exp $
+# $NetBSD: Makefile,v 1.333 2023/02/25 19:30:32 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -33,6 +33,21 @@
 .MAKE.OS?= ${uname -s:L:sh}
 .MAKE.UID?= ${id -u:L:sh}
 
+# for many tests we need a TMPDIR that will not collide
+# with other users.
+.if ${.OBJDIR} != ${.CURDIR}
+# easy
+TMPDIR:=	${.OBJDIR}/tmp
+.elif defined(TMPDIR)
+TMPDIR:=	${TMPDIR}/uid${.MAKE.UID}
+.else
+TMPDIR:=	/tmp/uid${.MAKE.UID}
+.endif
+# make sure it exists
+.if !exist(${TMPDIR})
+_!= mkdir -p ${TMPDIR}
+.endif
+
 # Each test is in a sub-makefile.
 # Keep the list sorted.
 # Any test that is commented out must be ignored in
@@ -405,7 +420,9 @@ TESTS+=		varname-dot-make-makefiles
 TESTS+=		varname-dot-make-meta-bailiwick
 TESTS+=		varname-dot-make-meta-created
 TESTS+=		varname-dot-make-meta-files
-.if ${.MAKE.PATH_FILEMON:Uno:Nktrace:N/dev*} == ""
+.if ${.MAKE.PATH_FILEMON:Uno:Nktrace:N/dev*} == "" && ${TMPDIR:N/tmp*:N/var/tmp*} != ""
+# these tests will not work if TMPDIR is or is a subdir of
+# /tmp or /var/tmp
 TESTS+=		varname-dot-make-meta-ignore_filter
 TESTS+=		varname-dot-make-meta-ignore_paths
 TESTS+=		varname-dot-make-meta-ignore_patterns
@@ -667,22 +684,6 @@ LC_ALL=		C
 LANG=		C
 .export LANG LC_ALL
 
-
-# for many tests we need a TMPDIR that will not collide
-# with other users.
-.if ${.OBJDIR} != ${.CURDIR}
-# easy
-TMPDIR:=	${.OBJDIR}/tmp
-.elif defined(TMPDIR)
-TMPDIR:=	${TMPDIR}/uid${.MAKE.UID}
-.else
-TMPDIR:=	/tmp/uid${.MAKE.UID}
-.endif
-# make sure it exists
-.if !exist(${TMPDIR})
-_!= mkdir -p ${TMPDIR}
-.endif
-
 # Some Linux systems such as Fedora have deprecated egrep in favor of grep -E.
 .if ${.MAKE.OS:NLinux} == ""
 EGREP= grep -E

Index: src/usr.bin/make/unit-tests/meta-ignore.inc
diff -u src/usr.bin/make/unit-tests/meta-ignore.inc:1.1 src/usr.bin/make/unit-tests/meta-ignore.inc:1.2
--- src/usr.bin/make/unit-tests/meta-ignore.inc:1.1	Thu Feb 23 05:21:27 2023
+++ src/usr.bin/make/unit-tests/meta-ignore.inc	Sat Feb 25 19:30:32 2023
@@ -1,9 +1,11 @@
-# $NetBSD: meta-ignore.inc,v 1.1 2023/02/23 05:21:27 sjg Exp $
+# $NetBSD: meta-ignore.inc,v 1.2 2023/02/25 19:30:32 sjg Exp $
 
 # common logic for testing .MAKE.META.IGNORE_*
 
 # we want a directory outside of .OBJDIR to drop a file
 # that our meta file refers to.
+# Note: these tests will not work if TMPDIR is /tmp or /var/tmp
+# or a subdir thereof
 IGNORE:= ${TMPDIR}/ignore
 OBJ:=	${TMPDIR}/obj
 
@@ -18,11 +20,11 @@ setup:
 	@rm -f ${OBJ}/check-ignore
 
 makefile:= ${.INCLUDEDFROMDIR}/${.INCLUDEDFROMFILE}
-TEST:= ${.INCLUDEDFROMFILE:R}
+TEST:= ${.INCLUDEDFROMFILE:R:C,.*meta-,,:S,-,_,g:tu}
 
 DESC.one= Initialize check-ignore.meta
-DESC.two= Use .MAKE.META.IGNORE_* - check-ignore is up to date
-DESC.three= Skip .MAKE.META.IGNORE_* - check-ignore is out of date
+DESC.two= Use .MAKE.META.${TEST} - check-ignore is up to date
+DESC.three= Skip .MAKE.META.${TEST} - check-ignore is out of date
 
 # just in case someone runs us with -jN
 .ORDER: one two three
@@ -35,16 +37,16 @@ one two three: .MAKE setup
 .MAKE.MODE = meta verbose silent=yes
 .OBJDIR: ${OBJ}
 .if ${parent} == "two"
-.if ${TEST:M*ignore_paths} != ""
+.if ${TEST} == "IGNORE_PATHS"
 # this is a prefix list - any path that matches
 # one of these prefixes will be ignored
 .MAKE.META.IGNORE_PATHS = ${IGNORE}
-.elif ${TEST:M*ignore_patterns} != ""
+.elif ${TEST} == "IGNORE_PATTERNS"
 # more flexible but more expensive
 # this example is equivalent to M*/ignore/*
 # a match means ignore
 .MAKE.META.IGNORE_PATTERNS = */ignore/*
-.elif ${TEST:M*ignore_filter} != ""
+.elif 

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

2023-02-25 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Feb 25 19:30:32 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: Makefile meta-ignore.inc
varname-dot-make-meta-ignore_filter.exp
varname-dot-make-meta-ignore_paths.exp
varname-dot-make-meta-ignore_patterns.exp

Log Message:
make: meta-ignore tests will not work if TMPDIR is /tmp

Since /tmp and /var/tmp are always part of .MAKE.META.IGNORE_PATHS
the varname-dot-make-meta-ignore_* tests will not work
if TMPDIR is either (or subdir) of those.


To generate a diff of this commit:
cvs rdiff -u -r1.332 -r1.333 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/meta-ignore.inc
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp

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



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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 25 19:24:07 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-makeflags.exp
varname-dot-makeflags.mk varname-makeflags.mk

Log Message:
tests/make: clean up tests for MAKEFLAGS and related variables


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/usr.bin/make/unit-tests/varname-dot-makeflags.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk \
src/usr.bin/make/unit-tests/varname-makeflags.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/varname-dot-makeflags.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.5 src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.6
--- src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.5	Sat Feb 25 11:59:12 2023
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.exp	Sat Feb 25 19:24:07 2023
@@ -1,9 +1,9 @@
 make: "varname-dot-makeflags.mk" line 10: MAKEFLAGS=
 make: "varname-dot-makeflags.mk" line 11: .MAKEFLAGS=< -r -k>
 make: "varname-dot-makeflags.mk" line 12: .MAKEOVERRIDES=<>
-make: "varname-dot-makeflags.mk" line 17: MAKEFLAGS=
-make: "varname-dot-makeflags.mk" line 18: .MAKEFLAGS=< -r -k -D VARNAME -r>
-make: "varname-dot-makeflags.mk" line 19: .MAKEOVERRIDES=< VAR>
+make: "varname-dot-makeflags.mk" line 18: MAKEFLAGS=
+make: "varname-dot-makeflags.mk" line 20: .MAKEFLAGS=< -r -k -D VARNAME -r>
+make: "varname-dot-makeflags.mk" line 22: .MAKEOVERRIDES=< VAR>
 runtime: MAKEFLAGS=< -r -k -D VARNAME -r VAR=value>
 runtime: .MAKEFLAGS=< -r -k -D VARNAME -r>
 runtime: .MAKEOVERRIDES=< VAR>

Index: src/usr.bin/make/unit-tests/varname-dot-makeflags.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.6 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.7
--- src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.6	Sat Feb 25 11:59:12 2023
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.mk	Sat Feb 25 19:24:07 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-makeflags.mk,v 1.6 2023/02/25 11:59:12 rillig Exp $
+# $NetBSD: varname-dot-makeflags.mk,v 1.7 2023/02/25 19:24:07 rillig Exp $
 #
 # Tests for the special .MAKEFLAGS variable, which collects almost all
 # command line arguments and passes them on to any child processes via
@@ -14,11 +14,22 @@
 # Append an option with argument, a plain option and a variable assignment.
 .MAKEFLAGS: -DVARNAME -r VAR=value
 
+# expect+1: MAKEFLAGS=
 .info MAKEFLAGS=<${MAKEFLAGS:Uundefined}>
+# expect+1: .MAKEFLAGS=< -r -k -D VARNAME -r>
 .info .MAKEFLAGS=<${.MAKEFLAGS}>
+# expect+1: .MAKEOVERRIDES=< VAR>
 .info .MAKEOVERRIDES=<${.MAKEOVERRIDES}>
 
-# After parsing, the environment variable 'MAKEFLAGS' is set based on
+# The environment variable 'MAKEFLAGS' is not available to child processes
+# when parsing the makefiles.  This is different from exported variables,
+# which are already available during parse time.
+.if ${:!echo "\${MAKEFLAGS-undef}"!} != "undef"
+.  error
+.endif
+
+# After parsing, the environment variable 'MAKEFLAGS' is set based on the
+# special variables '.MAKEFLAGS' and '.MAKEOVERRIDES'.
 runtime:
 	@echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
 	@echo '$@: .MAKEFLAGS=<'${.MAKEFLAGS:Q}'>'
Index: src/usr.bin/make/unit-tests/varname-makeflags.mk
diff -u src/usr.bin/make/unit-tests/varname-makeflags.mk:1.6 src/usr.bin/make/unit-tests/varname-makeflags.mk:1.7
--- src/usr.bin/make/unit-tests/varname-makeflags.mk:1.6	Sat Feb 25 11:59:12 2023
+++ src/usr.bin/make/unit-tests/varname-makeflags.mk	Sat Feb 25 19:24:07 2023
@@ -1,9 +1,11 @@
-# $NetBSD: varname-makeflags.mk,v 1.6 2023/02/25 11:59:12 rillig Exp $
+# $NetBSD: varname-makeflags.mk,v 1.7 2023/02/25 19:24:07 rillig Exp $
 #
-# Tests for the special MAKEFLAGS variable, which is basically just a normal
-# environment variable.  It is closely related to .MAKEFLAGS but captures the
-# state of .MAKEFLAGS at the very beginning of make, before any makefiles are
-# read.
+# Tests for the environment variable 'MAKEFLAGS', from which additional
+# command line arguments are read before the actual command line arguments.
+#
+# After reading the makefiles and before making the targets, the arguments
+# that were collected in '.MAKEFLAGS' and '.MAKEOVERRIDES' are written back to
+# the environment variable 'MAKEFLAGS'.
 
 all: spaces_stage_0 dollars_stage_0 append_stage_0 override_stage_0
 
@@ -11,9 +13,7 @@ all: spaces_stage_0 dollars_stage_0 appe
 .if !make(*stage*)
 
 # The unit tests are run with an almost empty environment.  In particular,
-# the variable MAKEFLAGS is not set.  The '.MAKEFLAGS:' above also doesn't
-# influence the environment variable MAKEFLAGS, therefore it is still
-# undefined at this point.
+# the variable MAKEFLAGS is not set.
 .  if ${MAKEFLAGS:Uundefined} != "undefined"
 .error
 .  endif



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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 25 19:24:07 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-makeflags.exp
varname-dot-makeflags.mk varname-makeflags.mk

Log Message:
tests/make: clean up tests for MAKEFLAGS and related variables


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/usr.bin/make/unit-tests/varname-dot-makeflags.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk \
src/usr.bin/make/unit-tests/varname-makeflags.mk

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



CVS commit: src/sys/arch/i386/i386

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 18:35:54 UTC 2023

Modified Files:
src/sys/arch/i386/i386: genassym.cf locore.S

Log Message:
x86: Add kthread_fpu_enter/exit support, take two -- forgot i386 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.191 -r1.192 src/sys/arch/i386/i386/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/i386/i386/genassym.cf
diff -u src/sys/arch/i386/i386/genassym.cf:1.131 src/sys/arch/i386/i386/genassym.cf:1.132
--- src/sys/arch/i386/i386/genassym.cf:1.131	Tue Dec 27 08:40:40 2022
+++ src/sys/arch/i386/i386/genassym.cf	Sat Feb 25 18:35:54 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.131 2022/12/27 08:40:40 msaitoh Exp $
+#	$NetBSD: genassym.cf,v 1.132 2023/02/25 18:35:54 riastradh Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -175,6 +175,7 @@ define	L_MD_FLAGS		offsetof(struct lwp, 
 define	L_MD_ASTPENDING		offsetof(struct lwp, l_md.md_astpending)
 
 define	LW_SYSTEM		LW_SYSTEM
+define	LW_SYSTEM_FPU		LW_SYSTEM_FPU
 define	MDL_FPU_IN_CPU		MDL_FPU_IN_CPU
 
 define	P_FLAG			offsetof(struct proc, p_flag)

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.191 src/sys/arch/i386/i386/locore.S:1.192
--- src/sys/arch/i386/i386/locore.S:1.191	Fri Feb  3 09:21:58 2023
+++ src/sys/arch/i386/i386/locore.S	Sat Feb 25 18:35:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.191 2023/02/03 09:21:58 mlelstv Exp $	*/
+/*	$NetBSD: locore.S,v 1.192 2023/02/25 18:35:54 riastradh Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.191 2023/02/03 09:21:58 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.192 2023/02/25 18:35:54 riastradh Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1447,7 +1447,7 @@ ENTRY(cpu_switchto)
 
 	/* Don't bother with the rest if switching to a system process. */
 	testl	$LW_SYSTEM,L_FLAG(%edi)
-	jnz	switch_return
+	jnz	.Lswitch_system
 
 #ifndef XENPV
 	/* Restore thread-private %fs/%gs descriptors. */
@@ -1501,6 +1501,21 @@ switch_return:
 	popl	%ebx
 	ret
 
+.Lswitch_system:
+	/*
+	 * If it has LWP_SYSTEM_FPU set, meaning it's running in
+	 * kthread_fpu_enter/exit, we need to restore the FPU state
+	 * and enable FPU instructions with fpu_handle_deferred.
+	 *
+	 * No need to test MDL_FPU_IN_CPU via HANDLE_DEFERRED_FPU --
+	 * fpu_switch guarantees it is clear, so we can just call
+	 * fpu_handle_deferred unconditionally.
+	 */
+	testl	$LW_SYSTEM_FPU,L_FLAG(%edi)
+	jz	switch_return
+	call	_C_LABEL(fpu_handle_deferred)
+	jmp	switch_return
+
 .Lcopy_iobitmap:
 	/* Copy I/O bitmap. */
 	incl	_C_LABEL(pmap_iobmp_evcnt)+EV_COUNT



CVS commit: src/sys/arch/i386/i386

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 18:35:54 UTC 2023

Modified Files:
src/sys/arch/i386/i386: genassym.cf locore.S

Log Message:
x86: Add kthread_fpu_enter/exit support, take two -- forgot i386 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.191 -r1.192 src/sys/arch/i386/i386/locore.S

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



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

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 18:28:57 UTC 2023

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

Log Message:
x86/fpu.c: Sprinkle KNF.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/x86/x86/fpu.c

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

Modified files:

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.82 src/sys/arch/x86/x86/fpu.c:1.83
--- src/sys/arch/x86/x86/fpu.c:1.82	Sat Feb 25 18:04:42 2023
+++ src/sys/arch/x86/x86/fpu.c	Sat Feb 25 18:28:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.82 2023/02/25 18:04:42 riastradh Exp $	*/
+/*	$NetBSD: fpu.c,v 1.83 2023/02/25 18:28:57 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,35 +96,38 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.82 2023/02/25 18:04:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.83 2023/02/25 18:28:57 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
 #include 
-#include 
+#include 
+
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include 
-#include 
+#include 
 #include 
+#include 
 #include 
-#include 
 #include 
-#include 
 #include 
+#include 
+
 #include 
 #include 
 
 #ifdef XENPV
-#define clts() HYPERVISOR_fpu_taskswitch(0)
-#define stts() HYPERVISOR_fpu_taskswitch(1)
+#define	clts()	HYPERVISOR_fpu_taskswitch(0)
+#define	stts()	HYPERVISOR_fpu_taskswitch(1)
 #endif
 
 void fpu_handle_deferred(void);
@@ -179,7 +182,8 @@ fpu_save_lwp(struct lwp *l)
 	s = splvm();
 	if (l->l_md.md_flags & MDL_FPU_IN_CPU) {
 		KASSERT(lwp_can_haz_fpu(l));
-		fpu_area_save(area, x86_xsave_features, !(l->l_proc->p_flag & PK_32));
+		fpu_area_save(area, x86_xsave_features,
+		!(l->l_proc->p_flag & PK_32));
 		l->l_md.md_flags &= ~MDL_FPU_IN_CPU;
 	}
 	splx(s);
@@ -192,12 +196,14 @@ fpu_save_lwp(struct lwp *l)
 void
 fpu_save(void)
 {
+
 	fpu_save_lwp(curlwp);
 }
 
 void
 fpuinit(struct cpu_info *ci)
 {
+
 	/*
 	 * This might not be strictly necessary since it will be initialized
 	 * for each process. However it does no harm.
@@ -278,6 +284,7 @@ fpu_errata_amd(void)
 void
 fpu_area_save(void *area, uint64_t xsave_features, bool is_64bit)
 {
+
 	switch (x86_fpu_save) {
 	case FPU_SAVE_FSAVE:
 		fnsave(area);
@@ -299,6 +306,7 @@ fpu_area_save(void *area, uint64_t xsave
 void
 fpu_area_restore(const void *area, uint64_t xsave_features, bool is_64bit)
 {
+
 	clts();
 
 	switch (x86_fpu_save) {
@@ -323,6 +331,7 @@ void
 fpu_handle_deferred(void)
 {
 	struct pcb *pcb = lwp_getpcb(curlwp);
+
 	fpu_area_restore(>pcb_savefpu, x86_xsave_features,
 	!(curlwp->l_proc->p_flag & PK_32));
 }
@@ -379,7 +388,7 @@ fpu_lwp_abandon(struct lwp *l)
 	splx(s);
 }
 
-/* -- */
+/* - */
 
 static const union savefpu safe_fpu __aligned(64) = {
 	.sv_xmm = {
@@ -428,8 +437,8 @@ fpu_kern_enter(void)
 	ci->ci_kfpu_spl = s;
 
 	/*
-	 * If we are in a softint and have a pinned lwp, the fpu state is that
-	 * of the pinned lwp, so save it there.
+	 * If we are in a softint and have a pinned lwp, the fpu state
+	 * is that of the pinned lwp, so save it there.
 	 */
 	while ((l->l_pflag & LP_INTR) && (l->l_switchto != NULL))
 		l = l->l_switchto;
@@ -513,7 +522,7 @@ kthread_fpu_exit_md(void)
 	stts();
 }
 
-/* -- */
+/* - */
 
 /*
  * The following table is used to ensure that the FPE_... value
@@ -667,6 +676,7 @@ fpudna(struct trapframe *frame)
 static inline void
 fpu_xstate_reload(union savefpu *fpu_save, uint64_t xstate)
 {
+
 	/*
 	 * Force a reload of the given xstate during the next XRSTOR.
 	 */
@@ -865,6 +875,7 @@ process_read_xstate(struct lwp *l, struc
 int
 process_verify_xstate(const struct xstate *xstate)
 {
+
 	/* xstate_bv must be a subset of RFBM */
 	if (xstate->xs_xstate_bv & ~xstate->xs_rfbm)
 		return EINVAL;
@@ -894,8 +905,10 @@ process_write_xstate(struct lwp *l, cons
 
 	/* Convert data into legacy FSAVE format. */
 	if (x86_fpu_save == FPU_SAVE_FSAVE) {
-		if (xstate->xs_xstate_bv & XCR0_X87)
-			process_xmm_to_s87(>xs_fxsave, _save->sv_87);
+		if (xstate->xs_xstate_bv & XCR0_X87) {
+			process_xmm_to_s87(>xs_fxsave,
+			_save->sv_87);
+		}
 		return 0;
 	}
 
@@ -928,15 +941,16 @@ process_write_xstate(struct lwp *l, cons
 		/*
 		 * Invalid bits in mxcsr or mxcsr_mask will cause faults.
 		 */
-		fpu_save->sv_xmm.fx_mxcsr_mask = xstate->xs_fxsave.fx_mxcsr_mask
-		& x86_fpu_mxcsr_mask;
+		fpu_save->sv_xmm.fx_mxcsr_mask =
+		xstate->xs_fxsave.fx_mxcsr_mask & x86_fpu_mxcsr_mask;
 		fpu_save->sv_xmm.fx_mxcsr = 

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

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 18:28:57 UTC 2023

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

Log Message:
x86/fpu.c: Sprinkle KNF.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/x86/x86/fpu.c

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



CVS commit: src/sys/arch

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 18:04:42 UTC 2023

Modified Files:
src/sys/arch/amd64/amd64: genassym.cf locore.S
src/sys/arch/x86/x86: fpu.c

Log Message:
x86: Add kthread_fpu_enter/exit support, take two.

This time, make sure to restore the FPU state when switching to a
kthread in the middle of kthread_fpu_enter/exit.

This adds a single predicted-taken branch for the case of kthreads
that are not in kthread_fpu_enter/exit, so it incurs a penalty only
for threads that actually use it.  Since it avoids FPU state
switching in kthreads that do use the FPU, namely cgd worker threads,
this should be a net performance win on systems using it and have
negligible impact otherwise.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/amd64/amd64/genassym.cf
cvs rdiff -u -r1.215 -r1.216 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/x86/x86/fpu.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/genassym.cf
diff -u src/sys/arch/amd64/amd64/genassym.cf:1.93 src/sys/arch/amd64/amd64/genassym.cf:1.94
--- src/sys/arch/amd64/amd64/genassym.cf:1.93	Tue Dec 27 08:40:40 2022
+++ src/sys/arch/amd64/amd64/genassym.cf	Sat Feb 25 18:04:42 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.93 2022/12/27 08:40:40 msaitoh Exp $
+#	$NetBSD: genassym.cf,v 1.94 2023/02/25 18:04:42 riastradh Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -166,6 +166,7 @@ define	L_MD_FLAGS		offsetof(struct lwp, 
 define	L_MD_ASTPENDING		offsetof(struct lwp, l_md.md_astpending)
 
 define	LW_SYSTEM		LW_SYSTEM
+define	LW_SYSTEM_FPU		LW_SYSTEM_FPU
 define	MDL_IRET		MDL_IRET
 define	MDL_COMPAT32		MDL_COMPAT32
 define	MDL_FPU_IN_CPU		MDL_FPU_IN_CPU

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.215 src/sys/arch/amd64/amd64/locore.S:1.216
--- src/sys/arch/amd64/amd64/locore.S:1.215	Mon Dec 26 17:46:00 2022
+++ src/sys/arch/amd64/amd64/locore.S	Sat Feb 25 18:04:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.215 2022/12/26 17:46:00 christos Exp $	*/
+/*	$NetBSD: locore.S,v 1.216 2023/02/25 18:04:42 riastradh Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1247,7 +1247,7 @@ ENTRY(cpu_switchto)
 
 	/* Don't bother with the rest if switching to a system process. */
 	testl	$LW_SYSTEM,L_FLAG(%r12)
-	jnz	.Lswitch_return
+	jnz	.Lswitch_system
 
 	/* Is this process using RAS (restartable atomic sequences)? */
 	movq	L_PROC(%r12),%rdi
@@ -1336,6 +1336,21 @@ ENTRY(cpu_switchto)
 	popq	%r12
 	popq	%rbx
 	ret
+
+.Lswitch_system:
+	/*
+	 * If it has LWP_SYSTEM_FPU set, meaning it's running in
+	 * kthread_fpu_enter/exit, we need to restore the FPU state
+	 * and enable FPU instructions with fpu_handle_deferred.
+	 *
+	 * No need to test MDL_FPU_IN_CPU via HANDLE_DEFERRED_FPU --
+	 * fpu_switch guarantees it is clear, so we can just call
+	 * fpu_handle_deferred unconditionally.
+	 */
+	testl	$LW_SYSTEM_FPU,L_FLAG(%r12)
+	jz	.Lswitch_return
+	callq	_C_LABEL(fpu_handle_deferred)
+	jmp	.Lswitch_return
 END(cpu_switchto)
 
 /*

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.81 src/sys/arch/x86/x86/fpu.c:1.82
--- src/sys/arch/x86/x86/fpu.c:1.81	Sat Feb 25 18:04:25 2023
+++ src/sys/arch/x86/x86/fpu.c	Sat Feb 25 18:04:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.81 2023/02/25 18:04:25 riastradh Exp $	*/
+/*	$NetBSD: fpu.c,v 1.82 2023/02/25 18:04:42 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.81 2023/02/25 18:04:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.82 2023/02/25 18:04:42 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -107,6 +107,7 @@ __KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.81
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -131,13 +132,35 @@ void fpu_switch(struct lwp *, struct lwp
 
 uint32_t x86_fpu_mxcsr_mask __read_mostly = 0;
 
+/*
+ * True if this a thread that is allowed to use the FPU -- either a
+ * user thread, or a system thread with LW_SYSTEM_FPU enabled.
+ */
+static inline bool
+lwp_can_haz_fpu(struct lwp *l)
+{
+
+	return (l->l_flag & (LW_SYSTEM|LW_SYSTEM_FPU)) != LW_SYSTEM;
+}
+
+/*
+ * True if this is a system thread with its own private FPU state.
+ */
+static inline bool
+lwp_system_fpu_p(struct lwp *l)
+{
+
+	return (l->l_flag & (LW_SYSTEM|LW_SYSTEM_FPU)) ==
+	(LW_SYSTEM|LW_SYSTEM_FPU);
+}
+
 static inline union savefpu *
 fpu_lwp_area(struct lwp *l)
 {
 	struct pcb *pcb = lwp_getpcb(l);
 	union savefpu *area = >pcb_savefpu;
 
-	KASSERT((l->l_flag & LW_SYSTEM) == 0);
+	KASSERT(lwp_can_haz_fpu(l));
 	if (l == curlwp) {
 		fpu_save();
 	}
@@ -155,7 +178,7 @@ fpu_save_lwp(struct lwp *l)
 
 	s = splvm();
 	if (l->l_md.md_flags & MDL_FPU_IN_CPU) {
-		

CVS commit: src/sys/arch

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 18:04:42 UTC 2023

Modified Files:
src/sys/arch/amd64/amd64: genassym.cf locore.S
src/sys/arch/x86/x86: fpu.c

Log Message:
x86: Add kthread_fpu_enter/exit support, take two.

This time, make sure to restore the FPU state when switching to a
kthread in the middle of kthread_fpu_enter/exit.

This adds a single predicted-taken branch for the case of kthreads
that are not in kthread_fpu_enter/exit, so it incurs a penalty only
for threads that actually use it.  Since it avoids FPU state
switching in kthreads that do use the FPU, namely cgd worker threads,
this should be a net performance win on systems using it and have
negligible impact otherwise.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/amd64/amd64/genassym.cf
cvs rdiff -u -r1.215 -r1.216 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/x86/x86/fpu.c

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



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

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 18:04:25 UTC 2023

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

Log Message:
x86: Label boolean is_64bit argument to fpu_area_restore.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/x86/x86/fpu.c

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

Modified files:

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.80 src/sys/arch/x86/x86/fpu.c:1.81
--- src/sys/arch/x86/x86/fpu.c:1.80	Sat Feb 25 13:57:37 2023
+++ src/sys/arch/x86/x86/fpu.c	Sat Feb 25 18:04:25 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.80 2023/02/25 13:57:37 riastradh Exp $	*/
+/*	$NetBSD: fpu.c,v 1.81 2023/02/25 18:04:25 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.80 2023/02/25 13:57:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.81 2023/02/25 18:04:25 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -416,7 +416,7 @@ fpu_kern_enter(void)
 	/*
 	 * Zero the FPU registers and install safe control words.
 	 */
-	fpu_area_restore(_fpu, x86_xsave_features, false);
+	fpu_area_restore(_fpu, x86_xsave_features, /*is_64bit*/false);
 }
 
 /*
@@ -446,7 +446,7 @@ fpu_kern_leave(void)
 	 * through Spectre-class attacks to userland, even if there are
 	 * no bugs in fpu state management.
 	 */
-	fpu_area_restore(_fpu, x86_xsave_features, false);
+	fpu_area_restore(_fpu, x86_xsave_features, /*is_64bit*/false);
 
 	/*
 	 * Set CR0_TS again so that the kernel can't accidentally use



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

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 18:04:25 UTC 2023

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

Log Message:
x86: Label boolean is_64bit argument to fpu_area_restore.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/x86/x86/fpu.c

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



CVS commit: src/usr.bin/ftp

2023-02-25 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Feb 25 17:37:09 UTC 2023

Modified Files:
src/usr.bin/ftp: ftp.1

Log Message:
ftp(1): better mark up for url vs cd example


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/ftp/ftp.1

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



CVS commit: src/usr.bin/ftp

2023-02-25 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Feb 25 17:37:09 UTC 2023

Modified Files:
src/usr.bin/ftp: ftp.1

Log Message:
ftp(1): better mark up for url vs cd example


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/ftp/ftp.1

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/ftp/ftp.1
diff -u src/usr.bin/ftp/ftp.1:1.149 src/usr.bin/ftp/ftp.1:1.150
--- src/usr.bin/ftp/ftp.1:1.149	Sat Feb 25 13:51:48 2023
+++ src/usr.bin/ftp/ftp.1	Sat Feb 25 17:37:09 2023
@@ -1,4 +1,4 @@
-.\" 	$NetBSD: ftp.1,v 1.149 2023/02/25 13:51:48 uwe Exp $
+.\" 	$NetBSD: ftp.1,v 1.150 2023/02/25 17:37:09 uwe Exp $
 .\"
 .\" Copyright (c) 1996-2023 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -1792,24 +1792,38 @@ and where to use
 For example, the following URLs correspond to the
 equivalents of the indicated commands:
 .Bl -tag -width "ftp://host/%2Fdir1%2Fdir2%2Ffile;
-.It ftp://host/dir1/dir2/file
-.Dq "cd dir1" ,
-.Dq "cd dir2" ,
-.Dq "get file" .
-.It ftp://host/%2Fdir1/dir2/file
-.Dq "cd /dir1" ,
-.Dq "cd dir2" ,
-.Dq "get file" .
-.It ftp://host/dir1%2Fdir2/file
-.Dq "cd dir1/dir2" ,
-.Dq "get file" .
-.It ftp://host/%2Fdir1%2Fdir2/file
-.Dq "cd /dir1/dir2" ,
-.Dq "get file" .
-.It ftp://host/dir1%2Fdir2%2Ffile
-.Dq "get dir1/dir2/file" .
-.It ftp://host/%2Fdir1%2Fdir2%2Ffile
-.Dq "get /dir1/dir2/file" .
+.It Xo \" ftp://host/dir1/dir2/file
+.Sm off
+.Ic ftp:// Ar host
+.Ic / Ar dir1
+.Ic / Ar dir2
+.Ic / Ar file
+.Sm on
+.Xc
+.Ic cd Ar dir1 ,
+.Ic cd Ar dir2 ,
+.Ic get Ar file .
+.It Xo \" ftp://host/%2Fdir1/dir2/file
+.Sm off
+.Ic ftp:// Ar host
+.Ic /%2F Ar dir1
+.Ic / Ar dir2
+.Ic / Ar file
+.Sm on
+.Xc
+.Ic cd / Ns Ar dir1 ,
+.Ic cd Ar dir2 ,
+.Ic get Ar file .
+.It Xo \" ftp://host/dir1%2Fdir2/file
+.Sm off
+.Ic ftp:// Ar host
+.Ic / Ar dir1
+.Ic %2F Ar dir2
+.Ic / Ar file
+.Sm on
+.Xc
+.Ic cd Ar dir1 Ns Ic / Ns Ar dir2 ,
+.Ic get Ar file .
 .El
 .It
 You must have appropriate access permission for each of the



CVS commit: src/sys/arch/x86

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 13:57:37 UTC 2023

Modified Files:
src/sys/arch/x86/include: cpu_extended_state.h
src/sys/arch/x86/x86: fpu.c

Log Message:
x86: Mitigate MXCSR Configuration Dependent Timing in kernel FPU use.

In fpu_kern_enter, make sure all the MXCSR exception status bits are
set when we start using the FPU, so that instructions which exhibit
MCDT are unaffected by it.

While here, zero all the other FPU registers in fpu_kern_enter.

In principle we could skip this step on future CPUs that fix the MCDT
bug, but there's probably not much benefit -- workloads that do a lot
of crypto in the kernel are probably better off using
kthread_fpu_enter or WQ_FPU to skip the fpu_kern_enter/leave cycles
in the first place.

For details, see:
https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/best-practices/mxcsr-configuration-dependent-timing.html


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/include/cpu_extended_state.h
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/x86/x86/fpu.c

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

Modified files:

Index: src/sys/arch/x86/include/cpu_extended_state.h
diff -u src/sys/arch/x86/include/cpu_extended_state.h:1.17 src/sys/arch/x86/include/cpu_extended_state.h:1.18
--- src/sys/arch/x86/include/cpu_extended_state.h:1.17	Wed Jun 26 12:30:13 2019
+++ src/sys/arch/x86/include/cpu_extended_state.h	Sat Feb 25 13:57:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_extended_state.h,v 1.17 2019/06/26 12:30:13 mgorny Exp $	*/
+/*	$NetBSD: cpu_extended_state.h,v 1.18 2023/02/25 13:57:37 riastradh Exp $	*/
 
 #ifndef _X86_CPU_EXTENDED_STATE_H_
 #define _X86_CPU_EXTENDED_STATE_H_
@@ -306,8 +306,15 @@ union savefpu {
  * Bits 13 and 14 are rounding control.
  * Bit 15 is 'flush to zero' - affects underflow.
  * Bits 16-31 must be zero.
+ *
+ * The safe MXCSR is fit for constant-time use, e.g. in crypto.  Some
+ * CPU instructions take input- dependent time if an exception status
+ * bit is not set; __SAFE_MXCSR__ has the exception status bits all set
+ * already to mitigate this.  See:
+ * https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/best-practices/mxcsr-configuration-dependent-timing.html
  */
 #define	__INITIAL_MXCSR__	0x1f80
 #define	__INITIAL_MXCSR_MASK__	0xffbf
+#define	__SAFE_MXCSR__		0x1fbf
 
 #endif /* _X86_CPU_EXTENDED_STATE_H_ */

Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.79 src/sys/arch/x86/x86/fpu.c:1.80
--- src/sys/arch/x86/x86/fpu.c:1.79	Sat Aug 20 11:34:08 2022
+++ src/sys/arch/x86/x86/fpu.c	Sat Feb 25 13:57:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.79 2022/08/20 11:34:08 riastradh Exp $	*/
+/*	$NetBSD: fpu.c,v 1.80 2023/02/25 13:57:37 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.79 2022/08/20 11:34:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.80 2023/02/25 13:57:37 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -373,6 +373,11 @@ fpu_lwp_abandon(struct lwp *l)
 void
 fpu_kern_enter(void)
 {
+	static const union savefpu safe_fpu __aligned(64) = {
+		.sv_xmm = {
+			.fx_mxcsr = __SAFE_MXCSR__,
+		},
+	};
 	struct lwp *l = curlwp;
 	struct cpu_info *ci;
 	int s;
@@ -407,6 +412,11 @@ fpu_kern_enter(void)
 	 * the last FPU usage requiring that we save the FPU state.
 	 */
 	clts();
+
+	/*
+	 * Zero the FPU registers and install safe control words.
+	 */
+	fpu_area_restore(_fpu, x86_xsave_features, false);
 }
 
 /*



CVS commit: src/sys/arch/x86

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 13:57:37 UTC 2023

Modified Files:
src/sys/arch/x86/include: cpu_extended_state.h
src/sys/arch/x86/x86: fpu.c

Log Message:
x86: Mitigate MXCSR Configuration Dependent Timing in kernel FPU use.

In fpu_kern_enter, make sure all the MXCSR exception status bits are
set when we start using the FPU, so that instructions which exhibit
MCDT are unaffected by it.

While here, zero all the other FPU registers in fpu_kern_enter.

In principle we could skip this step on future CPUs that fix the MCDT
bug, but there's probably not much benefit -- workloads that do a lot
of crypto in the kernel are probably better off using
kthread_fpu_enter or WQ_FPU to skip the fpu_kern_enter/leave cycles
in the first place.

For details, see:
https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/best-practices/mxcsr-configuration-dependent-timing.html


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/include/cpu_extended_state.h
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/x86/x86/fpu.c

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



CVS commit: src/sys/arch/i386/i386

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 13:52:09 UTC 2023

Modified Files:
src/sys/arch/i386/i386: bioscall.S

Log Message:
i386/bioscall: Disable preemption while we load the kernel pmap.

Fixes crash on boot in new KASSERT(kpreempt_disabled()) in
cpu_load_pmap.

We could do KASSERT(kpreempt_disabled() || cold), but I don't know if
bioscall is ever reachable after warm boot; this way is safer.

XXX Would be nice if bioscall were a C function, not asm -- I don't
see any reason why we need it to be asm?


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

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



CVS commit: src/sys/arch/i386/i386

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 13:52:09 UTC 2023

Modified Files:
src/sys/arch/i386/i386: bioscall.S

Log Message:
i386/bioscall: Disable preemption while we load the kernel pmap.

Fixes crash on boot in new KASSERT(kpreempt_disabled()) in
cpu_load_pmap.

We could do KASSERT(kpreempt_disabled() || cold), but I don't know if
bioscall is ever reachable after warm boot; this way is safer.

XXX Would be nice if bioscall were a C function, not asm -- I don't
see any reason why we need it to be asm?


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/i386/bioscall.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/i386/i386/bioscall.S
diff -u src/sys/arch/i386/i386/bioscall.S:1.10 src/sys/arch/i386/i386/bioscall.S:1.11
--- src/sys/arch/i386/i386/bioscall.S:1.10	Sat Jul 14 14:29:40 2018
+++ src/sys/arch/i386/i386/bioscall.S	Sat Feb 25 13:52:09 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: bioscall.S,v 1.10 2018/07/14 14:29:40 maxv Exp $ */
+/*	$NetBSD: bioscall.S,v 1.11 2023/02/25 13:52:09 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bioscall.S,v 1.10 2018/07/14 14:29:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bioscall.S,v 1.11 2023/02/25 13:52:09 riastradh Exp $");
 
 #include 
 
@@ -67,6 +67,8 @@ ENTRY(bioscall)
 	pushl	%ebp
 	movl	%esp,%ebp		/* set up frame ptr */
 
+	call	_C_LABEL(kpreempt_disable)
+
 	/* install lwp0 pmap */
 	movl	_C_LABEL(kernel_pmap_ptr),%eax
 	pushl	%eax
@@ -85,5 +87,7 @@ ENTRY(bioscall)
 	call	_C_LABEL(cpu_load_pmap)
 	addl	$4,%esp
 
+	call	_C_LABEL(kpreempt_enable)
+
 	leave
 	ret



CVS commit: src/usr.bin/ftp

2023-02-25 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Feb 25 13:51:48 UTC 2023

Modified Files:
src/usr.bin/ftp: ftp.1

Log Message:
ftp(1): minor markup tweaks

Use .Ql instead of .Sq Li, add some missing ones.  Use .Pq instead of
explicit () for longer phrases - these are easier to read in the
postscript output b/c of extra spacing.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/usr.bin/ftp/ftp.1

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/ftp/ftp.1
diff -u src/usr.bin/ftp/ftp.1:1.148 src/usr.bin/ftp/ftp.1:1.149
--- src/usr.bin/ftp/ftp.1:1.148	Sat Feb 25 12:07:25 2023
+++ src/usr.bin/ftp/ftp.1	Sat Feb 25 13:51:48 2023
@@ -1,4 +1,4 @@
-.\" 	$NetBSD: ftp.1,v 1.148 2023/02/25 12:07:25 mlelstv Exp $
+.\" 	$NetBSD: ftp.1,v 1.149 2023/02/25 13:51:48 uwe Exp $
 .\"
 .\" Copyright (c) 1996-2023 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -77,9 +77,9 @@
 .Oo
 .Fl T Xo
 .Sm off
-.Ar dir ,
+.Ar dir Cm \&,
 .Ar max
-.Op , Ar inc
+.Op Cm \&, Ar inc
 .Sm on
 .Xc
 .Oc
@@ -239,11 +239,14 @@ will check the
 an account on the remote machine.
 If no entry exists,
 .Nm
-will prompt for the remote machine login name (default is the user
-identity on the local machine), and, if necessary, prompt for a password
+will prompt for the remote machine login name
+.Pq default is the user identity on the local machine ,
+and, if necessary, prompt for a password
 and an account with which to login.
 To override the auto-login for auto-fetch transfers, specify the
-username (and optionally, password) as appropriate.
+username
+.Pq and optionally, password
+as appropriate.
 .It Fl o Ar output
 When auto-fetching files, save the contents in
 .Ar output .
@@ -254,9 +257,9 @@ below.
 If
 .Ar output
 is not
-.Sq -
+.Sq Fl
 or doesn't start with
-.Sq \&| ,
+.Sq Cm \&| ,
 then only the first file specified will be retrieved into
 .Ar output ;
 all other files will be retrieved into the basename of their
@@ -286,7 +289,7 @@ Uses
 as the local IP address for all connections.
 .It Fl t
 Enables packet tracing.
-.It Fl T Ar direction Ns , Ns Ar maximum Ns Oo , Ns Ar increment Oc
+.It Fl T Ar direction Ns Cm \&, Ns Ar maximum\| Ns Oo Cm \&, Ns Ar increment Oc
 Set the maximum transfer rate for
 .Ar direction
 to
@@ -304,9 +307,10 @@ Upload files on the command line to
 where
 .Ar url
 is one of the
-.Sq Li ftp://
+.Ql ftp://
 URL types as supported by auto-fetch
-(with an optional target filename for single file uploads), and
+.Pq with an optional target filename for single file uploads ,
+and
 .Ar file
 is one or more local files to be uploaded.
 .It Fl V
@@ -320,10 +324,13 @@ Enable
 .Ic verbose
 and
 .Ic progress .
-This is the default if output is to a terminal (and in the case of
+This is the default if output is to a terminal
+.Po
+and in the case of
 .Ic progress ,
 .Nm
-is the foreground process).
+is the foreground process
+.Pc .
 Forces
 .Nm
 to show all responses from the remote server, as well
@@ -334,7 +341,7 @@ Set the size of the socket send and rece
 Refer to
 .Ic xferbuf
 for more information.
-.It Fl ?
+.It Fl \&?
 Display help to stdout, and exit.
 .El
 .Pp
@@ -356,7 +363,7 @@ is awaiting commands from the user the p
 is provided to the user.
 The following commands are recognized
 by
-.Nm ftp :
+.Nm :
 .Bl -tag -width Ic
 .It Ic \&! Op Ar command Op Ar args
 Invoke an interactive shell on the local machine.
@@ -454,7 +461,7 @@ sequence to conform with the
 single linefeed record
 delimiter.
 Records on
-.Pf non\- Ns Ux
+.Pf non\- Ux
 remote systems may contain single linefeeds;
 when an ascii type transfer is made, these linefeeds may be
 distinguished from a record delimiter only when
@@ -527,9 +534,8 @@ is executed again.
 A synonym for
 .Ic bye .
 .It Ic features
-Display what features the remote server supports (using the
-.Dv FEAT
-command).
+Display what features the remote server supports
+.Pq using the Dv FEAT No command .
 .It Ic fget Ar localfile
 Retrieve the files listed in
 .Ar localfile ,
@@ -541,7 +547,7 @@ to
 .Ar format .
 The default (and only supported)
 format is
-.Dq non-print .
+.Ql non-print .
 .It Ic ftp Ar host Op Ar port
 A synonym for
 .Ic open .
@@ -551,9 +557,11 @@ TIS FWTK and Gauntlet
 .Tn FTP
 proxies.
 This will not be permitted if the gate-ftp server hasn't been set
-(either explicitly by the user, or from the
+.Po
+either explicitly by the user, or from the
 .Ev FTPSERVER
-environment variable).
+environment variable
+.Pc .
 If
 .Ar host
 is given,
@@ -625,7 +633,7 @@ transferring a
 archive of the subtree (in binary mode).
 .It Ic hash Op Ar size
 Toggle hash-sign
-.Pq Sq #
+.Pq Ql #
 printing for each data block transferred.
 The size of a data block defaults to 1024 bytes.
 This can be changed by specifying
@@ -675,16 +683,24 @@ A synonym for
 Define a macro.
 Subsequent lines are stored as the macro
 .Ar macro-name  ;
-a null line 

CVS commit: src/usr.bin/ftp

2023-02-25 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Feb 25 13:51:48 UTC 2023

Modified Files:
src/usr.bin/ftp: ftp.1

Log Message:
ftp(1): minor markup tweaks

Use .Ql instead of .Sq Li, add some missing ones.  Use .Pq instead of
explicit () for longer phrases - these are easier to read in the
postscript output b/c of extra spacing.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/usr.bin/ftp/ftp.1

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



CVS commit: src/sys/external/bsd/common/include/asm

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 12:23:36 UTC 2023

Modified Files:
src/sys/external/bsd/common/include/asm: barrier.h

Log Message:
linux asm/barrier.h: Fix !MULTIPROCESSOR build.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/common/include/asm/barrier.h

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



CVS commit: src/sys/external/bsd/common/include/asm

2023-02-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Feb 25 12:23:36 UTC 2023

Modified Files:
src/sys/external/bsd/common/include/asm: barrier.h

Log Message:
linux asm/barrier.h: Fix !MULTIPROCESSOR build.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/common/include/asm/barrier.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/external/bsd/common/include/asm/barrier.h
diff -u src/sys/external/bsd/common/include/asm/barrier.h:1.20 src/sys/external/bsd/common/include/asm/barrier.h:1.21
--- src/sys/external/bsd/common/include/asm/barrier.h:1.20	Fri Feb 24 11:02:05 2023
+++ src/sys/external/bsd/common/include/asm/barrier.h	Sat Feb 25 12:23:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: barrier.h,v 1.20 2023/02/24 11:02:05 riastradh Exp $	*/
+/*	$NetBSD: barrier.h,v 1.21 2023/02/25 12:23:36 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -106,8 +106,8 @@
 #  define	smp_mb()			__insn_barrier()
 #  define	smp_wmb()			__insn_barrier()
 #  define	smp_rmb()			__insn_barrier()
-#  define	smp_mb__before_atomic		__nothing
-#  define	smp_mb__after_atomic		__nothing
+#  define	smp_mb__before_atomic()		__nothing
+#  define	smp_mb__after_atomic()		__nothing
 #endif
 
 #endif  /* _ASM_BARRIER_H_ */



CVS commit: src/usr.bin/ftp

2023-02-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 25 12:07:25 UTC 2023

Modified Files:
src/usr.bin/ftp: cmdtab.c extern.h fetch.c ftp.1 main.c ssl.c util.c
version.h

Log Message:
Add option sslnoverify to control validation of SSL certificates.
Add netrc processing to fetch-mode (URL on command line) to enable options and 
autologin
via netrc.
Fix SSL cleanup in some error paths.

Certificate validation is now enabled by default. Set FTPSSLNOVERIFY=1 in 
environment
or configure a corresponding init macro via netrc to not validate certs 
(required if
you haven't installed a required CA certificate for OpenSSL).

Discussed with lukem@ on icb.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/ftp/cmdtab.c
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/ftp/extern.h
cvs rdiff -u -r1.235 -r1.236 src/usr.bin/ftp/fetch.c
cvs rdiff -u -r1.147 -r1.148 src/usr.bin/ftp/ftp.1
cvs rdiff -u -r1.128 -r1.129 src/usr.bin/ftp/main.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/ftp/ssl.c
cvs rdiff -u -r1.165 -r1.166 src/usr.bin/ftp/util.c
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/ftp/version.h

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



CVS commit: src/usr.bin/ftp

2023-02-25 Thread Michael van Elst
(c) 2015 Thomas Klausner 
+ * Copyright (c) 2023 Michael van Elst 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -34,7 +35,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: ssl.c,v 1.12 2022/09/12 15:10:31 christos Exp $");
+__RCSID("$NetBSD: ssl.c,v 1.13 2023/02/25 12:07:25 mlelstv Exp $");
 #endif
 
 #include 
@@ -63,6 +64,11 @@ __RCSID("$NetBSD: ssl.c,v 1.12 2022/09/1
 
 #include "ssl.h"
 
+#include 
+#include 
+#include 
+#include "extern.h"
+
 extern int quit_time, verbose, ftp_debug;
 extern FILE *ttyout;
 
@@ -589,7 +595,7 @@ fetch_start_ssl(int sock, const char *se
 	SSL_CTX *ctx;
 	X509_VERIFY_PARAM *param;
 	int ret, ssl_err;
-	int verify = 0;	// getenv("NO_CERT_VERIFY") == NULL;
+	int verify = !ftp_truthy("sslnoverify", getoptionvalue("sslnoverify"), 0);
 
 	/* Init the SSL library and context */
 	if (!SSL_library_init()){
@@ -618,6 +624,8 @@ fetch_start_ssl(int sock, const char *se
 		if (!X509_VERIFY_PARAM_set1_host(param, servername,
 		strlen(servername))) {
 			fprintf(ttyout, "SSL verification setup failed\n");
+			SSL_free(ssl);
+			SSL_CTX_free(ctx);
 			return NULL;
 		}
 
@@ -628,6 +636,7 @@ fetch_start_ssl(int sock, const char *se
 	SSL_set_fd(ssl, sock);
 	if (!SSL_set_tlsext_host_name(ssl, __UNCONST(servername))) {
 		fprintf(ttyout, "SSL hostname setting failed\n");
+		SSL_free(ssl);
 		SSL_CTX_free(ctx);
 		return NULL;
 	}
@@ -637,6 +646,7 @@ fetch_start_ssl(int sock, const char *se
 		ssl_err != SSL_ERROR_WANT_WRITE) {
 			ERR_print_errors_fp(ttyout);
 			SSL_free(ssl);
+			SSL_CTX_free(ctx);
 			return NULL;
 		}
 	}

Index: src/usr.bin/ftp/util.c
diff -u src/usr.bin/ftp/util.c:1.165 src/usr.bin/ftp/util.c:1.166
--- src/usr.bin/ftp/util.c:1.165	Fri Jan 20 22:08:48 2023
+++ src/usr.bin/ftp/util.c	Sat Feb 25 12:07:25 2023
@@ -1,7 +1,7 @@
-/*	$NetBSD: util.c,v 1.165 2023/01/20 22:08:48 andvar Exp $	*/
+/*	$NetBSD: util.c,v 1.166 2023/02/25 12:07:25 mlelstv Exp $	*/
 
 /*-
- * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997-2023 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -64,7 +64,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: util.c,v 1.165 2023/01/20 22:08:48 andvar Exp $");
+__RCSID("$NetBSD: util.c,v 1.166 2023/02/25 12:07:25 mlelstv Exp $");
 #endif /* not lint */
 
 /*
@@ -1495,6 +1495,26 @@ ftp_poll(struct pollfd *fds, int nfds, i
 	return poll(fds, nfds, timeout);
 }
 
+/*
+ * Evaluate a "boolean" string, accept only "1" as true and "0" as false
+ * Anything else returns the default value.
+ * Warn about an invalid value that isn't empty.
+ */
+int
+ftp_truthy(const char *name, const char *str, int defvalue)
+{
+
+	if (strcmp(str, "1") == 0)
+		return 1;
+	else if (strcmp(str, "0") == 0)
+		return 0;
+
+	if (*str)
+		warn("Option %s must be boolean (1 or 0)\n", name);
+
+	return defvalue;
+}
+
 #ifndef SMALL
 /*
  * malloc() with inbuilt error checking

Index: src/usr.bin/ftp/version.h
diff -u src/usr.bin/ftp/version.h:1.95 src/usr.bin/ftp/version.h:1.96
--- src/usr.bin/ftp/version.h:1.95	Thu Sep 22 03:31:04 2022
+++ src/usr.bin/ftp/version.h	Sat Feb 25 12:07:25 2023
@@ -1,7 +1,7 @@
-/*	$NetBSD: version.h,v 1.95 2022/09/22 03:31:04 lukem Exp $	*/
+/*	$NetBSD: version.h,v 1.96 2023/02/25 12:07:25 mlelstv Exp $	*/
 
 /*-
- * Copyright (c) 1999-2022 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999-2023 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -34,5 +34,5 @@
 #endif
 
 #ifndef FTP_VERSION
-#define	FTP_VERSION	"20220911"
+#define	FTP_VERSION	"20230225"
 #endif



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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 25 11:59:12 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-makeflags.exp
varname-dot-makeflags.mk varname-makeflags.exp varname-makeflags.mk

Log Message:
tests/make: move tests for MAKRFLAGS to the correct file

I had accidentally added these tests to the file for the special
variable '.MAKEFLAGS' instead of the file for the environment variable
'MAKEFLAGS'.  While here, add a basic test that shows how 'MAKEFLAGS' is
built from '.MAKEFLAGS' and '.MAKEOVERRIDES'.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/varname-dot-makeflags.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk \
src/usr.bin/make/unit-tests/varname-makeflags.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varname-makeflags.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/unit-tests/varname-dot-makeflags.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.4 src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.5
--- src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.4	Sat Feb 25 11:11:16 2023
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.exp	Sat Feb 25 11:59:12 2023
@@ -1,21 +1,10 @@
-spaces_stage_0: MAKEFLAGS=< -r -k >
-spaces_stage_0: env MAKEFLAGS=< -r -k >
-spaces_stage_1: MAKEFLAGS=< -r -k -d 0 -D VARNAME WITH SPACES >
-spaces_stage_1: env MAKEFLAGS=< -r -k -d 0 -D VARNAME WITH SPACES >
-dollars_stage_0: MAKEFLAGS=< -r -k >
-dollars_stage_1: env MAKEFLAGS=< -r -k DOLLARS=\$\{varname\}>
-dollars_stage_1: MAKEFLAGS=< -r -k DOLLARS=\{varname\}>
-dollars_stage_1: MAKEFLAGS:q=< -r -k DOLLARS=\{varname\}>
-dollars_stage_2: env MAKEFLAGS=< -r -k DOLLARS=>
-dollars_stage_2: dollars=<>
-dollars_stage_2: MAKEFLAGS=< -r -k DOLLARS=>
-dollars_stage_3: env MAKEFLAGS=< -r -k DOLLARS=>
-dollars_stage_3: dollars=<>
-dollars_stage_3: MAKEFLAGS=< -r -k DOLLARS=>
-append_stage_0: MAKEFLAGS=< -r -k >
-append_stage_1: MAKEFLAGS=< -r -k -D before-0 -D after-0 VAR0=value>
-append_stage_2: MAKEFLAGS=< -r -k -D before-0 -D after-0 -D before-1 -D after-1 VAR0=value VAR1=value>
-append_stage_3: MAKEFLAGS=< -r -k -D before-0 -D after-0 -D before-1 -D after-1 -D before-2 -D after-2 VAR0=value VAR1=value VAR2=value>
-override_stage_1: run MAKEFLAGS=< -r -k STAGE=1 VAR=value>
-override_stage_2: STAGE=<2> VAR=
+make: "varname-dot-makeflags.mk" line 10: MAKEFLAGS=
+make: "varname-dot-makeflags.mk" line 11: .MAKEFLAGS=< -r -k>
+make: "varname-dot-makeflags.mk" line 12: .MAKEOVERRIDES=<>
+make: "varname-dot-makeflags.mk" line 17: MAKEFLAGS=
+make: "varname-dot-makeflags.mk" line 18: .MAKEFLAGS=< -r -k -D VARNAME -r>
+make: "varname-dot-makeflags.mk" line 19: .MAKEOVERRIDES=< VAR>
+runtime: MAKEFLAGS=< -r -k -D VARNAME -r VAR=value>
+runtime: .MAKEFLAGS=< -r -k -D VARNAME -r>
+runtime: .MAKEOVERRIDES=< VAR>
 exit status 0

Index: src/usr.bin/make/unit-tests/varname-dot-makeflags.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.5 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.6
--- src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.5	Sat Feb 25 11:11:16 2023
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.mk	Sat Feb 25 11:59:12 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-makeflags.mk,v 1.5 2023/02/25 11:11:16 rillig Exp $
+# $NetBSD: varname-dot-makeflags.mk,v 1.6 2023/02/25 11:59:12 rillig Exp $
 #
 # Tests for the special .MAKEFLAGS variable, which collects almost all
 # command line arguments and passes them on to any child processes via
@@ -7,143 +7,19 @@
 # See also:
 #	varname-dot-makeoverrides.mk
 
-all: spaces_stage_0 dollars_stage_0 append_stage_0 override_stage_0
+.info MAKEFLAGS=<${MAKEFLAGS:Uundefined}>
+.info .MAKEFLAGS=<${.MAKEFLAGS}>
+.info .MAKEOVERRIDES=<${.MAKEOVERRIDES:Uundefined}>
+
+# Append an option with argument, a plain option and a variable assignment.
+.MAKEFLAGS: -DVARNAME -r VAR=value
+
+.info MAKEFLAGS=<${MAKEFLAGS:Uundefined}>
+.info .MAKEFLAGS=<${.MAKEFLAGS}>
+.info .MAKEOVERRIDES=<${.MAKEOVERRIDES}>
 
-
-# When options are parsed, the option and its argument are appended as
-# separate words to .MAKEFLAGS.  Special characters in the option argument
-# are not quoted though.  It seems to have not been necessary since at least
-# 1993.
-spaces_stage_0:
-	@echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
-	@echo "$@: env MAKEFLAGS=<$$MAKEFLAGS>"
-	@${MAKE} -f ${MAKEFILE} spaces_stage_1 -d0 -D"VARNAME WITH SPACES"
-
-# At this point, the 'VARNAME WITH SPACES' is no longer recognizable as a
-# single command line argument.  In practice, variable names don't contain
-# spaces.
-spaces_stage_1:
-	@echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
-	@echo "$@: env MAKEFLAGS=<$$MAKEFLAGS>"
-
-
-# Demonstrate that '$' characters are altered when they are passed on to child
-# make 

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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 25 11:59:12 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-makeflags.exp
varname-dot-makeflags.mk varname-makeflags.exp varname-makeflags.mk

Log Message:
tests/make: move tests for MAKRFLAGS to the correct file

I had accidentally added these tests to the file for the special
variable '.MAKEFLAGS' instead of the file for the environment variable
'MAKEFLAGS'.  While here, add a basic test that shows how 'MAKEFLAGS' is
built from '.MAKEFLAGS' and '.MAKEOVERRIDES'.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/varname-dot-makeflags.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk \
src/usr.bin/make/unit-tests/varname-makeflags.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varname-makeflags.exp

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



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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 25 11:11:16 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-makeflags.exp
varname-dot-makeflags.mk

Log Message:
tests/make: test that MAKEFLAGS is an environment variable


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/varname-dot-makeflags.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varname-dot-makeflags.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/varname-dot-makeflags.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.3 src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.4
--- src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.3	Sat Feb 25 09:02:45 2023
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.exp	Sat Feb 25 11:11:16 2023
@@ -16,4 +16,6 @@ append_stage_0: MAKEFLAGS=< -r -k >
 append_stage_1: MAKEFLAGS=< -r -k -D before-0 -D after-0 VAR0=value>
 append_stage_2: MAKEFLAGS=< -r -k -D before-0 -D after-0 -D before-1 -D after-1 VAR0=value VAR1=value>
 append_stage_3: MAKEFLAGS=< -r -k -D before-0 -D after-0 -D before-1 -D after-1 -D before-2 -D after-2 VAR0=value VAR1=value VAR2=value>
+override_stage_1: run MAKEFLAGS=< -r -k STAGE=1 VAR=value>
+override_stage_2: STAGE=<2> VAR=
 exit status 0

Index: src/usr.bin/make/unit-tests/varname-dot-makeflags.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.4 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.5
--- src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.4	Sat Feb 25 10:41:14 2023
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.mk	Sat Feb 25 11:11:16 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-makeflags.mk,v 1.4 2023/02/25 10:41:14 rillig Exp $
+# $NetBSD: varname-dot-makeflags.mk,v 1.5 2023/02/25 11:11:16 rillig Exp $
 #
 # Tests for the special .MAKEFLAGS variable, which collects almost all
 # command line arguments and passes them on to any child processes via
@@ -7,7 +7,7 @@
 # See also:
 #	varname-dot-makeoverrides.mk
 
-all: spaces_stage_0 dollars_stage_0 append_stage_0
+all: spaces_stage_0 dollars_stage_0 append_stage_0 override_stage_0
 
 
 # When options are parsed, the option and its argument are appended as
@@ -119,3 +119,31 @@ append_stage_2:
 
 append_stage_3:
 	@echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
+
+
+# Demonstrates the implementation details of 'MAKEFLAGS', in particular that
+# it is an environment variable rather than a global variable.
+override_stage_0:
+	@${MAKE} -f ${MAKEFILE} STAGE=1 VAR=value override_stage_1
+
+.if make(override_stage_1)
+# While parsing the makefiles, 'MAKEFLAGS' is the value of the environment
+# variable, in this case provided by stage 0.
+.  if ${MAKEFLAGS:M*} != "-r -k"
+.error
+.  endif
+MAKEFLAGS=	overridden	# temporarily override it
+.  if ${MAKEFLAGS} != "overridden"
+.error
+.  endif
+.undef MAKEFLAGS		# make the environment variable visible again
+.  if ${MAKEFLAGS:M*} != "-r -k"
+.error
+.  endif
+.endif
+override_stage_1:
+	@echo '$@: run MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
+	@${MAKE} -f ${MAKEFILE} STAGE=2 override_stage_2
+
+override_stage_2:
+	@echo '$@: STAGE=<${STAGE}> VAR=<${VAR}>'



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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 25 11:11:16 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-makeflags.exp
varname-dot-makeflags.mk

Log Message:
tests/make: test that MAKEFLAGS is an environment variable


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/varname-dot-makeflags.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk

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



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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 25 10:41:15 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-makeflags.mk

Log Message:
tests/make: fix explanation for '$' in MAKEFLAGS

My previous interpretation was completely wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varname-dot-makeflags.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/varname-dot-makeflags.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.3 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.4
--- src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.3	Sat Feb 25 09:02:45 2023
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.mk	Sat Feb 25 10:41:14 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-makeflags.mk,v 1.3 2023/02/25 09:02:45 rillig Exp $
+# $NetBSD: varname-dot-makeflags.mk,v 1.4 2023/02/25 10:41:14 rillig Exp $
 #
 # Tests for the special .MAKEFLAGS variable, which collects almost all
 # command line arguments and passes them on to any child processes via
@@ -31,52 +31,65 @@ spaces_stage_1:
 # make processes via MAKEFLAGS.
 dollars_stage_0:
 	@echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
-	# The '' gets parsed as a literal '$$', making the actual variable
-	# value '$${varname}'.
-	#
-	# When Main_ExportMAKEFLAGS adds the variable DOLLARS to MAKEFLAGS, it
-	# first evaluates the variable value, resulting in '${varname}'.
-	#
-	# This value is then escaped as '\$\{varname\}', to ensure that the
-	# variable is later interpreted as a single shell word.
+
+	# The '' becomes a literal '$$' when building the '${MAKE}'
+	# command line, making the actual argument 'DOLLARS=$${varname}'.
+	# At this stage, MAKEFLAGS is not yet involved.
 	@${MAKE} -f ${MAKEFILE} dollars_stage_1 DOLLARS='{varname}'
 
-# The environment variable 'MAKEFLAGS' now contains the variable assignment
-# 'DOLLARS=\$\{varname\}', including the backslashes.
-#
-# expect: dollars_stage_1: env MAKEFLAGS=< -r -k DOLLARS=\$\{varname\}>
-#
-# When Main_ParseArgLine calls Str_Words to parse the flags from MAKEFLAGS, it
-# removes the backslashes, resulting in the plain variable assignment
-# 'DOLLARS=${varname}'.
+.if make(dollars_stage_1)
+# At this point, the variable 'DOLLARS' contains '$${varname}', which
+# evaluates to a literal '$' followed by '{varname}'.
+.  if ${DOLLARS} != "\${varname}"
+.error
+.  endif
+.endif
 dollars_stage_1:
+	# At this point, the stage 1 make provides the environment variable
+	# 'MAKEFLAGS' to its child processes, even if the child process is not
+	# another make.
+	#
+	# expect: dollars_stage_1: env MAKEFLAGS=< -r -k DOLLARS=\$\{varname\}>
+	#
+	# The 'DOLLARS=\$\{varname\}' assignment is escaped so that the stage
+	# 2 make will see it as a single word.
 	@echo "$@: env MAKEFLAGS=<$$MAKEFLAGS>"
 
-	# At this point, evaluating the environment variable 'MAKEFLAGS' has
-	# strange side effects, as the string '\$\{varname\}' is interpreted
+	# At this point, evaluating the environment variable 'MAKEFLAGS' leads
+	# to strange side effects as the string '\$\{varname\}' is interpreted
 	# as:
 	#
-	#	\		a single backslash
+	#	\		a literal string of a single backslash
 	#	$\		the value of the variable named '\'
 	#	{varname\}	a literal string
 	#
 	# Since the variable name '\' is not defined, the resulting value is
-	# '\{varname\}'.
+	# '\{varname\}'.  Make doesn't handle isolated '$' characters in
+	# strings well, instead each '$' has to be part of a '$$' or be part
+	# of a subexpression like '${VAR}'.
 	@echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
 
-	# The modifier ':q' escapes a '$' in the variable value to '$$', but
-	# it's too late, as that modifier applies after the expression has
-	# been evaluated.
+	# The modifier ':q' preserves a '$$' in an expression value instead of
+	# expanding it to a single '$', but it's already too late, as that
+	# modifier applies after the expression has been evaluated.  Except
+	# for debug logging, there is no way to process strings that contain
+	# isolated '$'.
 	@echo '$@: MAKEFLAGS:q=<'${MAKEFLAGS:q}'>'
 
-	# The value of the variable DOLLARS is now '${varname}'.  Since there
-	# is no variable named 'varname', this expression evaluates to ''.
 	@${MAKE} -f ${MAKEFILE} dollars_stage_2
 
-# Uncomment these lines to see the above variable expansions in action.
-#${:U\\}=backslash
-#varname=varvalue
-
+.if make(dollars_stage_2)
+# At this point, the variable 'DOLLARS' contains '${varname}', and since
+# 'varname' is undefined, that expression evaluates to an empty string.
+.  if ${DOLLARS} != ""
+.error
+.  endif
+varname=	varvalue
+.  if ${DOLLARS} != "varvalue"
+.error
+.  endif
+.  undef varname
+.endif
 dollars_stage_2:
 	@echo "$@: env MAKEFLAGS=<$$MAKEFLAGS>"
 	@echo '$@: dollars=<'${DOLLARS:Q}'>'



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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 25 10:41:15 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-makeflags.mk

Log Message:
tests/make: fix explanation for '$' in MAKEFLAGS

My previous interpretation was completely wrong.


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

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



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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 25 09:02:45 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-makeflags.exp
varname-dot-makeflags.mk

Log Message:
tests/make: activate all tests for MAKEFLAGS


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/varname-dot-makeflags.exp \
src/usr.bin/make/unit-tests/varname-dot-makeflags.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/varname-dot-makeflags.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.2 src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.3
--- src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.2	Sat Feb 25 06:54:08 2023
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.exp	Sat Feb 25 09:02:45 2023
@@ -1,3 +1,7 @@
+spaces_stage_0: MAKEFLAGS=< -r -k >
+spaces_stage_0: env MAKEFLAGS=< -r -k >
+spaces_stage_1: MAKEFLAGS=< -r -k -d 0 -D VARNAME WITH SPACES >
+spaces_stage_1: env MAKEFLAGS=< -r -k -d 0 -D VARNAME WITH SPACES >
 dollars_stage_0: MAKEFLAGS=< -r -k >
 dollars_stage_1: env MAKEFLAGS=< -r -k DOLLARS=\$\{varname\}>
 dollars_stage_1: MAKEFLAGS=< -r -k DOLLARS=\{varname\}>
@@ -8,4 +12,8 @@ dollars_stage_2: MAKEFLAGS=< -r -k DOLLA
 dollars_stage_3: env MAKEFLAGS=< -r -k DOLLARS=>
 dollars_stage_3: dollars=<>
 dollars_stage_3: MAKEFLAGS=< -r -k DOLLARS=>
+append_stage_0: MAKEFLAGS=< -r -k >
+append_stage_1: MAKEFLAGS=< -r -k -D before-0 -D after-0 VAR0=value>
+append_stage_2: MAKEFLAGS=< -r -k -D before-0 -D after-0 -D before-1 -D after-1 VAR0=value VAR1=value>
+append_stage_3: MAKEFLAGS=< -r -k -D before-0 -D after-0 -D before-1 -D after-1 -D before-2 -D after-2 VAR0=value VAR1=value VAR2=value>
 exit status 0
Index: src/usr.bin/make/unit-tests/varname-dot-makeflags.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.2 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.3
--- src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.2	Sat Feb 25 06:54:08 2023
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.mk	Sat Feb 25 09:02:45 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-makeflags.mk,v 1.2 2023/02/25 06:54:08 rillig Exp $
+# $NetBSD: varname-dot-makeflags.mk,v 1.3 2023/02/25 09:02:45 rillig Exp $
 #
 # Tests for the special .MAKEFLAGS variable, which collects almost all
 # command line arguments and passes them on to any child processes via
@@ -7,7 +7,7 @@
 # See also:
 #	varname-dot-makeoverrides.mk
 
-all: dollars_stage_0 #spaces_stage_0 dollars_stage_0 append_stage_0
+all: spaces_stage_0 dollars_stage_0 append_stage_0
 
 
 # When options are parsed, the option and its argument are appended as
@@ -26,6 +26,7 @@ spaces_stage_1:
 	@echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>'
 	@echo "$@: env MAKEFLAGS=<$$MAKEFLAGS>"
 
+
 # Demonstrate that '$' characters are altered when they are passed on to child
 # make processes via MAKEFLAGS.
 dollars_stage_0:



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

2023-02-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 25 09:02:45 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-makeflags.exp
varname-dot-makeflags.mk

Log Message:
tests/make: activate all tests for MAKEFLAGS


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/varname-dot-makeflags.exp \
src/usr.bin/make/unit-tests/varname-dot-makeflags.mk

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



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

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:41:37 UTC 2023

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

Log Message:
Convert some assignments into KASSERTs.

l_md is zeroised by lwp_create with

 memset(>l_startzero, 0, sizeof(*l2) -
offsetof(lwp_t, l_startzero));


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/arch/mips/mips/vm_machdep.c

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

Modified files:

Index: src/sys/arch/mips/mips/vm_machdep.c
diff -u src/sys/arch/mips/mips/vm_machdep.c:1.165 src/sys/arch/mips/mips/vm_machdep.c:1.166
--- src/sys/arch/mips/mips/vm_machdep.c:1.165	Thu Sep 29 07:00:46 2022
+++ src/sys/arch/mips/mips/vm_machdep.c	Sat Feb 25 08:41:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.165 2022/09/29 07:00:46 skrll Exp $	*/
+/*	$NetBSD: vm_machdep.c,v 1.166 2023/02/25 08:41:37 skrll Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.165 2022/09/29 07:00:46 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.166 2023/02/25 08:41:37 skrll Exp $");
 
 #include "opt_ddb.h"
 #include "opt_cputype.h"
@@ -93,9 +93,9 @@ cpu_lwp_fork(struct lwp *l1, struct lwp 
 
 	KASSERT(l1 == curlwp || l1 == );
 
-	l2->l_md.md_ss_addr = 0;
-	l2->l_md.md_ss_instr = 0;
-	l2->l_md.md_astpending = 0;
+	KASSERT(l2->l_md.md_ss_addr == 0);
+	KASSERT(l2->l_md.md_ss_instr == 0);
+	KASSERT(l2->l_md.md_astpending == 0);
 
 	/* Copy the PCB from parent. */
 	*pcb2 = *pcb1;



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

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:41:37 UTC 2023

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

Log Message:
Convert some assignments into KASSERTs.

l_md is zeroised by lwp_create with

 memset(>l_startzero, 0, sizeof(*l2) -
offsetof(lwp_t, l_startzero));


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/arch/mips/mips/vm_machdep.c

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



CVS commit: src/sys/arch/hppa/hppa

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:30:31 UTC 2023

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

Log Message:
Convert some assignments into KASSERTs.

l_md is zeroised by lwp_create with

 memset(>l_startzero, 0, sizeof(*l2) -
offsetof(lwp_t, l_startzero));


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/hppa/hppa/vm_machdep.c

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



CVS commit: src/sys/arch/hppa/hppa

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:30:31 UTC 2023

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

Log Message:
Convert some assignments into KASSERTs.

l_md is zeroised by lwp_create with

 memset(>l_startzero, 0, sizeof(*l2) -
offsetof(lwp_t, l_startzero));


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/hppa/hppa/vm_machdep.c

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

Modified files:

Index: src/sys/arch/hppa/hppa/vm_machdep.c
diff -u src/sys/arch/hppa/hppa/vm_machdep.c:1.57 src/sys/arch/hppa/hppa/vm_machdep.c:1.58
--- src/sys/arch/hppa/hppa/vm_machdep.c:1.57	Thu Sep 29 06:39:59 2022
+++ src/sys/arch/hppa/hppa/vm_machdep.c	Sat Feb 25 08:30:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.57 2022/09/29 06:39:59 skrll Exp $	*/
+/*	$NetBSD: vm_machdep.c,v 1.58 2023/02/25 08:30:31 skrll Exp $	*/
 
 /*	$OpenBSD: vm_machdep.c,v 1.64 2008/09/30 18:54:26 miod Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.57 2022/09/29 06:39:59 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.58 2023/02/25 08:30:31 skrll Exp $");
 
 #include 
 #include 
@@ -96,8 +96,8 @@ cpu_lwp_fork(struct lwp *l1, struct lwp 
 	pcb1 = lwp_getpcb(l1);
 	pcb2 = lwp_getpcb(l2);
 
-	l2->l_md.md_astpending = 0;
-	l2->l_md.md_flags = 0;
+	KASSERT(l2->l_md.md_astpending == 0);
+	KASSERT(l2->l_md.md_flags == 0);
 
 	/* Flush the parent LWP out of the FPU. */
 	hppa_fpu_flush(l1);



CVS commit: src/sys/kern

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:22:00 UTC 2023

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/sys/kern/kern_fork.c

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

Modified files:

Index: src/sys/kern/kern_fork.c
diff -u src/sys/kern/kern_fork.c:1.229 src/sys/kern/kern_fork.c:1.230
--- src/sys/kern/kern_fork.c:1.229	Fri Jul  1 09:54:36 2022
+++ src/sys/kern/kern_fork.c	Sat Feb 25 08:22:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_fork.c,v 1.229 2022/07/01 09:54:36 prlw1 Exp $	*/
+/*	$NetBSD: kern_fork.c,v 1.230 2023/02/25 08:22:00 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008, 2019
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.229 2022/07/01 09:54:36 prlw1 Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.230 2023/02/25 08:22:00 skrll Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -644,7 +644,7 @@ child_return(void *arg)
 
 	if ((p->p_slflag & (PSL_TRACED|PSL_TRACEDCHILD)) ==
 	(PSL_TRACED|PSL_TRACEDCHILD)) {
-		eventswitchchild(p, TRAP_CHLD, 
+		eventswitchchild(p, TRAP_CHLD,
 		ISSET(p->p_lflag, PL_PPWAIT) ? PTRACE_VFORK : PTRACE_FORK);
 	}
 



CVS commit: src/sys/kern

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:22:00 UTC 2023

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/sys/kern/kern_fork.c

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



CVS commit: src/sys/arch

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:19:35 UTC 2023

Modified Files:
src/sys/arch/arm/fdt: arm_platform.c
src/sys/arch/evbarm/conf: GENERIC GENERIC64

Log Message:
Restore the ability to have EARLYCONS work for the QEMU virt after
SOC_VIRT got removed.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/arm_platform.c
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/evbarm/conf/GENERIC
cvs rdiff -u -r1.209 -r1.210 src/sys/arch/evbarm/conf/GENERIC64

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/fdt/arm_platform.c
diff -u src/sys/arch/arm/fdt/arm_platform.c:1.5 src/sys/arch/arm/fdt/arm_platform.c:1.6
--- src/sys/arch/arm/fdt/arm_platform.c:1.5	Sat Apr 24 23:36:26 2021
+++ src/sys/arch/arm/fdt/arm_platform.c	Sat Feb 25 08:19:35 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_platform.c,v 1.5 2021/04/24 23:36:26 thorpej Exp $ */
+/* $NetBSD: arm_platform.c,v 1.6 2023/02/25 08:19:35 skrll Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill 
@@ -35,8 +35,10 @@
  *  - Console UART is pre-configured by firmware
  */
 
+#include "opt_console.h"
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arm_platform.c,v 1.5 2021/04/24 23:36:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_platform.c,v 1.6 2023/02/25 08:19:35 skrll Exp $");
 
 #include 
 #include 
@@ -58,6 +60,9 @@ __KERNEL_RCSID(0, "$NetBSD: arm_platform
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 
 #include 
@@ -65,6 +70,31 @@ __KERNEL_RCSID(0, "$NetBSD: arm_platform
 extern struct arm32_bus_dma_tag arm_generic_dma_tag;
 extern struct bus_space arm_generic_bs_tag;
 
+void plcom_platform_early_putchar(char);
+
+#define	ARM_PTOV(p)   (((p) - DEVMAP_ALIGN(uart_base)) + KERNEL_IO_VBASE)
+
+void __noasan
+plcom_platform_early_putchar(char c)
+{
+#ifdef CONSADDR
+	bus_addr_t uart_base = CONSADDR;
+
+	volatile uint32_t *uartaddr = cpu_earlydevice_va_p() ?
+		(volatile uint32_t *)ARM_PTOV(uart_base):
+		(volatile uint32_t *)uart_base;
+
+	while ((le32toh(uartaddr[PL01XCOM_FR / 4]) & PL01X_FR_TXFF) != 0)
+		continue;
+
+	uartaddr[PL01XCOM_DR / 4] = htole32(c);
+	dsb(sy);
+
+	while ((le32toh(uartaddr[PL01XCOM_FR / 4]) & PL01X_FR_TXFE) == 0)
+		continue;
+#endif
+}
+
 static void
 arm_platform_init_attach_args(struct fdt_attach_args *faa)
 {
@@ -87,12 +117,12 @@ arm_platform_devmap(void)
 		DEVMAP_ENTRY(KERNEL_IO_VBASE, 0, PAGE_SIZE),
 		DEVMAP_ENTRY_END
 	};
-	bus_addr_t uart_base;
 
 	const int phandle = fdtbus_get_stdout_phandle();
 	if (phandle <= 0)
 		return devmap_empty;
 
+	bus_addr_t uart_base;
 	if (fdtbus_get_reg(phandle, 0, _base, NULL) != 0)
 		return devmap_empty;
 

Index: src/sys/arch/evbarm/conf/GENERIC
diff -u src/sys/arch/evbarm/conf/GENERIC:1.117 src/sys/arch/evbarm/conf/GENERIC:1.118
--- src/sys/arch/evbarm/conf/GENERIC:1.117	Thu Feb  9 14:09:48 2023
+++ src/sys/arch/evbarm/conf/GENERIC	Sat Feb 25 08:19:35 2023
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC,v 1.117 2023/02/09 14:09:48 abs Exp $
+#	$NetBSD: GENERIC,v 1.118 2023/02/25 08:19:35 skrll Exp $
 #
 #	GENERIC ARM (aarch32) kernel
 #
@@ -78,10 +78,12 @@ options 	MSGBUFSIZE=32768
 #options 	EARLYCONS=tegra, CONSADDR=0x70006300
 
 #options 	EARLYCONS=vexpress, CONSADDR=0x1c09
-#options 	EARLYCONS=virt, CONSADDR=0x0900
 #options 	EARLYCONS=zynq, CONSADDR=0xe0001000
 #options 	EARLYCONS=rk3288, CONSADDR=0xff69
 
+# The QEMU virt machine
+#options 	EARLYCONS=plcom, CONSADDR=0x0900
+
 # Kernel Undefined Behavior Sanitizer (kUBSan). Use UBSAN_ALWAYS_FATAL
 # if you want panics instead of warnings.
 #options 	KUBSAN			# mandatory

Index: src/sys/arch/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.209 src/sys/arch/evbarm/conf/GENERIC64:1.210
--- src/sys/arch/evbarm/conf/GENERIC64:1.209	Sat Feb 11 07:01:32 2023
+++ src/sys/arch/evbarm/conf/GENERIC64	Sat Feb 25 08:19:35 2023
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.209 2023/02/11 07:01:32 mrg Exp $
+#	$NetBSD: GENERIC64,v 1.210 2023/02/25 08:19:35 skrll Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -47,7 +47,9 @@ options 	INCLUDE_CONFIG_FILE
 #options 	EARLYCONS=sunxi, CONSADDR=0x01c28000
 #options 	EARLYCONS=tegra, CONSADDR=0x70006000
 #options 	EARLYCONS=thunderx, CONSADDR=0x87e02400
-#options 	EARLYCONS=virt, CONSADDR=0x0900
+
+# The QEMU virt machine
+#options 	EARLYCONS=plcom, CONSADDR=0x0900
 
 # Hardware management of the Access flag and dirty state (HAFDBS).
 options 	ARMV81_HAFDBS



CVS commit: src/sys/arch

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:19:35 UTC 2023

Modified Files:
src/sys/arch/arm/fdt: arm_platform.c
src/sys/arch/evbarm/conf: GENERIC GENERIC64

Log Message:
Restore the ability to have EARLYCONS work for the QEMU virt after
SOC_VIRT got removed.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/arm_platform.c
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/evbarm/conf/GENERIC
cvs rdiff -u -r1.209 -r1.210 src/sys/arch/evbarm/conf/GENERIC64

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



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

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:05:46 UTC 2023

Modified Files:
src/sys/arch/arm/arm32: bus_dma.c

Log Message:
Don't refer to physical_{start,end} here and just pass minimum (0UL)
address and maximum (~0UL) physical address.  The values are passed
through to uvm_pglistalloc which knows about the RAM ranges.


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/sys/arch/arm/arm32/bus_dma.c

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

Modified files:

Index: src/sys/arch/arm/arm32/bus_dma.c
diff -u src/sys/arch/arm/arm32/bus_dma.c:1.138 src/sys/arch/arm/arm32/bus_dma.c:1.139
--- src/sys/arch/arm/arm32/bus_dma.c:1.138	Tue Oct 11 22:03:37 2022
+++ src/sys/arch/arm/arm32/bus_dma.c	Sat Feb 25 08:05:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.138 2022/10/11 22:03:37 andvar Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.139 2023/02/25 08:05:46 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2020 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include "opt_cputypes.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.138 2022/10/11 22:03:37 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.139 2023/02/25 08:05:46 skrll Exp $");
 
 #include 
 
@@ -1327,9 +1327,6 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
  * by bus-specific DMA memory allocation functions.
  */
 
-extern paddr_t physical_start;
-extern paddr_t physical_end;
-
 int
 _bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
 bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs,
@@ -1359,8 +1356,7 @@ _bus_dmamem_alloc(bus_dma_tag_t t, bus_s
 		}
 	} else {
 		error = _bus_dmamem_alloc_range(t, size, alignment, boundary,
-		segs, nsegs, rsegs, flags, trunc_page(physical_start),
-		trunc_page(physical_end));
+		segs, nsegs, rsegs, flags, 0UL, ~0UL);
 	}
 
 #ifdef DEBUG_DMA



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

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:05:46 UTC 2023

Modified Files:
src/sys/arch/arm/arm32: bus_dma.c

Log Message:
Don't refer to physical_{start,end} here and just pass minimum (0UL)
address and maximum (~0UL) physical address.  The values are passed
through to uvm_pglistalloc which knows about the RAM ranges.


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/sys/arch/arm/arm32/bus_dma.c

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



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

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:00:35 UTC 2023

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

Log Message:
Add a KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/aarch64/aarch64/vm_machdep.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/vm_machdep.c
diff -u src/sys/arch/aarch64/aarch64/vm_machdep.c:1.13 src/sys/arch/aarch64/aarch64/vm_machdep.c:1.14
--- src/sys/arch/aarch64/aarch64/vm_machdep.c:1.13	Sun May 29 16:13:41 2022
+++ src/sys/arch/aarch64/aarch64/vm_machdep.c	Sat Feb 25 08:00:35 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.13 2022/05/29 16:13:41 ryo Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.14 2023/02/25 08:00:35 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.13 2022/05/29 16:13:41 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.14 2023/02/25 08:00:35 skrll Exp $");
 
 #include 
 #include 
@@ -97,6 +97,7 @@ cpu_lwp_fork(struct lwp *l1, struct lwp 
 	 * FP state is valid.
 	 */
 	l2->l_md.md_cpacr = CPACR_FPEN_NONE;
+	KASSERT(l2->l_md.md_astpending == 0);
 
 #ifdef ARMV83_PAC
 	/*



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

2023-02-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Feb 25 08:00:35 UTC 2023

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

Log Message:
Add a KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/aarch64/aarch64/vm_machdep.c

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