Commit Graph

306396 Commits

Author SHA1 Message Date
Jonathan T. Looney fb4b0c9119 witness: Provide facility to print detailed lock tree
When witness(4) detects lock order reversals (LORs), it prints
information about the stack trace which caused the LOR. If available,
it can also print information about the first stack trace which
established the other lock ordering. However, it only does this for
"simple" LORs where the two locks in question were directly locked
in the opposite order. When the lock order was established through
a more complex pattern of intermediate locks, WITNESS only prints
the stack trace where it detected the LOR.

This commit provides new functionality to provide more verbose
information about the lock chain(s) which established the lock
ordering. The new functionality can be disabled by setting the
debug.witness.trace sysctl/tunable to 1. The new functionality
is also available through the debug.witness.badstacks sysctl,
which has been modified to always show the more verbose
information.

Reviewed by:	markj, glebius (previous version), kib (previous version)
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D54785
MFC after:	1 month
2026-01-26 20:22:57 +00:00
Jose Luis Duran fe962e33d8 METALOG: Order keyword entries
To facilitate comparison with mtree -C generated output, keep the
keywords ordered.

No functional change intended.

Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54872
2026-01-26 20:19:44 +00:00
Konstantin Belousov 2a5b083c1f posix_spawnattr_getexecfd_np.3: add closing .Fc
Fixes:	9bf69c37f43e96292e97e41bf942d7aca4101362
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-01-26 22:09:40 +02:00
Konstantin Belousov 080d8ed7dd libc: add posix_spawnattr_{get,set}procdescp_np
Reviewed by:	asomers
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54879
2026-01-26 21:30:14 +02:00
Konstantin Belousov 74a2bf1b7a libsys: add pdrfork_thread() on x86
Reviewed by:	asomers
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54879
2026-01-26 21:30:05 +02:00
Mark Johnston 8934c3dc78 pf tests: Set require.kmods in divert-to tests
Tests should declare their dependencies rather than testing for them at
runtime.

Reviewed by:	igoro, kp, glebius
MFC after:	2 weeks
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54846
2026-01-26 17:24:25 +00:00
Mark Johnston 39878d24a6 pf: Rationalize the ip_divert_ptr test
If a rule has a divert port set, then we can reasonably predict that
ipdivert.ko is loaded, and in particular that ip_divert_ptr is set.

Moreover, in this case, if ipdivert.ko is not loaded we should just drop
the packet instead of ignoring the divert rule.

Reviewed by:	igoro, kp, glebius
MFC after:	2 weeks
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54845
2026-01-26 17:23:33 +00:00
Aymeric Wibo 49ec19f1e1 acpi: Add ACPI_SPMC debug layer define
Reported by:	des
Fixes:	c5daa5a4c3 ("acpi_spmc: Add system power management controller driver")
Sponsored by:	The FreeBSD Foundation
2026-01-26 18:02:41 +01:00
Dag-Erling Smørgrav 0eb2c9d39b freebsd32: Fix includes
The previous commit added <sys/cdefs.h>, which isn't actually needed.
Conversely, <sys/event.h> is needed (and has been for a long time) but
was not included.

MFC after:	1 week
Fixes:		a11d132f6c ("devstat: Provide 32-bit compatibility")
Reported by:	gallatin@
2026-01-26 17:37:40 +01:00
Doongar Singh 972c488bf4 riscv: Add macro for hfence.gvma instruction
Add an inline function hfence_gvma() for hfence.gvma instruction.

Signed-off-by:	Doongar Singh <doonbsd@gmail.com>
Reviewed by:	mhorne, markj
Differential Revision:	https://reviews.freebsd.org/D54857
2026-01-26 12:23:16 -04:00
Marius Strobl e769bc7718 sym(4): Employ memory barriers also on x86
In an MP world, it doesn't hold that x86 requires no memory barriers.

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. [1]

While at it:
- Improve the granularity somewhat by distinguishing between read and
  write memory barriers as well as refer to existing *mb(9) functions
  instead of duplicating these [2], unless IO barriers are also used.
- Nuke the unused SYM_DRIVER_NAME macro.

PR:		270816 [1]
Obtained from:	BSD-licensed Linux sym53c8xx driver [2]
MFC after:	1 week
2026-01-26 16:54:48 +01:00
Marius Strobl 518c01b31e sym(4): Provide a DEVICE_DETACH(9) method
This also fixes sym_cam_free() to tear things down correctly, i. e. in
opposite order of setup, as well as sym_cam_attach() to not free devq
and SIM twice in the failure case.
2026-01-26 16:54:48 +01:00
Marius Strobl c8e9479c74 sym(4): Use memcpy(9) instead of bcopy(9)
The overlap handling of bcopy(9) is not required in these cases.

Obtained from:	BSD-licensed Linux sym53c8xx driver
2026-01-26 16:54:47 +01:00
Marius Strobl 48eee744b5 sym(4): Consistently use device_printf(9) where applicable 2026-01-26 16:54:47 +01:00
Mitchell Horne 38e5564ece native-xtools: use static LLVM libraries
Set the MK_LLVM_LINK_STATIC_LIBRARIES knob to "yes" when building the
native-xtools target. This reverts to the behaviour prior to
2e47f35be5.

