CVS commit: src/tests/dev/audio

2020-04-30 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri May  1 05:45:57 UTC 2020

Modified Files:
src/tests/dev/audio: audiotest.c

Log Message:
Fix two tests.
- kqueue_mode_{RDONLY,RDWR}_READ: Fix expected value.
  This is rest of rev1.9.
- AUDIO_SETINFO_params_simul: Fix condition.
  This happens on full-duplex, not bi-directional.
These affect only standalone test, not atf.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/dev/audio/audiotest.c

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



CVS commit: src/tests/dev/audio

2020-04-30 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri May  1 05:45:57 UTC 2020

Modified Files:
src/tests/dev/audio: audiotest.c

Log Message:
Fix two tests.
- kqueue_mode_{RDONLY,RDWR}_READ: Fix expected value.
  This is rest of rev1.9.
- AUDIO_SETINFO_params_simul: Fix condition.
  This happens on full-duplex, not bi-directional.
These affect only standalone test, not atf.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/dev/audio/audiotest.c

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

Modified files:

Index: src/tests/dev/audio/audiotest.c
diff -u src/tests/dev/audio/audiotest.c:1.10 src/tests/dev/audio/audiotest.c:1.11
--- src/tests/dev/audio/audiotest.c:1.10	Thu Mar 26 13:43:10 2020
+++ src/tests/dev/audio/audiotest.c	Fri May  1 05:45:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiotest.c,v 1.10 2020/03/26 13:43:10 isaki Exp $	*/
+/*	$NetBSD: audiotest.c,v 1.11 2020/05/01 05:45:57 isaki Exp $	*/
 
 /*
  * Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: audiotest.c,v 1.10 2020/03/26 13:43:10 isaki Exp $");
+__RCSID("$NetBSD: audiotest.c,v 1.11 2020/05/01 05:45:57 isaki Exp $");
 
 #include 
 #include 
@@ -3582,9 +3582,8 @@ test_kqueue_mode(int openmode, int filt,
 	XP_SYS_EQ(0, r);
 }
 DEF(kqueue_mode_RDONLY_READ) {
-	/* Should not raise yet (NetBSD7 has bugs?) */
-	int expected = (netbsd < 8) ? 1 : 0;
-	test_kqueue_mode(O_RDONLY, EVFILT_READ, expected);
+	/* Should raise */
+	test_kqueue_mode(O_RDONLY, EVFILT_READ, 1);
 }
 DEF(kqueue_mode_RDONLY_WRITE) {
 	/* Should never raise (NetBSD7 has bugs) */
@@ -3600,8 +3599,8 @@ DEF(kqueue_mode_WRONLY_WRITE) {
 	test_kqueue_mode(O_WRONLY, EVFILT_WRITE, 1);
 }
 DEF(kqueue_mode_RDWR_READ) {
-	/* Should not raise yet (NetBSD7 is something strange) */
-	int expected = (netbsd < 8 && hw_fulldup()) ? 1 : 0;
+	/* Should raise on fulldup but not on halfdup, on NetBSD9 */
+	int expected = hw_fulldup() ? 1 : 0;
 	test_kqueue_mode(O_RDWR, EVFILT_READ, expected);
 }
 DEF(kqueue_mode_RDWR_WRITE) {
@@ -5149,16 +5148,16 @@ DEF(AUDIO_SETINFO_params_simul)
 	XP_SYS_EQ(0, r);
 
 	/*
-	 * On bi-directional device, the 2nd one has both track so that
+	 * On full-duplex device, the 2nd one has both track so that
 	 * both track are not affected by sticky parameter.
-	 * On uni-directional device, the 2nd one has only playback track
-	 * so that playback track is not affected by sticky parameter.
+	 * Otherwise, the 2nd one has only playback track so that
+	 * playback track is not affected by sticky parameter.
 	 */
 	memset(, 0, sizeof(ai));
 	r = IOCTL(fd1, AUDIO_GETBUFINFO, , "");
 	XP_SYS_EQ(0, r);
 	XP_EQ(11025, ai.play.sample_rate);
-	if (hw_bidir()) {
+	if (hw_fulldup()) {
 		XP_EQ(11025, ai.record.sample_rate);
 	} else {
 		XP_EQ(16000, ai.record.sample_rate);



re: CVS commit: src/sys

2020-04-30 Thread matthew green
> At Wed, 29 Apr 2020 21:59:59 +,
> Andrew Doran wrote:
> > > > How about this diff?
> > > > The old platforms are the same as before, hppa, m68k, sh3, sparc(!64)
> > > > and vax.
> > > 
> > > machine/param.h seems more natural to me.  I don't have a strong opinion
> > > though.
> > 
> > .. I mean, if it's a "tuneable" value like this rather than a constant like
> > __HAVE_SLOW_COMPUTER. :-)
> 
> I see.  I like this feeling. (not strong opinion too though)
> How about you, mrg@?

works for me.   i like Andrew's argument fo param.h for values
and types.h for yes/no.

thanks!


.mrg.


Re: CVS commit: src/sys

2020-04-30 Thread Tetsuya Isaki
At Wed, 29 Apr 2020 21:59:59 +,
Andrew Doran wrote:
> > > How about this diff?
> > > The old platforms are the same as before, hppa, m68k, sh3, sparc(!64)
> > > and vax.
> > 
> > machine/param.h seems more natural to me.  I don't have a strong opinion
> > though.
> 
> .. I mean, if it's a "tuneable" value like this rather than a constant like
> __HAVE_SLOW_COMPUTER. :-)

I see.  I like this feeling. (not strong opinion too though)
How about you, mrg@?

Thanks,
---
Tetsuya Isaki 

diff --git a/sys/arch/hppa/include/param.h b/sys/arch/hppa/include/param.h
index 39ce45623..69686c405 100644
--- a/sys/arch/hppa/include/param.h
+++ b/sys/arch/hppa/include/param.h
@@ -88,3 +88,8 @@
 
 #define btop(x)((unsigned long)(x) >> PGSHIFT)
 #define ptob(x)((unsigned long)(x) << PGSHIFT)
+
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#if defined(_KERNEL)
+#define__AUDIO_BLK_MS (40)
+#endif
diff --git a/sys/arch/m68k/include/param.h b/sys/arch/m68k/include/param.h
index f0bbe169e..ae67a324c 100644
--- a/sys/arch/m68k/include/param.h
+++ b/sys/arch/m68k/include/param.h
@@ -95,4 +95,9 @@
 #definem68k_btop(x)((vaddr_t)(x) >> PGSHIFT)
 #definem68k_ptob(x)((vaddr_t)(x) << PGSHIFT)
 
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#if defined(_KERNEL)
+#define__AUDIO_BLK_MS (40)
+#endif
+
 #endif /* !_M68K_PARAM_H_ */
diff --git a/sys/arch/sh3/include/param.h b/sys/arch/sh3/include/param.h
index 547b791f2..66b6d578e 100644
--- a/sys/arch/sh3/include/param.h
+++ b/sys/arch/sh3/include/param.h
@@ -91,4 +91,9 @@
 #defineNKMEMPAGES_MIN_DEFAULT  ((16 * 1024 * 1024) >> PAGE_SHIFT)
 #defineNKMEMPAGES_MAX_DEFAULT  ((128 * 1024 * 1024) >> PAGE_SHIFT)
 
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#if defined(_KERNEL)
+#define__AUDIO_BLK_MS (40)
+#endif
+
 #endif /* !_SH3_PARAM_H_ */
diff --git a/sys/arch/sparc/include/param.h b/sys/arch/sparc/include/param.h
index f6112f886..2225a52a2 100644
--- a/sys/arch/sparc/include/param.h
+++ b/sys/arch/sparc/include/param.h
@@ -155,4 +155,7 @@ extern void delay(unsigned int);
 #  define PGSHIFT  pgshift
 #endif
 
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#define__AUDIO_BLK_MS (40)
+
 #endif /* _KERNEL || _STANDALONE */
diff --git a/sys/arch/vax/include/param.h b/sys/arch/vax/include/param.h
index 57685709c..f350237b7 100644
--- a/sys/arch/vax/include/param.h
+++ b/sys/arch/vax/include/param.h
@@ -118,6 +118,10 @@ void   delay(int);
 
 #defineDELAY(x) delay(x)
 #defineMAXEXEC 1
+
+/* Default audio blocksize in msec.  See sys/dev/audio/audio.c */
+#define__AUDIO_BLK_MS (40)
+
 #endif /* _KERNEL */
 
 #endif /* _VAX_PARAM_H_ */
diff --git a/sys/dev/audio/audio.c b/sys/dev/audio/audio.c
index 13386ccfb..ef1424d48 100644
--- a/sys/dev/audio/audio.c
+++ b/sys/dev/audio/audio.c
@@ -454,38 +454,25 @@ audio_track_bufstat(audio_track_t *track, struct 
audio_track_debugbuf *buf)
 /*
  * Default hardware blocksize in msec.
  *
- * We use 10 msec for most platforms.  This period is good enough to play
- * audio and video synchronizely.
+ * We use 10 msec for most modern platforms.  This period is good enough to
+ * play audio and video synchronizely.
  * In contrast, for very old platforms, this is usually too short and too
  * severe.  Also such platforms usually can not play video confortably, so
- * it's not so important to make the blocksize shorter.
+ * it's not so important to make the blocksize shorter.  If the platform
+ * defines its own value as __AUDIO_BLK_MS in its , it
+ * uses this instead.
+ *
  * In either case, you can overwrite AUDIO_BLK_MS by your kernel
  * configuration file if you wish.
- *
- * 40 msec was initially choosen for the following reason:
- * (1 / 40ms) = 25 = 5^2.  Thus, the frequency is factored by 5.
- * In this case, the number of frames in a block can be an integer
- * even if the frequency is a multiple of 100 (44100, 48000, etc),
- * or even if 15625Hz (vs(4)).
  */
-#if defined(__hppa__)  || \
-defined(__m68k__)  || \
-defined(__sh3__)   || \
-(defined(__sparc__) && !defined(__sparc64__))  || \
-defined(__vax__)
-#define AUDIO_TOO_SLOW_ARCHS 1
-#endif
-
 #if !defined(AUDIO_BLK_MS)
-# if defined(AUDIO_TOO_SLOW_ARCHS)
-#  define AUDIO_BLK_MS 40
+# if defined(__AUDIO_BLK_MS)
+#  define AUDIO_BLK_MS __AUDIO_BLK_MS
 # else
-#  define AUDIO_BLK_MS 10
+#  define AUDIO_BLK_MS (10)
 # endif
 #endif
 
-#undef AUDIO_TOO_SLOW_ARCHS
-
 /* Device timeout in msec */
 #define AUDIO_TIMEOUT  (3000)
 


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

2020-04-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May  1 04:07:24 UTC 2020

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

Log Message:
- Add AMD INVLPGB/TLBSYNC hypervisor enable in VMCB and TLBSYNC intercept bit.
- Modify comment.


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

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



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

2020-04-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May  1 04:07:24 UTC 2020

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

Log Message:
- Add AMD INVLPGB/TLBSYNC hypervisor enable in VMCB and TLBSYNC intercept bit.
- Modify comment.


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

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

Modified files:

Index: src/sys/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.163 src/sys/arch/x86/include/specialreg.h:1.164
--- src/sys/arch/x86/include/specialreg.h:1.163	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/include/specialreg.h	Fri May  1 04:07:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.163 2020/04/25 15:26:18 bouyer Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.164 2020/05/01 04:07:24 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2014-2019 The NetBSD Foundation, Inc.
@@ -730,6 +730,7 @@
  * %eax: Long Mode Size Identifiers
  * %ebx: Extended Feature Identifiers
  * %ecx: Size Identifiers
+ * %edx: RDPRU Register Identifier Range
  */
 
 /* %ebx */
@@ -773,6 +774,7 @@
 #define CPUID_AMD_SVM_vGIF		0x0001 /* Virtualized GIF */
 #define CPUID_AMD_SVM_GMET		0x0002
 #define CPUID_AMD_SVM_SPEC_CTRL		__BIT(20)
+#define CPUID_AMD_SVM_TLBICTL		__BIT(24)  /* TLB Inttercept Control */
 
 #define CPUID_AMD_SVM_FLAGS	 "\20"	\
 	"\1" "NP"	"\2" "LbrVirt"	"\3" "SVML"	"\4" "NRIPS"	\
@@ -782,10 +784,11 @@
 	"\15" "PFThreshold" "\16" "AVIC" "\17" "B14"			\
 		"\20" "V_VMSAVE_VMLOAD"	\
 	"\21" "VGIF"	"\22" "GMET"	\
-	"\25" "SPEC_CTRL"
+	"\25" "SPEC_CTRL"		\
+	"\31" "TLBICTL"
 
 /*
- * AMD Fn8000_0001d Cache Topology Information.
+ * AMD Fn8000_001d Cache Topology Information.
  * It's almost the same as Intel Deterministic Cache Parameter Leaf(0x04)
  * except the following:
  *	No Cores/package (%eax bit 31..26)
@@ -793,7 +796,7 @@
  */
 
 /*
- * AMD Fn8000_0001f Encrypted Memory Capabilities.
+ * AMD Fn8000_001f Encrypted Memory Capabilities.
  * %eax: flags
  * %ebx:  5-0: Cbit Position
  *   11-6: PhysAddrReduction



CVS commit: src/distrib/notes/hp300

2020-04-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri May  1 03:02:28 UTC 2020

Modified Files:
src/distrib/notes/hp300: hardware

Log Message:
Move HP332 to "Supported hardware" list, as reported by Chris Hanson.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/distrib/notes/hp300/hardware

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

Modified files:

Index: src/distrib/notes/hp300/hardware
diff -u src/distrib/notes/hp300/hardware:1.21 src/distrib/notes/hp300/hardware:1.22
--- src/distrib/notes/hp300/hardware:1.21	Sun Apr 12 17:13:29 2020
+++ src/distrib/notes/hp300/hardware	Fri May  1 03:02:28 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: hardware,v 1.21 2020/04/12 17:13:29 tsutsui Exp $
+.\"	$NetBSD: hardware,v 1.22 2020/05/01 03:02:28 tsutsui Exp $
 .
 .Nx*M
 \*V will run on most HP 9000/300- and 400-series machines.
@@ -21,6 +21,8 @@ CPUs
 .br
 .Em "Requires Human Interface board"
 .It
+332 (16 MHz 68030, optional 68882, up to 8 MB RAM)
+.It
 340 (16 MHz 68030, up to 16 MB RAM)
 .It
 345 (50 MHz 68030 with 32 KB L2 cache, up to 128 MB RAM, built-in SCSI)
@@ -245,8 +247,6 @@ CPUs
 .(bullet -compact
 310 (10 MHz 68010, with built-in monochrome framebuffer, rs232
 (25 pin), hil, and slow hpib)
-.It
-332 (16? MHz 68030, with no floating point unit)
 .bullet)
 .It
 Graphics Devices



CVS commit: src/distrib/notes/hp300

2020-04-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri May  1 03:02:28 UTC 2020

Modified Files:
src/distrib/notes/hp300: hardware

Log Message:
Move HP332 to "Supported hardware" list, as reported by Chris Hanson.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/distrib/notes/hp300/hardware

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



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

2020-04-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri May  1 01:44:30 UTC 2020

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

Log Message:
Oops, accidentally #if 0'd some tests, probably while debugging
something else.  Correct this silly mistake.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_futex_robust.c

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



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

2020-04-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri May  1 01:44:30 UTC 2020

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

Log Message:
Oops, accidentally #if 0'd some tests, probably while debugging
something else.  Correct this silly mistake.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_futex_robust.c

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

Modified files:

Index: src/tests/lib/libc/sys/t_futex_robust.c
diff -u src/tests/lib/libc/sys/t_futex_robust.c:1.1 src/tests/lib/libc/sys/t_futex_robust.c:1.2
--- src/tests/lib/libc/sys/t_futex_robust.c:1.1	Sun Apr 26 18:53:33 2020
+++ src/tests/lib/libc/sys/t_futex_robust.c	Fri May  1 01:44:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_futex_robust.c,v 1.1 2020/04/26 18:53:33 thorpej Exp $ */
+/* $NetBSD: t_futex_robust.c,v 1.2 2020/05/01 01:44:30 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2019\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_futex_robust.c,v 1.1 2020/04/26 18:53:33 thorpej Exp $");
+__RCSID("$NetBSD: t_futex_robust.c,v 1.2 2020/05/01 01:44:30 thorpej Exp $");
 
 #include 
 #include 
@@ -396,12 +396,10 @@ ATF_TC_CLEANUP(futex_robust_bad_pending,
 
 ATF_TP_ADD_TCS(tp)
 {
-#if 0
 	ATF_TP_ADD_TC(tp, futex_robust_positive);
 	ATF_TP_ADD_TC(tp, futex_robust_negative);
 	ATF_TP_ADD_TC(tp, futex_robust_unmapped);
 	ATF_TP_ADD_TC(tp, futex_robust_evil_circular);
-#endif
 	ATF_TP_ADD_TC(tp, futex_robust_bad_pending);
 
 	return atf_no_error();



CVS commit: src/sys/dev/ic

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May  1 01:34:58 UTC 2020

Modified Files:
src/sys/dev/ic: pckbc.c

Log Message:
Zero rndsource before using it.

XXX pullup


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/ic/pckbc.c

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



CVS commit: src/sys/dev/ic

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May  1 01:34:58 UTC 2020

Modified Files:
src/sys/dev/ic: pckbc.c

Log Message:
Zero rndsource before using it.

XXX pullup


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/ic/pckbc.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/ic/pckbc.c
diff -u src/sys/dev/ic/pckbc.c:1.61 src/sys/dev/ic/pckbc.c:1.62
--- src/sys/dev/ic/pckbc.c:1.61	Sun Nov 10 21:16:35 2019
+++ src/sys/dev/ic/pckbc.c	Fri May  1 01:34:57 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pckbc.c,v 1.61 2019/11/10 21:16:35 chs Exp $ */
+/* $NetBSD: pckbc.c,v 1.62 2020/05/01 01:34:57 riastradh Exp $ */
 
 /*
  * Copyright (c) 2004 Ben Harris.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.61 2019/11/10 21:16:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.62 2020/05/01 01:34:57 riastradh Exp $");
 
 #include 
 #include 
@@ -262,9 +262,12 @@ pckbc_attach_slot(struct pckbc_softc *sc
 		t->t_slotdata[slot] = NULL;
 	}
 
-	if (child != NULL && t->t_slotdata[slot] != NULL)
+	if (child != NULL && t->t_slotdata[slot] != NULL) {
+		memset(>t_slotdata[slot]->rnd_source, 0,
+		sizeof(t->t_slotdata[slot]->rnd_source));
 		rnd_attach_source(>t_slotdata[slot]->rnd_source,
 		device_xname(child), RND_TYPE_TTY, RND_FLAG_DEFAULT);
+	}
 
 	return child != NULL;
 }



CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May  1 01:31:17 UTC 2020

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

Log Message:
Fix sense of conditional in previous.

I must have tested (cold ? (void *)1 : curlwp) but then decided,
after testing, to replace cold by !curcpu_available() -- thinking
that would be a safe change to make, except I forgot to either write
the ! or change the sense of the conditional.  OOPS.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 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.7 src/sys/kern/kern_entropy.c:1.8
--- src/sys/kern/kern_entropy.c:1.7	Thu Apr 30 20:06:40 2020
+++ src/sys/kern/kern_entropy.c	Fri May  1 01:31:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.7 2020/04/30 20:06:40 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.8 2020/05/01 01:31:17 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.7 2020/04/30 20:06:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.8 2020/05/01 01:31:17 riastradh Exp $");
 
 #include 
 #include 
@@ -1566,7 +1566,7 @@ rnd_trylock_sources(void)
 
 	if (E->sourcelock)
 		return false;
-	E->sourcelock = (curcpu_available() ? (void *)1 : curlwp);
+	E->sourcelock = (curcpu_available() ? curlwp : (void *)1);
 	return true;
 }
 
@@ -1582,9 +1582,9 @@ rnd_unlock_sources(void)
 
 	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
 
-	KASSERTMSG(E->sourcelock == (curcpu_available() ? (void *)1 : curlwp),
+	KASSERTMSG(E->sourcelock == (curcpu_available() ? curlwp : (void *)1),
 	"lwp %p releasing lock held by %p",
-	(curcpu_available() ? (void *)1 : curlwp), E->sourcelock);
+	(curcpu_available() ? curlwp : (void *)1), E->sourcelock);
 	E->sourcelock = NULL;
 	if (E->stage >= ENTROPY_WARM)
 		cv_broadcast(>cv);
@@ -1600,7 +1600,7 @@ static bool __diagused
 rnd_sources_locked(void)
 {
 
-	return E->sourcelock == (curcpu_available() ? (void *)1 : curlwp);
+	return E->sourcelock == (curcpu_available() ? curlwp : (void *)1);
 }
 
 /*



CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri May  1 01:31:17 UTC 2020

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

Log Message:
Fix sense of conditional in previous.

I must have tested (cold ? (void *)1 : curlwp) but then decided,
after testing, to replace cold by !curcpu_available() -- thinking
that would be a safe change to make, except I forgot to either write
the ! or change the sense of the conditional.  OOPS.


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



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

2020-04-30 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Apr 30 22:09:32 UTC 2020

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

Log Message:
Change module path to xen-* only for XENPV


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/sys/arch/x86/x86/x86_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/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.138 src/sys/arch/x86/x86/x86_machdep.c:1.139
--- src/sys/arch/x86/x86/x86_machdep.c:1.138	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/x86/x86_machdep.c	Thu Apr 30 22:09:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_machdep.c,v 1.138 2020/04/25 15:26:18 bouyer Exp $	*/
+/*	$NetBSD: x86_machdep.c,v 1.139 2020/04/30 22:09:32 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.138 2020/04/25 15:26:18 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.139 2020/04/30 22:09:32 bouyer Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -95,7 +95,7 @@ void (*x86_cpu_idle)(void);
 static bool x86_cpu_idle_ipi;
 static char x86_cpu_idle_text[16];
 
-#ifdef XEN
+#ifdef XENPV
 char module_machine_amd64_xen[] = "amd64-xen";
 char module_machine_i386pae_xen[] = "i386pae-xen";
 #endif
@@ -222,7 +222,7 @@ module_init_md(void)
 	struct bi_modulelist_entry *bi, *bimax;
 
 	/* setup module path for XEN kernels */
-#ifdef XEN
+#ifdef XENPV
 #ifdef __x86_64__
 	module_machine = module_machine_amd64_xen;
 #else



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

2020-04-30 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Apr 30 22:09:32 UTC 2020

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

Log Message:
Change module path to xen-* only for XENPV


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

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



CVS commit: src/sys/arch

2020-04-30 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Apr 30 22:05:18 UTC 2020

Modified Files:
src/sys/arch/amd64/include: intrdefs.h
src/sys/arch/i386/include: intrdefs.h
src/sys/arch/x86/include: cpu.h

Log Message:
Don't #include xen/intrdefs.h is !XEN.
Should fix third-party module builds (e.g. virtualbox)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amd64/include/intrdefs.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/include/intrdefs.h
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/x86/include/cpu.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/include/intrdefs.h
diff -u src/sys/arch/amd64/include/intrdefs.h:1.3 src/sys/arch/amd64/include/intrdefs.h:1.4
--- src/sys/arch/amd64/include/intrdefs.h:1.3	Sat Apr 25 15:26:16 2020
+++ src/sys/arch/amd64/include/intrdefs.h	Thu Apr 30 22:05:17 2020
@@ -1,4 +1,7 @@
-/*	$NetBSD: intrdefs.h,v 1.3 2020/04/25 15:26:16 bouyer Exp $	*/
+/*	$NetBSD: intrdefs.h,v 1.4 2020/04/30 22:05:17 bouyer Exp $	*/
 
 #include 
+
+#ifdef XEN
 #include 
+#endif

Index: src/sys/arch/i386/include/intrdefs.h
diff -u src/sys/arch/i386/include/intrdefs.h:1.5 src/sys/arch/i386/include/intrdefs.h:1.6
--- src/sys/arch/i386/include/intrdefs.h:1.5	Sat Apr 25 15:26:17 2020
+++ src/sys/arch/i386/include/intrdefs.h	Thu Apr 30 22:05:17 2020
@@ -1,4 +1,7 @@
-/*	$NetBSD: intrdefs.h,v 1.5 2020/04/25 15:26:17 bouyer Exp $	*/
+/*	$NetBSD: intrdefs.h,v 1.6 2020/04/30 22:05:17 bouyer Exp $	*/
 
 #include 
+
+#ifdef XEN
 #include 
+#endif

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.123 src/sys/arch/x86/include/cpu.h:1.124
--- src/sys/arch/x86/include/cpu.h:1.123	Mon Apr 27 16:29:17 2020
+++ src/sys/arch/x86/include/cpu.h	Thu Apr 30 22:05:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.123 2020/04/27 16:29:17 bouyer Exp $	*/
+/*	$NetBSD: cpu.h,v 1.124 2020/04/30 22:05:17 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -318,7 +318,8 @@ struct cpu_info {
 	struct evcnt	ci_xen_missed_hardclock_evcnt;
 #endif	/* XEN */
 };
-#ifndef XENPV
+
+#if defined(XEN) && !defined(XENPV)
 	__CTASSERT(XEN_NIPIS <= X86_NIPI);
 #endif
 



CVS commit: src/sys/arch

2020-04-30 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Apr 30 22:05:18 UTC 2020

Modified Files:
src/sys/arch/amd64/include: intrdefs.h
src/sys/arch/i386/include: intrdefs.h
src/sys/arch/x86/include: cpu.h

Log Message:
Don't #include xen/intrdefs.h is !XEN.
Should fix third-party module builds (e.g. virtualbox)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amd64/include/intrdefs.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/include/intrdefs.h
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/x86/include/cpu.h

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



CVS commit: [netbsd-7-0] src/games/fortune

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 21:24:25 UTC 2020

Modified Files:
src/games/fortune/strfile [netbsd-7-0]: strfile.c
src/games/fortune/unstr [netbsd-7-0]: unstr.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1729):

