Commit graph

292193 commits

Author SHA1 Message Date
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
Stefan Eßer 17e85f5990 newfs_msdos: align to multiple of cluster size by default
A previous commit aligned the start of the data area to a multiple of
the VM page size, in order to prevent extra buffers to be allocated
(which failed for 64 KB cluster size without this alignment).

Since a dependency on PAGE_SIZE caused compatibility issues, the
alignment was made conditional on this macro being defined, in the
previous commit. This lead to different behavior of this program
when built on FreeBSD vs. Linux (which does not define PAGE_SIZE).

This commit removes any use of PAGE_SIZE and instead always aligns
the start of the data area to a multiple of the cluster size.

The -A option is now implied, unless overridden by a specific number
of reserved sectors with the -r option.

Approved by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45436
2024-06-06 12:28:02 +02: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
Zhenlei Huang 215a18d502 if_enc(4): Prefer the boolean form when calling bpf_peers_present()
No functional change intended.

MFC after:	1 week
2024-06-06 12:20:26 +08:00
Ryan Libby 780666c09b getblk: reduce time under bufobj lock
Use the new pctrie combined insert/lookup facility to reduce work and
time under the bufobj interlock when associating a buf with a vnode.

We now do one lookup in the dirty tree and one combined lookup/insert in
the clean tree instead of one lookup in dirty, two in clean, and then an
insert in clean.  We also avoid touching the possibly unrelated buf at
the tail of the queue.

Also correct an issue where the actual order of the tail queue depended
on the insertion order due to sign issues.

Reviewed by:	kib (previous version), dougm, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45395
2024-06-05 20:21:22 -07:00
Ryan Libby bbf81f4629 pctrie: add combined insert/lookup operations
In several places in code, we do a pctrie lookup followed by a pctrie
insert.  Provide a few flavors of combined lookup/insert.  This may save
a portion of the work from walking a large pctrie twice.

The general idea is that while we walk the trie during insert, we also
do the same kind of tracking work that we do during pctrie_lookup_ge or
pctrie_lookup_le, and we pass out a pctrie node from where such a lookup
may continue.

Reviewed by:	dougm (previous version), kib (previous version), markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45394
2024-06-05 19:17:20 -07:00
Mark Johnston c70c791f06 drm2: Remove one more implementation of ilog2()
Reviewed by:	dougm
Fixes:		b0056b31e9 ("libkern: add ilog2 macro")
Differential Revision:	https://reviews.freebsd.org/D45504
2024-06-05 18:18:19 -04:00
Bjoern A. Zeeb 9e012a9da5 iwn(4): correct debug message: "not" to "no"
Sponosred by:	The FreeBSD Foundation
MFC after:	3 days
2024-06-05 22:05:12 +00:00
John Baldwin f46d4971b5 nvmf: Handle shutdowns more gracefully
If an association is disconnected during a clean shutdown, abort all
pending and future I/O requests with an error to avoid hangs either due
to filesystem unmounts or a stuck GEOM event.

If an association is connected during a clean shutdown, gracefully
disconnect from the remote controller and close the open queues.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45462
2024-06-05 12:59:28 -07:00
John Baldwin aacaeeee8e nvmf: Permit failing I/O requests while disconnected
Add a kern.nvmf.fail_on_disconnection sysctl similar to the
kern.iscsi.fail_on_disconnection sysctl.  This causes pending I/O
requests to fail with an error if an association is disconnected
instead of requeueing to be retried once the association is
reconnected.  As with iSCSI, the default is to queue and retry
operations.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45308
2024-06-05 12:59:07 -07:00
John Baldwin e140f85dc1 nvmf: Rescan namespaces after reconnecting
While a host was disconnected from a remote controller, namespaces
might have been added, removed, or altered properties.  Rescan the
namespaces after reconnecting to detect any such changes.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45461
2024-06-05 12:53:08 -07:00
John Baldwin f6d434f110 nvmf: Rescan all namespaces if the changed NS log page is too large
Previously this just punted with a warning message.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45460
2024-06-05 12:52:43 -07:00
John Baldwin 8a082ca89f nvmf: Factor out most of nvmf_rescan_ns into a helper routine
This function accepts a namespace ID and associated namespace data
from IDENTIFY and takes care of updating nvmeXnY and ndaZ.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45459
2024-06-05 12:52:24 -07:00
John Baldwin 02ddb305cc nvmf: Refactor nvmf_add_namespaces to be more generic
Rename to nvmf_scan_active_namespaces and accept an additional
callback function and callback argument.  The callback is invoked on
each active namespace enumerated by the active namespace list from the
IDENTIFY command.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45458
2024-06-05 12:51:56 -07:00
John Baldwin bed59baba2 nvmf: Pass const pointers to namespace data to nvmf_*_ns
Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45457
2024-06-05 12:51:37 -07:00
Alan Cox 60847070f9 vm: Eliminate a redundant call to vm_reserv_break_all()
When vm_object_collapse() was changed in commit 98087a0 to call
vm_object_terminate(), rather than destroying the object directly, its
call to vm_reserv_break_all() should have been removed, as
vm_object_terminate() calls vm_reserv_break_all().

