HardenedBSD/src fdb29f2 — share/man/man7 build.7, sys/cddl/dev/fbt/powerpc fbt_isa.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+75-114sys/net/route/nhgrp_ctl.c
+10-10sys/sys/kobj.h
+6-6sys/net/route/route_helpers.c
+7-0sys/cddl/dev/fbt/powerpc/fbt_isa.c
+3-3sys/tools/makeobjops.awk
+3-2share/man/man7/build.7
+104-1359 files not shown
+113-14115 files

HardenedBSD/src d14361d — share/man/man7 build.7, sys/cddl/dev/fbt/powerpc fbt_isa.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+75-114sys/net/route/nhgrp_ctl.c
+10-10sys/sys/kobj.h
+6-6sys/net/route/route_helpers.c
+7-0sys/cddl/dev/fbt/powerpc/fbt_isa.c
+3-3sys/tools/makeobjops.awk
+3-2share/man/man7/build.7
+104-1359 files not shown
+113-14115 files

HardenedBSD/src 6ba91b5 — sys/dev/sound dummy.c, sys/dev/sound/pci emu10k1.c cmi.c

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+10-4sys/dev/sound/dummy.c
+7-5sys/vm/swap_pager.c
+9-3sys/dev/sound/usb/uaudio.c
+0-1sys/dev/sound/pci/emu10k1.c
+0-1sys/dev/sound/pci/cmi.c
+26-145 files

HardenedBSD/src 132cc5c — sys/net/route nhop.h route_var.h

routing: Sort the nexthops of a group by metric

Sort the nexthops of a group by metric first and by index second,
and keep the metric of each nexthop in the unused storage field.

The nexthops with the lowest metric are the first ones in the array.

The group is sized and compiled from them without visiting every
nexthop for its metric, and the metric argument of these functions
goes away.

decompose_change_notification() walks two groups in their sort
order, so make it use the same comparison.

Reviewed by:    glebius
Differential Revision:  https://reviews.freebsd.org/D61637
DeltaFile
+49-44sys/net/route/nhgrp_ctl.c
+6-6sys/net/route/route_helpers.c
+1-1sys/net/route/nhop.h
+2-0sys/net/route/route_var.h
+58-514 files

HardenedBSD/src b450c1d — sys/net/route nhgrp_ctl.c

routing: Fix the size of nexthop groups with mixed metrics

calc_min_mpath_slots_fast() selects the nexthops with the lowest
metric through wn[i].nh, but reads their weights from wn[i].storage,
a copy of the weights that is sorted independently of the nexthops.
In a group with more than one metric the weights of the wrong
nexthops are summed, and the weights of all nexthops take part in
the divisibility check, so the group gets a wrong number of slots
and a wrong traffic split.

Calculate the number of slots as the sum of the weights divided by
their greatest common divisor instead.  It needs no sorted copy of
the weights and is exact where the old code gave up and used
RIB_MAX_MPATH_WIDTH slots.

The storage field is part of the bytes that identify a group.  It is
no longer written by the calculation, so set it to zero.

Reviewed by:    glebius

    [2 lines not shown]
DeltaFile
+33-77sys/net/route/nhgrp_ctl.c
+33-771 files

HardenedBSD/src bf362c1 — sys/sys kobj.h, sys/tools makeobjops.awk

kobj: convert KOBJOPLOOKUP() to returning pointer to function

This makes KOBJOPLOOKUP() rather more suitable for purposes outside the
macros generated by makeobjops.awk. Of note other callers can lookup
the function on their parent class and call that explicitly.

Reviewed by:    zlei
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D48408
DeltaFile
+10-10sys/sys/kobj.h
+3-3sys/tools/makeobjops.awk
+13-132 files

HardenedBSD/src 5541489 — sys/dev/sound dummy.c

snd_dummy: Do not use dummy_chan_io() as mpu401's interrupt handler

dummy_chan_io() runs with sc->lock held, but mpu401 calls its handler
from a callout with no mutex associated with it, so writing to the MIDI
device node caused a panic.

Give mpu401 its own handler, and leave MIDI to mpu401's timer instead of
the PCM callout.

Fixes:          e963472ef853 ("snd_dummy: Initial MIDI support")
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit c8d1c94741231d95964b91910880769019478854)
DeltaFile
+10-4sys/dev/sound/dummy.c
+10-41 files

HardenedBSD/src 6f80968 — sys/dev/sound/usb uaudio.c

snd_uaudio: Fix the MIDI TX round-robin

Nothing advances curr_cable, so umidi_bulk_write_callback() only
services cable 0, which is a problem on MIDI devices with more than one
jack.

Fixes:          039477d3e7e7 ("snd_uaudio: Simplify chan->curr_cable calculation in uaudio_bulk_write_callback()")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 day

