Commit graph

151331 commits

Author SHA1 Message Date
Rick Macklem 13a51233e4 nfsd: Delete an unused VNET global variable
During code inspection, I noticed that
NFSD_VNET_DEFINE(nfsrv_dontlisthead)
is unused, so delete it.

MFC after:	2 weeks
2024-06-08 16:40:52 -07:00
Alan Cox 5ee5c40402 arm64 pmap: Defer bti lookup
Defer the bti lookup until after page table page allocation is complete.
We sometimes release the pmap lock and sleep during page table page
allocation.  Consequently, the result of a bti lookup from before
page table page allocation could be stale when we finally create the
mapping based on it.

Modify pmap_bti_same() to update the prototype PTE at the same time as
checking the address range.  This eliminates the need for calling
pmap_pte_bti() in addition to pmap_bti_same().  pmap_bti_same() was
already doing most of the work of pmap_pte_bti().

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45502
2024-06-08 02:26:55 -05:00
Zhenlei Huang 23f4131ad6 sys/sysctl.h: Fix wrong assertion with multiple access flags
With multiple flags passed in, e.g., CTLFLAG_RD | CTLFLAG_CAPRD, due to
the precedence rules, this will result in false positive assertion. Fix
that by surrounding the replacement lists with parentheses.

Reviewed by:	imp, erj
Fixes:		10a1e981d4 iflib: mark isc_driver_version as constant
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D45531
2024-06-08 11:21:11 +08:00
Kristof Provost ba2a920786 pf: convert DIOCBEGINADDRS to netlink 2024-06-08 04:46:43 +02:00
Bjoern A. Zeeb 63a327b954 LinuxKPI: 802.11: use net80211 IEEE80211_HTCAP_* definitions
Rather than using the values and leaving net80211 names in a comment
define the LinuxKPI IEEE80211_HT_CAP_* to the net80211 IEEE80211_HTCAP_*
names.  That way errors like the one fixed in 3e0915b7b6 are less
likely to happen.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-06-07 23:57:04 +00:00
Bjoern A. Zeeb 3753988c5d LinuxKPI: pm: add SET_SYSTEM_SLEEP_PM_OPS() and device_can_wakeup()
Add the SET_SYSTEM_SLEEP_PM_OPS() by factoring some other macro code
out in order to set the suspend/resume functions when the struct is
already given.  Such is the case in iwlwifi d3.

Also add an initial implementation of device_can_wakeup().  Though
this is likely all we need we have no way of setting the flag for it
yet so leave a pr_debug() and a comment there as well.  Until we want
to support WoWLAN this is likely not needed for wireless.
Doing it the proper way checking a bool in 'struct dev_pm_info' would
change 'struct device' and with that 'struct pci_dev' and break the
KBI.  In favour of mergeability this version does not implement the
full functionality yet.

Both help to make an updated iwlwifi d3 compile.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D45358
2024-06-07 22:57:04 +00:00
Bjoern A. Zeeb 8866534929 LinuxKPI: 802.11: make sure we can send DISASSOC or DEAUTH frames
The "Invalid TXQ" error from iwlwifi seems to be triggered by a
frame being sent for a sta which is no longer known to the driver/fw.

While we make sure to trigger the sending of the frame in net80211
early enough (by calling (*iv_newstate)() early on rather than at
the end), TX in LinuxKPI is run in a deferred task.  When we drop the
net80211 ic lock again and re-acquire the LHW lock the packet may not
yet have made it to the driver.
Work around this between the (ic and lhw) locks by making sure
(a) no new packets get queued after we return from (*iv_newstate)(),
and (b) the TX task has run or gets cancelled and we manually push
any remaining packets out (or let lsta_free() clean them up).
The disabled packet queuing now also needs to be re-enabled in
scan_to_auth() in case an lsta is staying in service or gets re-used.

