FreeBSD/src 6d9f435sys/dev/hwpmc hwpmc_amd.c hwpmc_ibs.c

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]
DeltaFile
+4-0sys/dev/hwpmc/hwpmc_ibs.c
+2-0sys/dev/hwpmc/hwpmc_amd.c
+6-02 files

FreeBSD/src 34c4012tests/sys/fs/tarfs tarfs_test.sh

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
DeltaFile
+78-19tests/sys/fs/tarfs/tarfs_test.sh
+78-191 files

FreeBSD/src fa28edesys/dev/clk/starfive jh7110_clk_sys.c, sys/riscv/starfive files.starfive jh7110_temp.c

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
DeltaFile
+269-0sys/riscv/starfive/jh7110_temp.c
+16-0sys/dev/clk/starfive/jh7110_clk_sys.c
+1-0sys/riscv/starfive/files.starfive
+286-03 files

FreeBSD/src ad0a85f. Makefile.in, lib internal.h xmltok.c

Vendor import of expat 2.8.5
DeltaFile
+349-5tests/basic_tests.c
+100-123lib/xmlparse.c
+139-64lib/xmltok.c
+67-100lib/internal.h
+105-56Makefile.in
+157-0tests/hash_tests.c
+917-34852 files not shown
+1,609-85458 files

FreeBSD/src 82007cesys/dev/ntb/test ntb_tool.c

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)
DeltaFile
+1-1sys/dev/ntb/test/ntb_tool.c
+1-11 files

FreeBSD/src 9d9063esys/amd64/amd64 pmap.c

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)
DeltaFile
+13-1sys/amd64/amd64/pmap.c
+13-11 files

FreeBSD/src 65a5b32sys/kern vfs_bio.c

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)
DeltaFile
+4-4sys/kern/vfs_bio.c
+4-41 files

FreeBSD/src 36f268eshare/man/man4 dtrace_pid.4

dtrace_pid.4: Add example "Listing Program's Function Entries"

Reviewed by:    bcr
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D57515

(cherry picked from commit 7008192726a30d2d5f8ed912554cc53d7bcf9fba)
DeltaFile
+22-2share/man/man4/dtrace_pid.4
+22-21 files

FreeBSD/src 9b4b68esbin/ipfw ipfw2.c

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
DeltaFile
+2-2sbin/ipfw/ipfw2.c
+2-21 files

FreeBSD/src 9c78088. README.md NEWS

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]
DeltaFile
+12-3NEWS
+1-1README.md
+13-42 files

FreeBSD/src 9def2eatests/sys/kern unix_stream.c

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)
DeltaFile
+2-1tests/sys/kern/unix_stream.c
+2-11 files

FreeBSD/src c68b38flib/libarchive/tests Makefile

lib/libarchive/tests/Makefile: minor fixes

- Remove trailing whitespace
- Fix typo with variable referenced adding sources for `test_fuzz`.

MFC after:      2 weeks

(cherry picked from commit edbb2e9d7a9aba7194dd0f37cede7aea51408f74)
DeltaFile
+18-17lib/libarchive/tests/Makefile
+18-171 files

FreeBSD/src 0e0a2d2tests/sys/sys bitstring_test.c

tests/sys/sys/bitstring_test: fix build with ATF 0.22+

Do not assign `b` in the `ATF_REQUIRE` macro. Set and test `b`
separately to avoid the issue cited by clang++/g++ after
implementing the change referenced in [1].

MFC after:      2 weeks
Reported by:    clang (-Wparenthesis)
Reference:      https://github.com/freebsd/atf/pull/72

(cherry picked from commit 4ae95fe823c0ec8b0b93ed27192bfc91058d9a6b)
DeltaFile
+2-1tests/sys/sys/bitstring_test.c
+2-11 files

FreeBSD/src d1fb660tests/sys/kern ktls_test.c

tests/sys/kern/ktls_test: fix -Wsign-compare issue

Cast the size_t quantity used in a comparison to off_t to mute a
`-Wsign-compare` complaint that now occurs after ATF 0.22 [1].

MFC after:      2 weeks
Reported by:    clang
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D59285
[1]: https://github.com/freebsd/atf/pull/72

(cherry picked from commit 505103215ee2e3e31d233b952633e5697ac5da5f)
DeltaFile
+1-1tests/sys/kern/ktls_test.c
+1-11 files

FreeBSD/src 97ff0d6lib/libc/tests/stdlib qsort_bench.c

Assign and test `malloc` result separately

The previous pattern is cited as an issue with ATF 0.22+ when using
clang/gcc after [1].

MFC after:      2 weeks
Reported by:    clang (-Wparenthesis)
Differential Revision:  https://reviews.freebsd.org/D59274

[1]: https://github.com/freebsd/atf/pull/72

(cherry picked from commit 2561c468c11309fbc0a097d3f4fcf0bd3bf28b8f)
DeltaFile
+1-1lib/libc/tests/stdlib/qsort_bench.c
+1-11 files

FreeBSD/src 5936c0atests/sys/kern Makefile

