Commit Graph

306606 Commits

Author SHA1 Message Date
Aymeric Wibo 9d4bad45e2 EVENTHANDLER.9: EVENTHANDLER_REGISTER never fails
Since ecdf4409f9 ("Rework the eventhandler locking [...]"),
EVENTHANDLER_REGISTER() can never return NULL.

Suggested by:	olce
Reviewed by:	olce, ziaee, zlei
Approved by:	olce, zlei
Fixes:	ecdf4409f9 ("Rework the eventhandler locking [...]")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D55014
2026-02-03 15:56:40 +01:00
Jean-Sébastien Pédron 465ba08bb5 vm_phys: Check RB_FIND() return value in case it is NULL
When trying to unregister a fictitious range in
`vm_phys_fictitious_unreg_range()`, the function checks the properties
of the looked up segment, but it does not check if a segment was found
in the first place.

This can happen with the amdgpu DRM driver which could call
`vm_phys_fictitious_unreg_range()` without a fictitious range registered
if the initialisation of the driver failed (for example because
firmwares are unavailable).

The code in the DRM driver was improved to avoid that, but
`vm_phys_fictitious_unreg_range()` should still check the return value
of `RB_FIND()` before trying to dereference the segment pointer and
panic with a page fault.

Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55076
2026-02-03 15:44:55 +01:00
Dag-Erling Smørgrav d70b9eb74f libc/tests: Clean up *dir() tests
Mainly, avoid reusing the name of one of the functions we should be
testing (but aren't) for local variables.

Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D55054
2026-02-03 15:39:32 +01:00
Olivier Certner 9ae367d11d hwpstate_amd(4): Rename CPPC register macros
To be closer to AMD's official terminology, except for the "Lowest
Non-Linear Performance" field which we label as 'EFFICIENT_PERF' closer
to Intel's ("Most Efficient Performance"), and to clear possible
confusion.

No functional change (intended).

Reviewed by:    aokblast
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54998
2026-02-03 15:03:02 +01:00
Olivier Certner 4b0e09a918 hwpstate_amd(4): Fix BITS_WITH_VALUE()/SET_BITS_VALUE() to obey the mask
While here, rename an argument of BITS_VALUE() to be consistent with the
other macros.

Reviewed by:    aokblast
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54997
2026-02-03 15:03:02 +01:00
Olivier Certner e5f8cbb86d x86: x86_msr_op(): MSR_OP_LOCAL: Disable interrupts on atomic ops
On MSR_OP_LOCAL and non-naturally-atomic operations (MSR_OP_ANDNOT and
MSR_OP_OR), there is no guarantee that we are not interrupted between
reading and writing the MSR, and that interruption could actually
perform some operation on that MSR, which would be lost.

Prevent that problem by temporarily disabling interrupts around MSR
manipulation.

Reviewed by:    kib
Discussed with: markj
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54996
2026-02-03 15:03:01 +01:00
Olivier Certner a1a8bcdfde x86: x86_msr_op(): Simplify assertions
Simplify them by moving them into more natural places, i.e., default
cases of 'switch' statements.

No functional change (intended).

Reviewed by:    kib
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54996
2026-02-03 15:03:01 +01:00
Olivier Certner 7acd7ac638 x86: x86_msr_op(): Move setting mode up, delineate logical blocks
No functional changes (intended).

Reviewed by:    kib
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54996
2026-02-03 15:02:55 +01:00
Konstantin Belousov cd8d44173a unmount(2): do not allow MNT_DEFERRED or MNT_RECURSE flags from userspace
Repprted and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-02-03 12:25:47 +02:00
Enji Cooper e1f36b9db9 usr.bin/tftp: remove tests when MK_TFTP=no
These tests require the tftp client, which is not installed when
`MK_TFTP=no`. Remove them when that's not true.

MFC after:	1 week
2026-02-02 21:44:47 -08:00
Enji Cooper 7baa76c30c usr.bin/factor: remove tests when MK_GAMES=no
factor(1) is only installed when MK_GAMES != no. Ergo, remove the tests
when that's not true.

MFC after:	1 week
2026-02-02 21:42:03 -08:00
Enji Cooper 1ccee516ed tftpd: remove tests when MK_TFTP=no
MFC after:	1 week
2026-02-02 21:24:33 -08:00
Enji Cooper fd6217075e tftpd tests: clean trailing whitespace
No functional change intended.

MFC after:	1 week
2026-02-02 21:19:08 -08:00
Enji Cooper 51509500ac Remove bsnmpd tests when MK_BSNMP == no
MFC after:	1 week
2026-02-02 21:12:25 -08:00
Kyle Evans e6fa918c4a tpm: crb: add support for the Pluton startmethod
The Pluton startmethod uses a simple doorbell mechanism to wakeup the
TPM unit after we've issued various forms of state change, with the
registers to use specified in the startmethod-specific segment of the
TPM2 table (up to 12 bytes after the StartMethod).

At the very least, this is the kind of TPM in use by my AMD Zen 4-based
Minisforum machine.

Differential Revision:	https://reviews.freebsd.org/D53683
2026-02-02 22:48:32 -06:00
Justin Hibbits 1bc75d77e9 powerpc/pmap/oea64: Make PV_LOCK superpage sized
HPT superpages are 16MB, not 2MB.  Taking 8 locks to lock a super page
almost defeats the purpose of using the super page.  Expanding the
PV_LOCK scope to cover 16MB (24 bit shift) reduces this to a single
lock.

MFC after:	3 weeks
2026-02-02 23:33:36 -05:00
Justin Hibbits 7f885581d5 powerpc/pmap: Mark more CPUs as lockless TLBIE
Add POWER10 and POWER11 to the list of lockless TLBIE capable CPUs.
According to Linux, anything POWER5 and later should be able to do this,
but that hasn't been tested with FreeBSD.  POWER10 and POWER11, being
derived after the POWER9, implicitly have this capability per the ISA
spec.

MFC after:	1 week
2026-02-02 23:33:20 -05:00
Abdelkader Boudih ed3a2469a7 uart: fix sleeping while holding mutex in uart_tty_detach()
Move swi_remove() call before acquiring the tty lock. swi_remove() calls
intr_event_remove_handler() which may sleep via msleep(), causing a lock
order violation when called with the tty mutex held.

The software interrupt handler removal operates on the interrupt event
structure independently and does not require the tty lock. This matches
the pattern used in other drivers such as tcp_hpts.c where swi_remove()
is called without holding other locks.

Reviewed by:	imp, kevans
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54953
2026-02-02 21:21:43 -06:00
Kyle Evans d3f21856aa rc: run the zfs rc script before tmp
The tmp rc script has much the same problem that the var does: it wants
to test if /tmp is writable, and mount a tmpfs if it's not.  This means
that we actually want our zfs datasets mounted first, because we might
have a /tmp dataset that changes the story.

The ordering problem is particularly noticable with a r/o zfs root,
since the write test will fail and we'll mount a tmpfs that later gets
covered by our /tmp dataset.  If that /tmp dataset inherited readonly,
then we're still in trouble.

This also fixes `tmpmfs=yes`, which would again get covered by a zfs
dataset with the existing ordering.

Reviewed by:	des
Differential Revision:	https://reviews.freebsd.org/D54995
2026-02-02 21:21:42 -06:00
Konstantin Belousov 120ca8d74b Re-introduce kern.sched.topology_spec
Move it back from kern.sched.ule.topology_spec.
Make it scheduler-agnostic.
Provide trivial report for UP kernels.

Apparently the MIB is used by some third-party software.  Obviously it
did not worked on UP or 4BSD configs.

PR:	292574
Reviewed by:	olce
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D55062
2026-02-03 04:43:18 +02:00
Abdelkader Boudih 052a791b00 acpi: add Darwin OSI quirk for Apple Mac hardware
Mac firmware hides the Intel integrated GPU (iGPU) on dual GPU x86
systems, i.e., with AMD/NVIDIA dGPUs, when the Darwin OSI is not
installed via ACPI.

Prior to this change, FreeBSD always used the dGPU. This is fine in
practice, but consumed more power than when the iGPU is used,
resulting in reduced battery life.

Linux handles this in `drivers/acpi/osi.c` by detecting Apple
hardware via DMI, disabling all Windows OSI strings, and
by explicitly installing the Darwin OSI ACPI handler. This change
applies equivalent logic to the acpi(4) driver on FreeBSD.

This feature can be enabled/disabled using the
`hw.acpi.apple_darwin_osi` tunable. Setting this tunable to `0`
restores the previous behavior by explicitly disabling the added
support.

Reviewed by:	obiwac, ngie, adrian
Differential Revision:	https://reviews.freebsd.org/D54762
2026-02-02 17:51:37 -08:00
Aymeric Wibo fedc9746bd acpi_spmc: Register SPMC suspend/resume routines
SPMC suspend runs after the device tree is suspended using the
acpi_post_dev_suspend eventhandler, and SPMC resume runs before the
device tree is resumed using the acpi_pre_dev_suspend eventhandler.

Reviewed by:	olce
Approved by:	olce
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48735
2026-02-03 00:51:17 +01:00
Aymeric Wibo 4a71fc3b5c acpi: Post/pre device suspend/resume eventhandlers
These eventhandlers are called after suspending the device tree and
before resuming it. This is useful for PMC (power management controller)
drivers.

Reviewed by:	olce
Approved by:	olce
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48735
2026-02-03 00:51:17 +01:00
Rick Macklem 4bfb7cfb70 runat: Add -h to manipulate a symlink's named attribute dir
Lionel Cons <lionelcons1972@gmail.com> requested
that a new option be added to runat(1) so that it could
be used to manipulate named attributes associated with
a symbolic link and not the file the symbolic link refers to).

