HardenedBSD/src 25c25b1sys/arm64/include hypervisor.h, sys/arm64/vmm vmm_reset.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+1,744-0sys/arm64/include/hypervisor.h
+405-0sys/arm64/vmm/vmm_reset.c
+62-60sys/dev/acpica/acpi.c
+40-37sys/kern/uipc_socket.c
+33-5sys/kern/kern_sysctl.c
+19-17sys/x86/cpufreq/hwpstate_amd.c
+2,303-11926 files not shown
+2,488-20432 files

HardenedBSD/src 6ea242csys/compat/linuxkpi/common/include/linux string_choices.h

LinuxKPI: add str_read_write()

Needed by a wireless driver.

Sponsored by:   The FreeBSD Foundation
MFC after:      3 days
Reviewed by:    kib, emaste
Differential Revision: https://reviews.freebsd.org/D55029
DeltaFile
+9-0sys/compat/linuxkpi/common/include/linux/string_choices.h
+9-01 files

HardenedBSD/src cbb7441sbin/nvmecontrol telemetry.c

nvmecontrol: Pass 1 to uint8_t arg

The rae arg is uint8_t (which we then shift over to the right bit. Pass
'1' instead of 'true' here to match the interface. While true is
promoted to (uint8_t)1, we don't use it as a bool in read_logpage().

Fixes:                  5322eec86ae4 ("nvmecontrol: Always set the RAE bit on telemetry-log requests")
Sponsored by:           Netflix
Reviewed by:            chs
Differential Revision:  https://reviews.freebsd.org/D55060
DeltaFile
+2-2sbin/nvmecontrol/telemetry.c
+2-21 files

HardenedBSD/src e401e6dsys/dev/acpica acpi.c acpivar.h

acpi: 'hw.acpi.s4bios' sysctl: Change type to bool, expand description

Another boolean, indicating hardware support, will be introduced in next commit.

Thanks to the previous commit modifying sysctl_handle_bool(), this
change is backwards-compatible with old programs using an integer in and
out of sysctl(3).

Reviewed by:    obiwac
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54626
DeltaFile
+3-3sys/dev/acpica/acpi.c
+1-1sys/dev/acpica/acpivar.h
+4-42 files

HardenedBSD/src 7f031c9sys/dev/acpica acpi.c

acpi: Move sysctl tree set up at end of initialization

Setting up the sysctl tree later:
1. Fixes not de-registering sysctl knobs on failure to attach.
2. Avoids having inconsistent knob values exposed during a brief moment.

Reviewed by:    imp, obiwac
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54926
DeltaFile
+61-59sys/dev/acpica/acpi.c
+61-591 files

HardenedBSD/src 406da39sys/kern kern_sysctl.c

sysctl(9): Booleans: Accept integers to ease knob conversion

In sysctl_handle_bool(), if the output buffer (for the old value) has
room for exactly 4 bytes (sizeof(int)), then output the current boolean
value as an integer rather than a 'uint8_t'.  Conversely, if 4 bytes
exactly remain in the input buffer (for the new value), treat them as an
integer and derive the new boolean value from it.

Doing so allows to convert existing integer syscstl knobs that are
interpreted as a boolean into true boolean ones while staying
backwards-compatible.

That brings no drawback as no code currently uses sysctl_handle_bool()
as part of a series of calls to sysctl_handle_*() functions for
(de)serialization of some compound structure.  If that case ever
materializes, it can be easily solved, e.g., by creating
a sysctl_handle_bool_strict() variant.

In the future, we might want to go further and generally be more liberal

    [10 lines not shown]
DeltaFile
+33-5sys/kern/kern_sysctl.c
+33-51 files

HardenedBSD/src 53bb020sys/amd64/amd64 machdep.c

amd64: parse_memmap(): Move comment about size at proper place

While here, declare 'size' only in the relevant block.

No functional change (intended).

MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
DeltaFile
+9-10sys/amd64/amd64/machdep.c
+9-101 files

HardenedBSD/src a4f0e93sys/arm64/vmm vmm_reset.c vmm_hyp.c

arm64/vmm: Set and use the fine-grained traps

Set the Fine-grained trap registers to trap any features we don't
support. These are expected to be more useful when we support nested
virtualisation, so for now just the base features and GICv3 are not
trapped.

As nested virtualisation will require VHE we only set the fine-grained
trap registers when VHE is used.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D54687
DeltaFile
+405-0sys/arm64/vmm/vmm_reset.c
+22-0sys/arm64/vmm/vmm_hyp.c
+16-0sys/arm64/vmm/arm64.h
+443-03 files

HardenedBSD/src 095a787sys/arm64/vmm vmm_arm64.c arm64.h

arm64/vmm: Add HYP_FEAT_FGT{,2}

Add the macros and detection for Fine-grained traps (FEAT_FGT and
FEAT_FGT2).

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D54686
DeltaFile
+12-0sys/arm64/vmm/vmm_arm64.c
+2-0sys/arm64/vmm/arm64.h
+14-02 files

HardenedBSD/src 4f82ce5sys/arm64/include hypervisor.h

arm64: Add the Fine-Grained Trap registers

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D54685
DeltaFile
+1,744-0sys/arm64/include/hypervisor.h
+1,744-01 files

HardenedBSD/src 2f3f505sys/dev/virtio/p9fs virtio_p9fs.c

virtio_p9fs: Use VIRTIO_SIMPLE_PNPINFO

This allows us to also use the common VIRTIO_SIMPLE_PROBE and to have
devmatch load the driver when detected.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D54684
DeltaFile
+3-7sys/dev/virtio/p9fs/virtio_p9fs.c
+3-71 files

HardenedBSD/src 32d1f18lib/libc/aarch64/string memset_resolver.c Makefile.inc

libc/aarch64: Add memset for a 64 byte dc zva

On arm64 we can use the "dc zva" instruction to zero memory. The CPU
tells software if the instruction is implemented, and if so the size
and alignment it will use.

When the size is 64-bytes the Arm Optimized Routines implementation of
memset can use dc zva to zero memory, and has a build flag to skip
checking.

Use this flag to build a version of memset that will be used when this
assumption is true.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D54776
DeltaFile
+13-0lib/libc/aarch64/string/memset_resolver.c
+3-1lib/libc/aarch64/string/Makefile.inc
+4-0lib/libc/aarch64/string/memset_zva64.S
+20-13 files

HardenedBSD/src 00f6839lib/libc/aarch64/string Makefile.inc

libc/aarch64: Add a Makefile.inc dependency

If we update Makefile.inc it may be to change the contents of these
files.

Reviewed by:    imp
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D54774
DeltaFile
+2-2lib/libc/aarch64/string/Makefile.inc
+2-21 files

HardenedBSD/src f0516edlib/libc/aarch64/string Makefile.inc memcpy.S

libc/aarch64: Split out the MOPS functions

This allows static binaries to only include the functions they
reference.

Reviewed by:    imp
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D54775
DeltaFile
+14-0lib/libc/aarch64/string/Makefile.inc
+0-2lib/libc/aarch64/string/memcpy.S
+0-1lib/libc/aarch64/string/memset.S
+14-33 files

HardenedBSD/src 64f7e3csys/kern uipc_socket.c uipc_usrreq.c, sys/netinet tcp_syncache.c

sockets: let protocols be responsible for socket buffer mutexes

Sockets that implement their own socket buffers (marked with PR_SOCKBUF)
are now also responsible for initialization of socket buffer mutexes in
pr_attach and for destruction in pr_detach (or pr_close).

This removes a big bunch of reported LORs, as now WITNESS is able to see
that tcp(4) socket buffer mutex and netlink(4) socket buffer mutex are two
different things.  Distinct names also improve diagnostics for blocked
threads.

This also removes a hack from unix(4), where we used to mtx_destroy().
Also removes an innocent bug from unix(4) where for accept(2)-ed socket
soreserve() was called twice.  This one was innocent since first call to
soreserve() was asking for 0 bytes of space.

This slightly increased amount of pasted code in TCP's syncache_socket().
The problem is that while for sockets created with socket(2) it is
pr_attach responsible for call to soreserve() (including !PR_SOCKBUF

    [7 lines not shown]
DeltaFile
+40-37sys/kern/uipc_socket.c
+8-9sys/kern/uipc_usrreq.c
+12-3sys/netinet/tcp_syncache.c
+8-2sys/netlink/netlink_domain.c
+68-514 files

HardenedBSD/src dbe9fa0. Makefile.inc1

Makefile.inc1: Don't mark GCC broken for riscv64

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D54969
DeltaFile
+0-3Makefile.inc1
+0-31 files

HardenedBSD/src 9555d80bin/sh sh.1

sh.1: Fix rendering error due to redundant .El

Due to this all the rest of the items in the Built-in Commands section
were not rendered at all.

Fixes: 2711852bd9ac ("sh.1: Provide detailed job control documentation")
MFC after:              3 days
Reviewed by:            emaste, ziaee
Differential Revision:  https://reviews.freebsd.org/D55080
DeltaFile
+1-2bin/sh/sh.1
+1-21 files

HardenedBSD/src c215eeflib/libpmc libpmc_pmu_util.c

libpmc: Fix the L3 counters for AMD Zen 1-4

On AMD processors libpmc was using the topic field (based on filename) to
determine the counter's subclass.  Unfortunately, the JSON definitions for
AMD Zen 1-4 have the L3 counters in files shared with other counters.

This change has libpmc to use the pmu field (which is derived from the Unit
field in JSON) to determine the correct counter subclass.

Reviewed by:    mhorne
MFC after:      2 weeks
Sponsored by:   Netflix
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1984
DeltaFile
+13-12lib/libpmc/libpmc_pmu_util.c
+13-121 files

HardenedBSD/src 9345091sys/powerpc/aim mmu_oea64.c, sys/powerpc/include pte.h

powerpc/pmap: Use a constant for HPT superpage shift

There are no plans to allow multiple sizes of HPT superpages, so just use a
constant for it.

MFC after:      3 weeks
Fixes:          1bc75d77e9 ("powerpc/pmap/oea64: Make PV_LOCK superpage sized")
DeltaFile
+3-2sys/powerpc/include/pte.h
+2-2sys/powerpc/aim/mmu_oea64.c
+5-42 files

HardenedBSD/src 9d4bad4share/man/man9 EVENTHANDLER.9

EVENTHANDLER.9: EVENTHANDLER_REGISTER never fails

Since ecdf4409f910 ("Rework the eventhandler locking [...]"),
EVENTHANDLER_REGISTER() can never return NULL.

Suggested by:   olce
Reviewed by:    olce, ziaee, zlei
Approved by:    olce, zlei
Fixes:  ecdf4409f910 ("Rework the eventhandler locking [...]")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D55014
DeltaFile
+1-2share/man/man9/EVENTHANDLER.9
+1-21 files

HardenedBSD/src 465ba08sys/vm vm_phys.c

vm_phys: Check `RB_FIND()` return value in case it is NULL

When trying to unregister a fictitious range in
`vm_phys_fictitious_unreg_range()`, the function checks the properties
of the looked up segment, but it does not check if a segment was found
in the first place.

This can happen with the amdgpu DRM driver which could call
`vm_phys_fictitious_unreg_range()` without a fictitious range registered
if the initialisation of the driver failed (for example because
firmwares are unavailable).

The code in the DRM driver was improved to avoid that, but
`vm_phys_fictitious_unreg_range()` should still check the return value
of `RB_FIND()` before trying to dereference the segment pointer and
panic with a page fault.

Reviewed by:    emaste
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55076
DeltaFile
+1-1sys/vm/vm_phys.c
+1-11 files

HardenedBSD/src d70b9eblib/libc/tests/gen dir2_test.c

libc/tests: Clean up *dir() tests

Mainly, avoid reusing the name of one of the functions we should be
testing (but aren't) for local variables.

Sponsored by:   Klara, Inc.
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D55054
DeltaFile
+13-15lib/libc/tests/gen/dir2_test.c
+13-151 files

HardenedBSD/src 9ae367dsys/x86/cpufreq hwpstate_amd.c

hwpstate_amd(4): Rename CPPC register macros

To be closer to AMD's official terminology, except for the "Lowest
Non-Linear Performance" field which we label as 'EFFICIENT_PERF' closer
to Intel's ("Most Efficient Performance"), and to clear possible
confusion.

No functional change (intended).

Reviewed by:    aokblast
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54998
DeltaFile
+14-14sys/x86/cpufreq/hwpstate_amd.c
+14-141 files

HardenedBSD/src 4b0e09asys/x86/cpufreq hwpstate_amd.c

hwpstate_amd(4): Fix BITS_WITH_VALUE()/SET_BITS_VALUE() to obey the mask

While here, rename an argument of BITS_VALUE() to be consistent with the
other macros.

Reviewed by:    aokblast
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54997
DeltaFile
+5-3sys/x86/cpufreq/hwpstate_amd.c
+5-31 files

HardenedBSD/src a1a8bcdsys/x86/x86 cpu_machdep.c

x86: x86_msr_op(): Simplify assertions

Simplify them by moving them into more natural places, i.e., default
cases of 'switch' statements.

No functional change (intended).

Reviewed by:    kib
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54996
DeltaFile
+4-6sys/x86/x86/cpu_machdep.c
+4-61 files

HardenedBSD/src e5f8cbbsys/x86/include x86_var.h, sys/x86/x86 cpu_machdep.c

x86: x86_msr_op(): MSR_OP_LOCAL: Disable interrupts on atomic ops

On MSR_OP_LOCAL and non-naturally-atomic operations (MSR_OP_ANDNOT and
MSR_OP_OR), there is no guarantee that we are not interrupted between
reading and writing the MSR, and that interruption could actually
perform some operation on that MSR, which would be lost.

Prevent that problem by temporarily disabling interrupts around MSR
manipulation.

Reviewed by:    kib
Discussed with: markj
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54996
DeltaFile
+3-0sys/x86/x86/cpu_machdep.c
+2-0sys/x86/include/x86_var.h
+5-02 files

HardenedBSD/src 7acd7acsys/x86/x86 cpu_machdep.c

x86: x86_msr_op(): Move setting mode up, delineate logical blocks

No functional changes (intended).

Reviewed by:    kib
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54996
DeltaFile
+5-3sys/x86/x86/cpu_machdep.c
+5-31 files

HardenedBSD/src af12912sys/kern vfs_mount.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+2-0sys/kern/vfs_mount.c
+2-01 files

HardenedBSD/src c3c4021share/mk src.opts.mk, sys/dev/bnxt/bnxt_en if_bnxt.c

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+3-4sys/dev/bnxt/bnxt_en/if_bnxt.c
+0-5share/mk/src.opts.mk
+3-92 files

HardenedBSD/src cd8d441sys/kern vfs_mount.c

unmount(2): do not allow MNT_DEFERRED or MNT_RECURSE flags from userspace

Repprted and tested by: pho
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+2-0sys/kern/vfs_mount.c
+2-01 files