tty_pts: reduce/correct libatf-c linkage

ATF_TESTS_C automatically adds the appropriate library to LDADD --
there's no need to manually append the same library.

MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D59411

(cherry picked from commit 5b10c3c3e3d5125e09e35cd607d15a546d5ad581)
DeltaFile
+1-2tests/sys/kern/Makefile
+1-21 files

FreeBSD/src f3cdf3dlib/libc/tests/stdlib qsort_bench.c

Assign and test `malloc` result separately

The previous pattern is cited as an issue with ATF 0.22+ when using
clang/gcc after [1].

MFC after:      2 weeks
Reported by:    clang (-Wparenthesis)
Differential Revision:  https://reviews.freebsd.org/D59274

[1]: https://github.com/freebsd/atf/pull/72

(cherry picked from commit 2561c468c11309fbc0a097d3f4fcf0bd3bf28b8f)
DeltaFile
+1-1lib/libc/tests/stdlib/qsort_bench.c
+1-11 files

FreeBSD/src f9c5a73tests/sys/kern ktls_test.c

tests/sys/kern/ktls_test: fix -Wsign-compare issue

Cast the size_t quantity used in a comparison to off_t to mute a
`-Wsign-compare` complaint that now occurs after ATF 0.22 [1].

MFC after:      2 weeks
Reported by:    clang
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D59285
[1]: https://github.com/freebsd/atf/pull/72

(cherry picked from commit 505103215ee2e3e31d233b952633e5697ac5da5f)
DeltaFile
+1-1tests/sys/kern/ktls_test.c
+1-11 files

FreeBSD/src a8b30aflib/libarchive/tests Makefile

lib/libarchive/tests/Makefile: minor fixes

- Remove trailing whitespace
- Fix typo with variable referenced adding sources for `test_fuzz`.

MFC after:      2 weeks

(cherry picked from commit edbb2e9d7a9aba7194dd0f37cede7aea51408f74)
DeltaFile
+18-17lib/libarchive/tests/Makefile
+18-171 files

FreeBSD/src 56b9c37tests/sys/sys bitstring_test.c

tests/sys/sys/bitstring_test: fix build with ATF 0.22+

Do not assign `b` in the `ATF_REQUIRE` macro. Set and test `b`
separately to avoid the issue cited by clang++/g++ after
implementing the change referenced in [1].

MFC after:      2 weeks
Reported by:    clang (-Wparenthesis)
Reference:      https://github.com/freebsd/atf/pull/72

(cherry picked from commit 4ae95fe823c0ec8b0b93ed27192bfc91058d9a6b)
DeltaFile
+2-1tests/sys/sys/bitstring_test.c
+2-11 files

FreeBSD/src 343618ctests/sys/kern Makefile

tty_pts: reduce/correct libatf-c linkage

ATF_TESTS_C automatically adds the appropriate library to LDADD --
there's no need to manually append the same library.

MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D59411

(cherry picked from commit 5b10c3c3e3d5125e09e35cd607d15a546d5ad581)
DeltaFile
+1-2tests/sys/kern/Makefile
+1-21 files

FreeBSD/src 6f34450contrib/netbsd-tests/lib/libc/gen t_assert.c

[tests] lib/libc/gen:assert_test: skip tests when NDEBUG set

In the event that NDEBUG is specified in CFLAGS--which is most likely
triggered via `MK_ASSERT_DEBUG` == "no" -- all assert(3) statements are
optimized out by design. This breaks the assert(3) tests as they
specifically rely on assert(3) actually raising a `SIGABRT` instead of
quietly succeeding.

Skip both tests if `NDEBUG` is set. There's no sense running the
`assert(true)` test if the result could instead be a false positive.

MFC after:      2 weeks
DeltaFile
+20-0contrib/netbsd-tests/lib/libc/gen/t_assert.c
+20-01 files

FreeBSD/src 14b855dcontrib/mandoc st.c mdoc.7, lib/msun/man tanpi.3 sinpi.3

mandoc: Drop -ieee754-2008 abbreviation

Improve manpage compatability by dropping an abbreviation macro that
compiler upstreams do not want, causing manuals using it to render
incorrectly on other toolchains or operating systems. It was only used
in three manuals, which are amended in this commit.

Reviewed by:    fuz, markj
MFC after:      no, these did not MFC
Requested by:   Ingo Schwarze <schwarze at openbsd.org>
Fixes:          db3884b03989 ("contrib/mandoc: add -ieee754-2008")
Fixes:          63cd0841de76 ("document .St -ieee754-2008 in mdoc")
Differential Revision:  https://reviews.freebsd.org/D59880
DeltaFile
+0-5contrib/mandoc/mdoc.7
+1-1lib/msun/man/tanpi.3
+1-1lib/msun/man/sinpi.3
+1-1lib/msun/man/cospi.3
+0-1contrib/mandoc/st.c
+3-95 files

FreeBSD/src d90a75ashare/man/man5 src.conf.5

src.conf(5): regenerate after f6db138f97b7

