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)
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]
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]
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)
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)
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)
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)
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]
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)
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)
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)
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)
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)
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)
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
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
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
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
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().")
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
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
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
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)