Commit graph

307088 commits

Author SHA1 Message Date
Franco Fichtner
da052d1dd3 netinet6: allocate correct size for ip6_fwdtag struct; closes #342
Looks like this has been the case ever since if_index was introduced.
While IPv4 was updated correctly it was forgotten for IPv6.

Submitted by: @pletch
2026-10-29 08:25:07 +01:00
Kyle Evans
c962f76493 wg: fix the LINT-NOIP build
We don't have anything to tunnel without INET or INET6, so just smack
it with the same config(5) hammer that ovpn uses and exclude it from
such builds.

Reported by:	mjg
Reviewed by:	emaste, markj

(cherry picked from commit 8430de47aa7c004e1330b8f6a3018c360425606e)
2026-10-26 06:59:28 +01:00
Mark Johnston
22a19c9f74 Add UPDATING entries and bump version
Approved by:	so
2026-10-26 06:55:52 +01:00
Dag-Erling Smørgrav
896161b110 ObsoleteFiles.inc: Add moved certificates
These two moved from trusted to untrusted.

Approved by:	so
Security:	FreeBSD-SA-26:73.caroot
Fixes:		21ac4761428c ("ObsoleteFiles.inc: Add dropped certificates")
(cherry picked from commit dd6a1fef0ed2bf760a294106ab93fbcdcfdcae3d)
2026-10-26 06:55:50 +01:00
Dag-Erling Smørgrav
c4ecddcbdc ObsoleteFiles.inc: Add dropped certificates
Approved by:	so
Security:	FreeBSD-SA-26:73.caroot
Reported by:	michaelo@
Fixes:		82af7f44ebef ("caroot: Regenerate")

(cherry picked from commit 21ac4761428c60c48bb5c3a0367a04dae164c414)
2026-10-26 06:55:49 +01:00
Dag-Erling Smørgrav
a85a932707 caroot: Regenerate
Regenerate using certificate data from NSS 3.131.1.

Upstream dropped emSign_ECC_Root_CA_-_G3.pem entirely; we deliberately
move it to untrusted instead to block its reintroduction through e.g.
an outdated copy of security/ca_root_nss.

Approved by:	so
Security:	FreeBSD-SA-26:73.caroot
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D60906

(cherry picked from commit 82af7f44ebefbe46cd635f63db300a066de48ee1)
2026-10-26 06:55:48 +01:00
Mark Johnston
01510f095c Add UPDATING entries and bump version
Approved by:	so
2026-10-15 11:29:01 +02:00
Mark Johnston
b38c50da10 bhyve: Fix handling of framebuffer resizing
The rfb code maintains an array of CRCs for 32x32 tiles in the
framebuffer.  This array is sized statically based on the rfb code's
notion of the maximum framebuffer size, which changed in commit
fb51ddb20d without updating the rfb code.

Morever, writes to the framebuffer BAR can modify the recorded height
and width of the framebuffer.  These values were not validated against
the maximum at all, unlike the parameters set via bhyve config.

Fix these problems:
- Define the maximum width and height in a shared header file so that
  they do not get out of sync again.
- In pci_fbuf_render(), don't resize the console if the new dimensions
  are too large.
- Add a mutex to synchronize framebuffer BAR I/O with the rfb thread.

Approved by:	so
Security:	FreeBSD-SA-26:72.bhyve
Security:	CVE-2026-101311
Fixes:		fb51ddb20d ("bhyve: increase fbuf display resolution limit")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D60680
2026-10-15 11:29:00 +02:00
Mark Johnston
a01b404b26 bhyve: Improve HDA stream descriptor validation
The length of each block in the stream must be non-zero.  This is
assumed in hda_transfer(), otherwise an out-of-bounds read or write is
possible.

Use atomic loads to access stream descriptor fields, since they are
guest-controlled.  Make sure that the descriptor array is suitably
aligned so that we can drop the __packed annotation from the structure
definition; per section 3.3.42 of the HDA spec the BDL pointer is
supposed to be 128-byte aligned, in fact.

Approved by:	so
Security:	FreeBSD-SA-26:72.bhyve
Security:	CVE-2026-101310
Reported by:	Brian Delgado from Intel using Anthropic Opus 4.8
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D60678
2026-10-15 11:28:59 +02:00
Mark Johnston
cd14da3bd4 bhyve: Fix handling of the xhci event ring
rts->erst_p and rts->erstba_p are pointers to guest-controlled memory
which describe the event rings and pending event array, respectively.
The device model was not validating the size nor saving the value.
As a result, the bounds checks in pci_xhci_insert_event() were
susceptible to TOCTOU races.

Fix pci_xhci_rtsregs_write() to save the ring size in a softc field.
Validate that the size isn't larger than the maximum allowed by the XHCI
specification (64KB, or 4096 TRBs).

When processing TRBs, make sure we don't load fields more than once.
Make sure that pci_xhci_trb_next() doesn't return a pointer to host
memory.  When handling ERDP writes, make sure that the guest-supplied
address is actually a pointer into the TRB array, and ignore the write
if not.

