HardenedBSD/src b6b10e5sys/dev/acpica acpi_spmc.c, sys/dev/sym sym_hipd.c

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+618-0sys/dev/acpica/acpi_spmc.c
+152-154sys/dev/sym/sym_hipd.c
+295-0tests/sys/kern/pdwait.c
+187-0tests/sys/kern/pdrfork.c
+98-0tests/sys/kern/procdesc.c
+83-15sys/riscv/riscv/pmap.c
+1,433-16912 files not shown
+1,472-20018 files

HardenedBSD/src 70e54a6sys/dev/acpica acpi_spmc.c, sys/dev/sym sym_hipd.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+618-0sys/dev/acpica/acpi_spmc.c
+152-154sys/dev/sym/sym_hipd.c
+295-0tests/sys/kern/pdwait.c
+187-0tests/sys/kern/pdrfork.c
+83-15sys/riscv/riscv/pmap.c
+98-0tests/sys/kern/procdesc.c
+1,433-16911 files not shown
+1,470-20017 files

HardenedBSD/src dec2471lib/libiconv_modules/mapper_std citrus_mapper_std.c, usr.bin/mkimg mkimg.1 mkimg.c

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+34-20usr.bin/mkimg/mkimg.1
+3-0usr.bin/mkimg/mkimg.c
+1-1lib/libiconv_modules/mapper_std/citrus_mapper_std.c
+38-213 files

HardenedBSD/src 97ee3aeusr.bin/mkimg mkimg.1 mkimg.c

mkimg(1): Sync mkimg(1) and usage() with the implementation

Reviewed by:    imp
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D54419

(cherry picked from commit 3aa8d5395c4223f1613f28d6f39904c2df4f92d4)
DeltaFile
+34-20usr.bin/mkimg/mkimg.1
+3-0usr.bin/mkimg/mkimg.c
+37-202 files

HardenedBSD/src 8934c3dtests/sys/netpfil/pf divert-to.sh

pf tests: Set require.kmods in divert-to tests

Tests should declare their dependencies rather than testing for them at
runtime.

Reviewed by:    igoro, kp, glebius
MFC after:      2 weeks
Sponsored by:   OPNsense
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D54846
DeltaFile
+8-23tests/sys/netpfil/pf/divert-to.sh
+8-231 files

HardenedBSD/src 39878d2sys/netpfil/pf pf.c

pf: Rationalize the ip_divert_ptr test

If a rule has a divert port set, then we can reasonably predict that
ipdivert.ko is loaded, and in particular that ip_divert_ptr is set.

Moreover, in this case, if ipdivert.ko is not loaded we should just drop
the packet instead of ignoring the divert rule.

Reviewed by:    igoro, kp, glebius
MFC after:      2 weeks
Sponsored by:   OPNsense
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D54845
DeltaFile
+10-5sys/netpfil/pf/pf.c
+10-51 files

HardenedBSD/src 49ec19fsys/dev/acpica acpivar.h

acpi: Add ACPI_SPMC debug layer define

Reported by:    des
Fixes:  c5daa5a4c32c ("acpi_spmc: Add system power management controller driver")
Sponsored by:   The FreeBSD Foundation
DeltaFile
+1-0sys/dev/acpica/acpivar.h
+1-01 files

HardenedBSD/src 0eb2c9dsys/compat/freebsd32 freebsd32.h

freebsd32: Fix includes

The previous commit added <sys/cdefs.h>, which isn't actually needed.
Conversely, <sys/event.h> is needed (and has been for a long time) but
was not included.

MFC after:      1 week
Fixes:          a11d132f6c62 ("devstat: Provide 32-bit compatibility")
Reported by:    gallatin@
DeltaFile
+1-1sys/compat/freebsd32/freebsd32.h
+1-11 files

HardenedBSD/src 972c488sys/riscv/include cpufunc.h, sys/riscv/vmm vmm_riscv.c

riscv: Add macro for hfence.gvma instruction

Add an inline function hfence_gvma() for hfence.gvma instruction.

Signed-off-by:  Doongar Singh <doonbsd at gmail.com>
Reviewed by:    mhorne, markj
Differential Revision:  https://reviews.freebsd.org/D54857
DeltaFile
+7-0sys/riscv/include/cpufunc.h
+1-1sys/riscv/vmm/vmm_riscv.c
+8-12 files