games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15

strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.6.1 src/games/fortune/strfile/strfile.c
cvs rdiff -u -r1.14 -r1.14.12.1 src/games/fortune/unstr/unstr.c

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



CVS commit: [netbsd-7-0] src/games/fortune

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 21:24:25 UTC 2020

Modified Files:
src/games/fortune/strfile [netbsd-7-0]: strfile.c
src/games/fortune/unstr [netbsd-7-0]: unstr.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1729):

games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15

strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.6.1 src/games/fortune/strfile/strfile.c
cvs rdiff -u -r1.14 -r1.14.12.1 src/games/fortune/unstr/unstr.c

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

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.38 src/games/fortune/strfile/strfile.c:1.38.6.1
--- src/games/fortune/strfile/strfile.c:1.38	Thu Sep 19 00:34:00 2013
+++ src/games/fortune/strfile/strfile.c	Thu Apr 30 21:24:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $	*/
+/*	$NetBSD: strfile.c,v 1.38.6.1 2020/04/30 21:24:25 martin Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)strfile.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.38.6.1 2020/04/30 21:24:25 martin Exp $");
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -267,6 +267,7 @@ getargs(int argc, char **argv)
 	int	ch;
 	extern	int optind;
 	extern	char *optarg;
+	size_t	len;
 
 	while ((ch = getopt(argc, argv, "c:iorsx")) != -1)
 		switch(ch) {
@@ -300,14 +301,25 @@ getargs(int argc, char **argv)
 
 	if (*argv) {
 		Infile = *argv;
-		if (*++argv)
-			(void) strcpy(Outfile, *argv);
+		if (*++argv) {
+			len = strlen(*argv);
+			if (len >= sizeof(Outfile)) {
+puts("Bad output filename");
+usage();
+			}
+			(void) memcpy(Outfile, *argv, len + 1);
+		}
 	}
 	if (!Infile) {
 		puts("No input file name");
 		usage();
 	}
 	if (*Outfile == '\0') {
+		len = strlen(Infile) + sizeof(".dat");
+		if (len > sizeof(Outfile)) {
+			puts("Bad input filename");
+			usage();
+		}
 		(void) strcpy(Outfile, Infile);
 		(void) strcat(Outfile, ".dat");
 	}

Index: src/games/fortune/unstr/unstr.c
diff -u src/games/fortune/unstr/unstr.c:1.14 src/games/fortune/unstr/unstr.c:1.14.12.1
--- src/games/fortune/unstr/unstr.c:1.14	Tue Jun 19 05:46:08 2012
+++ src/games/fortune/unstr/unstr.c	Thu Apr 30 21:24:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $	*/
+/*	$NetBSD: unstr.c,v 1.14.12.1 2020/04/30 21:24:25 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)unstr.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $");
+__RCSID("$NetBSD: unstr.c,v 1.14.12.1 2020/04/30 21:24:25 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -114,7 +114,7 @@ main(int ac __unused, char **av)
 void
 getargs(char *av[])
 {
-	if (!*++av) {
+	if (!*++av || (strlen(*av) + sizeof(".dat")) > sizeof(Datafile)) {
 		(void) fprintf(stderr, "usage: unstr datafile\n");
 		exit(1);
 	}



CVS commit: src/sys/kern

2020-04-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Apr 30 20:54:27 UTC 2020

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/kern/kern_softint.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_softint.c
diff -u src/sys/kern/kern_softint.c:1.64 src/sys/kern/kern_softint.c:1.65
--- src/sys/kern/kern_softint.c:1.64	Fri Mar 27 00:13:52 2020
+++ src/sys/kern/kern_softint.c	Thu Apr 30 20:54:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_softint.c,v 1.64 2020/03/27 00:13:52 ad Exp $	*/
+/*	$NetBSD: kern_softint.c,v 1.65 2020/04/30 20:54:27 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -112,7 +112,7 @@
  *	and so has a number of restrictions:
  *
  *	1) The software interrupts are not currently preemptive, so
- *	must wait for the currently executing LWP to yield the CPU. 
+ *	must wait for the currently executing LWP to yield the CPU.
  *	This can introduce latency.
  *
  *	2) An expensive context switch is required for a software
@@ -162,7 +162,7 @@
  *
  *	Once the soft interrupt has fired (and even if it has blocked),
  *	no further soft interrupts at that level will be triggered by
- *	MI code until the soft interrupt handler has ceased execution. 
+ *	MI code until the soft interrupt handler has ceased execution.
  *	If a soft interrupt handler blocks and is resumed, it resumes
  *	execution as a normal LWP (kthread) and gains VM context.  Only
  *	when it has completed and is ready to fire again will it
@@ -170,7 +170,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.64 2020/03/27 00:13:52 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.65 2020/04/30 20:54:27 skrll Exp $");
 
 #include 
 #include 
@@ -481,7 +481,7 @@ softint_schedule(void *arg)
 	 * If this assert fires, rather than disabling preemption explicitly
 	 * to make it stop, consider that you are probably using a softint
 	 * when you don't need to.
-	 */	
+	 */
 	KASSERT(kpreempt_disabled());
 
 	/* Find the handler record for this CPU. */
@@ -583,7 +583,7 @@ softint_execute(softint_t *si, lwp_t *l,
 			(*sh->sh_func)(sh->sh_arg);
 			KERNEL_UNLOCK_ONE(l);
 		}