Reviewed by:	kib, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45495
2024-06-05 12:39:47 -05:00
John Baldwin 56b822a17c pci: Only add special VF handling for direct children in bus methods
For activate/deactivate resource, use a more standard check at the
start of the function since the addition of the PCI_IOV code made this
more complex.  For the three recently added methods, just add the
typical check at the beginning that I missed.

This wasn't always fatal as if your system only had PCI device_t's as
children of PCI bus devices it would happen to work ok, but if you
have a non-PCI child device (e.g. an ATA channel) then dereferencing
ivars for non-direct-children could fault.

Reported by:	Cirrus-CI (via emaste)
Reviewed by:	emaste
Fixes:		871b33ad65 pci: Consistently use pci_vf_* for suballocated VF memory resources
Differential Revision:	https://reviews.freebsd.org/D45499
2024-06-05 09:50:05 -07:00
Jessica Clarke 9820007780 rtld-elf: Use a proper struct type for tlsdesc entries
This clarifies the code and makes it less error-prone. It also makes it
easier to extend downstream in CheriBSD (where pointer and integer
members no longer have the same representation and an additional member
is present).

Reviewed by:	jhb, kib
Differential Revision:	https://reviews.freebsd.org/D45143
2024-06-05 17:41:54 +01:00
Enji Cooper 637ee13919 pci(4): unbreak the build
`argsp` is not defined in `generic_pcie_unmap_resource(..)`. Remove the
parameter passed to `bus_generic_unmap_resource(..)` as this parameter
is never passed to `generic_pcie_unmap_resource(..)`.

Fixes:	98056127dd ("acpi/pci/vmd: Fix a nit with nested resource mapping requests")
Reported by:	Jenkins (aarch64, armv6, armv7, etc)
Differential Revision:	https://reviews.freebsd.org/D45493
2024-06-05 06:55:33 -07:00
Ruslan Bukin 03b330e191 riscv: add stage 2 translation to pmap.
Add basic stage 2 translation support (guest-physical to host-physical).

RISC-V hypervisor spec[1] introduces new translation schemes: Sv32x4,
Sv39x4, Sv48x4 and Sv57x4.
In each case, the size of the incoming address is widened by 2 bits (e.g.
Sv39 becomes 41-bit system).
To accommodate the 2 extra bits, the root page table (only) is expanded
by a factor of four to be 16 KiB instead of the usual 4 KiB. The rest of
page table system (including PTE format) is similar.
This gives us 4x of memory space in each scheme, but it does not make sense
to support all that memory for now.
Allocate required amount of pages for the top directory in case of stage 2,
but leave it unused.

1. https://github.com/riscv/riscv-isa-manual/blob/main/src/hypervisor.adoc

Reviewed by:	mhorne
Sponsored by:	UKRI
Differential Revision:	https://reviews.freebsd.org/D45481
2024-06-05 14:36:57 +01:00
Souradeep Chakrabarti bec000c9c1 amd64: add a func pointer to tlb shootdown function
Make the tlb shootdown function as a pointer. By default, it still
points to the system function smp_targeted_tlb_shootdown(). It allows
other implemenations to overwrite in the future.

Reviewed by:	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/D45174
2024-06-05 12:25:05 +00:00
Zhenlei Huang 4eb82e65a7 hidbus(4): Fix wrong assertion of bus
Reviewed by:	wulf
Fixes:		4151ac9f12 hidbus(4): Use generic hid methods to ...
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D45496
2024-06-05 20:03:27 +08:00
Andrew Turner bed65d85c6 linux64: Fix the build on arm64 with bti checking
When we enable checking for BTI on arm64 we need to include an ELF
note in all object files linked into a module.

As using objcopy from a binary to an ELF object file doesn't add the
note switch to using .incbin from an assembly file. This allows us to
add the needed note without affecting the included object.

Reviewed by:	imp, kib, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45468
2024-06-05 09:23:40 +00:00
Andrew Turner c2e0d56f5e arm64: Support BTI checking in most of the kernel
LLD has the -zbti-report=error argument to check if the BTI note is
present when linking. To allow for this to be used when linking the
kernel and modules:
 - Add the BTI note to the remaining assembly files
 - Mark ptrauth.c as protected by BTI
 - Disable -zbti-report for vmm hypervisor switching code as it's not
   used there.

The linux64 module doesn't build with the flag as it includes vdso code
that doesn't include the note.

Reviewed by:	imp, kib, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45466
2024-06-05 09:23:40 +00:00
Andrew Turner a5affc0c4c stats: Fix the build under gcc
Reviewed by:	brooks, imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45302
2024-06-05 09:23:40 +00:00
Andrew Turner 361da40536 arm64: Disable outling atomics
We don't have the symbols for this. The virtio randon number driver
uses a C11 atomic operation. With inline atomics this is translated to
an Armv8.0 atomic operation, with outling atomics this becomes a
function call to a handler. As we don't have the needed function the
kernel fails to link.

