LinuxKPI: pci: fix two errors in lkpi_pci_get_device()
On any result we need to acquire a reference. pci_dev_get() deals with
a NULL argument so we can simply pass what we "found" at the end.
This will avoid reference count problems.
If the iteration on the linux list in lkpi_pci_get_device() does
not find a match pdev will still be defined at the end of the
loop but not pointing to a valid pdev.
Store the found entry in a 2nd variable which otherwise will be NULL.
This will avoid random panics, usually in sysfs_remove_dir() when
the reference gets released.
Found during mt76 bringup.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Fixes: 8f61992d7cc11
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D50153
LinuxKPI: add ktime_get_boottime_seconds()
ktime_get_boottime_seconds() is needed by an updated iwlwifi driver.
Sposored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D50005
LinuxKPI: add _devcd_free_sgtable() to devcoredump.h
It may be that once we implement freeing of chained tables
_devcd_free_sgtable() will become our _lkpi_dev_coredumpsg_free()
but further investigations need to happen. For now make an
updated iwlwifi driver happy which should not need more.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D50006
LinuxKPI: pci: deal with kobject_add() being able to fail
lkpifill_pci_dev() uses a sequene of kobject_init/set_name/add.
The problem is that kobject_add could fail.
Move the entire logic to the beginning of the function,
switch to kobject_init_and_add() and check the return code.
Make lkpifill_pci_dev() return the error and deal in the callers
with a possible error accordingly.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D50154
src.conf.5: Add WITH_ZONEINFO_LEAPSECONDS_SUPPORT warning
People are turning on the option and then tripping over weird
consequences. See bugs 248338 and 271170 as examples.
Approved by: cy, imp, philip
Differential Revision: https://reviews.freebsd.org/D25902
Co-authored-by: Joseph Mingrone <jrm at FreeBSD.org>
bsddialog: Correct type for bsddialog_total_progview
It was an int, but printed with %lli format. Although it would be
reasonable to use a 32-bit int here (i.e., changing the printf format
instead) this matches what was done in bsddialog upstream (and now in
main).
PR: 286655
Reviewed by: asiciliano
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50261
service(8): Allow for passing no arguments to the service script
Currently, service(8) requires the user to provide a command to the
rc service script. For example,
service cron
does not even run the cron rc service script but
instead shows the usage message of service(8).
This patch makes it so running the rc service script with no arguments
via service(8) is closer to running the rc service script directly
(e.g., /etc/rc.d/cron).
Long story short, for most of the rc service scripts this change means
that running "service FOO" now shows the usage message of FOO instead of
the usage message of service(8).
PR: 255115
[4 lines not shown]
vm_page: make iter_insert() public
In places where vm_page_insert() is used after lookups, or for
consecutive pages, use vm_page_iter_insert instead, to exploit
locality.
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D50248
vm_page_grab_pages: fetch page ranges
Define an iterator based function for reading a range of consecutive,
non-NULL leaves from a pctrie. Adapt it to vm pages. Use it in
vm_page_grab_pages to fetch more than one page at a time.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D50253
crypto: Remove uses of CRYPTO_F_DONE
Previously OCF set CRYPTO_F_DONE prior to invoking the completion
callback, even if the request failed. This isn't particularly useful
and leads to bugs when consumers retry a failed request, since OCF also
asserts that CRYPTO_F_DONE is clear in crypto_dispatch(). (Really, OCF
should retry requests that fail with EAGAIN, but that's a larger
change.)
For now, just stop setting CRYPTO_F_DONE to simplify consumers (and fix
those which fail to clear the flag before retrying a request).
PR: 286321
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D50104
krb5: Fix handling of transient crypto request failures
- Instead of using CRYPTO_F_DONE to decide whether a request has
completed, use a custom protocol of setting crp_opaque = NULL in the
callback and checking that instead. CRYPTO_F_DONE is set independent
of whether an error occurred, but for transient errors signaled by
EAGAIN, we want to simply retry the request.
- Clear CRYPTO_F_DONE before retrying the request.
- Panic if the request truly failed, as we currently have no way to
pass hard errors back up.
Reviewed by: jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D50238
net80211: fix a race between ieee80211_sta_join and scan entries
We were seeing panics during ieee80211_sta_join() which seemed that
the ni->ni_chan was not valid anymore, which was true.
We also saw errors indicating data put into ni_ies became inalid.
The problem was that the ieee80211_scan_entry passed into
ieee80211_sta_join() (in the observed case from setmlme_assoc_sta())
became invalid during ieee80211_alloc_node().
As a result for the ni_chan case the the rateset and len in rates[1]
became invalid. Similarly for the IEs.
Make a (deep)copy of the scan entry in setmlme_assoc_sta() and return
the copy as once we leave ieee80211_scan_iterate() we can no longer
rely on the scan entry to be valid.
Sponsored by: The FreeBSD Foundation
Reported by: rm, ziaee, bz
Tested by: rm, ziaee, bz
[7 lines not shown]
loader: i386: use -z nostart-stop-gc for bfd as well
binutils 2.37 seems to have added the knob, so let's just use that
version here (it's not clear if GC'ing start/stop symbols was actually
made the default at the time, and it didn't seem worth it to dig much
further). This fixes misbehavior when built with more recent binutils,
as we do rely on linker sets for loader commands that we use.
Reported by: sjg
Reviewed by: dim, sjg
Differential Revision: https://reviews.freebsd.org/D50252
pci: Ignore PCRx devices resources
Some systems provide two PCI root complex devices in the ACPI tables.
Allow us to skip known pci-like devices even if they aren't detected
as a PCI root complex.
Reviewed by: cognet, jhb
Co-authored-by: cognet
Differential Revision: https://reviews.freebsd.org/D49709
Revert "VFS cache: Fix initial sizing for non-default 'ncsizefactor'"
Because it unadvertently was committed without the proper tags. Will be recommitted with them.
This reverts commit 455203ec8885 (VFS cache: Fix initial sizing for non-default 'ncsizefactor', 2025-05-01).
libusb: Emit event after deregistering hotplug handler
The original implementation did not emit an event when a hotplug handler
was deregistered. This omission causes issues for programs that follow
the best practices recommended by libusb—particularly those that use
`libusb_hotplug_register_callback()` or similar functions in a loop
while managing hotplug handlers dynamically.
Without emitting an event after deregistration, these programs can
become stuck waiting indefinitely for an event that will never come,
as the condition to break out of the wait loop is never satisfied.
See: https://github.com/libusb/libusb/blob/6c0ae1ab456da49e7805115e77ce0428ace4ea41/libusb/hotplug.c#L459
Reviewed by: bapt
Sponsored By: FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50170
queue(3): Install *_SPLIT_AFTER() links to the main manual page
Completes commit "queue(3): New *_SPLIT_AFTER(), *_ASSERT_EMPTY(),
*_ASSERT_NONEMPTY()" (c02880233949b01f).
MFC after: 1 day
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c071616b06aa0f51ac4314f989c472d0268c2ddb)
sysctl(9): Ease exporting struct sizes; Discourage doing that
Introduce two helpers, the more general SYSCTL_SIZEOF() and
a struct-specific one SYSCTL_SIZEOF_STRUCT() which prepends 'struct' in
the description and in the use of sizeof() but uses the raw structure
name as the knob's name. The size of the object/structure is exported
under 'debug.sizeof'.
Existing knobs under 'debug.sizeof' were all converted to use the
helpers.
Add a note before the helpers discouraging the introduction of new
leaves for ad-hoc reasons. List alternative means for developers to
obtain the size of arbitrary kernel structures easily (thanks to markj@
for providing these).
No functional change (intended).
Reviewed by: kib, markj
[5 lines not shown]
stress2: exlock2.sh: Preserve behavior after ps(1)'s '-U' change
Remove '-Uroot', as now '-U' selects processes based on their real user
IDs, and since the program using them was launched as 'root', the
equivalent now is just to remove it, as now ps(1) by default selects
processes based on its effective UID (root) and their effective UIDs.
It seems that matching on effective or real UID does not really matter
in this test, but at least this change simplifies the command-line.
MFC after: 1 day
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50200
(cherry picked from commit 1265d3b07eaa418e9c60800db93f3482ddbb6ae2)
rc/tests: Fix process flags checks using ps(1)
These checks use ps(1) with both the '-p' and '-a' flags, which worked
so far as ps(1)'s '-a' option was buggy. Since the fix in commit
"ps(1): Make '-a' and '-A' always show all processes"
(93a94ce731a89b56), such a command-line always selects all processes,
making the specified '-p' useless and the test wrong. Remove the
useless '-a'.
While here, remove the redundant '-x', as '-p' implies '-x' by default.
MFC after: 1 day
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50201
(cherry picked from commit 646375408742dd5ed9abb174a621a3f8f65a56ef)
ps.1: Remove ambiguity in description of option '-J'
As stated in the previous commit, option '-J' was introduced by commit
"Add -J to filter by matching jail IDs and names."
(13767130c7147ae7182a, r265229), which unfortunately talked about '-J'
being a filter while actually implementing it as a regular selection
option which adds to the processes to display.
The manual page's formulation hinted more at '-J' being a filter, which
it is not, or could be just considered ambiguous, because of the
presence of the "only" word. Consequently, remove it and reformulate.
Reviewed by: ziaee, dch
MFC after: 1 day
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50194
(cherry picked from commit cbda1aea6532697247bcca6e59d45775857c35e2)
RELNOTES: ps(1): Document change in behavior for '-a'/'-A'
Document the practical consequence of change "ps(1): Make '-a' and '-A'
always show all processes" (93a94ce731a8) that specifying '-a'/'-A'
leads to printing all processes regardless of the presence of other
process selection options (except for '-x'/'-X', which command
a filter).
While here, mention a possible practical issue with '-J', as reported by
dch@. This option was introduced by commit "Add -J to filter by
matching jail IDs and names." (13767130c7147ae7182a, r265229), which
unfortunately talked about '-J' being a filter while actually
implementing it as a regular selection option which adds to the
processes to display.
Reviewed by: dch
MFC after: 1 day
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50193
[4 lines not shown]