FreeBSD/src 813eb5asys/kern subr_devstat.c

devstat: Fix a kernel stack disclosure

The 16-byte "device_name" field was not zero-filled, so could contain
uninitialized stack data.  Zero the whole struct, as that's the
prevailing pattern for this kind of conversion code, and it's more
robust in the face of future revisions to struct devstat.

Approved by:    re (cperciva)
Reviewed by:    olce, kib
Reported by:    Reo Shiseki
Fixes:          a11d132f6c62 ("devstat: Provide 32-bit compatibility")
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D59309

(cherry picked from commit 7cb1a76f88158fb690418336b736e66c238cd4f7)
(cherry picked from commit 6e94e0734b9d3036df8c7d94d827f8eb1119905b)
DeltaFile
+1-0sys/kern/subr_devstat.c
+1-01 files

FreeBSD/src 48efb6clib/geom/zoned gzoned.8 geom_zoned.c, sys/geom/zoned g_zoned.h g_zoned.c

gzoned: Introduce Zoned Storage emulator

gzoned(8) is a new GEOM class that exposes a host-managed zoned device
(similar to ZAC/ZBC drives) on top of regular, non-zoned providers.

The created medium is sliced into equally sized zones, by default
sequential-write-required.  Such zones can be turned into conventional
zones if desired.  The zoned drive's state and configuration is
persistent through metadata at the tail of the backing provider, meaning
the zoned device gets recreated at the provider retaste.  Zone state
changes only mark the table dirty with BIO_FLUSH committing it,
mirroring drives whose zone state is volatile until a cache flush.

The new class tries to emulate real zoned drives by incorporating
per-zone write pointers and support for BIO_ZONE management commands.
Fault emulation through zone conditions (RWP recommended, offline, R/O),
URSWRZ bit toggling and concurrent open zone limits are additional
features useful for testing.


    [11 lines not shown]
DeltaFile
+1,819-0sys/geom/zoned/g_zoned.c
+1,056-0tests/sys/geom/class/zoned/zoned_test.sh
+291-0sys/geom/zoned/g_zoned.h
+289-0lib/geom/zoned/geom_zoned.c
+260-0lib/geom/zoned/gzoned.8
+221-0usr.sbin/zonectl/tests/zonectl_test.sh
+3,936-020 files not shown
+4,142-1526 files

FreeBSD/src 22e27e3tests/sys/pmc Makefile

pmc_exterr_test: add MACHINE_ARCH check

The tests manipulate MD structure fields directly. Build these tests for
amd64 only.

Fixes:  e555692d1bb ("hwpmc: Add ATF regression tests for hwpmc EXTERROR diagnostics")
DeltaFile
+2-0tests/sys/pmc/Makefile
+2-01 files

FreeBSD/src e555692tests/sys/pmc Makefile pmc_exterr_test.c

hwpmc: Add ATF regression tests for hwpmc EXTERROR diagnostics

Root-only ATF program hitting negative allocate/attach/read-write paths
and asserting the exterr(3) text. AMD/IBS cases skip without the PMC
class; program skips without hwpmc.

Additional changes by mhorne@:
- Move and rename to the established test directory tests/sys/pmc
- Remove broken test amd_missing_pmu_flag; fixed by recent change
  6c4d9b9af1a3
- Add ATF_REQUIRE_FEATURE("exterr_strings") to skip the tests on kernels
  compiled without the strings
- Remove arch-conditional compilation; tests are properly gated by PMC
  class check
- Fix copyright formatting

Reviewed by:    Ali Mashtizadeh <ali at mashtizadeh.com>
Signed-off-by:  Andre Silva <andasilv at amd.com>
Co-authored-by: mhorne

    [2 lines not shown]
DeltaFile
+449-0tests/sys/pmc/pmc_exterr_test.c
+5-0tests/sys/pmc/Makefile
+454-02 files

FreeBSD/src 10ebbebtests/sys/kern subr_physmem_test.c

subr_physmem_test: add tests for two edge-cases

