Commit Graph

300916 Commits

Author SHA1 Message Date
Mark Johnston 5202cfcf93 inotify: Add man pages for the new syscalls and for VOP_INOTIFY
Reviewed by:	kib
MFC after:	3 months
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D50315
2025-07-04 14:42:33 +00:00
Mark Johnston e02d4fab54 kdump: Add support for decoding inotify events
These are emitted when reading from an inotify descriptor.

MFC after:	3 months
Sponsored by:	Klara, Inc.
2025-07-04 14:42:33 +00:00
Mark Johnston 4d08e7815d truss: Add a decoder for inotify_add_watch_at(2)
MFC after:	3 months
Sponsored by:	Klara, Inc.
2025-07-04 14:42:33 +00:00
Mark Johnston b79bd43f9a libsysdecode: Add support for decoding inotify syscall flags
MFC after:	3 months
Sponsored by:	Klara, Inc.
2025-07-04 14:42:33 +00:00
Mark Johnston bc4430dc20 vfs: Add event notification points
The INOTIFY macro and its variants check if the vnode is being watched,
and if so, calls into a slow path which adds an event to one or more
inotify descriptors.  Most of these events correspond to EVFILT_VNODE
events as well, and are added to VOP *_post hooks.

Reviewed by:	kib
MFC after:	3 months
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D50315
2025-07-04 14:42:33 +00:00
Mark Johnston cf65b5e43d libsys: Add inotify support
Include the two new syscalls in the symbol map.

Reviewed by:	kib
MFC after:	3 months
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D50315
2025-07-04 14:42:33 +00:00
Mark Johnston 245ff4c4b2 libc: Add inotify support
inotify_init() and inotify_init1() are implemented using __specialfd(2).
inotify_add_watch() is implemented in terms of inotify_add_watch_at(2).

Reviewed by:	kib
MFC after:	3 months
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D50315
2025-07-04 14:42:33 +00:00
Mark Johnston d4ead7edbb inotify: Regenerate syscall definitions
Sponsored by:	Klara, Inc.
2025-07-04 14:42:33 +00:00
Mark Johnston f1f230439f vfs: Initial revision of inotify
Add an implementation of inotify_init(), inotify_add_watch(),
inotify_rm_watch(), source-compatible with Linux.  This provides
functionality similar to kevent(2)'s EVFILT_VNODE, i.e., it lets
applications monitor filesystem files for accesses.  Compared to
inotify, however, EVFILT_VNODE has the limitation of requiring the
application to open the file to be monitored.  This means that activity
on a newly created file cannot be monitored reliably, and that a file
descriptor per file in the hierarchy is required.

inotify on the other hand allows a directory and its entries to be
monitored at once.  It introduces a new file descriptor type to which
"watches" can be attached; a watch is a pseudo-file descriptor
associated with a file or directory and a set of events to watch for.
When a watched vnode is accessed, a description of the event is queued
to the inotify descriptor, readable with read(2).  Events for files in a
watched directory include the file name.

A watched vnode has its usecount bumped, so name cache entries
originating from a watched directory are not evicted.  Name cache
entries are used to populate inotify events for files with a link in a
watched directory.  In particular, if a file is accessed with, say,
read(2), an IN_ACCESS event will be generated for any watched hard link
of the file.

The inotify_add_watch_at() variant is included so that this
functionality is available in capability mode; plain inotify_add_watch()
is disallowed in capability mode.

When a file in a nullfs mount is watched, the watch is attached to the
lower vnode, such that accesses via either layer generate inotify
events.

Many thanks to Gleb Popov for testing this patch and finding lots of
bugs.

PR:		258010, 215011
Reviewed by:	kib
Tested by:	arrowd
MFC after:	3 months
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D50315
2025-07-04 14:42:33 +00:00
Ahmad Khalifa 4695e3aa7c gpio: attach gpiobus when the controller is ready
Only attach gpiobus when the controller is fully initialized. Children
of gpiobus expect this to be the case.

