FreeBSD/src d713a81 — usr.sbin/bhyve/riscv fdt.c

bhyve/riscv: fix PCIe FDT interrupt-map entry stride

In bhyve arm64, each PCIe interrupt-map entry spans 10 cells because the
ARM GIC specifies #interrupt-cells = 3. On RISC-V, the APLIC uses
#interrupt-cells = 2, so each entry spans only 9 cells.

When the PCIe FDT code was originally adapted from arm64, the property
allocation size and cell assignments were reduced to 9 cells per entry,
but the loop multiplier retained the 10-cell stride. This caused the
interrupt-map array to be packed incorrectly with gaps, breaking PCI
interrupt routing in guest operating systems and overflowing the
allocation by 16 cells.

Correct the loop stride to 9 cells so the interrupt map is properly
formed.

Approved by:    re (cperciva)
Reviewed by:    jrtc27
Fixes:          7ab1a32cd43c ("bhyve/riscv: Initial import")

    [28 lines not shown]
DeltaFile
+9-9usr.sbin/bhyve/riscv/fdt.c
+9-91 files

FreeBSD/src d9daf5a — contrib/kyua config.h

contrib/kyua: update config.h for 0.15.1 -> 0.15.2

This was accidentally missed in the prior commit.

This commit addresses a largely cosmetic issue.

MFC after:      6 days
MFC with:       c16da33701d0
Fixes:          c16da33701d0 contrib/kyua: update to 0.15.2
DeltaFile
+3-3contrib/kyua/config.h
+3-31 files

FreeBSD/src f992c08 — contrib/netbsd-tests/kernel t_mqueue.c, tests/freebsd_test_suite macros.h

Remove {ATF,PLAIN}_REQUIRE_KERNEL_MODULE macros

These macros predated the `require.kmod` (ATF) and `required_kmods`
(kyua) test metadata and are no longer needed.

Add a hint to freebsd_test_suite/macros.h about the `*FEATURE*` macros
going away soon. See [this kyua issue][kyua-issue] for more details.

MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D61082

[kyua-issue]: https://github.com/freebsd/kyua/issues/346
DeltaFile
+13-13tests/freebsd_test_suite/macros.h
+15-3tests/sys/net/routing/rtsock_config.h
+0-4contrib/netbsd-tests/kernel/t_mqueue.c
+1-0tests/sys/kern/Makefile
+29-204 files

FreeBSD/src ef3c76f — sys/dev/mii mii.c

mii: call only PHY_STATUS() from mii_pollstat()

When we are in mii_pollstat() which effectively is called only from
ue_mii_sts methods of various drivers, we are interested in polling the
status and not making any actions.

What PHY_SERVICE(,, MII_POLLSTAT) effectively did was PHY_STATUS()
followed by mii_phy_update().  The latter is undesired, as we already may
be servicing a link state change event and posting a second one is not
what we want.  Usually mostly harmless, this second event would panic when
device is calling into mii during its detach (e.g. USB device).

NB: there are few drivers that would do extra stuff between PHY_STATUS()
and mii_phy_update() in their mii_service methods. This seems irrelevant
to me when we are in ue_mii_stat/mii_pollstat. But I could be wrong.

See the PR for longer discussion.

PR:             290417
DeltaFile
+1-1sys/dev/mii/mii.c
+1-11 files

FreeBSD/src ba04542 — tests/sys/kern ssl_sendfile.c

tests/ssl_sendfile: size socket buffers before connecting

The :grow, :truncate and :eagain_vs_eof cases rely on the socket buffers
filling up before the whole file has been sent. :grow and :truncate shrank
SO_SNDBUF and SO_RCVBUF only after the connection was established, when
the receiver had already advertised a window based on the default buffer
size; TCP does not shrink an advertised window. :eagain_vs_eof used the
default, autosized buffers. With a large net.inet.tcp.recvspace, or once
autosizing has grown the buffers, the whole 2 MB file fits in the socket
buffers:

  :grow and :truncate: sendfile(2) returns before the file is resized, and
the poll loop that waits for the sender to block spins forever on a
writable socket.
  :eagain_vs_eof: the loop that keeps writing until
EAGAIN never sees it, since sendfile(2) returns 0 at EOF.

Either way kyua reports a timeout, which is why doubling the timeouts did
not help. Apply a 128 KB buffer size to the listening socket, which the

    [12 lines not shown]
DeltaFile
+15-17tests/sys/kern/ssl_sendfile.c
+15-171 files

