HardenedBSD/src 1f7a458 — sys/amd64/amd64 fpu.c, sys/dev/rtwn/rtl8192f r92f_calib.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+5-8sys/dev/rtwn/rtl8192f/r92f_calib.c
+11-2sys/amd64/amd64/fpu.c
+6-6sys/ofed/drivers/infiniband/ulp/nfsclrdma/xprt_verbs.c
+2-5sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
+24-214 files

HardenedBSD/src 59418eb — sys/amd64/amd64 fpu.c, sys/dev/rtwn/rtl8192f r92f_calib.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+5-8sys/dev/rtwn/rtl8192f/r92f_calib.c
+11-2sys/amd64/amd64/fpu.c
+6-6sys/ofed/drivers/infiniband/ulp/nfsclrdma/xprt_verbs.c
+2-5sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
+24-214 files

HardenedBSD/src 3343e51 — sys/dev/rtwn/rtl8192f r92f_calib.c

rtwn: fix the build without RTWN_DEBUG

RTWN_DPRINTF() compiles to nothing without RTWN_DEBUG, which leaves four
of the IQK result copies in r92f_iq_calib() set but never read.  Kernels
with "device rtwn" in their config, LINT among them, then fail with
-Werror,-Wunused-but-set-variable.  The module build does not hit this
because its generated opt_rtwn.h always defines RTWN_DEBUG.

Print the result array directly and drop the four locals.

Fixes:          1f0e186e1832 ("rtwn: added support for Realtek RTL8192FU...")
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+5-8sys/dev/rtwn/rtl8192f/r92f_calib.c
+5-81 files

HardenedBSD/src 8a8a527 — sys/amd64/amd64 fpu.c

amd64: Avoid redundant CR0 writes on switches to kernel threads

fpu_activate_sw() sets CR0.TS whenever it switches to a kernel thread,
or to a thread inside fpu_kern_enter().  The bit is clear only while a
thread owns the FPU, and at a context switch the only possible owner is
the old thread.  When fpcurthread is NULL the bit is already set and
the write to CR0, which is serializing, changes nothing.  That is the
common case for switches between kernel threads, such as the idle
thread and interrupt threads on a router.

Write CR0 only when fpcurthread was set, as cpu_switch() did before
the eager FPU switch became the default in d1a07e31e5cc, and assert
that TS is set otherwise.

Reviewed by:            kib
MFC after:              1 week
Sponsored by:           Rubicon Communications, LLC ("Netgate")
Differential Revision:  https://reviews.freebsd.org/D62206
DeltaFile
+11-2sys/amd64/amd64/fpu.c
+11-21 files

HardenedBSD/src b75ceca — sys/ofed/drivers/infiniband/ulp/nfsclrdma clnt_rdma.c xprt_verbs.c

nfsclrdma: Fix a few things in the RDMA client module

This patch fixes a few things in the nfsclrdma module:
- A typo that caused _rpcrdma_get_srcaddr() to return 0
  when it should have returned 1.
- Don't consider a server returning RPC_SYSTEMERROR or
  RPC_FAILED as needing a new connection, to be compatible
  with clnt_vc.c for TCP.
- Fix off by one checks in the KASSERT()s for the RPC index.

Reported by:    llm-postcr
MFC after:      1 month
Fixes:  80bee4d83637 ("nfsclrdma: Add code to support client side NFS over RDMA")
DeltaFile
+6-6sys/ofed/drivers/infiniband/ulp/nfsclrdma/xprt_verbs.c
+2-5sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
+8-112 files

HardenedBSD/src c5986e6 — sys/contrib/dev/rtwn rtwn-rtl8192fufw.fw.uu, sys/dev/rtwn/rtl8192f r92f_calib.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+8,751-0sys/powerpc/linux/linux_systrace_args.c
+2,209-0sys/powerpc/linux/syscalls.master
+2,095-0sys/powerpc/linux/linux_proto.h
+1,087-0sys/dev/rtwn/rtl8192f/r92f_calib.c
+848-0sys/powerpc/linux/linux_sysvec.c
+695-0sys/contrib/dev/rtwn/rtwn-rtl8192fufw.fw.uu
+15,685-078 files not shown
+21,364-6184 files