MFC after:      2 weeks
MFC with:       f6db138f97b7 ("src.opts.mk: force the Dtrace tests ...")
DeltaFile
+5-1share/man/man5/src.conf.5
+5-11 files

FreeBSD/src df6131etools/build/mk OptionalObsoleteFiles.inc

Remove CDDL and ctfconvert tests when their controlling knobs are disabled

In the event someone specified MK_CDDL == no prior to this change, all
tests under `/usr/tests/cddl` would stick around after the change,
resulting in errors. Similarly, MK_DTRACE == no removed ctfconvert,
which the ctfconvert tests relied on (but remained around after the knob
was disabled).

Remove the tests under the respective blocks now so they don't linger
around on systems where these knobs are disabled, resulting in false
positives when running the complete test suite.

The ctfconvert tests weren't specifically put under
`${MK_DTRACE_TESTS}` == no because ctfconvert was bundled separately
from the upstream provided Dtrace test suite.

MFC after:      2 weeks
MFC with:       30c20ca26 ("Remove Dtrace/ZFS tests if their knobs are disabled")
DeltaFile
+22-0tools/build/mk/OptionalObsoleteFiles.inc
+22-01 files

FreeBSD/src f6db138share/mk src.opts.mk

src.opts.mk: force the Dtrace tests off if ${MK_DTRACE} == no

Prior to this change Dtrace's tests could be enabled even if
`${MK_DTRACE}` == no. Allowing this doesn't make sense so remove the
tests if `${MK_DTRACE}` is also disabled.

MFC after:      2 weeks
DeltaFile
+1-0share/mk/src.opts.mk
+1-01 files

FreeBSD/src 04fcf30sbin/ipfw dummynet.c

dummynet: do not overflow the points[ED_MAX_SAMPLES_NO] array

Otherwise, the following would segfault

dnctl pipe 1 config bw 1Mbit/s profile 1025points.txt

Found with:     Claude Code Sonnet 5
MFC after:      2 weeks
DeltaFile
+3-0sbin/ipfw/dummynet.c
+3-01 files

FreeBSD/src 30c20catools/build/mk OptionalObsoleteFiles.inc

Remove Dtrace/ZFS tests if their knobs are disabled

Prior to this change, Dtrace and ZFS tests and their respective
directories would remain installed even if `${MK_DTRACE_TESTS}` == no or
`${MK_ZFS_TESTS}` == no.

This change enhances the logic to remove the tests when the respective
knobs are disabled so the tests will be removed when `make delete-old`
is run.

MFC after:      2 weeks
DeltaFile
+25-0tools/build/mk/OptionalObsoleteFiles.inc
+25-01 files

FreeBSD/src 5a2328arelease/tools vmimage.subr

vmimage.subr: Include dangling symlinks in images

When creating VM images, we filter the METALOG file created by pkg(8)
when installing non-base packages, rejecting any lines which correspond
to files which don't exist; this solves a problem which arose when a
package was installed and then deinstalled (or upgraded) later in the
image-building process.

Unfortunately [ -e ... ] follows symlinks and is not basedir-aware, so
an absolute symlink which is valid *inside* the image is omitted from
the image if it points to something which isn't present in the build
host system.

Replace [ -e ... ] with [ -e ... ] || [ -L ... ] so that symlinks are
included even if dangling.

While I'm here, add quoting in case future paths become problematic.

Sponsored by:   Amazon
MFC after:      3 days
DeltaFile
+2-1release/tools/vmimage.subr
+2-11 files

FreeBSD/src 8a0cab2sys/dev/hwpmc hwpmc_amd.h hwpmc_amd.c

hwpmc/amd: replace static pmcdesc[] and pc_amdpmcs[] with dynamic allocation

AMD_NPMCS_MAX = 342 (16 core + 6 L3 + 64 DF + 256 UMC). On a Zen 4
EPYC 9654 with 6 core, 6 L3, 16 DF, and 4 UMC counters, only 32
descriptors are needed; the static arrays over-allocate by ~10x.

Replace both amd_pmcdesc[AMD_NPMCS_MAX] and per-CPU pc_amdpmcs[AMD_NPMCS_MAX]
with mallocarray() sized to the actual registered PMC count:
  - amd_pmcdesc: allocated in pmc_amd_initialize()
  - pc_amdpmcs:  allocated per-CPU in amd_pcpu_init(), freed in fini()

Normalize amd_l3_npmcs and amd_df_npmcs against the AMDID2_PTSCEL2I
and AMDID2_PNXC feature bits before computing npmcs_total, so that
allocation, registration, and amd_get_msr() row offsets are all derived
from the same values.  Previously the ternary in npmcs_total excluded
L3/DF from the allocation while the globals retained their defaults,
causing amd_get_msr() to miscompute DF row offsets when L3 is absent.

amd_umc_npmcs comes from CPUID Fn8000_0022h EBX[23:16] (NumUMCCounters)

    [14 lines not shown]
DeltaFile
+41-2sys/dev/hwpmc/hwpmc_amd.c
+2-1sys/dev/hwpmc/hwpmc_amd.h
+43-32 files