Approved by:	so
Security:	FreeBSD-SA-26:72.bhyve
Security:	CVE-2026-101309
Reported by:	Brian Delgado from Intel using Anthropic Opus 4.8
Differential Revision:	https://reviews.freebsd.org/D60677
2026-10-15 11:28:57 +02:00
Mark Johnston
cf42166fdd sound: Revalidate after reacquiring locks when resizing buffers
sndbuf_resize() and sndbuf_remalloc() drop the channel lock in order to
allocate the new buffer(s) with M_WAITOK.  Before doing that they verify
that the buffer is not mapped, but this could change while the lock is
dropped, as there is no higher-level synchronization which prevents
buffer resize (e.g., via the SNDCTL_DSP_SETBLKSIZE ioctl) from happening
concurrently with mmap.  Thus, these checks are insufficient.

Modify sndbuf_resize() and sndbuf_remalloc() to revalidate after
reacquiring the lock.  Extend them to check for a couple of channel
flags, mirroring the check in chn_resizebuf().  Modify chn_resizebuf()
to revalidate state after reacquiring the channel lock.

We could also allocate new buffers with M_NOWAIT and so avoid dropping
the lock.  Then, I think we could go even further and invoke
CHANNEL_SETBLOCKSIZE and CHANNEL_SETFRAGMENTS with the channel lock
held.  But really it would be better to ensure that dsp operations are
serialized; there is no reason for mmap and chn_resizebuf() to be able
to run in parallel, we should not be relying on the channel lock for
this.  So, let's keep a more minimal approach here.

Add a simple regression test.

Approved by:	so
Security:	FreeBSD-SA-26:71.sound
Security:	CVE-2026-101308
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D60554
2026-10-15 11:28:55 +02:00
Mark Johnston
cec5431f2c sound: Check for errors from sndbuf_resize()
Most implementations of CHANNEL_SETBLOCKSIZE and CHANNEL_SETFRAGMENTS
were not checking this.  This is probably not a big problem: it's
unlikely for sndbuf_resize() to fail due to the refcount check in this
case since it's operating on the hardware buffer, which doesn't get
mmaped.  But, I will add more reasons for it to fail in the next patch,
so let's be more careful.

This change modifies various CHANNEL_SETBLOCKSIZE implementations to
check for errors.  In some cases I reordered things to avoid updating
driver state until after sndbuf_resize() succeeds.

Return 0 from CHANNEL_SETBLOCKSIZE to indicate an error, as it otherwise
returns the new block size.  We could change the interface to return
both an error number and a block size, but that would break at least one
out-of-tree driver and I wish to avoid that here.  Make sure that errors
from CHANNEL_SETFRAGMENTS are returned to userspace.

Approved by:	so
Security:	FreeBSD-SA-26:71.sound
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D60553
2026-10-15 11:28:53 +02:00
Michael Tuexen
2eb84a2d6c tcp/rack: Fix a potential overflow in rack_update_pcm_ack()
The RACK stack's path capacity measurement module maintains an array of
samples, updated when the stack receives an ACK.  The array grows as
needed, but code which handles the expansion is susceptible to remotely
triggerable overflow.  This could lead to underallocation and a ~512KB
out-of-bounds write.

Fix this by bounding the sample array size.

Approved by:	so
Security:	FreeBSD-SA-26:70.tcp
Security:	CVE-2026-101307
Reviewed by:	glebius, markj
Reported by:	Nozomi Networks Security Research
2026-10-15 11:28:52 +02:00
Michael Tuexen
511326f4b2 tcp: improve handling of stopped timers
When a TCP timer is stopped, t_timers[] is set to SBT_MAX. Adding the
corresponding t_precisions[], if it is not zero, would result in
overflows in tcp_timer_next(). To avoid this, skip stopped timers.

The problem was identified while debugging uperf by Lukas Book and
an initial patch was provided by him. The committed patch was
suggested by glebius.

The problem can be observed by running netstat -nxptcp and looking for
negative timer values and by observing very long running timers in
some cases.

Approved by:		so
Security:		FreeBSD-EN-26:27.tcp
Reported by:		Lukas Book <lkbook@outlook.de>
Reviewed by:		glebius
Differential Revision:	https://reviews.freebsd.org/D58484

(cherry picked from commit 52b7cbcb78c14e89f6faec8da5acc2caa3d37208)
(cherry picked from commit e8d1cee437414dd9bb3c779ff0a0c234fb7d411e)
2026-10-15 11:28:51 +02:00
Dag-Erling Smørgrav
cf81be35c3 hastd: Use fixed-length protocol names
All communication between hastd nodes and internally between hastd and
its worker children passes through the same pair of send / receive
functions.  The receive function uses recv(2) with the MSG_WAITALL flag,
which in theory means we should never get a short read.  However, when
handing off a socket to a worker child, we also pass a variable-length
string identifying the type of socket we're passing, and reading this
string relies on a short read.  This used to work because the arrival of
the descriptor would interrupt the recv(2) call, but this bug was fixed
when the AF_UNIX code was rewritten a while ago and hastd has been
broken ever since.

