Florian Walpen [Tue, 30 Jan 2024 15:07:57 +0000 (15:07 +0000)]
snd_hdspe(4): Per device sysctl for sample rate.
Some hardware setups require a specific sample rate due to devices being
connected to digital ports (AES, S/PDIF, ADAT). Add a per device sysctl
"sample_rate" to let the user override sample rate requests from the pcm
infrastructure, when needed.
Mark Johnston [Sun, 21 Jan 2024 15:19:42 +0000 (10:19 -0500)]
scsi_cd: Remove commented-out code
This is left over from before the implementation of asynchronous media
probing, which was committed in dd78f43259ef
("scsi_cd: make the media check asynchronous") quite a while ago now.
Mark Johnston [Tue, 30 Jan 2024 01:01:12 +0000 (20:01 -0500)]
scsi_cd: Maintain a periph reference during media checks
Otherwise nothing prevents the asynchronous media check state machine
from running after the periph has been destroyed, which can result in a
double free. Acquire the reference even when performing a synchronous
check, since that doesn't hurt and keeps things simpler.
PR: 276251
Reviewed by: imp
Fixes: dd78f43259ef ("scsi_cd: make the media check asynchronous")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43525
Andriy Gapon [Tue, 30 Jan 2024 06:45:01 +0000 (08:45 +0200)]
rdmsr_safe/wrmsr_safe: handle pcb_onfault nesting
rdmsr_safe and wrmsr_safe can be called while pcb_onfault is already
set, so the functions are modified to preserve the handler rather than
resetting it before returning.
One case where that happens is when AMD microcode update routine
is executed on a stack where copyin / copyout was already active.
Here is a sample panic message from a crash caused by resetting the
handler:
<118>Updating CPU Microcode...
Fatal trap 12: page fault while in kernel mode
cpuid = 3; apic id = 03
fault virtual address = 0x11ed0de6000
fault code = supervisor write data, page not present
instruction pointer = 0x20:0xffffffff80c2df03
stack pointer = 0x28:0xfffffe01ce4a4c70
frame pointer = 0x28:0xfffffe01ce4a4c70
code segment = base 0x0, limit 0xfffff, type 0x1b
= DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags = interrupt enabled, resume, IOPL = 0
current process = 117 (logger)
trap number = 12
panic: page fault
cpuid = 3
time = 1681462027
KDB: stack backtrace:
db_trace_self_wrapper() at 0xffffffff80615deb = db_trace_self_wrapper+0x2b/frame 0xfffffe01ce4a4830
kdb_backtrace() at 0xffffffff80943c77 = kdb_backtrace+0x37/frame 0xfffffe01ce4a48e0
vpanic() at 0xffffffff808f5fe5 = vpanic+0x185/frame 0xfffffe01ce4a4940
panic() at 0xffffffff808f5da3 = panic+0x43/frame 0xfffffe01ce4a49a0
trap_fatal() at 0xffffffff80c31849 = trap_fatal+0x379/frame 0xfffffe01ce4a4a00
trap_pfault() at 0xffffffff80c318b5 = trap_pfault+0x65/frame 0xfffffe01ce4a4a60
trap() at 0xffffffff80c30f5f = trap+0x29f/frame 0xfffffe01ce4a4b80
trap_check() at 0xffffffff80c31c29 = trap_check+0x29/frame 0xfffffe01ce4a4ba0
calltrap() at 0xffffffff80c07fd8 = calltrap+0x8/frame 0xfffffe01ce4a4ba0
--- trap 0xc, rip = 0xffffffff80c2df03, rsp = 0xfffffe01ce4a4c70, rbp = 0xfffffe01ce4a4c70 ---
copyout_nosmap_std() at 0xffffffff80c2df03 = copyout_nosmap_std+0x63/frame 0xfffffe01ce4a4c70
uiomove_faultflag() at 0xffffffff8095f0d5 = uiomove_faultflag+0xe5/frame 0xfffffe01ce4a4cb0
uiomove() at 0xffffffff8095efeb = uiomove+0xb/frame 0xfffffe01ce4a4cc0
pipe_read() at 0xffffffff80968860 = pipe_read+0x230/frame 0xfffffe01ce4a4d30
dofileread() at 0xffffffff809653cb = dofileread+0x8b/frame 0xfffffe01ce4a4d80
sys_read() at 0xffffffff80964fa0 = sys_read+0xc0/frame 0xfffffe01ce4a4df0
amd64_syscall() at 0xffffffff80c3221a = amd64_syscall+0x18a/frame 0xfffffe01ce4a4f30
fast_syscall_common() at 0xffffffff80c088eb = fast_syscall_common+0xf8/frame 0xfffffe01ce4a4f30
--- syscall (3, FreeBSD ELF64, read), rip = 0x11ece41cfaa, rsp = 0x11ecbec4908, rbp = 0x11ecbec4920 ---
Uptime: 41s
And another one:
Fatal trap 12: page fault while in kernel mode
cpuid = 4; apic id = 04
fault virtual address = 0x800a22000
fault code = supervisor write data, page not present
instruction pointer = 0x20:0xffffffff80b2c7ca
stack pointer = 0x28:0xfffffe01c55b5480
frame pointer = 0x28:0xfffffe01c55b5480
code segment = base 0x0, limit 0xfffff, type 0x1b
= DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags = interrupt enabled, resume, IOPL = 0
current process = 68418 (pfctl)
trap number = 12
panic: page fault
cpuid = 4
time = 1625184463
KDB: stack backtrace:
db_trace_self_wrapper() at 0xffffffff805c1e8b = db_trace_self_wrapper+0x2b/frame 0xfffffe01c55b5040
kdb_backtrace() at 0xffffffff808874b7 = kdb_backtrace+0x37/frame 0xfffffe01c55b50f0
vpanic() at 0xffffffff808449d8 = vpanic+0x188/frame 0xfffffe01c55b5150
panic() at 0xffffffff808445f3 = panic+0x43/frame 0xfffffe01c55b51b0
trap_fatal() at 0xffffffff80b300a5 = trap_fatal+0x375/frame 0xfffffe01c55b5210
trap_pfault() at 0xffffffff80b30180 = trap_pfault+0x80/frame 0xfffffe01c55b5280
trap() at 0xffffffff80b2f729 = trap+0x289/frame 0xfffffe01c55b5390
trap_check() at 0xffffffff80b304d9 = trap_check+0x29/frame 0xfffffe01c55b53b0
calltrap() at 0xffffffff80b0bb28 = calltrap+0x8/frame 0xfffffe01c55b53b0
--- trap 0xc, rip = 0xffffffff80b2c7ca, rsp = 0xfffffe01c55b5480, rbp = 0xfffffe01c55b5480 ---
copyout_nosmap_std() at 0xffffffff80b2c7ca = copyout_nosmap_std+0x15a/frame 0xfffffe01c55b5480
pfioctl() at 0xffffffff85539358 = pfioctl+0x4d28/frame 0xfffffe01c55b5940
devfs_ioctl() at 0xffffffff807176cf = devfs_ioctl+0xcf/frame 0xfffffe01c55b59a0
VOP_IOCTL_APV() at 0xffffffff80bb26e2 = VOP_IOCTL_APV+0x92/frame 0xfffffe01c55b59c0
VOP_IOCTL() at 0xffffffff80928014 = VOP_IOCTL+0x34/frame 0xfffffe01c55b5a10
vn_ioctl() at 0xffffffff80923330 = vn_ioctl+0xc0/frame 0xfffffe01c55b5b00
devfs_ioctl_f() at 0xffffffff80717bbe = devfs_ioctl_f+0x1e/frame 0xfffffe01c55b5b20
fo_ioctl() at 0xffffffff808abc6b = fo_ioctl+0xb/frame 0xfffffe01c55b5b30
kern_ioctl() at 0xffffffff808abc01 = kern_ioctl+0x1d1/frame 0xfffffe01c55b5b80
sys_ioctl() at 0xffffffff808ab982 = sys_ioctl+0x132/frame 0xfffffe01c55b5c50
syscallenter() at 0xffffffff80b30cc9 = syscallenter+0x159/frame 0xfffffe01c55b5ca0
amd64_syscall() at 0xffffffff80b309a5 = amd64_syscall+0x15/frame 0xfffffe01c55b5d30
fast_syscall_common() at 0xffffffff80b0c44e = fast_syscall_common+0xf8/frame 0xfffffe01c55b5d30
Warner Losh [Mon, 29 Jan 2024 23:57:19 +0000 (16:57 -0700)]
style(9): Note larger divergence than implied
Times have changed, and we've diverged somewhat from the original style
guide, while still keeping much of the flavor and flair of its spirit as
the C language has evolved over the last 30 years since 4.4 was
released.
Olivier Certner [Thu, 25 Jan 2024 22:25:10 +0000 (23:25 +0100)]
login_cap.h: Remove LOGIN_DEFPRI
This is an implementation detail which is likely to become irrelevant in
the future, as we move to not resetting the priority if the
corresponding capability is not present in the configuration file
('/etc/login.conf').
GitHub's code search and Google show no use of this public constant, and
it doesn't exist in OpenBSD and NetBSD.
So, remove this definition and its sole use in-tree.
PR: 276570 (exp-run)
Reviewed by: emaste
Approved by: emaste (mentor)
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D43609
Olivier Certner [Thu, 25 Jan 2024 22:10:40 +0000 (23:10 +0100)]
login_cap.h: Remove LOGIN_DEFUMASK
This public constant has not been used in-tree since 1997 (this was
noticed while working on previous commit "setusercontext(): umask: Set
it only once (in the common case)").
Since it was an implementation detail and GitHub's code search and
Google show no use of this symbol today, simply remove it.
PR: 276570 (exp-run)
Reviewed by: emaste, kib (earlier version, then part of D40344)
Approved by: emaste (mentor)
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D43608
Olivier Certner [Tue, 30 May 2023 15:14:50 +0000 (17:14 +0200)]
setusercontext(): Set priority from '~/.login_conf' as well
Setting the process priority is done only when the current process'
effective UID corresponds to that for which context is to be set.
Consequently, setting priority is done with appropriate credentials and
will fail if the target user tries to raise it unduly via his
'~/.login_conf'.
PR: 271751
Reviewed by: kib, Andrew Gierth <andrew_tao173.riddles.org.uk>
Approved by: emaste (mentor)
MFC after: 3 days
Relnotes: yes
Sponsored by: Kumacom SAS
Differential Revision: https://reviews.freebsd.org/D40352
Olivier Certner [Wed, 21 Jun 2023 08:53:37 +0000 (10:53 +0200)]
setclasspriority(): New possible value 'inherit'
It indicates to the login.conf machinery (setusercontext() /
setclasscontext()) to leave priority alone, effectively inheriting it
from the parent process.
Olivier Certner [Wed, 21 Jun 2023 08:39:15 +0000 (10:39 +0200)]
login.conf(5): Document priority's default and possible values
Priority is reset to 0 if not explicitly specified.
While here, be more explicit about what "Initial priority (nice) level"
means and document that it is possible to set real-time or idle class'
priorities with this capability.
Reviewed by: emaste
Approved by: emaste (mentor)
MFC after: 3 days
Sponsored by: Kumacom SAS
Differential Revision: https://reviews.freebsd.org/D40689
Olivier Certner [Mon, 29 May 2023 16:39:04 +0000 (18:39 +0200)]
setusercontext(): Better error messages when priority is not set correctly
Polish the syslog messages to contain readily useful information.
Behavior of capability 'priority' is inconsistent with what is done for
all other contexts: 'umask', 'cpumask', resource limits, etc., where an
absence of capability means to inherit the value. It is currently
preserved for compatibility, but is subject to change on a future major
release.
Olivier Certner [Thu, 25 May 2023 12:18:45 +0000 (14:18 +0200)]
setusercontext(): umask: Set it only once (in the common case)
Simplify the code and make it more coherent (umask was the only context
setting not modified by setlogincontext() directly).
Preserve the current behavior of not changing the umask if none is
specified in the login class capabilities database, but without the
superfluous umask() dance. (The only exception to this is that
a special value no user is likely to input in the database now stands
for no specification.)
If some user has a 'umask' override in its '~/.login_conf', the umask
will still be set twice as before (as is the case for all other context
settings overriden in '~/.login_conf').
Log a warning in case of an invalid umask specification.
This change makes it apparent that the value of LOGIN_DEFUMASK doesn't
matter. It will be removed in a subsequent commit.
Emmanuel Vadot [Fri, 26 Jan 2024 18:52:03 +0000 (19:52 +0100)]
pkgbase: Create two new rules for creating repo
This adds two new rules named create-packages-kernel-repo and
create-packages-world-repo.
The goal of those rules is to create the {kernel,world} packages and
after that the repository.
It helps a lot for developing with pkgbase by adding the dev machine
repository created by those rules on top of the official pkgbase one.
Michael Tuexen [Mon, 29 Jan 2024 17:41:24 +0000 (18:41 +0100)]
TCP LRO: convert TCP header fields to host byte order earlier
This is a preparation for adding dtrace hooks in a follow-up commit,
which are missing in the code path, where packets are directly queued
to the tcpcb. The dtrace hooks expect the fields to be in host byte
order. This only applies when TCP HPTS is used.
No functional change intended.
Lexi Winter [Sat, 13 Jan 2024 23:34:46 +0000 (23:34 +0000)]
service(8): direct user to rc(8) for a list of valid commands
New users may refer to service(8) to discover how to manage services,
but this manpage does not explain which commands are permitted besides
start/stop (for example, 'enable'). Add a paragraph that directs the
reader to rc(8) to discover this.
While here, add a few examples of common use-cases.
Reported by: Mina Galić <freebsd@igalic.co>
Pull request: https://github.com/freebsd/freebsd-src/pull/1057
Dimitry Andric [Mon, 29 Jan 2024 17:26:48 +0000 (18:26 +0100)]
Merge commit 4a39d0890894 from llvm-project (by Mark Johnston):
[libc++] Fix filesystem::remove_all() on FreeBSD (#79540)
remove_all_impl() opens the target path with O_NOFOLLOW, which fails if
the target is a symbolic link. On FreeBSD, rather than returning ELOOP,
openat() returns EMLINK. This is unlikely to change for compatibility
reasons, see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214633 .
Ed Maste [Mon, 29 Jan 2024 14:25:40 +0000 (09:25 -0500)]
linuxkpi: remove invalid KASSERT from hash_add_rcu
hash_add_rcu asserted that the node's prev pointer was NULL in an
attempt to detect addition of a node already on a list, but the caller
is not required to provide a zeroed node.
Reported in https://github.com/freebsd/drm-kmod/issues/282
Reviewed by: bz, manu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D43645
When a temporary/bootonce boot environment is renamed, we need to also
update the bootenv nvlist on-disk to reflect the new name. Additionally,
when a temporary/bootonce boot environment is destroyed, we also need to
clear out the on-disk state.
Kristof Provost [Thu, 25 Jan 2024 10:16:49 +0000 (11:16 +0100)]
pf: bind route-to states to their route-to interface
When we route-to the state should be bound to the route-to interface,
not the default route interface. However, we should only do so for
outbound traffic, because inbound traffic should bind on the arriving
interface, not the one we eventually transmit on.
Explicitly check for this in BOUND_IFACE().
We must also extend pf_find_state(), because subsequent packets within
the established state will attempt to match the original interface, not
the route-to interface.
Kristof Provost [Fri, 26 Jan 2024 12:29:31 +0000 (13:29 +0100)]
pfil: PFIL_PASS never frees the mbuf
pfil hooks (i.e. firewalls) may pass, modify or free the mbuf passed
to them. (E.g. when rejecting a packet, or when gathering up packets
for reassembly).
If the hook returns PFIL_PASS the mbuf must still be present. Assert
this in pfil_mem_common() and ensure that ipfilter follows this
convention. pf and ipfw already did.
Similarly, if the hook returns PFIL_DROPPED or PFIL_CONSUMED the mbuf
must have been freed (or now be owned by the firewall for further
processing, like packet scheduling or reassembly).
This allows us to remove a few extraneous NULL checks.
The RFC6675 pipe calculation (sack.revised, enabled
by default since D28702), uses outdated information,
while the previous default calculated it correctly
with up-to-date information from the incoming ACK.
This difference can become as large as the receive
window (not the congestion window previously),
potentially triggering a massive burst of new packets.
Warner Losh [Mon, 29 Jan 2024 05:08:55 +0000 (22:08 -0700)]
vtnet: Adjust for ethernet alignment.
If the header that we add to the packet's size is 0 % 4 and we're
strictly aligning, then we need to adjust where we store the header so
the packet that follows will have it's struct ip header properly
aligned. We do this on allocation (and when we check the length of the
mbufs in the lro_nomrg case). We can't just adjust the clustersz in the
softc, because it's also used to allocate the mbufs and it needs to be
the proper size for that. Since we otherwise use the size of the mbuf
(or sometimes the smaller size of the received packet) to compute how
much we can buffer, this ensures no overflows. The 2 byte adjustment
also does not affect how many packets we can receive in the lro_nomrg
case.
Colin Percival [Mon, 29 Jan 2024 02:04:20 +0000 (18:04 -0800)]
release.sh: Add -jN to `make release`
The `make release` command now creates VM and cloudware images (if
enabled) in addition to disk images; this results in a very large
number of 'make installworld' commands running sequentially. Adding
-jN should speed this up significantly.
Florian Walpen [Sun, 28 Jan 2024 20:18:20 +0000 (20:18 +0000)]
snd_hdspe(4): Per device sysctl for period.
Let the user choose a period (interrupt cadence in samples), in the
official RME drivers this setting is available as "Buffer Size".
Override the period propagated through blocksize by pcm channel latency
settings (see sound(4)), since these are unreliable and differ between
playback and recording channels.
Warner Losh [Sun, 28 Jan 2024 19:19:32 +0000 (12:19 -0700)]
kboot: update copyright on these files.
host_syscalls.c: I've written, so put Netflix copyright on. It's
possible in the confusion that Nathan wrote the host_gettimeofday
implementation.
syscall_nr: These files likely can't enjoy copyright protection since
they are just facts (the per-arch Linux system calls), so add a note
they are in the public domain.
Warner Losh [Sun, 28 Jan 2024 18:28:05 +0000 (11:28 -0700)]
kboot: Cleanup libkern reference
For aarch64 and amd64, we don't pull in anything from libkern, so we
don't need it in our path. However, powerpc needs ucmpdi2 from libkern,
so bring it into libkboot's build and omit it from loader.kboot.
Warner Losh [Sun, 28 Jan 2024 18:53:59 +0000 (11:53 -0700)]
kboot: Move _start out of kboot and into libkboot
Move the startup code from kboot/kboot to kboot/libkboot and add the
necessary infrastructure for it to build. move start_arch.h, a private
header for libkboot, over as well.
Warner Losh [Sun, 28 Jan 2024 18:05:05 +0000 (11:05 -0700)]
kboot: Move to kboot/kboot
In anticipation of separating the library elements from the kboot
prorgam elements, move kboot down a level into a subdirectory. There
will be libkboot and include directories in subsequent commits,
mirroring other subsystems like i386 and efi.
Andriy Gapon [Tue, 25 Oct 2022 21:10:39 +0000 (00:10 +0300)]
efibootmgr: fix potential endless loop with -v
I observed the problem on a system with fairly old and, apparently,
buggy EFI implementation. A list of boot devices had an invalid
trailing entry. efidp_size() for that entry returned zero, which means
that the code got stuck looping on that entry.
Andriy Gapon [Sun, 28 Jan 2024 13:18:02 +0000 (15:18 +0200)]
hdaa_pcmchannel_setup: do not advertise AC3 8+0
The rest of the sound system supports 7+1 maximum and is not aware of 8+0.
I believe that these messages are caused by 8+0:
kernel: feeder_init(0xfffff801f935d680) on feeder_matrix returned 22
kernel: pcm0: feeder_build_matrix(): can't add feeder_matrix
Andriy Gapon [Fri, 24 Dec 2021 09:38:38 +0000 (11:38 +0200)]
dtrace: make 'ring' and 'fill' policies imply 'noswitch' flag
This should disable allocation of the second per-CPU principal buffer
which is never used. This will also enable additional asserts
for buffers that are never switched.
First of all and unlike I2C, it's not the master that dictates how many
bytes to read in block read operation. It's the device that informs the
master how many bytes it's sending back.
Thus, for ichsmb_bread() the count parameter is purely an output
parameter. The code has been changed to reflect that.
The sanity checking of the response length is now done once it (the
first byte of the response) is received.
While here, handling of ICH_HST_STA_FAILED status bit has been added.
Plus some code style improvements and some new code comments in the
vicinity of the changed code.
Andriy Gapon [Sun, 28 Jan 2024 11:29:41 +0000 (13:29 +0200)]
gpiopower: trigger low, high and both edges
Power off or reset may be activated either by low or high signal or by an
edge. So, try everything.
Also, the driver now supports DTS properties for timings.
Finally, the driver does not change the pin configuration during attach.
It is assumed that the pin is already in a state that does not trigger
the power event (otherwise we wouldn't be running).
Andriy Gapon [Tue, 2 May 2023 20:46:39 +0000 (23:46 +0300)]
ds1307: restore hints-based configuration on FDT systems
Fall-through to non-FDT probe code if no matching device node is found.
While here, fix indentation of the switch statement.
Also, make the device description for the hints-based attachment the
same as for FDT attachment.
Fixes: 2486b446db ds1307: add support for the EPSON RX-8035SA I2C RTC
On several systems we've noticed that when NTB link goes down, the
Physical Layer User Test Pattern registers we use as additional
scratchpad registers (that is explicitly allowed by the chip specs)
become read-only for about 100us. I see no explanation for this in
the chip specs, neither why it was not seen before, may be a race.
Since we do need these registers, workaround it by repeating writes
until we succeed or 1ms timeout expire.
Dimitry Andric [Sat, 27 Jan 2024 21:51:08 +0000 (22:51 +0100)]
Add libllvm and liblldb source files to enable WITH_ASAN build
This is another part of fixing the WITH_ASAN build. Some additional
source files had to be added to libllvm and liblldb, since the ASan
instrumentation causes symbols in those files to be referenced.
a freebsd dev member reported a symbol conflict and intercepting this
had little value anyway.
This is one part of fixing the WITH_ASAN build. Some executables in the
base system define their own hexdump() symbol, which would otherwise
conflict with the ASan-intercepted one.
Dimitry Andric [Sat, 27 Jan 2024 21:24:38 +0000 (22:24 +0100)]
msun: remove fabs from Symbol.map, and adjust comment
We have s_fabs.c, but fabs(3) is already provided by libc due to
historical reasons, so it is not compiled into libm. When the linker
does not use --undefined-version, this leads to a complaint about the
symbol being nonexistent, so remove it from Symbol.map.
While here, adjust the comment about some functions being supplied by
libc: while it is true that all these are indeed in libc, libm still
includes its own versions of frexp(3), isnan(3), isnanf(3), and
isnanl(3).
Reported by: Steve Kargl <sgk@troutmask.apl.washington.edu>
MFC after: 3 days
Mark Johnston [Sat, 27 Jan 2024 15:26:22 +0000 (10:26 -0500)]
netinet tests: Make test jail names unique
Otherwise we get spurious test failures when running tests in parallel.
The intent here was to name jails after the tests, but this was done
incorrectly in a couple of places.