Fix by disabling outline atomics for now.

Reviewed by:	brooks, imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45301
2024-06-05 09:23:40 +00:00
Baptiste Daroussin 8d7331e62a nuageinit: fix authorized_key test
After miss reading the cloudinit spec I ended up writting a wrong
test for basic ssh key setup, nuageinit has been fixed, but not
the test, here is the actual fix.

Reported by:	markj
2024-06-05 11:00:54 +02:00
Baptiste Daroussin fa07b02f6e nuageinit: make addsshkey friendly for testsuite 2024-06-05 11:00:53 +02:00
Baptiste Daroussin 83fcab792c nuageinit: use pw(8) instead of getent(1)
pw(8) allows to seek for users in a custom rootdir, which makes it
easier for a testsuite

MFC After:	3 days
2024-06-05 11:00:53 +02:00
Alan Cox 41dfea24ee arm64 pmap: Enable L3C promotions by pmap_enter_quick()
More precisely, implement L3C (64KB/2MB, depending on base page size)
promotion in pmap_enter_quick()'s helper function,
pmap_enter_quick_locked().  At the same time, use the recently
introduced flag VM_PROT_NO_PROMOTE from pmap_enter_object() to
pmap_enter_quick_locked() to avoid L3C promotion attempts that will
fail.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D45445
2024-06-04 23:25:51 -05:00
Enji Cooper 77c04f3eb1 radlib: fix a memory leak in is_valid_request
Call `HMAC_CTX_free` if returning early from `is_valid_request` when
processing `Message-Authenticator` tags.

Reported by:	Coverity
MFC after:	1 week
Fixes: 8d5c781306 ("libradius: Fix input validation bugs")
Differential Revision:	https://reviews.freebsd.org/D45488
2024-06-04 19:40:55 -07:00
Rick Macklem dbe7ff254e nfsd: Update a file missed by commit e2c9fad2e0
MFC after:	1 month
2024-06-04 18:54:15 -07:00
Rick Macklem e2c9fad2e0 nfsd: Fix delegation handled for atomic upgrade
For NFSv4.1/4.2, an atomic upgrade of a delegation from a
read delegation to a write delegation is allowed and can
result in signoficantly improved performance.

This patch adds support for this atomic upgrade, plus fixes
a couple of other delegation related bugs.  Since there were
three cases where delegations were being issued, the patch
factors this out into a separate function called
nfsrv_issuedelegations().

This patch should only affect the NFSv4.1/4.2 behaviour
when delegations are enabled, which is not the default.

MFC after:	1 month
2024-06-04 18:46:41 -07:00
John Baldwin 871b33ad65 pci: Consistently use pci_vf_* for suballocated VF memory resources
Some of the bus resource methods were passing these up to the parent
which triggered rman mismatch assertions in INVARIANTS kernels.

Reported by:	kp
Reviewed by:	imp
Tested by:	kp (earlier version)
Differential Revision:	https://reviews.freebsd.org/D45406
2024-06-04 16:51:37 -07:00
John Baldwin 98056127dd acpi/pci/vmd: Fix a nit with nested resource mapping requests
Some bus drivers use rmans to suballocate resources to child devices.
When the driver for a child device requests a mapping for a
suballocated resource, the bus driver translates this into a mapping
request for a suitable subrange of the original resource the bus
driver allocated from its parent.  This nested mapping request should
look like any other resource mapping request being made by the bus
device (i.e. as if the bus device had called bus_map_resource() or
bus_alloc_resource() with RF_ACTIVE).

I had slightly flubbed this last bit though since the direct use of
bus_generic_map/unmap_resource passed up the original child device
(second argument to the underlying kobj interface).  While this is
currently harmless, it is not strictly correct as the resource being
mapped is owned by the bus device, not the child and can break for
other bus drivers in the future.

Instead, use bus_map/unmap_resource for the nested request where the
requesting device is now the bus device that owns the parent resource.

Reviewed by:	imp
Fixes:		0e1246e334 acpi: Cleanup handling of suballocated resources
Fixes:		b377ff8110 pcib: Refine handling of resources allocated from bridge windows
Fixes:		d79b6b8ec2 pci_host_generic: Don't rewrite resource start address for translation
Fixes:		d714e73f78 vmd: Use bus_generic_rman_* for PCI bus and memory resources
Differential Revision:	https://reviews.freebsd.org/D45433
2024-06-04 16:51:14 -07:00
Mitchell Horne 65a33120c3 riscv: fix vm.pmap.kernel_maps with Sv48
With 4-level paging enabled, the layout of KVA is identical, but we need
to step through an extra level to find the L1 table.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45473
2024-06-04 20:18:54 -03:00
Mitchell Horne 191bf63da2 riscv: Move sigcode out of locore.S
It really doesn't fit here anymore as locore is all about early startup
code. Thus, move it to its own file.

Reviewed by:	br
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45320
2024-06-04 20:18:05 -03:00