Also make sure that any following lkpi_wake_tx_queues() calls no
longer ignore queues which have not seen a prior dequeue.
This former workaround "feature" (ltxq->seen_dequeue) should be
fully garbage collected in a later change on its own.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
PR:		274382
Tested by:	emaste, lwhsu, thj, rkoberman at gmail.com
Accepted by:	adrian
Differential Revision: https://reviews.freebsd.org/D45508
2024-06-07 21:47:42 +00:00
Bjoern A. Zeeb 105b9df26e LinuxKPI: 802.11: close race lkpi_sta_scan_to_auth()/(*iv_update_bss)()
We have to unlock the net80211 ic lock in order to be able to call
sleepable downcalls to the driver/firmware; a 2nd thread may go through
net80211::join1() and (*iv_update_bss)() after we checked and unlocked.
Re-check status at the end of the function under the ic lock so that we
do not accidentally set lvif_bss_synched to true again despite it no
longer being true.

This should fix a race where we lost the (*iv_update_bss)() state
during startup where one SCAN->AUTH is followed by a (then) AUTH->AUTH
and lkpi_sta_a_to_a() did the wrong thing.

Once we re-consider net80211 state and allowing a second join
on a different node or iv_bss update without previously tearing down
the older node we can likely undo a lot of these extra checks and
workarounds.

Sponsored by:	The FreeBSD Foundation (updated version)
Tested by:	emaste (on and off)
MFC after:	3 days
Reviewd by:	cc
Differential Revision: https://reviews.freebsd.org/D43967
2024-06-07 21:40:32 +00:00
Bjoern A. Zeeb 3e0915b7b6 LinuxKPI: 802.11: Fix definition of IEEE80211_HT_CAP_RX_STBC
IEEE80211_HT_CAP_RX_STBC was set to 0x100 instead of 0x300.
Correct to get the expected behavior.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Fixes:		b0f7376822 LinuxKPI: 802.11 header updates
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D45506
2024-06-07 21:16:49 +00:00
Bjoern A. Zeeb 5bbf4b6291 net80211: fix IEEE80211_FHT_BITS
AMPDU_RX was added as a second AMPDU_TX, LDPC_TX and LDPC_RX missing;
correct and add missing.
Makes ddb output (and other debugging) look more correct.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D45505
2024-06-07 21:15:04 +00:00
Bjoern A. Zeeb 582469016a LinuxKPI: 802.11: initalize lsta to NULL in linuxkpi_ieee80211_rx()
The logic following this new assignment in some cases may not set lsta
but the later tracing is checking for it to be != NULL.
With lsta not initialized that check may not hold up and later we would
dereference lsta->state and possibly panic.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D45507
2024-06-07 21:06:31 +00:00
Kristof Provost d9ab899931 pf: migrate DIOCGETLIMIT/DIOCSETLIMIT to netlink
Event:		Kitchener-Waterloo Hackathon 202406
2024-06-07 20:59:02 +02:00
Dmitry Luhtionov 4cc4b5e2b5 Add some AMD device IDs. 2024-06-07 13:02:03 -04:00
Zhenlei Huang 0dfd11abc4 bpf: Make bpf_peers_present a boolean inline function
This function was introduced in commit [1] and is actually used as a
boolean function although it was not defined as so.

No functional change intended.

1. 16d878cc99 Fix the following bpf(4) race condition which can result in a panic

Reviewed by:	markj, kp, #network
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45509
2024-06-07 23:06:08 +08:00
Zhenlei Huang 89204d9dcb bpf: Prefer the boolean form when calling bpf_peers_present()
No functional change intended.

Reviewed by:	markj, kp, #network
MFC with:	8f31b879ec
Differential Revision:	https://reviews.freebsd.org/D45509
2024-06-07 23:06:07 +08:00
Souradeep Chakrabarti 2b887687ed Hyper-V: TLB flush enlightment using hypercall
Currently FreeBSD uses IPI based TLB flushing for remote
TLB flushing. Hyper-V allows hypercalls to flush local and
remote TLB. The use of Hyper-V hypercalls gives significant
performance improvement in TLB operations.