Help validate my assertion that "physmem will never report empty
ranges". Part of this is covered by the existing tests, which check the
merging of adjacent/overlapping regions. The other part is to ensure
that addition of zero-sized ranges is ignored.

The physmem implementation also includes logic to ignore the first
physical page of memory (physical addresses 0 to PAGE_SIZE-1). Add a
second test case for this.

Reviewed by:    markj
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D45914

(cherry picked from commit 1b5ec2e466ee100161017ae2618f91829310f1d6)
DeltaFile
+43-0tests/sys/kern/subr_physmem_test.c
+43-01 files

FreeBSD/src 5ed8358sys/geom/eli g_eli.c

g_eli: better handling of absent/disabled CPUs

Checking hlt_cpus_mask is a no-op, and the mask will be removed in the
next commit. However, we can use the more recent CPU_ABSENT() macro to
check the status.

Reviewed by:    olce
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D58157

(cherry picked from commit 63d4f044225d1bb86767759b18c0ae63b25a9c03)
DeltaFile
+1-11sys/geom/eli/g_eli.c
+1-111 files

FreeBSD/src ce2e423sys/dev/hwt hwt_ioctl.c hwt_vm.c, sys/kern subr_smp.c kern_pmc.c

smp: remove unused hlt_cpus_mask

It is a relic, apparently once populated by a machdep.hlt_cpus sysctl.
The sysctl was removed, and ULE has never honored this mask. It is now
safe to remove.

Remove the mask, and its few remaining references in: sched_4bsd(4),
hwpmc(4), and hwt(4).

Reviewed by:    olce, kib
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D58158

(cherry picked from commit df0aca0d73064a1a199dbae3857012951f96cf2d)
DeltaFile
+0-17sys/kern/sched_4bsd.c
+0-6sys/dev/hwt/hwt_vm.c
+0-5sys/dev/hwt/hwt_ioctl.c
+1-2sys/kern/kern_pmc.c
+0-1sys/sys/smp.h
+0-1sys/kern/subr_smp.c
+1-326 files

FreeBSD/src 64dd924sys/kern sched_shim.c sched_ule.c, sys/sys sched.h

sched/lapic: remove sched_do_timer_accounting()

The check is always true, especially after the removal of hlt_cpus_mask
from sched_4bsd.

Reviewed by:    olce, kib
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D58159

(cherry picked from commit 01f165c68103df22cebe26d410c1d4a0e5fae377)
DeltaFile
+0-7sys/kern/sched_ule.c
+0-7sys/kern/sched_4bsd.c
+0-3sys/x86/x86/local_apic.c
+0-3sys/sys/sched.h
+0-1sys/kern/sched_shim.c
+0-215 files

FreeBSD/src 261d589sys/geom/eli g_eli.c

g_eli: disambiguate CPU-bound worker creation

This makes an effort to clarify and correct the intent of the code,
which is to either:

 1. Create one software crypto worker thread for each CPU, to be pinned
    later
 2. Create the number of threads requested by the kern.geom.eli.threads
    tunable

This is as described in geli(8).

If a CPU were somehow* absent, it should be skipped, but not in the
second case when creating a set number of threads.

To achieve this cleanly and correctly:
 - split worker creation logic into a helper function
 - keep the loops separate
 - debug message for absent CPUs is dropped

    [17 lines not shown]
DeltaFile
+72-42sys/geom/eli/g_eli.c
+72-421 files

FreeBSD/src 3ef9ef5sys/sys libkern.h

libkern.h: remove HAVE_INLINE_* macros

The final consumer of this was OpenZFS, fixed in ffaea0831973 (thanks
mav@). That change has been present in all active OpenZFS release
branches for at least 6 months. These can finally be retired.

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

(cherry picked from commit 76f14217f6051df414e435c3388d3f4bb388cc22)
DeltaFile
+0-11sys/sys/libkern.h
+0-111 files

FreeBSD/src 24db983sys/riscv/starfive jh7110_gpio.c

jh7110_gpio: remove unneeded cleanup