This patch adds the option -h/--nofollow to do this.

Requested by:	Lionel Cons <lionelcons1972@gmail.com>
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D55023
2026-02-02 14:38:13 -08:00
Marius Strobl b941d1c64e sym(4): Map HCB memory as uncacheable also on x86
As part of making the chip-specific mix and match of different accesses
(DMA/bus space) work as desired, the intent is to map the HCB memory as
uncacheable. Prior to VM_MEMATTR_*, the !x86 way of indicating this to
bus_dmamem_alloc(9) was BUS_DMA_COHERENT. Then later on in 2db99100a4,
BUS_DMA_NOCACHE was hooked up to VM_MEMATTR_UNCACHEABLE for x86. As it
turns out, still as of today bus_dmamem_alloc(9) differs in this regard
across architectures. On arm, it still supports BUS_DMA_COHERENT only
for requesting uncacheable DMA and x86 still uses BUS_DMA_NOCACHE only.
On arm64 and riscv, BUS_DMA_COHERENT seems to effectively be an alias
for BUS_DMA_NOCACHE.

Thus, allocate the HCB memory with BUS_DMA_COHERENT | BUS_DMA_NOCACHE,
so we get uncacheable memory on all architectures including x86 and so
loads and stores from/to HCB won't get reordered. However, even on x86
we still need to use at least compiler barriers to achieve the desired
program order.

