FreeBSD/src d76523asys/dev/speaker spkr.c

speaker(4): enable concurrent opens from different threads

Prior to this patch, a thread would get EBUSY on open(2) if another
thread had the speaker open.

With this patch, two or more threads/processes can use the speaker
device at the same time. When two or more threads write to the speaker
concurrently, individual melodies--single strings, as written by
write(2) or ioctl(2) with command SPKRTONE/SPKRTUNE--are played
atomically.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1922
DeltaFile
+125-100sys/dev/speaker/spkr.c
+125-1001 files

FreeBSD/src 690ef95sys/dev/speaker spkr.c

speaker(4): move static data to bss

Signed-off-by: Raphael Poss <knz at thaumogen.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1922
DeltaFile
+2-2sys/dev/speaker/spkr.c
+2-21 files

FreeBSD/src 03a515esys/dev/speaker spkr.c

speaker(4): Update outdated comments

The comments in tone() were referring to pre-2000 logic that does not
exist any more. This patch updates them.

Signed-off-by: Raphael Poss <knz at thaumogen.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1922
DeltaFile
+10-4sys/dev/speaker/spkr.c
+10-41 files

FreeBSD/src a80ec2bsys/dev/speaker spkr.c

speaker(4): make spkropen thread-safe

Signed-off-by: Raphael Poss <knz at thaumogen.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1922
DeltaFile
+4-5sys/dev/speaker/spkr.c
+4-51 files

FreeBSD/src 43b7cf4sys/dev/speaker spkr.c

speaker(4): drop NEEDGIANT

When the frequency configuration logic was moved to clock.c in 2008, a
mutex lock was added there (timer_spkr_setfreq) to serialize accesses
to the I/O register.

Since then, no more calls to disable/enable_intr were needed in spkr.c
than they were needed in the other callers to the same timer_spkr
functions in syscons / kern_cons, that is, not at all. This is because
there are no other accesses remaining in the kernel to the i8254
timers after boot than through clock.c.

For context, see commits
e46598588587b4897f6604489364f83fffd4d033
and
93f5134aaf829826dbcbea457bfeb27389761854.

Signed-off-by: Raphael Poss <knz at thaumogen.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1922
DeltaFile
+1-3sys/dev/speaker/spkr.c
+1-31 files

FreeBSD/src e2199dcsys/dev/speaker spkr.c

speaker(4): one ioctl / write at a time

If two processes are holding a spkr fd, we want orderly access to the
allocated tone buffer and the speaker itself.

Signed-off-by: Raphael Poss <knz at thaumogen.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1922
DeltaFile
+25-6sys/dev/speaker/spkr.c
+25-61 files

FreeBSD/src 70ae0c4share/examples/perfmon perfmon.c README, share/man/man4/man4.i386 perfmon.4

i386: Remove perfmon performance monitoring facility

Remove the perfmon performance monitoring facility that was for Intel
Pentium and Pentium Pro processors.

Reviewed by: imp,mhorne,emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/2155
DeltaFile
+0-402sys/i386/i386/perfmon.c
+0-253sys/i386/include/perfmon.h
+0-211share/man/man4/man4.i386/perfmon.4
+0-191share/examples/perfmon/perfmon.c
+0-23share/examples/perfmon/README
+0-8share/examples/perfmon/Makefile
+0-1,0889 files not shown
+8-1,12015 files

FreeBSD/src 576c6e9lib/libpmc libpmc.c pmc.ibs.3, sys/dev/hwpmc hwpmc_ibs.h hwpmc_ibs.c

pmc: Implement the feature bits for recent Zen 4/5

Ensure that the optional MSRs and the user flags are guarded by the
cpuid feature flags.  This prevents the user from triggering undefined
behavior or crashes on AMD processors where some of these features are
not present.  As part of this, I added the branch target and DATA4 MSRs
to the IBS op state as those are only present on a subset of the Zen
chips that I have tested.

Reviewed by:    mhorne
Sponsored by:   Netflix
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2133
DeltaFile
+28-1lib/libpmc/libpmc.c
+9-6sys/dev/hwpmc/hwpmc_ibs.h
+9-3sys/dev/hwpmc/hwpmc_ibs.c
+6-4lib/libpmc/pmc.ibs.3
+52-144 files

FreeBSD/src bc28aaf. Makefile.inc1

Makefile.inc1: Don't mark GCC broken for riscv64

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D54969

(cherry picked from commit dbe9fa0be1d627522a532160f6f8780701b86c72)
DeltaFile
+0-3Makefile.inc1
+0-31 files

FreeBSD/src 3b0fc44usr.sbin/bhyve net_backend_slirp.c