Fixing the length of the protocol name to four characters including the
terminating null solves the short-read bug by never requiring a short
read (nothing else in hastd requires one).

Note that this issue appears to have been reported independently first
by Alessandro Sagratini in PR 292322 and then by Martin Vidovic in
D57511.  I ended up going in a different direction than Martin's patch,
but his analysis was invaluable, hence the double credit below.

Approved by:	so
Security:	FreeBSD-EN-26:26.hastd
PR:		292322
Reported by:	Martin Vidovic <xtronom@gmail.com>
MFC after:	1 week
Event:		EuroBSDcon DevSummit 2026
Reviewed by:	xtronom_gmail.com, kevans, glebius, gjb
Differential Revision:	https://reviews.freebsd.org/D59521

(cherry picked from commit b7e5c2e008f5b441611830ad3a0329de0882419e)
(cherry picked from commit cd8eef45d2d0296afe0226bde587f52eb0404516)
2026-10-15 11:28:50 +02:00
Dag-Erling Smørgrav
cbee6453d0 hastd: Ensure nvpair padding is initialized
The proto-libnv implementation embedded in hastd pads names and values
out to the nearest multiple of eight bytes, but leaves the padding
uninitialized, leaking up to 14 bytes of recycled heap per pair in a
message.

While here, switch from bcopy() to memcpy().

Approved by:	so
Security:	FreeBSD-EN-26:26.hastd
MFC after:	3 days
Reviewed by:	kevans, emaste
Differential Revision:	https://reviews.freebsd.org/D59343

(cherry picked from commit 911bda7cffbf358c4e83ea05cfe980d429aff61c)
(cherry picked from commit 0d0f40cd29d2aba7bfeef8861b73930bbb84308e)
2026-10-15 11:28:49 +02:00
Glen Barber
fa77e56a6a hastd: Fix crash on empty message
A HAST message can be empty, in which case ebuf_add_tail() does nothing
and ebuf_data() returns NULL because the size of the ebuf is zero, but
hast_proto_recv_hdr() asserts that the return value is not NULL,
resulting in an immediate crash if hastctl or hastd receive an empty
message.  This is trivially reproducable by running `hastctl status` or
`hastctl role init` (as the rc script does prior to stopping hastd).

To avoid this, don't try to grow the ebuf or receive additional data
if the header size is zero.

Approved by:	so
Security:	FreeBSD-EN-26:26.hastd
PR:		298085
MFC after:	3 days
Reviewed by:	kevans, gjb
Differential Revision:	https://reviews.freebsd.org/D59306

(cherry picked from commit 8646d65b45339642d4aab1de35a2bc79fc45f09e)
(cherry picked from commit 2581bc3af3815e92b0eef44bee224fff92931de8)
2026-10-15 11:28:47 +02:00
Philip Paeps
bcb8f053c9 contrib/tzdata: import tzdata 2026e
Changes: https://github.com/eggert/tz/blob/2026e/NEWS

Briefly:
    Manitoba moves to permanent -05 on 2026-10-31.

Approved by:	so
Security:	FreeBSD-EN-26:25.tzdata

(cherry picked from commit f11af6535044c8266d52806d72b07e939f94049c)
(cherry picked from commit 961a842fdd3a2e0868444d689acbe7349a55ebfa)
2026-10-15 11:28:44 +02:00
Bojan Novković
abbbe67a45 pf: Send syncookies from the receiving thread
pf sends outbound packets by offloading them to a single per-vnet SWI handler
through the `V_pf_sendqueue` mbuf queue. A large DDoS attack may overwhelm
that per-vnet queue with syncookie packets and cause contention in the SWI
handler that negatively affects other pf operations.

Fix this by sending the initial syncookie challenge from the context
of the receiving thread. This avoids the syncookie-induced contention on
the `pf_intr` mbuf queue.

Sponsored by:	Klara, Inc.
Sponsored by:	Entersekt
MFC after:	3 weeks
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D59068

(cherry picked from commit bf05236727cf367ee8e22ef47febebb319db9ddb)
2026-10-13 09:27:54 +02:00
Ed Maste
a1e084d16d bsdinstall: Drop "Technology preview" from package sets
And refer to dist sets as "legacy."

We're planning on turning off dist sets in 16.0 (the code will remain
in the tree, but disabled by default) so we'd like to encourage users
to install 15.2 systems using package sets in order to ease the upgrade
path to 16.0.

Reviewed by:	cperciva
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D54156

