sendfile(2): rework compat implementation
Rename the sendfile() function to kern_sendfile(), expand the arguments
previously passed in struct sendfile_args, and extend with two function
pointer arguments to copy in the header/trailer structure and the
create uio's for the header and trailer as required. Use this to allow
the removal of freebsd32_do_sendfile() which was a nearly identical
duplicate of sendfile() with attendant maintenance cost.
Reviewed by: kib, markj
Effort: CHERI upstreaming
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D59034
linuxkpi: Fix cancel_delayed_work_sync() return value
Align behavior between the Linux cancel_delayed_work_sync()
function return value and the LinuxKPI equivalent.
Linux cancel_delayed_work_sync() returns whether delayed
work was pending, even if canceled before executing. This
includes the case where the timer fired and work was queued
but the callback had not yet started.
The LinuxKPI version used the return value from taskqueue_cancel()
as the return value of the public facing API, which inverted the
behavior of two cases, violating the Linux API contract.
Queued work which was removed before running would return false, and
work whose callback was already executing would return true.
Track the taskqueue pending count separately from the
taskqueue_cancel() return value.
Use the pending count for the public return value.
[11 lines not shown]
stress2: add two new unionfs test scenarios
These exercise lookup traversal from tmpfs into unionfs, which is
useful because, unlike UFS, tmpfs does not allow recursion on its vnode
locks by default.
unionfs22.sh exercises these lookups with a normal unionfs mount, while
unionfs23.sh uses '-o below' for the unionfs mount and reproduces the
panic described in PR 298201.
Reviewed by: kib, markj, pho
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D59494
vfs_lookup_cross_mount(): fix missing LK_CANRECURSE
This was a rather dumb miss on my part in commit 42442d7a6e.
LK_CANRECURSE is clearly needed in any case in which the covered vnode
is held exclusive across the call to VFS_ROOT(), regardless of whether
it was initially held exclusive or upgraded. The commit message for
that change also noted that unionfs lookup only worked without
LK_CANRECURSE due to a coincidence of the then-current unionfs
implementation. As it happens, said coincidence was recently removed
in commit b952606b4f ("unionfs_lock(): eliminate LK_CANRECURSE special-
case").
PR: 298201
Reported by: olivier
Fixes: 42442d7a6e "Generalize the VV_CROSSLOCK logic in
vfs_lookup"
Reviewed by: kib, markj, pho
Tested by: pho
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D59494
iwx: fix kernel panic on module unload with assertions enabled
When interface is up and running 'kldunload if_iwx' stops the device and executes RUN -> INIT state transition.
Since the device is already stopped iwx_run_stop fails to stop the device again and returns non-zero exit code from iv_newstate callback which triggers 'INIT state change failed' assertion.
I reused IWX_FLAG_SHUTDOWN flag to:
a) set it in iwx_detach
b) check it in iwx_newstate_sub - when it is set all custom state transition logic is skipped
Accidentally found while experimenting with iwlwifi / iwx drivers
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D59624
pci: Adapt PME capability queries to stable/14
Add explicit D3hot and D3cold names and the bounds needed by
pci_has_pme(), while retaining PCI_POWERSTATE_D3 == 3. D3cold is a
capability-query state here, not a newly supported power transition.
This avoids importing the ACPI D3cold changes for the PME and igc
Wake-on-LAN backports.
Use pci_has_pm() to check capability presence instead of pp_location,
which is not present in stable/14. Keep the PCI configuration structure
layout unchanged.
Fixes: d831cb2ad3d8 ("pci: Expose PME support by power state")
Fixes: 443dc80b712c ("igc: Correct Wake-on-LAN filter programming")
igc: Correct Wake-on-LAN filter programming
The attach path translated WUC.APME into a saved link-change filter,
then advertised magic-packet wake. Suspend removed unselected magic,
unicast, and multicast bits from that saved value, commonly leaving no
hardware wake filter at all. The destructive masking also made later
capability changes ineffective.
Advertise the I225/I226 wake filters whenever PCI power management is
available and enable magic-packet wake by default. Build a fresh WUFC
mask for every suspend, and explicitly clear WUC, WUFC, and PCI PME when
wake is disabled.
Require the PCI power-management capability to report D3hot PME support
before advertising or arming wake. A PM capability alone does not mean
the function can signal PME from the state used during system sleep.
Reconstruct RAR0, the multicast table, and the receive filter after the
stop-time reset so unicast and multicast wake use the current interface
[48 lines not shown]
pci: Expose PME support by power state
The presence of the PCI power management capability does not imply that
a function can signal PME# from every power state. Drivers which
advertise wake based only on pci_has_pm() can consequently expose wake
modes that cannot work.
Add pci_has_pme() to query the PME_Support bitmap for a specific state.
Use it to implement LinuxKPI pci_pme_capable(), removing its duplicate
PME_Support decoder.
Validated the helper against PCI PMC capability values from 82571EB,
82573L, 82579LM, I210, I225, and I226-V controllers. The 82571 and
82573 reported PMC 0xc822, while the I226-V reported 0xc823. In both
values, bits 15, 14, and 11 advertise PME from D3cold, D3hot, and D0;
the low-bit difference is only the PM capability version.
Sponsored by: BBOX.io
(cherry picked from commit c4e24e95c3f905b817d4bfc6e93457eb297bfa4b)
igc: Correct Wake-on-LAN filter programming
The attach path translated WUC.APME into a saved link-change filter,
then advertised magic-packet wake. Suspend removed unselected magic,
unicast, and multicast bits from that saved value, commonly leaving no
hardware wake filter at all. The destructive masking also made later
capability changes ineffective.
Advertise the I225/I226 wake filters whenever PCI power management is
available and enable magic-packet wake by default. Build a fresh WUFC
mask for every suspend, and explicitly clear WUC, WUFC, and PCI PME when
wake is disabled.
Require the PCI power-management capability to report D3hot PME support
before advertising or arming wake. A PM capability alone does not mean
the function can signal PME from the state used during system sleep.
Reconstruct RAR0, the multicast table, and the receive filter after the
stop-time reset so unicast and multicast wake use the current interface
[48 lines not shown]
pci: Expose PME support by power state
The presence of the PCI power management capability does not imply that
a function can signal PME# from every power state. Drivers which
advertise wake based only on pci_has_pm() can consequently expose wake
modes that cannot work.
Add pci_has_pme() to query the PME_Support bitmap for a specific state.
Use it to implement LinuxKPI pci_pme_capable(), removing its duplicate
PME_Support decoder.
Validated the helper against PCI PMC capability values from 82571EB,
82573L, 82579LM, I210, I225, and I226-V controllers. The 82571 and
82573 reported PMC 0xc822, while the I226-V reported 0xc823. In both
values, bits 15, 14, and 11 advertise PME from D3cold, D3hot, and D0;
the low-bit difference is only the PM capability version.
Sponsored by: BBOX.io
(cherry picked from commit c4e24e95c3f905b817d4bfc6e93457eb297bfa4b)
nfscl: Yet more fixes for the NFS over RDMA client glue
This should be it for a while, but there will be another cycle
of "glue" updates. I just found out that I'll need to create
an alternate code path that uses a contigmalloc() blob instead
of scatter/gather of pages, since some NICs cannot do the
scatter/gather of pages well.
This commit should not affect non-RDMA behaviour.
MFC after: 3 months
Fixes: 884ee8d6c9b4 ("nfscl: Add some glue for client side NFS over RDMA")
aq(4): arm PHY thermal shutdown from the admin poll
move thermal shutdown arming to the admin poll
this gives a more reasonable delay prior to the first attempt, and also
allows us to retry and make the option runtime-tuneable via a new
disable_thermal_arm sysctl
Approved by: adrian (mentor)
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D59593
Signed-off-by: Nick Price <nprice at FreeBSD.org>
fdescfs: descend through /dev/fd/N when mounted linrdlnk
Linux resolves a path below /proc/self/fd/N in the directory the
descriptor names, and linprocfs makes /proc/<pid>/fd a symlink to
/dev/fd. Under linrdlnk the fdescfs node carries only VV_READLINK,
which namei will not walk through, so such a path fails with ENOTDIR.
Return the underlying vnode from fdesc_lookup for a non-final component,
or a trailing slash, reusing the machinery the nodup option already
uses. The last component is untouched, so open("/dev/fd/N") keeps its
dup(2) semantic; a descriptor with no vnode behind it, such as a pipe,
yields ENOTDIR.
Add ATF coverage for traversal, descriptor reuse, and preservation of
last-component and mount-option semantics.
Approved by: adrian (mentor)
Reviewed by: kib, adrian
Differential Revision: https://reviews.freebsd.org/D59393
[2 lines not shown]
amd64, powerpc: Enable tpm(4) in supported kernels
tpm(4) was removed from amd64 GENERIC because it broke suspend and
resume. The preceding lifecycle, state-save, interrupt, locality, and
teardown fixes address those failures for both TPM 1.2 and TPM 2.0.
Restore the driver to amd64 GENERIC and MINIMAL, where TPM entropy
harvesting remained enabled. Enable the driver and entropy harvesting
in the MPC85XX and QORIQ64 configurations, which already provide FDT,
spibus, and the platform SPI controller required by FDT-attached TPMs.
Leave the generic AIM and POWER configurations unchanged because they
have no TPM attachment bus.
The TPM 1.2 path completed repeated S3 cycles and command tests on
ThinkPad T430 and T440p systems. The TPM 2.0 path completed repeated
device and full-system suspend/resume cycles on a ThinkPad P51. The
PowerPC configuration matrix was checked to retain tpm(4) only where its
FDT SPI attachment path is present.
[8 lines not shown]
puc: add the WCH CH382 2S dual serial card
Two 16850 UARTs in the first I/O BAR at offset 0xc0, 8 bytes apart.
Approved by: adrian (mentor)
Reviewed by: imp, adrian
Differential Revision: https://reviews.freebsd.org/D59512
Signed-off-by: Nick Price <nprice at FreeBSD.org>
puc: be more careful about using MSI
puc has preferred MSI for every card since MSI support was added, with
only a global tunable to opt out. uart(4) makes the same decision for
the serial devices it attaches directly, and has since grown two
defences: it skips MSI unless the device advertises exactly one vector,
because attaching a single instance to a device offering many has caused
problems (PR 235016), and it lets individual devices be flagged when
they claim MSI support that does not work.
Adopt both.
Approved by: adrian (mentor)
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D59623
Signed-off-by: Nick Price <nprice at FreeBSD.org>
superio, ncthwm: add support for the Nuvoton NCT6798D
The ASUS PRIME X570-P carries a Nuvoton NCT6798D, Super I/O device ID 0xd42b. Add an exact-match entry to both. Exact rather than masked: the neighboring 0xd42a entries are deliberately exact with an extid because that ID is claimed by both NCT6796D-E and NCT5585D, and widening the family would make them collide.
The NCT6798D has seven tachometers, so raise NCTHWM_FAN_MAX to seven and describe the two extra ones; existing entries keep fan_count = 5 and are unaffected. Fan names follow the NCT6779 convention and do not map to any board's physical headers.
Tested on: ASUS PRIME X570-P, Ryzen 9 5950X, FreeBSD 16.0-CURRENT.
Approved by: adrian
Reviewed by: stephane.rochoy_stormshield.eu, adrian
Differential Revision: https://reviews.freebsd.org/D58291
Signed-off-by: Nick Price <nprice at FreeBSD.org>
bsdinstall: allow ZFS root on GPT under UEFI (amd64)
GPT+ZFS+UEFI boots fine, but the manual guided
wizard prevented it.
MFC after: 3 days
Reviewed by: imp, adrian
Differential Revision: https://reviews.freebsd.org/D59603
lib/googletest: also use -O0 for internal tests with GCC
This fixes the build with gcc 16's aggressive inlining.
Reviewed by: ngie
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D59538
linux: LINUX_PR_SET_THP_DISABLE all non-zero values are disable
Linux treats any nonzero value as "disable", so accept them all.
Fixes: a8a6eac57091
Sponsored by: Netflix
loader.efi: Only try to download md if we're netbooting
The only possible time we could download the initmd that the dhcp server
told us about is if we're netbooting. So only attempt to do that if the
load device for loader.efi is a network. IF you are booting off disk and
then need to snag an initmd off the network, that's a different path,
and wouldn't need to necessarily do a dhcp exchange, except to get the
IP address.
Sponsored by: Netflix
loader.efi: Expose efi_devpath_get_mac to get mac
This is a convenient way to test if a device path is a nic or not, so
expose it to the world.
Sponsored by: Netflix
nvmecontrol: Minor correctness issues
Turn an assert into a bounds check to not overflow if the nvme drive
reports too many power states (we validate the user input, but not the
drive's identify data).
Use a uint32_t instead of int for entry so right shift we do is defined.
No functional changes.
Fixes: 35793364d722
Noticed by: claude + Sonet 5
Sponsored by: Netflix
loader.efi: Fix memory leak in efihttp_dev_close
Save enough context to free the host we allocated in open on close.
Fixes: 6788e42d53c6
Noticed by: claude + Sonet 5
Sponsored by: Netflix
mpsutil: Better naming form the discovery_status function
It's really discovery_status_str(). Rename it and use open_memstream()
to write the string so we don't have to play as many str* games.
Fixes: afb60897a15c
Noticed by: claude + Sonet 5 (size error, bad fix ignored)
Sponsored by: Netflix
dhclient(8): Add support for IPv6-Only option (RFC 8925)
Accept and validate the ipv6only option. When dhclient receives this
option and IPv6 connectivity is available, stop the DHCP configuration
process and wait for the duration specified by the option before
restarting DHCP discovery.
If the address was previously leased, disassociate it and send a
DHCPRELEASE packet.
Use netlink to check for IPv6 connectivity.
Also, unregister ignored options from default PRL.
Reviewed by: ziaee, kfv
Tested by: Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D56637