HardenedBSD/src 74fb2f4 — sys/contrib/dev/rtwn rtwn-rtl8192fufw.fw.uu, sys/dev/rtwn/rtl8192f r92f_calib.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+8,751-0sys/powerpc/linux/linux_systrace_args.c
+2,209-0sys/powerpc/linux/syscalls.master
+2,095-0sys/powerpc/linux/linux_proto.h
+1,087-0sys/dev/rtwn/rtl8192f/r92f_calib.c
+848-0sys/powerpc/linux/linux_sysvec.c
+695-0sys/contrib/dev/rtwn/rtwn-rtl8192fufw.fw.uu
+15,685-078 files not shown
+21,364-6184 files

HardenedBSD/src 86d2198 —

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+0-00 files

HardenedBSD/src 493c847 — etc/mtree BSD.tests.dist, lib/libsys Makefile

libsys: add test checking that -lsys alone is linkable

Reviewed by:    jrtc27 (previous version)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D62131
DeltaFile
+25-0lib/libsys/tests/Makefile
+24-0lib/libsys/tests/hermetic_test.sh
+18-0lib/libsys/tests/hermetic.c
+3-0lib/libsys/Makefile
+2-0etc/mtree/BSD.tests.dist
+72-05 files

HardenedBSD/src d64d2be — lib/libsys Makefile

libsys: do not link in csu, and compile as freestanding

This is a library below implementation of the C runtime.  It should not
(and really cannot) use any of that.

In particular, libsys no longer has undef __cxa_finalize.

Reviewed by:    brooks, jrtc27
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D62131
DeltaFile
+3-0lib/libsys/Makefile
+3-01 files

HardenedBSD/src 98a7f08 — lib/libsys Makefile

libsys: this is libsys, not libc

Reviewed by:    brooks, jrtc27
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D62131
DeltaFile
+1-1lib/libsys/Makefile
+1-11 files

HardenedBSD/src 0425a73 — lib/libsys Makefile

libsys: link internal copies of fls*(3), str*(3), and mem*(3) functions used by libsys

To avoid undef symbols which get resolved from libc.

Reviewed by:    brooks, jrtc27
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D62131
DeltaFile
+10-1lib/libsys/Makefile
+10-11 files

HardenedBSD/src 2fbea17 — lib/libsys auxv.c

libsys: avoid depending on libc _once()

The __init_elf_aux_vector() function is idempotent, so do not bother
ensuring a single call.  Just tolerate a possible race.

Reviewed by:    brooks, jrtc27 (previous version)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D62131
DeltaFile
+10-16lib/libsys/auxv.c
+10-161 files

HardenedBSD/src 570f922 — sys/vm vm_page.h vm_pageout.c

vm_pageout: Recheck PGA_SWAP_FREE after locking

vm_pageout_scan_active() reads PGA_SWAP_FREE without the object lock,
and once VM_OBJECT_TRYWLOCK() succeeds it calls
vm_pager_page_unswapped() without rereading the flag.  In between,
another thread can move the page to the laundry, e.g., by performing
madvise(MADV_DONTNEED) on a dirty page, where swap_pager_putpages()
clears PGA_SWAP_FREE and assigns a new swap block.  Then, the scan frees
that block, perhaps while the write to it is still in flight, and the
page's contents are lost or corrupted.

Recheck the flag with the object locked, and document the rule where
the flag is defined.

Found by:       Claude Code (Opus 5.5)
Reviewed by:    kib, markj
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D62202
DeltaFile
+8-2sys/vm/vm_pageout.c
+2-2sys/vm/vm_page.h
+10-42 files

HardenedBSD/src 83d1b68 — sys/i386/include sdt_machdep.h, sys/x86/x86 sdt_machdep.c

i386/sdt: Use a single NOP for disabled probes

As on amd64, a disabled tracepoint must be a single instruction, so
that a thread cannot be interrupted inside it and resume in the middle
of the jump written when the probe is enabled.  On i386, both
_SDT_ASM_PATCH_INSTR and sdt_tracepoint_restore() used five one-byte
NOPs.

Use "leal %ds:0(%esi,%eiz,1), %esi" (3e 8d 74 26 00) instead.  The
multi-byte NOP (0f 1f) is avoided because i386 GENERIC still supports
CPUs without it.

Tested on stable/15 i386 under bhyve with a reproducer that toggles a
probe while other CPUs run its sites.