FreeBSD/src d851c68 — usr.sbin/bhyve/riscv fdt.c

bhyve/riscv: fix PCIe FDT interrupt-map entry stride

In bhyve arm64, each PCIe interrupt-map entry spans 10 cells because the
ARM GIC specifies #interrupt-cells = 3. On RISC-V, the APLIC uses
#interrupt-cells = 2, so each entry spans only 9 cells.

When the PCIe FDT code was originally adapted from arm64, the property
allocation size and cell assignments were reduced to 9 cells per entry,
but the loop multiplier retained the 10-cell stride. This caused the
interrupt-map array to be packed incorrectly with gaps, breaking PCI
interrupt routing in guest operating systems and overflowing the
allocation by 16 cells.

Correct the loop stride to 9 cells so the interrupt map is properly
formed.

Reviewed by:    jrtc27
Fixes:          7ab1a32cd43c ("bhyve/riscv: Initial import")
MFC after:      3 days

    [3 lines not shown]
DeltaFile
+9-9usr.sbin/bhyve/riscv/fdt.c
+9-91 files

FreeBSD/src a24fc8c — usr.sbin/bhyve/riscv fdt.c

Revert "bhyve/riscv: fix PCIe FDT interrupt-map entry stride"

Thanks to past me's foolish choice not to alter the commit message such
that none of its lines start with a #, Git got very confused the
cherry-pick and included its own commented-out instructions. Reverting
to re-land with a fixed body.

This is a direct commit to stable/15.

This reverts commit 69f76efd01a72fe0d6cb68442d2c15d3174a268f.
DeltaFile
+9-9usr.sbin/bhyve/riscv/fdt.c
+9-91 files

FreeBSD/src 69f76ef — usr.sbin/bhyve/riscv fdt.c

bhyve/riscv: fix PCIe FDT interrupt-map entry stride

In bhyve arm64, each PCIe interrupt-map entry spans 10 cells because the
ARM GIC specifies #interrupt-cells = 3. On RISC-V, the APLIC uses
#interrupt-cells = 2, so each entry spans only 9 cells.

When the PCIe FDT code was originally adapted from arm64, the property
allocation size and cell assignments were reduced to 9 cells per entry,
but the loop multiplier retained the 10-cell stride. This caused the
interrupt-map array to be packed incorrectly with gaps, breaking PCI
interrupt routing in guest operating systems and overflowing the
allocation by 16 cells.

Correct the loop stride to 9 cells so the interrupt map is properly
formed.

Reviewed by:    jrtc27
Fixes:          7ab1a32cd43c ("bhyve/riscv: Initial import")
MFC after:      3 days

    [25 lines not shown]
DeltaFile
+9-9usr.sbin/bhyve/riscv/fdt.c
+9-91 files

FreeBSD/src 9b7959f — tests/sys/kern ssl_sendfile.c

Revert "tests/sys/kern/ssl_sendfile: double timeouts for :grow and :truncate"

A proper fix is being done in https://reviews.freebsd.org/D61752 .

PR:     299447

This reverts commit 932996069a5343b1d6563e97a12308a81c34d4fe.
DeltaFile
+2-21tests/sys/kern/ssl_sendfile.c
+2-211 files

FreeBSD/src a8fd8a5 — share/man/man9 style.9

style.9: Avoid C++ keywords

Headers may be included by C++ code, and sometimes we might like to
use exinst code as C++.  Encourage authors to avoid C++ keywords as
identifiers.

Reviewed by:    des, imp (earlier version)
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61767
DeltaFile
+15-1share/man/man9/style.9
+15-11 files

FreeBSD/src 8364b6b — sys/netpfil/ipfw ip_fw_sockopt.c ip_fw_compat.c

ipfw: fix off-by-one in the IP_FW_XADD rule count check

Restore the pre-4a77657cbc0 ">=" comparison, otherwise parse_rules_v1()
writes one rule_check_info beyond the allocated buffer.

Do the same in ip_fw_compat.c, which has a copy of the loop but is not
built at the moment.

stable/14 is not affected.

Reviewed by:    ae
Fixes:          4a77657cbc0 ("ipfw: migrate ipfw to 32-bit size rule numbers")
MFC after:      1 week
MFC to:         stable/15
Found with:     Claude Code Opus 5.5
Differential Revision:  https://reviews.freebsd.org/D61727
DeltaFile
+1-1sys/netpfil/ipfw/ip_fw_sockopt.c
+1-1sys/netpfil/ipfw/ip_fw_compat.c
+2-22 files