-		
+
 		/* Diagnostic: check that spin-locks have not leaked. */
 		KASSERTMSG(curcpu()->ci_mtx_count == 0,
 		"%s: ci_mtx_count (%d) != 0, sh_func %p\n",



CVS commit: src/sys/kern

2020-04-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Apr 30 20:54:27 UTC 2020

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

Log Message:
Trailing whitespace


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

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



CVS commit: src/sys/arch

2020-04-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Apr 30 20:48:10 UTC 2020

Modified Files:
src/sys/arch/alpha/include: types.h
src/sys/arch/mips/include: types.h
src/sys/arch/sh3/include: types.h

Log Message:
G/C __HAVE_AST_PERPROC


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/alpha/include/types.h
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/mips/include/types.h
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/sh3/include/types.h

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



CVS commit: src/sys/arch

2020-04-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Apr 30 20:48:10 UTC 2020

Modified Files:
src/sys/arch/alpha/include: types.h
src/sys/arch/mips/include: types.h
src/sys/arch/sh3/include: types.h

Log Message:
G/C __HAVE_AST_PERPROC


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/alpha/include/types.h
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/mips/include/types.h
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/sh3/include/types.h

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

Modified files:

Index: src/sys/arch/alpha/include/types.h
diff -u src/sys/arch/alpha/include/types.h:1.55 src/sys/arch/alpha/include/types.h:1.56
--- src/sys/arch/alpha/include/types.h:1.55	Sat Apr  6 03:06:24 2019
+++ src/sys/arch/alpha/include/types.h	Thu Apr 30 20:48:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.55 2019/04/06 03:06:24 thorpej Exp $ */
+/* $NetBSD: types.h,v 1.56 2020/04/30 20:48:10 skrll Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -74,7 +74,6 @@ typedef __register_t	register_t;
 #define	__HAVE_CPU_COUNTER
 #define	__HAVE_SYSCALL_INTERN
 #define	__HAVE_MINIMAL_EMUL
-#define	__HAVE_AST_PERPROC
 #define	__HAVE_ATOMIC64_OPS
 #define	__HAVE_MM_MD_DIRECT_MAPPED_IO
 #define	__HAVE_MM_MD_DIRECT_MAPPED_PHYS

Index: src/sys/arch/mips/include/types.h
diff -u src/sys/arch/mips/include/types.h:1.69 src/sys/arch/mips/include/types.h:1.70
--- src/sys/arch/mips/include/types.h:1.69	Sun Mar 22 17:33:58 2020
+++ src/sys/arch/mips/include/types.h	Thu Apr 30 20:48:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.69 2020/03/22 17:33:58 ad Exp $	*/
+/*	$NetBSD: types.h,v 1.70 2020/04/30 20:48:10 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -147,7 +147,6 @@ typedef __uint32_t tlb_asid_t;
 #define	__SIMPLELOCK_UNLOCKED	0
 
 #define	__HAVE_FAST_SOFTINTS
-#define	__HAVE_AST_PERPROC
 #define	__HAVE_SYSCALL_INTERN
 #define	__HAVE_CPU_LWP_SETPRIVATE
 #define	__HAVE_CPU_DATA_FIRST

Index: src/sys/arch/sh3/include/types.h
diff -u src/sys/arch/sh3/include/types.h:1.37 src/sys/arch/sh3/include/types.h:1.38
--- src/sys/arch/sh3/include/types.h:1.37	Sat Jan 23 22:31:20 2016
+++ src/sys/arch/sh3/include/types.h	Thu Apr 30 20:48:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.37 2016/01/23 22:31:20 christos Exp $	*/
+/*	$NetBSD: types.h,v 1.38 2020/04/30 20:48:10 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -69,7 +69,6 @@ typedef	int		__register_t;
 #define	__SIMPLELOCK_LOCKED	0x80
 #define	__SIMPLELOCK_UNLOCKED	0
 
-#define	__HAVE_AST_PERPROC
 #define	__HAVE_NEW_STYLE_BUS_H
 #define	__HAVE_CPU_DATA_FIRST
 #define	__HAVE_SYSCALL_INTERN



CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 30 20:06:40 UTC 2020

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

Log Message:
Mark rnd_sources_locked __diagused -- only for KASSERTs.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.6 src/sys/kern/kern_entropy.c:1.7
--- src/sys/kern/kern_entropy.c:1.6	Thu Apr 30 19:34:37 2020
+++ src/sys/kern/kern_entropy.c	Thu Apr 30 20:06:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.6 2020/04/30 19:34:37 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.7 2020/04/30 20:06:40 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.6 2020/04/30 19:34:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.7 2020/04/30 20:06:40 riastradh Exp $");
 
 #include 
 #include 
@@ -1596,7 +1596,7 @@ rnd_unlock_sources(void)
  *	True if we hold the list of rndsources locked, for diagnostic
  *	assertions.
  */
-static bool
+static bool __diagused
 rnd_sources_locked(void)
 {
 



CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 30 20:06:40 UTC 2020

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

Log Message:
Mark rnd_sources_locked __diagused -- only for KASSERTs.


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



CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 30 19:34:37 UTC 2020

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

Log Message:
curlwp may not be available early enough for kern_entropy.c.

Fortunately, we're just using it to print helpful diagnostic messages
in kasserts here, so while we're still cold just use (void *)1 for
now until someone figures out how to make curlwp available earlier on
x86.

(All of the curcpu_available() business is a provisional crock here
and it would be better to get rid of it.)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 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.5 src/sys/kern/kern_entropy.c:1.6
--- src/sys/kern/kern_entropy.c:1.5	Thu Apr 30 17:16:00 2020
+++ src/sys/kern/kern_entropy.c	Thu Apr 30 19:34:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.5 2020/04/30 17:16:00 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.6 2020/04/30 19:34:37 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.5 2020/04/30 17:16:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.6 2020/04/30 19:34:37 riastradh Exp $");
 
 #include 
 #include 
@@ -1566,7 +1566,7 @@ rnd_trylock_sources(void)
 
 	if (E->sourcelock)
 		return false;
-	E->sourcelock = curlwp;
+	E->sourcelock = (curcpu_available() ? (void *)1 : curlwp);
 	return true;
 }
 
@@ -1582,8 +1582,9 @@ rnd_unlock_sources(void)
 
 	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
 
-	KASSERTMSG(E->sourcelock == curlwp, "lwp %p releasing lock held by %p",
-	curlwp, E->sourcelock);
+	KASSERTMSG(E->sourcelock == (curcpu_available() ? (void *)1 : curlwp),
+	"lwp %p releasing lock held by %p",
+	(curcpu_available() ? (void *)1 : curlwp), E->sourcelock);
 	E->sourcelock = NULL;
 	if (E->stage >= ENTROPY_WARM)
 		cv_broadcast(>cv);
@@ -1599,7 +1600,7 @@ static bool
 rnd_sources_locked(void)
 {
 
-	return E->sourcelock == curlwp;
+	return E->sourcelock == (curcpu_available() ? (void *)1 : curlwp);
 }
 
 /*



CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 30 19:34:37 UTC 2020

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

Log Message:
curlwp may not be available early enough for kern_entropy.c.

Fortunately, we're just using it to print helpful diagnostic messages
in kasserts here, so while we're still cold just use (void *)1 for
now until someone figures out how to make curlwp available earlier on
x86.

(All of the curcpu_available() business is a provisional crock here
and it would be better to get rid of it.)


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



re: CVS commit: src/doc

2020-04-30 Thread matthew green
> Modified Files:
>   src/doc: HACKS

thank you for keeping this upto date.


.mrg.


CVS commit: src/sys/kern

2020-04-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu Apr 30 17:36:06 UTC 2020

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

Log Message:
Make kern.arandom truncate the output instead of failing with ETOOBIG
when the requested data exceeds 256 bytes in size. The actual size of
the returned data is output to oldlenp.

This matches FreeBSD's behaviour and seems to be more in line with
what software in the wild expects.

"sounds reasonble" - Riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/kern/subr_cprng.c

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



CVS commit: src/sys/kern

2020-04-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu Apr 30 17:36:06 UTC 2020

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

Log Message:
Make kern.arandom truncate the output instead of failing with ETOOBIG
when the requested data exceeds 256 bytes in size. The actual size of
the returned data is output to oldlenp.

This matches FreeBSD's behaviour and seems to be more in line with
what software in the wild expects.

"sounds reasonble" - Riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/kern/subr_cprng.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/subr_cprng.c
diff -u src/sys/kern/subr_cprng.c:1.36 src/sys/kern/subr_cprng.c:1.37
--- src/sys/kern/subr_cprng.c:1.36	Thu Apr 30 03:28:18 2020
+++ src/sys/kern/subr_cprng.c	Thu Apr 30 17:36:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cprng.c,v 1.36 2020/04/30 03:28:18 riastradh Exp $	*/
+/*	$NetBSD: subr_cprng.c,v 1.37 2020/04/30 17:36:06 nia Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.36 2020/04/30 03:28:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.37 2020/04/30 17:36:06 nia Exp $");
 
 #include 
 #include 
@@ -172,7 +172,7 @@ sysctl_kern_arandom(SYSCTLFN_ARGS)
 	 * the past, so let's not break compatibility.
 	 */
 	if (*oldlenp > 256)	/* size_t, so never negative */
-		return E2BIG;
+		*oldlenp = 256;
 
 	/* Generate data.  */
 	cprng_strong(user_cprng, buf, *oldlenp, 0);



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

2020-04-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 30 17:21:12 UTC 2020

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

Log Message:
The labels are already global, drop unused.


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/sys/arch/amd64/amd64/locore.S

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



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

2020-04-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 30 17:21:12 UTC 2020

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

Log Message:
The labels are already global, drop unused.


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/sys/arch/amd64/amd64/locore.S

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

Modified files:

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.203 src/sys/arch/amd64/amd64/locore.S:1.204
--- src/sys/arch/amd64/amd64/locore.S:1.203	Thu Apr 30 17:17:33 2020
+++ src/sys/arch/amd64/amd64/locore.S	Thu Apr 30 17:21:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.203 2020/04/30 17:17:33 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.204 2020/04/30 17:21:12 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1610,11 +1610,6 @@ LABEL(hp_stac)
 LABEL(hp_stac_end)
 
 #ifdef SVS
-	.globl	svs_enter, svs_enter_end
-	.globl	svs_enter_altstack, svs_enter_altstack_end
-	.globl	svs_leave, svs_leave_end
-	.globl	svs_leave_altstack, svs_leave_altstack_end
-
 LABEL(svs_enter)
 	movabs	SVS_UTLS+UTLS_KPDIRPA,%rax
 	movq	%rax,%cr3
@@ -1656,9 +1651,6 @@ LABEL(svs_leave_nmi)
 LABEL(svs_leave_nmi_end)
 #endif
 
-	.globl	ibrs_enter, ibrs_enter_end
-	.globl	ibrs_leave, ibrs_leave_end
-
 	/* IBRS <- 1 */
 LABEL(ibrs_enter)
 	movl	$MSR_IA32_SPEC_CTRL,%ecx
@@ -1683,8 +1675,6 @@ LABEL(noibrs_leave)
 	NOIBRS_LEAVE
 LABEL(noibrs_leave_end)
 
-	.globl	mds_leave, mds_leave_end
-
 LABEL(mds_leave)
 	pushq	$GSEL(GDATA_SEL, SEL_KPL)
 	verw	(%rsp)



CVS commit: src/sys/arch

2020-04-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 30 17:17:33 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: locore.S
src/sys/arch/i386/i386: locore.S
src/sys/arch/x86/x86: patch.c

Log Message:
Switch to templates.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.180 -r1.181 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.42 -r1.43 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.



CVS commit: src/sys/arch

2020-04-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 30 17:17:33 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64: locore.S
src/sys/arch/i386/i386: locore.S
src/sys/arch/x86/x86: patch.c

Log Message:
Switch to templates.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.180 -r1.181 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.42 -r1.43 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/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.202 src/sys/arch/amd64/amd64/locore.S:1.203
--- src/sys/arch/amd64/amd64/locore.S:1.202	Sun Apr 26 14:07:43 2020
+++ src/sys/arch/amd64/amd64/locore.S	Thu Apr 30 17:17:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.202 2020/04/26 14:07:43 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.203 2020/04/30 17:17:33 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1589,6 +1589,26 @@ END(intrfastexit)
 
 	.section .rodata
 
+	/*
+	 * Hotpatch templates.
+	 */
+
+LABEL(hp_nolock)
+	nop
+LABEL(hp_nolock_end)
+
+LABEL(hp_retfence)
+	lfence
+LABEL(hp_retfence_end)
+
+LABEL(hp_clac)
+	clac
+LABEL(hp_clac_end)
+
+LABEL(hp_stac)
+	stac
+LABEL(hp_stac_end)
+
 #ifdef SVS
 	.globl	svs_enter, svs_enter_end
 	.globl	svs_enter_altstack, svs_enter_altstack_end

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.180 src/sys/arch/i386/i386/locore.S:1.181
--- src/sys/arch/i386/i386/locore.S:1.180	Sat Apr 25 15:26:17 2020
+++ src/sys/arch/i386/i386/locore.S	Thu Apr 30 17:17:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.180 2020/04/25 15:26:17 bouyer Exp $	*/
+/*	$NetBSD: locore.S,v 1.181 2020/04/30 17:17:33 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.180 2020/04/25 15:26:17 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.181 2020/04/30 17:17:33 maxv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1612,3 +1612,24 @@ ENTRY(intrfastexit)
 	iret
 END(intrfastexit)
 
+	.section .rodata
+
+	/*
+	 * Hotpatch templates.
+	 */
+
+LABEL(hp_nolock)
+	nop
+LABEL(hp_nolock_end)
+
+LABEL(hp_retfence)
+	lfence
+LABEL(hp_retfence_end)
+
+LABEL(hp_clac)
+	clac
+LABEL(hp_clac_end)
+
+LABEL(hp_stac)
+	stac
+LABEL(hp_stac_end)

Index: src/sys/arch/x86/x86/patch.c
diff -u src/sys/arch/x86/x86/patch.c:1.42 src/sys/arch/x86/x86/patch.c:1.43
--- src/sys/arch/x86/x86/patch.c:1.42	Sun Apr 26 14:49:17 2020
+++ src/sys/arch/x86/x86/patch.c	Thu Apr 30 17:17:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: patch.c,v 1.42 2020/04/26 14:49:17 maxv Exp $	*/
+/*	$NetBSD: patch.c,v 1.43 2020/04/30 17:17:33 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.42 2020/04/26 14:49:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.43 2020/04/30 17:17:33 maxv Exp $");
 
 #include "opt_lockdebug.h"
 #ifdef i386
@@ -174,6 +174,8 @@ void
 x86_patch(bool early)
 {
 	static bool first, second;
+	uint8_t *bytes;
+	size_t size;
 	u_long psl;
 	u_long cr0;
 
@@ -194,12 +196,11 @@ x86_patch(bool early)
 		/*
 		 * Uniprocessor: kill LOCK prefixes.
 		 */
-		const uint8_t bytes[] = {
-			X86_NOP
-		};
+		extern uint8_t hp_nolock, hp_nolock_end;
 
-		/* lock -> nop */
-		x86_hotpatch(HP_NAME_NOLOCK, bytes, sizeof(bytes));
+		bytes = _nolock;
+		size = (size_t)_nolock_end - (size_t)_nolock;
+		x86_hotpatch(HP_NAME_NOLOCK, bytes, size);
 #endif
 	}
 
@@ -212,8 +213,6 @@ x86_patch(bool early)
 		 */
 		extern uint8_t sse2_lfence, sse2_lfence_end;
 		extern uint8_t sse2_mfence, sse2_mfence_end;
-		uint8_t *bytes;
-		size_t size;
 
 		bytes = _lfence;
 		size = (size_t)_lfence_end - (size_t)_lfence;