bhyve/slirp: Avoid a nested declaration of environ

Fixes:  0e62ebd20172 ("bhyve: Move the slirp backend out into a separate process")
(cherry picked from commit bac572b2b1c9aec0ebfd3ae1fd02b314984cb716)
DeltaFile
+2-1usr.sbin/bhyve/net_backend_slirp.c
+2-11 files

FreeBSD/src 3a86c76sys/sys time.h

sys/time: appease gcc -Wtype-limits

In environments where time_t is 32 bits, including the 32-bit library
build on amd64, the overflow being tested for cannot happen, and gcc
complains with -Wtype-limits, causing the gcc build to fail.  Work
around this by ifdef'ing out the saturation code on i386.

Reviewed by:    imp, jfree
Discussed with: markj
Fixes:  e3799530b3ba ("sys/time: Add saturating sbt conversions")
Differential Revision:  https://reviews.freebsd.org/D56369
(cherry picked from commit 00dccc3164c6dff38350a1baeeea7238acf2efc3)
DeltaFile
+4-0sys/sys/time.h
+4-01 files

FreeBSD/src 7a2de81tests/sys/fs/fusefs rename.cc

tests/fusefs: appease gcc -Wcast-qual

Fix gcc build error.

Reviewed by:    asomers, kib
Fixes:  7e68af7ce2c1 ("fusefs: redo vnode attribute locking")
Differential Revision:  https://reviews.freebsd.org/D56370
(cherry picked from commit 0c09c6527b16953d355125bee7a839f743a39dad)
DeltaFile
+2-2tests/sys/fs/fusefs/rename.cc
+2-21 files

FreeBSD/src 9c4106clib/libsysdecode utrace.c, libexec/rtld-elf rtld.c rtld_utrace.h

rtld: silence clang's unterminated-string-initialization warning

Since the initializer is used in other places where we can't just
replace it with a char-by-char initializer, this adds a macro for the
nonstring attribute (match the linuxkpi definition).

Reviewed by:    emaste, jhb
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D52535

(cherry picked from commit 86f325711c07b723b85c031d581d0a5c1a0964f3)
DeltaFile
+2-1lib/libsysdecode/utrace.c
+2-1libexec/rtld-elf/rtld.c
+1-1libexec/rtld-elf/rtld_utrace.h
+5-33 files

FreeBSD/src dadecd7stand/libsa Makefile

stand: Add compiler builtins needed by GCC for RISC-V

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D54963

(cherry picked from commit fe45651224bea513c7db88abbc53bd1241ab442f)
DeltaFile
+3-0stand/libsa/Makefile
+3-01 files

FreeBSD/src c9501b9sys/powerpc/powerpc vm_machdep.c exec_machdep.c

powerpc: Fix alignment of initial PCB on kstack

Commit cc81c44dd806737f98b4fd4094674dd71c8749f3 aimed to consolidate
duplicated code between the Book-E and AIM backends.  For
cpu_thread_alloc cpu_thread_alloc and cpu_fork it used the AIM
functions which used a bogus alignment mask (~0x2f).  The Book-E
functions used a proper alignment mask (~0x3f).  The AIM functions
appear to have been busted since they were first imported in commit
919cb3362fded33aca682a6ac57777f8fff86e36.

To fix, use the Book-E mask which requests 64 byte alignment.
Probably this was harmless in practice since td_kstack is page aligned
and struct pcb is probably a multiple of 32 bytes in size, so the 0x10
bit should have been clear anyway.

Reviewed by:    fuz, jhibbits
Fixes:          cc81c44dd806 ("Unify ABI-related bits of the Book-E and AIM...")
Effort:         CHERI upstreaming
Sponsored by:   AFRL, DARPA

    [2 lines not shown]
DeltaFile
+1-1sys/powerpc/powerpc/vm_machdep.c
+1-1sys/powerpc/powerpc/exec_machdep.c
+2-22 files

FreeBSD/src 251267asys/arm/arm machdep.c, sys/arm/include machdep.h

arm: Make init_proc0 static

This function is not used outside of machdep.c and is already static
on arm64 and riscv.

Reviewed by:    imp
Effort:         CHERI upstreaming
Sponsored by:   AFRL, DARPA
Differential Revision:  https://reviews.freebsd.org/D54838

(cherry picked from commit 05609c5eff27ea7b382237bd2a937c01c1ceb59a)
DeltaFile
+1-1sys/arm/arm/machdep.c
+0-1sys/arm/include/machdep.h
+1-22 files

FreeBSD/src d6e1660sys/sys sdt.h

sdt: Use the "cc" operand modifier for the address of probes for GCC 15+

