CVS commit: src/sys/net

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 15 00:05:18 UTC 2022

Modified Files:
src/sys/net: if_tun.c

Log Message:
tun(4): Fix bug introduced in previous locking change.

Now that tun_lock runs at IPL_NONE, taking it does not have the side
effect of disabling preemption, but pktq_enqueue assumes the caller
has disabled preemption so it can safely schedule a softint.

This isn't a problem in most physical network drivers because the
pktq_enqueue call happens from within the driver's softint context
anyway.  But tun(4) is special -- here, the pktq_enqueue is triggered
by a userland write to the device, which is in thread context.  So
let's just disable preemption in tunwrite.

Reported-by: syzbot+21c2cb300f1ec2162...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/sys/net/if_tun.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

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 15 00:05:18 UTC 2022

Modified Files:
src/sys/net: if_tun.c

Log Message:
tun(4): Fix bug introduced in previous locking change.

Now that tun_lock runs at IPL_NONE, taking it does not have the side
effect of disabling preemption, but pktq_enqueue assumes the caller
has disabled preemption so it can safely schedule a softint.

This isn't a problem in most physical network drivers because the
pktq_enqueue call happens from within the driver's softint context
anyway.  But tun(4) is special -- here, the pktq_enqueue is triggered
by a userland write to the device, which is in thread context.  So
let's just disable preemption in tunwrite.

Reported-by: syzbot+21c2cb300f1ec2162...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/sys/net/if_tun.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/net/if_tun.c
diff -u src/sys/net/if_tun.c:1.171 src/sys/net/if_tun.c:1.172
--- src/sys/net/if_tun.c:1.171	Sun Mar 13 21:42:39 2022
+++ src/sys/net/if_tun.c	Tue Mar 15 00:05:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tun.c,v 1.171 2022/03/13 21:42:39 riastradh Exp $	*/
+/*	$NetBSD: if_tun.c,v 1.172 2022/03/15 00:05:17 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988, Julian Onions 
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.171 2022/03/13 21:42:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.172 2022/03/15 00:05:17 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -987,6 +987,7 @@ tunwrite(dev_t dev, struct uio *uio, int
 		error = ENXIO;
 		goto out;
 	}
+	kpreempt_disable();
 	if (__predict_false(!pktq_enqueue(pktq, top, 0))) {
 		if_statinc(ifp, if_collisions);
 		mutex_exit(&tp->tun_lock);
@@ -994,6 +995,7 @@ tunwrite(dev_t dev, struct uio *uio, int
 		m_freem(top);
 		goto out0;
 	}
+	kpreempt_enable();
 	if_statadd2(ifp, if_ipackets, 1, if_ibytes, tlen);
 out:
 	mutex_exit(&tp->tun_lock);



CVS commit: src/sys/dev/ata

2022-03-14 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Mar 14 22:15:51 UTC 2022

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Avoid an unaccounted extra channel freeze, if a reset is requested
more than once before the thread services the request.  Closes PR#56745.


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/dev/ata/ata.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/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.166 src/sys/dev/ata/ata.c:1.167
--- src/sys/dev/ata/ata.c:1.166	Wed Feb 23 21:54:40 2022
+++ src/sys/dev/ata/ata.c	Mon Mar 14 22:15:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata.c,v 1.166 2022/02/23 21:54:40 andvar Exp $	*/
+/*	$NetBSD: ata.c,v 1.167 2022/03/14 22:15:51 perseant Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.166 2022/02/23 21:54:40 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.167 2022/03/14 22:15:51 perseant Exp $");
 
 #include "opt_ata.h"
 
@@ -1600,12 +1600,14 @@ ata_thread_run(struct ata_channel *chp, 
 			/* NOTREACHED */
 		}
 
-		/*
-		 * Block execution of other commands while reset is scheduled
-		 * to a thread.
-		 */
-		ata_channel_freeze_locked(chp);
-		chp->ch_flags |= type;
+		if (!(chp->ch_flags & type)) {
+			/*
+			 * Block execution of other commands while
+			 * reset is scheduled to a thread.
+			 */
+			ata_channel_freeze_locked(chp);
+			chp->ch_flags |= type;
+		}
 
 		cv_signal(&chp->ch_thr_idle);
 		return;



CVS commit: src/sys/dev/ata

2022-03-14 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Mar 14 22:15:51 UTC 2022

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Avoid an unaccounted extra channel freeze, if a reset is requested
more than once before the thread services the request.  Closes PR#56745.


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/dev/ata/ata.c

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



CVS commit: src/lib/libc/stdlib

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 22:14:19 UTC 2022

Modified Files:
src/lib/libc/stdlib: system.c

Log Message:
system(3): Simplify initialization of argp.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/stdlib/system.c

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

Modified files:

Index: src/lib/libc/stdlib/system.c
diff -u src/lib/libc/stdlib/system.c:1.27 src/lib/libc/stdlib/system.c:1.28
--- src/lib/libc/stdlib/system.c:1.27	Mon Mar 14 22:06:28 2022
+++ src/lib/libc/stdlib/system.c	Mon Mar 14 22:14:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: system.c,v 1.27 2022/03/14 22:06:28 riastradh Exp $	*/
+/*	$NetBSD: system.c,v 1.28 2022/03/14 22:14:19 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)system.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: system.c,v 1.27 2022/03/14 22:06:28 riastradh Exp $");
+__RCSID("$NetBSD: system.c,v 1.28 2022/03/14 22:14:19 riastradh Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -57,12 +57,10 @@ system(const char *command)
 	struct sigaction intsa, quitsa, sa;
 	sigset_t nmask, omask, sigdefault;
 	int pstat;
-	const char *argp[] = {"sh", "-c", "--", NULL, NULL};
+	const char *argp[] = {"sh", "-c", "--", command, NULL};
 	posix_spawnattr_t attr;
 	int error;
 
-	argp[3] = command;
-
 	/*
 	 * ISO/IEC 9899:1999 in 7.20.4.6 describes this special case.
 	 * We need to check availability of a command interpreter.



CVS commit: src/lib/libc/stdlib

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 22:14:19 UTC 2022

Modified Files:
src/lib/libc/stdlib: system.c

Log Message:
system(3): Simplify initialization of argp.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/stdlib/system.c

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



CVS commit: src/lib/libc/stdlib

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 22:06:28 UTC 2022

Modified Files:
src/lib/libc/stdlib: system.c

Log Message:
system(3): Switch from vfork/execve to posix_spawn.

Changes by me:
- Minor style nits.
- Set errno on posix_spawn failure.
- Handle edge cases of SIGINT/SIGQUIT set to SIG_IGN by caller.

Author: Nikita Ronja Gillmann 
Committer: Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/stdlib/system.c

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



CVS commit: src/lib/libc/stdlib

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 22:06:28 UTC 2022

Modified Files:
src/lib/libc/stdlib: system.c

Log Message:
system(3): Switch from vfork/execve to posix_spawn.

Changes by me:
- Minor style nits.
- Set errno on posix_spawn failure.
- Handle edge cases of SIGINT/SIGQUIT set to SIG_IGN by caller.

Author: Nikita Ronja Gillmann 
Committer: Taylor R Campbell 


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/stdlib/system.c

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

Modified files:

Index: src/lib/libc/stdlib/system.c
diff -u src/lib/libc/stdlib/system.c:1.26 src/lib/libc/stdlib/system.c:1.27
--- src/lib/libc/stdlib/system.c:1.26	Fri Oct 29 19:27:06 2021
+++ src/lib/libc/stdlib/system.c	Mon Mar 14 22:06:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: system.c,v 1.26 2021/10/29 19:27:06 kre Exp $	*/
+/*	$NetBSD: system.c,v 1.27 2022/03/14 22:06:28 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)system.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: system.c,v 1.26 2021/10/29 19:27:06 kre Exp $");
+__RCSID("$NetBSD: system.c,v 1.27 2022/03/14 22:06:28 riastradh Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -46,6 +46,7 @@ __RCSID("$NetBSD: system.c,v 1.26 2021/1
 #include 
 #include 
 #include 
+#include 
 
 #include "env.h"
 
@@ -54,9 +55,12 @@ system(const char *command)
 {
 	pid_t pid;
 	struct sigaction intsa, quitsa, sa;
-	sigset_t nmask, omask;
+	sigset_t nmask, omask, sigdefault;
 	int pstat;
 	const char *argp[] = {"sh", "-c", "--", NULL, NULL};
+	posix_spawnattr_t attr;
+	int error;
+
 	argp[3] = command;
 
 	/*
@@ -88,22 +92,41 @@ system(const char *command)
 		return -1;
 	}
 
+	/*
+	 * We arrange to inherit all signal handlers from the caller by
+	 * default, except possibly SIGINT and SIGQUIT.  These we have
+	 * overridden internally for system(3) to be SIG_IGN.
+	 *
+	 * - If the caller had SIGINT or SIGQUIT at SIG_IGN, then we
+	 *   inherit them as is -- caller had SIG_IGN, child will too.
+	 *
+	 * - Otherwise, they are SIG_DFL or a signal handler, and we
+	 *   must reset them to SIG_DFL in the child, rather than
+	 *   SIG_IGN in system(3) in the parent, by including them in
+	 *   the sigdefault set.
+	 */
+	sigemptyset(&sigdefault);
+	if (intsa.sa_handler != SIG_IGN)
+		sigaddset(&sigdefault, SIGINT);
+	if (quitsa.sa_handler != SIG_IGN)
+		sigaddset(&sigdefault, SIGQUIT);
+
+	posix_spawnattr_init(&attr);
+	posix_spawnattr_setsigdefault(&attr, &sigdefault);
+	posix_spawnattr_setsigmask(&attr, &omask);
+	posix_spawnattr_setflags(&attr,
+	POSIX_SPAWN_SETSIGDEF|POSIX_SPAWN_SETSIGMASK);
 	(void)__readlockenv();
-	switch(pid = vfork()) {
-	case -1:			/* error */
-		(void)__unlockenv();
-		sigaction(SIGINT, &intsa, NULL);
-		sigaction(SIGQUIT, &quitsa, NULL);
-		(void)sigprocmask(SIG_SETMASK, &omask, NULL);
-		return -1;
-	case 0:/* child */
-		sigaction(SIGINT, &intsa, NULL);
-		sigaction(SIGQUIT, &quitsa, NULL);
-		(void)sigprocmask(SIG_SETMASK, &omask, NULL);
-		execve(_PATH_BSHELL, __UNCONST(argp), environ);
-		_exit(127);
-	}
+	error = posix_spawn(&pid, _PATH_BSHELL, NULL, &attr, __UNCONST(argp),
+	environ);
 	(void)__unlockenv();