FreeBSD/src 8651589 — usr.sbin/bhyve bhyve.8, usr.sbin/bhyvectl bhyvectl.8

bhyve.8: mention VM nodes in /dev/vmm

Currently, VM nodes in /dev/vmm are only described in the
EXAMPLES section of bhyvectl.8. Add a FILES section to bhyve.8
to make this information easier to find.

Update the bhyvectl.8 example to say "Existing VMs"
instead of "Running VMs" as the VMs listed in /dev/vmm
are not necessarily running.

Update bhyvectl.8 to refer to vmm(4).

Reviewed by:    ziaee
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D61623
DeltaFile
+3-2usr.sbin/bhyvectl/bhyvectl.8
+5-0usr.sbin/bhyve/bhyve.8
+8-22 files

FreeBSD/src 457873b — tests/sys/pmc pmc_rdpmc_test.c pmc_ss_test.c

tests/sys/pmc: Skip pmc_ss and getmsr_refusals without a hardware PMC

In a guest without a PMU, hwpmc(4) registers only the SOFT class, but
the "instructions" alias still resolves from the pmu-events tables, so
pmc_allocate() fails with EINVAL.  pmc_ss_test checked only the alias
and getmsr_refusals required the allocation, so both failed in CI
instead of skipping.

Probe the allocation the tests make and skip if it fails, as
rdpmc_reads_own_counter already does.

PR:             300856 (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300856)
Reported by:    ngie
Reviewed by:    mhorne, ngie
Fixes:          d546356523f3 ("tests/sys/pmc: add PERF, RDPMC, row, sampling and unload tests")
Sponsored by:   Advanced Micro Devices, Inc.
Signed-off-by:  Osvaldo Janeri Filho <ojanerif at amd.com>
Differential Revision:  https://reviews.freebsd.org/D61689
DeltaFile
+8-4tests/sys/pmc/pmc_ss_test.c
+3-1tests/sys/pmc/pmc_rdpmc_test.c
+11-52 files

FreeBSD/src 1768d48 — sys/dev/hwpmc hwpmc_amd.c

hwpmc: keep AMD UMC counters from saturating

UMC counters saturate at 2^48 instead of wrapping, after about a day
and a half of memory clock cycles.  Clear bit 47 on a read once it is
set and count the carries in the per-CPU overflow count of the PMC,
like the arm64 and armv7 drivers do for their 32-bit counters.

Reviewed by:    mhorne
Sponsored by:   Advanced Micro Devices, Inc.
Signed-off-by:  Osvaldo Janeri Filho <ojanerif at amd.com>
Differential Revision:  https://reviews.freebsd.org/D60771
DeltaFile
+21-3sys/dev/hwpmc/hwpmc_amd.c
+21-31 files

FreeBSD/src ed4bad7 — usr.sbin/bhyve bhyve.8

bhyve.8: mention config files for VM parameters

Mention that virtual CPUs, memory and other options can be configured
with a configuration file, and refer to the -k option.

Reviewed by:    ziaee
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D61718
DeltaFile
+4-2usr.sbin/bhyve/bhyve.8
+4-21 files

FreeBSD/src 78a69f9 — usr.bin/top display.c

top: fix off-by-one in screenbuf

There is a heap overflow for screenbuf originating from
the top import to the tree. The i_process()/u_process() functions
write a terminating NUL one byte past each screenbuf line slot
when the line fills the slot, which is a 1-byte heap overflow on the last slot.

The display_resize() function allocates screen_width bytes per line.
i_process() and u_process() cut lines to screen_width characters and
then stpcpy() them into the slot, which writes screen_width + 1 bytes.
line_update() can do the same with *old = ch. For inner slots,
the NUL lands in byte 0 of the next slot. This can corrupt the saved
contents used when updating the next line. For the last slot, it writes
one byte past the end of screenbuf.

Fix by allocating (screen_width + 1) bytes per line and updating the
line offsets to fit the terminating NUL.

Reviewed by:    kib

    [5 lines not shown]
DeltaFile
+3-3usr.bin/top/display.c
+3-31 files

FreeBSD/src cd2ec1b — usr.bin/top display.c

top: fix off-by-one in screenbuf

There is a heap overflow for screenbuf originating from
the top import to the tree. The i_process()/u_process() functions
write a terminating NUL one byte past each screenbuf line slot
when the line fills the slot, which is a 1-byte heap overflow on the last slot.