This change should also fix panics due to out-of-sync data seen with
FreeBSD VMs on top of OpenStack and HBAs of type lsiLogic as a result
of loads and stores getting reordered. [1]

While at it:
- Nuke the unused SYM_DRIVER_NAME macro.
- Remove unused/redundant HCB members and correct a comment typo.

PR:		270816 [1]
MFC after:	3 days
2026-02-02 22:57:56 +01:00
Marius Strobl bfbcd310bd Revert "sym(4): Employ memory barriers also on x86"
The problem will be avoided in a different way.

This reverts commit e769bc7718.
2026-02-02 22:53:13 +01:00
Brooks Davis 18d47c1856 rpc: correct resultproc_t's type
It takes exactly three arguments of known type.

Tweak the types of various resultproc_t functions to match the type (mostly
added const to struct pointers) allowing us to drop casts.

Effort:		CHERI upstreaming
Reviewed by:	vangyzen, glebius
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D54941
2026-02-02 21:20:16 +00:00
Brooks Davis e236502a99 clnt_broadcast(3): fix eachresult argument type
The `eachresult` argument is documented to take a function pointer of
type:

	bool_t (*)(caddr_t, struct sockaddr_in *)

It was declared to take a resultproc_t which has historically been
declared to be:

	bool_t (*resultproc_t)(caddr_t, ...);

This overlapped well enough for currently supported ABIs where variadic
arguments are passed in registers, but this declaration is misaligned
with the documentation (resultproc_t takes three arguments) and will be
fixed in a followup commit.

Fix the type to be non-variadic, matching callbacks, and define a
convenience type of as most callbacks take something other than a char *
as their first argument and need to be cast.