This is required for GCC on RISC-V.  The GCC 15 docs claim that "cc" is
similar to "c" except that it "tries harder".

NB: I have not yet found a way to make the DTrace probes compile on
RISC-V with older versions of GCC.

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D54964

(cherry picked from commit f7144a9c4a11214a71a3091ce1b232a8243b83ea)
DeltaFile
+4-0sys/sys/sdt.h
+4-01 files

FreeBSD/src ec53704stand/efi/loader/arch/riscv riscv.ldscript

stand: Use the correct OUTPUT_ARCH in the linker script for RISC-V

Compare to the OUTPUT_ARCH in sys/conf/ldscript.riscv.

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D54962

(cherry picked from commit 2e8ef82b3418b41e7c54e2dbd16df0edb3cb8376)
DeltaFile
+1-1stand/efi/loader/arch/riscv/riscv.ldscript
+1-11 files

FreeBSD/src 27a7b98lib/libfetch common.c

libfetch: Fix -Wunterminated-string-initialization

This defaults to an error in clang HEAD, use a char-by-char
initializer instead.

Reviewed by:    emaste, jhb
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D52532

(cherry picked from commit 79f578531f21aa57307cbffd858a8a89e562aa5c)
DeltaFile
+1-1lib/libfetch/common.c
+1-11 files

FreeBSD/src 91cdb8fsys/conf kern.mk

riscv: Enable the zifencei extension explicitly in -march

clang is more tolerant and implies this extension whereas GCC is
stricter and requires it to be included.

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D54965

(cherry picked from commit 31b259049e2b932ae6527d1dc850c2bec58e94e0)
DeltaFile
+1-1sys/conf/kern.mk
+1-11 files

FreeBSD/src 441beb3contrib/netbsd-tests/lib/libc/regex t_regex_att.c

netbsd-tests t_regex_att: Use __nonstring for a non-string constant

Fixes the following warning from GCC 15:

contrib/netbsd-tests/lib/libc/regex/t_regex_att.c:54:30: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (4 chars into 3 available) [-Werror=unterminated-string-initialization]
   54 | static const char delim[3] = "\\\\\0";
      |                              ^~~~~~~~

Reviewed by:    ngie, imp, dim
Differential Revision:  https://reviews.freebsd.org/D54866

(cherry picked from commit 2dea50a661b903513efc42e270c4e6f5c2b89bc3)
DeltaFile
+1-1contrib/netbsd-tests/lib/libc/regex/t_regex_att.c
+1-11 files

FreeBSD/src f5b85ccsys/amd64/amd64 vm_machdep.c, sys/i386/i386 vm_machdep.c

sys: Use __is_aligned and __align_down for some kstack alignment operations

Reviewed by:    kib, jhibbits
Effort:         CHERI upstreaming
Sponsored by:   AFRL, DARPA
Differential Revision:  https://reviews.freebsd.org/D54840

(cherry picked from commit 093fffa296d009de8cebf713a58ddbf876f05c5c)
DeltaFile
+2-3sys/powerpc/powerpc/machdep.c
+2-2sys/powerpc/powerpc/exec_machdep.c
+2-2sys/powerpc/powerpc/vm_machdep.c
+1-2sys/amd64/amd64/vm_machdep.c
+2-1sys/i386/i386/vm_machdep.c
+9-105 files

FreeBSD/src 9fefd51sys/conf files.riscv

riscv: Add ffs.c and ffsdi2.c

These are only needed for GCC, but it doesn't hurt to include these
always.

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D54968

(cherry picked from commit f4c40a5acb16e542934ed17ee475183b87420eae)
DeltaFile
+2-0sys/conf/files.riscv
+2-01 files

FreeBSD/src 6ca22d1usr.sbin/wlanstat Makefile

wlanstat: Drop unneeded bsd.compiler.mk from Makefile

No functional change, but downstream in CheriBSD this was causing a
link error as the Makefile was overriding CFLAGS set via a side effect
of bsd.compiler.mk.

Reviewed by:    bz, brooks, emaste
Sponsored by:   AFRL, DARPA
Differential Revision:  https://reviews.freebsd.org/D54894

(cherry picked from commit 6e82cb29066765c03408a81c9bec4ed0d99cab81)
DeltaFile
+0-2usr.sbin/wlanstat/Makefile
+0-21 files

FreeBSD/src 66b5d1flib/libthr/thread thr_printf.c

libthr: fix -Wunterminated-string-initialization

Reviewed by:    jhb, emaste
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D52528

(cherry picked from commit 4cfc7de13f110563463c15be99690c6fe7b8676a)
DeltaFile
+1-2lib/libthr/thread/thr_printf.c
+1-21 files