(cherry picked from commit dac74b20c706b1f73986fb40dac27ed85c1d2850)
2026-10-11 14:02:43 +02:00
Franco Fichtner
412e76211e hyperv: two possible issues with patch
PR: https://forum.opnsense.org/index.php?topic=53114.msg275453#msg275453
2026-10-09 08:30:04 +02:00
Osvaldo Janeri Filho
86ceb5a41b pcib: Only apply ARI translation to a bridge's own secondary bus
ARI changes RID interpretation only for the device on a downstream
port's secondary bus.  pcib_xlate_ari() applied that translation to
every config access through an ARI-enabled bridge, including cycles
forwarded to a subordinate bus.

A non-zero slot on a subordinate bus then panics an INVARIANTS kernel
and is misrouted otherwise.  Translate only when the access targets
this bridge's secondary bus.

Reviewed by:	kib, jhb
Fixes:		55d3ea1731 ("Add support for PCIe ARI")
Sponsored by:	AMD
Differential Revision:	https://reviews.freebsd.org/D60033
(cherry picked from commit 10409ee40baf593b810cd0140f3c2f0d737c1a65)
2026-10-09 08:13:27 +02:00
John Baldwin
06503b4231 ktls CBC decrypt: Avoid creating zero length iovec entries
If an mbuf's length in the chain for an encrypted TLS record exactly
matches the remaining length of header bytes to skip, skip the mbuf
entirely rather than adding a zero-length iovec entry.

Sponsored by:	Chelsio Communications

(cherry picked from commit 1756d1cab3ce28085eec94a45c557e1af265ccd0)
2026-10-09 08:13:07 +02:00
Pouria Mousavizadeh Tehrani
89187fb704 route/fib_algo: Respect immediate_sync in fd_ref_nhop
Now fd_ref_nhop() returns zero for cross family routes,
Do not schedule nhop references and try to rebuild it immediately
for connected and static routes.

PR:	298733
Fixes:	633438224304 ("route/fib_algo: Fix nexthop index ...")
(cherry picked from commit 3d030136ad1906e6d463673a8d2ef313eb054fb3)
2026-10-09 08:07:30 +02:00
Pouria Mousavizadeh Tehrani
60a50f0c2e route/fib_algo: Fix FIB_ALGO without ROUTE_MPATH option
The ROUTE_MPATH compile option has been removed from CURRENT
branch. Therefore, use the ROUTE_MPATH macro for nhgrp headers.

PR:	299210
Fixes:	891bda143f6b ("route/fib_algo: Fix nexthop index ...")
Differential Revision:	https://reviews.freebsd.org/D59552

(cherry picked from commit 63343822430453f4add20bcbfa134c99132361df)
2026-10-09 08:06:52 +02:00
Olivier Certner
8c18f157b9 SYSCTL(9): Retire SYSCTL_NODE_CHILDREN()
It does not provide value over the pre-existing SYSCTL_STATIC_CHILDREN()
macro, which is widely used in the tree, whereas SYSCTL_NODE_CHILDREN()
is not.

Reviewed by:    markj
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D60009

(cherry picked from commit 4672ad1f16092c146261b4de485ec5eb5e8d127b)
2026-10-09 08:05:40 +02:00
John Baldwin
309914e5e7 vnic: Add missing #include
Reported by:	bz, olivier
Fixes:		6dc813301a17 ("sys: Use is_pci_device instead of direct comparisons to devclasses")
Sponsored by:	Chelsio Communications
(cherry picked from commit 8c9dc47b5fcaf58a89b1511118b78a65737b20cc)
2026-10-09 08:03:48 +02:00
Mitchell Horne
0a7d52ef87 ofw: bool-ify OF_hasprop()
Adjust the function signature and the few callers that don't treat it
this way already.

This is style only; no functional change intended.

Reviewed by:	andrew
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D56203

(cherry picked from commit b60cd486a652f0427e525b4482ac598be5460459)
2026-10-07 13:35:15 +02:00
Kyle Evans
ed7f8101a1 kern: ofw: provide ofw_bus_destroy_iinfo to teardown interrupt-map
For symmetry with ofw_bus_setup_iinfo, the next commits will use it to
properly cleanup on failure in bcm2838_pci.

Reviewed by:	andrew

(cherry picked from commit b230a7b9a52c0fc948f4f1dcd1225a94674073f6)
2026-10-07 13:34:04 +02:00
Ed Maste
7e3d38654d sys: Import snapshot of Aquantia ACQ107 vendor driver
Obtained from https://github.com/Aquantia/aqtion-freebsd commit
c61d27b1d94af72c642deefa0595884481ea7377.

This is not using a vendor branch.  The formerly-upstream repo is
abandoned and I do not believe it will receive updates.  This initial
import serves as a snapshot of the vendor code, but from here we will
iterate on it in the tree as our own code.

Bug fixes, code cleanup, and build infrastructure will follow.

NetBSD and OpenBSD have derivatives of this driver (with additional
hardware support).  We can look to changes in those drivers, and the
Linux driver, to add support here.

Reviewed by:	adrian
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53813