This avoids a build failure that occurs otherwise, where compilation
fails looking for a libllvmprivate.so that was not built.

It is unclear if this addresses the issue in all instances---some
replies in the PRs indicate otherwise. Still, some report success, and
in my own testing this fixed creation of a cross-compiled poudriere
jail. Commit this while we continue to investigate...

PR:		286710, 291409
Tested by:	marck, rdunkle@smallcatbrain.com
Reviewed by:	emaste
MFC after:	3 days
Fixes:	2e47f35be5 ("Convert libllvm, libclang and liblldb into private shared libraries").
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D54815
2026-01-26 11:12:30 -04:00
Mitchell Horne 27595bea69 riscv: smarter DMAP construction (again)
Extend pmap_bootstrap_dmap() to build the DMAP with 4K-page granularity.

Recently we have been approximating it with 2MB mappings. The motivation
again is the problematic FU540 hardware, which seems to require more
accurate mappings still to avoid triggering its PMP errata.

Although this hardware alone is of little consequence, constructing the
DMAP accurately/correctly may help avoid future surprises.

The implementation contains some repetitive code. This could be
expressed differently, but my guiding principle for these early routines
is that being simple and explicit about what we are doing makes them
easier to comprehend.

See also 762a3224cd ("riscv: smarter DMAP construction).

Tested by:	Klaus Küchemann <maciphone2@googlemail.com>
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D54716
2026-01-26 10:50:56 -04:00
Alan Somers 277539ae7f Add tests for pdwait
MFC With:	4d707825bf
Sponsored by:	ConnectWise
2026-01-26 07:37:16 -07:00
Alan Somers d1e6057fa4 Add tests for pdrfork
MFC With:	5c2ee618d5
Sponsored by:	ConnectWise
2026-01-26 07:37:08 -07:00
Alan Somers e35df41f68 procdesc: Add a test for pid recycling behavior
MFC With:	09984871d8
Sponsored by:	ConnectWise
2026-01-26 07:36:57 -07:00
Aymeric Wibo c5daa5a4c3 acpi_spmc: Add system power management controller driver
Add SPMC (system power management controller) driver as acpi_spmc. This
is the device which provides the LPI device D-state constraints and
allows for OSPM to send S0ix/modern standby entry/exit notifications.
This supports the original Intel DSM
(https://uefi.org/sites/default/files/resources/Intel_ACPI_Low_Power_S0_Idle.pdf,
untested), the AMD DSM (tested), and the Microsoft DSM (tested).

Before entry, acpi_spmc_check_constraints is called to notify of any
violated power constraints. This will use acpi_pwr_get_state to get
current device D-states when that gets added back.

Reviewed by:	olce
Tested by:	jkim, Oleksandr Kryvulia, Matthias Lanter
Approved by:	olce
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48387
2026-01-26 14:42:11 +01:00
Dag-Erling Smørgrav a11d132f6c devstat: Provide 32-bit compatibility
If a 32-bit process running on a 64-bit kernel requests kern.devstat.all,
translate each struct devstat to its 32-bit equivalent before copying it
out.

Also fix a bug where an early error would be ignored if there were no
devices to report.

MFC after:	1 week
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D54591
2026-01-26 13:01:59 +01:00
Ahmad Khalifa c29e05113c hpt: remove unnecessary macro expansion hacks
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D54875
2026-01-26 11:32:10 +02:00
Ahmad Khalifa 6ecaa8dfb6 sys/module.h: allow MODULE_DEPEND to accept macros
Allow MODULE_DEPEND to accept macros by adding an extra level of
indirection. Some drivers in the tree actually depend on this being the
case.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D54874
2026-01-26 11:32:10 +02:00
Jaeyoon Choi 8ef8c6abfa cam/scsi: Restore scsi_start_stop() and add scsi_start_stop_pc()
Revert the argument change that broke libcam in 8c35de49 and move
power_condition support to scsi_start_stop_pc().

Reported by:		imp
Reviewed By:		#cam, imp (mentor)
Sponsored by:           Samsung Electronics
Differential Revision:	https://reviews.freebsd.org/D54822
2026-01-26 06:35:31 +00:00
Artem Bunichev 4efe75af08 kqueue.2: Fix reference to unexisting kevent1()
kqueue1() was meant.

While here, make the wording in the AUTHORS section more clear.

PR:		291908
Fixes:		9b1585384d ("kqueue.2: Editorial pass")
Reviewed by:	kib, dab
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54858
2026-01-25 22:41:24 +00:00
Mark Johnston d6bc31f929 makefs/zfs/tests: Force-destroy md devices
Most of these tests create a md(4) device backed by a makefs-generated
image, then import the pool, using the md device as a pool vdev.  When
a test finishes, it destroys the pool, then destroys the md device.

Once in a while md device destruction fails with EBUSY.  This happens
when a GEOM consumer is holding the device open; kern_mddetach_locked()
simply fails if any consumers are present.  zpool destruction is
synchronous so ZFS is innocent, rather, the problem seems to be that
GEOM re-tastes the device after the zpool reference goes away.  This
operation creates a transient reference that causes the spurious
failure.

Use "mdconfig -o force" to work around this.

MFC after:	2 weeks
2026-01-25 22:41:10 +00:00
Konstantin Belousov 58580dc0c6 libc: document posix_spawnattr_getexecfd_np(3)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54862
2026-01-25 19:20:00 +02:00
Konstantin Belousov 3f0aea0968 libc: add posix_spawnattr_{get,set}execfd_np(3)
If execfd is set, the fexecve(2) is used by posix_spawn() instead of the
provided path.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54862
2026-01-25 19:19:53 +02:00
Jean-Sébastien Pédron d185e9fae9 Bump __FreeBSD_version to 1600011 after changes to eventfd
This covers the commits that updated the API and the commit that exposes
that API in linuxkpi for DRM drivers.

Sponsored by:	The FreeBSD Foundation
2026-01-25 17:04:44 +01:00
Jean-Sébastien Pédron a200c8e51c linuxkpi: Add eventfd_*()
Add <linux/eventfd.h> and expose the `eventfd_*()` API. This is used by
DRM drivers for some time, but the code was commented out so far.

Note that Linux uses `struct eventfd_ctx`, but FreeBSD defines `struct
eventfd`. We define `eventfd_ctx` as a synonym to `eventfd`.

Reviewed by:	christos, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50853
2026-01-25 17:04:44 +01:00
Jean-Sébastien Pédron 28d6ffe37c eventfd: Add eventfd_signal()
The `eventfd_signal()` function is the equivalent to a write to an
eventfd file descriptor: it bumps the internal counter and wakes up
processes waiting for it.

`eventfd_signal()` is meant to be used by kernel drivers. DRM drivers
will call it through linuxkpi.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50850
2026-01-25 17:04:44 +01:00
Jean-Sébastien Pédron 5931649751 eventfd: Add refcounting
An eventfd file descriptor can be used by drivers such as DRM drivers
through linuxkpi. A driver can hold a reference to such a file
regardless of the fact it is used by userland or not.

This patch introduces a refcount in `struct eventfd`, plus the
`eventfd_get()` and `eventfd_put()` functions to acquire and release
references. These functions will be used by DRM drivers for instance.

This structure is internal to `sys/kern/sys_eventfd.c` and not used
anywhere else. Thus it is safe to add a field without breaking anything.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50849
2026-01-25 17:04:40 +01:00
Konstantin Belousov e878df0d3b Regen syscall tables after pdfork(2) and pdwait(2) additions 2026-01-25 17:54:29 +02:00
Konstantin Belousov 6c82bf1407 Regen for the fork and exit/wait exterror category addition 2026-01-25 17:54:27 +02:00
Konstantin Belousov ec8e8fa601 rights.4: document CAP_PDWAIT
Noted by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:54:22 +02:00
Konstantin Belousov f7b56887cc Document pdrfork(2) and pdwait(2)
Reviewed by:	asomers, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:54:15 +02:00
Konstantin Belousov 2d555ec85a lib/libsys, lib/libc: export pdwait
Make pdwait(2) cancellable, same as all other wait*(2) syscalls wrappers.

Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:54:08 +02:00
Konstantin Belousov 4d707825bf Add pdwait(2)
Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:54:02 +02:00
Konstantin Belousov 09984871d8 procdesc: postpone freeing the zombie' pid until procdesc is freed
Requested by:	asomers
Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:53:54 +02:00
Konstantin Belousov aa72df78d7 sys: Add cap_pdwait_rights
Suggested by:	asomers
Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:53:47 +02:00
Konstantin Belousov a560abedfb audit: handle AUE_PDWAIT
Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:53:42 +02:00
Konstantin Belousov 7fe33d58a8 kern/kern_exit.c: extract wait6_check_alive() helper
Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:53:36 +02:00
Konstantin Belousov 2b67cfa39d kern/kern_exit.c: extract some helpers from proc_to_reap()
Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:53:30 +02:00
Konstantin Belousov 109b9f48ec kern/kern_exit.c: define the exterror category for exit/wait
Convert EINVALs in kern_exit.c into EXTERRORs.

Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:53:22 +02:00
Konstantin Belousov f10b4b6131 lib/libsys, lib/libc: export pdrfork(2)
Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:53:16 +02:00
Konstantin Belousov 5c2ee618d5 sys: add pdrfork(2)
Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:53:09 +02:00
Konstantin Belousov d0d4b9b9df sys: add AUE_PDRFORK
Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:53:02 +02:00
Konstantin Belousov 7211cd2cce kern/kern_fork.c: define the exterror category for fork
Convert EINVALs in kern_fork.c into EXTERRORs.

Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:52:55 +02:00
Konstantin Belousov 472c32a83b kern/kern_fork/exit.c: organize includes
Remove sys/cdefs.h.
Remove sys/param.h.
Order the sys/*.h includes alphabetically.

Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:52:46 +02:00
Konstantin Belousov f5acbacb28 kern/kern_exit.c: some style
Reviewed by:	asomers, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
2026-01-25 17:52:39 +02:00