Reviewed by:    markj
MFC after:      1w
Co-authored-by: Claude Opus 5.5
Differential Revision:  https://reviews.freebsd.org/D62198
DeltaFile
+6-5sys/x86/x86/sdt_machdep.c
+6-1sys/i386/include/sdt_machdep.h
+12-62 files

HardenedBSD/src 1f0e186 — sys/contrib/dev/rtwn rtwn-rtl8192fufw.fw.uu, sys/dev/rtwn/rtl8192f r92f_priv.h r92f_chan.c

rtwn: added support for Realtek RTL8192FU chipset

Added support for Realtek RTL8192FU chipset using rtwn driver.

* Used Linux's rtl8xxxu driver for reference.
* New registers derived from it are saved in r92f_reg.h.
* Current additions include:
  IQ/LC calibration, channel configuration, LED configuration.
* Firmware image added as uuencoded rtwn-rtl8192fufw.fw.uu with a new
  rtwnfw/rtwnrtl8192fu module.

 Sponsored by: Alchemilla Ventures Private Limited

Reviewed by:    adrian
Differential Revision:  https://reviews.freebsd.org/D61728
DeltaFile
+1,087-0sys/dev/rtwn/rtl8192f/r92f_calib.c
+695-0sys/contrib/dev/rtwn/rtwn-rtl8192fufw.fw.uu
+544-0sys/dev/rtwn/rtl8192f/usb/r92fu_init.c
+332-0sys/dev/rtwn/rtl8192f/r92f_chan.c
+320-0sys/dev/rtwn/rtl8192f/r92f_priv.h
+232-0sys/dev/rtwn/rtl8192f/usb/r92fu_attach.c
+3,210-034 files not shown
+4,424-1340 files

HardenedBSD/src 1751658 — sys/dev/hid hid.h

hid: Increase HID_ITEM_MAXUSAGE to 32

I have a Logitech mouse that reports 16 buttons.  Bump to 32 to be a
little more future proof.  This increases the size of struct hid_item
but this struct is not exported to userland.

Reviewed by:    wulf
Differential Revision:  https://reviews.freebsd.org/D59273

(cherry picked from commit 5cc15fef2656b078982d453b8915379b47ff0e88)
DeltaFile
+1-1sys/dev/hid/hid.h
+1-11 files

HardenedBSD/src b030920 — sys/modules Makefile, sys/modules/linux_common Makefile

linuxulator/powerpc: Add ELFv2 and powerpc64le support

Differential Revision:  https://reviews.freebsd.org/D42992
DeltaFile
+85-2sys/powerpc/linux/linux_sysvec.c
+2-2sys/modules/linux_common/Makefile
+2-2sys/modules/Makefile
+89-63 files

HardenedBSD/src e62e2bb — sys/powerpc/linux linux_syscalls.c linux_sysent.c

powerpc: Add first Linuxulator support (ELFv1, BE, powerpc64)

Introduce the first cut of the Linuxulator for powerpc64.  This was a
GSoC project for 2022, and consists of the following:

* ELFv1
* Limited shared page (no timekeep fallback)
* Most, if not all, syscalls are implemented, all common ones, no
  arch-specific ones.

At completion of the GSoC period this was able to run through the LTP
test suite, with a very high pass rate.  More work remains, as always,
and will be done as needed.

Further work is still necessary, but this lays the groundwork.  Expected
future work includes:

* ELFv2
* 32-bit support (running legacy Linux applications)

    [4 lines not shown]
DeltaFile
+8,751-0sys/powerpc/linux/linux_systrace_args.c
+2,209-0sys/powerpc/linux/syscalls.master
+2,095-0sys/powerpc/linux/linux_proto.h
+765-0sys/powerpc/linux/linux_sysvec.c
+531-0sys/powerpc/linux/linux_sysent.c
+462-0sys/powerpc/linux/linux_syscalls.c
+14,813-028 files not shown
+16,739-2034 files

HardenedBSD/src adfc1e3 — sys/dev/cpufreq cpufreq_dt.h cpufreq_dt_vendor_if.m, sys/dev/nvmem nvmem.h nvmem.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+198-31sys/dev/cpufreq/cpufreq_dt.c
+99-0sys/dev/cpufreq/cpufreq_allwinner.c
+62-0sys/dev/nvmem/nvmem.c
+52-0sys/dev/cpufreq/cpufreq_dt_vendor_if.m
+47-0sys/dev/cpufreq/cpufreq_dt.h
+7-0sys/dev/nvmem/nvmem.h
+465-314 files not shown
+470-3210 files