This patch set during test has shown near to 40 percent
TLB performance improvement.

Also this patch adds rep hypercall implementation as well.

Reviewed by:	whu, kib
Tested by:	whu
Authored-by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Co-Authored-by:	Erni Sri Satya Vennela <ernis@microsoft.com>
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D45521
2024-06-07 07:56:07 +00:00
Vladimir Kondratyev db42bd1f71 LinuxKPI: Convert Linux integer types to ISO C99 in linux/kstrtox.h
Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45465
2024-06-06 23:42:07 +03:00
Vladimir Kondratyev d207a2dee3 LinuxKPI: Add kstrtoll to linux/kstrtox.h
kstrtoll converts a string to a long long.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45455
2024-06-06 23:42:07 +03:00
Vladimir Kondratyev a97f3a9ec9 LinuxKPI: Move kstrto* functions to linux/kstrtox.h
from linux/kernel.h to match Linux and
allow direct linux/kstrtox.h inclusion.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D45454
2024-06-06 23:42:07 +03:00
Vladimir Kondratyev afc450fac9 LinuxKPI: Add abs_diff to linux/math.h
It returns absolute value of the difference between the arguments.

Add LinuxKPI version check as the macro was moved from drm-kmod to
linux/math.h in Linux kernel commit 46f12960aad (6.6 timeframe).

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45453
2024-06-06 23:42:07 +03:00
Vladimir Kondratyev 588064e658 LinuxKPI: Move linux/math.h content out of linux/kernel.h
To match Linux and allow direct linux/math.h inclusion.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D45452
2024-06-06 23:42:07 +03:00
Vladimir Kondratyev 07c7c41ca1 LinuxKPI: Add min_not_zero() to linux/minmax.h
It returns the minimum that is not zero, except both equals to zero.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste, ssaxena
Differential Revision:	https://reviews.freebsd.org/D45450
Differential Revision:	https://reviews.freebsd.org/D45451
2024-06-06 23:42:06 +03:00
Vladimir Kondratyev f79474c4e3 LinuxKPI: Move linux/minmax.h content out of linux/kernel.h
To match Linux and allow direct linux/minmax.h inclusion.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D45449
2024-06-06 23:42:06 +03:00
Vladimir Kondratyev cb8bfc4db8 LinuxKPI: Move page_address definition from linux/gfp.h to linux/mm.h
To match Linux. Some future changes may depend on proper location.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45448
2024-06-06 23:42:06 +03:00
Austin Shafer 613723bac2 linuxkpi: Allow ida_destroy and idr_destroy to be called multiple times
This fixes some weird behavior triggered by nvidia-drm.ko: some DRM
cleanup functions will be called multiple times, leading to a double
free. drm_mode_config_cleanup will be called twice, causing ida_destroy
to be called twice. Although calling the cleanup twice doesn't seem
very clean, on Linux this seems to be permissable as it handles it
just fine. Not doing these checks causes mutex panics and double frees.

In order to preserve this behavior this change checks if the objects
have already been destroyed and bails if so. This fixes the panic seen
when unloading the nvidia-drm driver.

MFC after:	1 week
Reviewed by:	bz, manu
Differential revision:	https://reviews.freebsd.org/D44865
2024-06-06 23:42:06 +03:00
Alvin Chen 21f4cf5ccf LinuxKPI: lockdep_assert: wrong 'cond' used in WARN_ON MACRO
'cond' in WARN_ON need be bracketed,
otherwise it is wrong for multiple conditions.

Reviewed by:	wulf
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44604
2024-06-06 23:42:06 +03:00
Kristof Provost f042e15154 pf: add sctp multihome probe points
Add probe points to allow us to probe when we add or remove multihome addresses.

