ipfilter: Only recalculate the UDP header when we have one
When ipf_nat_out processes NAT_DIVERTOUT (ipnat rdr statements)
it also fixes the checksum in the UDP header. Test for a UDP header
before adjusting its length.
While we are here, the length in the UDP header must be converted
from network byte order to host byte order. Add the missing ntohs().
PR: 296944
MFC after: 3 days
libcasper: Use pdfork() for the zygote
Use pdfork(2) rather than fork(2) to fork the zygote, and close the
descriptor when the main loop terminates.
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: Qualys, Inc.
Reviewed by: oshogbo
Differential Revision: https://reviews.freebsd.org/D60176
pf tests: make return.py more robust
Sometimes ICMP echo packets get lost, so send more than one during
the sanity check. This should resolve the intermittent failure of the
return.py:TestReturn::test_tcp test.
PR: 300511
Sponsored by: Rubicon Communications, LLC ("Netgate")
intel/intel_pmc: Add support for Cannon Lake through Meteor Lake
Match the platform by CPU model and attach on acpi with PWRM at
0xfe000000; the PMC is not PCI-enumerable on these platforms.
SLP_S0_RES offsets and granularities follow each generation's PCH
Family Datasheet Volume 2. A mismatch between the LPIT residency
counter address and SLP_S0_RES is reported on attach.
Reviewed by: olce, adrian
Differential Revision: https://reviews.freebsd.org/D59596
bhyve: Treat BAR registration failures as non-fatal
Some guest operating systems (at least 9front) will leave device I/O
space decoding enabled while probing BAR sizes. In this case, a
sufficiently large 32-bit BAR can overlap with the HPET MMIO region
fixed at 0xfed00000. This results in an assertion failure in
modify_bar_registration(), even though the collision is transient, i.e.,
the guest will promptly map the BAR elsewhere.
Tolerate such overlaps. Keep track of a BAR's registration state and
make sure that modify_bar_registration() doesn't try to unregister an
I/O space if registration failed.
This fixes a problem where a 32MB framebuffer ends up overlapping with
the HPET MMIO region, causing some guests to crash with an assertion
failure when probing BARs during boot.
Approved by: re (cperciva)
PR: 290098
[7 lines not shown]
inotify: Open target the directory when adding a watch
When an application uses inotify to watch a directory,
vn_inotify_add_watch() reads the directory entries and does a name
lookup so as to induce the filesystem to create namecache entries.
Some filesystems expect the directory to be opened before VOP_READDIR
can be called, so do that.
Approved by: re (cperciva)
PR: 299239
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D60782
(cherry picked from commit de80428118101624aaeaae02d59665d1027ff10e)
(cherry picked from commit d4f4bd11adf266b926400b4725682d39187a489d)
camcontrol: Don't close the CAM device in nvme_get_data()
nvme_get_data() closed the supplied CAM device on every error
path, but its callers either pass the device that main() opened
and closes, or close the device themselves, so an error resulted
in a double cam_close_device() and a double free. Move the error
path close into print_dev_nvme(), the one caller that opens its
own device, and leave the device alone in nvme_get_data().
This predates the recent camcontrol NVMe additions, but they added
more callers.
Reported by: llm-postcr
Fixes: 6ee13c54dad0
MFC after: 1 week
Sponsored by: Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
nvme: Restore the host memory buffer size calculation
When the nvme_ctrlr_cmd_set_feature() call in
nvme_ctrlr_hmb_enable() was rewritten for the widened Set Features
API, the HSIZE calculation reverted to dividing by a hard coded
4096 instead of the controller page size, undoing commit
3740a8db13ba. The Host Memory Buffer Size field is in units of
the current memory page size (CC.MPS), so the wrong size would be
programmed on controllers configured with a page size other than
4KB.
Reported by: llm-postcr
Fixes: 7a9e4375316b
MFC after: 1 week
Sponsored by: Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
nvme: Fix the data length in the Reservation Report command builder
nvme_ns_resv_report_cmd() put its length argument, which callers
supply in bytes, directly into cdw10. The NUMD field is a 0's
based count of dwords, so the command asked the controller to
transfer nearly four times the size of the supplied data buffer.
In practice controllers limit the transfer to the length described
by the PRP entries, which is why this worked in testing, but the
command was incorrect.
Convert the byte count to a 0's based dword count in the builder.
Reported by: llm-postcr
Fixes: 7a9e4375316b
MFC after: 1 week
Sponsored by: Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
camcontrol: Fix swapped protection information defaults in nvformat
When no -p or -l arguments are given, the nvformat subcommand fills
in the protection information type and location from the
namespace's current settings. The two were swapped: pi was taken
from the DPS metadata location bit and pil from the protection
information type field. Formatting a namespace with protection
information enabled would therefore silently change its PI
settings, and before the Format NVM command builder masked its
fields, a namespace with PI type 2 enabled would set bit 9 of
cdw10, turning the format into a user data erase.
Reported by: llm-postcr
Fixes: 80f090111ae4
MFC after: 1 week
Sponsored by: Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
camcontrol: Fix extended host identifier retrieval
The Get Features command for the host identifier always requested
the 64-bit form (cdw11 EXHID=0), but the decoding logic sized the
identifier from the controller's CTRATT extended host identifier
capability bit, or always treated it as 128 bits when -U was
given. On a controller supporting the extended host identifier,
the printed value did not match what was requested from the
controller.
Fetch the controller data before issuing the command, request the
extended form when the controller supports it, and decode the form
that was requested. Reject -U when the controller only supports
64-bit host identifiers, since an 8 byte value cannot be shown as
a UUID.
sys/cam/nvme/nvme_all.c,
sys/cam/nvme/nvme_all.h:
Add an exhid argument to nvme_get_feature_hostid(),
[17 lines not shown]
camcontrol: Require a reservation type for reserve, preempt and release
res_type was initialized to 0, but the checks that enforce the -T
argument for the reserve, preempt and release reservation actions
compare it against -1, so they could never fire and camcontrol
silently sent a reservation type of 0, which is invalid.
Initialize res_type to -1 so the checks work, and default the
reservation type to 0 for the release action's clear variant,
which does not take -T and ignores the field.
Reported by: llm-postcr
Fixes: ba75cf05727e
MFC after: 1 week
Sponsored by: Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
nvme: Byte-swap the nsid in the Get/Set Features command builders
nvme_admin_get_feature_cmd() and nvme_admin_set_feature_cmd() stored
the namespace ID in the command without converting it to little
endian, unlike the other command building functions. Any caller
passing a non-zero namespace ID would send the wrong namespace ID on
big endian machines.
Reported by: llm-postcr
Fixes: 7a9e4375316b
MFC after: 1 week
Sponsored by: Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
nvme: Mask the fields in the Format NVM command builder
nvme_admin_format_cmd() did not mask any of the fields it composes
into cdw10, so an out of range value in one field would corrupt
neighboring fields. In particular, an LBA format index greater
than 15 would bleed into the metadata settings and protection
information fields. It also had no support for LBA format indexes
above 15, which NVMe 2.0 encodes via the separate LBAFU field.
Mask all of the fields, and encode bits 5:4 of the LBA format index
in the LBAFU field (cdw10 bits 13:12).
Also reject out of range LBA format indexes in camcontrol's
nvformat global (-G) mode, which has no namespace data to validate
against. The per-namespace mode already validates the index
against NLBAF.
sys/dev/nvme/nvme.h:
Mask the SES, PIL, PI, MSET and LBAF fields in
[12 lines not shown]
asmc: Use c99 initializers with for-loop counters to improve scoping
declared loop indices in the for statement
Index types are unchanged.
No functional change.
MFC After: 1 Week
Approved-by: ngie (co-mentor)
Reviewed by: ngie, imp
Differential Revision: https://reviews.freebsd.org/D61301
asmc: split the sysctl layer into asmcsysctl.c
Moved the dev.asmc.N tree out of asmc.c
No functional change
MFC After: 1 Week
Approved-by: ngie (co-mentor)
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61300
asmc: split the PIO backend into asmcpio.c
Moved the inline PIO transactions out of the key transport routines,
which now only dispatch on sc_is_mmio, matching asmcmmio.c. getbyindex and
getinfo stay fused: PIO needs both halves under one hold of sc_mtx.
No functional change.
MFC After: 1 Week
Approved-by: ngie (co-mentor)
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61296
asmc: split the debug key access into asmc_debug.c
Move the ASMC_DEBUG code out of asmc.c into a file compiled only when the
option is set, gated in files.amd64 the way acpi_debug gates the ACPICA
debugger sources. The module Makefile writes the define into opt_asmc.h so
every translation unit sees it; the old CFLAGS.asmc.c form covered one.
No functional change.
MFC After: 1 Week
Approved-by: ngie (co-mentor)
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61294
krb5: Don't include libsys in LIBADD
This has the curious effect of placing libsys before libc in the link
order even though libc links against libsys. While this happens to
work currently, it is fragile and fails to link properly in some edge
cases.
Sponsored by: AFRL, DARPA
Differential Revision: https://reviews.freebsd.org/D60724
.github: Update actions version to 7
version 4 raises warnings when run as the runners force it to use Node
24 instead of Node 20. version 5 defaults to Node 24, but version 7
is the current version.
Reviewed by: emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/2477
arm64: Rename the user_regs struct and array
In preparation for storing a non-user register rename the struct so and
array so they are more obviously for sanitized registers.
While here switch to a flag field and add a flag to record if the
register is for userspace or just the kernel and check for this when
reading the value for userspace.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D60742
arm64 pmap: combine L3C accessed bits in pmap_mincore()
The accessed bit may be set in only some of an L3C superpage's L3
PTEs. However, when pmap_mincore() found an L3C mapping, it reported
the accessed state of the specified L3 PTE only, so mincore(2) could
fail to report MINCORE_REFERENCED for an L3C superpage that had been
accessed. When the accessed bit is not set in the specified entry, use
pmap_load_l3c() to combine the accessed bits from all of the L3C
superpage's L3 PTEs.
Found by: Claude Code (Opus 5.5)
MFC after: 1 week