Commit graph

152848 commits

Author SHA1 Message Date
Doug Moore
faa9356f97 swap_pager: fix seek_hole assert
Moving code from tmpfs to swap_pager introduced another WLOCKED object
assert that should have been an RLOCKED object assert.  Fix it.
2024-10-24 18:08:32 -05:00
Doug Moore
02e85d1c8a swap_pager: fix assert in seek_data
An assertion that an object was write-locked should be instead an
assertion that the object is read locked.

Reported by:	Jenkins
Fixes:	 db08b0b04d tmpfs_vnops: move swap work to swap_pager
Differential Revision:	https://reviews.freebsd.org/D47278
2024-10-24 18:04:19 -05:00
Michael Tuexen
ce5b5361d4 sctp garbage collect sctp_update_ifn_mtu
MFC after:	3 days
2024-10-24 22:00:59 +02:00
Doug Moore
db08b0b04d tmpfs_vnops: move swap work to swap_pager
Two functions in tmpfs_vnops.c use an interface provided by
swap_pager.c. Move most of the implementation of those functions to
swap_pager.c so that they can be implemented more effectively, with
access to implementation details of the swap pager.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D47212
2024-10-24 14:24:49 -05:00
Gleb Smirnoff
d021d3b3c6 tcp: get rid of TDP_INTCPCALLOUT
With CALLOUT_TRYLOCK we don't need this special flag.

Reviewed by:		jtl
Differential Revision:	https://reviews.freebsd.org/D45748
2024-10-24 10:14:03 -07:00
Gleb Smirnoff
bffebc336f tcp: use CALLOUT_TRYLOCK for the TCP callout
This allows to remove the drop of the lock tcp_timer_enter(), which closes
a sophisticated but possible race that involves three threads.  In case we
got a callout executing and two threads trying to close the connection,
e.g. and interrupt and a syscall, then lock yielding in tcp_timer_enter()
may transfer lock from one closing thread to the other closing thread,
instead of the callout.

Reviewed by:		jtl
Differential Revision:	https://reviews.freebsd.org/D45747
2024-10-24 10:14:03 -07:00
Gleb Smirnoff
efcb2ec8cb callout: provide CALLOUT_TRYLOCK flag
If a callout was initialized with the flag, then the callout(9) system
will not drop the callwheel lock in softclock_call_cc() to obtain the
callout lock.  Instead it will use try-lock semantic to obtain the
callout's lock.  In case of a failure the callout will be rescheduled to
the 50% of the precision value.  The main benefit of such behavior is not
the avoidance of the lock contention in the callout thread, but the fact
that callout with such flag can be actually stopped in a safe manner,
because the race window in the beginning of softclock_call_cc() is closed.

Call of callout_stop() on such a callout would guarantee that nothing will
be executed after callout_stop() returns, neither callout lock will be
dereferenced.  A callout marked as CALLOUT_TRYLOCK |
CALLOUT_RETURNUNLOCKED can call callout_stop() from the callout function
itself (0, a failure to stop, will be returned), then unlock the lock and
then free the memory containing the callout structure.

Caveat: when calling callout_stop() from outside the callout function, the
return value from callout_stop() is still inconsistent.  A race window at
the end of softclock_call_cc() still exists, so callout_stop() may report
failure to stop, which would not be true.

Reviewed by:            jtl, kib
Differential Revision:	https://reviews.freebsd.org/D45746
2024-10-24 10:14:03 -07:00
Gleb Smirnoff
656991b0c6 locks: augment lock_class with lc_trylock method
Implement for mutex(9) and rwlock(9).

Reviewed by:		jtl
Differential Revision:	https://reviews.freebsd.org/D45745
2024-10-24 10:14:03 -07:00
Zhenlei Huang
2f395cfda8 tcp cc: Remove a stray semicolon
MFC after:	1 week
2024-10-24 23:04:50 +08:00
Zhenlei Huang
36756195a3 ocs_fc: Remove a stray semicolon
MFC after:	1 week
2024-10-24 23:04:50 +08:00
Zhenlei Huang
86a2c910c0 mpi3mr: Remove a stray semicolon
MFC after:	1 week
2024-10-24 23:04:50 +08:00
Zhenlei Huang
6ccf4f4071 mana: Remove stray semicolons
MFC after:	1 week
2024-10-24 23:04:49 +08:00
Zhenlei Huang
75ff90814a enic: Remove a stray semicolon
MFC after:	1 week
2024-10-24 23:04:49 +08:00
Zhenlei Huang
b4856b8e9d LinuxKPI: Remove stray semicolons
MFC after:	1 week
2024-10-24 23:04:48 +08:00
Zhenlei Huang
88b71d1fe0 arm64: rockchip: Remove a stray semicolon
MFC after:	1 week
2024-10-24 23:04:48 +08:00
John Baldwin
f0bc751d6f csa: Use pci_find_device to simplify clkrun_hack
Reviewed by:	christos, imp
Differential Revision:	https://reviews.freebsd.org/D47222
2024-10-24 10:24:06 -04:00
Michael Tuexen
e4ac0183a1 sctp: cleanup
No functional change intended.

