CVS commit: src/sys

2020-05-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri May  8 03:26:51 UTC 2020

Modified Files:
src/sys/kern: kern_sleepq.c
src/sys/sys: sleepq.h

Log Message:
Add a new function, sleepq_transfer(), that moves an lwp from one
sleepq to another.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/kern/kern_sleepq.c
cvs rdiff -u -r1.29 -r1.30 src/sys/sys/sleepq.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/kern/kern_sleepq.c
diff -u src/sys/kern/kern_sleepq.c:1.66 src/sys/kern/kern_sleepq.c:1.67
--- src/sys/kern/kern_sleepq.c:1.66	Sun Apr 19 20:35:29 2020
+++ src/sys/kern/kern_sleepq.c	Fri May  8 03:26:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sleepq.c,v 1.66 2020/04/19 20:35:29 ad Exp $	*/
+/*	$NetBSD: kern_sleepq.c,v 1.67 2020/05/08 03:26:51 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.66 2020/04/19 20:35:29 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.67 2020/05/08 03:26:51 thorpej Exp $");
 
 #include 
 #include 
@@ -237,6 +237,38 @@ sleepq_enqueue(sleepq_t *sq, wchan_t wch
 }
 
 /*
+ * sleepq_transfer:
+ *
+ *	Move an LWP from one sleep queue to another.  Both sleep queues
+ *	must already be locked.
+ *
+ *	The LWP will be updated with the new sleepq, wchan, wmesg,
+ *	sobj, and mutex.  The interruptible flag will also be updated.
+ */
+void
+sleepq_transfer(lwp_t *l, sleepq_t *from_sq, sleepq_t *sq, wchan_t wchan,
+const char *wmesg, syncobj_t *sobj, kmutex_t *mp, bool catch_p)
+{
+
+	KASSERT(l->l_sleepq == from_sq);
+
+	LIST_REMOVE(l, l_sleepchain);
+	l->l_syncobj = sobj;
+	l->l_wchan = wchan;
+	l->l_sleepq = sq;
+	l->l_wmesg = wmesg;
+
+	if (catch_p)
+		l->l_flag |= LW_SINTR;
+	else
+		l->l_flag &= ~LW_SINTR;
+
+	lwp_setlock(l, mp);
+
+	sleepq_insert(sq, l, sobj);
+}
+
+/*
  * sleepq_block:
  *
  *	After any intermediate step such as releasing an interlock, switch.

Index: src/sys/sys/sleepq.h
diff -u src/sys/sys/sleepq.h:1.29 src/sys/sys/sleepq.h:1.30
--- src/sys/sys/sleepq.h:1.29	Sun Apr 19 20:35:29 2020
+++ src/sys/sys/sleepq.h	Fri May  8 03:26:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sleepq.h,v 1.29 2020/04/19 20:35:29 ad Exp $	*/
+/*	$NetBSD: sleepq.h,v 1.30 2020/05/08 03:26:51 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019, 2020
@@ -61,7 +61,9 @@ typedef struct sleeptab {
 void	sleepq_init(sleepq_t *);
 void	sleepq_remove(sleepq_t *, lwp_t *);
 void	sleepq_enqueue(sleepq_t *, wchan_t, const char *, struct syncobj *,
-bool);
+	bool);
+void	sleepq_transfer(lwp_t *, sleepq_t *, sleepq_t *, wchan_t, const char *,
+	struct syncobj *, kmutex_t *, bool);
 void	sleepq_unsleep(lwp_t *, bool);
 void	sleepq_timeout(void *);
 void	sleepq_wake(sleepq_t *, wchan_t, u_int, kmutex_t *);



CVS commit: src/sys/kern

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May  8 00:54:44 UTC 2020

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

Log Message:
Eliminate curcpu_available() hack.

The entropy subsystem is no longer used before curcpu() and curlwp
are available on x86.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/kern/kern_entropy.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_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.15 src/sys/kern/kern_entropy.c:1.16
--- src/sys/kern/kern_entropy.c:1.15	Fri May  8 00:53:25 2020
+++ src/sys/kern/kern_entropy.c	Fri May  8 00:54:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.15 2020/05/08 00:53:25 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.16 2020/05/08 00:54:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.15 2020/05/08 00:53:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.16 2020/05/08 00:54:44 riastradh Exp $");
 
 #include 
 #include 
@@ -255,19 +255,6 @@ static void	rndsource_to_user(struct krn
 static void	rndsource_to_user_est(struct krndsource *, rndsource_est_t *);
 
 /*
- * curcpu_available()
- *
- *	True if we can inspect the current CPU.  Early on this may not
- *	work.  XXX On most if not all ports, this should work earlier.
- */
-static inline bool
-curcpu_available(void)
-{
-
-	return true;
-}
-
-/*
  * entropy_timer()
  *
  *	Cycle counter, time counter, or anything that changes a wee bit
@@ -279,10 +266,6 @@ entropy_timer(void)
 	struct bintime bt;
 	uint32_t v;
 
-	/* Very early on, cpu_counter32() may not be available.  */
-	if (!curcpu_available())
-		return 0;
-
 	/* If we have a CPU cycle counter, use the low 32 bits.  */
 #ifdef __HAVE_CPU_COUNTER
 	if (__predict_true(cpu_hascounter()))