Example use:
	pf:sctp:multihome:add
	{
		printf("Add tag %x address %x", arg0,
		    ((struct pf_sctp_source *)arg1)->addr.v4.s_addr);
	}

	pf:sctp:multihome:remove
	{
		printf("Remove tag %x address %x", arg0,
		    ((struct pf_sctp_source *)arg2)->addr.v4.s_addr);
	}

MFC after:	1 week
Sponsored by:	Orange Business Services
2024-06-06 20:46:19 +02:00
Kristof Provost 30bad751e8 pf: convert DIOCGETTIMEOUT/DIOCSETTIMEOUT to netlink 2024-06-06 20:46:18 +02:00
Doug Moore 2c10bacdf4 rangeset: add next() iteration
Add a method rangeset_next to find the first range that starts at or
after a given value. Use it to rewrite pmap_pkru_same and
pmap_bti_same to avoid walking a page at a time over pages in no
range.

Reviewed by:	andrew, kib
Differential Revision:	https://reviews.freebsd.org/D45511
2024-06-06 13:42:31 -05:00
Ryan Libby 1b13e36fcc vm_page_insert: use pctrie combined insert/lookup
This reduces work done under vm_page_insert for large objects.

Reviewed by:	alc, dougm, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45486
2024-06-06 10:26:50 -07:00
Ryan Libby 7658d1532c vm_radix: define vm_radix_insert_lookup_lt and use in vm_page_rename
Use the new pctrie combined lookup/insert.  This is an easy application
of the new facility.  There are other places where we do this for pages
that may need more plumbing to use combined lookup/insert.

Reviewed by:	kib (previous version), dougm, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45396
2024-06-06 10:26:50 -07:00
Maxime Thiebaut b5b90ff984 u3g: Add support for SIM7600G
Signed-off-by:	Maxime Thiebaut <maxime+freebsd@thiebaut.dev>
Reviewed by:	kp
2024-06-06 17:02:15 +02:00
Kristof Provost 8f04209d37 pf: simplify pf_addrcpy() and pf_match_addr()
Use the v4/v6 union members rather than the uint32_t ones.
Export IN_ARE_MASKED_ADDR_EQUAL() in in_var.h and use it (and its IPv6
equivalent) for masked comparisons rather than hand-rolled code.

Event:		Kitchener-Waterloo Hackathon 202406
2024-06-06 15:45:31 +02:00
Kristof Provost f0829825fb netlink: pass the correct arguments for SIOCDIFADDR and SIOCDIFADDR_IN6
These take struct ifreq and struct in6_ifreq respectively. Passing struct
in_aliasreq or struct in6_aliasreq means we're supplying a shorter object than
expected. While this doesn't actively break things on most architectures other
than CHERI it is still wrong.

Reported by:	CheriBSD
Event:		Kitchener-Waterloo Hackathon 202406
2024-06-06 15:45:30 +02:00
Kristof Provost 8ca12190bf pf: remove incorrect SUNION2PF() macro
It casts in_addr to pf_addr, which is smaller, so this isn't quite right.
Replace it with a function that will only read the actual address.