HardenedBSD/src 9307589 — sys/dev/cpufreq cpufreq_dt.h cpufreq_dt_vendor_if.m, sys/dev/nvmem nvmem.h nvmem.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+198-31sys/dev/cpufreq/cpufreq_dt.c
+99-0sys/dev/cpufreq/cpufreq_allwinner.c
+62-0sys/dev/nvmem/nvmem.c
+52-0sys/dev/cpufreq/cpufreq_dt_vendor_if.m
+47-0sys/dev/cpufreq/cpufreq_dt.h
+7-0sys/dev/nvmem/nvmem.h
+465-314 files not shown
+470-3210 files

HardenedBSD/src 47372db — sys/ofed/drivers/infiniband/ulp/nfsclrdma clnt_rdma.c

clnt_rdma.c: Copy data into the pages before dma mapping them

Without this patch, the code would copy data into pages for
a large RPC request being done over RDMA after doing the
dma mapping of the pages. (Dma mapping of the pages includes
the dma sync for the device.)

This patch moves the data copying up to before the call
to xprt_rdma_create_chunk(), which does the dma mapping,
including the dma sync for the device.

Reported by:    llm-postcr
MFC after:      1 month
Fixes:  80bee4d83637 ("nfsclrdma: Add code to support client side NFS over RDMA")
DeltaFile
+1-1sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
+1-11 files

HardenedBSD/src 97dfe36 — sys/dev/cpufreq cpufreq_dt.c

cpufreq_dt: Only register the first CPU of a group sharing the OPP table

The CPUs using the same OPP table share their clock and their
regulator, but each one had its own cpufreq driver looking for
cpu-supply in its own node. Some device trees only have cpu-supply
for the first CPU (for example the Pine H64), so changing the
frequency with another CPU changed it without changing the voltage.

Only register the driver of the first CPU of each group. The
dev.cpu.N.freq sysctls of the other CPUs of the group are not created
anymore, the frequency is changed with the first one for all of them.

Fixes:  41a76289e601 ("cpufreq_dt: Add operating-points-v2 support")
Tested on:      Quartz64
Reviewed by:    mmel
Differential Revision:  https://reviews.freebsd.org/D61701
DeltaFile
+20-1sys/dev/cpufreq/cpufreq_dt.c
+20-11 files

HardenedBSD/src 3df00fe — sys/conf files.arm64, sys/dev/cpufreq cpufreq_allwinner.c

cpufreq_allwinner: Add the hardware version of the H6

The voltage of each OPP of the H6 depends on the speed bin of the
chip, stored in an efuse referenced by the nvmem-cells property of the
OPP table. Read it and give the bin to cpufreq_dt, so it uses the
matching opp-microvolt-speed<N> property.

Tested on:      Pine H64
Reviewed by:    mmel
Differential Revision:  https://reviews.freebsd.org/D61700
DeltaFile
+99-0sys/dev/cpufreq/cpufreq_allwinner.c
+1-0sys/conf/files.arm64
+100-02 files

HardenedBSD/src 7178a47 — sys/dev/cpufreq cpufreq_dt.c

cpufreq_dt: Honor opp-supported-hw and opp-microvolt-<name>

Use the hardware version given by the SoC specific code to select
the OPPs and their voltages, as described by the OPP binding.

An OPP with opp-supported-hw is only used if one of its sub-groups
matches the hardware version, which means that each level of the
sub-group has a bit in common with the version.

The voltages are read from opp-microvolt-<name> if the SoC specific
code gives a name and the OPP has this property, from opp-microvolt
otherwise.

If no hardware version is known the OPPs with opp-supported-hw are not
used as it is not safe to use an OPP that the hardware might not
support. Setting the hw.cpufreq_dt.ignore_supported_hw loader tunable
to 1 uses them all, as it was done before.

Reviewed by:    mmel
Differential Revision:  https://reviews.freebsd.org/D61699
DeltaFile
+85-8sys/dev/cpufreq/cpufreq_dt.c
+85-81 files

HardenedBSD/src 8e918cf — sys/conf files.riscv files.arm64, sys/dev/cpufreq cpufreq_dt.c cpufreq_dt.h

cpufreq_dt: Add a hook for the SoC specific hardware version