Any failure within bus_alloc_resources() will call bus_release_resources();
thus the call is redundant here.

MFC after:      3 days
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 2af2ec524957754ff356daea5fa7ee4990c1c3ea)
DeltaFile
+0-1sys/riscv/starfive/jh7110_gpio.c
+0-11 files

FreeBSD/src a722716sys/riscv/starfive jh7110_gpio.c

jh7110_gpio: driver enhancements

Fix reporting of state and capabilities by the gpioctl command.

Support selection of pull-up and pull-down resistors.

Support second gpio device (AON - always on power domain) to allow
attaching gpioled device to visionfive2 status LED or querying boot
selection switches.

Reviewed by:    mhorne
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D58693

(cherry picked from commit 3d20f8a022435e8ed37e2c0ce8f66d4c1203ec1c)
DeltaFile
+111-36sys/riscv/starfive/jh7110_gpio.c
+111-361 files

FreeBSD/src 66fb43csys/riscv/starfive jh7110_gpio.c

jh7110_gpio: style

- Fix whitespace
- Replace JH7110_GPIO_READ with RD4 (and WR4)
- Trim headers
- Explicit conditional checks
- Use correct method typedefs

MFC after:      3 days
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 72216145d3e4e2460d48d279a339072e0be2cc74)
DeltaFile
+49-52sys/riscv/starfive/jh7110_gpio.c
+49-521 files

FreeBSD/src 55e62f1release/riscv GENERICSD.conf

release/riscv: tweak GENERICSD partition placement

Increase EFI partition size to begin rootfs at 64mb. I believe this was
my original intention. I have a microSD card with 8mb block size which
emits an advisory in verbose dmesg about the misaligned partition.

MFC after:      1 week
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 49749f21284d817b5431255106c8c2da3afa9965)
DeltaFile
+1-1release/riscv/GENERICSD.conf
+1-11 files

FreeBSD/src 4315454share/man/man9 cdefs.9

cdefs(9): document __nonstring

Reviewed by:    emaste
Discussed with: imp
Fixes:  802c6d5d61d1 ("cdefs.h: Introduce __nonstring attribute")
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D58804

(cherry picked from commit 2ea905c875b6c89117023e240c3158f2da79bc52)
DeltaFile
+4-1share/man/man9/cdefs.9
+4-11 files

FreeBSD/src 84b241fsys/dev/hwpmc hwpmc_mod.c

hwpmc: fix false callchain assertion on the PMC_UR ring

pmc_capture_user_callchain() asserts that TDP_CALLCHAIN is set on the
current thread, but PMC_UR samples never set that flag -- only PMC_HR
and PMC_SR do. That makes the assertion always fail for PMC_UR,
panicking INVARIANTS kernels as soon as pmcstat -U is used.

Skip the assertion for PMC_UR. No functional change on kernels built
without INVARIANTS.

Signed-off-by:  Andre Silva <andasilv at amd.com>
Reviewed by:    mhorne
MFC after:      1 week
Sponsored by:   AMD
Differential Revision:  https://reviews.freebsd.org/D58572

(cherry picked from commit af3929c5152b47278c0b6ea66efbb782b9637495)
DeltaFile
+1-1sys/dev/hwpmc/hwpmc_mod.c
+1-11 files

FreeBSD/src 92cf9e3sys/dev/hwpmc hwpmc_mod.c

hwpmc: fix false runcount assertion in user callchain capture

pmc_capture_user_callchain() checks a PMC's runcount before walking
the user stack, but reads it without holding the spinlock that
protects it. hardclock() can run on the same CPU during the capture
and drop the runcount to zero in between, tripping the assertion and
panicking INVARIANTS kernels under load.

Move the check inside the existing spinlock, right where the code
already confirms the sample is still valid. No functional change on
kernels built without INVARIANTS.

Signed-off-by:  Andre Silva <andasilv at amd.com>
Reviewed by:    mhorne
MFC after:      1 week
Sponsored by:   AMD
Differential Revision:  https://reviews.freebsd.org/D58571