MFC after:	3 days
2024-10-24 13:24:49 +02:00
Michael Tuexen
ce20b48a60 sctp: improve debug output
MFC after:	3 days
2024-10-24 13:19:14 +02:00
Christos Margiolis
b1bb6934bb sound: Fix build error in chm_mkname() KASSERT
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
2024-10-24 14:57:19 +02:00
Christos Margiolis
802c78f519 sound: Untangle dsp_cdevs[] and dsp_unit2name() confusion
Before de8c0d15a64fa ("sound: Get rid of snd_clone and use
DEVFS_CDEVPRIV(9)"), sound(4) would create one device for each allocated
channel. The device names would be chosen from dsp_cdevs[], and created
with dsp_unit2name(). Additionally, dsp_cdevs[] was also used to match
these devices names, as well as OSSv4 aliases in dsp_clone().

Since sound(4) does not create separate devices for each channel
anymore, the meaning and use dsp_cdevs[] has changed. Part of it no
longer corresponds to devices at all, but instead is used to create
channel names, and another part is used to match only OSSv4 aliases in
dsp_clone().

To address this confusion, separate dsp_cdevs[] into a dsp_aliases[]
array, and move dsp_unit2name() to pcm/channel.c and rename it to
chn_mkname().

While here, get rid of the SND_DEV_DSPHW_* channel types, and simply use
the existing PCMDIR_* constants as the channel types. There is no need
to duplicate the same meaning twice.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D47199
2024-10-24 13:37:23 +02:00
Christos Margiolis
a4111e9dc7 sound: Change PCMDIR_* numbering
Needed by a follow-up patch, so that channels can be sorted properly.
This change does not affect the behavior of any subsystem.

While here, change to an enum.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D47198
2024-10-24 13:37:17 +02:00
Christos Margiolis
bb5e3ac1a7 sound: Use DSP_REGISTERED in dsp_clone()
DSP_REGISTERED calls PCM_REGISTERED, and already contains all the checks
we are doing.

No functional change intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D47196
2024-10-24 13:37:10 +02:00
Christos Margiolis
9693241188 sound: Call DSP_REGISTERED before PCM_DETACHING
DSP_REGISTERED first checks if the softc is not null, through
PCM_REGISTERED, which in turn calls PCM_ALIVE, whereas PCM_DETACHING
accesses the softc flags directly.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D47195
2024-10-24 13:37:01 +02:00
Andrew Turner
8efb1500d4 arm64: Enable handling EFI runtime service faults
Now we can handle EFI runtime service faults on arm64 do so.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D46818
2024-10-24 11:20:48 +01:00
Andrew Turner
d7f930b80e arm64: Implement efi_rt_arch_call
This is a function that calls into the EFI Runtime Services, but can
handle a fault. To support this add a handler in assembly that can
restore the kernel state on an exception and return a failure to the
caller.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D46817
2024-10-24 11:20:48 +01:00
Andrew Turner
a84653c5db arm64: Don't enable interrupts when in a spinlock
When we receive an exception while in a spinlock we shouldn't enable
interrupts. When entering a spinlock we disable interrupts so enabling
them here could cause surprising results.

The three cases that could cause this are:
 1. A break-before-make sequence
 2. Accessing possibly unmapped code with a fault handler
 3. Buggy code

1 and 2 are supported later in the data abort handler, and 3 should be
fixed when found.

Reviewed by:	mmel, kib, markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D46816
2024-10-24 11:20:48 +01:00
Andrew Turner
6204391e99 arm64: Check TDP_NOFAULTING in a data abort
As with other architectures when the TDP_NOFAULTING flag is set we
shouldn't panic when td_critnest is non-zero or if the witness check
fails.

The EFI runtime service functions will soon set this flag to handle
exceptions in the services.

Reviewed by:	markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D46815
2024-10-24 11:20:48 +01:00
Andrew Turner
3b03e1bb86 intrng: Store the IPI priority
When registering an interrupt controller we take a priority to compare.
We never store the priority so any later calls may act incorrectly.

Store the priority so later calls act as expected.

Reviewed by:	jrtc27
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D47235
2024-10-24 11:20:48 +01:00
Andrew Turner
b2dd4970c7 dev/gpio: Mask all pl011 interrupts
The firmware may have unmasked pl011 interrupts. If we don't have a
device to handle one the kernel will print a spurious interrupt
warning. Rather than print the warning mask all interrupts until we
are ready to handle them.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D46863
2024-10-24 11:20:48 +01:00
Kyle Evans
4f12b529f4 sys/intr.h: formally depend on machine/intr.h
sys/intr.h originally started life as an extract of arm's intr.h, and
this include was dropped in its place.  Changes in flight want to add
some MD definitions that we'll use in the more MI parts of INTRNG.

Let's formally reverse the dependency now since this is way more
common in general.  All of the includes switched in this change that I
spot-checked were in-fact wanting declarations historically included in
sys/intr.h anyways.

Reviewed by:	andrew, imp, jrtc27, mhorne, mmel, olce
Differential Revision:	https://reviews.freebsd.org/D47002
2024-10-23 22:55:29 -05:00
Elliott Mitchell
536c8d948e intrng: change multi-interrupt root support type to enum
uint32_t is handy for directly interfacing with assembly-language.  For
the C portion, enum is much handier.  In particular there is no need to
count the number of roots by hand.  This also works better for being
able to build kernels with varying numbers of roots.

Switch to INTR_ROOT_COUNT as this better matches the purpose of the
value.  Switch to root_type, rather than rootnum for similar reasons.

Remove the default from the core.  Better to require the architectures
to declare the type since they will routinely deviate and a default
chosen now will likely be suboptimal.

Leave intr_irq_handler() taking a register type as that better matches
for interfacing with assembly-language.
2024-10-23 22:55:21 -05:00
Elliott Mitchell
d64442a898 arm{,64}: use genassym for INTR_ROOT_* values
Rather than keeping the entire machine interrupt header assembly-safe,
switch to use of the existing genassym.c program to generate them.  This
will be handier in the long-term, most of the header never needs to be
exposed to assembly-language.
2024-10-23 22:55:21 -05:00
Kevin Bowling
77b70ad751 e1000: Move I219 LM19/V19 to ADL
This roughly corresponds to Linux 9d9e5347b035412daa844f884b94a05bac94f864

For FreeBSD this is currently not expected to cause any difference in
behavior because we do not have the MTP force smbus changes for modern
standby.

MFC after:	3 days
Sponsored by:	BBOX.io
2024-10-23 20:31:17 -07:00
Kyle Evans
3360a15898 net: route: convert routing statistics to a sysctl
Exporting the relevant pcpustat is trivial, so let's do that.  We will
use it in a near-future change in netstat to avoid having to dig around
in mem(4) for live kernel statistics.

Differential Revision:	https://reviews.freebsd.org/D47231
2024-10-23 22:15:55 -05:00
Konstantin Belousov
9f718b57b8 x86 specialreg: add bit masks definitions for LASS and LAM features
in CPUID Structured Extended Features %eax 0x7 leaf 1 %eax, from
Intel SDM vol. 2 rev. 085.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-10-24 05:41:11 +03:00
Konstantin Belousov
6308db659f x86 specialreg: add bit masks definitions for EFER features
listed in AMD64 APM vol.2 rev. 3.42.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-10-24 05:41:10 +03:00
Konstantin Belousov
5999b74e96 x86 specialreg: add bit masks definitions for LAM in %cr3
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-10-24 05:41:10 +03:00
Konstantin Belousov
cc4b25f102 x86 specialreg: reorder %cr3 bits masks definitions by value
and align them visually.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-10-24 05:41:10 +03:00
Konstantin Belousov
cc11bc1150 x86 specialreg.h: add all defined bits for %cr4
taken from Intel SDM rev. 085

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-10-24 05:41:10 +03:00
Konstantin Belousov
2ac21f2c98 x86 specialreg.h: visually align %cr4 and MSR_EFER bit mask definitions
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-10-24 05:41:10 +03:00
Doug Moore
34951b0b9e swap_pager: move scan_all_shadowed, use iterators
Move vm_object_scan_all_shadowed from vm_object.c to swap_pager.c, and
rename it. In the moved function, use vm_page and swblk iterators to
advance through the objects. Avoid checking a backing page for
busyness or validity more than once, or when it is beyond the upper
bound of the scan.

Reviewed by:	kib, markj
Tested by:	pho
Differential Revision:	https://reviews.freebsd.org/D47150
2024-10-23 21:30:45 -05:00
Mark Johnston
b5149b2653 linker: Handle a truncated hints file properly
If vattr.va_size is 0, we will end up accessing invalid memory.  This is
mostly harmless (because malloc(0) still allocates some memory), but it
triggers a KASAN report.

PR:		282268
Reviewed by:	christos, imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47240
2024-10-23 22:12:45 +00:00
Li-Wen Hsu
dab59af3bc
Canonicalize the name of the FreeBSD Foundation
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
2024-10-24 05:03:07 +08:00
Konstantin Belousov
705090cba4 DMAR: handle affinity for in-memory data structures
Reviewed and tested by:	markj
Sponsored by:	Advanced Micro Devices (AMD)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47254
2024-10-23 23:00:10 +03:00
Andrew Gallatin
49597c3e84 mlx5e: Use M_WAITOK when allocating TLS tags
Now that it is clear we're in a sleepable context, use
M_WAITOK when allocating TLS tags.

Suggested by: kib
Sponsored by: Netflix
2024-10-23 15:56:14 -04:00
Andrew Gallatin
81dbc22ce8 mlx5e: Immediately initialize TLS send tags
Under massive connection thrashing (web server restarting), we see
long periods where the web server blocks when enabling ktls offload
when NIC ktls offload is enabled.

It turns out the driver uses a single-threaded linux work queue to
serialize the commands that must be sent to the nic to allocate and
free tls resources. When freeing sessions, this work is handled
asynchronously. However, when allocating sessions, the work is handled
synchronously and the driver waits for the work to complete before
returning. When under massive connection thrashing, the work queue is
first filled by TLS sessions closing. Then when new sessions arrive,
the web server enables kTLS and blocks while the tens or hundreds of
thousands of sessions closes queued up are processed by the NIC.

Rather than using the work queue to open a TLS session on the NIC,
switch to doing the open directly. This allows use to cut in front of
all those sessions that are waiting to close, and minimize the amount
of time the web server blocks. The risk is that the NIC may be out of
resources because it has not processed all of those session frees. So
if we fail to open a session directly, we fall back to using the work
queue.

Differential Revision: https://reviews.freebsd.org/D47260
Sponsored by: Netflix
Reviewed by: kib
2024-10-23 15:16:19 -04:00
Dimitry Andric
f3dbef1082 Bump __FreeBSD_version for llvm 19.1.2 merge
PR:		280562
MFC after:	1 month
2024-10-23 20:27:43 +02:00
Dimitry Andric
36d486cc2e Fix enum warning in ath_hal's ar9002
This fixes a clang 19 warning:

    sys/dev/ath/ath_hal/ar9002/ar9285_btcoex.c:57:32: error: comparison of different enumeration types ('HAL_BOOL' and 'HAL_ANT_SETTING') [-Werror,-Wenum-compare]
       57 |             (AH5212(ah)->ah_diversity != HAL_ANT_VARIABLE)) {
          |              ~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~

The `ah_diversity` field of `struct ath_hal_5212` is of type `HAL_BOOL`,
not the enum type `HAL_ANT_SETTING`. In other code, `ah_diversity` is
set to `AH_TRUE` whenever the related field `ah_antControl` is set to
`HAL_ANT_VARIABLE`.

It is not entirely clear to me what the intended statement is here: the
test as it is written now compares the enum value 0 to `ah_diversity`,
so in effect it enables the following block whenever `ah_diversity` is
`AH_TRUE`. Write it like that, to avoid the compiler warning.

MFC after:	3 days
2024-10-23 20:26:35 +02:00
Li-Wen Hsu
419249c1ca
Revert "LINT: Add mac_do"
This reverts commit 91b7b225b2.
2024-10-23 15:40:14 +08:00
Li-Wen Hsu
91b7b225b2
LINT: Add mac_do
Sponsored by:	The FreeBSD Foundation
2024-10-23 14:21:55 +08:00