Effort:		CHERI upstreaming
Reviewed by:	ngie, glebius, jhb
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D54940
2026-02-02 21:20:10 +00:00
Brooks Davis 47413f23e5 clnt_broadcast(3): don't free function pointers
Replace use of thr_getspecific/thr_setspecific to stash the function
pointer we're smuggling between clnt_broadcast and rpc_wrap_bcast with a
simple thread local variable.  Clear it after use so the reference
doesn't linger.

In the relatively unlikely event clnt_broadcast was called from threads
that exited prior to program termination, the previous code called free
on a function pointer, which is undefined and might corrupted allocator
state.

Effort:		CHERI upstreaming
Reviewed by:	glebius, jhb
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D54939
2026-02-02 21:20:01 +00:00
Xin LI dafba19e42 MFV less v691
Relnotes:	yes
MFC after:	2 weeks
2026-02-02 12:50:35 -08:00
John Hall 69f5355641 RELNOTES: Add entry for 7f54c65abc 2026-02-02 13:37:15 -07:00
Gleb Smirnoff 32c3723f06 tests/netgraph: fix tests that depended on connect(in6addr_any)
Fixes:	627e126dbb
2026-02-02 12:15:26 -08:00
Konstantin Belousov a8e92198f8 devfs: unlock the directory vnode around the call to dev_clone handler
The lock around dev_clone is unfortunate because cloner might need to
take its own locks that establish the order with devfs vnodes, and then
transiently participates in further VFS locks order.  For instance, this
way the proctree_lock or allproc_lock become involved.

Unlock dvp, we can unwind if the vnode become doomed while cloner was
called.

Reported and tested by:	pho
Reviewed by:	kevans, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D55028
2026-02-02 21:48:25 +02:00
Jessica Clarke 9e0fe12671 i386: Fix build and remove empty unused macro
When inlining the macro, reg was not substituted with the %ecx argument
previously passed in. One of the definitions was also left behind as an
empty macro.

PR:		292883
Fixes:		377c053a43 ("cpu_switch(): unconditionally wait on the blocked mutex transient")
MFC after:	1 week
2026-02-02 17:43:50 +00:00
John Baldwin f7144a9c4a 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
2026-02-02 12:19:51 -05:00
John Baldwin 03d8ac948b heimdal: Pass the correct pointer to realloc when growing a string buffer
The realloc in my_fgetln was trying to grow the pointer to the string
buffer, not the string buffer itself.

In function 'my_fgetln',
    inlined from 'mit_prop_dump' at crypto/heimdal/kdc/mit_dump.c:156:19:
crypto/heimdal/kdc/mit_dump.c:119:13: error: 'realloc' called on unallocated object 'line' [-Werror=free-nonheap-object]
  119 |         n = realloc(buf, *sz + (*sz >> 1));
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
crypto/heimdal/kdc/mit_dump.c: In function 'mit_prop_dump':
crypto/heimdal/kdc/mit_dump.c:139:11: note: declared here
  139 |     char *line = NULL;
      |           ^~~~

Reviewed by:	rmacklem, cy
Fixes:		a93e1b731ae4 ("heimdal-kadmin: Add support for the -f dump option")
Differential Revision:	https://reviews.freebsd.org/D54933
2026-02-02 12:18:11 -05:00
John Hall 7f54c65abc smartpqi: Update to vendor version 14.4690.0.2008 - 15.2.0.2008
Update to versions:
FreeBSD14 14.4690.2008
FreeBSD15 15.2.0.2008

Included in this update are:
 - Support for new controllers
 - Add code that utilizes the new BIG_IOCTL_Command_struct and allows
   the I/O buffer size for a single passthrough ioctl to be stored as a
   32 bit integer instead of the original 16 bit integer.
 - Update occurrences of Microsemi to Microchip
 - Some format changes including converting comments from C++ to C
   style, remove instances of /* $FreeBSD$ */, and updating copyright
   dates.

Update to versions:
FreeBSD14 14.4690.2008
FreeBSD15 15.2.0.2008

Included in this update are:

- Support for new controllers

_ Add code that utilizes the new BIG_IOCTL_Command_struct and allows
  the I/O buffer size for a single passthrough ioctl to be stored as
  a 32 bit integer instead of the original 16 bit integer.

- Update occurrences of Microsemi to Microchip

- Some format changes including converting comments from C++ to C
  style, remove instances of /* $FreeBSD$ */, and updating copyright
  dates.

Reviewed by:	imp
Approved by:	imp
MFC after:	1 week