(cherry picked from commit 493d26c58e732dcfcdd87993ef71880adfe9d0cb)
2026-10-07 08:13:04 +02:00
Minsoo Choo
d41d432ac3 conf: remove trailing whitespace
This prevents unwanted change when saving files on IDEs (e.g. VSCode,
Zed)

Signed-off-by: Minsoo Choo <minsoo@minsoo.io>
Sponsored by:	The FreeBSD Foundation
Pull request:	https://github.com/freebsd/freebsd-src/pull/2152

(cherry picked from commit a338f5a0e7b1b5c22595aacbac44582ed5e0fe86)
2026-10-07 08:07:51 +02:00
Sreekanth Reddy
975fafe179 if_bnxt: Add support for HWRM passthrough with multiple DMA buffers
Added support for HWRM passthrough commands with multiple DMA buffers.

Also, changed the mgmt_lock to sleepable exclusive lock.

MFC after:      2 weeks
Reviewed by:    gallatin, ssaxena
Differential Revision: https://reviews.freebsd.org/D56686

(cherry picked from commit 9d87ca8b9f60bdec0bbc1733920df250a08beb0c)
2026-10-07 08:06:12 +02:00
Chandrakanth Patil
b20cae1836 bnxt_en: add bnxt_sriov.c to sys/conf/files for built-in kernel builds
The SR-IOV series added bnxt_sriov.c and listed it in sys/modules/bnxt/bnxt_en/Makefile,
but kernels that build bnxt into the image only compile sources named in sys/conf/files.
Add bnxt_sriov.c next to the other bnxt_en entries so built-in bnxt (including LINT)
links the SR-IOV implementation and avoids undefined symbols referenced from if_bnxt.c.

Fixes: f2f831b2c151 ("bnxt_en: Add core SR-IOV infrastructure")

MFC after:      1 month
Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D56688

(cherry picked from commit c21c63fb565f1bc7f9564dbf12068c864f8891d8)
2026-10-07 08:03:52 +02:00
Sumit Saxena
6159a23201 if_bnxt: add few source files to version control
Commits- f85e66e655c9 ("if_bnxt/bnxt_re: add support for driver snapdump")
and 03839879a2dd ("if_bnxt: Add Firmware crashdump collection support")
missed to add few files under version control, those files are
added now:

sys/dev/bnxt/bnxt_en/bnxt_log.c
sys/dev/bnxt/bnxt_en/bnxt_log.h
sys/dev/bnxt/bnxt_en/bnxt_log_data.c
sys/dev/bnxt/bnxt_en/bnxt_log_data.h
sys/dev/bnxt/bnxt_en/bnxt_coredump.c
sys/dev/bnxt/bnxt_en/bnxt_coredump.h

bnxt_coredump.c entry is added in sys/conf/files as well.

Fixes: f85e66e655c9 ("if_bnxt/bnxt_re: add support for driver snapdump")
Fixes: 03839879a2dd ("if_bnxt: Add Firmware crashdump collection support")
(cherry picked from commit 9931dc5bf3831146c08a381c42ecbfcedb8ac7f1)
2026-10-07 08:02:54 +02:00
Sumit Saxena
be4b0097de if_bnxt: add bnxt logger module files to sys/conf/files for built-in kernel builds
The bnxt snapdump and coredump support patches added bnxt_log/{_data}.c. and listed it in
sys/modules/bnxt/bnxt_en/Makefile, but missed to add these files in sys/conf/files.

Fix up the issue by adding bnxt_log/{_data}.c in sys/conf/files.

Fixes: f85e66e655c9 ("if_bnxt/bnxt_re: add support for driver snapdump")
(cherry picked from commit 03676cafa882c471a29436aae76c8751d451dd07)
2026-10-07 08:02:43 +02:00
Sreekanth Reddy
f269083091 if_bnxt: Fix the Unknown command 0x80000000 ioctl command error
With the latest niccli version, user will observe below
Unknown command command error when try to list the devices.

if_bnxt: Unknown command 0x80000000

Here, niccli is issuing command opcode as 0x80000000 but
driver is expecting 0x20000000 command opcode.

So, replaced _IOW(0,0,0) with the _IOC(IOC_IN,0,0,0).

Fixes: d53d7b4 ("bnxt: Fix up ioctl opcodes to support IOC_VOID along with IOC_IN")

MFC after:      2 weeks
Reviewed by:    gallatin, ssaxena
Differential Revision: https://reviews.freebsd.org/D56685

(cherry picked from commit 3987058a3a943c461c27dbebf10dad555b1bb2fa)
2026-10-07 08:01:09 +02:00
Sreekanth Reddy
e01b50d9f9 if_bnxt: Add Firmware crashdump collection support
This patch adds support for DDR-based firmware coredump memory handling.
It detects firmware coredump capability, allocates host DDR (DMA) memory
for crash dumps, and programs the firmware with the allocated memory during
attach. The allocated memory is released during driver detach.