+	posix_spawnattr_destroy(&attr);
+
+	if (error) {
+		errno = error;
+		pstat = -1;
+		goto out;
+	}
 
 	while (waitpid(pid, &pstat, 0) == -1) {
 		if (errno != EINTR) {
@@ -112,7 +135,7 @@ system(const char *command)
 		}
 	}
 
-	sigaction(SIGINT, &intsa, NULL);
+out:	sigaction(SIGINT, &intsa, NULL);
 	sigaction(SIGQUIT, &quitsa, NULL);
 	(void)sigprocmask(SIG_SETMASK, &omask, NULL);
 



CVS commit: src/sys/dev/audio

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 21:38:04 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Fix typo in previous -- atomic_store_release, not reease.

Built the wrong kernel to compile-test AUDIO_DEBUG, oops.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 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.114 src/sys/dev/audio/audio.c:1.115
--- src/sys/dev/audio/audio.c:1.114	Mon Mar 14 11:47:33 2022
+++ src/sys/dev/audio/audio.c	Mon Mar 14 21:38:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.114 2022/03/14 11:47:33 riastradh Exp $	*/
+/*	$NetBSD: audio.c,v 1.115 2022/03/14 21:38:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.114 2022/03/14 11:47:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.115 2022/03/14 21:38:04 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -280,7 +280,7 @@ audio_mlog_flush(void)
 	mlog_buf[mlog_wpage][0] = '\0';
 	mlog_used = 0;
 
-	atomic_store_reease(&mlog_inuse, 0);
+	atomic_store_release(&mlog_inuse, 0);
 
 	if (mlog_buf[rpage][0] != '\0') {
 		printf("%s", mlog_buf[rpage]);



CVS commit: src/sys/dev/audio

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 21:38:04 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Fix typo in previous -- atomic_store_release, not reease.

Built the wrong kernel to compile-test AUDIO_DEBUG, oops.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 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: src/external/bsd/elftoolchain/dist/libdwarf

2022-03-14 Thread Joseph Koshy
Module Name:src
Committed By:   jkoshy
Date:   Mon Mar 14 20:50:48 UTC 2022

Modified Files:
src/external/bsd/elftoolchain/dist/libdwarf: dwarf.3
dwarf_add_AT_comp_dir.3 dwarf_add_AT_const_value_string.3
dwarf_add_AT_dataref.3 dwarf_add_AT_flag.3
dwarf_add_AT_location_expr.3 dwarf_add_AT_name.3
dwarf_add_AT_producer.3 dwarf_add_AT_ref_address.3
dwarf_add_AT_reference.3 dwarf_add_AT_signed_const.3
dwarf_add_AT_string.3 dwarf_add_AT_targ_address.3
dwarf_add_arange.3 dwarf_add_die_to_debug.3
dwarf_add_directory_decl.3 dwarf_add_expr_addr.3
dwarf_add_expr_gen.3 dwarf_add_fde_inst.3 dwarf_add_file_decl.3
dwarf_add_frame_cie.3 dwarf_add_frame_fde.3 dwarf_add_funcname.3
dwarf_add_line_entry.3 dwarf_add_pubname.3 dwarf_add_typename.3
dwarf_add_varname.3 dwarf_add_weakname.3 dwarf_attr.3
dwarf_attrlist.3 dwarf_attroffset.3 dwarf_attrval_signed.3
dwarf_child.3 dwarf_dealloc.3 dwarf_def_macro.3
dwarf_die_abbrev_code.3 dwarf_die_link.3 dwarf_diename.3
dwarf_dieoffset.3 dwarf_end_macro_file.3 dwarf_errmsg.3
dwarf_errno.3 dwarf_expand_frame_instructions.3
dwarf_expr_current_offset.3 dwarf_expr_into_block.3
dwarf_fde_cfa_offset.3 dwarf_find_macro_value_start.3
dwarf_finish.3 dwarf_formaddr.3 dwarf_formblock.3
dwarf_formexprloc.3 dwarf_formflag.3 dwarf_formref.3
dwarf_formsig8.3 dwarf_formstring.3 dwarf_formudata.3
dwarf_get_AT_name.3 dwarf_get_abbrev.3
dwarf_get_abbrev_children_flag.3 dwarf_get_abbrev_code.3
dwarf_get_abbrev_entry.3 dwarf_get_abbrev_tag.3
dwarf_get_address_size.3 dwarf_get_arange.3 dwarf_get_arange_info.3
dwarf_get_aranges.3 dwarf_get_cie_index.3 dwarf_get_cie_info.3
dwarf_get_cie_of_fde.3 dwarf_get_cu_die_offset.3
dwarf_get_die_infotypes_flag.3 dwarf_get_elf.3
dwarf_get_fde_at_pc.3 dwarf_get_fde_info_for_all_regs.3
dwarf_get_fde_info_for_all_regs3.3
dwarf_get_fde_info_for_cfa_reg3.3 dwarf_get_fde_info_for_reg.3
dwarf_get_fde_info_for_reg3.3 dwarf_get_fde_instr_bytes.3
dwarf_get_fde_list.3 dwarf_get_fde_n.3 dwarf_get_fde_range.3
dwarf_get_form_class.3 dwarf_get_funcs.3 dwarf_get_globals.3
dwarf_get_loclist_entry.3 dwarf_get_macro_details.3
dwarf_get_pubtypes.3 dwarf_get_ranges.3 dwarf_get_relocation_info.3
dwarf_get_relocation_info_count.3 dwarf_get_section_bytes.3
dwarf_get_section_max_offsets.3 dwarf_get_str.3 dwarf_get_types.3
dwarf_get_vars.3 dwarf_get_weaks.3 dwarf_hasattr.3 dwarf_hasform.3
dwarf_highpc.3 dwarf_init.3 dwarf_lineno.3 dwarf_lne_end_sequence.3
dwarf_lne_set_address.3 dwarf_loclist.3 dwarf_loclist_from_expr.3
dwarf_new_die.3 dwarf_new_expr.3 dwarf_new_fde.3
dwarf_next_cu_header.3 dwarf_next_types_section.3
dwarf_object_init.3 dwarf_producer_init.3 dwarf_producer_set_isa.3
dwarf_reset_section_bytes.3 dwarf_set_frame_cfa_value.3
dwarf_set_reloc_application.3 dwarf_seterrarg.3 dwarf_srcfiles.3
dwarf_srclines.3 dwarf_start_macro_file.3 dwarf_tag.3
dwarf_transform_to_disk_form.3 dwarf_undef_macro.3
dwarf_vendor_ext.3 dwarf_whatattr.3

Log Message:
Sync libdwarf's manual pages with upstream [r3964].


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/elftoolchain/dist/libdwarf/dwarf.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_comp_dir.3 \

src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_const_value_string.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_dataref.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_flag.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_location_expr.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_name.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_producer.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_ref_address.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_reference.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_signed_const.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_string.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_AT_targ_address.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_arange.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_die_to_debug.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_directory_decl.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_expr_addr.3 \
src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_expr_gen.3 \
src/external/bsd/elftoo

CVS commit: src/tests/usr.bin/xlint/lint1

2022-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Mar 14 20:25:26 UTC 2022

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230_uchar.c msg_230_uchar.exp

Log Message:
tests/lint: fix test about "non-portable character constant" on uchar

The warning is wrong, and it has been for a long time.  For now just fix
the test to match the actual output.  Seen on evbarm, which is one of
the platforms where a plain char is unsigned.

Noticed by Martin.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_230_uchar.c
diff -u src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.7 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.8
--- src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.7	Sat Feb 26 11:13:01 2022
+++ src/tests/usr.bin/xlint/lint1/msg_230_uchar.c	Mon Mar 14 20:25:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_230_uchar.c,v 1.7 2022/02/26 11:13:01 rillig Exp $	*/
+/*	$NetBSD: msg_230_uchar.c,v 1.8 2022/03/14 20:25:26 rillig Exp $	*/
 # 3 "msg_230_uchar.c"
 
 // Test for message: nonportable character comparison '%s %d' [230]