FreeBSD/src d100ff6sys/libkern ffsdi2.c ffs.c

libkern: Add libcalls for ffs and __ffsdi2

These are needed when compiling a RISC-V kernel with GCC which does
not inline __builtin_ffs*.

The __ffsdi2 is adapated from the previous ffsl.c.

This partially reverts commit f4db342d44198973c1c7b9005d0c5683a582707e.

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D54967

(cherry picked from commit 4c822dd4a15c533c08271b2286da949fffafc89e)
DeltaFile
+47-0sys/libkern/ffsdi2.c
+47-0sys/libkern/ffs.c
+1-0sys/libkern/quad.h
+95-03 files

FreeBSD/src 63e4b5cusr.bin/kyua Makefile

kyua: Workaround unclear warning from GCC

GCC 15 does not like a push_back() invocation in utils::find_core()
and incorrectly believes libc++ will free a non-heap pointer.  Disable
the warning to pacify GCC.

In function 'void std::__1::__libcpp_operator_delete(_Args ...) [with _Args = {void*, long unsigned int}]',
    inlined from 'void std::__1::__do_deallocate_handle_size(void*, size_t, _Args ...) [with _Args = {}]' at /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/new:298:39,
    inlined from 'void std::__1::__libcpp_deallocate(void*, size_t, size_t)' at /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/new:311:39,
    inlined from 'void std::__1::allocator<_Tp>::deallocate(_Tp*, size_t) [with _Tp = utils::fs::path]' at /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/__memory/allocator.h:132:31,
    inlined from 'static void std::__1::allocator_traits<_Alloc>::deallocate(allocator_type&, pointer, size_type) [with _Alloc = std::__1::allocator<utils::fs::path>]' at /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/__memory/allocator_traits.h:314:19,
    inlined from 'std::__1::__split_buffer<_Tp, _Allocator>::~__split_buffer() [with _Tp = utils::fs::path; _Allocator = std::__1::allocator<utils::fs::path>&]' at /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/__split_buffer:365:31,
    inlined from 'std::__1::vector<_Tp, _Alloc>::pointer std::__1::vector<_Tp, _Alloc>::__push_back_slow_path(_Up&&) [with _Up = utils::fs::path; _Tp = utils::fs::path; _Allocator = std::__1::allocator<utils::fs::path>]' at /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/vector:1504:1,
    inlined from 'void std::__1::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = utils::fs::path; _Allocator = std::__1::allocator<utils::fs::path>]' at /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/vector:1526:34,
    inlined from 'utils::optional<utils::fs::path> utils::find_core(const fs::path&, const process::status&, const fs::path&)' at contrib/kyua/utils/stacktrace.cpp:217:25:
/usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/new:274:38: error: 'void operator delete(void*, size_t)' called on pointer '<unknown>' with nonzero offset [24, 9223372036854775807] [-Werror=free-nonheap-object]
  274 |   __builtin_operator_delete(__args...);
      |                                      ^
In function 'void* std::__1::__libcpp_operator_new(_Args ...) [with _Args = {long unsigned int}]',

    [15 lines not shown]
DeltaFile
+2-0usr.bin/kyua/Makefile
+2-01 files

FreeBSD/src 628d378share/mk bsd.sys.mk

bsd.sys.mk: Silence a few GCC warnings for C++

These warnings were already marked with -Wno-error=, but they trigger
so many false positives in libc++ headers to be utterly useless for
C++ code, so disable them entirely for C++.

Reviewed by:    imp, dim
Differential Revision:  https://reviews.freebsd.org/D54867

(cherry picked from commit 6fb87a1a6042887550571316fa9e539239f158d1)
DeltaFile
+6-0share/mk/bsd.sys.mk
+6-01 files

FreeBSD/src ff90e61sys/dev/acpica acpi.c acpi_battery.c

acpi: Add a function to deregister all ioctl commands using the same function

This simplifies detach/cleanup for drivers that add multiple ACPI ioctls.

Reviewed by:    imp
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D54420

(cherry picked from commit 5bd84c4f0d016a2ca87ee115370ec1e7802e6d8a)
DeltaFile
+15-0sys/dev/acpica/acpi.c
+1-7sys/dev/acpica/acpi_battery.c
+1-0sys/dev/acpica/acpiio.h
+17-73 files

FreeBSD/src 2d31369sys/dev/acpica acpi.c

acpi: Statically initialize acpi_ioctl_hooks

Reviewed by:    imp
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D54313

(cherry picked from commit 11757b1487e3e8ca0479dff5da0815b42aea3fe0)
DeltaFile
+6-11sys/dev/acpica/acpi.c
+6-111 files