The display_resize() function allocates screen_width bytes per line.
i_process() and u_process() cut lines to screen_width characters and
then stpcpy() them into the slot, which writes screen_width + 1 bytes.
line_update() can do the same with *old = ch. For inner slots,
the NUL lands in byte 0 of the next slot. This can corrupt the saved
contents used when updating the next line. For the last slot, it writes
one byte past the end of screenbuf.

Fix by allocating (screen_width + 1) bytes per line and updating the
line offsets to fit the terminating NUL.

Reviewed by:    kib

    [5 lines not shown]
DeltaFile
+3-3usr.bin/top/display.c
+3-31 files

FreeBSD/src 5165da2 — sys/netpfil/pf pf_lb.c, tests/sys/netpfil/pf Makefile nat46.sh

pf: fix nat46 ICMP handling

When porting from OpenBSD I typo'd the variable where we store the ICMP
type, in the nat46 direction. The nat64 direction was correct. Fix this
so ICMP translation works for nat46.

Add a test case for this, as well as basic TCP and UDP cases because
nat46 was entirely untested.

PR:             300461
MFC after:      1 week
Submitted by:   Charles Marshall <charles at wozi.com> (pf patch)
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+190-0tests/sys/netpfil/pf/nat46.sh
+2-2sys/netpfil/pf/pf_lb.c
+1-0tests/sys/netpfil/pf/Makefile
+193-23 files

FreeBSD/src e536321 — sys/netpfil/pf pf_norm.c

pf: fix sctp normalisation cleanup

If we fail to allocate the dst scrub structure we should free the src
one too, but we passed src rather than src->scrub.

Reported by:    llm-postcr
MFC after:      1 week
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+1-1sys/netpfil/pf/pf_norm.c
+1-11 files

FreeBSD/src c589ea8 — tests/sys/netpfil/pf/ioctl Makefile validation.c

pf tests: run the ioctl tests in their own vnet too

Fix the validation:settflags test, because using a NULL buffer succeeds
if there's no table to set tflags in. Create a table to fix the test.

Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+8-0tests/sys/netpfil/pf/ioctl/validation.c
+4-0tests/sys/netpfil/pf/ioctl/Makefile
+12-02 files

FreeBSD/src 5131335 — tests/sys/netpfil/pf snmp.sh

pf tests: test pfTablesTblCount in snmp_pf

This works fine on main, but not on stable/15 so add a test.

PR:     300818
MFC after:      3 days
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+13-0tests/sys/netpfil/pf/snmp.sh
+13-01 files

FreeBSD/src 670bad0 — sys/kern kern_fail.c

pause fail point: affirm sleeping without a lock

The previous patch to fail_point_pause removed a lock wrapping a sleep.
INVARIANTS assertions require we affirm we are deliberately sleeping
without a lock or timeout via the PNOLOCK flag.

Reported by:    netchild
Reviewed by:    netchild
Fixes:  331613ddd8a5 ("Pause failpoint: replace mtx_sleep with tsleep")
Differential Revision:  https://reviews.freebsd.org/D61730
DeltaFile
+1-1sys/kern/kern_fail.c
+1-11 files

FreeBSD/src 4d8501e — sys/dev/acpica acpi_pci_link.c

acpi_pci_link: Handle IRQ values > 255

Some systems use a stub PCI link device for hardwired interrupts
instead of static _PRT entries.  These link devices can use an IRQ >
255.  The current driver was designed to handle PCI link devices on
x86 used for legacy INTx IRQs which were < 255.  These changes handle
larger IRQ values while making a few tradeoffs.

- Expand most IRQ fields from 8 bits to 32-bits.  The BIOS IRQ
  (read from the PCIR_INTLINE config register which is an 8-bit register)
  remains 8 bits.

- Add a wrapper API for managing interrupt weights and avoid tracking
  weights for IRQs > 255 and instead report a constant weight of 0 for
  IRQs > 255.

Approved by:    re (cperciva)
PR:             300476
Reported by:    Aviv Bakal <avivb at amazon.com>

    [4 lines not shown]
DeltaFile
+44-15sys/dev/acpica/acpi_pci_link.c
+44-151 files

FreeBSD/src e3589b7 — sys/dev/acpica acpi_pci_link.c

acpi_pci_link: Factor out some duplicated code into a single copy

Approved by:    re (cperciva)
Tested by:      cperciva