@@ -265,35 +264,30 @@ x86_patch(bool early)
 	(CPUID_TO_FAMILY(cpu_info_primary.ci_signature) == 0xe ||
 	(CPUID_TO_FAMILY(cpu_info_primary.ci_signature) == 0xf &&
 	CPUID_TO_EXTMODEL(cpu_info_primary.ci_signature) < 0x4))) {
-		const uint8_t bytes[] = {
-			0x0F, 0xAE, 0xE8 /* lfence */
-		};
+		extern uint8_t hp_retfence, hp_retfence_end;
 
-		/* ret,nop,nop -> lfence */
-		x86_hotpatch(HP_NAME_RETFENCE, bytes, sizeof(bytes));
+		bytes = _retfence;
+		size = (size_t)_retfence_end - (size_t)_retfence;
+		x86_hotpatch(HP_NAME_RETFENCE, bytes, size);
 	}
 
 	/*
 	 * If SMAP is present then patch the prepared holes with clac/stac
 	 * instructions.
-	 *
-	 * clac = 0x0f, 0x01, 0xca
-	 * stac = 0x0f, 0x01, 0xcb
 	 */
 	if (!early && cpu_feature[5] & CPUID_SEF_SMAP) {
-		KASSERT(rcr4() & CR4_SMAP);
-		const uint8_t clac_bytes[] = {
-			0x0F, 0x01, 0xCA /* clac */
-		};
-		const uint8_t stac_bytes[] = {
-			0x0F, 0x01, 0xCB /* stac */
-		};
+		extern uint8_t hp_clac, hp_clac_end;
+		extern uint8_t hp_stac, hp_stac_end;
 
-		/* nop,nop,nop -> clac */
-		

CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 30 17:16:00 UTC 2020

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

Log Message:
Missed a spot!  (Part II(b) of no percpu_foreach under spin lock.)


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



CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 30 17:16:00 UTC 2020

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

Log Message:
Missed a spot!  (Part II(b) of no percpu_foreach under spin lock.)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 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.4 src/sys/kern/kern_entropy.c:1.5
--- src/sys/kern/kern_entropy.c:1.4	Thu Apr 30 16:50:00 2020
+++ src/sys/kern/kern_entropy.c	Thu Apr 30 17:16:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.4 2020/04/30 16:50:00 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.5 2020/04/30 17:16:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.4 2020/04/30 16:50:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.5 2020/04/30 17:16:00 riastradh Exp $");
 
 #include 
 #include 
@@ -2000,7 +2000,9 @@ entropy_ioctl(unsigned long cmd, void *d
 break;
 		}
 		while (i < stat->count && rs != NULL) {
+			mutex_exit(>lock);
 			rndsource_to_user(rs, >source[i++]);
+			mutex_enter(>lock);
 			rs = LIST_NEXT(rs, list);
 		}
 		KASSERT(i <= stat->count);



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

2020-04-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 30 16:56:24 UTC 2020

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

Log Message:
If we were processing a software int/excp, and got a VMEXIT in the middle,
we must also reflect the instruction length, otherwise the next VMENTER
fails and Qemu shuts the guest down.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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

Modified files:

Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.53 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.54
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.53	Thu Apr 30 16:50:17 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Thu Apr 30 16:56:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.53 2020/04/30 16:50:17 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.54 2020/04/30 16:56:23 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.53 2020/04/30 16:50:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.54 2020/04/30 16:56:23 maxv Exp $");
 
 #include 
 #include 
@@ -369,7 +369,7 @@ vmx_vmclear(paddr_t *pa)
 #define		INTR_INFO_ERROR			__BIT(11)
 #define		INTR_INFO_VALID			__BIT(31)
 #define VMCS_ENTRY_EXCEPTION_ERROR		0x4018
-#define VMCS_ENTRY_INST_LENGTH			0x401A
+#define VMCS_ENTRY_INSTRUCTION_LENGTH		0x401A
 #define VMCS_TPR_THRESHOLD			0x401C
 #define VMCS_PROCBASED_CTLS2			0x401E
 #define		PROC_CTLS2_VIRT_APIC_ACCESSES	__BIT(0)
@@ -1896,7 +1896,7 @@ vmx_htlb_flush_ack(struct vmx_cpudata *c
 static inline void
 vmx_exit_evt(struct vmx_cpudata *cpudata)
 {
-	uint64_t info, err;
+	uint64_t info, err, inslen;
 
 	cpudata->evt_pending = false;
 
@@ -1909,6 +1909,14 @@ vmx_exit_evt(struct vmx_cpudata *cpudata
 	vmx_vmwrite(VMCS_ENTRY_INTR_INFO, info);
 	vmx_vmwrite(VMCS_ENTRY_EXCEPTION_ERROR, err);
 
+	switch (__SHIFTOUT(info, INTR_INFO_TYPE)) {
+	case INTR_TYPE_SW_INT:
+	case INTR_TYPE_PRIV_SW_EXC:
+	case INTR_TYPE_SW_EXC:
+		inslen = vmx_vmread(VMCS_EXIT_INSTRUCTION_LENGTH);
+		vmx_vmwrite(VMCS_ENTRY_INSTRUCTION_LENGTH, inslen);
+	}
+
 	cpudata->evt_pending = true;
 }
 



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

2020-04-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 30 16:56:24 UTC 2020

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

Log Message:
If we were processing a software int/excp, and got a VMEXIT in the middle,
we must also reflect the instruction length, otherwise the next VMENTER
fails and Qemu shuts the guest down.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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



CVS commit: src/sys/dev/nvmm

2020-04-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 30 16:50:18 UTC 2020

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

Log Message:
When the identification fails, print the reason.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/nvmm/nvmm.c
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
cvs rdiff -u -r1.52 -r1.53 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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



CVS commit: src/sys/dev/nvmm

2020-04-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 30 16:50:18 UTC 2020

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

Log Message:
When the identification fails, print the reason.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/nvmm/nvmm.c
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
cvs rdiff -u -r1.52 -r1.53 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c

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

Modified files:

Index: src/sys/dev/nvmm/nvmm.c
diff -u src/sys/dev/nvmm/nvmm.c:1.26 src/sys/dev/nvmm/nvmm.c:1.27
--- src/sys/dev/nvmm/nvmm.c:1.26	Sun Apr 26 19:31:36 2020
+++ src/sys/dev/nvmm/nvmm.c	Thu Apr 30 16:50:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm.c,v 1.26 2020/04/26 19:31:36 maxv Exp $	*/
+/*	$NetBSD: nvmm.c,v 1.27 2020/04/30 16:50:17 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.26 2020/04/26 19:31:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.27 2020/04/30 16:50:17 maxv Exp $");
 
 #include 
 #include 
@@ -961,7 +961,7 @@ nvmm_init(void)
 		break;
 	}
 	if (nvmm_impl == NULL) {
-		printf("[!] No implementation found\n");
+		printf("NVMM: CPU not supported\n");
 		return ENOTSUP;
 	}
 

Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.58 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.59
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.58	Sun Mar 22 00:16:16 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c	Thu Apr 30 16:50:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_svm.c,v 1.58 2020/03/22 00:16:16 ad Exp $	*/
+/*	$NetBSD: nvmm_x86_svm.c,v 1.59 2020/04/30 16:50:17 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.58 2020/03/22 00:16:16 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.59 2020/04/30 16:50:17 maxv Exp $");
 
 #include 
 #include 
@@ -2257,21 +2257,25 @@ svm_ident(void)
 		return false;
 	}
 	if (!(cpu_feature[3] & CPUID_SVM)) {
+		printf("NVMM: SVM not supported\n");
 		return false;
 	}
 
 	if (curcpu()->ci_max_ext_cpuid < 0x800a) {
+		printf("NVMM: CPUID leaf not available\n");
 		return false;
 	}
 	x86_cpuid(0x800a, descs);
 
 	/* Want Nested Paging. */
 	if (!(descs[3] & CPUID_AMD_SVM_NP)) {
+		printf("NVMM: SVM-NP not supported\n");
 		return false;
 	}
 
 	/* Want nRIP. */
 	if (!(descs[3] & CPUID_AMD_SVM_NRIPS)) {
+		printf("NVMM: SVM-NRIPS not supported\n");
 		return false;
 	}
 
@@ -2279,6 +2283,7 @@ svm_ident(void)
 
 	msr = rdmsr(MSR_VMCR);
 	if ((msr & VMCR_SVMED) && (msr & VMCR_LOCK)) {
+		printf("NVMM: SVM disabled in BIOS\n");
 		return false;
 	}
 

Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.52 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.53
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.52	Sun Mar 22 00:16:16 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Thu Apr 30 16:50:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.52 2020/03/22 00:16:16 ad Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.53 2020/04/30 16:50:17 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.52 2020/03/22 00:16:16 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.53 2020/04/30 16:50:17 maxv Exp $");
 
 #include 
 #include 
@@ -3001,17 +3001,21 @@ vmx_ident(void)
 
 	msr = rdmsr(MSR_IA32_FEATURE_CONTROL);
 	if ((msr & IA32_FEATURE_CONTROL_LOCK) == 0) {
+		printf("NVMM: VMX disabled in BIOS\n");
 		return false;
 	}
 	if ((msr & IA32_FEATURE_CONTROL_OUT_SMX) == 0) {
+		printf("NVMM: VMX disabled in BIOS\n");
 		return false;
 	}
 
 	msr = rdmsr(MSR_IA32_VMX_BASIC);
 	if ((msr & IA32_VMX_BASIC_IO_REPORT) == 0) {
+		printf("NVMM: I/O reporting not supported\n");
 		return false;
 	}
 	if (__SHIFTOUT(msr, IA32_VMX_BASIC_MEM_TYPE) != MEM_TYPE_WB) {
+		printf("NVMM: WB memory not supported\n");
 		return false;
 	}
 
@@ -3020,6 +3024,7 @@ vmx_ident(void)
 	vmx_cr0_fixed1 = rdmsr(MSR_IA32_VMX_CR0_FIXED1) | (CR0_PG|CR0_PE);
 	ret = vmx_check_cr(rcr0(), vmx_cr0_fixed0, vmx_cr0_fixed1);
 	if (ret == -1) {
+		printf("NVMM: CR0 requirements not satisfied\n");
 		return false;
 	}
 
@@ -3027,6 +3032,7 @@ vmx_ident(void)
 	vmx_cr4_fixed1 = rdmsr(MSR_IA32_VMX_CR4_FIXED1);
 	ret = vmx_check_cr(rcr4() | CR4_VMXE, vmx_cr4_fixed0, vmx_cr4_fixed1);
 	if (ret == -1) {
+		printf("NVMM: CR4 requirements not satisfied\n");
 		return false;
 	}
 
@@ -3036,6 +3042,7 @@ vmx_ident(void)
 	VMX_PINBASED_CTLS_ONE, VMX_PINBASED_CTLS_ZERO,
 	_pinbased_ctls);
 	if (ret == -1) {
+		printf("NVMM: pin-based-ctls requirements not satisfied\n");
 		return false;
 	}
 	ret = vmx_init_ctls(
@@ -3043,6 +3050,7 @@ vmx_ident(void)
 	

CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 30 16:50:01 UTC 2020

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

Log Message:
Lock the rndsource list without E->lock for ioctls too.

Use the same mechanism as entropy_request, with a little more
diagnostic information in case anything goes wrong.  No need for
LIST_FOREACH_SAFE; elements cannot be deleted while the list is
locked.

This is part II of avoiding percpu_foreach with spin lock held.


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



CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 30 16:50:01 UTC 2020

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

Log Message:
Lock the rndsource list without E->lock for ioctls too.

Use the same mechanism as entropy_request, with a little more
diagnostic information in case anything goes wrong.  No need for
LIST_FOREACH_SAFE; elements cannot be deleted while the list is
locked.

This is part II of avoiding percpu_foreach with spin lock held.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.3 src/sys/kern/kern_entropy.c:1.4
--- src/sys/kern/kern_entropy.c:1.3	Thu Apr 30 16:43:12 2020
+++ src/sys/kern/kern_entropy.c	Thu Apr 30 16:50:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.3 2020/04/30 16:43:12 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.4 2020/04/30 16:50:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.3 2020/04/30 16:43:12 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.4 2020/04/30 16:50:00 riastradh Exp $");
 
 #include 
 #include 
@@ -161,13 +161,13 @@ struct {
 	unsigned	epoch;		/* (A) changes when needed -> 0 */
 	kcondvar_t	cv;		/* notifies state changes */
 	struct selinfo	selq;		/* notifies needed -> 0 */
+	struct lwp	*sourcelock;	/* lock on list of sources */
 	LIST_HEAD(,krndsource) sources;	/* list of entropy sources */
 	enum entropy_stage {
 		ENTROPY_COLD = 0, /* single-threaded */
 		ENTROPY_WARM,	  /* multi-threaded at boot before CPUs */
 		ENTROPY_HOT,	  /* multi-threaded multi-CPU */
 	}		stage;
-	bool		requesting;	/* busy requesting from sources */
 	bool		consolidate;	/* kick thread to consolidate */
 	bool		seed_rndsource;	/* true if seed source is attached */
 	bool		seeded;		/* true if seed file already loaded */
@@ -1514,11 +1514,11 @@ rnd_detach_source(struct krndsource *rs)
 	/* We may have to wait for entropy_request.  */
 	ASSERT_SLEEPABLE();
 
-	/* Remove it from the list and wait for entropy_request.  */
+	/* Wait until the source list is not in use, and remove it.  */
 	mutex_enter(>lock);
-	LIST_REMOVE(rs, list);
-	while (E->requesting)
+	while (E->sourcelock)
 		cv_wait(>cv, >lock);
+	LIST_REMOVE(rs, list);
 	mutex_exit(>lock);
 
 	/* Free the per-CPU data.  */
@@ -1526,6 +1526,83 @@ rnd_detach_source(struct krndsource *rs)
 }
 
 /*
+ * rnd_lock_sources()
+ *
+ *	Prevent changes to the list of rndsources while we iterate it.
+ *	Interruptible.  Caller must hold the global entropy lock.  If
+ *	successful, no rndsource will go away until rnd_unlock_sources
+ *	even while the caller releases the global entropy lock.
+ */
+static int
+rnd_lock_sources(void)
+{
+	int error;
+
+	KASSERT(mutex_owned(>lock));
+
+	while (E->sourcelock) {
+		error = cv_wait_sig(>cv, >lock);
+		if (error)
+			return error;
+	}
+
+	E->sourcelock = curlwp;
+	return 0;
+}
+
+/*
+ * rnd_trylock_sources()
+ *
+ *	Try to lock the list of sources, but if it's already locked,
+ *	fail.  Caller must hold the global entropy lock.  If
+ *	successful, no rndsource will go away until rnd_unlock_sources
+ *	even while the caller releases the global entropy lock.
+ */
+static bool
+rnd_trylock_sources(void)
+{
+
+	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
+
+	if (E->sourcelock)
+		return false;
+	E->sourcelock = curlwp;
+	return true;
+}
+
+/*
+ * rnd_unlock_sources()
+ *
+ *	Unlock the list of sources after rnd_lock_sources or
+ *	rnd_trylock_sources.  Caller must hold the global entropy lock.
+ */
+static void
+rnd_unlock_sources(void)
+{
+
+	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
+
+	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);
+}
+
+/*
+ * rnd_sources_locked()
+ *
+ *	True if we hold the list of rndsources locked, for diagnostic
+ *	assertions.
+ */
+static bool
+rnd_sources_locked(void)
+{
+
+	return E->sourcelock == curlwp;
+}
+
+/*
  * entropy_request(nbytes)
  *
  *	Request nbytes bytes of entropy from all sources in the system.
@@ -1535,7 +1612,7 @@ rnd_detach_source(struct krndsource *rs)
 static void
 entropy_request(size_t nbytes)
 {
-	struct krndsource *rs, *next;
+	struct krndsource *rs;
 
 	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
 
@@ -1544,16 +1621,15 @@ entropy_request(size_t nbytes)
 	 * Otherwise, note that a request is in progress to avoid
 	 * reentry and to block rnd_detach_source until we're done.
 	 */
-	if (E->requesting)
+	if (!rnd_trylock_sources())
 		return;
-	E->requesting = true;
 	entropy_request_evcnt.ev_count++;
 
 	/* Clamp to the maximum reasonable request.  */
 	nbytes 

CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 30 16:43:12 UTC 2020

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

Log Message:
Avoid calling entropy_pending() with E->lock held.

This is part I of avoiding percpu_foreach with spin lock held.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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.2 src/sys/kern/kern_entropy.c:1.3
--- src/sys/kern/kern_entropy.c:1.2	Thu Apr 30 03:42:23 2020
+++ src/sys/kern/kern_entropy.c	Thu Apr 30 16:43:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.2 2020/04/30 03:42:23 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.3 2020/04/30 16:43:12 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.2 2020/04/30 03:42:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.3 2020/04/30 16:43:12 riastradh Exp $");
 
 #include 
 #include 
@@ -932,29 +932,32 @@ entropy_softintr(void *cookie)
 static void
 entropy_thread(void *cookie)
 {
+	bool consolidate;
 
 	for (;;) {
 		/*
-		 * Wait until someone wants to consolidate or there's
-		 * full entropy somewhere among the CPUs, as confirmed
-		 * at most once per minute.
+		 * Wait until there's full entropy somewhere among the
+		 * CPUs, as confirmed at most once per minute, or
+		 * someone wants to consolidate.
 		 */
-		mutex_enter(>lock);
-		for (;;) {
-			if (E->consolidate ||
-			entropy_pending() >= ENTROPY_CAPACITY*NBBY) {
-E->consolidate = false;
-break;
-			}
-			cv_timedwait(>cv, >lock, 60*hz);
+		if (entropy_pending() >= ENTROPY_CAPACITY*NBBY) {
+			consolidate = true;
+		} else {
+			mutex_enter(>lock);
+			if (!E->consolidate)
+cv_timedwait(>cv, >lock, 60*hz);
+			consolidate = E->consolidate;
+			E->consolidate = false;
+			mutex_exit(>lock);
 		}
-		mutex_exit(>lock);
 
-		/* Do it.  */
-		entropy_consolidate();
+		if (consolidate) {
+			/* Do it.  */
+			entropy_consolidate();
 
-		/* Mitigate abuse.  */
-		kpause("entropy", false, hz, NULL);
+			/* Mitigate abuse.  */
+			kpause("entropy", false, hz, NULL);
+		}
 	}
 }
 
@@ -969,7 +972,6 @@ entropy_pending(void)
 	uint32_t pending = 0;
 
 	percpu_foreach(entropy_percpu, _pending_cpu, );
-
 	return pending;
 }
 



CVS commit: src/sys/kern

2020-04-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 30 16:43:12 UTC 2020

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

Log Message:
Avoid calling entropy_pending() with E->lock held.

This is part I of avoiding percpu_foreach with spin lock held.


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



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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:25:16 UTC 2020

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

Log Message:
Ticket #1729


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



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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:25:16 UTC 2020

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

Log Message:
Ticket #1729


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.161 -r1.1.2.162 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.161 src/doc/CHANGES-7.0.3:1.1.2.162
--- src/doc/CHANGES-7.0.3:1.1.2.161	Wed Apr 15 14:59:54 2020
+++ src/doc/CHANGES-7.0.3	Thu Apr 30 16:25:15 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.161 2020/04/15 14:59:54 martin Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.162 2020/04/30 16:25:15 martin Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -5951,3 +5951,9 @@ sys/netinet6/nd6_rtr.c1.148 (via pat
 	PR kern/55091 and PR bin/54997: fix default route selection.
 	[kim, ticket #1727]
 
+games/fortune/strfile/strfile.c			1.39
+games/fortune/unstr/unstr.c			1.15
+
+	Fix potential buffer overflows in fortune tools.
+	[nia, ticket #1729]
+



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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:24:26 UTC 2020

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

Log Message:
Ticket #1729


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.69 -r1.1.2.70 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.69 src/doc/CHANGES-7.1.3:1.1.2.70
--- src/doc/CHANGES-7.1.3:1.1.2.69	Wed Apr 15 14:59:15 2020
+++ src/doc/CHANGES-7.1.3	Thu Apr 30 16:24:26 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.3,v 1.1.2.69 2020/04/15 14:59:15 martin Exp $
+# $NetBSD: CHANGES-7.1.3,v 1.1.2.70 2020/04/30 16:24:26 martin Exp $
 
 A complete list of changes from the NetBSD 7.1.2 release to the NetBSD 7.1.3
 release:
@@ -676,3 +676,10 @@ sys/netinet6/nd6_rtr.c1.148 (via pat
 	PR kern/55091 and PR bin/54997: fix default route selection.
 	[kim, ticket #1727]
 
+games/fortune/strfile/strfile.c			1.39
+games/fortune/unstr/unstr.c			1.15
+
+	Fix potential buffer overflows in fortune tools.
+	[nia, ticket #1729]
+
+ 



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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:24:26 UTC 2020

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

Log Message:
Ticket #1729


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



CVS commit: [netbsd-7-1] src/games/fortune

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:24:03 UTC 2020

Modified Files:
src/games/fortune/strfile [netbsd-7-1]: strfile.c
src/games/fortune/unstr [netbsd-7-1]: unstr.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1729):

games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15

strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.14.1 src/games/fortune/strfile/strfile.c
cvs rdiff -u -r1.14 -r1.14.20.1 src/games/fortune/unstr/unstr.c

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



CVS commit: [netbsd-7] src/doc

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:23:32 UTC 2020

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

Log Message:
Ticket #1729


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.80 -r1.1.2.81 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.80 src/doc/CHANGES-7.3:1.1.2.81
--- src/doc/CHANGES-7.3:1.1.2.80	Thu Apr 23 14:18:09 2020
+++ src/doc/CHANGES-7.3	Thu Apr 30 16:23:32 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.3,v 1.1.2.80 2020/04/23 14:18:09 martin Exp $
+# $NetBSD: CHANGES-7.3,v 1.1.2.81 2020/04/30 16:23:32 martin Exp $
 
 A complete list of changes from the NetBSD 7.2 release to the NetBSD 7.3
 release:
@@ -838,3 +838,9 @@ external/bsd/bind/include/config.h		(app
 	This should make DNSSEC work on such hosts as well.
 	[he, ticket #1728]
 
+games/fortune/strfile/strfile.c			1.39
+games/fortune/unstr/unstr.c			1.15
+
+	Fix potential buffer overflows in fortune tools.
+	[nia, ticket #1729]
+



CVS commit: [netbsd-7-1] src/games/fortune

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:24:03 UTC 2020

Modified Files:
src/games/fortune/strfile [netbsd-7-1]: strfile.c
src/games/fortune/unstr [netbsd-7-1]: unstr.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1729):

games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15

strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.14.1 src/games/fortune/strfile/strfile.c
cvs rdiff -u -r1.14 -r1.14.20.1 src/games/fortune/unstr/unstr.c

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

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.38 src/games/fortune/strfile/strfile.c:1.38.14.1
--- src/games/fortune/strfile/strfile.c:1.38	Thu Sep 19 00:34:00 2013
+++ src/games/fortune/strfile/strfile.c	Thu Apr 30 16:24:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $	*/
+/*	$NetBSD: strfile.c,v 1.38.14.1 2020/04/30 16:24:03 martin Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)strfile.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.38.14.1 2020/04/30 16:24:03 martin Exp $");
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -267,6 +267,7 @@ getargs(int argc, char **argv)
 	int	ch;
 	extern	int optind;
 	extern	char *optarg;
+	size_t	len;
 
 	while ((ch = getopt(argc, argv, "c:iorsx")) != -1)
 		switch(ch) {
@@ -300,14 +301,25 @@ getargs(int argc, char **argv)
 
 	if (*argv) {
 		Infile = *argv;
-		if (*++argv)
-			(void) strcpy(Outfile, *argv);
+		if (*++argv) {
+			len = strlen(*argv);
+			if (len >= sizeof(Outfile)) {
+puts("Bad output filename");
+usage();
+			}
+			(void) memcpy(Outfile, *argv, len + 1);
+		}
 	}
 	if (!Infile) {
 		puts("No input file name");
 		usage();
 	}
 	if (*Outfile == '\0') {
+		len = strlen(Infile) + sizeof(".dat");
+		if (len > sizeof(Outfile)) {
+			puts("Bad input filename");
+			usage();
+		}
 		(void) strcpy(Outfile, Infile);
 		(void) strcat(Outfile, ".dat");
 	}

Index: src/games/fortune/unstr/unstr.c
diff -u src/games/fortune/unstr/unstr.c:1.14 src/games/fortune/unstr/unstr.c:1.14.20.1
--- src/games/fortune/unstr/unstr.c:1.14	Tue Jun 19 05:46:08 2012
+++ src/games/fortune/unstr/unstr.c	Thu Apr 30 16:24:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $	*/
+/*	$NetBSD: unstr.c,v 1.14.20.1 2020/04/30 16:24:03 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)unstr.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $");
+__RCSID("$NetBSD: unstr.c,v 1.14.20.1 2020/04/30 16:24:03 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -114,7 +114,7 @@ main(int ac __unused, char **av)
 void
 getargs(char *av[])
 {
-	if (!*++av) {
+	if (!*++av || (strlen(*av) + sizeof(".dat")) > sizeof(Datafile)) {
 		(void) fprintf(stderr, "usage: unstr datafile\n");
 		exit(1);
 	}



CVS commit: [netbsd-7] src/doc

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:23:32 UTC 2020

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

Log Message:
Ticket #1729


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

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



CVS commit: [netbsd-7] src/games/fortune

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:22:59 UTC 2020

Modified Files:
src/games/fortune/strfile [netbsd-7]: strfile.c
src/games/fortune/unstr [netbsd-7]: unstr.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1729):

games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15

strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.4.1 src/games/fortune/strfile/strfile.c
cvs rdiff -u -r1.14 -r1.14.10.1 src/games/fortune/unstr/unstr.c

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



CVS commit: [netbsd-7] src/games/fortune

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:22:59 UTC 2020

Modified Files:
src/games/fortune/strfile [netbsd-7]: strfile.c
src/games/fortune/unstr [netbsd-7]: unstr.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1729):

games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15

strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.4.1 src/games/fortune/strfile/strfile.c
cvs rdiff -u -r1.14 -r1.14.10.1 src/games/fortune/unstr/unstr.c

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

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.38 src/games/fortune/strfile/strfile.c:1.38.4.1
--- src/games/fortune/strfile/strfile.c:1.38	Thu Sep 19 00:34:00 2013
+++ src/games/fortune/strfile/strfile.c	Thu Apr 30 16:22:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $	*/
+/*	$NetBSD: strfile.c,v 1.38.4.1 2020/04/30 16:22:59 martin Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)strfile.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.38.4.1 2020/04/30 16:22:59 martin Exp $");
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -267,6 +267,7 @@ getargs(int argc, char **argv)
 	int	ch;
 	extern	int optind;
 	extern	char *optarg;
+	size_t	len;
 
 	while ((ch = getopt(argc, argv, "c:iorsx")) != -1)
 		switch(ch) {
@@ -300,14 +301,25 @@ getargs(int argc, char **argv)
 
 	if (*argv) {
 		Infile = *argv;
-		if (*++argv)
-			(void) strcpy(Outfile, *argv);
+		if (*++argv) {
+			len = strlen(*argv);
+			if (len >= sizeof(Outfile)) {
+puts("Bad output filename");
+usage();
+			}
+			(void) memcpy(Outfile, *argv, len + 1);
+		}
 	}
 	if (!Infile) {
 		puts("No input file name");
 		usage();
 	}
 	if (*Outfile == '\0') {
+		len = strlen(Infile) + sizeof(".dat");
+		if (len > sizeof(Outfile)) {
+			puts("Bad input filename");
+			usage();
+		}
 		(void) strcpy(Outfile, Infile);
 		(void) strcat(Outfile, ".dat");
 	}

Index: src/games/fortune/unstr/unstr.c
diff -u src/games/fortune/unstr/unstr.c:1.14 src/games/fortune/unstr/unstr.c:1.14.10.1
--- src/games/fortune/unstr/unstr.c:1.14	Tue Jun 19 05:46:08 2012
+++ src/games/fortune/unstr/unstr.c	Thu Apr 30 16:22:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $	*/
+/*	$NetBSD: unstr.c,v 1.14.10.1 2020/04/30 16:22:59 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)unstr.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $");
+__RCSID("$NetBSD: unstr.c,v 1.14.10.1 2020/04/30 16:22:59 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -114,7 +114,7 @@ main(int ac __unused, char **av)
 void
 getargs(char *av[])
 {
-	if (!*++av) {
+	if (!*++av || (strlen(*av) + sizeof(".dat")) > sizeof(Datafile)) {
 		(void) fprintf(stderr, "usage: unstr datafile\n");
 		exit(1);
 	}



CVS commit: [netbsd-8] src/doc

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:22:10 UTC 2020

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

Log Message:
Tickets #1543 and #1544


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.6 -r1.1.2.7 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.6 src/doc/CHANGES-8.3:1.1.2.7
--- src/doc/CHANGES-8.3:1.1.2.6	Sat Apr 25 10:55:11 2020
+++ src/doc/CHANGES-8.3	Thu Apr 30 16:22:10 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.3,v 1.1.2.6 2020/04/25 10:55:11 martin Exp $
+# $NetBSD: CHANGES-8.3,v 1.1.2.7 2020/04/30 16:22:10 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -116,3 +116,14 @@ sys/arch/hppa/hppa/trap.c			1.115
 	Fix incorrect KASSERT.
 	[skrll, ticket #1542]
 
+sys/kern/subr_cprng.c1.34
+
+	Disable rngtest on output of cprng_strong.
+	[riastradh, ticket #1543]
+
+games/fortune/strfile/strfile.c			1.39
+games/fortune/unstr/unstr.c			1.15
+
+	Fix potential buffer overflows in fortune tools.
+	[nia, ticket #1544]
+



CVS commit: [netbsd-8] src/doc

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:22:10 UTC 2020

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

Log Message:
Tickets #1543 and #1544


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

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



CVS commit: [netbsd-8] src/games/fortune

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:21:14 UTC 2020

Modified Files:
src/games/fortune/strfile [netbsd-8]: strfile.c
src/games/fortune/unstr [netbsd-8]: unstr.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1544):

games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15

strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.18.1 src/games/fortune/strfile/strfile.c
cvs rdiff -u -r1.14 -r1.14.24.1 src/games/fortune/unstr/unstr.c

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



CVS commit: [netbsd-8] src/games/fortune

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:21:14 UTC 2020

Modified Files:
src/games/fortune/strfile [netbsd-8]: strfile.c
src/games/fortune/unstr [netbsd-8]: unstr.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #1544):

games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15

strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.18.1 src/games/fortune/strfile/strfile.c
cvs rdiff -u -r1.14 -r1.14.24.1 src/games/fortune/unstr/unstr.c

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

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.38 src/games/fortune/strfile/strfile.c:1.38.18.1
--- src/games/fortune/strfile/strfile.c:1.38	Thu Sep 19 00:34:00 2013
+++ src/games/fortune/strfile/strfile.c	Thu Apr 30 16:21:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $	*/
+/*	$NetBSD: strfile.c,v 1.38.18.1 2020/04/30 16:21:14 martin Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)strfile.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.38.18.1 2020/04/30 16:21:14 martin Exp $");
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -267,6 +267,7 @@ getargs(int argc, char **argv)
 	int	ch;
 	extern	int optind;
 	extern	char *optarg;
+	size_t	len;
 
 	while ((ch = getopt(argc, argv, "c:iorsx")) != -1)
 		switch(ch) {
@@ -300,14 +301,25 @@ getargs(int argc, char **argv)
 
 	if (*argv) {
 		Infile = *argv;
-		if (*++argv)
-			(void) strcpy(Outfile, *argv);
+		if (*++argv) {
+			len = strlen(*argv);
+			if (len >= sizeof(Outfile)) {
+puts("Bad output filename");
+usage();
+			}
+			(void) memcpy(Outfile, *argv, len + 1);
+		}
 	}
 	if (!Infile) {
 		puts("No input file name");
 		usage();
 	}
 	if (*Outfile == '\0') {
+		len = strlen(Infile) + sizeof(".dat");
+		if (len > sizeof(Outfile)) {
+			puts("Bad input filename");
+			usage();
+		}
 		(void) strcpy(Outfile, Infile);
 		(void) strcat(Outfile, ".dat");
 	}

Index: src/games/fortune/unstr/unstr.c
diff -u src/games/fortune/unstr/unstr.c:1.14 src/games/fortune/unstr/unstr.c:1.14.24.1
--- src/games/fortune/unstr/unstr.c:1.14	Tue Jun 19 05:46:08 2012
+++ src/games/fortune/unstr/unstr.c	Thu Apr 30 16:21:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $	*/
+/*	$NetBSD: unstr.c,v 1.14.24.1 2020/04/30 16:21:14 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)unstr.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $");
+__RCSID("$NetBSD: unstr.c,v 1.14.24.1 2020/04/30 16:21:14 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -114,7 +114,7 @@ main(int ac __unused, char **av)
 void
 getargs(char *av[])
 {
-	if (!*++av) {
+	if (!*++av || (strlen(*av) + sizeof(".dat")) > sizeof(Datafile)) {
 		(void) fprintf(stderr, "usage: unstr datafile\n");
 		exit(1);
 	}



CVS commit: [netbsd-9] src/doc

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:20:21 UTC 2020

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

Log Message:
Tickets #874 - #879


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.47 -r1.1.2.48 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.47 src/doc/CHANGES-9.1:1.1.2.48
--- src/doc/CHANGES-9.1:1.1.2.47	Wed Apr 29 13:56:12 2020
+++ src/doc/CHANGES-9.1	Thu Apr 30 16:20:21 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.47 2020/04/29 13:56:12 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.48 2020/04/30 16:20:21 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -2360,3 +2360,31 @@ sys/dev/usb/usbdevs_data.h			(regen)
 	usbdevs: more Intel Integrated Rate Matching Hub IDs.
 	[nia, ticket #873]
 
+sys/kern/subr_cprng.c1.34
+
+	Disable rngtest on output of cprng_strong.
+	[riastradh, ticket #874]
+
+share/man/man4/audio.41.102,1.103
+sys/dev/audio/audio.c1.43,1.59
+
+	Fix playing multi channel audio files on non multi channel hardware.
+	[isaki, ticket #875]
+
+sys/dev/audio/audio.c1.60,1.62
+
+	Restore backward compatibility with netbsd-7 audio.
+	[isaki, ticket #876]
+
+sys/dev/audio/audio.c1.41,1.48,1.55,1.63 (patch),
+		1.64
+sys/dev/audio/audiovar.h			1.7, 1.11
+
+	auido(4): fix several potential problems.
+	[isaki, ticket #877]
+
+crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c 1.16
+
+	Fix the detection of KERN_ARND by OpenSSL.
+	[nia, ticket #878]
+



CVS commit: [netbsd-9] src/doc

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:20:21 UTC 2020

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

Log Message:
Tickets #874 - #879


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

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



CVS commit: [netbsd-9] src/games/fortune

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:19:29 UTC 2020

Modified Files:
src/games/fortune/strfile [netbsd-9]: strfile.c
src/games/fortune/unstr [netbsd-9]: unstr.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #879):

games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15

strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.28.1 src/games/fortune/strfile/strfile.c
cvs rdiff -u -r1.14 -r1.14.34.1 src/games/fortune/unstr/unstr.c

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



CVS commit: [netbsd-9] src/games/fortune

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:19:29 UTC 2020

Modified Files:
src/games/fortune/strfile [netbsd-9]: strfile.c
src/games/fortune/unstr [netbsd-9]: unstr.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #879):

games/fortune/strfile/strfile.c: revision 1.39
games/fortune/unstr/unstr.c: revision 1.15

strfile: Check that input/output filenames don't exceed the buffer size
unstr: Check that the input filename fits in the buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.28.1 src/games/fortune/strfile/strfile.c
cvs rdiff -u -r1.14 -r1.14.34.1 src/games/fortune/unstr/unstr.c

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

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.38 src/games/fortune/strfile/strfile.c:1.38.28.1
--- src/games/fortune/strfile/strfile.c:1.38	Thu Sep 19 00:34:00 2013
+++ src/games/fortune/strfile/strfile.c	Thu Apr 30 16:19:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $	*/
+/*	$NetBSD: strfile.c,v 1.38.28.1 2020/04/30 16:19:29 martin Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)strfile.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.38.28.1 2020/04/30 16:19:29 martin Exp $");
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -267,6 +267,7 @@ getargs(int argc, char **argv)
 	int	ch;
 	extern	int optind;
 	extern	char *optarg;
+	size_t	len;
 
 	while ((ch = getopt(argc, argv, "c:iorsx")) != -1)
 		switch(ch) {
@@ -300,14 +301,25 @@ getargs(int argc, char **argv)
 
 	if (*argv) {
 		Infile = *argv;
-		if (*++argv)
-			(void) strcpy(Outfile, *argv);
+		if (*++argv) {
+			len = strlen(*argv);
+			if (len >= sizeof(Outfile)) {
+puts("Bad output filename");
+usage();
+			}
+			(void) memcpy(Outfile, *argv, len + 1);
+		}
 	}
 	if (!Infile) {
 		puts("No input file name");
 		usage();
 	}
 	if (*Outfile == '\0') {
+		len = strlen(Infile) + sizeof(".dat");
+		if (len > sizeof(Outfile)) {
+			puts("Bad input filename");
+			usage();
+		}
 		(void) strcpy(Outfile, Infile);
 		(void) strcat(Outfile, ".dat");
 	}

Index: src/games/fortune/unstr/unstr.c
diff -u src/games/fortune/unstr/unstr.c:1.14 src/games/fortune/unstr/unstr.c:1.14.34.1
--- src/games/fortune/unstr/unstr.c:1.14	Tue Jun 19 05:46:08 2012
+++ src/games/fortune/unstr/unstr.c	Thu Apr 30 16:19:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $	*/
+/*	$NetBSD: unstr.c,v 1.14.34.1 2020/04/30 16:19:29 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)unstr.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: unstr.c,v 1.14 2012/06/19 05:46:08 dholland Exp $");
+__RCSID("$NetBSD: unstr.c,v 1.14.34.1 2020/04/30 16:19:29 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -114,7 +114,7 @@ main(int ac __unused, char **av)
 void
 getargs(char *av[])
 {
-	if (!*++av) {
+	if (!*++av || (strlen(*av) + sizeof(".dat")) > sizeof(Datafile)) {
 		(void) fprintf(stderr, "usage: unstr datafile\n");
 		exit(1);
 	}



CVS commit: [netbsd-9] src/crypto/external/bsd/openssl/dist/crypto/rand

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:17:04 UTC 2020

Modified Files:
src/crypto/external/bsd/openssl/dist/crypto/rand [netbsd-9]:
rand_unix.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #878):

crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c: revision 1.16

Fix the detection of KERN_ARND by OpenSSL.

Firstly, include the correct headers. Then, make sure that requests
never exceed 256 bytes.

Disable a hack for old FreeBSD versions, just in case it actually gets
used.

This should mean that OpenSSL doesn't ever fall back to reading from
/dev/urandom.

XXX pullup, XXX upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.12.2.3 -r1.12.2.4 \
src/crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c

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

Modified files:

Index: src/crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c
diff -u src/crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c:1.12.2.3 src/crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c:1.12.2.4
--- src/crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c:1.12.2.3	Mon Apr 27 14:47:26 2020
+++ src/crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c	Thu Apr 30 16:17:04 2020
@@ -26,12 +26,12 @@
 #  include 
 # endif
 #endif
-#if defined(__FreeBSD__) && !defined(OPENSSL_SYS_UEFI)
+#if (defined(__FreeBSD__) || defined(__NetBSD__)) && !defined(OPENSSL_SYS_UEFI)
 # include 
 # include 
 # include 
 #endif
-#if defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__OpenBSD__)
 # include 
 #endif
 
@@ -247,10 +247,12 @@ static ssize_t sysctl_random(char *buf, 
  * when the sysctl returns long and we want to request something not a
  * multiple of longs, which should never be the case.
  */
+#if   defined(__FreeBSD__)
 if (!ossl_assert(buflen % sizeof(long) == 0)) {
 errno = EINVAL;
 return -1;
 }
+#endif
 
 /*
  * On NetBSD before 4.0 KERN_ARND was an alias for KERN_URND, and only
@@ -268,7 +270,8 @@ static ssize_t sysctl_random(char *buf, 
 mib[1] = KERN_ARND;
 
 do {
-len = buflen;
+/* On NetBSD, KERN_ARND fails if more than 256 bytes are requested */
+len = buflen > 256 ? 256 : buflen;
 if (sysctl(mib, 2, buf, , NULL, 0) == -1)
 return done > 0 ? done : -1;
 done += len;



CVS commit: [netbsd-9] src/crypto/external/bsd/openssl/dist/crypto/rand

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:17:04 UTC 2020

Modified Files:
src/crypto/external/bsd/openssl/dist/crypto/rand [netbsd-9]:
rand_unix.c

Log Message:
Pull up following revision(s) (requested by nia in ticket #878):

crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c: revision 1.16

Fix the detection of KERN_ARND by OpenSSL.

Firstly, include the correct headers. Then, make sure that requests
never exceed 256 bytes.

Disable a hack for old FreeBSD versions, just in case it actually gets
used.

This should mean that OpenSSL doesn't ever fall back to reading from
/dev/urandom.

XXX pullup, XXX upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.12.2.3 -r1.12.2.4 \
src/crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c

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



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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:05:18 UTC 2020

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c audiovar.h

Log Message:
Pull up following revision(s) (requested by isaki in ticket #877):

sys/dev/audio/audio.c: revision 1.55
sys/dev/audio/audio.c: revision 1.41
sys/dev/audio/audio.c: revision 1.48
sys/dev/audio/audiovar.h: revision 1.7
sys/dev/audio/audio.c: revision 1.63 (via patch)
sys/dev/audio/audiovar.h: revision 1.11
sys/dev/audio/audio.c: revision 1.64

Simplify async_mixer handling.
- It makes FIOASYNC code in mixer_ioctl() symmetric.
- For readability, mixer_async_{add,remove}() should take pid argument
  though pid is always curproc.

hw_if->query_format is already mandatory method.  Drop null checks.

Improve error handling around audio_hw_probe().
It was difficult to return multiple errors.

Split sc_lock and sc_exlock.

Most (probably all) malloc/free (or routines which may sleep) now can be
called without holding mutex.
Pointed out by riastradh@.

Fix/Update comments about allocm/freem.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.11 -r1.28.2.12 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/dev/audio/audiovar.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.11 src/sys/dev/audio/audio.c:1.28.2.12
--- src/sys/dev/audio/audio.c:1.28.2.11	Thu Apr 30 15:43:30 2020
+++ src/sys/dev/audio/audio.c	Thu Apr 30 16:05:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.11 2020/04/30 15:43:30 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.12 2020/04/30 16:05:18 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -118,8 +118,8 @@
  *	set_port 		-	x +
  *	get_port 		-	x +
  *	query_devinfo 		-	x
- *	allocm 			-	- +	(*1)
- *	freem 			-	- +	(*1)
+ *	allocm 			-	- +
+ *	freem 			-	- +
  *	round_buffersize 	-	x
  *	get_props 		-	x	Called at attach time
  *	trigger_output 		x	x +
@@ -127,10 +127,6 @@
  *	dev_ioctl 		-	x
  *	get_locks 		-	-	Called at attach time
  *
- * *1 Note: Before 8.0, since these have been called only at attach time,
- *   neither lock were necessary.  Currently, on the other hand, since
- *   these may be also called after attach, the thread lock is required.
- *
  * In addition, there is an additional lock.
  *
  * - track->lock.  This is an atomic variable and is similar to the
@@ -142,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.11 2020/04/30 15:43:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.12 2020/04/30 16:05:18 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -466,6 +462,9 @@ audio_track_bufstat(audio_track_t *track
 int audio_idle_timeout = 30;
 #endif
 
+/* Number of elements of async mixer's pid */
+#define AM_CAPACITY	(4)
+
 struct portname {
 	const char *name;
 	int mask;
@@ -497,8 +496,10 @@ static void audio_mixer_restore(struct a
 static void audio_softintr_rd(void *);
 static void audio_softintr_wr(void *);
 
-static int  audio_enter_exclusive(struct audio_softc *);
-static void audio_exit_exclusive(struct audio_softc *);
+static int audio_exlock_mutex_enter(struct audio_softc *);
+static void audio_exlock_mutex_exit(struct audio_softc *);
+static int audio_exlock_enter(struct audio_softc *);
+static void audio_exlock_exit(struct audio_softc *);
 static struct audio_softc *audio_file_enter(audio_file_t *, struct psref *);
 static void audio_file_exit(struct audio_softc *, struct psref *);
 static int audio_track_waitio(struct audio_softc *, audio_track_t *);
@@ -560,9 +561,7 @@ static int audio_mixers_init(struct audi
 	const audio_format2_t *, const audio_format2_t *,
 	const audio_filter_reg_t *, const audio_filter_reg_t *);
 static int audio_select_freq(const struct audio_format *);
-static int audio_hw_probe(struct audio_softc *, int, int *,
-	audio_format2_t *, audio_format2_t *);
-static int audio_hw_probe_fmt(struct audio_softc *, audio_format2_t *, int);
+static int audio_hw_probe(struct audio_softc *, audio_format2_t *, int);
 static int audio_hw_validate_format(struct audio_softc *, int,
 	const audio_format2_t *);
 static int audio_mixers_set_format(struct audio_softc *,
@@ -609,7 +608,8 @@ static void mixer_init(struct audio_soft
 static int mixer_open(dev_t, struct audio_softc *, int, int, struct lwp *);
 static int mixer_close(struct audio_softc *, audio_file_t *);
 static int mixer_ioctl(struct audio_softc *, u_long, void *, int, struct lwp *);
-static void mixer_remove(struct audio_softc *);
+static void mixer_async_add(struct audio_softc *, pid_t);
+static void mixer_async_remove(struct audio_softc *, pid_t);
 static void mixer_signal(struct audio_softc *);
 
 static int au_portof(struct audio_softc *, char *, int);
@@ -882,9 +882,13 @@ audioattach(device_t parent, 

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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 16:05:18 UTC 2020

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c audiovar.h

Log Message:
Pull up following revision(s) (requested by isaki in ticket #877):

sys/dev/audio/audio.c: revision 1.55
sys/dev/audio/audio.c: revision 1.41
sys/dev/audio/audio.c: revision 1.48
sys/dev/audio/audiovar.h: revision 1.7
sys/dev/audio/audio.c: revision 1.63 (via patch)
sys/dev/audio/audiovar.h: revision 1.11
sys/dev/audio/audio.c: revision 1.64

Simplify async_mixer handling.
- It makes FIOASYNC code in mixer_ioctl() symmetric.
- For readability, mixer_async_{add,remove}() should take pid argument
  though pid is always curproc.

hw_if->query_format is already mandatory method.  Drop null checks.

Improve error handling around audio_hw_probe().
It was difficult to return multiple errors.

Split sc_lock and sc_exlock.

Most (probably all) malloc/free (or routines which may sleep) now can be
called without holding mutex.
Pointed out by riastradh@.

Fix/Update comments about allocm/freem.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.11 -r1.28.2.12 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/dev/audio/audiovar.h

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



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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:43:30 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by isaki in ticket #876):

sys/dev/audio/audio.c: revision 1.60
sys/dev/audio/audio.c: revision 1.62

Fix wrong parameter displayed in debug messages.

Restore backward compatibility with netbsd-7 audio.

For sticky parameters (encoding, precision, channels, sample_rate and pause):
 - AUDIO_SETINFO for nonexistent track updates sticky parameters.
 - AUDIO_GETINFO for nonexistent track reads sticky parameters.

For blocksize, hiwat, lowat and {play.record}.buffer_size:
 - AUDIO_SETINFO for nonexistent track does nothing.
 - AUDIO_GETINFO for nonexistent track returns dummy non-zero values.

Nonexistent track is a playback track on O_RDONLY descriptor for example,
or both tracks on /dev/audioctl.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.10 -r1.28.2.11 src/sys/dev/audio/audio.c

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



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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:43:30 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by isaki in ticket #876):

sys/dev/audio/audio.c: revision 1.60
sys/dev/audio/audio.c: revision 1.62

Fix wrong parameter displayed in debug messages.

Restore backward compatibility with netbsd-7 audio.

For sticky parameters (encoding, precision, channels, sample_rate and pause):
 - AUDIO_SETINFO for nonexistent track updates sticky parameters.
 - AUDIO_GETINFO for nonexistent track reads sticky parameters.

For blocksize, hiwat, lowat and {play.record}.buffer_size:
 - AUDIO_SETINFO for nonexistent track does nothing.
 - AUDIO_GETINFO for nonexistent track returns dummy non-zero values.

Nonexistent track is a playback track on O_RDONLY descriptor for example,
or both tracks on /dev/audioctl.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.10 -r1.28.2.11 src/sys/dev/audio/audio.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.10 src/sys/dev/audio/audio.c:1.28.2.11
--- src/sys/dev/audio/audio.c:1.28.2.10	Thu Apr 30 15:40:50 2020
+++ src/sys/dev/audio/audio.c	Thu Apr 30 15:43:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.10 2020/04/30 15:40:50 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.11 2020/04/30 15:43:30 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.10 2020/04/30 15:40:50 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.11 2020/04/30 15:43:30 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -542,8 +542,8 @@ static int audio_query_devinfo(struct au
 static __inline int audio_track_readablebytes(const audio_track_t *);
 static int audio_file_setinfo(struct audio_softc *, audio_file_t *,
 	const struct audio_info *);
-static int audio_track_setinfo_check(audio_format2_t *,
-	const struct audio_prinfo *, const audio_format2_t *);
+static int audio_track_setinfo_check(audio_track_t *,
+	audio_format2_t *, const struct audio_prinfo *);
 static void audio_track_setinfo_water(audio_track_t *,
 	const struct audio_info *);
 static int audio_hw_setinfo(struct audio_softc *, const struct audio_info *,
@@ -6779,20 +6779,30 @@ audio_file_setinfo(struct audio_softc *s
 	memset(_pfmt, 0, sizeof(saved_pfmt));
 	memset(_rfmt, 0, sizeof(saved_rfmt));
 
-	/* Set default value and save current parameters */
+	/*
+	 * Set default value and save current parameters.
+	 * For backward compatibility, use sticky parameters for nonexistent
+	 * track.
+	 */
 	if (ptrack) {
 		pfmt = ptrack->usrbuf.fmt;
 		saved_pfmt = ptrack->usrbuf.fmt;
 		saved_ai.play.pause = ptrack->is_pause;
+	} else {
+		pfmt = sc->sc_sound_pparams;
 	}
 	if (rtrack) {
 		rfmt = rtrack->usrbuf.fmt;
 		saved_rfmt = rtrack->usrbuf.fmt;
 		saved_ai.record.pause = rtrack->is_pause;
+	} else {
+		rfmt = sc->sc_sound_rparams;
 	}
 	saved_ai.mode = file->mode;
 
-	/* Overwrite if specified */
+	/*
+	 * Overwrite if specified.
+	 */
 	mode = file->mode;
 	if (SPECIFIED(ai->mode)) {
 		/*
@@ -6811,35 +6821,35 @@ audio_file_setinfo(struct audio_softc *s
 		}
 	}
 
-	if (ptrack) {
-		pchanges = audio_track_setinfo_check(, pi,
-		>sc_pmixer->hwbuf.fmt);
-		if (pchanges == -1) {
+	pchanges = audio_track_setinfo_check(ptrack, , pi);
+	if (pchanges == -1) {
 #if defined(AUDIO_DEBUG)
-			char fmtbuf[64];
-			audio_format2_tostr(fmtbuf, sizeof(fmtbuf), );
-			TRACET(1, ptrack, "check play.params failed: %s",
-			fmtbuf);
+		TRACEF(1, file, "check play.params failed: "
+		"%s %ubit %uch %uHz",
+		audio_encoding_name(pi->encoding),
+		pi->precision,
+		pi->channels,
+		pi->sample_rate);
 #endif
-			return EINVAL;
-		}
-		if (SPECIFIED(ai->mode))
-			pchanges = 1;
+		return EINVAL;
 	}
-	if (rtrack) {
-		rchanges = audio_track_setinfo_check(, ri,
-		>sc_rmixer->hwbuf.fmt);
-		if (rchanges == -1) {
+
+	rchanges = audio_track_setinfo_check(rtrack, , ri);
+	if (rchanges == -1) {
 #if defined(AUDIO_DEBUG)
-			char fmtbuf[64];
-			audio_format2_tostr(fmtbuf, sizeof(fmtbuf), );
-			TRACET(1, rtrack, "check record.params failed: %s",
-			fmtbuf);
+		TRACEF(1, file, "check record.params failed: "
+		"%s %ubit %uch %uHz",
+		audio_encoding_name(ri->encoding),
+		ri->precision,
+		ri->channels,
+		ri->sample_rate);
 #endif
-			return EINVAL;
-		}
-		if (SPECIFIED(ai->mode))
-			rchanges = 1;
+		return EINVAL;
+	}
+
+	if (SPECIFIED(ai->mode)) {
+		pchanges = 1;
+		rchanges = 1;
 	}
 
 	/*
@@ -6849,16 +6859,27 @@ audio_file_setinfo(struct audio_softc *s
 	if (pchanges || rchanges) {
 		audio_file_clear(sc, file);
 #if defined(AUDIO_DEBUG)
+		char nbuf[16];
 		char fmtbuf[64];
 		if (pchanges) {
+			if 

CVS commit: [netbsd-9] src

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:40:50 UTC 2020

Modified Files:
src/share/man/man4 [netbsd-9]: audio.4
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #875):

sys/dev/audio/audio.c: revision 1.59
share/man/man4/audio.4: revision 1.102
share/man/man4/audio.4: revision 1.103
sys/dev/audio/audio.c: revision 1.43

Limit the number of channels that userland apps can set (by AUDIO_SETINFO)
to the number of channels supported by the hardware or less, if the hardware
supports multi channels.
- On monaural or stereo hardware, userland apps can always set 1ch or 2ch.
  The kernel (audio layer) can convert mono-stereo each other.
- On 3ch (2.1ch) hardware, for example, userland apps can set 1, 2, or 3ch,
  but not 4ch or more.

This allows userland apps to know actual number of channels supported by
the hardware in the same way as before.

PR kern/54973.

Reinitialize the sticky parameters whenever the hardware format is changed.

When the number of the hardware channels becomes less than the number of
channels that sticky parameters remember, subsequent open("/dev/sound") will
fail without this treatment.  This is for rev 1.43.

Add description about channel limitation introduced in audio.c 1.43.
PR kern/54973.

Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.90.2.1 src/share/man/man4/audio.4
cvs rdiff -u -r1.28.2.9 -r1.28.2.10 src/sys/dev/audio/audio.c

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/audio.4
diff -u src/share/man/man4/audio.4:1.90 src/share/man/man4/audio.4:1.90.2.1
--- src/share/man/man4/audio.4:1.90	Thu May  9 09:35:29 2019
+++ src/share/man/man4/audio.4	Thu Apr 30 15:40:50 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audio.4,v 1.90 2019/05/09 09:35:29 wiz Exp $
+.\"	$NetBSD: audio.4,v 1.90.2.1 2020/04/30 15:40:50 martin Exp $
 .\"
 .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -402,18 +402,25 @@ unsigned linear encoding with big endian
 Dolby Digital AC3
 .El
 .Pp
-Regardless of formats supported by underlying driver, the
+The
 .Nm
 driver accepts the following formats.
 .Va encoding
 and
 .Va precision
 are one of the values obtained by
-.Dv AUDIO_GETENC .
-.Va channels
-ranges from 1 to 12.
+.Dv AUDIO_GETENC ,
+regardless of formats supported by underlying driver.
 .Va frequency
-ranges from 1000Hz to 192000Hz.
+ranges from 1000Hz to 192000Hz,
+regardless of frequency (ranges) supported by underlying driver.
+.Va channels
+depends your underlying driver.
+If the underlying driver only supports monaural (1channel)
+or stereo (2channels), you can specify 1 or 2 regardless of
+number of channels supported by underlying driver.
+If the underlying driver supports three or more channels, you can specify
+the number of channels supported by the underlying driver or less.
 .Pp
 The
 .Va gain ,

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.9 src/sys/dev/audio/audio.c:1.28.2.10
--- src/sys/dev/audio/audio.c:1.28.2.9	Sat Mar 21 15:47:00 2020
+++ src/sys/dev/audio/audio.c	Thu Apr 30 15:40:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.9 2020/03/21 15:47:00 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.10 2020/04/30 15:40:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.9 2020/03/21 15:47:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.10 2020/04/30 15:40:50 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -543,7 +543,7 @@ static __inline int audio_track_readable
 static int audio_file_setinfo(struct audio_softc *, audio_file_t *,
 	const struct audio_info *);
 static int audio_track_setinfo_check(audio_format2_t *,
-	const struct audio_prinfo *);
+	const struct audio_prinfo *, const audio_format2_t *);
 static void audio_track_setinfo_water(audio_track_t *,
 	const struct audio_info *);
 static int audio_hw_setinfo(struct audio_softc *, const struct audio_info *,
@@ -6546,6 +6546,18 @@ audio_mixers_set_format(struct audio_sof
 	if (error)
 		return error;
 
+	/*
+	 * Reinitialize the sticky parameters for /dev/sound.
+	 * If the number of the hardware channels becomes less than the number
+	 * of channels that sticky parameters remember, subsequent /dev/sound
+	 * open will fail.  To prevent this, reinitialize the sticky
+	 * parameters whenever the hardware format is changed.
+	 */
+	sc->sc_sound_pparams = params_to_format2(_default);
+	sc->sc_sound_rparams = params_to_format2(_default);
+	sc->sc_sound_ppause = false;
+	sc->sc_sound_rpause = false;
+
 	return 0;
 }
 
@@ -6800,7 +6812,8 @@ audio_file_setinfo(struct audio_softc *s
 	}
 
 	if (ptrack) {
-		pchanges = audio_track_setinfo_check(, pi);
+		pchanges = 

CVS commit: [netbsd-9] src

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:40:50 UTC 2020

Modified Files:
src/share/man/man4 [netbsd-9]: audio.4
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #875):

sys/dev/audio/audio.c: revision 1.59
share/man/man4/audio.4: revision 1.102
share/man/man4/audio.4: revision 1.103
sys/dev/audio/audio.c: revision 1.43

Limit the number of channels that userland apps can set (by AUDIO_SETINFO)
to the number of channels supported by the hardware or less, if the hardware
supports multi channels.
- On monaural or stereo hardware, userland apps can always set 1ch or 2ch.
  The kernel (audio layer) can convert mono-stereo each other.
- On 3ch (2.1ch) hardware, for example, userland apps can set 1, 2, or 3ch,
  but not 4ch or more.

This allows userland apps to know actual number of channels supported by
the hardware in the same way as before.

PR kern/54973.

Reinitialize the sticky parameters whenever the hardware format is changed.

When the number of the hardware channels becomes less than the number of
channels that sticky parameters remember, subsequent open("/dev/sound") will
fail without this treatment.  This is for rev 1.43.

Add description about channel limitation introduced in audio.c 1.43.
PR kern/54973.

Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.90.2.1 src/share/man/man4/audio.4
cvs rdiff -u -r1.28.2.9 -r1.28.2.10 src/sys/dev/audio/audio.c

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



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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:35:57 UTC 2020

Modified Files:
src/sys/kern [netbsd-8]: subr_cprng.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1543):

sys/kern/subr_cprng.c: revision 1.34

Disable rngtest on output of cprng_strong.

We already do a self-test for correctenss of Hash_DRBG output;
applying rngtest to it does nothing but give everyone warning fatigue
about spurious rngtest failures.


To generate a diff of this commit:
cvs rdiff -u -r1.27.10.2 -r1.27.10.3 src/sys/kern/subr_cprng.c

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



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

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:35:57 UTC 2020

Modified Files:
src/sys/kern [netbsd-8]: subr_cprng.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1543):

sys/kern/subr_cprng.c: revision 1.34

Disable rngtest on output of cprng_strong.

We already do a self-test for correctenss of Hash_DRBG output;
applying rngtest to it does nothing but give everyone warning fatigue
about spurious rngtest failures.


To generate a diff of this commit:
cvs rdiff -u -r1.27.10.2 -r1.27.10.3 src/sys/kern/subr_cprng.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/subr_cprng.c
diff -u src/sys/kern/subr_cprng.c:1.27.10.2 src/sys/kern/subr_cprng.c:1.27.10.3
--- src/sys/kern/subr_cprng.c:1.27.10.2	Mon Nov 25 16:03:08 2019
+++ src/sys/kern/subr_cprng.c	Thu Apr 30 15:35:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cprng.c,v 1.27.10.2 2019/11/25 16:03:08 martin Exp $ */
+/*	$NetBSD: subr_cprng.c,v 1.27.10.3 2020/04/30 15:35:57 martin Exp $ */
 
 /*-
  * Copyright (c) 2011-2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.27.10.2 2019/11/25 16:03:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.27.10.3 2020/04/30 15:35:57 martin Exp $");
 
 #include 
 #include 
@@ -49,9 +49,6 @@ __KERNEL_RCSID(0, "$NetBSD: subr_cprng.c
 #include 
 #include 
 #include 
-#if DIAGNOSTIC
-#include 
-#endif
 
 #include 
 
@@ -66,9 +63,6 @@ static void	cprng_strong_generate(struct
 static void	cprng_strong_reseed(struct cprng_strong *);
 static void	cprng_strong_reseed_from(struct cprng_strong *, const void *,
 		size_t, bool);
-#if DIAGNOSTIC
-static void	cprng_strong_rngtest(struct cprng_strong *);
-#endif
 
 static rndsink_callback_t	cprng_strong_rndsink_callback;
 
@@ -450,48 +444,8 @@ cprng_strong_reseed_from(struct cprng_st
 		/* XXX Fix nist_hash_drbg API so this can't happen.  */
 		panic("cprng %s: NIST Hash_DRBG reseed failed",
 		cprng->cs_name);
-
-#if DIAGNOSTIC
-	cprng_strong_rngtest(cprng);
-#endif
 }
 
-#if DIAGNOSTIC
-/*
- * Generate some output and apply a statistical RNG test to it.
- */
-static void
-cprng_strong_rngtest(struct cprng_strong *cprng)
-{
-
-	KASSERT(mutex_owned(>cs_lock));
-
-	/* XXX Switch to a pool cache instead?  */
-	rngtest_t *const rt = kmem_intr_alloc(sizeof(*rt), KM_NOSLEEP);
-	if (rt == NULL)
-		/* XXX Warn?  */
-		return;
-
-	(void)strlcpy(rt->rt_name, cprng->cs_name, sizeof(rt->rt_name));
-
-	if (nist_hash_drbg_generate(>cs_drbg, rt->rt_b,
-		sizeof(rt->rt_b), NULL, 0))
-		panic("cprng %s: NIST Hash_DRBG failed after reseed",
-		cprng->cs_name);
-
-	if (rngtest(rt)) {
-		printf("cprng %s: failed statistical RNG test\n",
-		cprng->cs_name);
-		/* XXX Not clear that this does any good...  */
-		cprng->cs_ready = false;
-		rndsink_schedule(cprng->cs_rndsink);
-	}
-
-	explicit_memset(rt, 0, sizeof(*rt)); /* paranoia */
-	kmem_intr_free(rt, sizeof(*rt));
-}
-#endif
-
 /*
  * Feed entropy from an rndsink request into the CPRNG for which the
  * request was issued.



CVS commit: [netbsd-9] src/sys/kern

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:34:06 UTC 2020

Modified Files:
src/sys/kern [netbsd-9]: subr_cprng.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #874):

sys/kern/subr_cprng.c: revision 1.34

Disable rngtest on output of cprng_strong.

We already do a self-test for correctenss of Hash_DRBG output;
applying rngtest to it does nothing but give everyone warning fatigue
about spurious rngtest failures.


To generate a diff of this commit:
cvs rdiff -u -r1.30.2.2 -r1.30.2.3 src/sys/kern/subr_cprng.c

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



CVS commit: [netbsd-9] src/sys/kern

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:34:06 UTC 2020

Modified Files:
src/sys/kern [netbsd-9]: subr_cprng.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #874):

sys/kern/subr_cprng.c: revision 1.34

Disable rngtest on output of cprng_strong.

We already do a self-test for correctenss of Hash_DRBG output;
applying rngtest to it does nothing but give everyone warning fatigue
about spurious rngtest failures.


To generate a diff of this commit:
cvs rdiff -u -r1.30.2.2 -r1.30.2.3 src/sys/kern/subr_cprng.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/subr_cprng.c
diff -u src/sys/kern/subr_cprng.c:1.30.2.2 src/sys/kern/subr_cprng.c:1.30.2.3
--- src/sys/kern/subr_cprng.c:1.30.2.2	Mon Nov 25 17:00:22 2019
+++ src/sys/kern/subr_cprng.c	Thu Apr 30 15:34:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cprng.c,v 1.30.2.2 2019/11/25 17:00:22 martin Exp $ */
+/*	$NetBSD: subr_cprng.c,v 1.30.2.3 2020/04/30 15:34:06 martin Exp $ */
 
 /*-
  * Copyright (c) 2011-2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.30.2.2 2019/11/25 17:00:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.30.2.3 2020/04/30 15:34:06 martin Exp $");
 
 #include 
 #include 
@@ -49,9 +49,6 @@ __KERNEL_RCSID(0, "$NetBSD: subr_cprng.c
 #include 
 #include 
 #include 
-#if DIAGNOSTIC
-#include 
-#endif
 
 #include 
 
@@ -66,9 +63,6 @@ static void	cprng_strong_generate(struct
 static void	cprng_strong_reseed(struct cprng_strong *);
 static void	cprng_strong_reseed_from(struct cprng_strong *, const void *,
 		size_t, bool);
-#if DIAGNOSTIC
-static void	cprng_strong_rngtest(struct cprng_strong *);
-#endif
 
 static rndsink_callback_t	cprng_strong_rndsink_callback;
 
@@ -482,48 +476,8 @@ cprng_strong_reseed_from(struct cprng_st
 		/* XXX Fix nist_hash_drbg API so this can't happen.  */
 		panic("cprng %s: NIST Hash_DRBG reseed failed",
 		cprng->cs_name);
-
-#if DIAGNOSTIC
-	cprng_strong_rngtest(cprng);
-#endif
 }
 
-#if DIAGNOSTIC
-/*
- * Generate some output and apply a statistical RNG test to it.
- */
-static void
-cprng_strong_rngtest(struct cprng_strong *cprng)
-{
-
-	KASSERT(mutex_owned(>cs_lock));
-
-	/* XXX Switch to a pool cache instead?  */
-	rngtest_t *const rt = kmem_intr_alloc(sizeof(*rt), KM_NOSLEEP);
-	if (rt == NULL)
-		/* XXX Warn?  */
-		return;
-
-	(void)strlcpy(rt->rt_name, cprng->cs_name, sizeof(rt->rt_name));
-
-	if (nist_hash_drbg_generate(>cs_drbg, rt->rt_b,
-		sizeof(rt->rt_b), NULL, 0))
-		panic("cprng %s: NIST Hash_DRBG failed after reseed",
-		cprng->cs_name);
-
-	if (rngtest(rt)) {
-		printf("cprng %s: failed statistical RNG test\n",
-		cprng->cs_name);
-		/* XXX Not clear that this does any good...  */
-		cprng->cs_ready = false;
-		rndsink_schedule(cprng->cs_rndsink);
-	}
-
-	explicit_memset(rt, 0, sizeof(*rt)); /* paranoia */
-	kmem_intr_free(rt, sizeof(*rt));
-}
-#endif
-
 /*
  * Feed entropy from an rndsink request into the CPRNG for which the
  * request was issued.



CVS commit: src/usr.bin/kdump

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:12:25 UTC 2020

Modified Files:
src/usr.bin/kdump: kdump.c

Log Message:
futexput: cast the mask to u_long (as the op already is)


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/usr.bin/kdump/kdump.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/kdump/kdump.c
diff -u src/usr.bin/kdump/kdump.c:1.138 src/usr.bin/kdump/kdump.c:1.139
--- src/usr.bin/kdump/kdump.c:1.138	Thu Apr 30 12:17:01 2020
+++ src/usr.bin/kdump/kdump.c	Thu Apr 30 15:12:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kdump.c,v 1.138 2020/04/30 12:17:01 thorpej Exp $	*/
+/*	$NetBSD: kdump.c,v 1.139 2020/04/30 15:12:25 martin Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)kdump.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: kdump.c,v 1.138 2020/04/30 12:17:01 thorpej Exp $");
+__RCSID("$NetBSD: kdump.c,v 1.139 2020/04/30 15:12:25 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -661,7 +661,7 @@ futexput(u_long op)
 	const char *s = "";
 
 	if (opname == NULL) {
-		printf("%#lx", op & FUTEX_CMD_MASK);
+		printf("%#lx", op & (u_long)FUTEX_CMD_MASK);
 	} else {
 		fputs(opname, stdout);
 	}



CVS commit: src/usr.bin/kdump

2020-04-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 30 15:12:25 UTC 2020

Modified Files:
src/usr.bin/kdump: kdump.c

Log Message:
futexput: cast the mask to u_long (as the op already is)


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/usr.bin/kdump/kdump.c

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



CVS commit: src/sys/sys

2020-04-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Apr 30 14:32:05 UTC 2020

Modified Files:
src/sys/sys: cdefs_elf.h

Log Message:
GNU as on ARM silently accepts @progbits, but interpretes it as comment
internally. LLVM bails out on the other hand. So conditionally this
properly.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/sys/cdefs_elf.h

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



CVS commit: src/sys/sys

2020-04-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Apr 30 14:32:05 UTC 2020

Modified Files:
src/sys/sys: cdefs_elf.h

Log Message:
GNU as on ARM silently accepts @progbits, but interpretes it as comment
internally. LLVM bails out on the other hand. So conditionally this
properly.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/sys/cdefs_elf.h

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

Modified files:

Index: src/sys/sys/cdefs_elf.h
diff -u src/sys/sys/cdefs_elf.h:1.56 src/sys/sys/cdefs_elf.h:1.57
--- src/sys/sys/cdefs_elf.h:1.56	Fri Apr 17 14:19:44 2020
+++ src/sys/sys/cdefs_elf.h	Thu Apr 30 14:32:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cdefs_elf.h,v 1.56 2020/04/17 14:19:44 joerg Exp $	*/
+/*	$NetBSD: cdefs_elf.h,v 1.57 2020/04/30 14:32:05 joerg Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -134,16 +134,30 @@
 	  _C_LABEL_STRING(#name) " = " _C_LABEL_STRING(#resolver))
 #endif
 
+#ifdef __arm__
 #if __STDC__
-#define	__SECTIONSTRING(_sec, _str)	\
-	__asm(".pushsection " #_sec ",\"MS\",@progbits,1\n"		\
+#  define	__SECTIONSTRING(_sec, _str)	\
+	__asm(".pushsection " #_sec ",\"MS\",%progbits,1\n"		\
+	  ".asciz \"" _str "\"\n"	\
+	  ".popsection")
+#else
+#  define	__SECTIONSTRING(_sec, _str)	\
+	__asm(".pushsection " _sec ",\"MS\",%progbits,1\n"		\
 	  ".asciz \"" _str "\"\n"	\
 	  ".popsection")
+#  endif
 #else
-#define	__SECTIONSTRING(_sec, _str)	\
+#  if __STDC__
+#  define	__SECTIONSTRING(_sec, _str)	\
+	__asm(".pushsection " #_sec ",\"MS\",@progbits,1\n"		\
+	  ".asciz \"" _str "\"\n"	\
+	  ".popsection")
+#  else
+#  define	__SECTIONSTRING(_sec, _str)	\
 	__asm(".pushsection " _sec ",\"MS\",@progbits,1\n"		\
 	  ".asciz \"" _str "\"\n"	\
 	  ".popsection")
+#  endif
 #endif
 
 #define	__IDSTRING(_n,_s)		__SECTIONSTRING(.ident,_s)



CVS commit: src/sys/dev/pci

2020-04-30 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Apr 30 14:04:55 UTC 2020

Modified Files:
src/sys/dev/pci: if_msk.c

Log Message:
msk(4): actually moderate interrupts from the Yukon 2 Status BMU

Previously the interrupt moderation enable register was being programmed
with sk(4)-style enable bits, none of which matched the significant
interrupt sources of the Yukon 2 we enable.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/pci/if_msk.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/pci/if_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.107 src/sys/dev/pci/if_msk.c:1.108
--- src/sys/dev/pci/if_msk.c:1.107	Thu Apr 30 13:51:43 2020
+++ src/sys/dev/pci/if_msk.c	Thu Apr 30 14:04:54 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.107 2020/04/30 13:51:43 jakllsch Exp $ */
+/* $NetBSD: if_msk.c,v 1.108 2020/04/30 14:04:54 jakllsch Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.107 2020/04/30 13:51:43 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.108 2020/04/30 14:04:54 jakllsch Exp $");
 
 #include 
 #include 
@@ -866,8 +866,7 @@ msk_update_int_mod(struct sk_softc *sc, 
 		aprint_verbose_dev(sc->sk_dev,
 		"interrupt moderation is %d us\n", sc->sk_int_mod);
 	sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(sc->sk_int_mod));
-	sk_win_write_4(sc, SK_IMMR, SK_ISR_TX1_S_EOF | SK_ISR_TX2_S_EOF |
-	SK_ISR_RX1_EOF | SK_ISR_RX2_EOF);
+	sk_win_write_4(sc, SK_IMMR, SK_Y2_IMR_BMU);
 	sk_win_write_1(sc, SK_IMTIMERCTL, SK_IMCTL_START);
 	sc->sk_int_mod_pending = 0;
 }



CVS commit: src/sys/dev/pci

2020-04-30 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Apr 30 14:04:55 UTC 2020

Modified Files:
src/sys/dev/pci: if_msk.c

Log Message:
msk(4): actually moderate interrupts from the Yukon 2 Status BMU

Previously the interrupt moderation enable register was being programmed
with sk(4)-style enable bits, none of which matched the significant
interrupt sources of the Yukon 2 we enable.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/pci/if_msk.c

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



CVS commit: src/sys/net

2020-04-30 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Apr 30 13:59:50 UTC 2020

Modified Files:
src/sys/net: if_bridgevar.h

Log Message:
add sc_capenable member, forgot to commit


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/net/if_bridgevar.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/net/if_bridgevar.h
diff -u src/sys/net/if_bridgevar.h:1.33 src/sys/net/if_bridgevar.h:1.34
--- src/sys/net/if_bridgevar.h:1.33	Wed Dec 12 01:46:47 2018
+++ src/sys/net/if_bridgevar.h	Thu Apr 30 13:59:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridgevar.h,v 1.33 2018/12/12 01:46:47 rin Exp $	*/
+/*	$NetBSD: if_bridgevar.h,v 1.34 2020/04/30 13:59:50 jdolecek Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -328,6 +328,7 @@ struct bridge_softc {
 	uint32_t		sc_rthash_key;	/* key for hash */
 	uint32_t		sc_filter_flags; /* ipf and flags */
 	int			sc_csum_flags_tx;
+	int			sc_capenable;
 };
 
 extern const uint8_t bstp_etheraddr[];



CVS commit: src/sys/net

2020-04-30 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Apr 30 13:59:50 UTC 2020

Modified Files:
src/sys/net: if_bridgevar.h

Log Message:
add sc_capenable member, forgot to commit


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/net/if_bridgevar.h

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



CVS commit: src/sys/dev/pci

2020-04-30 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Apr 30 13:51:43 UTC 2020

Modified Files:
src/sys/dev/pci: if_msk.c

Log Message:
msk(4): during attach print intrstr only once


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/pci/if_msk.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/pci/if_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.106 src/sys/dev/pci/if_msk.c:1.107
--- src/sys/dev/pci/if_msk.c:1.106	Thu Apr 30 01:52:08 2020
+++ src/sys/dev/pci/if_msk.c	Thu Apr 30 13:51:43 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.106 2020/04/30 01:52:08 jakllsch Exp $ */
+/* $NetBSD: if_msk.c,v 1.107 2020/04/30 13:51:43 jakllsch Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.106 2020/04/30 01:52:08 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.107 2020/04/30 13:51:43 jakllsch Exp $");
 
 #include 
 #include 
@@ -1740,7 +1740,7 @@ mskc_attach(device_t parent, device_t se
 	aprint_normal(", %s", sc->sk_name);
 	if (revstr != NULL)
 		aprint_normal(" rev. %s", revstr);
-	aprint_normal(" (0x%x): %s\n", sc->sk_rev, intrstr);
+	aprint_normal(" (0x%x)\n", sc->sk_rev);
 
 	aprint_normal_dev(sc->sk_dev, "interrupting at %s\n", intrstr);
 



CVS commit: src/sys/dev/pci

2020-04-30 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Apr 30 13:51:43 UTC 2020

Modified Files:
src/sys/dev/pci: if_msk.c

Log Message:
msk(4): during attach print intrstr only once


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/pci/if_msk.c

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



CVS commit: src/doc

2020-04-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 30 12:44:41 UTC 2020

Modified Files:
src/doc: HACKS

Log Message:
Hack "gcc-4.5 arm without -fno-tree-vrp generate broken code" was removed in
src/lib/libc/softfloat/Makefile.inc rev 1.21:

http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/softfloat/Makefile.inc#rev1.21

Now, all tests mentioned in the entry are passed for softfloat arm.


To generate a diff of this commit:
cvs rdiff -u -r1.204 -r1.205 src/doc/HACKS

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



CVS commit: src/doc

2020-04-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 30 12:44:41 UTC 2020

Modified Files:
src/doc: HACKS

Log Message:
Hack "gcc-4.5 arm without -fno-tree-vrp generate broken code" was removed in
src/lib/libc/softfloat/Makefile.inc rev 1.21:

http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/softfloat/Makefile.inc#rev1.21

Now, all tests mentioned in the entry are passed for softfloat arm.


To generate a diff of this commit:
cvs rdiff -u -r1.204 -r1.205 src/doc/HACKS

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

Modified files:

Index: src/doc/HACKS
diff -u src/doc/HACKS:1.204 src/doc/HACKS:1.205
--- src/doc/HACKS:1.204	Thu Apr 30 12:35:01 2020
+++ src/doc/HACKS	Thu Apr 30 12:44:41 2020
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.204 2020/04/30 12:35:01 rin Exp $
+# $NetBSD: HACKS,v 1.205 2020/04/30 12:44:41 rin Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -604,25 +604,6 @@ port	arm
 		http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48863#c4
 	kcah
 
-	hack	gcc-4.5 arm without -fno-tree-vrp generate broken code
-	cdate	Wed Nov 14 13:02:02 JST 2012
-	who	msaitoh
-	file	lib/libc/softfloat/Makefile.inc : 1.11 (hack removed)
-	pr	46953
-	regress	src/tests/lib/libm/t_cbrt
-	regress	src/tests/lib/libm/t_ceil
-	regress	src/tests/lib/libm/t_exp
-	regress	src/tests/lib/libm/t_log
-	regress	src/tests/lib/libm/t_scalbn
-	regress	src/tests/lib/libm/t_sinh
-	regress	src/tests/lib/libm/t_sqrt
-	descr	Gcc has a bug in tree optimization. For adddf3,
-		-INF + -INF returns 0 without -fno-tree-vrp.
-		Debugging with -fdump-tree-all shows that
-		softfloat.c.021t.cleanup_cfg is ok but softfloat.c.023t.ssa
-		is broken.
-	kcah
-
 port	sh3
 
 	hack	gcc4-sh3-bz2



CVS commit: src/games/fortune/unstr

2020-04-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 30 12:40:11 UTC 2020

Modified Files:
src/games/fortune/unstr: unstr.c

Log Message:
Simplify, little KNF


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/games/fortune/unstr/unstr.c

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



CVS commit: src/games/fortune/unstr

2020-04-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 30 12:40:11 UTC 2020

Modified Files:
src/games/fortune/unstr: unstr.c

Log Message:
Simplify, little KNF


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/games/fortune/unstr/unstr.c

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

Modified files:

Index: src/games/fortune/unstr/unstr.c
diff -u src/games/fortune/unstr/unstr.c:1.15 src/games/fortune/unstr/unstr.c:1.16
--- src/games/fortune/unstr/unstr.c:1.15	Wed Apr 29 17:00:42 2020
+++ src/games/fortune/unstr/unstr.c	Thu Apr 30 08:40:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: unstr.c,v 1.15 2020/04/29 21:00:42 nia Exp $	*/
+/*	$NetBSD: unstr.c,v 1.16 2020/04/30 12:40:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)unstr.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: unstr.c,v 1.15 2020/04/29 21:00:42 nia Exp $");
+__RCSID("$NetBSD: unstr.c,v 1.16 2020/04/30 12:40:11 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -59,19 +59,19 @@ __RCSID("$NetBSD: unstr.c,v 1.15 2020/04
  *	Ken Arnold		Aug 13, 1978
  */
 
-# include	
-# include	
-# include	
-# include	
-# include	
-# include	
-# include	
-# include	
-# include	"strfile.h"
-
-# ifndef MAXPATHLEN
-# define	MAXPATHLEN	1024
-# endif	/* MAXPATHLEN */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "strfile.h"
+
+#ifndef MAXPATHLEN
+#define	MAXPATHLEN	1024
+#endif	/* MAXPATHLEN */
 
 char	*Infile,			/* name of input file */
 	Datafile[MAXPATHLEN],		/* name of data file */
@@ -91,9 +91,9 @@ main(int ac __unused, char **av)
 
 	getargs(av);
 	if ((Inf = fopen(Infile, "r")) == NULL)
-		err(1, "fopen %s", Infile);
+		err(EXIT_FAILURE, "fopen %s", Infile);
 	if ((Dataf = fopen(Datafile, "r")) == NULL)
-		err(1, "fopen %s", Datafile);
+		err(EXIT_FAILURE, "fopen %s", Datafile);
 	(void) fread((char *) , sizeof tbl, 1, Dataf);
 	BE32TOH(tbl.str_version);
 	BE32TOH(tbl.str_numstr);
@@ -108,19 +108,19 @@ main(int ac __unused, char **av)
 	order_unstr();
 	(void) fclose(Inf);
 	(void) fclose(Dataf);
-	exit(0);
+	return EXIT_SUCCESS;
 }
 
 void
 getargs(char *av[])
 {
-	if (!*++av || (strlen(*av) + sizeof(".dat")) > sizeof(Datafile)) {
-		(void) fprintf(stderr, "usage: unstr datafile\n");
-		exit(1);
+	if (!*++av ||
+	(size_t)snprintf(Datafile, sizeof(Datafile), "%s.dat", Infile) >
+	sizeof(Datafile)) {
+		(void) fprintf(stderr, "Usage: %s datafile\n", getprogname());
+		exit(EXIT_FAILURE);
 	}
 	Infile = *av;
-	(void) strcpy(Datafile, Infile);
-	(void) strcat(Datafile, ".dat");
 }
 
 void



CVS commit: src/doc

2020-04-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 30 12:35:01 UTC 2020

Modified Files:
src/doc: HACKS

Log Message:
lmcconfig(8) was removed.


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/doc/HACKS

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

Modified files:

Index: src/doc/HACKS
diff -u src/doc/HACKS:1.203 src/doc/HACKS:1.204
--- src/doc/HACKS:1.203	Thu Apr 30 12:32:16 2020
+++ src/doc/HACKS	Thu Apr 30 12:35:01 2020
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.203 2020/04/30 12:32:16 rin Exp $
+# $NetBSD: HACKS,v 1.204 2020/04/30 12:35:01 rin Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -511,7 +511,6 @@ port	vax
 	file	sbin/fsdb/Makefile : 1.36
 	file	sbin/newfs_ext2fs/Makefile : 1.6
 	file	sbin/ping/Makefile : 1.17
-	file	usr.sbin/lmcconfig/Makefile : 1.2 (file removed)
 	file	usr.sbin/mtrace/Makefile : 1.11
 	descr
 		external/gpl3/gcc/dist/gcc/expmed.c:2781:1:
@@ -527,9 +526,6 @@ port	vax
 		at postreload.c:1561
 		external/gpl3/gdb/dist/libdecnumber/decNumber.c:7214:3:
 		internal compiler error: in change_address_1, at emit-rtl.c:2019
-		usr.sbin/lmcconfig/lmcconfig.c:939:3:
-		internal compiler error: in reload_combine_note_use,
-		at postreload.c:1561
 		usr.sbin/mtrace/mtrace.c:1655:1:
 		internal compiler error: in change_address_1, at emit-rtl.c:2019
 	kcah



CVS commit: src/doc

2020-04-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 30 12:35:01 UTC 2020

Modified Files:
src/doc: HACKS

Log Message:
lmcconfig(8) was removed.


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/doc/HACKS

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



CVS commit: src/games/fortune/strfile

2020-04-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 30 12:32:26 UTC 2020

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Simplify, errors to stderr.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/games/fortune/strfile/strfile.c

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



CVS commit: src/games/fortune/strfile

2020-04-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 30 12:32:26 UTC 2020

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Simplify, errors to stderr.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/games/fortune/strfile/strfile.c

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

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.39 src/games/fortune/strfile/strfile.c:1.40
--- src/games/fortune/strfile/strfile.c:1.39	Wed Apr 29 16:45:05 2020
+++ src/games/fortune/strfile/strfile.c	Thu Apr 30 08:32:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.39 2020/04/29 20:45:05 nia Exp $	*/
+/*	$NetBSD: strfile.c,v 1.40 2020/04/30 12:32:26 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)strfile.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.39 2020/04/29 20:45:05 nia Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.40 2020/04/30 12:32:26 christos Exp $");
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -55,6 +55,7 @@ __RCSID("$NetBSD: strfile.c,v 1.39 2020/
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -131,7 +132,7 @@ static STR *Firstch;			/* first chars of
 
 static uint32_t h2nl(uint32_t h);
 static void getargs(int argc, char **argv);
-static void usage(void) __dead;
+static void usage(const char *, ...) __dead __printflike(1, 2);
 static void add_offset(FILE *fp, off_t off);
 static void do_order(void);
 static int cmp_str(const void *vp1, const void *vp2);
@@ -295,39 +296,39 @@ getargs(int argc, char **argv)
 			break;
 		case '?':
 		default:
-			usage();
+			usage(NULL);
 		}
 	argv += optind;
 
 	if (*argv) {
 		Infile = *argv;
 		if (*++argv) {
-			len = strlen(*argv);
+			len = strlcpy(Outfile, *argv, sizeof(Outfile));
 			if (len >= sizeof(Outfile)) {
-puts("Bad output filename");
-usage();
+usage("Too long output filename");
 			}
-			(void) memcpy(Outfile, *argv, len + 1);
 		}
 	}
 	if (!Infile) {
-		puts("No input file name");
-		usage();
+		usage("No input file name");
 	}
 	if (*Outfile == '\0') {
-		len = strlen(Infile) + sizeof(".dat");
-		if (len > sizeof(Outfile)) {
-			puts("Bad input filename");
-			usage();
+		len = snprintf(Outfile, sizeof(Outfile), "%s.dat", Infile);
+		if (len >= sizeof(Outfile)) {
+			usage("Too long input filename");
 		}
-		(void) strcpy(Outfile, Infile);
-		(void) strcat(Outfile, ".dat");
 	}
 }
 
 static void
-usage(void)
+usage(const char *fmt, ...)
 {
+	if (fmt) {
+		va_list ap;
+		va_start(ap, fmt);
+		vwarnx(fmt, ap);
+		va_end(ap);
+	}
 	(void) fprintf(stderr,
 	"Usage: %s [-iorsx] [-c char] sourcefile [datafile]\n",
 	getprogname());



CVS commit: src/doc

2020-04-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 30 12:32:16 UTC 2020

Modified Files:
src/doc: HACKS

Log Message:
Add missing dates and revisions.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/doc/HACKS

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

Modified files:

Index: src/doc/HACKS
diff -u src/doc/HACKS:1.202 src/doc/HACKS:1.203
--- src/doc/HACKS:1.202	Wed Apr 29 11:08:40 2020
+++ src/doc/HACKS	Thu Apr 30 12:32:16 2020
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.202 2020/04/29 11:08:40 rin Exp $
+# $NetBSD: HACKS,v 1.203 2020/04/30 12:32:16 rin Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -81,7 +81,7 @@ kcah
 hack	wi-at-big-endian-bus
 cdate	15 Mar 2002
 who	martin
-file	dev/ic/wireg.h
+file	dev/ic/wireg.h : 1.20
 descr	Add an option to access the underlying bus in big endian byte order
 	to work around deficiencies in bus_space_{read,write}_* macros.
 	Those don't allow the implementation of a proper pcmcia bus space
@@ -407,9 +407,9 @@ kcah
 port	vax
 
 	hack	gcc4/vax ICE
-	cdate	
+	cdate	Sat Dec 22 08:17:57 2007 UTC
 	who	tsutsui
-	file	sys/arch/vax/conf/Makefile.vax
+	file	sys/arch/vax/conf/Makefile.vax : 1.79
 	descr
 		GCC4 on vax gets ICE on compiling sys/ddb/db_command.c.
 		-fno-tree-ter prevents it so add it to COPTS.
@@ -504,15 +504,15 @@ port	vax
 	hack	gcc 4.8 gcc miscompiles
 	date	Sat Nov  9 16:35:18 EST 2013
 	who	christos
-	file	distrib/utils/x_ping/Makefile
-	file	distrib/vax/miniroot/Makefile.inc
-	file	distrib/vax/ramdisk/Makefile
-	file	external/gpl3/gdb/lib/libdecnumber/Makefile
-	file	sbin/fsdb/Makefile
-	file	sbin/newfs_ext2fs/Makefile
-	file	sbin/ping/Makefile
-	file	usr.sbin/lmcconfig/Makefile
-	file	usr.sbin/mtrace/Makefile
+	file	distrib/utils/x_ping/Makefile : 1.8
+	file	distrib/vax/miniroot/Makefile.inc : ?
+	file	distrib/vax/ramdisk/Makefile : ?
+	file	external/gpl3/gdb/lib/libdecnumber/Makefile : 1.3
+	file	sbin/fsdb/Makefile : 1.36
+	file	sbin/newfs_ext2fs/Makefile : 1.6
+	file	sbin/ping/Makefile : 1.17
+	file	usr.sbin/lmcconfig/Makefile : 1.2 (file removed)
+	file	usr.sbin/mtrace/Makefile : 1.11
 	descr
 		external/gpl3/gcc/dist/gcc/expmed.c:2781:1:
 		internal compiler error: in change_address_1, at emit-rtl.c:2019
@@ -611,7 +611,7 @@ port	arm
 	hack	gcc-4.5 arm without -fno-tree-vrp generate broken code
 	cdate	Wed Nov 14 13:02:02 JST 2012
 	who	msaitoh
-	file	lib/libc/softfloat/Makefile.inc
+	file	lib/libc/softfloat/Makefile.inc : 1.11 (hack removed)
 	pr	46953
 	regress	src/tests/lib/libm/t_cbrt
 	regress	src/tests/lib/libm/t_ceil
@@ -746,6 +746,7 @@ port	x86
 		we are pass the wrong arguments to biosdisk_read(). 
 		$ cd /usr/src/sys/arch/i386/floppies/bootflopp-com
 		$ qemu-system-i386 -nographic -fda boot-com1.fs -boot a
+	cdate	Mon Apr 7 21:09:55 2014 UTC
 	who	christos
 	file	src/sys/arch/i386/stand/lib/Makefile : 1.38
 	descr
@@ -769,7 +770,7 @@ port	powerpc
 		properly.
 	cdate	Sat Mar 12 08:00:00 UTC 2011
 	who	matt
-	file	src/gnu/dist/gcc4/gcc/config/rs6000/netbsd.h
+	file	src/gnu/dist/gcc4/gcc/config/rs6000/netbsd.h : 1.7
 	descr
 		see above
 	kcah
@@ -843,7 +844,7 @@ port	x68k
 hack	fallback to /usr/bin/clang-cpp in rpcgen
 cdate	Wed Jun  5 15:49:27 CEST 2013
 who	joerg
-file	src/usr.bin/rpcgen/rpc_main.c
+file	src/usr.bin/rpcgen/rpc_main.c : 1.35
 descr
 	It is undecided which compiler owns /usr/bin/cpp and whether it should
 	exist in a MKGCC=no world. To allow rpcgen to work out-of-the-box,
@@ -919,6 +920,7 @@ kcah
 
 port	arm
 hack	avoid using labels in a 12-bit constant.
+cdate	Mon Mar 30 05:26:47 2015 UTC
 who	matt
 file	crypto/external/bsd/openssl/lib/libcrypto/arch/arm/aes-armv4.S: 1.2
 descr	workaround for clang misassembling an instruction
@@ -927,6 +929,7 @@ kcah
 port	sparc64
 hack	during profiling with -m32 (and ASLR) labels are not generated
 	consistently
+cdate	Sat Feb 11 04:56:37 2017 UTC
 who	christos
 file	/cvsroot/src/crypto/external/bsd/heimdal/lib/libasn1/Makefile: 1.4
 desc 	asn1_krb5_asn1.po does not produce the same results during successive
@@ -936,6 +939,7 @@ kcah
 
 port	ia64
 hack	ski emulator crashes
+cdate	Sat Apr 8 18:10:43 2017 UTC
 who	scole
 file	/cvsroot/src/sys/external/bsd/acpica/dist/tables/tbxfload.c: 1.6
 desc



CVS commit: src/doc

2020-04-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 30 12:32:16 UTC 2020

Modified Files:
src/doc: HACKS

Log Message:
Add missing dates and revisions.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/doc/HACKS

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



CVS commit: src/usr.bin/kdump

2020-04-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Apr 30 12:17:02 UTC 2020

Modified Files:
src/usr.bin/kdump: kdump.c

Log Message:
Decode futex op codes.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/usr.bin/kdump/kdump.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/kdump/kdump.c
diff -u src/usr.bin/kdump/kdump.c:1.137 src/usr.bin/kdump/kdump.c:1.138
--- src/usr.bin/kdump/kdump.c:1.137	Mon Apr 20 00:35:41 2020
+++ src/usr.bin/kdump/kdump.c	Thu Apr 30 12:17:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kdump.c,v 1.137 2020/04/20 00:35:41 christos Exp $	*/
+/*	$NetBSD: kdump.c,v 1.138 2020/04/30 12:17:01 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)kdump.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: kdump.c,v 1.137 2020/04/20 00:35:41 christos Exp $");
+__RCSID("$NetBSD: kdump.c,v 1.138 2020/04/30 12:17:01 thorpej Exp $");
 #endif
 #endif /* not lint */
 
@@ -55,6 +55,7 @@ __RCSID("$NetBSD: kdump.c,v 1.137 2020/0
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -629,6 +630,59 @@ putprot(int pr)
 	}
 }
 
+static const char *
+futex_op_name(u_long op)
+{
+#define	FUTEXCASE(a)	case a:	return # a
+	switch (op & FUTEX_CMD_MASK) {
+	FUTEXCASE(FUTEX_WAIT);
+	FUTEXCASE(FUTEX_WAKE);
+	FUTEXCASE(FUTEX_FD);
+	FUTEXCASE(FUTEX_REQUEUE);
+	FUTEXCASE(FUTEX_CMP_REQUEUE);
+	FUTEXCASE(FUTEX_WAKE_OP);
+	FUTEXCASE(FUTEX_LOCK_PI);
+	FUTEXCASE(FUTEX_UNLOCK_PI);
+	FUTEXCASE(FUTEX_TRYLOCK_PI);
+	FUTEXCASE(FUTEX_WAIT_BITSET);
+	FUTEXCASE(FUTEX_WAKE_BITSET);
+	FUTEXCASE(FUTEX_WAIT_REQUEUE_PI);
+	FUTEXCASE(FUTEX_CMP_REQUEUE_PI);
+	default:
+		return NULL;
+	}
+#undef FUTEXCASE
+}
+
+static void
+futexput(u_long op)
+{
+	const char *opname = futex_op_name(op);
+	const char *s = "";
+
+	if (opname == NULL) {
+		printf("%#lx", op & FUTEX_CMD_MASK);
+	} else {
+		fputs(opname, stdout);
+	}
+	op &= ~FUTEX_CMD_MASK;
+
+	if (op & FUTEX_PRIVATE_FLAG) {
+		fputs("_PRIVATE", stdout);
+		op &= ~FUTEX_PRIVATE_FLAG;
+	}
+
+	if (op & FUTEX_CLOCK_REALTIME) {
+		printf("%sFUTEX_CLOCK_REALTIME", s);
+		op &= ~FUTEX_CLOCK_REALTIME;
+		s = "|";
+	}
+
+	if (op) {
+		printf("%s%#lx", s, op);
+	}
+}
+
 static void
 ktrsyscall(struct ktr_syscall *ktr)
 {
@@ -699,6 +753,25 @@ ktrsyscall(struct ktr_syscall *ktr)
 			ap++;
 			argcount--;
 			c = ',';
+
+			/*
+			 * Linux name is "futex".
+			 * Native name is "__futex".
+			 * Both have the same op argument.
+			 */
+		} else if ((strcmp(sys_name, "futex") == 0 ||
+			strcmp(sys_name, "__futex") == 0) &&
+			   argcount > 2) {
+			(void)putchar('(');
+			output_long((long)*ap, 1);
+			(void)putchar(',');
+			ap++;
+			argcount--;
+			futexput(*ap);
+			ap++;
+			argcount--;
+			c = ',';
+
 		} else if ((strstr(sys_name, "sigaction") != NULL ||
 		strstr(sys_name, "sigvec") != NULL) && argcount >= 1) {
 			(void)printf("(SIG%s", signame(ap[0], 1));



CVS commit: src/usr.bin/kdump

2020-04-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Apr 30 12:17:02 UTC 2020

Modified Files:
src/usr.bin/kdump: kdump.c

Log Message:
Decode futex op codes.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/usr.bin/kdump/kdump.c

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



CVS commit: src/usr.bin/calendar/calendars

2020-04-30 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Apr 30 12:13:39 UTC 2020

Modified Files:
src/usr.bin/calendar/calendars: calendar.computer

Log Message:
It was aboard the Space Shuttle Atlantis using a Macintosh Portable.
https://support.apple.com/kb/TA30635


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/calendar/calendars/calendar.computer

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



CVS commit: src/usr.bin/calendar/calendars

2020-04-30 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Apr 30 12:13:39 UTC 2020

Modified Files:
src/usr.bin/calendar/calendars: calendar.computer

Log Message:
It was aboard the Space Shuttle Atlantis using a Macintosh Portable.
https://support.apple.com/kb/TA30635


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/calendar/calendars/calendar.computer

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/calendar/calendars/calendar.computer
diff -u src/usr.bin/calendar/calendars/calendar.computer:1.12 src/usr.bin/calendar/calendars/calendar.computer:1.13
--- src/usr.bin/calendar/calendars/calendar.computer:1.12	Thu Mar 19 07:20:36 2020
+++ src/usr.bin/calendar/calendars/calendar.computer	Thu Apr 30 12:13:39 2020
@@ -55,6 +55,7 @@
 	Temple Univ., Phila, 1948, for symbolic differentiation on the ENIAC
 07/08	Bell Telephone Co. formed (predecessor of AT), 1877
 07/08	CDC incorporated, 1957
+08/09	First email sent from space by the crew of STS-43, 1991
 08/14	First Unix-based mallet created, 1954
 08/14	IBM PC announced, 1981
 08/21	Structure and Interpretation of Computer Programs published, 1985



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

2020-04-30 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Apr 30 11:23:44 UTC 2020

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

Log Message:
add support for scatter-gather when accepting packets on frontend Tx path
(frontend -> backend)

don't enable ETHERCAP_JUMBO_MTU nor feature-sg yet, need to implement
support also for the frontend Rx side


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/xen/xen/xennetback_xenbus.c

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



  1   2   >