Sponsored by: Microchip Technology Inc.

Differential Revision:	https://reviews.freebsd.org/D54787
2026-02-02 10:01:30 -07:00
Artem Bunichev d0474eda50 socket.2: Cross-reference netintro(4)
netintro(4) is a great manual page that provides a basic introduction to
network facilities, I think it is well worth mentioning in the
socket(2).

I also think we can incorporate this reference somewhere in the text as
well, but I'm not sure, maybe the reference in the SEE ALSO section
would be enough.

Reviewed by:	glebius
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D55032
2026-02-02 16:54:54 +00:00
Mark Johnston a45fb94801 ip6_mroute: Remove an unhelpful comment
ifnets already track if_allmulti() calls in the if_amcount field.  That
field is older than the comment, so I'm not exactly sure what the intent
was; let's just remove it.

MFC after:	2 weeks
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
2026-02-02 16:54:54 +00:00
Mark Johnston b320e89e69 ip6_mroute: Remove an unused constant
No functional change intended.

MFC after:	2 weeks
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
2026-02-02 16:54:54 +00:00
Mark Johnston 5bb953b095 ip6_mroute: Fix the UPCALL_TIMING build
MFC after:	2 weeks
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
2026-02-02 16:54:54 +00:00
Mark Johnston b370fcc716 ip6_mroute: Make MF6CFIND a regular function
This is more natural and corresponds more closely to the v4 multicast
routing code.  No functional change intended.

Reviewed by:	glebius
MFC after:	2 weeks
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54983
2026-02-02 16:54:54 +00:00
Mark Johnston 74839871be ip_mroute: Make privilege checking more consistent
- The v6 socket option and ioctl handlers had no privilege checks at
  all.  The socket options, I believe, can only be reached via a raw
  socket, but a jailed root user with a raw socket shouldn't be able to
  configure multicast routing in a non-VNET jail.  The ioctls can only
  be used to fetch stats.
- Delete a bogus comment in X_mrt_ioctl(), one can issue multicast
  routing ioctls against any socket.  Note that the call path is
  soo_ioctl()->rtioctl_fib()->mrt_ioctl().

I think all of the mroute privilege checks should be done within the
ip(6)_mroute code, but let's first make the v4 and v6 modules
consistent.

Reviewed by:	glebius
MFC after:	2 weeks
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54982
2026-02-02 16:54:54 +00:00
Mark Johnston 07940d1d85 atf_python: Run vnet handlers in $HOME
When kyua runs a test, it creates a temp directory and sets $HOME to
point to it.  Tests are run with the cwd set to that temp directory.

When a process attaches to a jail, its cwd is set to the root of the
jail.  Modify atf_python to cd to $HOME instead, so that it's easier for
tests to share files.

Reviewed by:	zlei, ngie
MFC after:	2 weeks
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54971
2026-02-02 16:54:54 +00:00
Cy Schubert d0309745e6 ObsoleteFiles.mk: Remove obsolete MIT KRB5 plugins
Fixes:			1f9da4793c, dd0ec030f8
MFC after:		1 week
Differential revision:	https://reviews.freebsd.org/D54780
2026-02-02 08:47:21 -08:00
Dag-Erling Smørgrav 1c00d5a3b2 libc: Fix missing include
Although not needed on FreeBSD due to namespace pollution, we should
technically #include <stddef.h> to secure a definition of NULL.

Fixes:		5074d5c984 ("libc: Improve POSIX conformance of dirfd()")
2026-02-02 17:41:18 +01:00
Baptiste Daroussin 404753664a diff3: use pdwait instead of homemade one
MFC After:	3 days
2026-02-02 17:36:42 +01:00
Baptiste Daroussin c479817f30 diff: remove useless include as kevent is not used anymore
MFC After:	3 days
2026-02-02 17:13:55 +01:00
Baptiste Daroussin 0ec58e7c2e diff: use pdwait(2) instead of homemade one
MFC After:	3 days
Reviewed by:	des
Differential Revision:	https://reviews.freebsd.org/D55053
2026-02-02 17:13:16 +01:00
Baptiste Daroussin 4d73b07d02 diff: fix support for -l with new diff algorithm
MFC After: 3 days
Reviewed by:	des
Differential Revision:	https://reviews.freebsd.org/D55052
2026-02-02 17:13:16 +01:00