(cherry picked from commit 6c1b6f7cf81447315fc0c7a294ed1467c62832bd)
(cherry picked from commit b898d97abd96a31c1e26fb15779d35daf7b6ac97)
DeltaFile
+3-4sys/dev/acpica/acpi_pci_link.c
+3-41 files

FreeBSD/src 2f98fd7 — sys/dev/acpica acpi_pci_link.c

acpi_pci_link: Remove a helper variable from _PRS parsing

Approved by:    re (cperciva)
Tested by:      cperciva

(cherry picked from commit df10f7b7500c129c48a477e94039c4e0d2711b54)
(cherry picked from commit 0af24d1fe82f1161cab8f10ba7f23cc3bee7dc11)
DeltaFile
+3-5sys/dev/acpica/acpi_pci_link.c
+3-51 files

FreeBSD/src 0421a24 — sys/dev/acpica acpi_pci_link.c

acpi_pci_link: Ignore tunables with negative values

IRQ values are unsigned and negative values do not make sense.  The
invalid IRQ value (255) is already ignored, so ignoring other invalid
values is consistent with that behavior.

Approved by:    re (cperciva)
Reported by:    cperciva

(cherry picked from commit 81dab94a5452f996a063bdba2103eda4aa32b3d1)
(cherry picked from commit 1b71cb09074be51a87a2eb84acb46ee77fceec45)
DeltaFile
+4-2sys/dev/acpica/acpi_pci_link.c
+4-21 files

FreeBSD/src 109acce — usr.sbin/ctld nvmf.cc

ctld: Fix namespace IDs for exported NVMe namespaces part 2

This is the same fix as in commit
9c8be6518e2e5f396055ecdab8098ce19c4b2218 just applied to another
method that also accepts namespace IDs.  The original commit handled
configuration statements assigning a named LUN to a namespace.  This
change handles anonymous namespaces configured within a controller
context.

Approved by:    re (cperciva)
Fixes:          66b5296f1b29 ("ctld: Add support for NVMe over Fabrics")
Sponsored by:   Chelsio Communications
(cherry picked from commit 9a99fa3932ddd794234becc6eab6519d56ae6947)
(cherry picked from commit 469ac5a9c05f21526f81cb34833bfff53b07a7d5)
DeltaFile
+2-2usr.sbin/ctld/nvmf.cc
+2-21 files

FreeBSD/src 38c1b30 — usr.sbin/ctld nvmf.cc

ctld: Fix namespace IDs for exported NVMe namespaces

NVMe namespace IDs are 1-based, but CTL LUN IDs are 0-based.  The
in-kernel NVMe ctl(4) target accounts for this by adding one to the
LUN ID to compute a namespace ID.  ctld was attempting to handle this
by translating namespace IDs from config files to internal LUN IDs,
but it did this incorrectly resulting in the namespace configured for
as namespace N actually showing up as namespace N + 1.

Approved by:    re (cperciva)
Fixes:          66b5296f1b29 ("ctld: Add support for NVMe over Fabrics")
Sponsored by:   Chelsio Communications
(cherry picked from commit 9c8be6518e2e5f396055ecdab8098ce19c4b2218)
(cherry picked from commit 033c0cd3e89ba87f3d66ceea6436cf2a37148051)
DeltaFile
+2-2usr.sbin/ctld/nvmf.cc
+2-21 files

FreeBSD/src ab7815d — sys/cam/ctl ctl_ioctl.h

nvmft: Document all CTL_NVMF status codes

Sponsored by:   Chelsio Communications

(cherry picked from commit 02c0eefc4e0ba2208d97fb4a80cd9bc4ec0dc47f)
DeltaFile
+8-0sys/cam/ctl/ctl_ioctl.h
+8-01 files

FreeBSD/src 469ac5a — usr.sbin/ctld nvmf.cc

ctld: Fix namespace IDs for exported NVMe namespaces part 2

This is the same fix as in commit
9c8be6518e2e5f396055ecdab8098ce19c4b2218 just applied to another
method that also accepts namespace IDs.  The original commit handled
configuration statements assigning a named LUN to a namespace.  This
change handles anonymous namespaces configured within a controller
context.

Fixes:          66b5296f1b29 ("ctld: Add support for NVMe over Fabrics")
Sponsored by:   Chelsio Communications
(cherry picked from commit 9a99fa3932ddd794234becc6eab6519d56ae6947)
DeltaFile
+2-2usr.sbin/ctld/nvmf.cc
+2-21 files