e1000: Separate DH89xxCC memory errors
DH89xxCC shares the 82580 MAC type but reserves several of its memory
error control and status registers. Accessing the full 82580 register
set breaks normal RX/TX operation on affected adapters.
Give DH89xxCC separate configuration, accounting, and recovery paths.
Use its transmit packet-buffer ECC counter and DMA/LAN parity status
with device-specific masks, avoiding the reserved receive-buffer ECC
and PCIe error registers. Retain the port-reset sequence for fatal
memory-error recovery without waiting for the absent STATUS.RST_DONE.
Tested by: chuck2k (https://github.com/opnsense/src/issues/329)
Fixes: 915c628c4f49 ("igb: Report 82580 memory ECC errors")
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D61138
(cherry picked from commit 0857b57787cb2bdd2bb123b12638ea5e4c10eabd)
snd_hdsp: Use saved resource IDs on detach
Release resources with the IDs used to allocate them.
Rename irqid to rid to reflect that it stores a resource ID.
This mirrors the corresponding snd_hdspe change.
Sponsored by: BBOX.io
(cherry picked from commit 96e2a9a40a05716a444dc217629374c387efd159)
snd_hdspe: Use saved resource IDs on detach
Release resources with the IDs used to allocate them.
Rename irqid to rid to reflect that it stores a resource ID.
Reviewed by: br
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D58373
(cherry picked from commit d33ab9dae2f5f5421e4cb5a141751924e35eeb2d)
snd_hdsp: Use busdma for DMA buffers
Program DMA buffer registers with the bus addresses returned by busdma.
Require one full-size contiguous DMA segment per direction and validate
its alignment and 32-bit address range.
Synchronize buffer ownership around playback, capture, clearing, and
teardown. Disable channels before clearing their DMA buffers, and unwind
partially allocated resources on failure.
This mirrors snd_hdspe's DMA handling, adapted to HDSP's single base
address per direction.
Sponsored by: BBOX.io
(cherry picked from commit 5355c97e129a004f013570be0b7a99c8610e1757)
snd_hdsp: Serialize rate and latency updates
Protect running-state checks and register updates with the softc lock.
Keep the pointer reset and the HDSP 9632 frequency rewrite in the same
critical section as the latency update.
Drop the lock around sndbuf_resize(), which may sleep, and recheck the
running state after reacquiring it. Preserve resize error handling so
that a failed resize leaves the hardware unchanged.
This mirrors the locking in snd_hdspe.
Sponsored by: BBOX.io
(cherry picked from commit a25ad366d51d52ef30b8bc4e2a7dd377255a409b)
snd_hdspe: Serialize rate and latency updates
Protect running-state checks and register updates with the softc lock.
Drop the lock around sndbuf_resize(), which may sleep, and recheck the
running state after reacquiring it. Keep the resize ahead of the latency
register update so that a failed resize leaves the hardware unchanged.
Reviewed by: br
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D58371
(cherry picked from commit d1dcb2b117a3c128c8e8eda047f93739f06d6099)
Makefile.inc1: Make sure mandoc bootstrap tool depends on libz
It links against both libopenbsd and libz, so reflect this in the
bootstrap tool's dependencies in case of races from highly-parallel
builds.
Reported by: jkh
MFC after: 1 week
(cherry picked from commit 1dbcc7ee92c427480802cd1a40e1a1e3395d9bac)
Makefile.inc1: Make bootstrap mandoc's bootstrap libz dependency conditional
We bootstrap libz unconditionally on macOS and Linux, and conditionally
on FreeBSD if pre-1600029 or DISK_IMAGE_TOOLS_BOOTSTRAP is enabled, but
if building on new enough -CURRENT without DISK_IMAGE_TOOLS_BOOTSTRAP
then libz is not bootstrapped and so this libz dependency does not
exist. Add the dependency whenever we are bootstrapping libz but not
otherwise, and do so without duplicating the condition.
Fixes: 1dbcc7ee92c4 ("Makefile.inc1: Make sure mandoc bootstrap tool depends on libz")
MFC after: 1 week
(cherry picked from commit 983cb64c05fabe2b83338d4c2087a9114ed27a1c)
Makefile.inc1: Make sure mandoc bootstrap tool depends on libz
It links against both libopenbsd and libz, so reflect this in the
bootstrap tool's dependencies in case of races from highly-parallel
builds.
Reported by: jkh
MFC after: 1 week
(cherry picked from commit 1dbcc7ee92c427480802cd1a40e1a1e3395d9bac)
Makefile.inc1: Make bootstrap mandoc's bootstrap libz dependency conditional
We bootstrap libz unconditionally on macOS and Linux, and conditionally
on FreeBSD if pre-1600029 or DISK_IMAGE_TOOLS_BOOTSTRAP is enabled, but
if building on new enough -CURRENT without DISK_IMAGE_TOOLS_BOOTSTRAP
then libz is not bootstrapped and so this libz dependency does not
exist. Add the dependency whenever we are bootstrapping libz but not
otherwise, and do so without duplicating the condition.
Fixes: 1dbcc7ee92c4 ("Makefile.inc1: Make sure mandoc bootstrap tool depends on libz")
MFC after: 1 week
(cherry picked from commit 983cb64c05fabe2b83338d4c2087a9114ed27a1c)
libthr: Cache recent pshared_key
For a pshare key, we can actually cache the last one as a fast path
instead of trapping into kernel directly. It makes sense as a lock and
unlock should be a pair on the same key and at the same time. For
example, lock(A) -> unlock(A) -> lock(B) -> unlock(B). Each unlock is
a hit and refresh later (50% hit).
For a single pshare lock, it is evne a 100% hit as the key never
changed.
For nested lock lock(A) -> lock(B) -> lock(C) -> unlock(C) ->
unlock(B) -> unlock(A). It only cache the last one. However, we should
really think about rewritting this logic as it is a pshare lock shared
by many processes and nested should be uncommon.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D60957
gve: Page-align DQO descriptor and completion rings
Currently, gve_rx_alloc_ring_dqo() and gve_tx_alloc_ring_dqo() request
CACHE_LINE_SIZE alignment when allocating DMA memory for the DQO TX/RX
descriptor and completion rings. The device requires stronger alignment
than cache line alignment, which was incidentally being met due to how
the kernel allocates memory. Explicitly meet this requirement by
requesting page aligned memory.
Signed-off-by: Tim Hostetler <thostet at google.com>
Reviewed by: markj, Jasper Tran O'Leary <jtranoleary at google.com>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61211
gve: Fix AdminQ buffer DMA sync directions
In gve_verify_driver_compatibility(), the driver populates the
gve_driver_info buffer for the device to read. Sync this buffer with
BUS_DMASYNC_PREWRITE instead of BUS_DMASYNC_PREREAD before issuing
the command.
In gve_adminq_describe_device(), the device populates the
gve_device_descriptor buffer for the driver to read. Sync this buffer
with BUS_DMASYNC_PREREAD instead of BUS_DMASYNC_PREWRITE before
issuing the command.
In gve_adminq_get_ptype_map_dqo(), the device populates the
gve_ptype_map buffer for the driver to read. Add the missing
BUS_DMASYNC_PREREAD and BUS_DMASYNC_POSTREAD syncs around the
command.
In normal GCP environments this did not cause a functional failure
because the underlying platforms are DMA cache-coherent and
[12 lines not shown]
ioctl: Add a macro for extracting the ioctl number from a command
Sprinkle it in various drivers which hard-coded the command layout.
No functional change intended.
Reviewed by: dumbbell, emaste
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61045
libsecureboot: add support for more signatures
For 2027 we need to support new, stronger signatures and hashes.
Re-work Makefile.inc and local.trust.mk to define
VE_SIGN_URL_LIST or VE_SIGNATURE_LIST (can be derrived from
VE_SIGN_URL_LIST) containing tuples of sig/method/hash/flags and
for VE_SIGN_URL_LIST the same plus /url.
From VE_SIGNATURE_LIST we derrive VE_SIGNATURE_EXT_LIST used to populate
signature_ext_list which defines the order in which we look for
signatures for a manifest.
We also populate signature_info_list which maps a signature ext to the
needed hash and flags to indicate whether that hash needs to be repeated.
verify_sig will lookup signature_info_list, no match means not
supported. For asc we just call verify_asc() otherwise we call
verify_ec() or verify_rsa() depending on the key type found in the
[15 lines not shown]
nfs_clrpcops.c: Fix typo in commit db8444c1b7e4
Reported by: markj
MFC after: 1 month
Fixes: 884ee8d6c9b4 ("nfscl: Add some glue for client side NFS over RDMA")
LinuxKPI: set pci_dev msi_cap and msix_cap
Linux drivers find their MSI and MSI-X registers through pdev->msi_cap and
pdev->msix_cap, which hold where those capabilities start in PCI config
space. LinuxKPI never set them, so they stayed 0, and every access meant
for the MSI registers went to the start of config space instead.
Drivers using these fields, e.g. ath11k and amdgpu, are affected.
Fill in both fields from the capability offsets that the native PCI code
already records.
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D61125
Event: NetApp/Vendor Summit Hackathon 202611
mandoc: Drop obsolete files
These were removed by upstream long ago. Nothing in the
tree uses them. Remove them to reduce our diff to upstream.
Reviewed by: carlavilla, wosch
Reported by: Ingo Schwarze <schwarze at openbsd.org>
Differential Revision: https://reviews.freebsd.org/D61198
virtio_pci_modern: enable virtqueues before completing attach
Most of our drivers setup interrupt(s) and virtqueues are enabled at
that time, but nothing will currently enable them for devices that we're
only going to poll. This most notably affects virtio-random, and the
problem can be observed with qemu's q35 emulation and a random device
attached. The q35 implementation ignores the ring unless it's enabled,
so vtrnd_harvest() will consistently EAGAIN rather than contribute
anything of value, but with this patch it becomes functional.
This can be reproduced with a qemu invocation like so:
qemu-system-x86_64 -machine q35,accel=tcg -cpu max -smp 2 -m 2G \
-drive file=FreeBSD-16.0-CURRENT-amd64-ufs.qcow2,if=virtio \
-device pcie-root-port,id=rp1,bus=pcie.0,chassis=1 \
-object rng-random,id=rng0,filename=/dev/urandom \
-device virtio-rng-pci,rng=rng0,bus=rp1 \
-display curses
[4 lines not shown]
virtio_random: stop on detach, don't poll
If the device is hung, then polling will block the detach and hang us.
Stop it and drain the queue instead. This fixes a hang on detach in
some circumstances without the upcoming virtio_pci_modern fix.
Reviewed by: bnovkov, kfv
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D61051
virtio_random: avoid using vtrnd_detach in the failure path
On the off chance that we discover more than one virtio-random device,
the second one will deregister the global instance or trip an invariant
when it fails to attach and calls vtrnd_detach().
We don't have that many resources to free, so just inline those. This
is purely a hygiene thing, we haven't seen an instance of this in the
wild (to my knowledge).
Reviewed by: bnovkov, kfv
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D61050
ena: Reinit RSS components during queue count change flow
The io_queues_nb sysctl is writable while the interface is down, and
setting it destroys the RSS components. When the interface is not UP
nothing reinitialises them, so the indirection table is left referencing
queues that no longer exist until the next ifconfig up.
Call ena_rss_configure() after the queue count changes when the
interface is down. When it is up, this happens through ena_up().
This can configure RSS twice if the interface is brought up afterwards,
costing three redundant admin commands. That is preferred over changing
ena_up(), which the reset path also uses.
Reviewed by: cperciva
Fixes: 56d41ad5fe9c ("Add sysctl node for ENA IO queues number adjustment")
MFC after: 3 days
Sponsored by: Amazon, Inc.
(cherry picked from commit 2a27dd0076c55789a43415559906f795fd10c2da)
ena: Set ENA_FLAG_RSS_ACTIVE only when RSS is really configured
If the device does not report support for the RSS indirection table,
ena_rss_init_default() destroys the RSS state and returns EOPNOTSUPP.
ena_rss_configure() treats EOPNOTSUPP as success and returns 0, and
ena_up_complete() sets ENA_FLAG_RSS_ACTIVE on any 0 return.
Reading dev.ena.N.rss.key at this point causes kernel panic.
Every current device reports the indirection table, so reaching this
needs a device that is broken or misreporting.
The SYSINIT removed by a6205766b300 called ena_rss_init_default()
directly, saw the EOPNOTSUPP and cleared the flag. Routing the decision
through ena_rss_configure(), which hides EOPNOTSUPP, lost that.
Move the flag set into ena_rss_configure(), which can see whether a
table exists, and clear it when tbl_log_size is 0.
Reviewed by: cperciva
[6 lines not shown]
ena: Update driver version to v2.8.5
New Features:
* Retrieve RSS indirection table size from device
Bug Fixes:
* Limit IO IRQ setup loop to active queues only
* Reinit RSS table on device restore when queue count shrinks
* Fix RSS not working after driver reload
* Fix NULL deref before NULL check in RSS sysctl
* Reinit RSS components during queue count change flow
Minor Changes:
* Fix ENA_MEM_FREE_COHERENT with an expression size argument
Reviewed by: cperciva
MFC after: 3 days
Sponsored by: Amazon, Inc.
(cherry picked from commit 5e66bf0df3104e212c1b24ff65284b6d1a694c59)
ena: Update driver version to v2.8.6
Bug Fixes:
* Revert "Reinit RSS components during queue count change flow"
* Fix RSS sysctl panic when the RSS table is destroyed
* Set ENA_FLAG_RSS_ACTIVE only when RSS is really configured
Reviewed by: cperciva
MFC after: 3 days
Sponsored by: Amazon, Inc.
Differential Revision: https://reviews.freebsd.org/D61059
(cherry picked from commit 6c177745c58e526bcf7451ad2765df6c63f35f97)
ena: Fix RSS sysctl panic when the RSS table is destroyed
ena_set_io_queue_count() destroys the ena-com RSS state but left
ENA_FLAG_RSS_ACTIVE set. The RSS sysctl handlers gate on that flag, so
they ran against state that was gone.
This causes 2 types of issues:
1. Kernel panic when reading dev.ena.0.rss.key or writing to
dev.ena.0.rss.indir_table
2. Returning a stale cached RSS table when reading
dev.ena.0.rss.indir_table, or a bogus 1 when reading
dev.ena.0.rss.indir_table_size
ena_set_io_queue_count() is called in 2 cases:
1. The io_queues_nb sysctl.
2. Device restore when the device comes back with fewer MSI-X vectors
than before.
Clear ENA_FLAG_RSS_ACTIVE when the RSS table is destroyed. The handlers
[14 lines not shown]
Revert "ena: Reinit RSS components during queue count change flow"
This reverts commit 2a27dd0076c5.
Changing the IO queue count destroys the RSS table, and if this is done
while the device is down a new table is not rebuilt until the next
ena_up(). That leaves 2 problems in the meantime:
1. A stale copy of the destroyed table is still returned via sysctl.
2. Reading the destroyed key, or writing the table, panics.
That commit addressed 1 by creating a new RSS table, so that sysctl
returns a fresh default table with the new number of queues. It did not
set out to fix 2, but the rebuild hid it by accident.
The rebuilt table is the default round-robin one, wired to no queues and
unusable: a write still fails, because programming the device needs the
IO queues that only exist after ena_up(). ena_up() builds that same
table anyway.
[12 lines not shown]
ena: Fix NULL deref before NULL check in RSS sysctl
In ena_sysctl_rss_indir_table(), the code dereferenced
indir->sysctl_buf before checking whether indir itself is NULL.
Move the NULL check above the dereference so the early-return path
fires before any access through indir.
Reviewed by: cperciva
Fixes: 6d1ef2abd330 ("ena: Implement full RSS reconfiguration")
MFC after: 3 days
Sponsored by: Amazon, Inc.
(cherry picked from commit 462b6c50c7089e96c54cbd34378467f32fc709d4)
ena: Retrieve RSS table size from device
The current driver assumes a default RSS table size of 128 entries,
expecting the device's RSS table size to match this assumption.
This patch allows the driver to create RSS indirection table
with the size advertised by the device.
Reviewed by: cperciva
MFC after: 3 days
Sponsored by: Amazon, Inc.
(cherry picked from commit 3d1e732a43eda16f20dea3fe2671ce6fca8a03a6)