Some SoCs select the OPPs and their voltages (opp-supported-hw and
opp-microvolt-<name>) from a hardware version, for example a speed
grade read from an efuse. How to get this version depends on the SoC
and is not described by the OPP table.

Add the cpufreq_dt_vendor kobj interface, with a method returning the
version: a bitmask for each level of version and the name to use for
opp-microvolt-<name>. The class implementing it is found from the
compatible string of the OPP table (an array of ofw_compat_data, as
the uart driver does), or with the optional match method for the SoCs
that only use the generic operating-points-v2 compatible.

The version is stored in the softc but not used yet and no class
registers, so no functional change intended.

Reviewed by:    mmel
Differential Revision:  https://reviews.freebsd.org/D61698
DeltaFile
+52-0sys/dev/cpufreq/cpufreq_dt_vendor_if.m
+47-0sys/dev/cpufreq/cpufreq_dt.h
+45-0sys/dev/cpufreq/cpufreq_dt.c
+1-0sys/conf/files.riscv
+1-0sys/conf/files.arm64
+1-0sys/conf/files.arm
+147-06 files

HardenedBSD/src 2680480 — sys/dev/nvmem nvmem.h nvmem.c

nvmem: Add functions to get the provider and the location of a cell

Some SoCs store the hardware version needed to select the CPU OPPs in an
efuse, referenced by the nvmem-cells property of the OPP table or of
the CPU node.  The nvmem_read_cell_*() functions cannot be used for this
because they need nvmem-cell-names, which these device trees do not
have, and because the way to read and decode the value depends on the
SoC.

Add nvmem_cell_get_by_ofw_idx() and nvmem_cell_get_by_ofw_name(), which
return the nvmem provider and the offset and size of a cell, so that
the caller can read it with NVMEM_READ().

Nothing uses them yet.

Reviewed by:    mmel
Differential Revision:  https://reviews.freebsd.org/D61697
DeltaFile
+62-0sys/dev/nvmem/nvmem.c
+7-0sys/dev/nvmem/nvmem.h
+69-02 files

HardenedBSD/src b95ef17 — sys/dev/cpufreq cpufreq_dt.c

cpufreq_dt: Move the parsing of opp-microvolt in its own function

Move the code that reads the voltages of an OPP in
cpufreq_dt_oppv2_parse() to a new function, so the way the voltages
are found can be changed for some SoCs.

No functional change intended.

Reviewed by:    mmel
Differential Revision:  https://reviews.freebsd.org/D61696
DeltaFile
+42-26sys/dev/cpufreq/cpufreq_dt.c
+42-261 files

HardenedBSD/src 120b4a4 — sys/dev/cpufreq cpufreq_dt.c

cpufreq_dt: Do not count the OPP table nodes that have no opp-hz

The number of OPPs was the number of children of the OPP table, but
a child without opp-hz is skipped while parsing (opp-hz is a required
property) and the index was still incremented for it. The matching
entry of the array, which is not zeroed, was then left uninitialised
and used as a valid OPP.

Only count the nodes that have opp-hz so the number of entries
matches the ones that are parsed.

Fixes:  41a76289e601 ("cpufreq_dt: Add operating-points-v2 support")
Reviewed by:    mmel
Differential Revision:  https://reviews.freebsd.org/D61695
DeltaFile
+3-1sys/dev/cpufreq/cpufreq_dt.c
+3-11 files

HardenedBSD/src b219781 — sys/dev/cpufreq cpufreq_dt.c

cpufreq_dt: Read clock-latency-ns and convert latencies to microseconds

The operating-points-v2 binding names the per-OPP latency
"clock-latency-ns", but the parser looked for "clock-latency", so the
latency of every v2 OPP was reported as unknown.

The device tree gives the latencies in nanoseconds (this is also the
case for the "clock-latency" of operating-points v1) while the cpufreq
framework wants them in microseconds. Convert them, rounding up so a
non-zero latency never becomes 0.

Fixes:  41a76289e601 ("cpufreq_dt: Add operating-points-v2 support")
Fixes:  319336a943a5 ("Add generic device-tree cpufreq driver.")
Reviewed by:    mmel
Differential Revision:  https://reviews.freebsd.org/D61694
DeltaFile
+10-2sys/dev/cpufreq/cpufreq_dt.c
+10-21 files