Reviewed by:	mmel, imp, andrew
Approved by:	imp (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D51088
2025-07-04 16:56:00 +03:00
Ahmad Khalifa 2c356c8b8f gpiobus: add a gpiobus_add_bus function
Some drivers need to postpone the attachment of gpiobus until hardware
init is done. Add a new gpiobus_add_bus function to accommodate this
case.

Suggested by:	mmel, andrew
Reviewed by:	mmel, imp, andrew
Approved by:	imp (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D51133
2025-07-04 16:55:55 +03:00
Ahmad Khalifa c2d8cca771 gpio: remove redundant calls to bus_attach_children
gpiobus_attach_bus already calls it.

Reviewed by:	mmel, imp, andrew
Approved by:	imp (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D51108
2025-07-04 16:55:05 +03:00
Kristof Provost 945ba658d8 pfctl: Error out on missing table command, zap internal wrapper function
Table name and table command require each other as reflected in the
synopsis [-t table -T command [address ...]], so print usage and exit if
only one of them is given.

By moving the inter-dependence check right after option parsing is done,
we can bail out even before opening pf(4) and drop the internal wrapper
pfctl_command_tables() as unneeded indirection with now duplicate checks.

OK sashan

Obtained from:	OpenBSD, kn <kn@openbsd.org>, 97699edbc9
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:13 +02:00
Kristof Provost 3c24dfa30b pfctl.8: Explicitly mention that tables created by -T{add,replace} are persistent
pf.conf(5)'s TABLE section explains it, but lets be clear about it in the
table command descriptions, too.

"go for it" jmc

Obtained from:	OpenBSD, kn <kn@openbsd.org>, 8d4231551f
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:12 +02:00
Kristof Provost f7289cce49 pf: Check for main ruleset explicitly
All rulesets reference their parent anchor, except for the special cased
main anchor containing the main ruleset, which's reference is always NULL
since initialization and never changes.

Replacing nullity tests with clearer equality checks makes the code less
ambigious and easier to understand.

OK sashan

Obtained from:	OpenBSD, kn <kn@openbsd.org>, 55038654e1
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:12 +02:00
Kristof Provost ddb8faceb1 pf.4: DIOCIGETIFACES provides interfaces and groups, not drivers
"driver" is a left-over from earlier implementations.

Nowadays each driver such as lo(4) has it's respective interface group of
the same name ("lo"), but additional driver-independent groups exist, too:

        # ifconfig lo0 group foo
        # pfctl -s I -i foo
        foo
        lo0

OK henning

Obtained from:	OpenBSD, kn <kn@openbsd.org>, 822e892650
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:12 +02:00
Kristof Provost 651fbbc9a6 pf: Rename pf_anchor_remove() to pf_remove_anchor()
For semantic consistency with pf_{create,find,remove}_{anchor,ruleset}().

Simplify logic by squashing the if/else block while here.
No functional change.

Feedback jca and mikeb, OK mikeb

Obtained from:	OpenBSD, kn <kn@openbsd.org>, f6275afa61
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:12 +02:00
Kristof Provost 58571f3ea3 pf: Remove useless macros
These are just unhelpful case conversion.

OK sashan henning

Obtained from:	OpenBSD, kn <kn@openbsd.org>, 492cf6614c
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:11 +02:00
Kristof Provost 614ae218ca pf: pf_create_kanchor() can be static
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:11 +02:00
Kristof Provost 9ec47b79c1 pf: replace hardcoded function names by __func__
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:11 +02:00
Kristof Provost f78c18a7ac pfctl: sync cmdline_symset() changes with src/usr.sbin
OK sashan@ claudio@

Obtained from:	OpenBSD, miko <miko@openbsd.org>, 22023c0153
Obtained from:	OpenBSD, kn <kn@openbsd.org>, d0f238ef32
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:11 +02:00
Kristof Provost 7d5d1fae28 pfctl: odd condition/test in PF lexer
This commit rectifies earlier change:

    in the lex... even inside quotes, a \ followed by space or tab should
    expand to space or tab, and a \ followed by newline should be ignored
    (as a line continuation).  compatible with the needs of hoststated
    (which has the most strict quoted string requirements), and ifstated
    (where one commonly does line continuations in strings).

OK deraadt@, OK millert@

Obtained from:	OpenBSD, sashan <sashan@openbsd.org>, a153335958
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:11 +02:00
Kristof Provost b168cac066 pf: honor quick on anchor rules
Regression has been introduced in version 1.1024 (a 6.2 time frame).
  It's been discovered and reported by Fabian Mueller-Knapp. Fair amount
  of credit goes to kn@, benno@ and henning@ for pointing me to releveant
  section of pf.conf(5). Fabian and kn@ also did test the patch.

OK kn@, henning@

Obtained from:	OpenBSD, sashan <sashan@openbsd.org>, 7e89334d42
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:10 +02:00
Kristof Provost 90b0159163 pf: use PFR_RB_NONE consistently
Replace hardcoded 0 and implicit checks with enum as done in all other
use cases of `pfra_fback'.  No object change.

OK sashan

Obtained from:	OpenBSD, kn <kn@openbsd.org>, ab23e671fc
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-04 10:31:10 +02:00
Andriy Gapon ad0c3859a9 mmc_da: garbage-collect sdda_get_max_data
The function is unused since 5aedb8b1d4.

For information, in MMC CAM both XPT_GET_TRAN_SETTINGS and XPT_PATH_INQ
obtain data using MMC_SIM_GET_TRAN_SETTINGS.  So, "overlapping"
information like ccb_trans_settings_mmc::host_max_data and
ccb_pathinq::maxio is derived from the same source.
That's why sdda_get_max_data was redundant.

Reported by:	bz
MFC after:	5 days
2025-07-04 11:01:00 +03:00
Gleb Popov c51660a622 fusefs: exterrorize fuse_vnops.c
Approved by:	asomers
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1727
2025-07-04 10:14:21 +03:00
Gleb Popov d4c8fd3a2c fuse_vnop_allocate: Drop duplicated vfs_isrdonly() check
Approved by:	asomers
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1727
2025-07-04 10:14:21 +03:00
Tom Jones d72c74a6c5 loader: Add halt as an alias to poweroff machine
Add halt as an alias to also poweroff a machine from the loader prompt,
this is consistent with ddb.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D51132
2025-07-04 07:37:31 +01:00
Bjoern A. Zeeb 228b43c258 iwlwifi: compile in ACPI support
Now that LinuxKPI supports the lower case Linux ACPI spellings under
LINUXKPI_WANT_LINUX_ACPI we only need to provide the debug macro to
allow us to compile in ACPI support.

This ties into regulatory and will be used, e.g., for 11ax, 11be,
and Per Platform Antenna Gain (PPAG) settings.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-07-04 05:22:22 +00:00
Bjoern A. Zeeb 8c97c46418 rtw89: enable ACPI support on FreeBSD
Now that LinuxKPI supports the lower case Linux ACPI spellings under
LINUXKPI_WANT_LINUX_ACPI remove the #ifdef around the code and compile in
ACPI support.

Sponsored by:	The FreeBSD Foundation
MFC after;	3 days
2025-07-04 05:22:22 +00:00
Felix Johnson bd173a540c write.2: Add EINVAL to ERRORS
Since phk rewrote the block layer ~2 decades ago, write(2) can return
EINVAL when the target is a block device and nbytes, the write size, is
not a multiple of the sector's block size.

From the original PR:
When coming from Linux, people are surprised by the fact
that write(2) to a device must be aligned to block size.
Writing a non-aligned block onto a raw device is a case
where EINVAL is also returned but the manpage does not mention this.

MFC after:		3 days
PR:			227185
Reported by:		riggs
Reviewed by:		imp, Pau Amma <pauamma@gundo.com>
Differential Revision:	https://reviews.freebsd.org/D51138
2025-07-04 01:14:19 -04:00
Bjoern A. Zeeb 842da154a0 Bump __FreeBSD_verion for LinuxKPI changes to device.h and acpi.
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
X-MFC:		acpi part only
2025-07-04 03:22:23 +00:00
Bjoern A. Zeeb ba6460df56 LinuxKPI: acpi: add acpi_evaluate_dsm()
Add a acpi_evaluate_dsm() wrapper around the native implementation
as needd by wireless drivers.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50864
2025-07-04 03:22:22 +00:00
Bjoern A. Zeeb 2ddfcc013c LinuxKPI: acpi: provide union [linuxkpi]_acpi_(object|buffer)
Provide union acpi_(object|buffer) as linuxkpi_ versions and in Linux
native lower case spelling so that driver code compiles unmodified.

Use the linuxkpi_ prefix to avoid name clashes with the native ACPI
implementation which uses CamelCase.

Use the linuxkpi_ names internally and redefine the linuxkpi_ unions
to their native names so they are avail as expected in drivers.

As a transition to not break drm-kmod which has in-place (no #ifdef)
changes from Linux spelling ot FreeBSD spelling, introduce
LINUXKPI_WANT_LINUX_ACPI so we have the Linux spelling as an opt-in.
That way the transition can happen gracefully and once "top-of-trees"
are all sorted we can remove the #ifdefs here again.

Bump __FreeBSD_version to be able to detect this change.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	wulf (previous version), dumbbell
Differential Revision: https://reviews.freebsd.org/D50863
2025-07-04 03:22:22 +00:00
Bjoern A. Zeeb 16c6a3444a LinuxKPI: device.h add (*shutdown)
There are too many ways to call (*shutdown)() and others in Linux
it seems;  rather than using the one from dev_pm_ops or directly
on the bus system device, some wireless drivers are setting it on
struct device_driver so add it.

Bump __FreeBSD_version as this changes the size of various other
structs which have struct device_driver embedded.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50679
2025-07-04 03:22:22 +00:00
Bjoern A. Zeeb 2f5666c172 LinuxKPI: MODULE_DEVICE_TABLE() factor out the bus specific MODULE_PNP_INFO()
In order to be able to use MODULE_DEVICE_TABLE() with multiple bus
attachments, factor out the bus-specfic MODULE_PNP_INFO() and place
it next to the structure defining the table.

As it turns out bnxt(4) has been using the MODULE_DEVICE_TABLE() with
PCI attachments for the "auxillary" bus so far.  That makes little sense.
Define the MODULE_PNP_INFO() to nothing for that.  We may consider
pulling these LinucKPI bits in semi-native drivers into LinuxKPI
one day as that route is not really sustainabke.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	imp, dumbbell
Differential Revision: https://reviews.freebsd.org/D51049
2025-07-04 03:22:22 +00:00
Bjoern A. Zeeb f58e032410 LinuxKPI: MODULE_DEVICE_TABLE() remove hard coded pci
While we currently only use MODULE_DEVICE_TABLE() for pci (or so I
thought [*]), this may soon change.  Remove a hard coded "pci" for
the bus and use the bus name passed in as _bus.

[*] see follow-up change

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	imp, dumbbell
Differential Revision: https://reviews.freebsd.org/D51048
2025-07-04 03:22:22 +00:00
Alan Cox 1c1acaf685 amd64: enable EFER.TCE
Setting this option tells AMD processors that targeted TLB invalidation
instructions, such as invlpg, only have to invalidate cached entries
from the upper levels of the page table that lie along the path to the
targeted virtual address.  Otherwise, by default, all cached entries
from the upper levels of the page table are invalidated.

After unmapping a page table page we always perform a TLB invalidation
that will invalidate any cached references to that page table page, so
this option is safe to enable.

Reviewed by:	kib, markj
Tested by:	dougm
Differential Revision:	https://reviews.freebsd.org/D51093
2025-07-03 16:30:02 -05:00
Ruslan Bukin 906d7a4b52 hwt: fix !SMP build.
Sponsored by:	UKRI
2025-07-03 21:43:01 +01:00
Ruslan Bukin 070d185b2f hwt: fix build.
Include sys/lock.h header for spinlock_enter() prototype.

Sponsored by:	UKRI
2025-07-03 21:36:18 +01:00
James Mintram 3fee738c4e firmware.9: Fix minor grammar typos
MFC after:	3 days
Reviewed by:	ziaee
Closes:		https://github.com/freebsd/freebsd-src/pull/1749
2025-07-03 15:31:51 -04:00
Mark Johnston 5e213d8a74 random: Remove ARGSUSED annotations from random_harvestq.c
Such annotations are obsolete, the compiler tells us when parameters are
unused.  No functional change intended.

Reviewed by:	cem
MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51114
2025-07-03 17:31:42 +00:00
Mark Johnston e2a96b8340 random: Define a macro for getting the CPU cycle count
Entropy queue entries always include the low 32 bits of a CPU cycle
count reading.  Introduce a macro for this instead of hard-coding
get_cyclecount() calls everywhere; this is handy for testing purposes
since this way, random(4)'s use of the cycle counter (e.g., the number
of bits we use) can be changed in one place.

No functional change intended.

Reviewed by:	cem, delphij
MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51113
2025-07-03 17:31:42 +00:00
Mark Johnston 4b8b872a9c random: Move entropy harvest queue lock macros to random_harvestq.c
They can't be used externally, so it makes no sense to have them in a
header.  No functional change intended.

Reviewed by:	cem
MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51111
2025-07-03 17:21:37 +00:00
Mark Johnston 6ccf1801f2 random: Replace a comment with a static assertion
No functional change intended.

Reviewed by:	cem
MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51110
2025-07-03 17:21:18 +00:00
Mark Johnston 027beb002b vmm: Add a missing entry to the ioctl table
Reported by:	acm
Fixes:		b9ef152bec ("vmm: Merge vmm_dev.c")
2025-07-03 17:02:43 +00:00
Claudiu I. Palincas 6b8f0b4777 fusefs: Upgrade FUSE protocol to version 7.35.
Upgrade the FUSE API from protocol 7.33 to 7.35.
Add support for FOPEN_NOFLUSH, introduced in 7.35.

Also, reduce diffs vis-a-vis upstream by factoring out an ioctl type, a
change missed in d5e3cf41e8.

Signed-off-by:	Claudiu I. Palincas <mscotty@protonmail.ch>
Reviewed by:	asomers
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1744
2025-07-03 10:23:10 -06:00
Mark Johnston 5ae9f8e9ac md: Restore guards in mddestroy()
mddestroy() may be invoked on a partially constructed md device.
Restore the guards that handled this prior to commit e910221681.

Reported by:	syzbot+a0ff73f664de8757cfaa@syzkaller.appspotmail.com
Reported by:	syzbot+7b4a4824bf81548283ab@syzkaller.appspotmail.com
Reviewed by:	kib
Fixes:		e910221681 ("md(4): move type-specific data under union")
Differential Revision:	https://reviews.freebsd.org/D51145
2025-07-03 15:10:41 +00:00
Ruslan Bukin df114daef4 Import the Hardware Trace (HWT) framework.
The HWT framework provides infrastructure for hardware-assisted tracing. It
collects detailed information about software execution and records it as
"events" in highly compressed format into DRAM. The events cover information
about control flow changes of a program, whether branches taken or not,
exceptions taken, timing information, cycles elapsed and more. This allows
to reconstruct entire program flow of a given application.

This comes with separate machine-dependent tracing backends for trace
collection, trace decoder libraries and an instrumentation tool.

Reviewed by:	kib (sys/kern bits)
Sponsored by:	UKRI
Differential Revision:	https://reviews.freebsd.org/D40466
2025-07-03 15:48:34 +01:00
Kristof Provost 9d004de910 pf tests: verify that 'quick' works on anchors
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-03 09:16:15 +02:00