@@ -125,8 +125,10 @@ compare_with_character_literal(char ch)
 	 * interpreted using the type 'char' on the exact same platform as
 	 * where the comparison takes place.
 	 */
+	/* expect+1: warning: nonportable character comparison '== 128' [230] */
 	if (ch == '\200')
 		return;
+	/* expect+1: warning: nonportable character comparison '== 255' [230] */
 	if (ch == '\377')
 		return;
 	if (ch == '\000')

Index: src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp:1.3	Thu Dec 16 20:23:40 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp	Mon Mar 14 20:25:26 2022
@@ -17,3 +17,5 @@ msg_230_uchar.c(99): warning: comparison
 msg_230_uchar.c(109): warning: nonportable character comparison '>= 128' [230]
 msg_230_uchar.c(113): warning: nonportable character comparison '> 128' [230]
 msg_230_uchar.c(116): warning: nonportable character comparison '>= 129' [230]
+msg_230_uchar.c(129): warning: nonportable character comparison '== 128' [230]
+msg_230_uchar.c(132): warning: nonportable character comparison '== 255' [230]



CVS commit: src/tests/usr.bin/xlint/lint1

2022-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Mar 14 20:25:26 UTC 2022

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230_uchar.c msg_230_uchar.exp

Log Message:
tests/lint: fix test about "non-portable character constant" on uchar

The warning is wrong, and it has been for a long time.  For now just fix
the test to match the actual output.  Seen on evbarm, which is one of
the platforms where a plain char is unsigned.

Noticed by Martin.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp

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



CVS commit: src/sbin/dump

2022-03-14 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Mar 14 18:38:11 UTC 2022

Modified Files:
src/sbin/dump: optr.c

Log Message:
Silently ignore fstab entries with NAME= entries that cannot be resolved.
Fixes PR 56249.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sbin/dump/optr.c

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

Modified files:

Index: src/sbin/dump/optr.c
diff -u src/sbin/dump/optr.c:1.43 src/sbin/dump/optr.c:1.44
--- src/sbin/dump/optr.c:1.43	Fri Mar  1 16:42:11 2019
+++ src/sbin/dump/optr.c	Mon Mar 14 18:38:11 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: optr.c,v 1.43 2019/03/01 16:42:11 christos Exp $	*/
+/*	$NetBSD: optr.c,v 1.44 2022/03/14 18:38:11 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)optr.c	8.2 (Berkeley) 1/6/94";
 #else
-__RCSID("$NetBSD: optr.c,v 1.43 2019/03/01 16:42:11 christos Exp $");
+__RCSID("$NetBSD: optr.c,v 1.44 2022/03/14 18:38:11 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -344,9 +344,10 @@ allocfsent(const struct fstab *fs)
 	new->fs_file = xstrdup(fs->fs_file);
 	new->fs_type = xstrdup(fs->fs_type);
 	new->fs_spec = xmalloc(FILENAME_MAX);
-	if (getfsspecname(new->fs_spec, FILENAME_MAX, fs->fs_spec) == NULL)
-		quite(errno, "can't resolve mount point %s (%s)",
-		fs->fs_spec, new->fs_spec);
+	if (getfsspecname(new->fs_spec, FILENAME_MAX, fs->fs_spec) == NULL) {
+		free(new);
+		return NULL;
+	}
 	new->fs_passno = fs->fs_passno;
 	new->fs_freq = fs->fs_freq;
 	return new;
@@ -384,6 +385,9 @@ getfstab(void)
 			continue;
 #endif
 		fs = allocfsent(fs);
+		if (fs == NULL)
+			continue;
+
 		pf = (struct pfstab *)xmalloc(sizeof (*pf));
 		pf->pf_fstab = fs;
 		SLIST_INSERT_HEAD(&table, pf, pf_list);



CVS commit: src/sbin/dump

2022-03-14 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Mar 14 18:38:11 UTC 2022

Modified Files:
src/sbin/dump: optr.c

Log Message:
Silently ignore fstab entries with NAME= entries that cannot be resolved.
Fixes PR 56249.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sbin/dump/optr.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/usb

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 16:14:11 UTC 2022

Modified Files:
src/sys/dev/usb: umidi.c

Log Message:
umidi(4): Bail early if no endpoints.

kmem_alloc is unhappy with zero-size allocation.

Reported-by: syzbot+483b984480c295979...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/usb/umidi.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/usb/umidi.c
diff -u src/sys/dev/usb/umidi.c:1.84 src/sys/dev/usb/umidi.c:1.85
--- src/sys/dev/usb/umidi.c:1.84	Sun Aug  8 20:50:12 2021
+++ src/sys/dev/usb/umidi.c	Mon Mar 14 16:14:11 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: umidi.c,v 1.84 2021/08/08 20:50:12 andvar Exp $	*/
+/*	$NetBSD: umidi.c,v 1.85 2022/03/14 16:14:11 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2012, 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.84 2021/08/08 20:50:12 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.85 2022/03/14 16:14:11 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -778,6 +778,8 @@ alloc_all_endpoints_fixed_ep(struct umid
 
 	fp = umidi_get_quirk_data_from_type(sc->sc_quirk,
 	UMQ_TYPE_FIXED_EP);
+	if (fp->num_in_ep == 0 && fp->num_out_ep == 0)
+		return USBD_INVAL;
 	sc->sc_out_num_jacks = 0;
 	sc->sc_in_num_jacks = 0;
 	sc->sc_out_num_endpoints = fp->num_out_ep;
@@ -934,6 +936,8 @@ alloc_all_endpoints_yamaha(struct umidi_
 		sc->sc_in_num_jacks = 0;
 	}
 	sc->sc_endpoints_len = UMIDI_ENDPOINT_SIZE(sc);
+	if (sc->sc_endpoints_len == 0)
+		return USBD_INVAL;
 	sc->sc_endpoints = kmem_zalloc(sc->sc_endpoints_len, KM_SLEEP);
 	if (sc->sc_out_num_endpoints) {
 		sc->sc_out_ep = sc->sc_endpoints;



CVS commit: src/sys/dev/usb

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 16:14:11 UTC 2022

Modified Files:
src/sys/dev/usb: umidi.c

Log Message:
umidi(4): Bail early if no endpoints.

kmem_alloc is unhappy with zero-size allocation.

Reported-by: syzbot+483b984480c295979...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/usb/umidi.c

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



Re: CVS commit: src/etc

2022-03-14 Thread Simon Burge
Hi Alex,

Alexander Nasonov wrote:

> Simon Burge wrote:
> > Why don't we just mount all the ZFS filesystems in mountcritlocal?
>
> Future versions may require loading of encryption keys over kerberos
> or a special pam module to decrypt /home/$USER.

How is this different to the existing "zfs mount -a" that
/etc/rc.d/mountall does?  Would there be new rc.d scripts between
mountcritlocal and mountall ?

Cheers,
Simon.


CVS commit: src/sys/dev/pci

2022-03-14 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Mar 14 12:22:02 UTC 2022

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

Log Message:
virtio_pci_match: add TODO about PCI Revision ID.

The standard says:

  Transitional devices MUST have a PCI Revision ID of 0.

  Non-transitional devices SHOULD have a PCI Revision ID of 1 or higher.
  Drivers MUST match any PCI Revision ID value.

so we must not check the revision id for non-transitional devices.
The code in attach relies on the revision being specifically(NB!) 1 so
this calls for a revision, but I can't test this properly at the
moment, so just leave a reminder.  Comment change only.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/virtio_pci.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/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.33 src/sys/dev/pci/virtio_pci.c:1.34
--- src/sys/dev/pci/virtio_pci.c:1.33	Thu Oct 28 01:36:43 2021
+++ src/sys/dev/pci/virtio_pci.c	Mon Mar 14 12:22:02 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.33 2021/10/28 01:36:43 yamaguchi Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.34 2022/03/14 12:22:02 uwe Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.33 2021/10/28 01:36:43 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.34 2022/03/14 12:22:02 uwe Exp $");
 
 #include 
 #include 
@@ -196,16 +196,23 @@ virtio_pci_match(device_t parent, cfdata
 	pa = (struct pci_attach_args *)aux;
 	switch (PCI_VENDOR(pa->pa_id)) {
 	case PCI_VENDOR_QUMRANET:
+		/* Transitional devices MUST have a PCI Revision ID of 0. */
 		if (((PCI_PRODUCT_QUMRANET_VIRTIO_1000 <=
 		  PCI_PRODUCT(pa->pa_id)) &&
 		 (PCI_PRODUCT(pa->pa_id) <=
 		  PCI_PRODUCT_QUMRANET_VIRTIO_103F)) &&
 	  PCI_REVISION(pa->pa_class) == 0)
 			return 1;
