Implement vmemdup_{array}_user
This is what FreeBSD now does for memdup_user and memdup_array_user
(which is wrong for memdup, but correct for vmemdup).
The amdgpu DRM driver started this in Linux ~6.12.86+
Reviewed by: wulf
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D57444
(cherry picked from commit 302c6d25da6907ec762ff8937fa86d380743b000)
linuxkpi: Define `DEFINE_CLASS()` and `CLASS()`
`DEFINE_CLASS()` is in fact named `LINUXKPI_DEFINE_CLASS()` because it
conflicts with `DEFINE_CLASS()` defined in <sys/kobj.h>.
This macro defines a type and a pair of constructor/destructor
functions.
They are to be used by `CLASS()`: this one declares a variable,
initialise it with the constructor and set the `__cleanup()` attribute
to call the destructor once the variable goes out of scope.
The DRM drivers generic code started to use `CLASS()` in Linux 6.13. It
requires the `fd` class to be defined in <linux/file.h>.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57583
(cherry picked from commit f2a2e02ae54b836d1e23648756a050406f65111e)
amd64: add userspace control for disabling splitlocks
Thread can control it with sysarch(I386_SET_SPLITLOCK). The global
default is set with hw.splitlock_force.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D59815
amd64: use WRMSRNS immediate form to update splitlock control, when available
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D59815
amd64: support for tracking per-thread 'disable splitlocks' state
If hw supports it, on atomic operation that requires exclusive ownership
of more than one cache line, #AC is generated.
The state is maintained as the arch-private TDF_MD_SPLITLOCK_AC flag.
The state is inherited on thread creation from the thread spawning the
new one. It is cleared on exec.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D59815
amd64: handle #AC in kernel mode
Recover from it if PCB_ONFAULT handler is provided.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D59815
x86: add definitions for the CORE_CAP and MEMORY_CTL MSRs
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D59815
amd64: add md thread flags word
Use a hole in struct mdthread.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D59815
contrib/atf: upgrade to 0.26
This new version gets contrib/atf in line with the published version of
the package up on [GitHub][github].
Please note that this release is a major update: it contains several
bugfixes and feature enhancements. Most were already present in the
FreeBSD src repo, but there were a large number of changes made in
addition to what was already present.
MFC after: 1 month
Merge commit '9c78088348bcf1059d82a62bb57a0746309d4312'
Conflicts:
contrib/atf/.cirrus.yml
contrib/atf/Makefile.am
contrib/atf/Makefile.in
contrib/atf/aclocal.m4
[47 lines not shown]
hwpmc: fix leak of IBS per-CPU array on unload
pmc_ibs_initialize() allocates the ibs_pcpu[] pointer array, and
pmc_ibs_finalize() exists to free it, but pmc_ibs_finalize() is
never called. Every hwpmc unload on a CPU with IBS therefore leaks
one pmc_cpu_max()-sized pointer array.
Call pmc_ibs_finalize() from pmc_amd_finalize(), alongside the RAPL,
TSC and perf classes. IBS is only initialized on CPUs that support
it, so make pmc_ibs_finalize() return early when ibs_pcpu is NULL,
making it safe to call when the class was skipped at initialize
time, as pmc_rapl_finalize() already is.
Tested on an AMD Ryzen 5 5600X (Zen 3, 12 threads) with INVARIANTS.
Before the change, each kldload/kldunload cycle leaked one 96-byte
M_PMC allocation, and DTrace showed the ibs_pcpu[] allocation from
pmc_ibs_initialize() as the only one never freed. After the change,
50 load/unload cycles leave M_PMC InUse and MemUse unchanged, and
every allocation made at load is freed at unload.
[5 lines not shown]
tarfs_test: split large file test into independent cases
This avoids globally set timeouts for the group of
tarfs_large tests on slower emulated architectures.
While here, lower each testcase's timeout to reflect
the reduction of work. On QEMU aarch64, the largest case
runs in ~500s on a modern desktop, so double that for a
conservative estimate.
Discussed with: des
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D59033
jh7110_temp: CPU temperature sensor for JH7110
This patch adds a driver for the CPU temperature sensor on the jh7110
SoC.
The calibration numbers come from the OpenBSD driver but are reworked to
produce a result in K rather than C.
The temperature is exposed as a sysctl, dev.jh7110_temp.0.temperature
but I have also exposed it as dev.cpu.0.temperature because that's where
you find it on a RaspberryPi and amdtemp(4), so it's a lot more obvious.
(mhorne: Added 'starfive,jh7100-temp' compatible.)
Reviewed by: mhorne, bnovkov
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D59478
ntb_tool: Bound memory window option strings
parse_mw_buf() copies option names from privileged sysctl input into
eight-byte stack buffers. Unbounded %s conversions permit option tokens
longer than seven bytes to write past those buffers before the parser
validates them.
Limit each conversion to seven characters, leaving space for the
terminating NUL.
Signed-off-by: Yudi Yang <yudi.yang at rice.edu>
Fixes: 96f556f5044a ("NTB Tool: Test driver for NTB hardware drivers.")
Reviewed by: markj
MFC after: 1 week
(cherry picked from commit 602d1b994a22949fff7e4a87cb6e54d6fbad13b6)
amd64/pmap: Return la57 in amd nested page
AMD doesn't encode page depth in eptp. As a result, the page level is
decided by the host la57 value. Without this, it uses 4 level page and
therefore cause machine enable la57 have garbage page translation.
PR: 291768
Reviewed by: kib
Tested by: Antranig Vartanian <antranigv at freebsd.am>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D57978
(cherry picked from commit ef26f64c11220ea303de16d088c585f9d2908b0f)
buf: Avoid calling bufdomain() on newly initialized bufs
bufinit() inserts newly initialized bufs into the QUEUE_EMPTY queue, at
which point they haven't yet been assigned a domain. Thus, bufdomain()
returns &bdomain[-1], which trips the array-bounds sanitizer.
This is harmless since we don't use the result in that case, but let's
avoid the invalid access to begin with. This is sufficient to let an
amd64 kernel boot to a login prompt with -fsanitize=array-bounds
configured.
Reported by: Andrew Griffiths <andrew at calif.io>
Reviewed by: rlibby, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D59381
(cherry picked from commit e1d903bbfaf91060c43209b35b78a9992fbffe5e)
ipfw: fix gcc warning
We use first loop only for possible needed realloc, so it is not
required to restrict end condition.
Also check realloc() return value before accessing.
This is direct commit to stable/14.
Reported by: dim
Differential Revision: https://reviews.freebsd.org/D56616
atf: import atf-0.26
This change imports 0.26 release content from [upstream][1].
The atf-0.26 artifact was been verified by [SHA256 checksum][2].
This update pulls in a large number of memory management fixes, polished upstreamed
content from contrib/atf in FreeBSD (proper), etc.
Please note that this new version requires a C++-20 compatible toolchain
to build.
More information about the release (from a high level) can be found in
the [release notes][3].
Updated via [`update_atf.sh`][4] using `update_atf.sh 0.26 atf-0.26`.
1: https://github.com/freebsd/atf/releases/download/atf-0.26/atf-0.26.tar.gz
2: https://github.com/freebsd/atf/releases/download/atf-0.26/atf-0.26.tar.gz.sha256
[2 lines not shown]
tests/sys/kern/unix_stream: fix bad assertion
kqueue returns a value != -1 on error. Test for that instead of any
non-zero value to confirm that success was achieved when calling
`kqueue`.
This issue exists with ATF 0.22+ [1].
MFC after: 2 weeks
Reported by: clang (-Wparenthesis)
[1]: https://github.com/freebsd/atf/pull/72
(cherry picked from commit 4881c7a650571eeb4cd89b5af4c1d3e922a67706)