Commit Graph

306377 Commits

Author SHA1 Message Date
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
Konstantin Belousov 6af3cf27ed freebsd32_rusage_out(): bzero the compat32 structure
There is some padding on non-x86.  Unconditionally bzero the memory to
avoid a leak.

Noted by:	markj
Reviewed by:	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:30 +02:00
Bjoern A. Zeeb 072af59d46 netlink: make compile without VIMAGE
Add the #include for proc.h which seems to be there in the VIMAGE
case through some other includes only.

Sponsored by:	The FreeBSD Foundation
Fixes:		04f6b99947
2026-01-25 12:35:23 +00:00
Bjoern A. Zeeb 7e4a2b381d LinuxKPI: improve hweight<n> if complie time constant
rtw89(4) uses a static_assert() with hweight<n> calls.  In order to
avoid compile time errors, deal with the case when the arguments to
hweight<n> are complie time constant.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D54806
2026-01-25 12:35:22 +00:00
Bjoern A. Zeeb 44d1153dda LinuxKPI: add umin()
Add a version of umin() simply using MIN() assuming that the Linux
upstream code properly check that the arguments are unsigned, etc.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D54807
2026-01-25 12:35:22 +00:00
Bjoern A. Zeeb 0a57589121 LinuxKPI: implement dmam_free_coherent()
dmam_free_coherent() is used by an updated mt76 driver at v6.19-rc6.
We need to surgically find the devres information and destroy it before
calling dma_free_coherent.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D54810
2026-01-25 12:35:22 +00:00
Bjoern A. Zeeb bf4aa758dd LinuxKPI: PTP add (*settime64) to struct ptp_clock_info
While iwlwifi supportes PTP, LinuxKPI does not and we only add the
definitons to avoid mangling upstream drivers.
iwlwifi(4) does not even support the (*settime64) callback but only
returns -EOPNOTSUPP.

Sponosred by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D54802
2026-01-25 12:35:21 +00:00
Jose Luis Duran 4f093770b5 nanobsd: Fix _populate_part()
- Avoid unnecessary subshell execution
- Fix removing the temporary and empty /cfg directory
- Do not remove the generated metalog file for /cfg or /data partitions

Fixes:		61ac7309c3 ("nanobsd: Add a provisional populate_part function")
MFC after:	3 days
2026-01-25 10:59:27 +00:00
Enji Cooper da59b3147b Account for the ctl test needing the ctl(4) module
This testcase does not function unless the /dev/ctl/... node exists,
which is created by the ctl(4) module. Require the ctl(4) module to be
loaded so the test can be executed.

MFC after: 1 week
Differential Revision:	https://reviews.freebsd.org/D54518
2026-01-24 16:18:45 -08:00
Colin Percival f0ecf357aa vmimage.subr: Install pkg on pkgbase images
When building VM and Cloud images with a packaged base system, install
the pkg package; this makes it possible for the base system to be
updated without installing pkg from the FreeBSD-ports repository.

Sponsored by:	Amazon
2026-01-24 12:18:35 -08:00
Colin Percival ec2b3d786b loader: Only warn for !FDT && !ACPI take two
For unclear reasons, we used to print two warnings about not having a
DTB: First,
	printf("No valid device tree blob found!\n");
and immediately later a second,
	printf("WARNING! Trying to fire up the kernel, but no "
	    "device tree blob found!\n");

A previous commit silenced the second warning in the event that the
acpi.revision environment variable was set, on the theory that systems
which have ACPI might not need a DTB; this commit silences the first
of the two warnings under the same condition.

Reviewed by:	andrew
Fixes:	3989a3d817 ("loader: Only warn when we have neither FDT nor ACPI")
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D54772
2026-01-24 12:18:35 -08:00
Jean-Sébastien Pédron 710167623d linuxkpi: Implement <linux/seq_buf.h>
It is a wrapper above a `char *` to track the overall available space in
the buffer as well as the used space. This wrapper does not manage
memory allocation.

The DRM generic code started to use this in Linux 6.10.

Reviewed by:	bz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D54488
2026-01-24 20:16:14 +01:00
Michael Osipov 28764001b5 vt.4: Document that hw.vga.textmode does not apply for UEFI(8) boot
PR:		292598
Approved by:	ziaee, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54842
2026-01-24 19:41:29 +01:00
Alan Somers 52ddca7c2e fusefs: style
Reorder macro definitions.
2026-01-24 09:02:44 -07:00
Alan Somers ffb747d587 fusefs: Add tests for the new -o auto_unmount feature
Add tests for mount_fusefs's new -o auto_unmount feature, recently added
by arrowd.

MFC with:	10037d0978 "fusefs: Implement support for the auto_unmount"
2026-01-24 09:02:33 -07:00
Peter Holm c2b513335f stress2: Added two new test scenarios 2026-01-24 13:30:31 +01:00
Peter Holm 833f9294b4 stress2: Added two syzkaller reproducers. Updated the exclude file 2026-01-24 13:28:54 +01:00
Gleb Popov 10037d0978 fusefs: Implement support for the auto_unmount option kernel-side
libfuse clients may pass the "-o auto_unmount" flag to ensure that the mountpoint
will get unmounted even if the server terminate abnormally. Without this flag
sending KILL to a FUSE daemon leaves its mountpoint mounted.

Approved by:	asomers
Differential Revision:	https://reviews.freebsd.org/D53086
2026-01-24 13:06:16 +03:00
Pouria Mousavizadeh Tehrani 04f6b99947 netlink: use caller's credentials in rtnl_handle_newlink
Make sure rtnl_handle_newlink sets the caller's credential
during calls to ifc_create_ifp_nl and ifc_modify_ifp_nl

Reviewed by: glebius, melifaro
Approved by: glebius (mentor)
Differential Revision: https://reviews.freebsd.org/D54109
2026-01-24 13:20:50 +03:30
Jose Luis Duran cd730bef74 nanobsd: Use mtree -C to produce the metalog
Prefer an mtree -C output, which is guaranteed to be mtree-compatible.
Add "gname", "uname", and "tags" to the default keyword set, while
removing "size" and "time", the latter being set on kernel file entries
and taking precedence over makefs -T (when paired with -F).

As a side effect, this produces a cleaner file with sorted keywords.

Note that passing "-u" to sort in order to pipe to mtree is no longer
necessary, but we'll do it out of habit.

Reviewed by:	imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54854
2026-01-24 02:06:57 +00:00