@@ -777,7 +760,7 @@ entropy_enter(const void *buf, size_t le
 	uint32_t pending;
 	int s;
 
-	KASSERTMSG(!curcpu_available() || !cpu_intr_p(),
+	KASSERTMSG(!cpu_intr_p(),
 	"use entropy_enter_intr from interrupt context");
 	KASSERTMSG(howmany(nbits, NBBY) <= len,
 	"impossible entropy rate: %u bits in %zu-byte string", nbits, len);
@@ -1268,7 +1251,7 @@ entropy_extract(void *buf, size_t len, i
 		mutex_enter(>lock);
 
 	/* Count up request for entropy in interrupt context.  */
-	if (curcpu_available() && cpu_intr_p())
+	if (cpu_intr_p())
 		entropy_extract_intr_evcnt.ev_count++;
 
 	/* Wait until there is enough entropy in the system.  */
@@ -1627,7 +1610,7 @@ rnd_trylock_sources(void)
 
 	if (E->sourcelock)
 		return false;
-	E->sourcelock = (curcpu_available() ? curlwp : (void *)1);
+	E->sourcelock = curlwp;
 	return true;
 }
 
@@ -1643,9 +1626,8 @@ rnd_unlock_sources(void)
 
 	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
 
-	KASSERTMSG(E->sourcelock == (curcpu_available() ? curlwp : (void *)1),
-	"lwp %p releasing lock held by %p",
-	(curcpu_available() ? curlwp : (void *)1), E->sourcelock);
+	KASSERTMSG(E->sourcelock == curlwp, "lwp %p releasing lock held by %p",
+	curlwp, E->sourcelock);
 	E->sourcelock = NULL;
 	if (E->stage >= ENTROPY_WARM)
 		cv_broadcast(>cv);
@@ -1661,7 +1643,7 @@ static bool __diagused
 rnd_sources_locked(void)
 {
 
-	return E->sourcelock == (curcpu_available() ? curlwp : (void *)1);
+	return E->sourcelock == curlwp;
 }
 
 /*
@@ -1820,7 +1802,7 @@ rnd_add_data_1(struct krndsource *rs, co
 	 * take note of whether it consumed the full sample; if not,
 	 * use entropy_enter, which always consumes the full sample.
 	 */
-	if (curcpu_available() && cpu_intr_p()) {
+	if (curlwp && cpu_intr_p()) {
 		fullyused = entropy_enter_intr(buf, len, entropybits);
 	} else {
 		entropy_enter(buf, len, entropybits);



CVS commit: src/sys/kern

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May  8 00:53:25 UTC 2020

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

Log Message:
Make curcpu_available() always true.

This should work now that x86 runs cpu_init_rng just after curcpu()
and curlwp are initialized, and no other architecture needs it to
work that early.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/kern_entropy.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_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.14 src/sys/kern/kern_entropy.c:1.15
--- src/sys/kern/kern_entropy.c:1.14	Thu May  7 19:07:29 2020
+++ src/sys/kern/kern_entropy.c	Fri May  8 00:53:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.14 2020/05/07 19:07:29 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.15 2020/05/08 00:53:25 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.14 2020/05/07 19:07:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.15 2020/05/08 00:53:25 riastradh Exp $");
 
 #include 
 #include 
@@ -264,7 +264,7 @@ static inline bool
 curcpu_available(void)
 {
 
-	return __predict_true(!cold);
+	return true;
 }
 
 /*



CVS commit: src/sys/arch

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May  8 00:52:29 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/i386/i386: machdep.c

Log Message:
Move cpu_rng_init a little later, just after cpu_init_msrs, on x86.

This way curcpu() and curlwp are available, so that we no longer need
any annoying conditionalization in kern_entropy.c.


To generate a diff of this commit:
cvs rdiff -u -r1.353 -r1.354 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.829 -r1.830 src/sys/arch/i386/i386/machdep.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.353 src/sys/arch/amd64/amd64/machdep.c:1.354
--- src/sys/arch/amd64/amd64/machdep.c:1.353	Fri May  8 00:49:42 2020
+++ src/sys/arch/amd64/amd64/machdep.c	Fri May  8 00:52:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.353 2020/05/08 00:49:42 riastradh Exp $	*/
+/*	$NetBSD: machdep.c,v 1.354 2020/05/08 00:52:29 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.353 2020/05/08 00:49:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.354 2020/05/08 00:52:29 riastradh Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -1702,11 +1702,11 @@ init_x86_64(paddr_t first_avail)
 	uvm_lwp_setuarea(, lwp0uarea);
 
 	cpu_probe(_info_primary);
-	cpu_rng_init();
 #ifdef SVS
 	svs_init();
 #endif
 	cpu_init_msrs(_info_primary, true);
+	cpu_rng_init();
 #ifndef XENPV
 	cpu_speculation_init(_info_primary);
 #endif

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.829 src/sys/arch/i386/i386/machdep.c:1.830
--- src/sys/arch/i386/i386/machdep.c:1.829	Sat May  2 16:44:35 2020
+++ src/sys/arch/i386/i386/machdep.c	Fri May  8 00:52:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.829 2020/05/02 16:44:35 bouyer Exp $	*/
+/*	$NetBSD: machdep.c,v 1.830 2020/05/08 00:52:29 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.829 2020/05/02 16:44:35 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.830 2020/05/08 00:52:29 riastradh Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -1150,8 +1150,8 @@ init386(paddr_t first_avail)
 	uvm_lwp_setuarea(, lwp0uarea);
 
 	cpu_probe(_info_primary);
-	cpu_rng_init();
 	cpu_init_msrs(_info_primary, true);
+	cpu_rng_init();
 #ifndef XENPV
 	cpu_speculation_init(_info_primary);
 #endif



CVS commit: src/sys/arch

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May  8 00:49:43 UTC 2020

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

Log Message:
Factor randomization out of slotspace_rand.

slotspace_rand becomes deterministic; the randomization moves into
the callers instead.  Why?

There are two callers of slotspace_rand:

- x86/pmap.c pmap_bootstrap
- amd64/amd64.c init_slotspace

When the randomization was introduced, it used an x86-only
`cpu_earlyrng' abstraction that would hash rdseed/rdrand and rdtsc
output together.  Except init_slotspace ran before cpu_probe, so
cpu_feature was not yet filled out, so during init_slotspace, the
only randomization was rdtsc.

In the course of the recent entropy overhaul, I replaced cpu_earlyrng
by entropy_extract, and moved cpu_init_rng much earlier -- but still
after cpu_probe -- in order to reduce the number of abstractions
lying around and the number of copies of rdrand/rdseed logic.  In so
doing I added some annoying complication (see curcpu_available) to
kern_entropy.c to make it work early enough for init_slotspace, and
dropped the rdtsc.

For pmap_bootstrap that didn't substantively change anything.  But
for init_slotspace, it removed the only randomization.  To mitigate
this, this commit pulls the randomization out of slotspace_rand into
pmap_bootstrap and init_slotspace, so that

(a) init_slotspace can use rdtsc and a little private entropy pool in
order to restore the prior (weak) randomization it had, and

(b) pmap_bootstrap, which runs a little bit later, can continue to
use entropy_extract normally and get rdrand/rdseed too.

A subsequent commit will move cpu_init_rng just a wee bit later,
after cpu_init_msrs, so the kern_entropy.c complications can go away.
Perhaps someone else more wizardly with x86 can find a way to make
init_slotspace run a little later too, after cpu_probe and after
cpu_init_msrs and after cpu_rng_init, but I am not that wizardly.


To generate a diff of this commit:
cvs rdiff -u -r1.352 -r1.353 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.388 -r1.389 src/sys/arch/x86/x86/pmap.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.352 src/sys/arch/amd64/amd64/machdep.c:1.353
--- src/sys/arch/amd64/amd64/machdep.c:1.352	Sat May  2 16:44:34 2020
+++ src/sys/arch/amd64/amd64/machdep.c	Fri May  8 00:49:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.352 2020/05/02 16:44:34 bouyer Exp $	*/
+/*	$NetBSD: machdep.c,v 1.353 2020/05/08 00:49:42 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.352 2020/05/02 16:44:34 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.353 2020/05/08 00:49:42 riastradh Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -158,6 +158,8 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #endif
 
+#include  /* XXX */
+
 #include 
 #include 
 
@@ -1581,8 +1583,21 @@ init_pte(void)
 void
 init_slotspace(void)
 {
+	/*
+	 * XXX Too early to use cprng(9), or even entropy_extract.
+	 * Also too early to use rdrand/rdseed, since we haven't probed
+	 * cpu features yet.  This is a hack -- fix me!
+	 */
+	struct entpool pool;
+	size_t randhole;
+	vaddr_t randva;
+	uint64_t sample;
 	vaddr_t va;
 
+	memset(, 0, sizeof pool);
+	sample = rdtsc();
+	entpool_enter(, , sizeof sample);
+
 	memset(, 0, sizeof(slotspace));
 
 	/* User. [256, because we want to land in >= 256] */
@@ -1636,16 +1651,26 @@ init_slotspace(void)
 	slotspace.area[SLAREA_KERN].active = true;
 
 	/* Main. */
+	sample = rdtsc();
+	entpool_enter(, , sizeof sample);
+	entpool_extract(, , sizeof randhole);
+	entpool_extract(, , sizeof randva);
 	va = slotspace_rand(SLAREA_MAIN, NKL4_MAX_ENTRIES * NBPD_L4,
-	NBPD_L4); /* TODO: NBPD_L1 */
+	NBPD_L4, randhole, randva); /* TODO: NBPD_L1 */
 	vm_min_kernel_address = va;
 	vm_max_kernel_address = va + NKL4_MAX_ENTRIES * NBPD_L4;
 
 #ifndef XENPV
 	/* PTE. */
-	va = slotspace_rand(SLAREA_PTE, NBPD_L4, NBPD_L4);
+	sample = rdtsc();
+	entpool_enter(, , sizeof sample);
+	entpool_extract(, , sizeof randhole);
+	entpool_extract(, , sizeof randva);
+	va = slotspace_rand(SLAREA_PTE, NBPD_L4, NBPD_L4, randhole, randva);
 	pte_base = (pd_entry_t *)va;
 #endif
+
+	explicit_memset(, 0, sizeof pool);
 }
 
 void

Index: src/sys/arch/x86/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.119 src/sys/arch/x86/include/pmap.h:1.120
--- src/sys/arch/x86/include/pmap.h:1.119	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/include/pmap.h	Fri May  8 00:49:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.119 2020/04/25 15:26:18 bouyer Exp $	*/

CVS commit: src/sys/arch/amd64/stand/prekern

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 21:05:37 UTC 2020

Modified Files:
src/sys/arch/amd64/stand/prekern: prekern.h

Log Message:
Forgot to commit this file as part of elf.c::rev1.21 mm.c::rev1.27.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/amd64/stand/prekern/prekern.h

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

Modified files:

Index: src/sys/arch/amd64/stand/prekern/prekern.h
diff -u src/sys/arch/amd64/stand/prekern/prekern.h:1.21 src/sys/arch/amd64/stand/prekern/prekern.h:1.22
--- src/sys/arch/amd64/stand/prekern/prekern.h:1.21	Tue May  5 19:26:47 2020
+++ src/sys/arch/amd64/stand/prekern/prekern.h	Thu May  7 21:05:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: prekern.h,v 1.21 2020/05/05 19:26:47 maxv Exp $	*/
+/*	$NetBSD: prekern.h,v 1.22 2020/05/07 21:05:37 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -89,8 +89,9 @@ void print_banner(void);
 /* elf.c */
 size_t elf_get_head_size(vaddr_t);
 void elf_build_head(vaddr_t);
+void elf_fixup_boot(vaddr_t, paddr_t);
 void elf_map_sections(void);
-void elf_build_boot(vaddr_t, paddr_t);
+void elf_build_info(void);
 vaddr_t elf_kernel_reloc(void);
 
 /* locore.S */



CVS commit: src/sys

2020-05-07 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May  7 20:02:34 UTC 2020

Modified Files:
src/sys/kern: kern_exec.c kern_fork.c kern_sig.c
src/sys/sys: proc.h

Log Message:
On debugger attach to a prestarted process don't report SIGTRAP

Introduce PSL_TRACEDCHILD that indicates tracking of birth of a process.
A freshly forked process checks whether it is traced and if so, reports
SIGTRAP + TRAP_CHLD event to a debugger as a result of tracking forks-like
events. There is a time window when a debugger can attach to a newly
created process and receive SIGTRAP + TRAP_CHLD instead of SIGSTOP.

Fixes races in t_ptrace_wait* tests when a test hangs or misbehaves,
especially the ones reported in tracer_sysctl_lookup_without_duplicates.


To generate a diff of this commit:
cvs rdiff -u -r1.499 -r1.500 src/sys/kern/kern_exec.c
cvs rdiff -u -r1.223 -r1.224 src/sys/kern/kern_fork.c
cvs rdiff -u -r1.387 -r1.388 src/sys/kern/kern_sig.c
cvs rdiff -u -r1.364 -r1.365 src/sys/sys/proc.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/kern/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.499 src/sys/kern/kern_exec.c:1.500
--- src/sys/kern/kern_exec.c:1.499	Fri Apr 24 03:22:06 2020
+++ src/sys/kern/kern_exec.c	Thu May  7 20:02:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.499 2020/04/24 03:22:06 thorpej Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.500 2020/05/07 20:02:34 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.499 2020/04/24 03:22:06 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.500 2020/05/07 20:02:34 kamil Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -2279,8 +2279,10 @@ spawn_return(void *arg)
 	/* release our refcount on the data */
 	spawn_exec_data_release(spawn_data);
 
-	if (p->p_slflag & PSL_TRACED)
+	if ((p->p_slflag & (PSL_TRACED|PSL_TRACEDCHILD)) ==
+	(PSL_TRACED|PSL_TRACEDCHILD)) {
 		eventswitchchild(p, TRAP_CHLD, PTRACE_POSIX_SPAWN);
+	}
 
 	/* and finally: leave to userland for the first time */
 	cpu_spawn_return(l);
@@ -2664,8 +2666,10 @@ do_posix_spawn(struct lwp *l1, pid_t *pi
 	p2->p_exitsig = SIGCHLD;	/* signal for parent on exit */
 
 	if ((p1->p_slflag & (PSL_TRACEPOSIX_SPAWN|PSL_TRACED)) ==
-	(PSL_TRACEPOSIX_SPAWN|PSL_TRACED))
+	(PSL_TRACEPOSIX_SPAWN|PSL_TRACED)) {
 		proc_changeparent(p2, p1->p_pptr);
+		SET(p2->p_slflag, PSL_TRACEDCHILD);
+	}
 
 	p2->p_oppid = p1->p_pid;  /* Remember the original parent id. */
 

Index: src/sys/kern/kern_fork.c
diff -u src/sys/kern/kern_fork.c:1.223 src/sys/kern/kern_fork.c:1.224
--- src/sys/kern/kern_fork.c:1.223	Fri Apr 24 03:22:06 2020
+++ src/sys/kern/kern_fork.c	Thu May  7 20:02:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_fork.c,v 1.223 2020/04/24 03:22:06 thorpej Exp $	*/
+/*	$NetBSD: kern_fork.c,v 1.224 2020/05/07 20:02:34 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008, 2019
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.223 2020/04/24 03:22:06 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.224 2020/05/07 20:02:34 kamil Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -513,8 +513,10 @@ fork1(struct lwp *l1, int flags, int exi
 	/*
 	 * Trace fork(2) and vfork(2)-like events on demand in a debugger.
 	 */
-	if (tracefork(p1, flags) || tracevfork(p1, flags))
+	if (tracefork(p1, flags) || tracevfork(p1, flags)) {
 		proc_changeparent(p2, p1->p_pptr);
+		SET(p2->p_slflag, PSL_TRACEDCHILD);
+	}
 
 	p2->p_oppid = p1->p_pid; /* Remember the original parent id. */
 
@@ -634,7 +636,8 @@ child_return(void *arg)
 	struct lwp *l = curlwp;
 	struct proc *p = l->l_proc;
 
-	if ((p->p_slflag & PSL_TRACED) != 0) {
+	if ((p->p_slflag & (PSL_TRACED|PSL_TRACEDCHILD)) ==
+	(PSL_TRACED|PSL_TRACEDCHILD)) {
 		eventswitchchild(p, TRAP_CHLD, 
 		ISSET(p->p_lflag, PL_PPWAIT) ? PTRACE_VFORK : PTRACE_FORK);
 	}

Index: src/sys/kern/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.387 src/sys/kern/kern_sig.c:1.388
--- src/sys/kern/kern_sig.c:1.387	Mon Apr  6 08:20:05 2020
+++ src/sys/kern/kern_sig.c	Thu May  7 20:02:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.387 2020/04/06 08:20:05 kamil Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.388 2020/05/07 20:02:34 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.387 2020/04/06 08:20:05 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.388 2020/05/07 20:02:34 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -1693,7 +1693,8 @@ eventswitchchild(struct proc *p, int cod
 {
 	mutex_enter(proc_lock);
 	mutex_enter(p->p_lock);
-	if (!(p->p_slflag & PSL_TRACED)) {
+	if ((p->p_slflag & (PSL_TRACED|PSL_TRACEDCHILD)) !=
+	  

CVS commit: src/etc/rc.d

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  7 20:01:05 UTC 2020

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

Log Message:
If no random seed file exists on boot, create one.

rndctl -S triggers entropy consolidation, so whatever we gathered
during kernel startup -- interrupt timings, autoconf timings,  --
will be incorporated into the seed and into subsequent data read from
/dev/urandom, just like if rndctl -L had run at this boot, and the
seed will carry them into the next boot too.

But it still avoids frequently consolidating entropy on any regular
schedule, in order to continue to mitigate iterative-guessing
attacks.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/etc/rc.d/random_seed

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

Modified files:

Index: src/etc/rc.d/random_seed
diff -u src/etc/rc.d/random_seed:1.12 src/etc/rc.d/random_seed:1.13
--- src/etc/rc.d/random_seed:1.12	Thu May  7 20:00:38 2020
+++ src/etc/rc.d/random_seed	Thu May  7 20:01:04 2020
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: random_seed,v 1.12 2020/05/07 20:00:38 riastradh Exp $
+# $NetBSD: random_seed,v 1.13 2020/05/07 20:01:04 riastradh Exp $
 #
 
 # PROVIDE: random_seed
@@ -57,7 +57,8 @@ random_load()
 	local flags=
 
 	if [ ! -f "${random_file}" ]; then
-		message "Not present"
+		message "Not present; creating"
+		random_save
 		return
 	fi
 



CVS commit: src/etc/rc.d

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  7 20:00:38 UTC 2020

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

Log Message:
Omit needless verbiage in error message.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/etc/rc.d/random_seed

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

Modified files:

Index: src/etc/rc.d/random_seed
diff -u src/etc/rc.d/random_seed:1.11 src/etc/rc.d/random_seed:1.12
--- src/etc/rc.d/random_seed:1.11	Thu May  7 18:15:29 2020
+++ src/etc/rc.d/random_seed	Thu May  7 20:00:38 2020
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: random_seed,v 1.11 2020/05/07 18:15:29 riastradh Exp $
+# $NetBSD: random_seed,v 1.12 2020/05/07 20:00:38 riastradh Exp $
 #
 
 # PROVIDE: random_seed
@@ -62,7 +62,7 @@ random_load()
 	fi
 
 	if ! fs_safe "${random_file}"; then
-		message "Unsafe file system for random seed ${random_file}"
+		message "Unsafe file system"
 		flags=-i
 	fi
 



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

2020-05-07 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu May  7 19:52:50 UTC 2020

Modified Files:
src/sys/arch/xen/xen: xenevt.c

Log Message:
Go back using cpu_info_primary, all events are bound to vCPU 0 by default.
Register the event handler on cpu_info_primary.
While there. update the event counter on interrupts.
Finally this should be MP-safe.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/xen/xen/xenevt.c

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

Modified files:

Index: src/sys/arch/xen/xen/xenevt.c
diff -u src/sys/arch/xen/xen/xenevt.c:1.59 src/sys/arch/xen/xen/xenevt.c:1.60
--- src/sys/arch/xen/xen/xenevt.c:1.59	Wed May  6 20:40:33 2020
+++ src/sys/arch/xen/xen/xenevt.c	Thu May  7 19:52:50 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: xenevt.c,v 1.59 2020/05/06 20:40:33 bouyer Exp $  */
+/*  $NetBSD: xenevt.c,v 1.60 2020/05/07 19:52:50 bouyer Exp $  */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.59 2020/05/06 20:40:33 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.60 2020/05/07 19:52:50 bouyer Exp $");
 
 #include "opt_xen.h"
 #include 
@@ -129,6 +129,7 @@ struct xenevt_d {
 };
 
 static struct intrhand *xenevt_ih;
+static evtchn_port_t xenevt_ev;
 
 /* event -> user device mapping */
 static struct xenevt_d *devevent[NR_EVENT_CHANNELS];
@@ -175,15 +176,17 @@ xenevtattach(int n)
 
 	/*
 	 * Allocate a loopback event port.
-	 * This helps us massage xenevt_processevt() into the
-	 * callchain at the appropriate level using only
-	 * intr_establish_xname().
+	 * It won't be used by itself, but will help registering IPL
+	 * handlers.
 	 */
-	evtchn_port_t evtchn = xenevt_alloc_event();
+	xenevt_ev = xenevt_alloc_event();
 
-	/* The real objective here is to wiggle into the ih callchain for IPL level */
-	xenevt_ih = intr_establish_xname(-1, _pic, evtchn, 
-	IST_LEVEL, level, xenevt_processevt, NULL, true, "xenevt");
+	/*
+	 * The real objective here is to wiggle into the ih callchain for
+	 * IPL level on vCPU 0. (events are bound to vCPU 0 by default).
+	 */
+	xenevt_ih = event_set_handler(xenevt_ev, xenevt_processevt, NULL,
+	level, NULL, "xenevt", true, _info_primary);
 
 	KASSERT(xenevt_ih != NULL);
 }
@@ -192,9 +195,12 @@ xenevtattach(int n)
 void
 xenevt_setipending(int l1, int l2)
 {
+	KASSERT(curcpu() == xenevt_ih->ih_cpu);
+	KASSERT(xenevt_ih->ih_cpu->ci_ilevel >= IPL_HIGH);
 	atomic_or_ulong(_ev1, 1UL << l1);
 	atomic_or_ulong(_ev2[l1], 1UL << l2);
 	atomic_or_32(_ih->ih_cpu->ci_ipending, 1 << SIR_XENIPL_HIGH);
+	evtsource[xenevt_ev]->ev_evcnt.ev_count++;
 }
 
 /* process pending events */



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

2020-05-07 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu May  7 19:49:30 UTC 2020

Modified Files:
src/sys/arch/xen/xen: xbdback_xenbus.c

Log Message:
This should be mpsafe, register the event handler as such.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/arch/xen/xen/xbdback_xenbus.c

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

Modified files:

Index: src/sys/arch/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.95 src/sys/arch/xen/xen/xbdback_xenbus.c:1.96
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.95	Wed May  6 20:09:26 2020
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Thu May  7 19:49:29 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.95 2020/05/06 20:09:26 bouyer Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.96 2020/05/07 19:49:29 bouyer Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.95 2020/05/06 20:09:26 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.96 2020/05/07 19:49:29 bouyer Exp $");
 
 #include 
 #include 
@@ -597,7 +597,7 @@ xbdback_connect(struct xbdback_instance 
 	xbdi->xbdi_evtchn = evop.u.bind_interdomain.local_port;
 
 	xbdi->xbdi_ih = intr_establish_xname(-1, _pic, xbdi->xbdi_evtchn,
-	IST_LEVEL, IPL_BIO, xbdback_evthandler, xbdi, false,
+	IST_LEVEL, IPL_BIO, xbdback_evthandler, xbdi, true,
 	xbdi->xbdi_name);
 	KASSERT(xbdi->xbdi_ih != NULL);
 	aprint_verbose("xbd backend domain %d handle %#x (%d) "



CVS commit: src/sys/arch/xen

2020-05-07 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu May  7 19:48:58 UTC 2020

Modified Files:
src/sys/arch/xen/include: evtchn.h
src/sys/arch/xen/x86: xen_intr.c xen_ipi.c
src/sys/arch/xen/xen: evtchn.c xen_clock.c

Log Message:
Change event_set_handler() to take the target CPU parameter. If ci is NULL,
  event_set_handler() will choose the CPU and bind the event.
  If ci is not NULL the caller is responsible for binding the event.
Use a IPI xcall to register the handlers if needed.
pull in a hack from x86 to force pirq handlers to be mpsafe if registered at
a level != IPL_VM. This is for the com at isa interrupt handler, which
registers at IPL_HIGH and has to way to tell it's mpsafe (taking
KERNEL_LOCK at IPL_HIGH causes deadlocks on MP systems).


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/xen/include/evtchn.h
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/xen/x86/xen_intr.c
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/xen/x86/xen_ipi.c
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/xen/xen/evtchn.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/xen/xen/xen_clock.c

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

Modified files:

Index: src/sys/arch/xen/include/evtchn.h
diff -u src/sys/arch/xen/include/evtchn.h:1.31 src/sys/arch/xen/include/evtchn.h:1.32
--- src/sys/arch/xen/include/evtchn.h:1.31	Mon May  4 15:55:56 2020
+++ src/sys/arch/xen/include/evtchn.h	Thu May  7 19:48:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.h,v 1.31 2020/05/04 15:55:56 jdolecek Exp $	*/
+/*	$NetBSD: evtchn.h,v 1.32 2020/05/07 19:48:58 bouyer Exp $	*/
 
 /*
  *
@@ -40,12 +40,11 @@ unsigned int evtchn_do_event(int, struct
 void call_evtchn_do_event(int, struct intrframe *);
 void call_xenevt_event(int);
 struct intrhand *event_set_handler(int, int (*func)(void *), void *,
-int, const char *, const char *, bool, bool);
+int, const char *, const char *, bool, struct cpu_info *);
 int event_remove_handler(int, int (*func)(void *), void *);
 
 struct cpu_info;
 struct intrhand;
-void event_set_iplhandler(struct cpu_info *, struct intrhand *, int);
 
 extern int debug_port;
 extern int xen_debug_handler(void *);

Index: src/sys/arch/xen/x86/xen_intr.c
diff -u src/sys/arch/xen/x86/xen_intr.c:1.26 src/sys/arch/xen/x86/xen_intr.c:1.27
--- src/sys/arch/xen/x86/xen_intr.c:1.26	Tue May  5 17:02:01 2020
+++ src/sys/arch/xen/x86/xen_intr.c	Thu May  7 19:48:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_intr.c,v 1.26 2020/05/05 17:02:01 bouyer Exp $	*/
+/*	$NetBSD: xen_intr.c,v 1.27 2020/05/07 19:48:58 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.26 2020/05/05 17:02:01 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.27 2020/05/07 19:48:58 bouyer Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -143,7 +143,7 @@ xen_intr_establish_xname(int legacy_irq,
 		sizeof(intrstr_buf));
 
 		rih = event_set_handler(pin, handler, arg, level,
-		intrstr, xname, known_mpsafe, true);
+		intrstr, xname, known_mpsafe, NULL);
 
 		if (rih == NULL) {
 			printf("%s: can't establish interrupt\n", __func__);
@@ -157,6 +157,8 @@ xen_intr_establish_xname(int legacy_irq,
 	struct pintrhand *pih;
 	int gsi;
 	int evtchn;
+	/* the hack below is from x86's intr_establish_xname() */
+	bool mpsafe = (known_mpsafe || level != IPL_VM);
 
 	KASSERTMSG(legacy_irq == -1 || (0 <= legacy_irq && legacy_irq < NUM_XEN_IRQS),
 	"bad legacy IRQ value: %d", legacy_irq);
@@ -190,7 +192,7 @@ xen_intr_establish_xname(int legacy_irq,
 	}
 
 	pih = pirq_establish(gsi, evtchn, handler, arg, level,
-			 intrstr, xname, known_mpsafe);
+			 intrstr, xname, mpsafe);
 	pih->pic = pic;
 	return pih;
 #endif /* NPCI > 0 || NISA > 0 */

Index: src/sys/arch/xen/x86/xen_ipi.c
diff -u src/sys/arch/xen/x86/xen_ipi.c:1.38 src/sys/arch/xen/x86/xen_ipi.c:1.39
--- src/sys/arch/xen/x86/xen_ipi.c:1.38	Sat Apr 25 15:26:17 2020
+++ src/sys/arch/xen/x86/xen_ipi.c	Thu May  7 19:48:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_ipi.c,v 1.38 2020/04/25 15:26:17 bouyer Exp $ */
+/* $NetBSD: xen_ipi.c,v 1.39 2020/05/07 19:48:58 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  * Based on: x86/ipi.c
  */
 
-__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.38 2020/04/25 15:26:17 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.39 2020/05/07 19:48:58 bouyer Exp $");
 
 #include "opt_ddb.h"
 
@@ -143,7 +143,7 @@ xen_ipi_init(void)
 	device_xname(ci->ci_dev));
 
 	if (event_set_handler(evtchn, xen_ipi_handler, ci, IPL_HIGH, NULL,
-	intr_xname, true, false) == NULL) {
+	intr_xname, true, ci) == NULL) {
 		panic("%s: unable to register ipi handler\n", __func__);
 		/* NOTREACHED */
 	}

Index: src/sys/arch/xen/xen/evtchn.c
diff -u src/sys/arch/xen/xen/evtchn.c:1.93 src/sys/arch/xen/xen/evtchn.c:1.94
--- 

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

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 19:25:57 UTC 2020

Modified Files:
src/sys/arch/xen/xen: xbd_xenbus.c xencons.c

Log Message:
Localify.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/xen/xen/xbd_xenbus.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/xen/xen/xencons.c

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

Modified files:

Index: src/sys/arch/xen/xen/xbd_xenbus.c
diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.124 src/sys/arch/xen/xen/xbd_xenbus.c:1.125
--- src/sys/arch/xen/xen/xbd_xenbus.c:1.124	Sun May  3 17:54:28 2020
+++ src/sys/arch/xen/xen/xbd_xenbus.c	Thu May  7 19:25:57 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbd_xenbus.c,v 1.124 2020/05/03 17:54:28 jdolecek Exp $  */
+/*  $NetBSD: xbd_xenbus.c,v 1.125 2020/05/07 19:25:57 maxv Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.124 2020/05/03 17:54:28 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.125 2020/05/07 19:25:57 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -214,14 +214,14 @@ CFATTACH_DECL3_NEW(xbd, sizeof(struct xb
 xbd_xenbus_match, xbd_xenbus_attach, xbd_xenbus_detach, NULL, NULL, NULL,
 DVF_DETACH_SHUTDOWN);
 
-dev_type_open(xbdopen);
-dev_type_close(xbdclose);
-dev_type_read(xbdread);
-dev_type_write(xbdwrite);
-dev_type_ioctl(xbdioctl);
-dev_type_strategy(xbdstrategy);
-dev_type_dump(xbddump);
-dev_type_size(xbdsize);
+static dev_type_open(xbdopen);
+static dev_type_close(xbdclose);
+static dev_type_read(xbdread);
+static dev_type_write(xbdwrite);
+static dev_type_ioctl(xbdioctl);
+static dev_type_strategy(xbdstrategy);
+static dev_type_dump(xbddump);
+static dev_type_size(xbdsize);
 
 const struct bdevsw xbd_bdevsw = {
 	.d_open = xbdopen,
@@ -924,7 +924,7 @@ xbd_iosize(device_t dev, int *maxxfer)
 		*maxxfer = XBD_MAX_XFER;
 }
 
-int
+static int
 xbdopen(dev_t dev, int flags, int fmt, struct lwp *l)
 {
 	struct	xbd_xenbus_softc *sc;
@@ -939,7 +939,7 @@ xbdopen(dev_t dev, int flags, int fmt, s
 	return dk_open(>sc_dksc, dev, flags, fmt, l);
 }
 
-int
+static int
 xbdclose(dev_t dev, int flags, int fmt, struct lwp *l)
 {
 	struct xbd_xenbus_softc *sc;
@@ -950,7 +950,7 @@ xbdclose(dev_t dev, int flags, int fmt, 
 	return dk_close(>sc_dksc, dev, flags, fmt, l);
 }
 
-void
+static void
 xbdstrategy(struct buf *bp)
 {
 	struct xbd_xenbus_softc *sc;
@@ -976,7 +976,7 @@ xbdstrategy(struct buf *bp)
 	return;
 }
 
-int
+static int
 xbdsize(dev_t dev)
 {
 	struct	xbd_xenbus_softc *sc;
@@ -989,7 +989,7 @@ xbdsize(dev_t dev)
 	return dk_size(>sc_dksc, dev);
 }
 
-int
+static int
 xbdread(dev_t dev, struct uio *uio, int flags)
 {
 	struct xbd_xenbus_softc *sc = 
@@ -1001,7 +1001,7 @@ xbdread(dev_t dev, struct uio *uio, int 
 	return physio(xbdstrategy, NULL, dev, B_READ, xbdminphys, uio);
 }
 
-int
+static int
 xbdwrite(dev_t dev, struct uio *uio, int flags)
 {
 	struct xbd_xenbus_softc *sc =
@@ -1015,7 +1015,7 @@ xbdwrite(dev_t dev, struct uio *uio, int
 	return physio(xbdstrategy, NULL, dev, B_WRITE, xbdminphys, uio);
 }
 
-int
+static int
 xbdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
 {
 	struct xbd_xenbus_softc *sc =
@@ -1087,7 +1087,7 @@ xbdioctl(dev_t dev, u_long cmd, void *da
 	return error;
 }
 
-int
+static int
 xbddump(dev_t dev, daddr_t blkno, void *va, size_t size)
 {
 	struct xbd_xenbus_softc *sc;

Index: src/sys/arch/xen/xen/xencons.c
diff -u src/sys/arch/xen/xen/xencons.c:1.49 src/sys/arch/xen/xen/xencons.c:1.50
--- src/sys/arch/xen/xen/xencons.c:1.49	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/xen/xen/xencons.c	Thu May  7 19:25:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xencons.c,v 1.49 2020/04/25 15:26:18 bouyer Exp $	*/
+/*	$NetBSD: xencons.c,v 1.50 2020/05/07 19:25:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.49 2020/04/25 15:26:18 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.50 2020/05/07 19:25:57 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -96,11 +96,10 @@ static struct intrhand *ih;
 #define	XENCONS_UNIT(x)	(minor(x))
 #define XENCONS_BURST 128
 
-int xencons_match(device_t, cfdata_t, void *);
-void xencons_attach(device_t, device_t, void *);
-int xencons_intr(void *);
-void xencons_tty_input(struct xencons_softc *, char*, int);
-
+static int xencons_match(device_t, cfdata_t, void *);
+static void xencons_attach(device_t, device_t, void *);
+static int xencons_intr(void *);
+static void xencons_tty_input(struct xencons_softc *, char*, int);
 
 struct xencons_softc {
 	device_t sc_dev;
@@ -114,14 +113,14 @@ CFATTACH_DECL_NEW(xencons, sizeof(struct
 
 extern struct cfdriver xencons_cd;
 
-dev_type_open(xencons_open);
-dev_type_close(xencons_close);
-dev_type_read(xencons_read);
-dev_type_write(xencons_write);
-dev_type_ioctl(xencons_ioctl);

CVS commit: src/sbin/rndctl

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  7 19:13:38 UTC 2020

Modified Files:
src/sbin/rndctl: rndctl.c

Log Message:
Trigger entropy consolidation before saving seed.

This way, whenever /etc/security runs infrequently (daily), or the
operator manually issues rndctl -S, we ensure that all samples taken
during the entire boot are hashed together in the seed for the next
boot.

This should be infrequent enough that it's unlikely to enable the
iterative-guessing attacks that we try to mitigate by not frequently
consolidating entropy.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sbin/rndctl/rndctl.c

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

Modified files:

Index: src/sbin/rndctl/rndctl.c
diff -u src/sbin/rndctl/rndctl.c:1.35 src/sbin/rndctl/rndctl.c:1.36
--- src/sbin/rndctl/rndctl.c:1.35	Thu May  7 19:12:45 2020
+++ src/sbin/rndctl/rndctl.c	Thu May  7 19:13:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rndctl.c,v 1.35 2020/05/07 19:12:45 riastradh Exp $	*/
+/*	$NetBSD: rndctl.c,v 1.36 2020/05/07 19:13:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997 Michael Graff.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: rndctl.c,v 1.35 2020/05/07 19:12:45 riastradh Exp $");
+__RCSID("$NetBSD: rndctl.c,v 1.36 2020/05/07 19:13:38 riastradh Exp $");
 #endif
 
 #include 
@@ -40,6 +40,7 @@ __RCSID("$NetBSD: rndctl.c,v 1.35 2020/0
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -251,6 +252,11 @@ do_save(const char *filename)
 	char tmp[PATH_MAX];
 	int fd_seed;
 
+	/* Consolidate any pending samples.  */
+	if (sysctlbyname("kern.entropy.consolidate", NULL, NULL,
+		(const int[]){1}, sizeof(int)) == -1)
+		warn("consolidate entropy");
+
 	/* Format the temporary file name.  */
 	if (snprintf(tmp, sizeof tmp, "%s.tmp", filename) >= PATH_MAX)
 		errx(1, "path too long");
@@ -367,6 +373,11 @@ do_load(const char *filename)
 
 	/*
 	 * 2. Feed the old seed into the kernel.
+	 *
+	 * This also has the effect of consolidating pending samples,
+	 * whether or not there are enough samples from sources deemed
+	 * to have full entropy, so that the updated seed will
+	 * incorporate them.
 	 */
 	rd.len = MIN(sizeof(rd.data), sizeof(rs.data));
 	rd.entropy = rs.entropy;



CVS commit: src/sbin/rndctl

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  7 19:12:45 UTC 2020

Modified Files:
src/sbin/rndctl: rndctl.c

Log Message:
Rework rndctl seed load sequence again.

Go back to the book's order, now that writing to /dev/random
guarantees to consolidate entropy -- this way the _next_ boot is no
less secure than the current boot, in the event that entropy sources
like interrupt timings provided any security that we just don't know
how to measure honestly.

Make sure to open the old seed to overwrite and the new seed to write
anew first so that we can determine whether the medium is read-only
before accepting the file's entropy estimate.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sbin/rndctl/rndctl.c

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

Modified files:

Index: src/sbin/rndctl/rndctl.c
diff -u src/sbin/rndctl/rndctl.c:1.34 src/sbin/rndctl/rndctl.c:1.35
--- src/sbin/rndctl/rndctl.c:1.34	Wed May  6 18:49:26 2020
+++ src/sbin/rndctl/rndctl.c	Thu May  7 19:12:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rndctl.c,v 1.34 2020/05/06 18:49:26 riastradh Exp $	*/
+/*	$NetBSD: rndctl.c,v 1.35 2020/05/07 19:12:45 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997 Michael Graff.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: rndctl.c,v 1.34 2020/05/06 18:49:26 riastradh Exp $");
+__RCSID("$NetBSD: rndctl.c,v 1.35 2020/05/07 19:12:45 riastradh Exp $");
 #endif
 
 #include 
@@ -129,41 +129,34 @@ find_name(u_int32_t type)
 }
 
 static int
-update_seed(const char *filename, const void *extra, size_t nextra,
-uint32_t extraentropy)
+update_seed(const char *filename, int fd_seed, const char *tmp,
+const void *extra, size_t nextra, uint32_t extraentropy)
 {
-	char tmp[PATH_MAX];
 	uint32_t systementropy;
 	uint8_t buf[32];
 	SHAKE128_CTX shake128;
 	rndsave_t rs;
 	SHA1_CTX s;
 	ssize_t nread, nwrit;
-	int fd;
+	int fd_random;
 
 	/* Paranoia: Avoid stack memory disclosure.  */
 	memset(, 0, sizeof rs);
 
-	/* Format the temporary file name.  */
-	if (snprintf(tmp, sizeof tmp, "%s.tmp", filename) >= PATH_MAX) {
-		warnx("path too long");
-		return -1;
-	}
-
-	/* Open /dev/urandom.  */
-	if ((fd = open(_PATH_URANDOM, O_RDONLY)) == -1) {
-		warn("device open");
+	/* Open /dev/urandom to read data from the system.  */
+	if ((fd_random = open(_PATH_URANDOM, O_RDONLY)) == -1) {
+		warn("open /dev/urandom");
 		return -1;
 	}
 
 	/* Find how much entropy is in the pool.  */
-	if (ioctl(fd, RNDGETENTCNT, ) == -1) {
+	if (ioctl(fd_random, RNDGETENTCNT, ) == -1) {
 		warn("ioctl(RNDGETENTCNT)");
 		systementropy = 0;
 	}
 
 	/* Read some data from /dev/urandom.  */
-	if ((size_t)(nread = read(fd, buf, sizeof buf)) != sizeof buf) {
+	if ((size_t)(nread = read(fd_random, buf, sizeof buf)) != sizeof buf) {
 		if (nread == -1)
 			warn("read");
 		else
@@ -172,9 +165,9 @@ update_seed(const char *filename, const 
 	}
 
 	/* Close /dev/urandom; we're done with it.  */
-	if (close(fd) == -1)
+	if (close(fd_random) == -1)
 		warn("close");
-	fd = -1;		/* paranoia */
+	fd_random = -1;		/* paranoia */
 
 	/*
 	 * Hash what we read together with the extra input to generate
@@ -221,11 +214,7 @@ update_seed(const char *filename, const 
 	 * begin with in which case we're hosed either way, or we've
 	 * just revealed some output which is not a problem.
 	 */
-	if ((fd = open(tmp, O_CREAT|O_TRUNC|O_WRONLY, 0600)) == -1) {
-		warn("open seed file to save");
-		return -1;
-	}
-	if ((size_t)(nwrit = write(fd, , sizeof rs)) != sizeof rs) {
+	if ((size_t)(nwrit = write(fd_seed, , sizeof rs)) != sizeof rs) {
 		int error = errno;
 		if (unlink(tmp) == -1)
 			warn("unlink");
@@ -236,14 +225,14 @@ update_seed(const char *filename, const 
 		return -1;
 	}
 	explicit_memset(, 0, sizeof rs); /* paranoia */
-	if (fsync_range(fd, FDATASYNC|FDISKSYNC, 0, 0) == -1) {
+	if (fsync_range(fd_seed, FDATASYNC|FDISKSYNC, 0, 0) == -1) {
 		int error = errno;
 		if (unlink(tmp) == -1)
 			warn("unlink");
 		warnc(error, "fsync_range");
 		return -1;
 	}
-	if (close(fd) == -1)
+	if (close(fd_seed) == -1)
 		warn("close");
 
 	/* Rename it over the original file to commit.  */
@@ -259,8 +248,19 @@ update_seed(const char *filename, const 
 static void
 do_save(const char *filename)
 {
+	char tmp[PATH_MAX];
+	int fd_seed;
+
+	/* Format the temporary file name.  */
+	if (snprintf(tmp, sizeof tmp, "%s.tmp", filename) >= PATH_MAX)
+		errx(1, "path too long");
 
-	if (update_seed(filename, NULL, 0, 0) == -1)
+	/* Create a temporary seed file.  */
+	if ((fd_seed = open(tmp, O_CREAT|O_TRUNC|O_WRONLY, 0600)) == -1)
+		err(1, "open seed file to save");
+
+	/* Update the seed.  Abort on failure.  */
+	if (update_seed(filename, fd_seed, tmp, NULL, 0, 0) == -1)
 		exit(1);
 }
 
@@ -268,7 +268,7 @@ static void
 do_load(const char *filename)
 {
 	char tmp[PATH_MAX];
-	int fd_seed, fd_random;
+	int fd_new, fd_old, fd_random;
 	rndsave_t rs;
 	

CVS commit: src/sbin/rndctl

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  7 19:09:26 UTC 2020

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

Log Message:
Touch up rndctl(8) a bit.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sbin/rndctl/rndctl.8

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

Modified files:

Index: src/sbin/rndctl/rndctl.8
diff -u src/sbin/rndctl/rndctl.8:1.25 src/sbin/rndctl/rndctl.8:1.26
--- src/sbin/rndctl/rndctl.8:1.25	Thu May  7 12:58:09 2020
+++ src/sbin/rndctl/rndctl.8	Thu May  7 19:09:26 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rndctl.8,v 1.25 2020/05/07 12:58:09 wiz Exp $
+.\"	$NetBSD: rndctl.8,v 1.26 2020/05/07 19:09:26 riastradh Exp $
 .\"
 .\" Copyright (c) 1997 Michael Graff
 .\" All rights reserved.
@@ -31,7 +31,7 @@
 .Os
 .Sh NAME
 .Nm rndctl
-.Nd in-kernel random number generator management tool
+.Nd kernel entropy pool management tool
 .Sh SYNOPSIS
 .Nm
 .Op Fl CcEe
@@ -49,10 +49,9 @@ The
 .Nm
 program displays statistics on the current state of the
 .Xr rnd 4
-pseudo-driver, and allows the administrator to control which sources
-are allowed to contribute to the randomness pool maintained by
-.Xr rnd 4 ,
-as well as whether a given source counts as strongly random.
+device, and controls which sources are allowed to contribute to the
+entropy pool maintained by
+.Xr rnd 4 .
 .Pp
 The following options are available:
 .Bl -tag -width 123456
@@ -113,7 +112,7 @@ The file format is specific to
 .Nm
 and includes an estimate of the amount of saved entropy and a checksum.
 .It Fl s
-Display statistics on the current state of the random collection pool.
+Display statistics on the current state of the entropy pool.
 .It Fl t
 All devices of type
 .Ar devtype
@@ -132,19 +131,10 @@ Tape devices.
 .It Ic tty
 Terminal, mouse, or other user input devices.
 .It Ic rng
-Random number generators.
+Hardware random number generators.
 .El
 .It Fl v
-Verbose output: show entropy estimation statistics for each source.
-.El
-.Sh FILES
-.Bl -tag -width /dev/urandomx -compact
-.It Pa /dev/random
-Returns
-.Dq good
-values only.
-.It Pa /dev/urandom
-Always returns data, degenerates to a pseudo-random generator.
+Verbose output.
 .El
 .Sh SEE ALSO
 .Xr rnd 4 ,
@@ -160,9 +150,3 @@ The
 program was written by
 .An Michael Graff
 .Aq explo...@flame.org .
-.Sh BUGS
-Turning on entropy estimation from unsafe or predictable sources will
-weaken system security, while turning on entropy collection from such
-sources may weaken system security.
-.Pp
-Care should be taken when using this command.



CVS commit: src/sys/kern

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  7 19:07:29 UTC 2020

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

Log Message:
Print `entropy: ready' only when we first have full entropy.

Now that we consolidate entropy in rndctl -L and equivalent, not just
when the operator chooses, epoch != -1 no longer necessarily means
full entropy -- it just means `time to (re)seed, whether justified by
entropy accounting or by explicit consolidation'.

There is a bug on x86 systems with RDRAND/RDSEED that prevents this
message from appearing at all: it happens so early that consinit has
not run yet, so it just goes into oblivion.  Need to fix that some
other way!


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/kern_entropy.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_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.13 src/sys/kern/kern_entropy.c:1.14
--- src/sys/kern/kern_entropy.c:1.13	Thu May  7 19:05:51 2020
+++ src/sys/kern/kern_entropy.c	Thu May  7 19:07:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.13 2020/05/07 19:05:51 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.14 2020/05/07 19:07:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.13 2020/05/07 19:05:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.14 2020/05/07 19:07:29 riastradh Exp $");
 
 #include 
 #include 
@@ -172,7 +172,7 @@ struct {
 } entropy_global __cacheline_aligned = {
 	/* Fields that must be initialized when the kernel is loaded.  */
 	.needed = ENTROPY_CAPACITY*NBBY,
-	.epoch = (unsigned)-1,	/* -1 means not yet full entropy */
+	.epoch = (unsigned)-1,	/* -1 means entropy never consolidated */
 	.sources = LIST_HEAD_INITIALIZER(entropy_global.sources),
 	.stage = ENTROPY_COLD,
 };
@@ -596,10 +596,10 @@ entropy_bootrequest(void)
  * entropy_epoch()
  *
  *	Returns the current entropy epoch.  If this changes, you should
- *	reseed.  If -1, means the system has not yet reached full
- *	entropy; never reverts back to -1 after full entropy has been
- *	reached.  Never zero, so you can always use zero as an
- *	uninitialized sentinel value meaning `reseed ASAP'.
+ *	reseed.  If -1, means system entropy has not yet reached full
+ *	entropy or been explicitly consolidated; never reverts back to
+ *	-1.  Never zero, so you can always use zero as an uninitialized
+ *	sentinel value meaning `reseed ASAP'.
  *
  *	Usage model:
  *
@@ -1118,11 +1118,12 @@ entropy_notify(void)
 	 * that we're ready so operators can compare it to the timing
 	 * of other events.
 	 */
-	if (E->epoch == (unsigned)-1)
+	if (__predict_false(!rnd_initial_entropy) && E->needed == 0) {
 		printf("entropy: ready\n");
+		rnd_initial_entropy = 1;
+	}
 
 	/* Set the epoch; roll over from UINTMAX-1 to 1.  */
-	rnd_initial_entropy = 1; /* XXX legacy */
 	if (__predict_true(!atomic_load_relaxed(_depletion)) ||
 	ratecheck(, )) {
 		epoch = E->epoch + 1;



CVS commit: src/sys

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  7 19:05:51 UTC 2020

Modified Files:
src/sys/dev: random.c
src/sys/kern: kern_entropy.c
src/sys/sys: entropy.h

Log Message:
Consolidate entropy on RNDADDDATA and writes to /dev/random.

The man page for some time has advertised:

  Writing to either /dev/random or /dev/urandom influences subsequent
  output of both devices, guaranteed to take effect at next open.

So let's make that true again.

It is a conscious choice _not_ to consolidate entropy frequently.
For example, if you have a _slow_ HWRNG, which provides 32 bits of
entropy every few seconds, and you reveal a hash that to the
adversary before any more comes in, the adversary can in principle
just keep guessing the intermediate state by a brute force search
over ~2^32 possibilities.

To mitigate this, the kernel generally tries to avoid consolidating
entropy from the per-CPU pools until doing so would bring us from
zero entropy to full entropy.

However, there are various _possible_ sources of entropy which are
just hard to give honest estimates for that are valid on ~all
machines -- like interrupt timings.  The time at which we read a seed
in, which usually happens via /etc/rc.d/random_seed early in
userland, is a reasonable time to gather this up.  An operator or
system engineer who knows another opportune moment can always issue
`sysctl -w kern.entropy.consolidate=1'.

Prompted by a suggestion from nia@ to consolidate entropy at the
first transition to userland.  I chose not to do that because it
would likely cause warning fatigue on systems that are perfectly fine
with a random seed -- doing it this way instead lets rndctl -L
trigger the consolidation automatically.  A subsequent commit will
reorder the operations in rndctl again to make it work out better.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/random.c
cvs rdiff -u -r1.12 -r1.13 src/sys/kern/kern_entropy.c
cvs rdiff -u -r1.1 -r1.2 src/sys/sys/entropy.h

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

Modified files:

Index: src/sys/dev/random.c
diff -u src/sys/dev/random.c:1.2 src/sys/dev/random.c:1.3
--- src/sys/dev/random.c:1.2	Thu Apr 30 04:26:29 2020
+++ src/sys/dev/random.c	Thu May  7 19:05:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: random.c,v 1.2 2020/04/30 04:26:29 riastradh Exp $	*/
+/*	$NetBSD: random.c,v 1.3 2020/05/07 19:05:51 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.2 2020/04/30 04:26:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.3 2020/05/07 19:05:51 riastradh Exp $");
 
 #include 
 #include 
@@ -384,7 +384,7 @@ random_write(dev_t dev, struct uio *uio,
 {
 	kauth_cred_t cred = kauth_cred_get();
 	uint8_t *buf;
-	bool privileged = false;
+	bool privileged = false, any = false;
 	int error = 0;
 
 	/* Verify user's authorization to affect the entropy pool.  */
@@ -429,10 +429,16 @@ random_write(dev_t dev, struct uio *uio,
 		if (error)
 			break;
 		rnd_add_data(_rndsource, buf, n, privileged ? n*NBBY : 0);
+		any = true;
 	}
 
 	/* Zero the buffer and return it to the pool cache.  */
 	explicit_memset(buf, 0, RANDOM_BUFSIZE);
 	pool_cache_put(random_buf_pc, buf);
+
+	/* If we added anything, consolidate entropy now.  */
+	if (any)
+		entropy_consolidate();
+
 	return error;
 }

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.12 src/sys/kern/kern_entropy.c:1.13
--- src/sys/kern/kern_entropy.c:1.12	Thu May  7 00:55:13 2020
+++ src/sys/kern/kern_entropy.c	Thu May  7 19:05:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.12 2020/05/07 00:55:13 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.13 2020/05/07 19:05:51 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -60,9 +60,7 @@
  *	  transition from partial entropy to full entropy, so that
  *	  users can easily determine when to reseed.  This also
  *	  facilitates an operator explicitly causing everything to
- *	  reseed by sysctl -w kern.entropy.consolidate=1, e.g. if they
- *	  just flipped a coin 256 times and wrote `echo tththh... >
- *	  /dev/random'.
+ *	  reseed by sysctl -w kern.entropy.consolidate=1.
  *
  *	* No entropy estimation based on the sample values, which is a
  *	  contradiction in terms and a potential source of side
@@ -77,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.12 2020/05/07 00:55:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.13 2020/05/07 19:05:51 riastradh Exp $");
 
 #include 
 #include 
@@ -241,8 +239,8 @@ static void	entropy_softintr(void *);
 static void	entropy_thread(void *);
 static uint32_t	entropy_pending(void);
 static void	entropy_pending_cpu(void *, void *, struct cpu_info *);
-static void	entropy_consolidate(void);
-static void	entropy_gather_xc(void 

CVS commit: [netbsd-9] src/doc

2020-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May  7 18:27:19 UTC 2020

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

Log Message:
Tickets #890 - #895


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.53 -r1.1.2.54 src/doc/CHANGES-9.1

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

Modified files:

Index: src/doc/CHANGES-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.53 src/doc/CHANGES-9.1:1.1.2.54
--- src/doc/CHANGES-9.1:1.1.2.53	Tue May  5 18:34:48 2020
+++ src/doc/CHANGES-9.1	Thu May  7 18:27:19 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.53 2020/05/05 18:34:48 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.54 2020/05/07 18:27:19 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -2454,3 +2454,45 @@ sys/external/bsd/compiler_rt/dist/lib/bu
 	Align addresses to cache lines in __clear_cache for aarch64.
 	[jmcneill, ticket #889]
 
+bin/rcp/rcp.c	1.50
+
+	In sink(), upon error, avoid multiple replies to the source
+	as this would lead to a desynchronization of the protocol and
+	further files or directories to be ignored or corrupted.
+	[aymeric, ticket #890]
+
+sys/arch/arm/sunxi/sun4i_a10_ccu.c		1.12
+
+	Add A20 CLK_OUT_A and CLK_OUT_B clocks.
+	[jmcneill, ticket #891]
+
+sys/dev/sdmmc/if_bwfm_sdio.c			1.15
+
+	Add entry for BCM43362, found on Cubietruck.
+	[macallan, ticket #892]
+
+usr.sbin/lastlogin/lastlogin.8			1.13,1.14
+usr.sbin/lastlogin/lastlogin.c			1.16-1.20
+
+	lastlogin(8):
+	- Size output columns dynamically by default to fit contents.
+	- Show lastlogx entries even when a passwd entry is not found, just
+	  like with lastlog entries.
+	- If -n is specified more than once, print the numeric user id for
+	  lastlog entries, just like with lastlogx entries.
+	- Fix an issue where the last character of data copied from lastlog
+	  and lastlogx fields could sometimes be dropped.
+	[kim, ticket #893]
+
+usr.bin/finger/finger.11.22
+usr.bin/finger/util.c1.30
+
+	finger(1): add lastlogx support.
+	[kim, ticket #894]
+
+sys/arch/arm/cortex/gic_v2m.c			1.9
+sys/arch/arm/cortex/gic_v2m.h			1.3
+
+	Do not store a pointer to the passed in struct pci_attach_args.
+	[jmcneill, ticket #895]
+



CVS commit: [netbsd-9] src/sys/arch/arm/cortex

2020-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May  7 18:25:14 UTC 2020

Modified Files:
src/sys/arch/arm/cortex [netbsd-9]: gic_v2m.c gic_v2m.h

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

sys/arch/arm/cortex/gic_v2m.h: revision 1.3
sys/arch/arm/cortex/gic_v2m.c: revision 1.9

Do not store a pointer to the passed in struct pci_attach_args


To generate a diff of this commit:
cvs rdiff -u -r1.6.2.1 -r1.6.2.2 src/sys/arch/arm/cortex/gic_v2m.c
cvs rdiff -u -r1.1.8.1 -r1.1.8.2 src/sys/arch/arm/cortex/gic_v2m.h

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

Modified files:

Index: src/sys/arch/arm/cortex/gic_v2m.c
diff -u src/sys/arch/arm/cortex/gic_v2m.c:1.6.2.1 src/sys/arch/arm/cortex/gic_v2m.c:1.6.2.2
--- src/sys/arch/arm/cortex/gic_v2m.c:1.6.2.1	Tue Oct 15 19:40:34 2019
+++ src/sys/arch/arm/cortex/gic_v2m.c	Thu May  7 18:25:14 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_v2m.c,v 1.6.2.1 2019/10/15 19:40:34 martin Exp $ */
+/* $NetBSD: gic_v2m.c,v 1.6.2.2 2020/05/07 18:25:14 martin Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_v2m.c,v 1.6.2.1 2019/10/15 19:40:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_v2m.c,v 1.6.2.2 2020/05/07 18:25:14 martin Exp $");
 
 #include 
 #include 
@@ -66,6 +66,7 @@ static int
 gic_v2m_msi_alloc_spi(struct gic_v2m_frame *frame, int count,
 const struct pci_attach_args *pa)
 {
+	struct pci_attach_args *new_pa;
 	int spi, n;
 
 	for (spi = frame->frame_base;
@@ -75,8 +76,11 @@ gic_v2m_msi_alloc_spi(struct gic_v2m_fra
 if (frame->frame_pa[spi + n] != NULL)
 	goto next_spi;
 
-			for (n = 0; n < count; n++)
-frame->frame_pa[spi + n] = pa;
+			for (n = 0; n < count; n++) {
+new_pa = kmem_alloc(sizeof(*new_pa), KM_SLEEP);
+memcpy(new_pa, pa, sizeof(*new_pa));
+frame->frame_pa[spi + n] = new_pa;
+			}
 
 			return spi;
 		}
@@ -90,7 +94,13 @@ next_spi:
 static void
 gic_v2m_msi_free_spi(struct gic_v2m_frame *frame, int spi)
 {
+	struct pci_attach_args *pa;
+
+	pa = frame->frame_pa[spi];
 	frame->frame_pa[spi] = NULL;
+
+	if (pa != NULL)
+		kmem_free(pa, sizeof(*pa));
 }
 
 static int

Index: src/sys/arch/arm/cortex/gic_v2m.h
diff -u src/sys/arch/arm/cortex/gic_v2m.h:1.1.8.1 src/sys/arch/arm/cortex/gic_v2m.h:1.1.8.2
--- src/sys/arch/arm/cortex/gic_v2m.h:1.1.8.1	Tue Oct 15 19:40:34 2019
+++ src/sys/arch/arm/cortex/gic_v2m.h	Thu May  7 18:25:14 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_v2m.h,v 1.1.8.1 2019/10/15 19:40:34 martin Exp $ */
+/* $NetBSD: gic_v2m.h,v 1.1.8.2 2020/05/07 18:25:14 martin Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@ struct gic_v2m_frame {
 	uint32_t		frame_flags;
 #define	GIC_V2M_FLAG_GRAVITON		0x01	/* Amazon Graviton quirk */
 
-	const struct pci_attach_args *frame_pa[GICC_IAR_IRQ];
+	struct pci_attach_args *frame_pa[GICC_IAR_IRQ];
 
 	struct arm_pci_msi	frame_msi;
 };



CVS commit: [netbsd-9] src/usr.bin/finger

2020-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May  7 18:22:58 UTC 2020

Modified Files:
src/usr.bin/finger [netbsd-9]: finger.1 util.c

Log Message:
Pull up following revision(s) (requested by kim in ticket #894):

usr.bin/finger/finger.1: revision 1.22
usr.bin/finger/util.c: revision 1.30

Add lastlogx support


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.16.1 src/usr.bin/finger/finger.1
cvs rdiff -u -r1.29 -r1.29.18.1 src/usr.bin/finger/util.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/finger/finger.1
diff -u src/usr.bin/finger/finger.1:1.19 src/usr.bin/finger/finger.1:1.19.16.1
--- src/usr.bin/finger/finger.1:1.19	Thu Dec 22 12:39:40 2016
+++ src/usr.bin/finger/finger.1	Thu May  7 18:22:58 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: finger.1,v 1.19 2016/12/22 12:39:40 abhinav Exp $
+.\"	$NetBSD: finger.1,v 1.19.16.1 2020/05/07 18:22:58 martin Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993, 1994
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)finger.1	8.3 (Berkeley) 5/5/94
 .\"
-.Dd December 25, 2014
+.Dd May 7, 2020
 .Dt FINGER 1
 .Os
 .Sh NAME
@@ -199,9 +199,23 @@ The
 .Fl l
 option is the only option that may be passed to a remote machine.
 .Sh FILES
-.Bl -tag -width /var/log/lastlog -compact
+.Bl -tag -width /var/log/lastlogx -compact
+.It Pa /var/run/utmpx
+The
+.Nm utmpx
+file.
+.It Pa /var/log/lastlogx
+The
+.Nm lastlogx
+file.
+.It Pa /var/run/utmp
+The
+.Nm utmp
+file.
 .It Pa /var/log/lastlog
-last login data base
+The
+.Nm lastlog
+file.
 .El
 .Sh SEE ALSO
 .Xr chpass 1 ,

Index: src/usr.bin/finger/util.c
diff -u src/usr.bin/finger/util.c:1.29 src/usr.bin/finger/util.c:1.29.18.1
--- src/usr.bin/finger/util.c:1.29	Wed Mar  9 16:12:14 2016
+++ src/usr.bin/finger/util.c	Thu May  7 18:22:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.29 2016/03/09 16:12:14 chs Exp $	*/
+/*	$NetBSD: util.c,v 1.29.18.1 2020/05/07 18:22:58 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -72,7 +72,7 @@
 #if 0
 static char sccsid[] = "@(#)util.c	8.3 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: util.c,v 1.29 2016/03/09 16:12:14 chs Exp $");
+__RCSID("$NetBSD: util.c,v 1.29.18.1 2020/05/07 18:22:58 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -90,7 +90,6 @@ __RCSID("$NetBSD: util.c,v 1.29 2016/03/
 #include 
 #include 
 #include 
-#include 
 
 #include "utmpentry.h"
 
@@ -160,15 +159,40 @@ void
 enter_lastlog(PERSON *pn)
 {
 	WHERE *w;
-	static int opened, fd;
+	static int opened;
+#ifdef SUPPORT_UTMPX
+# define ll_time	ll_tv.tv_sec
+# define UT_LINESIZE	_UTX_LINESIZE
+# define UT_HOSTSIZE	_UTX_HOSTSIZE
+	static DB *lldb = NULL;
+	DBT key, data;
+	struct lastlogx ll;
+#else
+	static int fd;
 	struct lastlog ll;
+#endif
 	char doit = 0;
 
+	(void)memset(, 0, sizeof(ll));
+
 	/* some systems may not maintain lastlog, don't report errors. */
 	if (!opened) {
+#ifdef SUPPORT_UTMPX
+		lldb = dbopen(_PATH_LASTLOGX, O_RDONLY|O_SHLOCK, 0, DB_HASH, NULL);
+#else
 		fd = open(_PATH_LASTLOG, O_RDONLY, 0);
+#endif
 		opened = 1;
 	}
+#ifdef SUPPORT_UTMPX
+	if (lldb != NULL) {
+		key.data = >uid;
+		key.size = sizeof(pn->uid);
+		if ((*lldb->get)(lldb, , , 0) == 0 &&
+		data.size == sizeof(ll))
+			(void)memcpy(, data.data, sizeof(ll));
+	}
+#else
 	if (fd == -1 ||
 	lseek(fd, (off_t)pn->uid * sizeof(ll), SEEK_SET) !=
 	(off_t)pn->uid * (off_t)sizeof(ll) ||
@@ -177,6 +201,7 @@ enter_lastlog(PERSON *pn)
 			ll.ll_line[0] = ll.ll_host[0] = '\0';
 			ll.ll_time = 0;
 		}
+#endif
 	if ((w = pn->whead) == NULL)
 		doit = 1;
 	else if (ll.ll_time != 0) {



CVS commit: [netbsd-9] src/usr.sbin/lastlogin

2020-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May  7 18:19:28 UTC 2020

Modified Files:
src/usr.sbin/lastlogin [netbsd-9]: lastlogin.8 lastlogin.c

Log Message:
Pull up following revision(s) (requested by kim in ticket #893):

usr.sbin/lastlogin/lastlogin.c: revision 1.16
usr.sbin/lastlogin/lastlogin.c: revision 1.17
usr.sbin/lastlogin/lastlogin.c: revision 1.18
usr.sbin/lastlogin/lastlogin.c: revision 1.19
usr.sbin/lastlogin/lastlogin.c: revision 1.20
usr.sbin/lastlogin/lastlogin.8: revision 1.13
usr.sbin/lastlogin/lastlogin.8: revision 1.14

Size output columns dynamically by default to fit contents.

If the passwd entry is not found for a lastlogx entry, cons up a fake
struct passwd where pw_name is the numeric uid in parentheses. This was
already implemented for lastlog entries in revision 1.13.

If -n is specified more than once, also print the user numerically
(ie, uid instead of username) for lastlog entries. This was already
implemented for lastlogx entries in revision 1.13.

Reorder the lastlogx host name numeric condition so it better matches
the user name numeric condition.

Use memcpy for copying out lastlog and lastlogx text
Lastlog and lastlogx text fields are not NUL-terminated when original data
is truncated.

Output records in original order

Append to the list of output records instead of pushing on it, so we
don't reverse the order of records (when not sorting).

New sentence, new line.

Sync usage with man page.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.48.1 src/usr.sbin/lastlogin/lastlogin.8
cvs rdiff -u -r1.15 -r1.15.44.1 src/usr.sbin/lastlogin/lastlogin.c

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

Modified files:

Index: src/usr.sbin/lastlogin/lastlogin.8
diff -u src/usr.sbin/lastlogin/lastlogin.8:1.12 src/usr.sbin/lastlogin/lastlogin.8:1.12.48.1
--- src/usr.sbin/lastlogin/lastlogin.8:1.12	Wed Apr  8 14:20:38 2009
+++ src/usr.sbin/lastlogin/lastlogin.8	Thu May  7 18:19:28 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: lastlogin.8,v 1.12 2009/04/08 14:20:38 joerg Exp $
+.\"	$NetBSD: lastlogin.8,v 1.12.48.1 2020/05/07 18:19:28 martin Exp $
 .\"
 .\" Copyright (c) 1996 John M. Vinopal
 .\" All rights reserved.
@@ -30,7 +30,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 4, 2005
+.Dd May 6, 2020
 .Dt LASTLOGIN 8
 .Os
 .Sh NAME
@@ -38,7 +38,7 @@
 .Nd indicate last login time of users
 .Sh SYNOPSIS
 .Nm
-.Op Fl nrt
+.Op Fl Fnrt
 .Op Fl f Ar filename
 .Op Fl H Ar hostsize
 .Op Fl L Ar linesize
@@ -48,15 +48,16 @@
 .Nm
 will list the last login session of specified
 .Ar users ,
-or for all users by default.  Each line of output contains
-the user name, the tty from which the session was conducted, any
-hostname, and the start time for the session.
+or for all users by default.
+Each line of output contains the user name, the tty from which the
+session was conducted, any hostname, and the start time for the
+session.
 .Pp
 If multiple
 .Ar users
 are given, the session information for each user is printed in
-the order given on the command line.  Otherwise, information
-for all users is printed, sorted by uid.
+the order given on the command line.
+Otherwise, information for all users is printed, sorted by uid.
 .Pp
 .Nm
 differs from
@@ -66,6 +67,8 @@ The last login database is never turned 
 .Pp
 The following options are available:
 .Bl -tag -width indent
+.It Fl F
+Use fixed widths for all output fields.
 .It Fl f Ar filename
 Process input from
 .Ar filename .

Index: src/usr.sbin/lastlogin/lastlogin.c
diff -u src/usr.sbin/lastlogin/lastlogin.c:1.15 src/usr.sbin/lastlogin/lastlogin.c:1.15.44.1
--- src/usr.sbin/lastlogin/lastlogin.c:1.15	Wed Aug 31 13:31:29 2011
+++ src/usr.sbin/lastlogin/lastlogin.c	Thu May  7 18:19:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lastlogin.c,v 1.15 2011/08/31 13:31:29 joerg Exp $	*/
+/*	$NetBSD: lastlogin.c,v 1.15.44.1 2020/05/07 18:19:28 martin Exp $	*/
 /*
  * Copyright (c) 1996 John M. Vinopal
  * All rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lastlogin.c,v 1.15 2011/08/31 13:31:29 joerg Exp $");
+__RCSID("$NetBSD: lastlogin.c,v 1.15.44.1 2020/05/07 18:19:28 martin Exp $");
 #endif
 
 #include 
@@ -57,12 +57,35 @@ __RCSID("$NetBSD: lastlogin.c,v 1.15 201
 #include 
 #include 
 
+#ifndef UT_NAMESIZE
+# define UT_NAMESIZE	8
+#endif
+#ifndef UT_LINESIZE
+# define UT_LINESIZE	8
+#endif
+#ifndef UT_HOSTSIZE
+# define UT_HOSTSIZE	16
+#endif
+
+#ifndef UTX_USERSIZE
+# define UTX_USERSIZE	64
+#endif
+#ifndef UTX_LINESIZE
+# define UTX_LINESIZE	64
+#endif
+#ifndef UTX_HOSTSIZE
+# define UTX_HOSTSIZE	256
+#endif
+
+/*
+ * Fields in the structure below are 1 byte longer than the maximum possible
+ * for NUL-termination.
+ */
 struct output {
 	struct timeval	 o_tv;
-	struct sockaddr_storage o_ss;
-	char		 

CVS commit: src/etc/rc.d

2020-05-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu May  7 18:15:29 UTC 2020

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

Log Message:
Pass full pathname to df, and print warning message on failure.

No need to extract dirname; `df -P /var/db/entropy-file' and `df -l
/var/db/entropy-file' work just fine.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/etc/rc.d/random_seed

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

Modified files:

Index: src/etc/rc.d/random_seed
diff -u src/etc/rc.d/random_seed:1.10 src/etc/rc.d/random_seed:1.11
--- src/etc/rc.d/random_seed:1.10	Wed May  6 18:49:26 2020
+++ src/etc/rc.d/random_seed	Thu May  7 18:15:29 2020
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: random_seed,v 1.10 2020/05/06 18:49:26 riastradh Exp $
+# $NetBSD: random_seed,v 1.11 2020/05/07 18:15:29 riastradh Exp $
 #
 
 # PROVIDE: random_seed
@@ -61,7 +61,8 @@ random_load()
 		return
 	fi
 
-	if ! fs_safe "$(dirname "${random_file}")"; then
+	if ! fs_safe "${random_file}"; then
+		message "Unsafe file system for random seed ${random_file}"
 		flags=-i
 	fi
 



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

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 18:13:05 UTC 2020

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

Log Message:
Fix LOCKDEBUG compilation on i386.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/x86/x86/patch.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/patch.c
diff -u src/sys/arch/x86/x86/patch.c:1.48 src/sys/arch/x86/x86/patch.c:1.49
--- src/sys/arch/x86/x86/patch.c:1.48	Sat May  2 16:25:47 2020
+++ src/sys/arch/x86/x86/patch.c	Thu May  7 18:13:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: patch.c,v 1.48 2020/05/02 16:25:47 maxv Exp $	*/
+/*	$NetBSD: patch.c,v 1.49 2020/05/07 18:13:05 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.48 2020/05/02 16:25:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.49 2020/05/07 18:13:05 maxv Exp $");
 
 #include "opt_lockdebug.h"
 #ifdef i386
@@ -171,6 +171,7 @@ static const struct x86_hotpatch_descrip
 __link_set_add_rodata(x86_hotpatch_descriptors, hp_cx8_spllower_desc);
 
 /* MUTEX_EXIT. */
+#ifndef LOCKDEBUG
 extern uint8_t i686_mutex_spin_exit, i686_mutex_spin_exit_end;
 static const struct x86_hotpatch_source hp_i686_mutex_spin_exit_source = {
 	.saddr = _mutex_spin_exit,
@@ -183,6 +184,7 @@ static const struct x86_hotpatch_descrip
 };
 __link_set_add_rodata(x86_hotpatch_descriptors, hp_i686_mutex_spin_exit_desc);
 #endif
+#endif
 
 /* -- */
 



CVS commit: src/sys/lib/libsa

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 18:02:48 UTC 2020

Modified Files:
src/sys/lib/libsa: loadfile_elf32.c

Log Message:
Update the comments.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/lib/libsa/loadfile_elf32.c

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

Modified files:

Index: src/sys/lib/libsa/loadfile_elf32.c
diff -u src/sys/lib/libsa/loadfile_elf32.c:1.56 src/sys/lib/libsa/loadfile_elf32.c:1.57
--- src/sys/lib/libsa/loadfile_elf32.c:1.56	Thu Oct 17 14:00:28 2019
+++ src/sys/lib/libsa/loadfile_elf32.c	Thu May  7 18:02:48 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: loadfile_elf32.c,v 1.56 2019/10/17 14:00:28 maxv Exp $ */
+/* $NetBSD: loadfile_elf32.c,v 1.57 2020/05/07 18:02:48 maxv Exp $ */
 
 /*
  * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc.
@@ -332,9 +332,9 @@ ELFNAMEEND(readfile_global)(int fd, u_lo
 
 /*
  * Load a dynamic ELF binary into memory. Layout of the memory:
- * ++-+-+--+
- * | ELF HEADER | SECTION HEADERS | KERNEL SECTIONS | SYM+REL SECTIONS |
- * ++-+-+--+
+ * ++--+++
+ * | ELF HEADER | SECT HEADERS | KERN SECTS | REL/RELA/SYM/STR SECTS |
+ * ++--+++
  * The ELF HEADER start address is marks[MARK_END]. We then map the rest
  * by increasing maxp. An alignment is enforced between the code sections.
  *
@@ -438,7 +438,7 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf
 	maxp = roundup(maxp, KERNALIGN_LARGE);
 
 	/*
-	 * Load the SYM+REL SECTIONS.
+	 * Load the REL/RELA/SYM/STR SECTIONS.
 	 */
 	maxp = roundup(maxp, ELFROUND);
 	for (i = 0; i < elf->e_shnum; i++) {



CVS commit: src/sys/arch/amd64/stand/prekern

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 17:58:26 UTC 2020

Modified Files:
src/sys/arch/amd64/stand/prekern: elf.c mm.c

Log Message:
Clarify.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/amd64/stand/prekern/elf.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/amd64/stand/prekern/mm.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/stand/prekern/elf.c
diff -u src/sys/arch/amd64/stand/prekern/elf.c:1.20 src/sys/arch/amd64/stand/prekern/elf.c:1.21
--- src/sys/arch/amd64/stand/prekern/elf.c:1.20	Thu May  7 16:49:59 2020
+++ src/sys/arch/amd64/stand/prekern/elf.c	Thu May  7 17:58:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf.c,v 1.20 2020/05/07 16:49:59 maxv Exp $	*/
+/*	$NetBSD: elf.c,v 1.21 2020/05/07 17:58:26 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -300,6 +300,37 @@ elf_build_head(vaddr_t headva)
 }
 
 void
+elf_fixup_boot(vaddr_t bootva, paddr_t bootpa)
+{
+	const paddr_t basepa = kernpa_start;
+	const vaddr_t headva = (vaddr_t)eif.ehdr;
+	size_t i, offboot;
+
+	/*
+	 * Fix up the 'sh_offset' field of the REL/RELA/SYM/STR sections, which
+	 * are all in the "boot" region.
+	 */
+	for (i = 0; i < eif.ehdr->e_shnum; i++) {
+		if (eif.shdr[i].sh_type != SHT_STRTAB &&
+		eif.shdr[i].sh_type != SHT_REL &&
+		eif.shdr[i].sh_type != SHT_RELA &&
+		eif.shdr[i].sh_type != SHT_SYMTAB) {
+			continue;
+		}
+		if (eif.shdr[i].sh_offset == 0) {
+			/* The bootloader dropped it. */
+			continue;
+		}
+
+		/* Offset of the section within the boot region. */
+		offboot = basepa + eif.shdr[i].sh_offset - bootpa;
+
+		/* We want (headva + sh_offset) to be the VA of the region. */
+		eif.shdr[i].sh_offset = (bootva + offboot - headva);
+	}
+}
+
+void
 elf_map_sections(void)
 {
 	const paddr_t basepa = kernpa_start;
@@ -333,45 +364,27 @@ elf_map_sections(void)
 
 		secva = mm_map_segment(segtype, secpa, secsz, secalign);
 
-		/* We want (headva + sh_offset) to be the VA of the section. */
+		/*
+		 * Fix up the 'sh_offset' field of the NOBITS/PROGBITS sections.
+		 * We want (headva + sh_offset) to be the VA of the section.
+		 */
 		ASSERT(secva > headva);
 		shdr->sh_offset = secva - headva;
 	}
 }
 
 void
-elf_build_boot(vaddr_t bootva, paddr_t bootpa)
+elf_build_info(void)
 {
-	const paddr_t basepa = kernpa_start;
-	const vaddr_t headva = (vaddr_t)eif.ehdr;
-	size_t i, j, offboot;
-
-	for (i = 0; i < eif.ehdr->e_shnum; i++) {
-		if (eif.shdr[i].sh_type != SHT_STRTAB &&
-		eif.shdr[i].sh_type != SHT_REL &&
-		eif.shdr[i].sh_type != SHT_RELA &&
-		eif.shdr[i].sh_type != SHT_SYMTAB) {
-			continue;
-		}
-		if (eif.shdr[i].sh_offset == 0) {
-			/* hasn't been loaded */
-			continue;
-		}
-
-		/* Offset of the section within the boot region. */
-		offboot = basepa + eif.shdr[i].sh_offset - bootpa;
-
-		/* We want (headva + sh_offset) to be the VA of the region. */
-		eif.shdr[i].sh_offset = (bootva + offboot - headva);
-	}
+	size_t i, j;
 
 	/* Locate the section names */
 	j = eif.ehdr->e_shstrndx;
 	if (j == SHN_UNDEF) {
-		fatal("elf_build_boot: shstrtab not found");
+		fatal("elf_build_info: shstrtab not found");
 	}
 	if (j >= eif.ehdr->e_shnum) {
-		fatal("elf_build_boot: wrong shstrtab index");
+		fatal("elf_build_info: wrong shstrtab index");
 	}
 	eif.shstrtab = (char *)((uint8_t *)eif.ehdr + eif.shdr[j].sh_offset);
 	eif.shstrsz = eif.shdr[j].sh_size;
@@ -382,10 +395,10 @@ elf_build_boot(vaddr_t bootva, paddr_t b
 			break;
 	}
 	if (i == eif.ehdr->e_shnum) {
-		fatal("elf_build_boot: symtab not found");
+		fatal("elf_build_info: symtab not found");
 	}
 	if (eif.shdr[i].sh_offset == 0) {
-		fatal("elf_build_boot: symtab not loaded");
+		fatal("elf_build_info: symtab not loaded");
 	}
 	eif.symtab = (Elf_Sym *)((uint8_t *)eif.ehdr + eif.shdr[i].sh_offset);
 	eif.symcnt = eif.shdr[i].sh_size / sizeof(Elf_Sym);
@@ -393,13 +406,13 @@ elf_build_boot(vaddr_t bootva, paddr_t b
 	/* Also locate the string table */
 	j = eif.shdr[i].sh_link;
 	if (j == SHN_UNDEF || j >= eif.ehdr->e_shnum) {
-		fatal("elf_build_boot: wrong strtab index");
+		fatal("elf_build_info: wrong strtab index");
 	}
 	if (eif.shdr[j].sh_type != SHT_STRTAB) {
-		fatal("elf_build_boot: wrong strtab type");
+		fatal("elf_build_info: wrong strtab type");
 	}
 	if (eif.shdr[j].sh_offset == 0) {
-		fatal("elf_build_boot: strtab not loaded");
+		fatal("elf_build_info: strtab not loaded");
 	}
 	eif.strtab = (char *)((uint8_t *)eif.ehdr + eif.shdr[j].sh_offset);
 	eif.strsz = eif.shdr[j].sh_size;

Index: src/sys/arch/amd64/stand/prekern/mm.c
diff -u src/sys/arch/amd64/stand/prekern/mm.c:1.26 src/sys/arch/amd64/stand/prekern/mm.c:1.27
--- src/sys/arch/amd64/stand/prekern/mm.c:1.26	Thu May  7 17:10:02 2020
+++ src/sys/arch/amd64/stand/prekern/mm.c	Thu May  7 17:58:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mm.c,v 1.26 

CVS commit: src/sys/arch/amd64/stand/prekern

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 17:10:02 UTC 2020

Modified Files:
src/sys/arch/amd64/stand/prekern: mm.c

Log Message:
Explain more.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/amd64/stand/prekern/mm.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/stand/prekern/mm.c
diff -u src/sys/arch/amd64/stand/prekern/mm.c:1.25 src/sys/arch/amd64/stand/prekern/mm.c:1.26
--- src/sys/arch/amd64/stand/prekern/mm.c:1.25	Sat Feb 15 10:41:25 2020
+++ src/sys/arch/amd64/stand/prekern/mm.c	Thu May  7 17:10:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mm.c,v 1.25 2020/02/15 10:41:25 maxv Exp $	*/
+/*	$NetBSD: mm.c,v 1.26 2020/05/07 17:10:02 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -248,7 +248,7 @@ mm_randva_kregion(size_t size, size_t pa
 }
 
 static paddr_t
-bootspace_getend(void)
+bootspace_get_kern_segs_end_pa(void)
 {
 	paddr_t pa, max = 0;
 	size_t i;
@@ -410,21 +410,29 @@ mm_map_boot(void)
 	 * the number of pages entered is lower.
 	 */
 
-	/* Create the page tree */
+	/* Create the page tree, starting at a random VA */
 	size = (NKL2_KIMG_ENTRIES + 1) * NBPD_L2;
 	randva = mm_randva_kregion(size, PAGE_SIZE);
 
-	/* Enter the area and build the ELF info */
-	bootpa = bootspace_getend();
+	/* The "boot" region begins right after the kernel segments */
+	bootpa = bootspace_get_kern_segs_end_pa();
+
+	/* The prekern consumed some memory up until pa_avail, this covers
+	 * SYM+REL and EXTRA */
 	size = (pa_avail - bootpa);
 	npages = size / PAGE_SIZE;
+
+	/* Enter the whole area linearly */
 	for (i = 0; i < npages; i++) {
 		mm_enter_pa(bootpa + i * PAGE_SIZE,
 		randva + i * PAGE_SIZE, MM_PROT_READ|MM_PROT_WRITE);
 	}
+
+	/* At this point both "head" and "boot" are mapped, so we can build
+	 * the ELF info */
 	elf_build_boot(randva, bootpa);
 
-	/* Enter the ISA I/O MEM */
+	/* Map the ISA I/O MEM right after EXTRA */
 	iom_base = randva + npages * PAGE_SIZE;
 	npages = IOM_SIZE / PAGE_SIZE;
 	for (i = 0; i < npages; i++) {
@@ -451,23 +459,25 @@ mm_map_boot(void)
  * ++-+---+--+---+
  * | ELF HEADER | SECTION HEADERS | KERN SECTIONS | SYM+REL SECTIONS | EXTRA |
  * ++-+---+--+---+
- * Which we abstract into several "regions":
+ * This was done in the loadfile_elf32.c:loadfile_dynamic() function.
+ *
+ * We abstract this layout into several "regions":
  * +--+---+--+
- * | Head region  | Several segs  |   Boot region|
+ * | Head region  |  Kernel segs  |   Boot region|
  * +--+---+--+
- * See loadfile_elf32.c:loadfile_dynamic() for the details.
  *
  * There is a variable number of independent regions we create: one head,
  * several kernel segments, one boot. They are all mapped at random VAs.
  *
- * Head contains the ELF Header and ELF Section Headers, and we use them to
- * map the rest of the regions. Head must be placed in both virtual memory
- * and physical memory *before* the rest.
+ * "Head" contains the ELF Header and ELF Section Headers, and we use them to
+ * map the rest of the regions. Head must be placed *before* the other
+ * regions, in both virtual memory and physical memory.
  *
- * The Kernel Sections are mapped at random VAs using individual segments
- * in bootspace.
+ * The "Kernel Segments" contain the kernel SHT_NOBITS and SHT_PROGBITS
+ * sections, in a 1:1 manner (one segment is associated with one section).
+ * The segments are mapped at random VAs and referenced in bootspace.segs[].
  *
- * Boot contains various information, including the ELF Sym+Rel sections,
+ * "Boot" contains various information, including the ELF Sym+Rel sections,
  * plus extra memory the prekern has used so far; it is a region that the
  * kernel will eventually use for module_map. Boot is placed *after* the
  * other regions in physical memory. In virtual memory however there is no



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

2020-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May  7 17:06:44 UTC 2020

Modified Files:
src/sys/dev/sdmmc [netbsd-9]: if_bwfm_sdio.c

Log Message:
Pull up following revision(s) (requested by macallan in ticket #892):

sys/dev/sdmmc/if_bwfm_sdio.c: revision 1.15

add entry for BCM43362, found on Cubietruck
ok jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.3.8.1 -r1.3.8.2 src/sys/dev/sdmmc/if_bwfm_sdio.c

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

Modified files:

Index: src/sys/dev/sdmmc/if_bwfm_sdio.c
diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.3.8.1 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.3.8.2
--- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.3.8.1	Tue Feb 25 18:40:43 2020
+++ src/sys/dev/sdmmc/if_bwfm_sdio.c	Thu May  7 17:06:44 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bwfm_sdio.c,v 1.3.8.1 2020/02/25 18:40:43 martin Exp $ */
+/* $NetBSD: if_bwfm_sdio.c,v 1.3.8.2 2020/05/07 17:06:44 martin Exp $ */
 /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -239,6 +239,11 @@ static const struct bwfm_sdio_product {
 		SDMMC_PRODUCT_BROADCOM_BCM43455, 
 		SDMMC_CIS_BROADCOM_BCM43455
 	},
+	{
+		SDMMC_VENDOR_BROADCOM,
+		SDMMC_PRODUCT_BROADCOM_BCM43362, 
+		SDMMC_CIS_BROADCOM_BCM43362
+	},
 };
 
 static const char *compatible[] = {



CVS commit: [netbsd-9] src/sys/arch/arm/sunxi

2020-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May  7 17:05:07 UTC 2020

Modified Files:
src/sys/arch/arm/sunxi [netbsd-9]: sun4i_a10_ccu.c

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

sys/arch/arm/sunxi/sun4i_a10_ccu.c: revision 1.12

Add A20 CLK_OUT_A and CLK_OUT_B clocks


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/arch/arm/sunxi/sun4i_a10_ccu.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/sunxi/sun4i_a10_ccu.c
diff -u src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.10 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.10.4.1
--- src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.10	Tue Jan 22 23:06:49 2019
+++ src/sys/arch/arm/sunxi/sun4i_a10_ccu.c	Thu May  7 17:05:07 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sun4i_a10_ccu.c,v 1.10 2019/01/22 23:06:49 jmcneill Exp $ */
+/* $NetBSD: sun4i_a10_ccu.c,v 1.10.4.1 2020/05/07 17:05:07 martin Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.10 2019/01/22 23:06:49 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.10.4.1 2020/05/07 17:05:07 martin Exp $");
 
 #include 
 #include 
@@ -78,6 +78,8 @@ __KERNEL_RCSID(1, "$NetBSD: sun4i_a10_cc
 #define	HDMI_CLOCK_CFG_REG	0x150
 #define	MALI_CLOCK_CFG_REG	0x154
 #define	IEP_SCLK_CFG_REG	0x160
+#define	CLK_OUTA_REG		0x1f0
+#define	CLK_OUTB_REG		0x1f4
 
 static int sun4i_a10_ccu_match(device_t, cfdata_t, void *);
 static void sun4i_a10_ccu_attach(device_t, device_t, void *);
@@ -119,6 +121,7 @@ static const char *mod_parents[] = { "os
 static const char *sata_parents[] = { "pll6_periph_sata", "external" };
 static const char *de_parents[] = { "pll_video0", "pll_video1", "pll_ddr_other" };
 static const char *lcd_parents[] = { "pll_video0", "pll_video1", "pll_video0x2", "pll_video1x2" };
+static const char *out_parents[] = { "losc" /* really OSC24MHz/750 */, "losc", "osc24m" };
 
 static const struct sunxi_ccu_nkmp_tbl sun4i_a10_pll1_table[] = {
 	{ 100800, 21, 1, 0, 0 },
@@ -448,6 +451,23 @@ static struct sunxi_ccu_clk sun4i_a10_cc
 	0/* flags */
 	),
 
+	/* A20 specific */
+	SUNXI_CCU_NM(A20_CLK_OUT_A, "outa", out_parents,
+	CLK_OUTA_REG,		/* reg */
+	__BITS(21,20),		/* n */
+	__BITS(12,8),		/* m */
+	__BITS(25,24),		/* sel */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO),
+
+	SUNXI_CCU_NM(A20_CLK_OUT_B, "outb", out_parents,
+	CLK_OUTB_REG,		/* reg */
+	__BITS(21,20),		/* n */
+	__BITS(12,8),		/* m */
+	__BITS(25,24),		/* sel */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO),
+
 	/* AHB_GATING_REG0 */
 	SUNXI_CCU_GATE(A10_CLK_AHB_OTG, "ahb-otg", "ahb",
 	AHB_GATING_REG0, 0),



CVS commit: [netbsd-8] src/doc

2020-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May  7 17:03:51 UTC 2020

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

Log Message:
Ticket #1546


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.8 -r1.1.2.9 src/doc/CHANGES-8.3

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

Modified files:

Index: src/doc/CHANGES-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.8 src/doc/CHANGES-8.3:1.1.2.9
--- src/doc/CHANGES-8.3:1.1.2.8	Tue May  5 18:52:57 2020
+++ src/doc/CHANGES-8.3	Thu May  7 17:03:51 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.3,v 1.1.2.8 2020/05/05 18:52:57 martin Exp $
+# $NetBSD: CHANGES-8.3,v 1.1.2.9 2020/05/07 17:03:51 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -131,3 +131,11 @@ external/bsd/bind/dist/lib/isc/sha2.c		(
 
 	Fix a bug introduced when fixing alingment issues.
 	[he, ticket #1545]
+
+bin/rcp/rcp.c	1.50
+
+	In sink(), upon error, avoid multiple replies to the source
+	as this would lead to a desynchronization of the protocol and
+	further files or directories to be ignored or corrupted.
+	[aymeric, ticket #1546]
+



CVS commit: [netbsd-8] src/bin/rcp

2020-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May  7 17:02:33 UTC 2020

Modified Files:
src/bin/rcp [netbsd-8]: rcp.c

Log Message:
Pull up following revision(s) (requested by aymeric in ticket #1546):

bin/rcp/rcp.c: revision 1.50

In sink(), upon error, avoid multiple replies to the source as this
would lead to a desynchronization of the protocol and further files or
directories to be ignored or corrupted.

Reported by Daniel Goujot, Georges-Axel Jaloyan, Ryan Lahfa, and David Naccache.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.49.26.1 src/bin/rcp/rcp.c

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

Modified files:

Index: src/bin/rcp/rcp.c
diff -u src/bin/rcp/rcp.c:1.49 src/bin/rcp/rcp.c:1.49.26.1
--- src/bin/rcp/rcp.c:1.49	Mon May  7 15:22:54 2012
+++ src/bin/rcp/rcp.c	Thu May  7 17:02:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $	*/
+/*	$NetBSD: rcp.c,v 1.49.26.1 2020/05/07 17:02:33 martin Exp $	*/
 
 /*
  * Copyright (c) 1983, 1990, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)rcp.c	8.2 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $");
+__RCSID("$NetBSD: rcp.c,v 1.49.26.1 2020/05/07 17:02:33 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -470,7 +470,6 @@ sink(int argc, char *argv[])
 	static BUF buffer;
 	struct stat stb;
 	struct timeval tv[2];
-	enum { YES, NO, DISPLAYED } wrerr;
 	BUF *bp;
 	ssize_t j;
 	off_t i;
@@ -480,8 +479,9 @@ sink(int argc, char *argv[])
 	mode_t mask;
 	mode_t mode;
 	mode_t omode;
-	int setimes, targisdir;
+	int setimes, targisdir, wrerr;
 	int wrerrno = 0;	/* pacify gcc */
+	const char *wrcontext = NULL;
 	char ch, *cp, *np, *targ, *vect[1], buf[BUFSIZ];
 	const char *why;
 	off_t size;
@@ -624,9 +624,7 @@ sink(int argc, char *argv[])
 			sink(1, vect);
 			if (setimes) {
 setimes = 0;
-if (utimes(np, tv) < 0)
-run_err("%s: set times: %s",
-	np, strerror(errno));
+(void) utimes(np, tv);
 			}
 			if (mod_flag)
 (void)chmod(np, mode);
@@ -644,7 +642,20 @@ bad:			run_err("%s: %s", np, strerror(er
 			continue;
 		}
 		cp = bp->buf;
-		wrerr = NO;
+		wrerr = 0;
+
+/*
+ * Like run_err(), but don't send any message to the remote end.
+ * Instead, record the first error and send that in the end.
+ */
+#define RUN_ERR(w_context) do { \
+	if (!wrerr) {			\
+		wrerrno = errno;	\
+		wrcontext = w_context;	\
+		wrerr = 1;		\
+	}\
+} while(0)
+
 		count = 0;
 		for (i = 0; i < size; i += BUFSIZ) {
 			amt = BUFSIZ;
@@ -663,69 +674,56 @@ bad:			run_err("%s: %s", np, strerror(er
 			} while (amt > 0);
 			if (count == bp->cnt) {
 /* Keep reading so we stay sync'd up. */
-if (wrerr == NO) {
+if (!wrerr) {
 	j = write(ofd, bp->buf, (size_t)count);
 	if (j != count) {
-		wrerr = YES;
-		wrerrno = j >= 0 ? EIO : errno; 
+		if (j >= 0)
+			errno = EIO;
+		RUN_ERR("write");
 	}
 }
 count = 0;
 cp = bp->buf;
 			}
 		}
-		if (count != 0 && wrerr == NO &&
+		if (count != 0 && !wrerr &&
 		(j = write(ofd, bp->buf, (size_t)count)) != count) {
-			wrerr = YES;
-			wrerrno = j >= 0 ? EIO : errno; 
-		}
-		if (ftruncate(ofd, size)) {
-			run_err("%s: truncate: %s", np, strerror(errno));
-			wrerr = DISPLAYED;
+			if (j >= 0)
+errno = EIO;
+			RUN_ERR("write");
 		}
+		if (ftruncate(ofd, size))
+			RUN_ERR("truncate");
+
 		if (pflag) {
 			if (exists || omode != mode)
 if (fchmod(ofd, omode))
-	run_err("%s: set mode: %s",
-	np, strerror(errno));
+	RUN_ERR("set mode");
 		} else {
 			if (!exists && omode != mode)
 if (fchmod(ofd, omode & ~mask))
-	run_err("%s: set mode: %s",
-	np, strerror(errno));
+	RUN_ERR("set mode");
 		}
 #ifndef __SVR4
-		if (setimes && wrerr == NO) {
+		if (setimes && !wrerr) {
 			setimes = 0;
-			if (futimes(ofd, tv) < 0) {
-run_err("%s: set times: %s",
-np, strerror(errno));
-wrerr = DISPLAYED;
-			}
+			if (futimes(ofd, tv) < 0)
+RUN_ERR("set times");
 		}
 #endif
 		(void)close(ofd);
 #ifdef __SVR4
-		if (setimes && wrerr == NO) {
+		if (setimes && !wrerr) {
 			setimes = 0;
-			if (utimes(np, tv) < 0) {
-run_err("%s: set times: %s",
-np, strerror(errno));
-wrerr = DISPLAYED;
-			}
+			if (utimes(np, tv) < 0)
+RUN_ERR("set times");
 		}
 #endif
 		(void)response();
-		switch(wrerr) {
-		case YES:
-			run_err("%s: write: %s", np, strerror(wrerrno));
-			break;
-		case NO:
+		if (wrerr)
+			run_err("%s: %s: %s", np, wrcontext, strerror(wrerrno));
+		else
 			(void)write(rem, "", 1);
-			break;
-		case DISPLAYED:
-			break;
-		}
 	}
 
 out:



CVS commit: [netbsd-9] src/bin/rcp

2020-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu May  7 17:01:13 UTC 2020

Modified Files:
src/bin/rcp [netbsd-9]: rcp.c

Log Message:
Pull up following revision(s) (requested by aymeric in ticket #890):

bin/rcp/rcp.c: revision 1.50

In sink(), upon error, avoid multiple replies to the source as this
would lead to a desynchronization of the protocol and further files or
directories to be ignored or corrupted.

Reported by Daniel Goujot, Georges-Axel Jaloyan, Ryan Lahfa, and David Naccache.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.49.36.1 src/bin/rcp/rcp.c

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

Modified files:

Index: src/bin/rcp/rcp.c
diff -u src/bin/rcp/rcp.c:1.49 src/bin/rcp/rcp.c:1.49.36.1
--- src/bin/rcp/rcp.c:1.49	Mon May  7 15:22:54 2012
+++ src/bin/rcp/rcp.c	Thu May  7 17:01:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $	*/
+/*	$NetBSD: rcp.c,v 1.49.36.1 2020/05/07 17:01:13 martin Exp $	*/
 
 /*
  * Copyright (c) 1983, 1990, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)rcp.c	8.2 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $");
+__RCSID("$NetBSD: rcp.c,v 1.49.36.1 2020/05/07 17:01:13 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -470,7 +470,6 @@ sink(int argc, char *argv[])
 	static BUF buffer;
 	struct stat stb;
 	struct timeval tv[2];
-	enum { YES, NO, DISPLAYED } wrerr;
 	BUF *bp;
 	ssize_t j;
 	off_t i;
@@ -480,8 +479,9 @@ sink(int argc, char *argv[])
 	mode_t mask;
 	mode_t mode;
 	mode_t omode;
-	int setimes, targisdir;
+	int setimes, targisdir, wrerr;
 	int wrerrno = 0;	/* pacify gcc */
+	const char *wrcontext = NULL;
 	char ch, *cp, *np, *targ, *vect[1], buf[BUFSIZ];
 	const char *why;
 	off_t size;
@@ -624,9 +624,7 @@ sink(int argc, char *argv[])
 			sink(1, vect);
 			if (setimes) {
 setimes = 0;
-if (utimes(np, tv) < 0)
-run_err("%s: set times: %s",
-	np, strerror(errno));
+(void) utimes(np, tv);
 			}
 			if (mod_flag)
 (void)chmod(np, mode);
@@ -644,7 +642,20 @@ bad:			run_err("%s: %s", np, strerror(er
 			continue;
 		}
 		cp = bp->buf;
-		wrerr = NO;
+		wrerr = 0;
+
+/*
+ * Like run_err(), but don't send any message to the remote end.
+ * Instead, record the first error and send that in the end.
+ */
+#define RUN_ERR(w_context) do { \
+	if (!wrerr) {			\
+		wrerrno = errno;	\
+		wrcontext = w_context;	\
+		wrerr = 1;		\
+	}\
+} while(0)
+
 		count = 0;
 		for (i = 0; i < size; i += BUFSIZ) {
 			amt = BUFSIZ;
@@ -663,69 +674,56 @@ bad:			run_err("%s: %s", np, strerror(er
 			} while (amt > 0);
 			if (count == bp->cnt) {
 /* Keep reading so we stay sync'd up. */
-if (wrerr == NO) {
+if (!wrerr) {
 	j = write(ofd, bp->buf, (size_t)count);
 	if (j != count) {
-		wrerr = YES;
-		wrerrno = j >= 0 ? EIO : errno; 
+		if (j >= 0)
+			errno = EIO;
+		RUN_ERR("write");
 	}
 }
 count = 0;
 cp = bp->buf;
 			}
 		}
-		if (count != 0 && wrerr == NO &&
+		if (count != 0 && !wrerr &&
 		(j = write(ofd, bp->buf, (size_t)count)) != count) {
-			wrerr = YES;
-			wrerrno = j >= 0 ? EIO : errno; 
-		}
-		if (ftruncate(ofd, size)) {
-			run_err("%s: truncate: %s", np, strerror(errno));
-			wrerr = DISPLAYED;
+			if (j >= 0)
+errno = EIO;
+			RUN_ERR("write");
 		}
+		if (ftruncate(ofd, size))
+			RUN_ERR("truncate");
+
 		if (pflag) {
 			if (exists || omode != mode)
 if (fchmod(ofd, omode))
-	run_err("%s: set mode: %s",
-	np, strerror(errno));
+	RUN_ERR("set mode");
 		} else {
 			if (!exists && omode != mode)
 if (fchmod(ofd, omode & ~mask))
-	run_err("%s: set mode: %s",
-	np, strerror(errno));
+	RUN_ERR("set mode");
 		}
 #ifndef __SVR4
-		if (setimes && wrerr == NO) {
+		if (setimes && !wrerr) {
 			setimes = 0;
-			if (futimes(ofd, tv) < 0) {
-run_err("%s: set times: %s",
-np, strerror(errno));
-wrerr = DISPLAYED;
-			}
+			if (futimes(ofd, tv) < 0)
+RUN_ERR("set times");
 		}
 #endif
 		(void)close(ofd);
 #ifdef __SVR4
-		if (setimes && wrerr == NO) {
+		if (setimes && !wrerr) {
 			setimes = 0;
-			if (utimes(np, tv) < 0) {
-run_err("%s: set times: %s",
-np, strerror(errno));
-wrerr = DISPLAYED;
-			}
+			if (utimes(np, tv) < 0)
+RUN_ERR("set times");
 		}
 #endif
 		(void)response();
-		switch(wrerr) {
-		case YES:
-			run_err("%s: write: %s", np, strerror(wrerrno));
-			break;
-		case NO:
+		if (wrerr)
+			run_err("%s: %s: %s", np, wrcontext, strerror(wrerrno));
+		else
 			(void)write(rem, "", 1);
-			break;
-		case DISPLAYED:
-			break;
-		}
 	}
 
 out:



CVS commit: src/sys/arch/amd64/stand/prekern

2020-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May  7 16:49:59 UTC 2020

Modified Files:
src/sys/arch/amd64/stand/prekern: elf.c

Log Message:
If we encounter relocations from a section that the bootloader dropped,
AND if the section is a note, then skip the relocations.

Considering a note that the bootloader dropped, there are two possible
sides for the relocations: (1) the relocations from the note towards the
rest of the binary, and (2) the relocations from the rest of the binary
towards the note.

We skip (1), which is correct, because the notes do not play any role at
run time. If we encounter (2) however then there is a bug in the kernel,
so add a sanity check against that.

This fixes KASLR since the latest Xen changes (which introduced .note.Xen).


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/amd64/stand/prekern/elf.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/stand/prekern/elf.c
diff -u src/sys/arch/amd64/stand/prekern/elf.c:1.19 src/sys/arch/amd64/stand/prekern/elf.c:1.20
--- src/sys/arch/amd64/stand/prekern/elf.c:1.19	Tue May  5 19:26:47 2020
+++ src/sys/arch/amd64/stand/prekern/elf.c	Thu May  7 16:49:59 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: elf.c,v 1.19 2020/05/05 19:26:47 maxv Exp $	*/
+/*	$NetBSD: elf.c,v 1.20 2020/05/07 16:49:59 maxv Exp $	*/
 
 /*
- * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Maxime Villard.
@@ -60,6 +60,40 @@ elf_check_header(void)
 	return 0;
 }
 
+static bool
+elf_section_mappable(Elf_Shdr *shdr)
+{
+	if (!(shdr->sh_flags & SHF_ALLOC)) {
+		return false;
+	}
+	if (shdr->sh_type != SHT_NOBITS &&
+	shdr->sh_type != SHT_PROGBITS) {
+		return false;
+	}
+	return true;
+}
+
+static bool
+elf_can_drop_unmappable(Elf_Shdr *shdr)
+{
+	/*
+	 * We found relocations from the section 'shdr' towards the rest of
+	 * the binary, but 'shdr' is not mapped. Decide whether to skip the
+	 * relocations from this section.
+	 *
+	 * We skip only if it is a note. It means that we allow notes to
+	 * have relocations towards the rest of the binary, typically with
+	 * the ".note.Xen" section. Notes do not play any role at run time.
+	 *
+	 * Any section other than a note is the sign there is a design
+	 * mistake in the kernel (variables stored outside of rodata/data).
+	 */
+	if (shdr->sh_type == SHT_NOTE) {
+		return true;
+	}
+	return false;
+}
+
 static vaddr_t
 elf_get_entrypoint(void)
 {
@@ -144,6 +178,12 @@ elf_sym_lookup(size_t symidx)
 
 		fatal("elf_sym_lookup: external symbol");
 	}
+	if (sym->st_shndx >= eif.ehdr->e_shnum) {
+		fatal("elf_sym_lookup: st_shndx is malformed");
+	}
+	if (!elf_section_mappable([sym->st_shndx])) {
+		fatal("elf_sym_lookup: st_shndx not mappable");
+	}
 	if (sym->st_value == 0) {
 		fatal("elf_sym_lookup: zero value");
 	}
@@ -259,19 +299,6 @@ elf_build_head(vaddr_t headva)
 	}
 }
 
-static bool
-elf_section_mappable(Elf_Shdr *shdr)
-{
-	if (!(shdr->sh_flags & SHF_ALLOC)) {
-		return false;
-	}
-	if (shdr->sh_type != SHT_NOBITS &&
-	shdr->sh_type != SHT_PROGBITS) {
-		return false;
-	}
-	return true;
-}
-
 void
 elf_map_sections(void)
 {
@@ -429,6 +456,9 @@ elf_kernel_reloc(void)
 			fatal("elf_kernel_reloc: REL sh_info is malformed");
 		}
 		if (!elf_section_mappable([secidx])) {
+			if (elf_can_drop_unmappable([secidx])) {
+continue;
+			}
 			fatal("elf_kernel_reloc: REL sh_info not mappable");
 		}
 		base = (uintptr_t)eif.ehdr + eif.shdr[secidx].sh_offset;
@@ -461,6 +491,9 @@ elf_kernel_reloc(void)
 			fatal("elf_kernel_reloc: RELA sh_info is malformed");
 		}
 		if (!elf_section_mappable([secidx])) {
+			if (elf_can_drop_unmappable([secidx])) {
+continue;
+			}
 			fatal("elf_kernel_reloc: RELA sh_info not mappable");
 		}
 		base = (uintptr_t)eif.ehdr + eif.shdr[secidx].sh_offset;



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

2020-05-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu May  7 16:20:40 UTC 2020

Modified Files:
src/sys/arch/arm/cortex: gic_v2m.c gic_v2m.h

Log Message:
Do not store a pointer to the passed in struct pci_attach_args


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/cortex/gic_v2m.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/cortex/gic_v2m.h

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

Modified files:

Index: src/sys/arch/arm/cortex/gic_v2m.c
diff -u src/sys/arch/arm/cortex/gic_v2m.c:1.8 src/sys/arch/arm/cortex/gic_v2m.c:1.9
--- src/sys/arch/arm/cortex/gic_v2m.c:1.8	Mon Dec  2 03:06:51 2019
+++ src/sys/arch/arm/cortex/gic_v2m.c	Thu May  7 16:20:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_v2m.c,v 1.8 2019/12/02 03:06:51 msaitoh Exp $ */
+/* $NetBSD: gic_v2m.c,v 1.9 2020/05/07 16:20:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_v2m.c,v 1.8 2019/12/02 03:06:51 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_v2m.c,v 1.9 2020/05/07 16:20:40 jmcneill Exp $");
 
 #include 
 #include 
@@ -66,6 +66,7 @@ static int
 gic_v2m_msi_alloc_spi(struct gic_v2m_frame *frame, int count,
 const struct pci_attach_args *pa)
 {
+	struct pci_attach_args *new_pa;
 	int spi, n;
 
 	for (spi = frame->frame_base;
@@ -75,8 +76,11 @@ gic_v2m_msi_alloc_spi(struct gic_v2m_fra
 if (frame->frame_pa[spi + n] != NULL)
 	goto next_spi;
 
-			for (n = 0; n < count; n++)
-frame->frame_pa[spi + n] = pa;
+			for (n = 0; n < count; n++) {
+new_pa = kmem_alloc(sizeof(*new_pa), KM_SLEEP);
+memcpy(new_pa, pa, sizeof(*new_pa));
+frame->frame_pa[spi + n] = new_pa;
+			}
 
 			return spi;
 		}
@@ -90,7 +94,13 @@ next_spi:
 static void
 gic_v2m_msi_free_spi(struct gic_v2m_frame *frame, int spi)
 {
+	struct pci_attach_args *pa;
+
+	pa = frame->frame_pa[spi];
 	frame->frame_pa[spi] = NULL;
+
+	if (pa != NULL)
+		kmem_free(pa, sizeof(*pa));
 }
 
 static int

Index: src/sys/arch/arm/cortex/gic_v2m.h
diff -u src/sys/arch/arm/cortex/gic_v2m.h:1.2 src/sys/arch/arm/cortex/gic_v2m.h:1.3
--- src/sys/arch/arm/cortex/gic_v2m.h:1.2	Mon Oct 14 11:00:13 2019
+++ src/sys/arch/arm/cortex/gic_v2m.h	Thu May  7 16:20:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_v2m.h,v 1.2 2019/10/14 11:00:13 jmcneill Exp $ */
+/* $NetBSD: gic_v2m.h,v 1.3 2020/05/07 16:20:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@ struct gic_v2m_frame {
 	uint32_t		frame_flags;
 #define	GIC_V2M_FLAG_GRAVITON		0x01	/* Amazon Graviton quirk */
 
-	const struct pci_attach_args *frame_pa[GICC_IAR_IRQ];
+	struct pci_attach_args *frame_pa[GICC_IAR_IRQ];
 
 	struct arm_pci_msi	frame_msi;
 };



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

2020-05-07 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu May  7 15:44:35 UTC 2020

Modified Files:
src/sys/arch/xen/xen: hypervisor.c

Log Message:
Cast physical address to uintptr_t, fix PAE build.
Pointed out by John D. Baker


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/xen/xen/hypervisor.c

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

Modified files:

Index: src/sys/arch/xen/xen/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.81 src/sys/arch/xen/xen/hypervisor.c:1.82
--- src/sys/arch/xen/xen/hypervisor.c:1.81	Tue May  5 17:02:01 2020
+++ src/sys/arch/xen/xen/hypervisor.c	Thu May  7 15:44:35 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.81 2020/05/05 17:02:01 bouyer Exp $ */
+/* $NetBSD: hypervisor.c,v 1.82 2020/05/07 15:44:35 bouyer Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.81 2020/05/05 17:02:01 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.82 2020/05/07 15:44:35 bouyer Exp $");
 
 #include 
 #include 
@@ -244,7 +244,7 @@ init_xen_early(void)
 	xen_init_hypercall_page();
 	hvm_start_info = (void *)((uintptr_t)hvm_start_paddr + KERNBASE);
 
-	HYPERVISOR_shared_info = (void *)(HYPERVISOR_shared_info_pa + KERNBASE);
+	HYPERVISOR_shared_info = (void *)((uintptr_t)HYPERVISOR_shared_info_pa + KERNBASE);
 	struct xen_add_to_physmap xmap = {
 		.domid = DOMID_SELF,
 		.space = XENMAPSPACE_shared_info,



CVS commit: src/usr.bin/finger

2020-05-07 Thread Kimmo Suominen
Module Name:src
Committed By:   kim
Date:   Thu May  7 13:40:20 UTC 2020

Modified Files:
src/usr.bin/finger: finger.1 util.c

Log Message:
Add lastlogx support


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/finger/finger.1
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/finger/util.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/finger/finger.1
diff -u src/usr.bin/finger/finger.1:1.21 src/usr.bin/finger/finger.1:1.22
--- src/usr.bin/finger/finger.1:1.21	Thu Jan 30 23:59:59 2020
+++ src/usr.bin/finger/finger.1	Thu May  7 13:40:20 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: finger.1,v 1.21 2020/01/30 23:59:59 sevan Exp $
+.\"	$NetBSD: finger.1,v 1.22 2020/05/07 13:40:20 kim Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993, 1994
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)finger.1	8.3 (Berkeley) 5/5/94
 .\"
-.Dd January 30, 2020
+.Dd May 7, 2020
 .Dt FINGER 1
 .Os
 .Sh NAME
@@ -199,9 +199,23 @@ The
 .Fl l
 option is the only option that may be passed to a remote machine.
 .Sh FILES
-.Bl -tag -width /var/log/lastlog -compact
+.Bl -tag -width /var/log/lastlogx -compact
+.It Pa /var/run/utmpx
+The
+.Nm utmpx
+file.
+.It Pa /var/log/lastlogx
+The
+.Nm lastlogx
+file.
+.It Pa /var/run/utmp
+The
+.Nm utmp
+file.
 .It Pa /var/log/lastlog
-last login data base
+The
+.Nm lastlog
+file.
 .El
 .Sh SEE ALSO
 .Xr chpass 1 ,

Index: src/usr.bin/finger/util.c
diff -u src/usr.bin/finger/util.c:1.29 src/usr.bin/finger/util.c:1.30
--- src/usr.bin/finger/util.c:1.29	Wed Mar  9 16:12:14 2016
+++ src/usr.bin/finger/util.c	Thu May  7 13:40:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.29 2016/03/09 16:12:14 chs Exp $	*/
+/*	$NetBSD: util.c,v 1.30 2020/05/07 13:40:20 kim Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -72,7 +72,7 @@
 #if 0
 static char sccsid[] = "@(#)util.c	8.3 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: util.c,v 1.29 2016/03/09 16:12:14 chs Exp $");
+__RCSID("$NetBSD: util.c,v 1.30 2020/05/07 13:40:20 kim Exp $");
 #endif
 #endif /* not lint */
 
@@ -90,7 +90,6 @@ __RCSID("$NetBSD: util.c,v 1.29 2016/03/
 #include 
 #include 
 #include 
-#include 
 
 #include "utmpentry.h"
 
@@ -160,15 +159,40 @@ void
 enter_lastlog(PERSON *pn)
 {
 	WHERE *w;
-	static int opened, fd;
+	static int opened;
+#ifdef SUPPORT_UTMPX
+# define ll_time	ll_tv.tv_sec
+# define UT_LINESIZE	_UTX_LINESIZE
+# define UT_HOSTSIZE	_UTX_HOSTSIZE
+	static DB *lldb = NULL;
+	DBT key, data;
+	struct lastlogx ll;
+#else
+	static int fd;
 	struct lastlog ll;
+#endif
 	char doit = 0;
 
+	(void)memset(, 0, sizeof(ll));
+
 	/* some systems may not maintain lastlog, don't report errors. */
 	if (!opened) {
+#ifdef SUPPORT_UTMPX
+		lldb = dbopen(_PATH_LASTLOGX, O_RDONLY|O_SHLOCK, 0, DB_HASH, NULL);
+#else
 		fd = open(_PATH_LASTLOG, O_RDONLY, 0);
+#endif
 		opened = 1;
 	}
+#ifdef SUPPORT_UTMPX
+	if (lldb != NULL) {
+		key.data = >uid;
+		key.size = sizeof(pn->uid);
+		if ((*lldb->get)(lldb, , , 0) == 0 &&
+		data.size == sizeof(ll))
+			(void)memcpy(, data.data, sizeof(ll));
+	}
+#else
 	if (fd == -1 ||
 	lseek(fd, (off_t)pn->uid * sizeof(ll), SEEK_SET) !=
 	(off_t)pn->uid * (off_t)sizeof(ll) ||
@@ -177,6 +201,7 @@ enter_lastlog(PERSON *pn)
 			ll.ll_line[0] = ll.ll_host[0] = '\0';
 			ll.ll_time = 0;
 		}
+#endif
 	if ((w = pn->whead) == NULL)
 		doit = 1;
 	else if (ll.ll_time != 0) {



CVS commit: src/sbin/rndctl

2020-05-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu May  7 12:58:09 UTC 2020

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

Log Message:
Add -i to SYNOPSIS.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sbin/rndctl/rndctl.8

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

Modified files:

Index: src/sbin/rndctl/rndctl.8
diff -u src/sbin/rndctl/rndctl.8:1.24 src/sbin/rndctl/rndctl.8:1.25
--- src/sbin/rndctl/rndctl.8:1.24	Wed May  6 18:49:26 2020
+++ src/sbin/rndctl/rndctl.8	Thu May  7 12:58:09 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rndctl.8,v 1.24 2020/05/06 18:49:26 riastradh Exp $
+.\"	$NetBSD: rndctl.8,v 1.25 2020/05/07 12:58:09 wiz Exp $
 .\"
 .\" Copyright (c) 1997 Michael Graff
 .\" All rights reserved.
@@ -40,6 +40,7 @@
 .Op Fl lsv
 .Op Fl d Ar devname | Fl t Ar devtype
 .Nm
+.Op Fl i
 .Fl L Ar save-file
 .Nm
 .Fl S Ar save-file



CVS commit: src/share/man/man4

2020-05-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu May  7 12:56:19 UTC 2020

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

Log Message:
Fix macro usage.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/share/man/man4/hdaudio.4

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

Modified files:

Index: src/share/man/man4/hdaudio.4
diff -u src/share/man/man4/hdaudio.4:1.16 src/share/man/man4/hdaudio.4:1.17
--- src/share/man/man4/hdaudio.4:1.16	Wed May  6 20:15:15 2020
+++ src/share/man/man4/hdaudio.4	Thu May  7 12:56:19 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: hdaudio.4,v 1.16 2020/05/06 20:15:15 rkujawa Exp $
+.\"	$NetBSD: hdaudio.4,v 1.17 2020/05/07 12:56:19 wiz Exp $
 .\"
 .\" Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -94,7 +94,7 @@ by default.
 .Sh HARDWARE
 In addition to many on-board sound cards included in mainboards, the following
 add-on card is supported:
-.Bl -tag
+.Bl -tag -width 20n
 .It TerraTec Aureon 7.1 PCIe
 .El
 .Sh SEE ALSO



CVS commit: src/lib/libc/gen

2020-05-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu May  7 12:55:06 UTC 2020

Modified Files:
src/lib/libc/gen: getentropy.3

Log Message:
Fix macro usage. Fix typo. New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/gen/getentropy.3

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

Modified files:

Index: src/lib/libc/gen/getentropy.3
diff -u src/lib/libc/gen/getentropy.3:1.1 src/lib/libc/gen/getentropy.3:1.2
--- src/lib/libc/gen/getentropy.3:1.1	Wed May  6 16:17:36 2020
+++ src/lib/libc/gen/getentropy.3	Thu May  7 12:55:06 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getentropy.3,v 1.1 2020/05/06 16:17:36 nia Exp $ $
+.\"	$NetBSD: getentropy.3,v 1.2 2020/05/07 12:55:06 wiz Exp $ $
 .\"
 .\" Copyright (c) 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -40,16 +40,15 @@
 .Ft int
 .Fn getentropy "void *buf" "size_t buflen"
 .Sh DESCRIPTION
-.Pp
 The
 .Fn getentropy
 function fills a buffer with high quality random data, suitable for seeding
-cryptographically secure psuedorandom number generators.
+cryptographically secure pseudo-random number generators.
 .Pp
 .Fn getentropy
 is only intended for seeding random number generators and is not intended
-for use by regular code which simply needs secure random data.  For this
-purpose, please use
+for use by regular code which simply needs secure random data.
+For this purpose, please use
 .Xr arc4random 3 .
 .Pp
 The maximum value for
@@ -64,7 +63,7 @@ variable
 .Sh RETURN VALUES
 The
 .Fn getentropy
-function returns 0 on success, and -1 if an error occurred.
+function returns 0 on success, and \-1 if an error occurred.
 .Sh ERRORS
 .Fn getentropy
 will succeed unless:
@@ -75,6 +74,7 @@ The
 argument points to an invalid memory address.
 .It Bq Er EIO
 Too many bytes were requested.
+.El
 .Sh SEE ALSO
 .Xr arc4random 3 ,
 .Xr rnd 4



CVS commit: src/usr.sbin/lastlogin

2020-05-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu May  7 12:52:40 UTC 2020

Modified Files:
src/usr.sbin/lastlogin: lastlogin.c

Log Message:
Sync usage with man page.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/lastlogin/lastlogin.c

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

Modified files:

Index: src/usr.sbin/lastlogin/lastlogin.c
diff -u src/usr.sbin/lastlogin/lastlogin.c:1.19 src/usr.sbin/lastlogin/lastlogin.c:1.20
--- src/usr.sbin/lastlogin/lastlogin.c:1.19	Wed May  6 19:45:39 2020
+++ src/usr.sbin/lastlogin/lastlogin.c	Thu May  7 12:52:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lastlogin.c,v 1.19 2020/05/06 19:45:39 kim Exp $	*/
+/*	$NetBSD: lastlogin.c,v 1.20 2020/05/07 12:52:40 wiz Exp $	*/
 /*
  * Copyright (c) 1996 John M. Vinopal
  * All rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lastlogin.c,v 1.19 2020/05/06 19:45:39 kim Exp $");
+__RCSID("$NetBSD: lastlogin.c,v 1.20 2020/05/07 12:52:40 wiz Exp $");
 #endif
 
 #include 
@@ -531,8 +531,8 @@ output_record(struct output *o)
 static void
 usage(void)
 {
-	(void)fprintf(stderr, "Usage: %s [-nrt] [-f ] "
-	"[-H ] [-L ] [-N ] [user ...]\n",
+	(void)fprintf(stderr, "Usage: %s [-Fnrt] [-f filename] "
+	"[-H hostsize] [-L linesize] [-N namesize] [user ...]\n",
 	getprogname());
 	exit(1);
 }



CVS commit: src/usr.sbin/lastlogin

2020-05-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu May  7 12:52:26 UTC 2020

Modified Files:
src/usr.sbin/lastlogin: lastlogin.8

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/lastlogin/lastlogin.8

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

Modified files:

Index: src/usr.sbin/lastlogin/lastlogin.8
diff -u src/usr.sbin/lastlogin/lastlogin.8:1.13 src/usr.sbin/lastlogin/lastlogin.8:1.14
--- src/usr.sbin/lastlogin/lastlogin.8:1.13	Wed May  6 11:58:33 2020
+++ src/usr.sbin/lastlogin/lastlogin.8	Thu May  7 12:52:26 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: lastlogin.8,v 1.13 2020/05/06 11:58:33 kim Exp $
+.\"	$NetBSD: lastlogin.8,v 1.14 2020/05/07 12:52:26 wiz Exp $
 .\"
 .\" Copyright (c) 1996 John M. Vinopal
 .\" All rights reserved.
@@ -48,15 +48,16 @@
 .Nm
 will list the last login session of specified
 .Ar users ,
-or for all users by default.  Each line of output contains
-the user name, the tty from which the session was conducted, any
-hostname, and the start time for the session.
+or for all users by default.
+Each line of output contains the user name, the tty from which the
+session was conducted, any hostname, and the start time for the
+session.
 .Pp
 If multiple
 .Ar users
 are given, the session information for each user is printed in
-the order given on the command line.  Otherwise, information
-for all users is printed, sorted by uid.
+the order given on the command line.
+Otherwise, information for all users is printed, sorted by uid.
 .Pp
 .Nm
 differs from



CVS commit: [netbsd-7] src/doc

2020-05-07 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Thu May  7 12:09:26 UTC 2020

Modified Files:
src/doc [netbsd-7]: CHANGES-7.3

Log Message:
Whitespace fix


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.83 -r1.1.2.84 src/doc/CHANGES-7.3

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

Modified files:

Index: src/doc/CHANGES-7.3
diff -u src/doc/CHANGES-7.3:1.1.2.83 src/doc/CHANGES-7.3:1.1.2.84
--- src/doc/CHANGES-7.3:1.1.2.83	Thu May  7 12:01:40 2020
+++ src/doc/CHANGES-7.3	Thu May  7 12:09:26 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.3,v 1.1.2.83 2020/05/07 12:01:40 sborrill Exp $
+# $NetBSD: CHANGES-7.3,v 1.1.2.84 2020/05/07 12:09:26 sborrill Exp $
 
 A complete list of changes from the NetBSD 7.2 release to the NetBSD 7.3
 release:
@@ -850,7 +850,7 @@ external/bsd/bind/dist/lib/isc/sha2.c		(
 	converting the code to avoid alignment issues.
 	[he, ticket #1730]
 
-bin/rcp/rcp.c			1.50
+bin/rcp/rcp.c	1.50
 
 	In sink(), upon error, avoid multiple replies to the source
 	as this would lead to a desynchronization of the protocol and



CVS commit: [netbsd-7-1] src/doc

2020-05-07 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Thu May  7 12:07:13 UTC 2020

Modified Files:
src/doc [netbsd-7-1]: CHANGES-7.1.3

Log Message:
Ticket #1731


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.70 -r1.1.2.71 src/doc/CHANGES-7.1.3

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

Modified files:

Index: src/doc/CHANGES-7.1.3
diff -u src/doc/CHANGES-7.1.3:1.1.2.70 src/doc/CHANGES-7.1.3:1.1.2.71
--- src/doc/CHANGES-7.1.3:1.1.2.70	Thu Apr 30 16:24:26 2020
+++ src/doc/CHANGES-7.1.3	Thu May  7 12:07:13 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.3,v 1.1.2.70 2020/04/30 16:24:26 martin Exp $
+# $NetBSD: CHANGES-7.1.3,v 1.1.2.71 2020/05/07 12:07:13 sborrill Exp $
 
 A complete list of changes from the NetBSD 7.1.2 release to the NetBSD 7.1.3
 release:
@@ -682,4 +682,10 @@ games/fortune/unstr/unstr.c			1.15
 	Fix potential buffer overflows in fortune tools.
 	[nia, ticket #1729]
 
- 
+bin/rcp/rcp.c	1.50
+
+	In sink(), upon error, avoid multiple replies to the source
+	as this would lead to a desynchronization of the protocol and
+	further files or directories to be ignored or corrupted.
+	[aymeric, ticket #1731]
+



CVS commit: [netbsd-7-1] src/bin/rcp

2020-05-07 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Thu May  7 12:05:51 UTC 2020

Modified Files:
src/bin/rcp [netbsd-7-1]: rcp.c

Log Message:
Pull up the following revisions(s) (requested by aymeric in ticket #1731):
bin/rcp/rcp.c:  revision 1.50

In sink(), upon error, avoid multiple replies to the source as this
would lead to a desynchronization of the protocol and further files or
directories to be ignored or corrupted.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.49.22.1 src/bin/rcp/rcp.c

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

Modified files:

Index: src/bin/rcp/rcp.c
diff -u src/bin/rcp/rcp.c:1.49 src/bin/rcp/rcp.c:1.49.22.1
--- src/bin/rcp/rcp.c:1.49	Mon May  7 15:22:54 2012
+++ src/bin/rcp/rcp.c	Thu May  7 12:05:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $	*/
+/*	$NetBSD: rcp.c,v 1.49.22.1 2020/05/07 12:05:51 sborrill Exp $	*/
 
 /*
  * Copyright (c) 1983, 1990, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)rcp.c	8.2 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $");
+__RCSID("$NetBSD: rcp.c,v 1.49.22.1 2020/05/07 12:05:51 sborrill Exp $");
 #endif
 #endif /* not lint */
 
@@ -470,7 +470,6 @@ sink(int argc, char *argv[])
 	static BUF buffer;
 	struct stat stb;
 	struct timeval tv[2];
-	enum { YES, NO, DISPLAYED } wrerr;
 	BUF *bp;
 	ssize_t j;
 	off_t i;
@@ -480,8 +479,9 @@ sink(int argc, char *argv[])
 	mode_t mask;
 	mode_t mode;
 	mode_t omode;
-	int setimes, targisdir;
+	int setimes, targisdir, wrerr;
 	int wrerrno = 0;	/* pacify gcc */
+	const char *wrcontext = NULL;
 	char ch, *cp, *np, *targ, *vect[1], buf[BUFSIZ];
 	const char *why;
 	off_t size;
@@ -624,9 +624,7 @@ sink(int argc, char *argv[])
 			sink(1, vect);
 			if (setimes) {
 setimes = 0;
-if (utimes(np, tv) < 0)
-run_err("%s: set times: %s",
-	np, strerror(errno));
+(void) utimes(np, tv);
 			}
 			if (mod_flag)
 (void)chmod(np, mode);
@@ -644,7 +642,20 @@ bad:			run_err("%s: %s", np, strerror(er
 			continue;
 		}
 		cp = bp->buf;
-		wrerr = NO;
+		wrerr = 0;
+
+/*
+ * Like run_err(), but don't send any message to the remote end.
+ * Instead, record the first error and send that in the end.
+ */
+#define RUN_ERR(w_context) do { \
+	if (!wrerr) {			\
+		wrerrno = errno;	\
+		wrcontext = w_context;	\
+		wrerr = 1;		\
+	}\
+} while(0)
+
 		count = 0;
 		for (i = 0; i < size; i += BUFSIZ) {
 			amt = BUFSIZ;
@@ -663,69 +674,56 @@ bad:			run_err("%s: %s", np, strerror(er
 			} while (amt > 0);
 			if (count == bp->cnt) {
 /* Keep reading so we stay sync'd up. */
-if (wrerr == NO) {
+if (!wrerr) {
 	j = write(ofd, bp->buf, (size_t)count);
 	if (j != count) {
-		wrerr = YES;
-		wrerrno = j >= 0 ? EIO : errno; 
+		if (j >= 0)
+			errno = EIO;
+		RUN_ERR("write");
 	}
 }
 count = 0;
 cp = bp->buf;
 			}
 		}
-		if (count != 0 && wrerr == NO &&
+		if (count != 0 && !wrerr &&
 		(j = write(ofd, bp->buf, (size_t)count)) != count) {
-			wrerr = YES;
-			wrerrno = j >= 0 ? EIO : errno; 
-		}
-		if (ftruncate(ofd, size)) {
-			run_err("%s: truncate: %s", np, strerror(errno));
-			wrerr = DISPLAYED;
+			if (j >= 0)
+errno = EIO;
+			RUN_ERR("write");
 		}
+		if (ftruncate(ofd, size))
+			RUN_ERR("truncate");
+
 		if (pflag) {
 			if (exists || omode != mode)
 if (fchmod(ofd, omode))
-	run_err("%s: set mode: %s",
-	np, strerror(errno));
+	RUN_ERR("set mode");
 		} else {
 			if (!exists && omode != mode)
 if (fchmod(ofd, omode & ~mask))
-	run_err("%s: set mode: %s",
-	np, strerror(errno));
+	RUN_ERR("set mode");
 		}
 #ifndef __SVR4
-		if (setimes && wrerr == NO) {
+		if (setimes && !wrerr) {
 			setimes = 0;
-			if (futimes(ofd, tv) < 0) {
-run_err("%s: set times: %s",
-np, strerror(errno));
-wrerr = DISPLAYED;
-			}
+			if (futimes(ofd, tv) < 0)
+RUN_ERR("set times");
 		}
 #endif
 		(void)close(ofd);
 #ifdef __SVR4
-		if (setimes && wrerr == NO) {
+		if (setimes && !wrerr) {
 			setimes = 0;
-			if (utimes(np, tv) < 0) {
-run_err("%s: set times: %s",
-np, strerror(errno));
-wrerr = DISPLAYED;
-			}
+			if (utimes(np, tv) < 0)
+RUN_ERR("set times");
 		}
 #endif
 		(void)response();
-		switch(wrerr) {
-		case YES:
-			run_err("%s: write: %s", np, strerror(wrerrno));
-			break;
-		case NO:
+		if (wrerr)
+			run_err("%s: %s: %s", np, wrcontext, strerror(wrerrno));
+		else
 			(void)write(rem, "", 1);
-			break;
-		case DISPLAYED:
-			break;
-		}
 	}
 
 out:



CVS commit: [netbsd-7-0] src/doc

2020-05-07 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Thu May  7 12:03:47 UTC 2020

Modified Files:
src/doc [netbsd-7-0]: CHANGES-7.0.3

Log Message:
Ticket #1731


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.162 -r1.1.2.163 src/doc/CHANGES-7.0.3

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

Modified files:

Index: src/doc/CHANGES-7.0.3
diff -u src/doc/CHANGES-7.0.3:1.1.2.162 src/doc/CHANGES-7.0.3:1.1.2.163
--- src/doc/CHANGES-7.0.3:1.1.2.162	Thu Apr 30 16:25:15 2020
+++ src/doc/CHANGES-7.0.3	Thu May  7 12:03:47 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.162 2020/04/30 16:25:15 martin Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.163 2020/05/07 12:03:47 sborrill Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -5957,3 +5957,10 @@ games/fortune/unstr/unstr.c			1.15
 	Fix potential buffer overflows in fortune tools.
 	[nia, ticket #1729]
 
+bin/rcp/rcp.c	1.50
+
+	In sink(), upon error, avoid multiple replies to the source
+	as this would lead to a desynchronization of the protocol and
+	further files or directories to be ignored or corrupted.
+	[aymeric, ticket #1731]
+



CVS commit: [netbsd-7-0] src/bin/rcp

2020-05-07 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Thu May  7 12:02:24 UTC 2020

Modified Files:
src/bin/rcp [netbsd-7-0]: rcp.c

Log Message:
Pull up the following revisions(s) (requested by aymeric in ticket #1731):
bin/rcp/rcp.c:  revision 1.50

In sink(), upon error, avoid multiple replies to the source as this
would lead to a desynchronization of the protocol and further files or
directories to be ignored or corrupted.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.49.14.1 src/bin/rcp/rcp.c

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

Modified files:

Index: src/bin/rcp/rcp.c
diff -u src/bin/rcp/rcp.c:1.49 src/bin/rcp/rcp.c:1.49.14.1
--- src/bin/rcp/rcp.c:1.49	Mon May  7 15:22:54 2012
+++ src/bin/rcp/rcp.c	Thu May  7 12:02:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $	*/
+/*	$NetBSD: rcp.c,v 1.49.14.1 2020/05/07 12:02:24 sborrill Exp $	*/
 
 /*
  * Copyright (c) 1983, 1990, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)rcp.c	8.2 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $");
+__RCSID("$NetBSD: rcp.c,v 1.49.14.1 2020/05/07 12:02:24 sborrill Exp $");
 #endif
 #endif /* not lint */
 
@@ -470,7 +470,6 @@ sink(int argc, char *argv[])
 	static BUF buffer;
 	struct stat stb;
 	struct timeval tv[2];
-	enum { YES, NO, DISPLAYED } wrerr;
 	BUF *bp;
 	ssize_t j;
 	off_t i;
@@ -480,8 +479,9 @@ sink(int argc, char *argv[])
 	mode_t mask;
 	mode_t mode;
 	mode_t omode;
-	int setimes, targisdir;
+	int setimes, targisdir, wrerr;
 	int wrerrno = 0;	/* pacify gcc */
+	const char *wrcontext = NULL;
 	char ch, *cp, *np, *targ, *vect[1], buf[BUFSIZ];
 	const char *why;
 	off_t size;
@@ -624,9 +624,7 @@ sink(int argc, char *argv[])
 			sink(1, vect);
 			if (setimes) {
 setimes = 0;
-if (utimes(np, tv) < 0)
-run_err("%s: set times: %s",
-	np, strerror(errno));
+(void) utimes(np, tv);
 			}
 			if (mod_flag)
 (void)chmod(np, mode);
@@ -644,7 +642,20 @@ bad:			run_err("%s: %s", np, strerror(er
 			continue;
 		}
 		cp = bp->buf;
-		wrerr = NO;
+		wrerr = 0;
+
+/*
+ * Like run_err(), but don't send any message to the remote end.
+ * Instead, record the first error and send that in the end.
+ */
+#define RUN_ERR(w_context) do { \
+	if (!wrerr) {			\
+		wrerrno = errno;	\
+		wrcontext = w_context;	\
+		wrerr = 1;		\
+	}\
+} while(0)
+
 		count = 0;
 		for (i = 0; i < size; i += BUFSIZ) {
 			amt = BUFSIZ;
@@ -663,69 +674,56 @@ bad:			run_err("%s: %s", np, strerror(er
 			} while (amt > 0);
 			if (count == bp->cnt) {
 /* Keep reading so we stay sync'd up. */
-if (wrerr == NO) {
+if (!wrerr) {
 	j = write(ofd, bp->buf, (size_t)count);
 	if (j != count) {
-		wrerr = YES;
-		wrerrno = j >= 0 ? EIO : errno; 
+		if (j >= 0)
+			errno = EIO;
+		RUN_ERR("write");
 	}
 }
 count = 0;
 cp = bp->buf;
 			}
 		}
-		if (count != 0 && wrerr == NO &&
+		if (count != 0 && !wrerr &&
 		(j = write(ofd, bp->buf, (size_t)count)) != count) {
-			wrerr = YES;
-			wrerrno = j >= 0 ? EIO : errno; 
-		}
-		if (ftruncate(ofd, size)) {
-			run_err("%s: truncate: %s", np, strerror(errno));
-			wrerr = DISPLAYED;
+			if (j >= 0)
+errno = EIO;
+			RUN_ERR("write");
 		}
+		if (ftruncate(ofd, size))
+			RUN_ERR("truncate");
+
 		if (pflag) {
 			if (exists || omode != mode)
 if (fchmod(ofd, omode))
-	run_err("%s: set mode: %s",
-	np, strerror(errno));
+	RUN_ERR("set mode");
 		} else {
 			if (!exists && omode != mode)
 if (fchmod(ofd, omode & ~mask))
-	run_err("%s: set mode: %s",
-	np, strerror(errno));
+	RUN_ERR("set mode");
 		}
 #ifndef __SVR4
-		if (setimes && wrerr == NO) {
+		if (setimes && !wrerr) {
 			setimes = 0;
-			if (futimes(ofd, tv) < 0) {
-run_err("%s: set times: %s",
-np, strerror(errno));
-wrerr = DISPLAYED;
-			}
+			if (futimes(ofd, tv) < 0)
+RUN_ERR("set times");
 		}
 #endif
 		(void)close(ofd);
 #ifdef __SVR4
-		if (setimes && wrerr == NO) {
+		if (setimes && !wrerr) {
 			setimes = 0;
-			if (utimes(np, tv) < 0) {
-run_err("%s: set times: %s",
-np, strerror(errno));
-wrerr = DISPLAYED;
-			}
+			if (utimes(np, tv) < 0)
+RUN_ERR("set times");
 		}
 #endif
 		(void)response();
-		switch(wrerr) {
-		case YES:
-			run_err("%s: write: %s", np, strerror(wrerrno));
-			break;
-		case NO:
+		if (wrerr)
+			run_err("%s: %s: %s", np, wrcontext, strerror(wrerrno));
+		else
 			(void)write(rem, "", 1);
-			break;
-		case DISPLAYED:
-			break;
-		}
 	}
 
 out:



CVS commit: [netbsd-7] src/doc

2020-05-07 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Thu May  7 12:01:40 UTC 2020

Modified Files:
src/doc [netbsd-7]: CHANGES-7.3

Log Message:
Ticket #1731


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.82 -r1.1.2.83 src/doc/CHANGES-7.3

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

Modified files:

Index: src/doc/CHANGES-7.3
diff -u src/doc/CHANGES-7.3:1.1.2.82 src/doc/CHANGES-7.3:1.1.2.83
--- src/doc/CHANGES-7.3:1.1.2.82	Wed May  6 07:42:14 2020
+++ src/doc/CHANGES-7.3	Thu May  7 12:01:40 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.3,v 1.1.2.82 2020/05/06 07:42:14 sborrill Exp $
+# $NetBSD: CHANGES-7.3,v 1.1.2.83 2020/05/07 12:01:40 sborrill Exp $
 
 A complete list of changes from the NetBSD 7.2 release to the NetBSD 7.3
 release:
@@ -850,3 +850,10 @@ external/bsd/bind/dist/lib/isc/sha2.c		(
 	converting the code to avoid alignment issues.
 	[he, ticket #1730]
 
+bin/rcp/rcp.c			1.50
+
+	In sink(), upon error, avoid multiple replies to the source
+	as this would lead to a desynchronization of the protocol and
+	further files or directories to be ignored or corrupted.
+	[aymeric, ticket #1731]
+



CVS commit: [netbsd-7] src/bin/rcp

2020-05-07 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Thu May  7 12:01:00 UTC 2020

Modified Files:
src/bin/rcp [netbsd-7]: rcp.c

Log Message:
Pull up the following revisions(s) (requested by aymeric in ticket #1731):
bin/rcp/rcp.c:  revision 1.50

In sink(), upon error, avoid multiple replies to the source as this
would lead to a desynchronization of the protocol and further files or
directories to be ignored or corrupted.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.49.12.1 src/bin/rcp/rcp.c

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

Modified files:

Index: src/bin/rcp/rcp.c
diff -u src/bin/rcp/rcp.c:1.49 src/bin/rcp/rcp.c:1.49.12.1
--- src/bin/rcp/rcp.c:1.49	Mon May  7 15:22:54 2012
+++ src/bin/rcp/rcp.c	Thu May  7 12:01:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $	*/
+/*	$NetBSD: rcp.c,v 1.49.12.1 2020/05/07 12:01:00 sborrill Exp $	*/
 
 /*
  * Copyright (c) 1983, 1990, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)rcp.c	8.2 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $");
+__RCSID("$NetBSD: rcp.c,v 1.49.12.1 2020/05/07 12:01:00 sborrill Exp $");
 #endif
 #endif /* not lint */
 
@@ -470,7 +470,6 @@ sink(int argc, char *argv[])
 	static BUF buffer;
 	struct stat stb;
 	struct timeval tv[2];
-	enum { YES, NO, DISPLAYED } wrerr;
 	BUF *bp;
 	ssize_t j;
 	off_t i;
@@ -480,8 +479,9 @@ sink(int argc, char *argv[])
 	mode_t mask;
 	mode_t mode;
 	mode_t omode;
-	int setimes, targisdir;
+	int setimes, targisdir, wrerr;
 	int wrerrno = 0;	/* pacify gcc */
+	const char *wrcontext = NULL;
 	char ch, *cp, *np, *targ, *vect[1], buf[BUFSIZ];
 	const char *why;
 	off_t size;
@@ -624,9 +624,7 @@ sink(int argc, char *argv[])
 			sink(1, vect);
 			if (setimes) {
 setimes = 0;
-if (utimes(np, tv) < 0)
-run_err("%s: set times: %s",
-	np, strerror(errno));
+(void) utimes(np, tv);
 			}
 			if (mod_flag)
 (void)chmod(np, mode);
@@ -644,7 +642,20 @@ bad:			run_err("%s: %s", np, strerror(er
 			continue;
 		}
 		cp = bp->buf;
-		wrerr = NO;
+		wrerr = 0;
+
+/*
+ * Like run_err(), but don't send any message to the remote end.
+ * Instead, record the first error and send that in the end.
+ */
+#define RUN_ERR(w_context) do { \
+	if (!wrerr) {			\
+		wrerrno = errno;	\
+		wrcontext = w_context;	\
+		wrerr = 1;		\
+	}\
+} while(0)
+
 		count = 0;
 		for (i = 0; i < size; i += BUFSIZ) {
 			amt = BUFSIZ;
@@ -663,69 +674,56 @@ bad:			run_err("%s: %s", np, strerror(er
 			} while (amt > 0);
 			if (count == bp->cnt) {
 /* Keep reading so we stay sync'd up. */
-if (wrerr == NO) {
+if (!wrerr) {
 	j = write(ofd, bp->buf, (size_t)count);
 	if (j != count) {
-		wrerr = YES;
-		wrerrno = j >= 0 ? EIO : errno; 
+		if (j >= 0)
+			errno = EIO;
+		RUN_ERR("write");
 	}
 }
 count = 0;
 cp = bp->buf;
 			}
 		}
-		if (count != 0 && wrerr == NO &&
+		if (count != 0 && !wrerr &&
 		(j = write(ofd, bp->buf, (size_t)count)) != count) {
-			wrerr = YES;
-			wrerrno = j >= 0 ? EIO : errno; 
-		}
-		if (ftruncate(ofd, size)) {
-			run_err("%s: truncate: %s", np, strerror(errno));
-			wrerr = DISPLAYED;
+			if (j >= 0)
+errno = EIO;
+			RUN_ERR("write");
 		}
+		if (ftruncate(ofd, size))
+			RUN_ERR("truncate");
+
 		if (pflag) {
 			if (exists || omode != mode)
 if (fchmod(ofd, omode))
-	run_err("%s: set mode: %s",
-	np, strerror(errno));
+	RUN_ERR("set mode");
 		} else {
 			if (!exists && omode != mode)
 if (fchmod(ofd, omode & ~mask))
-	run_err("%s: set mode: %s",
-	np, strerror(errno));
+	RUN_ERR("set mode");
 		}
 #ifndef __SVR4
-		if (setimes && wrerr == NO) {
+		if (setimes && !wrerr) {
 			setimes = 0;
-			if (futimes(ofd, tv) < 0) {
-run_err("%s: set times: %s",
-np, strerror(errno));
-wrerr = DISPLAYED;
-			}
+			if (futimes(ofd, tv) < 0)
+RUN_ERR("set times");
 		}
 #endif
 		(void)close(ofd);
 #ifdef __SVR4
-		if (setimes && wrerr == NO) {
+		if (setimes && !wrerr) {
 			setimes = 0;
-			if (utimes(np, tv) < 0) {
-run_err("%s: set times: %s",
-np, strerror(errno));
-wrerr = DISPLAYED;
-			}
+			if (utimes(np, tv) < 0)
+RUN_ERR("set times");
 		}
 #endif
 		(void)response();
-		switch(wrerr) {
-		case YES:
-			run_err("%s: write: %s", np, strerror(wrerrno));
-			break;
-		case NO:
+		if (wrerr)
+			run_err("%s: %s: %s", np, wrcontext, strerror(wrerrno));
+		else
 			(void)write(rem, "", 1);
-			break;
-		case DISPLAYED:
-			break;
-		}
 	}
 
 out:



CVS commit: src/sys/dev/sdmmc

2020-05-07 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu May  7 11:46:27 UTC 2020

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

Log Message:
add entry for BCM43362, found on Cubietruck
ok jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sdmmc/if_bwfm_sdio.c

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

Modified files:

Index: src/sys/dev/sdmmc/if_bwfm_sdio.c
diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.14 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.15
--- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.14	Wed Mar 25 03:44:45 2020
+++ src/sys/dev/sdmmc/if_bwfm_sdio.c	Thu May  7 11:46:27 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bwfm_sdio.c,v 1.14 2020/03/25 03:44:45 thorpej Exp $ */
+/* $NetBSD: if_bwfm_sdio.c,v 1.15 2020/05/07 11:46:27 macallan Exp $ */
 /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -297,6 +297,11 @@ static const struct bwfm_sdio_product {
 		SDMMC_PRODUCT_BROADCOM_BCM43455, 
 		SDMMC_CIS_BROADCOM_BCM43455
 	},
+	{
+		SDMMC_VENDOR_BROADCOM,
+		SDMMC_PRODUCT_BROADCOM_BCM43362, 
+		SDMMC_CIS_BROADCOM_BCM43362
+	},
 };
 
 static const char *compatible[] = {



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

2020-05-07 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May  7 11:43:28 UTC 2020

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

Log Message:
Add PRID definition for newer SiByte SB1 cores (rev 0x11).
Add a constant for SiByte/BCRM cacheable coherent TLB cache attribute.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/mips/include/cpuregs.h

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

Modified files:

Index: src/sys/arch/mips/include/cpuregs.h
diff -u src/sys/arch/mips/include/cpuregs.h:1.96 src/sys/arch/mips/include/cpuregs.h:1.97
--- src/sys/arch/mips/include/cpuregs.h:1.96	Sun May  7 04:12:35 2017
+++ src/sys/arch/mips/include/cpuregs.h	Thu May  7 11:43:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuregs.h,v 1.96 2017/05/07 04:12:35 skrll Exp $	*/
+/*	$NetBSD: cpuregs.h,v 1.97 2020/05/07 11:43:28 simonb Exp $	*/
 
 /*
  * Copyright (c) 2009 Miodrag Vallat.
@@ -148,6 +148,7 @@
 
 #define	CCA_UNCACHED		2
 #define	CCA_CACHEABLE		3	/* cacheable non-coherent */
+#define	CCA_SB_CACHEABLE_COHERENT 5	/* cacheable coherent (SiByte ext) */
 #define	CCA_ACCEL		7	/* non-cached, write combining */
 
 /* CPU dependent mtc0 hazard hook */
@@ -964,7 +965,8 @@
 /*
  * CPU processor revision IDs for company ID == 4 (SiByte)
  */
-#define	MIPS_SB1	0x01	/* SiByte SB1	 		ISA 64  */
+#define	MIPS_SB1	0x01	/* SiByte SB1			ISA 64  */
+#define	MIPS_SB1_11	0x11	/* SiByte SB1 (rev 0x11)	ISA 64  */
 
 /*
  * CPU processor revision IDs for company ID == 5 (SandCraft)



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

2020-05-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu May  7 11:24:47 UTC 2020

Modified Files:
src/sys/arch/arm/sunxi: sun4i_a10_ccu.c

Log Message:
Add A20 CLK_OUT_A and CLK_OUT_B clocks


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sun4i_a10_ccu.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/sunxi/sun4i_a10_ccu.c
diff -u src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.11 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.12
--- src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.11	Thu Aug  1 22:23:16 2019
+++ src/sys/arch/arm/sunxi/sun4i_a10_ccu.c	Thu May  7 11:24:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sun4i_a10_ccu.c,v 1.11 2019/08/01 22:23:16 tnn Exp $ */
+/* $NetBSD: sun4i_a10_ccu.c,v 1.12 2020/05/07 11:24:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.11 2019/08/01 22:23:16 tnn Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.12 2020/05/07 11:24:47 jmcneill Exp $");
 
 #include 
 #include 
@@ -82,6 +82,8 @@ __KERNEL_RCSID(1, "$NetBSD: sun4i_a10_cc
 #define	HDMI_CLOCK_CFG_REG	0x150
 #define	MALI_CLOCK_CFG_REG	0x154
 #define	IEP_SCLK_CFG_REG	0x160
+#define	CLK_OUTA_REG		0x1f0
+#define	CLK_OUTB_REG		0x1f4
 
 static int sun4i_a10_ccu_match(device_t, cfdata_t, void *);
 static void sun4i_a10_ccu_attach(device_t, device_t, void *);
@@ -123,6 +125,7 @@ static const char *mod_parents[] = { "os
 static const char *sata_parents[] = { "pll6_periph_sata", "external" };
 static const char *de_parents[] = { "pll_video0", "pll_video1", "pll_ddr_other" };
 static const char *lcd_parents[] = { "pll_video0", "pll_video1", "pll_video0x2", "pll_video1x2" };
+static const char *out_parents[] = { "losc" /* really OSC24MHz/750 */, "losc", "osc24m" };
 
 static const struct sunxi_ccu_nkmp_tbl sun4i_a10_pll1_table[] = {
 	{ 100800, 21, 1, 0, 0 },
@@ -484,6 +487,23 @@ static struct sunxi_ccu_clk sun4i_a10_cc
 	0/* flags */
 	),
 
+	/* A20 specific */
+	SUNXI_CCU_NM(A20_CLK_OUT_A, "outa", out_parents,
+	CLK_OUTA_REG,		/* reg */
+	__BITS(21,20),		/* n */
+	__BITS(12,8),		/* m */
+	__BITS(25,24),		/* sel */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO),
+
+	SUNXI_CCU_NM(A20_CLK_OUT_B, "outb", out_parents,
+	CLK_OUTB_REG,		/* reg */
+	__BITS(21,20),		/* n */
+	__BITS(12,8),		/* m */
+	__BITS(25,24),		/* sel */
+	__BIT(31),			/* enable */
+	SUNXI_CCU_NM_POWER_OF_TWO),
+
 	/* AHB_GATING_REG0 */
 	SUNXI_CCU_GATE(A10_CLK_AHB_OTG, "ahb-otg", "ahb",
 	AHB_GATING_REG0, 0),



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

2020-05-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  7 09:13:06 UTC 2020

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

Log Message:
Operation zfs_zget_cleaner() cannot fail, comment and add assertions.


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

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.32 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.33
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.32	Thu May  7 09:12:31 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c	Thu May  7 09:13:06 2020
@@ -1288,6 +1288,12 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_
 	return error;
 }
 
+/*
+ * Get a known cached znode, to be used from zil_commit()->zfs_get_data()
+ * to resolve log entries.  Doesn't take a reference, will never fail and
+ * depends on zfs_vnops.c::zfs_netbsd_reclaim() running a zil_commit()
+ * before the znode gets freed.
+ */
 int
 zfs_zget_cleaner(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp)
 {
@@ -1295,31 +1301,26 @@ zfs_zget_cleaner(zfsvfs_t *zfsvfs, uint6
 	sa_handle_t *hdl;
 	dmu_object_info_t doi;
 	znode_t *zp;
-	int err;
 
 	ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num);
 
-	err = sa_buf_hold(zfsvfs->z_os, obj_num, NULL, );
-	if (err) {
-		ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
-		return (SET_ERROR(err));
-	}
+	VERIFY(0 == sa_buf_hold(zfsvfs->z_os, obj_num, NULL, ));
 
 	dmu_object_info_from_db(db, );
-	if (doi.doi_bonus_type != DMU_OT_SA &&
-	(doi.doi_bonus_type != DMU_OT_ZNODE ||
+	ASSERT(doi.doi_bonus_type == DMU_OT_SA ||
 	(doi.doi_bonus_type == DMU_OT_ZNODE &&
-	doi.doi_bonus_size < sizeof (znode_phys_t {
-		sa_buf_rele(db, NULL);
-		ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
-		return (SET_ERROR(EINVAL));
-	}
+	doi.doi_bonus_size >= sizeof (znode_phys_t)));
+
 	hdl = dmu_buf_get_user(db);
 	ASSERT3P(hdl, !=, NULL);
+
 	zp = sa_get_userdata(hdl);
 	ASSERT3U(zp->z_id, ==, obj_num);
+
 	sa_buf_rele(db, NULL);
+
 	ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
+
 	*zpp = zp;
 	return (0);
 }



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

2020-05-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  7 09:12:03 UTC 2020

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

Log Message:
Revert Rev. 1.63 and add a comment why we have to zil_commit() here:

Operation zfs_znode.c::zfs_zget_cleaner() depends on this
zil_commit() as a barrier to guarantee the znode cannot
get freed before its log entries are resolved.


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

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.64 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.65
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.64	Sat Mar 14 20:45:23 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Thu May  7 09:12:03 2020
@@ -5858,11 +5858,16 @@ zfs_netbsd_reclaim(void *v)
 			zp->z_atime_dirty = 0;
 			dmu_tx_commit(tx);
 		}
-
-		if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
-			zil_commit(zfsvfs->z_log, zp->z_id);
 	}
 
+	/*
+	 * Operation zfs_znode.c::zfs_zget_cleaner() depends on this
+	 * zil_commit() as a barrier to guarantee the znode cannot
+	 * get freed before its log entries are resolved.
+	 */
+	if (zfsvfs->z_log)
+		zil_commit(zfsvfs->z_log, zp->z_id);
+
 	if (zp->z_sa_hdl == NULL)
 		zfs_znode_free(zp);
 	else



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

2020-05-07 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  7 09:12:32 UTC 2020

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

Log Message:
Revert Rev. 1.31 as it is no longer possible for the handle to be NULL.


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

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.31 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.32
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c:1.31	Fri Mar 20 08:26:01 2020
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c	Thu May  7 09:12:31 2020
@@ -1315,11 +1315,7 @@ zfs_zget_cleaner(zfsvfs_t *zfsvfs, uint6
 		return (SET_ERROR(EINVAL));
 	}
 	hdl = dmu_buf_get_user(db);
-	if (hdl == NULL) {
-		sa_buf_rele(db, NULL);
-		ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
-		return (SET_ERROR(EINVAL));
-	}
+	ASSERT3P(hdl, !=, NULL);
 	zp = sa_get_userdata(hdl);
 	ASSERT3U(zp->z_id, ==, obj_num);
 	sa_buf_rele(db, NULL);