(cherry picked from commit 66118c3f1011d7852bce8b659899179a83781897)
DeltaFile
+4-3sys/dev/hwpmc/hwpmc_mod.c
+4-31 files

FreeBSD/src 83b88eashare/man/man9 vfs_unmountall.9

vfs_unmountall.9: Fix an outdated .Xr to boot(9)

boot.9 was moved to kern_reboot.9, but this reference was not changed
appropriately.

PR:             286013
Reviewed by:    mhorne, kib, emaste
Fixes:  800e74955d4e ("boot(9): update to match reality")
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D58350

(cherry picked from commit 5b7d6a128bef464e7fd331d172e4cf25a5d122c3)
DeltaFile
+1-1share/man/man9/vfs_unmountall.9
+1-11 files

FreeBSD/src f19f446lib/libpmc libpmc_pmu_util.c, lib/libpmc/pmu-events jevents.c

pmc: Add support for AMD UMC counters

This change adds support for AMD's UMC performance counters.  It is a
bit more complicated than existing counters because the enable bit has
moved.  This supports Zen 4 through most Zen 6 chips as UMC counters are
per-node, where a node does not necessarily translate to a NUMA domain.
A few follow up changes to PMC will address this limitation.

Reviewed by:    mhorne
Sponsored by:   Netflix
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2368
DeltaFile
+73-19sys/dev/hwpmc/hwpmc_amd.c
+29-2sys/dev/hwpmc/hwpmc_amd.h
+7-0lib/libpmc/libpmc_pmu_util.c
+3-1lib/libpmc/pmu-events/jevents.c
+112-224 files

FreeBSD/src 125ec0esys/dev/nvme nvme_ns.c

nvme: limit namespace character-device I/O size

The namespace character device does not initialize si_iosize_max, so
physio falls back to DFLTPHYS and can produce a bio larger than the
qpair payload DMA tag on a controller whose maximum transfer size is
below 64KB. Such a bio fails DMA mapping and is never submitted.

Approved by: ngie (co-mentor)
MFC after:      1 week

Reviewed by:    ngie, imp
Differential Revision:  https://reviews.freebsd.org/D59152
DeltaFile
+8-1sys/dev/nvme/nvme_ns.c
+8-11 files

FreeBSD/src b90c2b1sys/dev/nvme nvme_qpair.c

nvme: complete requests when payload DMA mapping fails

bus_dmamap_load_mem() reports most mapping failures, including EFBIG,
only through its callback and then returns zero. nvme_payload_map()
logged the error without telling the submission path, so the tracker
stayed on the outstanding list with no command submitted and no
timeout armed, stalling all later I/O on the queue behind it.

Approved by: ngie (co-mentor)
MFC after:      1 week

Reviewed by:    ngie, imp
Differential Revision:  https://reviews.freebsd.org/D59151
DeltaFile
+11-26sys/dev/nvme/nvme_qpair.c
+11-261 files

FreeBSD/src 3e6bc5csys/arm/arm exception.S trap-v6.c

sys/arm: Fix DTrace trap hook

Move the dtrace_trap hook at the start of the abort handler to exit
early when a trap is handled by DTrace.

Fix the type argument to be the actual fault type instead of the value
of the FAR. The latter will need to be added to the trapframe, until
then DTrace will report unmapped addresses as the null address.

Correct the comment of the PUSHFRAMEINSVC assembler macro to reflect
that coming from SVC32 mode is expected for DTrace traps.

PR:             298064
MFC after:      1 month
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D59279
DeltaFile
+8-7sys/arm/arm/trap-v6.c
+3-3sys/arm/arm/exception.S
+11-102 files

FreeBSD/src 8304e68share/man/man9 Makefile vm_page_free.9

vm_page_free.9: Remove references to vm_page_try_to_free()

That function was removed in commit 98549e2dc6fb0.

PR:     288081
Fixes:  98549e2dc6fb ("Centralize the logic in vfs_vmio_unwire() and sendfile_free_page().")
DeltaFile
+1-13share/man/man9/vm_page_free.9
+1-2share/man/man9/Makefile
+2-152 files