Also, This patch adds functions to retrieve crash dump data from host DDR
memory. The implementation handles data copying from page tables and
checks dump availability. Main function bnxt_get_coredump() copies
stored crash dump data from DDR memory to the application buffer.

MFC after:      2 weeks
Reviewed by:    gallatin, ssaxena
Differential Revision: https://reviews.freebsd.org/D56684

(cherry picked from commit 03839879a2dd2505eab80b99211b0637ebdc9d32)
2026-10-07 08:01:08 +02:00
Sreekanth Reddy
e805dc0058 if_bnxt/bnxt_re: Update hsi headers
Update hsi headers

MFC after:      2 weeks
Reviewed by:    gallatin, ssaxena
Differential Revision: https://reviews.freebsd.org/D56683

(cherry picked from commit 308784bebe796cbdaccf7ef259caf7d87f874d02)
2026-10-07 08:00:53 +02:00
Sreekanth Reddy
4793fbe9e5 if_bnxt/bnxt_re: add support for driver snapdump
Add a logging module which helps to log and collect the driver`s
various events and state of device data structures.
APIs help modules like l2, RoCE etc. to register and
add logs into thg buffers. A segment header is added to the
data available in buffers.

The final log messages are arranged in following fashion

|SegHeader0|Data0|SegHeader1|Data1|
Logging module provides two different kinds of buffers:
a) A large contiguous memory chunk is used to form circular buffers.

Module need to provide a number of buffers while registering to
the logging module.Please note that, since memory for the
buffers remains with the module as long as it is registered, memory
footprints of the driver could be higher so the modules should
allocate an appropriate number of buffers. Also, due to limited
space, modules should only log important events/messages into
the buffer.
Modules  must use bnxt_log_add_mssg() to add the message into the
list.
b) Live buffer - They are allocated during coredump retrieval and

freed after the coredump data is returned to the user. This helps
to collect live data from the driver. Modules must use the
bnxt_log_live() function to add the log messages.
When coredump is retrieved all the messages available in above buffers are
copied into the coredump buffer.

Test Plan:
Generate the coredump using below niccli command
./niccli.freebsd -i 1 debug --coredump

and then verify the coredump contents using the Broadcom's Coredump decoder.

MFC after:      2 weeks
Reviewed by:    gallatin, ssaxena
Differential Revision: https://reviews.freebsd.org/D56682

(cherry picked from commit f85e66e655c9293ea049814e21ed67ab246a7305)
2026-10-07 08:00:53 +02:00
Sumit Saxena
fb81e1c892 bnxt: Fix up ioctl opcodes to support IOC_VOID along with IOC_IN
The driver and applications currently use hard-coded numeric ioctl command
opcodes. These opcodes are interpreted as having the IOC_IN direction (data
copied from the user application to the driver), regardless of the actual packet
size. Consequently, when the packet size is zero and the direction is set to
IOC_IN, the kernel fails these ioctls if COMPAT is disabled.

While the driver and applications should ideally set the direction correctly—
for example, using IOC_VOID when the packet size is zero—the driver will now
be updated to define ioctl opcodes using the _IOC macro to support both
IOC_VOID and IOC_IN. This change ensures backward compatibility with older
applications that exclusively use IOC_IN.

Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D54601
MFC after: 3 days

(cherry picked from commit d53d7b466016408229491cfd2f8bdc742ff642e3)
2026-10-07 08:00:37 +02:00
Andrew Gallatin
47fd2ba69b bnxt: Fix build / load error for bnxt(4) in kernels without PCI_IOV
This change removes the hard-forcing of  PCI_IOV and adds shims to
allow the driver to compile and work when the kernel is missing
PCI_IOV support.

Fixes: 7c450d1127c7
Reviewed by: sumit.saxena_broadcom.com
Differential Revision: https://reviews.freebsd.org/D57300
Sponsored by: Netflix

(cherry picked from commit 3118f1b99f23431235c202d9aadbe3d183bcc259)
2026-10-07 08:00:37 +02:00
Chandrakanth Patil
aace4574a1 bnxt_en: Address review comments for core SR-IOV support
This patch addresses the code review comments provided for:
https://reviews.freebsd.org/D56197

* P7 VF PCI ID: rename NETXTREME_E_P7_VF to E_P7_VF (P7/Thor2 line drops the
  Netxtreme name in product strings; other VF device IDs are unchanged).
* Use the return value of bnxt_vf_parse_schema() in bnxt_iov_vf_add() to
  decide when to call bnxt_set_vf_admin_mac(); make parse_schema() return
  bool and remove the has_admin_mac field.
* In bnxt_free_vf_resources(), fix indentation after dma_free_coherent() so
  the NULL assignment is clearly separate from the call.
* In bnxt_hwrm_func_vf_resource_free(), use first_vf_id/last_vf_id in the
  HWRM_FUNC_VF_RESC_FREE loop.

MFC after:      1 month
Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D56644

(cherry picked from commit 7c450d1127c7f08361f848c0ac57189910da8d3b)
2026-10-07 08:00:24 +02:00
Chandrakanth Patil
2cf32cb9f6 bnxt_en: VF ring reservation, HWRM registration, and PF-only operation guards
VFs require separate HWRM commands for ring reservation and async
completion ring setup, so a common PF/VF dispatcher is introduced and
the async CR path is extended to handle both.  The PF must populate the
VF request forwarding bitmap during driver registration so the firmware
correctly forwards VF-originated HWRM commands.  VF reservation strategy
and min-guaranteed capability flags are now parsed for correct resource
partitioning, and PF-only operations (DCB, NVM, package version sysctl)
are guarded against VF invocation.

The short command buffer allocation is also reordered before the function
reset to ensure extended HWRM messages are available when needed, a
prerequisite uncovered during VF bring-up.

MFC after:      1 month
Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D56232

(cherry picked from commit c972c5acbac472a5dc797856f39f478862b6c6ea)
2026-10-07 08:00:23 +02:00
Chandrakanth Patil
2a64e770aa bnxt_en: Re-enable SR-IOV after firmware reset
When the firmware undergoes a hot-reset and the driver re-opens the
device, previously active Virtual Functions lose their resource
configuration.  bnxt_reenable_sriov() restores that configuration by
replaying bnxt_cfg_hw_sriov() with the saved resource parameters.

The function is called from bnxt_fw_reset_task() in the
BNXT_FW_RESET_STATE_OPENING state, guarded by #ifdef PCI_IOV.
Because bnxt_cfg_hw_sriov() is a no-op when active_vfs is zero the
call is safe on any PF regardless of whether VFs were ever created.

MFC after:      1 month
Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D56201

(cherry picked from commit 8743209350cb4b7db6d367df99da0a7ae3bc5d39)
2026-10-07 08:00:07 +02:00
Chandrakanth Patil
ca8e649671 bnxt_en: Add per-VF trust, spoof-check and promiscuous controls
Expose per-VF policy knobs via the FreeBSD sysctl tree and enforce
them at the data-path level.

Trust (dev.bnxt.<unit>.vfN.trusted):
  bnxt_set_vf_trust() sets/clears BNXT_VF_TRUST and sends
  HWRM_FUNC_CFG with FLAGS_TRUSTED_VF_ENABLE/DISABLE.
  bnxt_create_trusted_vf_sysctls() / bnxt_destroy_trusted_vf_sysctls()
  manage the sysctl lifetime with VF creation/teardown.

Spoof-check (dev.bnxt.<unit>.vfN.spoofchk):
  bnxt_set_vf_spoofchk() issues HWRM_FUNC_CFG with
  SRC_MAC_ADDR_CHECK_ENABLE/DISABLE.

Promiscuous gating:
  bnxt_is_trusted_vf() queries firmware via HWRM_FUNC_QCFG.
  bnxt_promisc_ok() returns false for untrusted VFs, preventing them
  from entering promiscuous mode.  bnxt_promisc_set() is updated to
  gate the PROMISCUOUS and ANYVLAN_NONVLAN mask bits on bnxt_promisc_ok().

bnxt_iov_vf_add() applies the initial trust/spoof-check policy from the
nvlist schema.  bnxt_iov_init() creates the sysctl trees after
bnxt_cfg_hw_sriov() succeeds.  bnxt_iov_uninit() tears them down.

MFC after:      1 month
Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D56200

(cherry picked from commit ea4ab7e36ed9cf153c374782be446254a7d11822)
2026-10-07 08:00:06 +02:00
Chandrakanth Patil
a5dbde22e2 bnxt_en: Add VF forwarded HWRM request handling
Enable the Physical Function to proxy HWRM commands issued by Virtual
Functions through the firmware forwarded-request mechanism.

When a VF issues a command that requires PF arbitration, the firmware
delivers a CMPL_BASE_TYPE_HWRM_FWD_REQ completion to the PF async ring.

* bnxt_process_async_msg() recognises CMPL_BASE_TYPE_HWRM_FWD_REQ,
  identifies the originating VF by its firmware function ID, sets the
  corresponding bit in pf.vf_event_bmap, and raises
  BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT to schedule deferred processing.

* bnxt_sp_task() dispatches to bnxt_hwrm_exec_fwd_req(), which iterates
  over all pending VF bits and calls bnxt_vf_req_validate_snd() for each.

* bnxt_vf_req_validate_snd() inspects the encapsulated request type:
  HWRM_FUNC_VF_CFG (MAC change) is handled by bnxt_vf_configure_mac()
  which enforces trust/existing-MAC rules; HWRM_CFA_L2_FILTER_ALLOC is
  handled by bnxt_vf_validate_set_mac(); HWRM_FUNC_CFG is forwarded
  as-is; all other commands are rejected.

All forwarded-request code is guarded by #ifdef PCI_IOV.

MFC after:      1 month
Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D56199

(cherry picked from commit fcf100da9b381ad9d81f94499fdadea15ae2b431)
2026-10-07 07:59:49 +02:00
Chandrakanth Patil
9805693cb1 bnxt_en: Add VF load path and PF/VF context differentiation
Teach the driver to distinguish a Physical Function from a Virtual
Function at probe time and configure each appropriately.

* Introduce bnxt_is_vf_device() to identify all known VF device IDs
  (NetXtreme-C/E Gen1-3, Thor1/2, Hyper-V variants).  Add corresponding
  PVID entries to bnxt_vendor_info_array.

* Refactor the iflib shared context: rename bnxt_sctx_init to
  bnxt_sctx_template, add a Thor2-specific bnxt_sctx_template_p7, and
  build per-call PF/VF instances via bnxt_init_sctx_variants(); the VF
  instance carries IFLIB_IS_VF.  bnxt_register() selects the correct sctx.

* bnxt_attach_pre(): replace the hard-coded NPAR/VF switch with
  bnxt_set_flags_by_devid(); on a VF call bnxt_approve_mac() to request
  PF approval for the firmware-assigned MAC address.

* bnxt_hwrm_func_qcaps(): populate fw_fid and MAC for PF and VF contexts
  separately; for PF call iflib_set_mac() and record max_msix_vfs; for VF
  handle the case where the PF has not yet assigned a MAC.

* bnxt_hwrm_func_qcfg(): populate the new alloc_* counters used by the VF
  resource configuration path; record registered_vfs for PF and VLAN/trust
  state for VF.

* bnxt_init(): call bnxt_update_vf_mac() on VFs after each bring-up.

MFC after:      1 month
Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D56198

(cherry picked from commit a5bedb41e5d6b3680981f109c3e89fb5ffd8eee1)
2026-10-07 07:59:49 +02:00
Chandrakanth Patil
2816a65847 bnxt_en: Add core SR-IOV infrastructure
Introduce the foundational building blocks for SR-IOV Virtual Function
support on Broadcom NetXtreme-C/E adapters.

* Add bnxt_sriov.h: defines the extended bnxt_vf_info structure (per-VF
  firmware FID, MAC addresses, VLAN, flags, DMA command buffers, resource
  counts), the bnxt_resc_map helper, flag macros (BNXT_VF_TRUST,
  BNXT_VF_SPOOFCHK, etc.), and prototypes for all SR-IOV functions.

* Add bnxt_sriov.c: implements the SR-IOV attachment sequence
  (bnxt_sriov_attach), the iflib IOV callbacks (bnxt_iov_init,
  bnxt_iov_uninit, bnxt_iov_vf_add), VF resource allocation and
  firmware configuration helpers (bnxt_alloc_vf_resources,
  bnxt_cfg_hw_sriov, bnxt_hwrm_func_vf_resc_cfg, bnxt_hwrm_func_buf_rgtr,
  bnxt_hwrm_func_vf_resource_free), and the per-VF parameter helper.

* Extend bnxt.h: include bnxt_sriov.h; extend bnxt_pf_info with VF-
  tracking fields (vf array, firmware FID/MAC, resource-reservation
  strategy, DMA page management, sysctl context); replace the upstream
  bnxt_vf_info stub with the full definition from bnxt_sriov.h; extend
  bnxt_func_qcfg with allocation counters required by the VF resource
  configuration path; add vf_resc_cfg_input and sriov_lock to bnxt_softc.

* Update Makefile to build bnxt_sriov.c and include bnxt_sriov.h.

* Wire up PCI-IOV device methods (pci_iov_init / pci_iov_uninit /
  pci_iov_add_vf) and iflib IOV callbacks (ifdi_iov_init / ifdi_iov_uninit
  / ifdi_iov_vf_add) in if_bnxt.c; call bnxt_sriov_attach() from
  bnxt_attach_post() on P5+ Physical Functions.

MFC after:      1 month
Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D56197

(cherry picked from commit f2f831b2c151a9d989a94fc7c894118c802ef348)
2026-10-07 07:59:35 +02:00
acazuc
a60f97b90f bnxt: set hardware checksum only if required
The test condition in the bnxt driver for TCP/UDP transmit hardware checksum
offload is invalid: only the TCP / UDP csum bits should be tested

Only the relevant ipi_csum_flags bits are now tested

Reviewed by: tuexen
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D53941

(cherry picked from commit 2e94e1631ef517f5495e25d7fa22c95f7dca0dc6)
2026-10-07 07:59:35 +02:00
Pouria Mousavizadeh Tehrani
fe4379374a nd6: Fix regeneration of temp addresses in detached state
When an on-link prefix becomes detached, the kernel keeps
generating new RFC 8981 temporary addresses for that prefix.
Fix it by ignoring the detached addresses in regen_tmpaddr().
While here, change its return type to bool.

PR:		298533
Discussed with:	markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D60051

(cherry picked from commit 61f98a98250da7bd2c80c6d93d0032961d7f2fad)
2026-10-07 07:56:46 +02:00