Reported by:	CheriBSD
Event:		Kitchener-Waterloo Hackathon 202406
2024-06-06 15:45:30 +02:00
Chandrakanth patil 8d3c3b5242 mpi3mr: Track IO per target counter during queue poll with local variable
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44494
2024-06-06 10:39:16 +00:00
Chandrakanth patil 3f3a15543a mpi3mr: Divert large WriteSame IOs to firmware if unmap and ndob bits are set
Firmware advertises the transfer lenght for writesame commands to driver during init.
So for any writesame IOs with ndob and unmap bit set and transfer lengh is greater
than the max write same length specified by the firmware, then direct those commands
to firmware instead of hardware otherwise hardware will break.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44452
2024-06-06 10:39:15 +00:00
Chandrakanth patil df595fc43e mpi3mr: driver version update to 8.10.0.1.0
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44430
2024-06-06 10:39:15 +00:00
Chandrakanth patil 945c3ce49e mpi3mr: copyright year update to 2024
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44429
2024-06-06 10:39:15 +00:00
Chandrakanth patil baabb91934 mpi3mr: mpi headers update to latest
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44428
2024-06-06 10:39:15 +00:00
Chandrakanth patil 3012fa8fae mpi3mr: Adding FreeBSD OS Type to Fault/Reset Reason Code
The driver is modified to add FreeBSD OS type in the upper nibble of the
fault/reset reason code for appropriate qualification of the reason code.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44427
2024-06-06 10:39:15 +00:00
Chandrakanth patil 4034d7061a mpi3mr: diag fault success beyond F000 fault code
Accept any fault as successful for diagnostic fault reset, not just the 0xF000
code. print fault information and return.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44426
2024-06-06 10:39:15 +00:00
Chandrakanth patil eb7a4b35de mpi3mr: Update consumer index of admin and operational reply queues after every 100 replies
Instead of updating the ConsumerIndex of the Admin and Operational ReplyQueues
after processing all replies in the queue, it will now be periodically updated
after processing every 100 replies.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44425
2024-06-06 10:39:15 +00:00
Chandrakanth patil 571f1d0638 mpi3mr: Decrement per controller and per target counter post reset
Post controller reset, If any device removal events arrive, and if
there are any outstanding IOs then the driver will unnecessarily wait
in the loop for 30 seconds before removing the device from the OS.

reset target outstanding IO counter and controller outstanding IO counter
and remove the redundant wait loop.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44424
2024-06-06 10:39:15 +00:00
Chandrakanth patil 701d776c98 mpi3mr: poll reply queue and add MPI3MR_DEV_REMOVE_HS_COMPLETED flag
An outstanding IO counter per target check has been added before deleting
the target from the OS which will poll the reply queue if there are any
outstanding IOs are found.

A new flag, named "MPI3MR_DEV_REMOVE_HS_COMPLETED," is added. If a remove event
for a target occurs and before the deletion of the target resource if the add event
for another target arrives reusing the same target ID then this flag will prevent
the removal of the target reference. This flag ensures synchronization between the interrupt
top and bottom half during target removal and addition events.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44423
2024-06-06 10:39:14 +00:00
Chandrakanth patil 042808f747 mpi3mr: Controller state check before enabling PEL
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44422
2024-06-06 10:39:14 +00:00
Chandrakanth patil 0d7056458d mpi3mr: Block devices persist despite being offlined during reset
The driver removes the drive from the OS if firmware sends 'device added'
event with hidden bit or inaccessible status.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44421
2024-06-06 10:39:14 +00:00
Andrew Turner ec69d23093 linux: Allows writing to the vdso from the kernel
We need to write to the vdso in the kernel to perform fixups. Move it
from .rodata to .data so these can be run.

Reported by:	cy
Sponsored by:	Arm Ltd
2024-06-06 09:07:49 +00:00
Michael Tuexen 86c9325d34 tcp: simplify stack switching protocol
Before this patch, a stack (tfb) accepts a tcpcb (tp), if the
tp->t_state is TCPS_CLOSED or tfb->tfb_tcp_handoff_ok is not NULL
and tfb->tfb_tcp_handoff_ok(tp) returns 0.
After this patch, the only check is tfb->tfb_tcp_handoff_ok(tp)
returns 0. tfb->tfb_tcp_handoff_ok must always be provided.
For existing TCP stacks (FreeBSD, RACK and BBR) there is no
functional change. However, the logic is simpler.

Reviewed by:		lstewart, peter_lei_ieee_.org, rrs
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D45253
2024-06-06 08:29:05 +02:00
Konstantin Belousov 9c5d7e4a0c pmap: move the smp_targeted_tlb_shutdown pointer stuff to amd64 pmap.h
Fixes:	bec000c9c1ef409989685bb03ff0532907befb4aESC
Sponsored by:	The FreeBSD Foundation
2024-06-06 08:15:08 +03:00