FreeBSD/src c874d31sys/cddl/dev/dtrace/arm dtrace_asm.S

dtrace/arm: Fix and de-pessimize dtrace_copy

Use an unprivileged load to access user memory from dtrace_copy, which
is running in SVC mode.

Abort the loop if the load is trapped, as it is useless, hence
wasteful, to keep faulting on successive addresses. I believe that
this de-pessimization should also be done on aarch64 and riscv.

PR:             298064
MFC after:      1 month
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D59280
DeltaFile
+6-5sys/cddl/dev/dtrace/arm/dtrace_asm.S
+6-51 files

FreeBSD/src 00678f5sys/cddl/dev/dtrace/arm dtrace_subr.c

dtrace/arm: Really trap translation faults

Fix the constant case label to properly handle translation faults
caused by DTrace probes. Alignment errors are not expected to be
generated, so stop handling them.

While at it, correct an amd64-specific comment and add a comment
regarding the missing faulting address which could be addressed by a
later improvement.

PR:             298064
MFC after:      1 month
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D59281
DeltaFile
+6-2sys/cddl/dev/dtrace/arm/dtrace_subr.c
+6-21 files

FreeBSD/src a5bb0fdsys/net iflib.c

iflib: update rs_pending based on descriptors consumed by isc_txd_encap

The new watchdog code triggers spurious watchdog resets on
NICs doing KTLS offload.  Fix this by using the actual segments
consumed by the NIC driver's isc_txd_encap.

The issue is that rs_pending is updated using an estimate of
the  descriptors that will be used for the current packet,
based on what bus_dma produced. However, NICs which support
ktls offload may do extra  DMAs (and consume extra
descriptors) to derive crypto state when re-transmitting
TLS segments.  This is the reason for allowing drivers to control
ift_pad.  When this happens, the estimated rs_pending may undercount.
This may also happen if NIC drivers consume extra descriptors for
other reasons. (eg, hw errata handling on e1000)

Reviewed by: kbowling
Differential Revision:  https://reviews.freebsd.org/D59321
Sponsored-by: Netflix
DeltaFile
+7-5sys/net/iflib.c
+7-51 files

FreeBSD/src 70b70acsbin/pfctl pfctl.c, tests/sys/netpfil/pf anchor.sh

pfctl: fix printing of wildcard anchors

PR:             297839
MFC after:      1 week
Obtained from:  OpenBSD, henning <henning at openbsd.org>, 5b6657d4d8
Sponsored by:   Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5de5140f06959f2724c626c7fab3e1c9187beefb)
DeltaFile
+30-0tests/sys/netpfil/pf/anchor.sh
+6-4sbin/pfctl/pfctl.c
+36-42 files

FreeBSD/src 678f107sbin/pfctl pfctl.c, tests/sys/netpfil/pf anchor.sh

pfctl: fix printing of wildcard anchors

PR:             297839
MFC after:      1 week
Obtained from:  OpenBSD, henning <henning at openbsd.org>, 5b6657d4d8
Sponsored by:   Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5de5140f06959f2724c626c7fab3e1c9187beefb)
DeltaFile
+30-0tests/sys/netpfil/pf/anchor.sh
+6-4sbin/pfctl/pfctl.c
+36-42 files

FreeBSD/src 0abd71fsbin/hastd ebuf.c

hastd: Clean up the ebuf code

Missed an instance of bcopy().

Fixes:          48c0fc0171a1 ("hastd: Clean up the ebuf code")
DeltaFile
+1-1sbin/hastd/ebuf.c
+1-11 files

FreeBSD/src 4d83686sbin/hastd hast_proto.c

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.

PR:             298085
MFC after:      3 days
Reviewed by:    kevans, gjb
Differential Revision:  https://reviews.freebsd.org/D59306

(cherry picked from commit 8646d65b45339642d4aab1de35a2bc79fc45f09e)
DeltaFile
+8-6sbin/hastd/hast_proto.c
+8-61 files