(cherry picked from commit f58613868b50dfd6c2adc7128ea60d7b276fdbf1)
DeltaFile
+2-1sys/dev/sound/usb/uaudio.c
+2-11 files

HardenedBSD/src 682a775 — sys/dev/sound/usb uaudio.c

snd_uaudio: Do not touch mixer_lock when there is no mixer

Using the mixer lock unconditionally panics because the lock is
uninitialized on devices with no audio interfaces, for instance
MIDI-only keyboards.

Fixes:          9a00e0b8ca56 ("snd_uaudio: Do not use snd_mixer->lock as mixer_lock")
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D61506

(cherry picked from commit dabd959b17597ad790327020a667ced9a05d7499)
DeltaFile
+7-2sys/dev/sound/usb/uaudio.c
+7-21 files

HardenedBSD/src 0e64d19 — sys/dev/sound/pci emu10k1.c cmi.c

sound: Remove stale midi module dependencies

midi(4) stopped being a module in 45bb10e0ed5a ("sound: Stop building
midi as a module"), so snd_cmi(4) and snd_emu10k1(4) fail to load
because they still depend on it.

Fixes:          45bb10e0ed5a ("sound: Stop building midi as a module")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 day

(cherry picked from commit 563c2f27e0ffec96a0ddd77b68c7ca6614d704af)
DeltaFile
+0-1sys/dev/sound/pci/emu10k1.c
+0-1sys/dev/sound/pci/cmi.c
+0-22 files

HardenedBSD/src 4588b63 — sys/cddl/dev/fbt/powerpc fbt_isa.c

fbt/powerpc: don't instrument the trap entry path

On powerpc an fbt probe is a program interrupt that goes through the
normal trap path, powerpc_interrupt() -> trap() -> dtrace_trap(). A
probe on trap() or powerpc_interrupt() fires again on the way to its
own handler, so it recurses until the kernel stack runs out, and
enabling fbt::trap:entry panics the machine right away.

Skip both functions, like aarch64 and riscv skip their exception
handlers.

Reviewed by:    jhibbits
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D61660
DeltaFile
+7-0sys/cddl/dev/fbt/powerpc/fbt_isa.c
+7-01 files

HardenedBSD/src 9a6e1be — usr.sbin/moused/msconvd msconvd.8

msconvd.8: remove double .El (end of list)
DeltaFile
+0-1usr.sbin/moused/msconvd/msconvd.8
+0-11 files

HardenedBSD/src 0678edc — usr.sbin/moused/moused moused.8

moused.8: add forgotten end of list .El
DeltaFile
+1-1usr.sbin/moused/moused/moused.8
+1-11 files

HardenedBSD/src 30e9c7e — share/man/man7 build.7

build.7: fix macro typo
DeltaFile
+2-2share/man/man7/build.7
+2-21 files

HardenedBSD/src 1e2470b — share/man/man4 acpi_einj.4

acpi_einj.4: fix .El (end of list) order
DeltaFile
+1-1share/man/man4/acpi_einj.4
+1-11 files

HardenedBSD/src e5c675d — share/man/man7 build.7

build.7: add forgotten end of list .El
DeltaFile
+1-0share/man/man7/build.7
+1-01 files

HardenedBSD/src c1664fe — sbin/init init.8

init.8: fix .El (end of list) order

Approved by: kib
Differential Revision: https://reviews.freebsd.org/D61787
DeltaFile
+1-1sbin/init/init.8
+1-11 files

HardenedBSD/src 26c14e4 — lib/libsys kexec_load.2

kexec_load.2: add forgotten end of list .El
DeltaFile
+1-0lib/libsys/kexec_load.2
+1-01 files

HardenedBSD/src 8033a9e — lib/libsys pdfork.2

pdfork.2: add forgotten end of list .El
DeltaFile
+1-0lib/libsys/pdfork.2
+1-01 files

HardenedBSD/src ae55e62 — lib/libsys jail.2

jail.2: fix macro typo
DeltaFile
+1-1lib/libsys/jail.2
+1-11 files

HardenedBSD/src fc59975 — sys/dev/clk/mediatek mtk_clk_mux.c mtk_clk_pll.c, sys/dev/uart uart_dev_mtk.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+407-0sys/dev/uart/uart_dev_mtk.c
+277-0sys/dev/clk/mediatek/mt7986_topckgen.c
+265-0sys/dev/clk/mediatek/mt7986_infracfg.c
+227-0sys/dev/clk/mediatek/mtk_clk.c
+214-0sys/dev/clk/mediatek/mtk_clk_pll.c
+164-0sys/dev/clk/mediatek/mtk_clk_mux.c
+1,554-020 files not shown
+2,193-9326 files

HardenedBSD/src a656cac — sys/dev/clk/mediatek mtk_clk_mux.c mtk_clk_pll.c, sys/dev/uart uart_dev_mtk.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+407-0sys/dev/uart/uart_dev_mtk.c
+277-0sys/dev/clk/mediatek/mt7986_topckgen.c
+265-0sys/dev/clk/mediatek/mt7986_infracfg.c
+227-0sys/dev/clk/mediatek/mtk_clk.c
+214-0sys/dev/clk/mediatek/mtk_clk_pll.c
+164-0sys/dev/clk/mediatek/mtk_clk_mux.c
+1,554-020 files not shown
+2,193-9326 files

HardenedBSD/src 90bc40e — sys/powerpc/include elf.h cpu.h

powerpc: Split CPU flags into separate file and include in ELF header

This change fixes Bug 239621, where FreeBSD on powerpc deviates from
userspace expectations on other architectures (arm) and operating
systems (Linux)

Approved by: jhibbits (mentor)
MFC after: 1 week
DeltaFile
+100-0sys/powerpc/include/cpu_flags.h
+1-52sys/powerpc/include/cpu.h
+2-0sys/powerpc/include/elf.h
+103-523 files

HardenedBSD/src b803000 — sys/dev/uart uart_core.c uart.h

uart: Add a flags field to struct uart_bas

uart_bus_probe() sets UART_BAS_IN_PROBE in it while the hardware driver
probes.  The softc is then still a plain struct uart_softc, so code that
the probe method shares with attached devices can check the flag before
using the class specific fields.

No functional change.

Reviewed by:    mmel
Approved by:    markj (mentor)
Sponsored by:   Alchemilla Ventures Private Limited
Differential Revision:  https://reviews.freebsd.org/D61620
DeltaFile
+3-0sys/dev/uart/uart_core.c
+3-0sys/dev/uart/uart.h
+6-02 files

HardenedBSD/src e7723c7 — sys/dev/uart uart_dev_ns8250.h uart_dev_ns8250.c

uart: Factor out the ns8250 baud rate generator code

Move the code that programs the divisor latch out of ns8250_param()
into ns8250_set_baudrate(), and the code that computes the rate from
it out of the UART_IOCTL_BAUD handler into ns8250_get_baudrate().

ns8250_get_divisor() now returns the input clock cycles per bit,
prescaler included, in units of 1 / NS8250_DIVISOR_SCALE, and the
rate, the delays and the rclk guess are derived from it.  This leaves
room for other prescalers and for fractional dividers.

ns8250_delay() is now computed in 64 bits with one formula.  The old
code split at a divisor of 134 to keep 16000000 * divisor within an int
(ebecffe93038), and above 134 divided by rclk / 1000 rounded down.  With
a clock that is not a multiple of 1 kHz this made the delay longer by
(rclk % 1000) / (rclk - rclk % 1000): 0.011% with a 1.8432 MHz clock,
e.g. 20002 instead of 20000 us at 50 baud.  Up to a divisor of 134 the
result is the same.  The delay is only a polling interval for
ns8250_drain() and the FIFO size probe.

    [7 lines not shown]
DeltaFile
+49-19sys/dev/uart/uart_dev_ns8250.c
+6-0sys/dev/uart/uart_dev_ns8250.h
+55-192 files

HardenedBSD/src b0cb5ad — sys/arm64/conf std.mediatek, sys/conf files.arm64

uart: Add MediaTek UART driver

The MediaTek UART is a 16550 with 32-bit spaced registers and a
fractional baud rate generator.  The driver gives that generator to the
ns8250 code through its set_baudrate, get_baudrate and get_divisor
functions, and uses the ns8250 code for everything else.  The low-level
console uses the ns8250 code too, so it keeps the rate the firmware set.

For the 30 MHz clock of Table 2-6 of the reference manual [1], the
divisor, SAMPLE_COUNT, SAMPLE_POINT and the number of extended bits are
the table's, except at 7200 baud, where one extended bit is closer than
the table's two.  Rates that need fewer than 8 samples per bit are
rejected: below that, the manual requires guard time from the sender.

Probe enables the clocks while it runs, attach applies the assigned
clocks and enables them, and detach releases them.  The console is
probed on the clocks the firmware left running and keeps its clocks on
detach.  Until there is an MT7986 pinctrl driver, UART1 and UART2 rely
on the firmware's pin setup.

    [9 lines not shown]
DeltaFile
+407-0sys/dev/uart/uart_dev_mtk.c
+3-0sys/arm64/conf/std.mediatek
+1-0sys/conf/files.arm64
+411-03 files

HardenedBSD/src 846ec9b — sys/arm64/conf GENERIC NOTES, sys/conf options.arm64

arm64: Add MediaTek SoC support skeleton

Add the SOC_MEDIATEK and SOC_MEDIATEK_MT7986 options, list them in
NOTES, add std.mediatek, include it in GENERIC and in a MEDIATEK kernel
configuration, and add a DTB module that builds the Banana Pi BPI-R3
(MT7986A) DTB.

Reviewed by:    mmel
Approved by:    markj (mentor)
Sponsored by:   Alchemilla Ventures Private Limited
Differential Revision:  https://reviews.freebsd.org/D61186
DeltaFile
+27-0sys/arm64/conf/MEDIATEK
+12-0sys/arm64/conf/std.mediatek
+5-0sys/modules/dtb/mediatek/Makefile
+2-0sys/conf/options.arm64
+2-0sys/arm64/conf/NOTES
+1-0sys/arm64/conf/GENERIC
+49-06 files

HardenedBSD/src bff1e7c — sys/conf files.arm64, sys/dev/clk/mediatek mt7986_infracfg.c

clk/mediatek: Add MT7986 INFRACFG clock and reset controller

INFRACFG provides the clock muxes and gates of the infrastructure
peripherals, and is their reset controller (the binding requires
#reset-cells).  It attaches after TOPCKGEN.

The gate and mux status registers are read-only (checked on a Banana
Pi BPI-R3), so gates and muxes are changed through their set and clear
registers.

The resets come in three banks, each with an assert register, a deassert
register at +4 and a status register at +8.  Reset id n is bit n % 32 of
bank n / 32.  Bank 0 at 0x70 is the one MediaTek's TF-A uses for the
TRNG [1].  Banks 1 (0x80) and 2 (0x90) were found on a Banana Pi BPI-R3
by resetting known blocks.

The clocks follow the MT7986 drivers of Linux [2] and U-Boot [3], which
were used for hardware facts only, with two changes:


    [19 lines not shown]
DeltaFile
+265-0sys/dev/clk/mediatek/mt7986_infracfg.c
+1-0sys/conf/files.arm64
+266-02 files

HardenedBSD/src 316e388 — sys/conf files.arm64, sys/dev/clk/mediatek mtk_clk_gate.c mtk_clk.h

clk/mediatek: Add common MediaTek clock and reset support

MediaTek SoCs split their clock tree over several controllers built from
the same blocks.  Add a base driver that maps a controller's registers
and registers its table of clocks, and the node types the tables use:

 - PLL with the MT7986 register layout: the rate is set by the
   frequency control word and the post divider.  A new control word is
   only taken over when the PLL is enabled, so a running PLL is stopped
   while its rate is changed, and a PLL that cannot stop keeps its rate.
   Without a lock bit, a PLL that was never programmed cannot be told
   from a stopped one, so the node has no gate: firmware starts the
   PLLs, and a PLL that is off reports 0 Hz and cannot be set.
 - Mux with an optional gate bit and an optional update latch, changed
   by read-modify-write or, where the mux register is read-only,
   through set/clear registers.
 - Gate, changed in the same two ways.

Clocks of other controllers are linked clocks, so the registration order

    [15 lines not shown]
DeltaFile
+227-0sys/dev/clk/mediatek/mtk_clk.c
+214-0sys/dev/clk/mediatek/mtk_clk_pll.c
+164-0sys/dev/clk/mediatek/mtk_clk_mux.c
+135-0sys/dev/clk/mediatek/mtk_clk.h
+112-0sys/dev/clk/mediatek/mtk_clk_gate.c
+6-0sys/conf/files.arm64
+858-06 files

HardenedBSD/src 49bd38b — sys/dev/uart uart_dev_ns8250.h uart_dev_ns8250.c

uart: Let ns8250 drivers provide their own baud rate generator

Add set_baudrate, get_baudrate and get_divisor function pointers to
struct ns8250_softc.  A driver for a UART with a baud rate generator of
its own sets them before calling ns8250_bus_attach(), which sets the
ones left NULL to the 16550 functions.  The param, ioctl, flush and
transmit methods use them, and ns8250_delay(), ns8250_drain() and
ns8250_flush() now take the softc to reach them.

While probing, the softc is not yet an ns8250_softc, so ns8250_delay()
uses the 16550 divisor when UART_BAS_IN_PROBE is set.  The low-level
console code, which has no softc, also uses the 16550 functions.

No functional change for existing drivers.

Reviewed by:    mmel
Approved by:    markj (mentor)
Sponsored by:   Alchemilla Ventures Private Limited
Differential Revision:  https://reviews.freebsd.org/D61611
DeltaFile
+42-18sys/dev/uart/uart_dev_ns8250.c
+14-0sys/dev/uart/uart_dev_ns8250.h
+56-182 files