+		/*
+		 * Non-transitional devices SHOULD have a PCI Revision
+		 * ID of 1 or higher.  Drivers MUST match any PCI
+		 * Revision ID value.
+		 */
 		if (((PCI_PRODUCT_QUMRANET_VIRTIO_1040 <=
 		  PCI_PRODUCT(pa->pa_id)) &&
 		 (PCI_PRODUCT(pa->pa_id) <=
 		  PCI_PRODUCT_QUMRANET_VIRTIO_107F)) &&
+		  /* XXX: TODO */
 		  PCI_REVISION(pa->pa_class) == 1)
 			return 1;
 		break;



CVS commit: src/sys/dev/pci

2022-03-14 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Mar 14 12:22:02 UTC 2022

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

Log Message:
virtio_pci_match: add TODO about PCI Revision ID.

The standard says:

  Transitional devices MUST have a PCI Revision ID of 0.

  Non-transitional devices SHOULD have a PCI Revision ID of 1 or higher.
  Drivers MUST match any PCI Revision ID value.

so we must not check the revision id for non-transitional devices.
The code in attach relies on the revision being specifically(NB!) 1 so
this calls for a revision, but I can't test this properly at the
moment, so just leave a reminder.  Comment change only.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/virtio_pci.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

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 12:02:19 UTC 2022

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

Log Message:
syscall(2): Provide better attribution for biglock slippage.

This adds a small overhead to the syscall path, but only when invoked
via the syscall(2) syscall, for which stack traces generally don't
print the actual syscall number in question so the better attribution
may make a difference.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/sys_syscall.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/sys_syscall.c
diff -u src/sys/kern/sys_syscall.c:1.13 src/sys/kern/sys_syscall.c:1.14
--- src/sys/kern/sys_syscall.c:1.13	Sat Feb  8 07:07:07 2020
+++ src/sys/kern/sys_syscall.c	Mon Mar 14 12:02:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_syscall.c,v 1.13 2020/02/08 07:07:07 maxv Exp $	*/
+/*	$NetBSD: sys_syscall.c,v 1.14 2022/03/14 12:02:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_syscall.c,v 1.13 2020/02/08 07:07:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_syscall.c,v 1.14 2022/03/14 12:02:19 riastradh Exp $");
 
 #include 
 #include 
@@ -44,6 +44,19 @@ __KERNEL_RCSID(0, "$NetBSD: sys_syscall.
 
 #define CONCAT(a,b) __CONCAT(a,b)
 
+static void
+CONCAT(SYS_SYSCALL, _biglockcheck)(struct proc *p, int code)
+{
+
+#ifdef DIAGNOSTIC
+   kpreempt_disable(); /* make curcpu() stable */
+   KASSERTMSG(curcpu()->ci_biglock_count == 0,
+   "syscall %ld of emul %s leaked %d kernel locks",
+   (long)code, p->p_emul->e_name, curcpu()->ci_biglock_count);
+   kpreempt_enable();
+#endif
+}
+
 int
 SYS_SYSCALL(struct lwp *l, const struct CONCAT(SYS_SYSCALL, _args) *uap,
 register_t *rval)