HardenedBSD/src 518c01bsys/dev/sym sym_hipd.c

sym(4): Provide a DEVICE_DETACH(9) method

This also fixes sym_cam_free() to tear things down correctly, i. e. in
opposite order of setup, as well as sym_cam_attach() to not free devq
and SIM twice in the failure case.
DeltaFile
+19-15sys/dev/sym/sym_hipd.c
+19-151 files

HardenedBSD/src e769bc7sys/dev/sym sym_hipd.c

sym(4): Employ memory barriers also on x86

In an MP world, it doesn't hold that x86 requires no memory barriers.

This change should also fix panics due to out-of-sync data seen with
FreeBSD VMs on top of OpenStack and HBAs of type lsiLogic. [1]

While at it:
- Improve the granularity somewhat by distinguishing between read and
  write memory barriers as well as refer to existing *mb(9) functions
  instead of duplicating these [2], unless IO barriers are also used.
- Nuke the unused SYM_DRIVER_NAME macro.

PR:             270816 [1]
Obtained from:  BSD-licensed Linux sym53c8xx driver [2]
MFC after:      1 week
DeltaFile
+14-26sys/dev/sym/sym_hipd.c
+14-261 files

HardenedBSD/src c8e9479sys/dev/sym sym_hipd.c

sym(4): Use memcpy(9) instead of bcopy(9)

The overlap handling of bcopy(9) is not required in these cases.

Obtained from:  BSD-licensed Linux sym53c8xx driver
DeltaFile
+5-5sys/dev/sym/sym_hipd.c
+5-51 files

HardenedBSD/src 48eee74sys/dev/sym sym_hipd.c

sym(4): Consistently use device_printf(9) where applicable
DeltaFile
+114-108sys/dev/sym/sym_hipd.c
+114-1081 files

HardenedBSD/src 14dc55clib/libiconv_modules/mapper_std citrus_mapper_std.c

libiconv: Fix typo in comment

(cherry picked from commit dec3ea45b65442b4f3cafcd8a672f1e13b69a066)
DeltaFile
+1-1lib/libiconv_modules/mapper_std/citrus_mapper_std.c
+1-11 files

HardenedBSD/src 38e5564. Makefile.inc1

native-xtools: use static LLVM libraries

Set the MK_LLVM_LINK_STATIC_LIBRARIES knob to "yes" when building the
native-xtools target. This reverts to the behaviour prior to
2e47f35be5dc.

This avoids a build failure that occurs otherwise, where compilation
fails looking for a libllvmprivate.so that was not built.

It is unclear if this addresses the issue in all instances---some
replies in the PRs indicate otherwise. Still, some report success, and
in my own testing this fixed creation of a cross-compiled poudriere
jail. Commit this while we continue to investigate...

PR:             286710, 291409
Tested by:      marck, rdunkle at smallcatbrain.com
Reviewed by:    emaste
MFC after:      3 days
Fixes:  2e47f35be5dc ("Convert libllvm, libclang and liblldb into private shared libraries").

    [2 lines not shown]
DeltaFile
+1-0Makefile.inc1
+1-01 files

HardenedBSD/src 27595besys/riscv/riscv pmap.c

riscv: smarter DMAP construction (again)

Extend pmap_bootstrap_dmap() to build the DMAP with 4K-page granularity.

Recently we have been approximating it with 2MB mappings. The motivation
again is the problematic FU540 hardware, which seems to require more
accurate mappings still to avoid triggering its PMP errata.

Although this hardware alone is of little consequence, constructing the
DMAP accurately/correctly may help avoid future surprises.

The implementation contains some repetitive code. This could be
expressed differently, but my guiding principle for these early routines
is that being simple and explicit about what we are doing makes them
easier to comprehend.