@@ -73,8 +86,11 @@ SYS_SYSCALL(struct lwp *l, const struct 
 	if (__predict_false(callp->sy_flags & SYCALL_INDIRECT))
 		return ENOSYS;
 
-	if (__predict_true(!p->p_trace_enabled))
-		return sy_call(callp, l, &uap->args, rval);
+	if (__predict_true(!p->p_trace_enabled)) {
+		error = sy_call(callp, l, &uap->args, rval);
+		CONCAT(SYS_SYSCALL, _biglockcheck)(p, code);
+		return error;
+	}
 
 #ifdef NETBSD32_SYSCALL
 	narg = callp->sy_narg;
@@ -87,6 +103,7 @@ SYS_SYSCALL(struct lwp *l, const struct 
 		return error;
 	error = sy_call(callp, l, &uap->args, rval);
 	trace_exit(code, callp, &uap->args, rval, error);
+	CONCAT(SYS_SYSCALL, _biglockcheck)(p, code);
 	return error;
 
 	#undef TRACE_ARGS



CVS commit: src/sys/kern

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 12:02:19 UTC 2022

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

Log Message:
syscall(2): Provide better attribution for biglock slippage.

This adds a small overhead to the syscall path, but only when invoked
via the syscall(2) syscall, for which stack traces generally don't
print the actual syscall number in question so the better attribution
may make a difference.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/sys_syscall.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/audio

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 11:47:34 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Membar audit.

Won't affect anything on x86 because atomic r/m/w operations are
always full sequential consistency barriers, but might potentially
fix problems on, e.g., arm.

Note 1: I'm not clear on why the track lock is a bespoke mutex made
out of an atomic -- why not just mutex(9)?

Note 2: I'm not convinced the audio_mlog_flush synchronization is
correct; what happens if the softint runs on two CPUs at the same
time and swaps mlog_wpage simultaneously?

Note 3: Should maybe use atomic_load/store_relaxed for mlog_full and
mlog_drop, and atomic_inc/dec for mlog_refs.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 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: src/sys/dev/audio

2022-03-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 14 11:47:34 UTC 2022

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
audio(4): Membar audit.

Won't affect anything on x86 because atomic r/m/w operations are
always full sequential consistency barriers, but might potentially
fix problems on, e.g., arm.

Note 1: I'm not clear on why the track lock is a bespoke mutex made
out of an atomic -- why not just mutex(9)?

Note 2: I'm not convinced the audio_mlog_flush synchronization is
correct; what happens if the softint runs on two CPUs at the same
time and swaps mlog_wpage simultaneously?

Note 3: Should maybe use atomic_load/store_relaxed for mlog_full and
mlog_drop, and atomic_inc/dec for mlog_refs.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 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.113 src/sys/dev/audio/audio.c:1.114
--- src/sys/dev/audio/audio.c:1.113	Sun Dec 12 13:05:13 2021
+++ src/sys/dev/audio/audio.c	Mon Mar 14 11:47:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.113 2021/12/12 13:05:13 andvar Exp $	*/
+/*	$NetBSD: audio.c,v 1.114 2022/03/14 11:47:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.113 2021/12/12 13:05:13 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.114 2022/03/14 11:47:33 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -162,6 +162,7 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -272,13 +273,14 @@ audio_mlog_flush(void)
 	/* Nothing to do if already in use ? */
 	if (atomic_swap_32(&mlog_inuse, 1) == 1)
 		return;
+	membar_enter();
 
 	int rpage = mlog_wpage;
 	mlog_wpage ^= 1;
 	mlog_buf[mlog_wpage][0] = '\0';
 	mlog_used = 0;
 
-	atomic_swap_32(&mlog_inuse, 0);
+	atomic_store_reease(&mlog_inuse, 0);
 
 	if (mlog_buf[rpage][0] != '\0') {
 		printf("%s", mlog_buf[rpage]);
@@ -308,6 +310,7 @@ audio_mlog_printf(const char *fmt, ...)
 		mlog_drop++;
 		return;
 	}
+	membar_enter();
 
 	va_start(ap, fmt);
 	len = vsnprintf(
@@ -321,7 +324,7 @@ audio_mlog_printf(const char *fmt, ...)
 		mlog_full++;
 	}
 
-	atomic_swap_32(&mlog_inuse, 0);
+	atomic_store_release(&mlog_inuse, 0);
 
 	if (mlog_sih)
 		softint_schedule(mlog_sih);
@@ -1652,7 +1655,11 @@ audio_track_waitio(struct audio_softc *s
 static __inline bool
 audio_track_lock_tryenter(audio_track_t *track)
 {
-	return (atomic_cas_uint(&track->lock, 0, 1) == 0);
+
+	if (atomic_swap_uint(&track->lock, 1) != 0)
+		return false;
+	membar_enter();
+	return true;
 }
 
 /*
@@ -1661,9 +1668,10 @@ audio_track_lock_tryenter(audio_track_t 
 static __inline void
 audio_track_lock_enter(audio_track_t *track)
 {
+
 	/* Don't sleep here. */
 	while (audio_track_lock_tryenter(track) == false)
-		;
+		SPINLOCK_BACKOFF_HOOK;
 }
 
 /*
@@ -1672,7 +1680,8 @@ audio_track_lock_enter(audio_track_t *tr
 static __inline void
 audio_track_lock_exit(audio_track_t *track)
 {
-	atomic_swap_uint(&track->lock, 0);
+
+	atomic_store_release(&track->lock, 0);
 }
 
 



CVS commit: src/sys/net80211

2022-03-14 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Mar 14 07:05:31 UTC 2022

Modified Files:
src/sys/net80211: _ieee80211.h

Log Message:
Additional channel flags.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/net80211/_ieee80211.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/net80211/_ieee80211.h
diff -u src/sys/net80211/_ieee80211.h:1.10 src/sys/net80211/_ieee80211.h:1.11
--- src/sys/net80211/_ieee80211.h:1.10	Thu Mar 21 18:30:09 2013
+++ src/sys/net80211/_ieee80211.h	Mon Mar 14 07:05:31 2022
@@ -116,17 +116,47 @@ extern const struct ieee80211_channel ie
 
 /* bits 0-3 are for private use by drivers */
 /* channel attributes */
-#define	IEEE80211_CHAN_TURBO	0x0010	/* Turbo channel */
-#define	IEEE80211_CHAN_CCK	0x0020	/* CCK channel */
-#define	IEEE80211_CHAN_OFDM	0x0040	/* OFDM channel */
-#define	IEEE80211_CHAN_2GHZ	0x0080	/* 2 GHz spectrum channel. */
-#define	IEEE80211_CHAN_5GHZ	0x0100	/* 5 GHz spectrum channel */
-#define	IEEE80211_CHAN_PASSIVE	0x0200	/* Only passive scan allowed */
-#define	IEEE80211_CHAN_DYN	0x0400	/* Dynamic CCK-OFDM channel */
-#define	IEEE80211_CHAN_GFSK	0x0800	/* GFSK channel (FHSS PHY) */
-#define	IEEE80211_CHAN_GSM	0x1000	/* 900 MHz spectrum channel */
-#define	IEEE80211_CHAN_HALF	0x4000	/* Half rate channel */
-#define	IEEE80211_CHAN_QUARTER	0x8000	/* Quarter rate channel */
+#define	IEEE80211_CHAN_TURBO	0x0010	/* Turbo channel */
+#define	IEEE80211_CHAN_CCK	0x0020	/* CCK channel */
+#define	IEEE80211_CHAN_OFDM	0x0040	/* OFDM channel */
+#define	IEEE80211_CHAN_2GHZ	0x0080	/* 2 GHz spectrum channel. */
+#define	IEEE80211_CHAN_5GHZ	0x0100	/* 5 GHz spectrum channel */
+#define	IEEE80211_CHAN_PASSIVE	0x0200	/* Only passive scan allowed */
+#define	IEEE80211_CHAN_DYN	0x0400	/* Dynamic CCK-OFDM channel */
+#define	IEEE80211_CHAN_GFSK	0x0800	/* GFSK channel (FHSS PHY) */
+#define	IEEE80211_CHAN_GSM	0x1000	/* 900 MHz spectrum channel */
+#define	IEEE80211_CHAN_HALF	0x4000	/* Half rate channel */
+#define	IEEE80211_CHAN_QUARTER	0x8000	/* Quarter rate channel */
+#define	IEEE80211_CHAN_HT20	0x0001	/* HT 20 channel */
+#define	IEEE80211_CHAN_HT40U	0x0002	/* HT 40 channel w/ ext	above */
+#define	IEEE80211_CHAN_HT40D	0x0004	/* HT 40 channel w/ ext	below */
+#define	IEEE80211_CHAN_DFS	0x0008	/* DFS required */
+#define	IEEE80211_CHAN_4MSXMIT	0x0010	/* 4ms limit on frame length */
+#define	IEEE80211_CHAN_NOADHOC	0x0020	/* adhoc mode not allowed */
+#define	IEEE80211_CHAN_NOHOSTAP	0x0040	/* hostap mode not allowed */
+#define	IEEE80211_CHAN_11D	0x0080	/* 802.11d required */
+#define	IEEE80211_CHAN_VHT20	0x0100	/* VHT20 channel */
+#define	IEEE80211_CHAN_VHT40U	0x0200	/* VHT40 channel, ext above */
+#define	IEEE80211_CHAN_VHT40D	0x0400	/* VHT40 channel, ext below */
+#define	IEEE80211_CHAN_VHT80	0x0800	/* VHT80 channel */
+#define	IEEE80211_CHAN_VHT80_80	0x1000	/* VHT80+80 channel */
+#define	IEEE80211_CHAN_VHT160	0x2000	/* VHT160 channel */
+#define	IEEE80211_CHAN_HT20	0x0001	/* HT 20 channel */
+#define	IEEE80211_CHAN_HT40U	0x0002	/* HT 40 channel w/ ext	above */
+#define	IEEE80211_CHAN_HT40D	0x0004	/* HT 40 channel w/ ext	below */
+#define	IEEE80211_CHAN_DFS	0x0008	/* DFS required */
+#define	IEEE80211_CHAN_4MSXMIT	0x0010	/* 4ms limit on frame length */
+#define	IEEE80211_CHAN_NOADHOC	0x0020	/* adhoc mode not allowed */
+#define	IEEE80211_CHAN_NOHOSTAP	0x0040	/* hostap mode not allowed */
+#define	IEEE80211_CHAN_11D	0x0080	/* 802.11d required */
+
+#define	IEEE80211_CHAN_HT40	(IEEE80211_CHAN_HT40U | IEEE80211_CHAN_HT40D)
+#define	IEEE80211_CHAN_HT	(IEEE80211_CHAN_HT20 | IEEE80211_CHAN_HT40)
+
+#define	IEEE80211_CHAN_VHT40	(IEEE80211_CHAN_VHT40U | IEEE80211_CHAN_VHT40D)
+#define	IEEE80211_CHAN_VHT	(IEEE80211_CHAN_VHT20 | IEEE80211_CHAN_VHT40 \
+| IEEE80211_CHAN_VHT80 | IEEE80211_CHAN_VHT80_80 \
+| IEEE80211_CHAN_VHT160)
 
 /*
  * Useful combinations of channel characteristics.



CVS commit: src/sys/net80211

2022-03-14 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Mar 14 07:05:31 UTC 2022

Modified Files:
src/sys/net80211: _ieee80211.h

Log Message:
Additional channel flags.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/net80211/_ieee80211.h

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