See also 762a3224cde6 ("riscv: smarter DMAP construction).

Tested by:      Klaus Küchemann <maciphone2 at googlemail.com>

    [3 lines not shown]
DeltaFile
+83-15sys/riscv/riscv/pmap.c
+83-151 files

HardenedBSD/src c1f5f72lib/libc/gen posix_spawn.c

HBSD: Fix build error caused by mismerge

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+2-0lib/libc/gen/posix_spawn.c
+2-01 files

HardenedBSD/src 277539atests/sys/kern pdwait.c Makefile

Add tests for pdwait

MFC With:       4d707825bf62ee73a32b615846eff9c4a9bda538
Sponsored by:   ConnectWise
DeltaFile
+295-0tests/sys/kern/pdwait.c
+1-0tests/sys/kern/Makefile
+296-02 files

HardenedBSD/src d1e6057tests/sys/kern pdrfork.c Makefile

Add tests for pdrfork

MFC With:       5c2ee618d5ec21f110c4da40e9f17833b2ab8b76
Sponsored by:   ConnectWise
DeltaFile
+187-0tests/sys/kern/pdrfork.c
+1-0tests/sys/kern/Makefile
+188-02 files

HardenedBSD/src e35df41tests/sys/kern procdesc.c Makefile

procdesc: Add a test for pid recycling behavior

MFC With:       09984871d8caff9263b955a94bb9fb5354af1b4c
Sponsored by:   ConnectWise
DeltaFile
+98-0tests/sys/kern/procdesc.c
+1-0tests/sys/kern/Makefile
+99-02 files

HardenedBSD/src c5daa5ashare/man/man4 acpi.4, sys/conf files

acpi_spmc: Add system power management controller driver

Add SPMC (system power management controller) driver as acpi_spmc. This
is the device which provides the LPI device D-state constraints and
allows for OSPM to send S0ix/modern standby entry/exit notifications.
This supports the original Intel DSM
(https://uefi.org/sites/default/files/resources/Intel_ACPI_Low_Power_S0_Idle.pdf,
untested), the AMD DSM (tested), and the Microsoft DSM (tested).

Before entry, acpi_spmc_check_constraints is called to notify of any
violated power constraints. This will use acpi_pwr_get_state to get
current device D-states when that gets added back.

Reviewed by:    olce
Tested by:      jkim, Oleksandr Kryvulia, Matthias Lanter
Approved by:    olce
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D48387
DeltaFile
+618-0sys/dev/acpica/acpi_spmc.c
+3-1share/man/man4/acpi.4
+1-0sys/conf/files
+1-0sys/dev/acpica/acpi.c
+623-14 files

HardenedBSD/src 11fae7asys/compat/freebsd32 freebsd32.h, sys/dev/hpt27xx hpt27xx_osm_bsd.c

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+49-7sys/kern/subr_devstat.c
+27-0sys/compat/freebsd32/freebsd32.h
+3-7sys/dev/hptrr/hptrr_osm_bsd.c
+3-7sys/dev/hpt27xx/hpt27xx_osm_bsd.c
+3-7sys/dev/hptnr/hptnr_osm_bsd.c
+5-3sys/sys/module.h
+90-311 files not shown
+91-337 files

HardenedBSD/src d432d87sys/compat/freebsd32 freebsd32.h, sys/dev/hpt27xx hpt27xx_osm_bsd.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+49-7sys/kern/subr_devstat.c
+27-0sys/compat/freebsd32/freebsd32.h
+3-7sys/dev/hptrr/hptrr_osm_bsd.c
+3-7sys/dev/hpt27xx/hpt27xx_osm_bsd.c
+3-7sys/dev/hptnr/hptnr_osm_bsd.c
+5-3sys/sys/module.h
+90-311 files not shown
+91-337 files

HardenedBSD/src 2cbb4c5contrib/llvm-project/libcxx/include inttypes.h, sys/arm/broadcom/bcm2835 files.bcm283x

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+9-2contrib/llvm-project/libcxx/include/inttypes.h
+3-0sys/conf/kern.mk
+1-1sys/conf/files.arm64
+1-1sys/arm/broadcom/bcm2835/files.bcm283x
+1-1sys/dev/mxge/if_mxge.c
+2-0sys/modules/iwlwifi/Makefile
+17-52 files not shown
+20-68 files

HardenedBSD/src a11d132sys/compat/freebsd32 freebsd32.h, sys/kern subr_devstat.c

devstat: Provide 32-bit compatibility

If a 32-bit process running on a 64-bit kernel requests kern.devstat.all,
translate each struct devstat to its 32-bit equivalent before copying it
out.

Also fix a bug where an early error would be ignored if there were no
devices to report.

MFC after:      1 week
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D54591
DeltaFile
+49-7sys/kern/subr_devstat.c
+27-0sys/compat/freebsd32/freebsd32.h
+76-72 files

HardenedBSD/src c29e051sys/dev/hpt27xx hpt27xx_osm_bsd.c, sys/dev/hptmv entry.c

hpt: remove unnecessary macro expansion hacks

Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D54875
DeltaFile
+3-7sys/dev/hptrr/hptrr_osm_bsd.c
+3-7sys/dev/hpt27xx/hpt27xx_osm_bsd.c
+3-7sys/dev/hptnr/hptnr_osm_bsd.c
+1-2sys/dev/hptmv/entry.c
+10-234 files

HardenedBSD/src 6ecaa8dsys/sys module.h

sys/module.h: allow MODULE_DEPEND to accept macros

Allow MODULE_DEPEND to accept macros by adding an extra level of
indirection. Some drivers in the tree actually depend on this being the
case.

Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D54874
DeltaFile
+5-3sys/sys/module.h
+5-31 files

HardenedBSD/src 5080b34sys/arm/broadcom/bcm2835 files.bcm283x, sys/conf kern.mk files.arm64

vchiq: fix build with clang 21

When compiling vchiq with clang 21, the following -Werror warning is
produced:

    sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c:728:27: error: default initialization of an object of type 'VCHIQ_QUEUE_MESSAGE32_T' with const member leaves the object uninitialized [-Werror,-Wdefault-const-init-field-unsafe]
      728 |                 VCHIQ_QUEUE_MESSAGE32_T args32;
          |                                         ^
    sys/contrib/vchiq/interface/vchiq_arm/vchiq_ioctl.h:151:40: note: member 'elements' declared 'const' here
      151 |         const /*VCHIQ_ELEMENT_T * */ uint32_t elements;
          |                                               ^

While the warning is formally correct, the 'args32' object is
immediately initialized after its declaration. Therefore, suppress the
warning.

MFC after:      3 days

(cherry picked from commit b39662fc388678db2b7b5fa3c900205252d15b3b)
DeltaFile
+3-0sys/conf/kern.mk
+1-1sys/conf/files.arm64
+1-1sys/arm/broadcom/bcm2835/files.bcm283x
+5-23 files

HardenedBSD/src 0b52fb5sys/dev/mxge if_mxge.c

mxge(4): avoid clang 21 warning in NO-IP configuration

Building the LINT-NOIP kernel on amd64 with clang 21 results in a
-Werror warning similar to:

    sys/dev/mxge/if_mxge.c:1846:44: error: variable 'sum' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
     1846 |                     cksum_offset, sizeof(sum), (caddr_t)&sum);
          |                                                          ^~~

Indeed, if both `INET` and `INET6` are undefined, `sum` is never
initialized. Initialize it to zero to silence the warning.

Reviewed by:    jhibbits
MFC after:      3 days
Differential Revision: https://reviews.freebsd.org/D54730

(cherry picked from commit 74cac745fe302b26ad22114f60735c8b73e90571)
DeltaFile
+1-1sys/dev/mxge/if_mxge.c
+1-11 files

HardenedBSD/src cff26b9contrib/llvm-project/libcxx/include inttypes.h

libc++ inttypes.h: define __STDC_CONSTANT_MACROS and __STDC_LIMIT_MACROS

Before transitively including the base version of inttypes.h, define
__STDC_CONSTANT_MACROS and __STDC_LIMIT_MACROS, because the base
inttypes.h directly includes sys/stdint.h, instead of going through the
'regular' stdint.h.

The libc++ version of the latter does define those macros, to ensure
things like UINT64_C() and SIZE_MAX are defined even in C++98 or C++03.

MFC after:      3 days

(cherry picked from commit 3cdb6c9d92ecf479a0df338267f3f844ef6feeb2)
DeltaFile
+9-2contrib/llvm-project/libcxx/include/inttypes.h
+9-21 files