FreeBSD/src 8302f09sys/riscv/riscv timer.c

riscv timer: fix interrupt handling.

Based on the spec the STIP bit of SIP register is read-only.

To clear STIP bit from supervisor we have to do an SBI call to firmware.
Upon reception of SBI request, the machine-mode firmware clears the STIP
bit in the MIP register.

This fixes operation on Codasip A730.

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D49487

(cherry picked from commit 6d58c670060a17817fa0c8ebf4e7543c3d2b4523)
DeltaFile
+2-2sys/riscv/riscv/timer.c
+2-21 files

FreeBSD/src 8501828sys/riscv/riscv timer.c

riscv: Fix SSTC extension support

From the SSTC spec:
"If the stimecmp (supervisor-mode timer compare) register is implemented,
then STIP is read-only in mip and reflects the supervisor-level timer
interrupt signal resulting from stimecmp. This timer interrupt signal
is cleared by writing stimecmp with a value greater than the current time
value."

This fixes operation in Spike with sstc extension enabled.
Example:
  spike --isa RV64IMAFDCH_zicntr_zihpm_sstc

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D45226

(cherry picked from commit ddd0d4f4cd65341a07bb3bb833dee7982018fd60)
DeltaFile
+5-2sys/riscv/riscv/timer.c
+5-21 files

FreeBSD/src 31eaa01sys/riscv/riscv timer.c

riscv timer: fix interrupt handling.

Based on the spec the STIP bit of SIP register is read-only.

To clear STIP bit from supervisor we have to do an SBI call to firmware.
Upon reception of SBI request, the machine-mode firmware clears the STIP
bit in the MIP register.

This fixes operation on Codasip A730.

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D49487

(cherry picked from commit 6d58c670060a17817fa0c8ebf4e7543c3d2b4523)
DeltaFile
+2-2sys/riscv/riscv/timer.c
+2-21 files

FreeBSD/src 4efc1b2sys/riscv/riscv timer.c

riscv: Fix SSTC extension support

From the SSTC spec:
"If the stimecmp (supervisor-mode timer compare) register is implemented,
then STIP is read-only in mip and reflects the supervisor-level timer
interrupt signal resulting from stimecmp. This timer interrupt signal
is cleared by writing stimecmp with a value greater than the current time
value."

This fixes operation in Spike with sstc extension enabled.
Example:
  spike --isa RV64IMAFDCH_zicntr_zihpm_sstc

Reviewed by:    mhorne
Differential Revision:  https://reviews.freebsd.org/D45226

(cherry picked from commit ddd0d4f4cd65341a07bb3bb833dee7982018fd60)
DeltaFile
+5-2sys/riscv/riscv/timer.c
+5-21 files

FreeBSD/src 6d83ae1share/man/man4 Makefile, share/man/man9 Makefile

share/man/man[49]: Set PACKAGE=kernel-man

When MANSPLITPKG is disabled (which is now the default), the kernel
manpages in sections 4 and 9 are installed in the -kernel package
instead of the -kernel-man package, because bsd.man.mk doesn't add
the -man suffix.

Since we already have handling for kernel-man in generate-ucl.lua,
set PACKAGE=kernel-man to make sure they're always in the right
package.

To avoid creating -kernel-man-man when WITH_MANSPLITPKG is enabled,
add some logic to bsd.man.mk (suggested by kevans) to avoid adding
the -man suffix if the package already has a -man suffix, and while
here, ensure ${__group}PACKAGE is always defined.

MFC after:      3 seconds
Reviewed by:    des, bapt
Differential Revision:  https://reviews.freebsd.org/D52525
DeltaFile
+4-3share/mk/bsd.man.mk
+1-1share/man/man4/Makefile
+1-1share/man/man9/Makefile
+6-53 files

FreeBSD/src a75c3c2share/man/man4 Makefile

udbc(4): connect to build

Reviewed by:    thj
MFC with:       d566b6a70bcbc329e8c690464043401fa8bdd49f
Sponsored by:   The FreeBSD Foundation
DeltaFile
+1-0share/man/man4/Makefile
+1-01 files

FreeBSD/src 18fd144sbin/ifconfig ifconfig.8 ifconfig.c

ifconfig: Enter jail as soon as possible

Some options (in particular, -g) are processed immediately upon being
parsed.  This will produce the wrong result in combination with -j since
we only attach to the jail after we're done parsing arguments.  Solve
this by attaching to the jail immediately when -j is encountered.  The
downside is that e.g. `ifconfig -j foo -j bar` would previously attach
to jail “bar”, whereas now it will attempt to attach to jail “foo”, and
if successful, attempt to attach to jail “bar” within jail “foo”.  This
may be considered a feature.

PR:             289134
MFC after:      1 week
Reviewed by:    zlei
Differential Revision:  https://reviews.freebsd.org/D52501
DeltaFile
+20-20sbin/ifconfig/ifconfig.8
+8-14sbin/ifconfig/ifconfig.c
+0-1sbin/ifconfig/ifconfig.h
+28-353 files

FreeBSD/src e8b5025sys/dev/sound/pcm dsp.c channel.h

sound: Honor CHN_F_NBIO

If the device is opened with O_NONBLOCK, even though we check for it in
order to set CHN_F_NBIO, the subsequent chn_reset() calls will clear all
flags, except those set in CHN_F_RESET, which does not include
CHN_F_NBIO.

Add CHN_F_NBIO to CHN_F_RESET. Additionally, because primary channels
can be reused, make sure we do not unintentionally keep CHN_F_NBIO set
if the channel is re-opened, but without O_NONBLOCK.

PR:             289441
MFC after:      2 days
Reviewed by:    christos, markj
Differential Revision:  https://reviews.freebsd.org/D52493
DeltaFile
+2-2sys/dev/sound/pcm/dsp.c
+1-1sys/dev/sound/pcm/channel.h
+3-32 files

FreeBSD/src 246d7e9sys/kern kern_jail.c, sys/security/audit audit_syscalls.c

jail: Optionally allow audit session state to be configured in a jail

Currently it is impossible for a privileged, jailed process to set audit
session state.  This can result in suprising audit event misattribution.
For example, suppose a user ssh'es into a jail and restarts a service;
normally, sshd sets audit state such that events generated by the SSH
session are attributed to the newly authenticated user, but in a jail,
the corresponding setaudit(2) call fails, so events are attributed to
the user who had started sshd in the jail (typically the user who had
started the jail itself by some means).

While this behaviour is reasonable, administrators might want to trust
the jailed sshd to reset audit state, such that the authenticated user
appears in audit logs.  Add a jail knob to enable this.  Add a simple
regression test.

Reviewed by:    kevans, jamie
MFC after:      1 week
Sponsored by:   Modirum MDPay

    [2 lines not shown]
DeltaFile
+20-0usr.sbin/jail/tests/jail_basic_test.sh
+15-4usr.sbin/jail/jail.8
+12-1sys/kern/kern_jail.c
+0-12sys/security/audit/audit_syscalls.c
+2-1sys/sys/jail.h
+49-185 files

FreeBSD/src cd02a8asys/netinet6 ip6_input.c, tools/regression/sockets/udp_pingpong udp_pingpong.c

ip6: add SO_BINTIME support

This adds support for obtaining timestamps from IPv6 packets using the
SO_BINTIME socket option, bringing it in parity with IPv4 behavior.

Enable testing the SO_BINTIME option in the relevant (manual) regression
test.

PR:             289423
Reviewed by:    markj
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D52504
DeltaFile
+37-18sys/netinet6/ip6_input.c
+3-5tools/regression/sockets/udp_pingpong/udp_pingpong.c
+40-232 files

FreeBSD/src b0469fasys/compat/linuxkpi/common/src linux_80211.c

LinuxKPI: 802.11: avoid recursive wiphy lock

When freeing the last reference of the net80211 node the net80211
node_free() code may directly call into the crypto code to delete
the keys.  While we still holding the wiphy lock this would lead to
a recursion on the non-recursive wiphy lock.  Defer freeing the
reference until we are back under the net80211 com lock.

Reported by:    Mark Phillips (mark freebsdfoundation.org) on 15.0-ALPHA1

(cherry picked from commit 3c38dce87ecd2c87744e4b7ff1904ee841f88a47)
DeltaFile
+36-18sys/compat/linuxkpi/common/src/linux_80211.c
+36-181 files

FreeBSD/src f20a09esys/compat/linuxkpi/common/include/linux device.h, sys/compat/linuxkpi/common/src linux_devres.c

LinuxKPI: devres: divorce dem_kfree from lkpi_devm_kmalloc_release

dem_kfree() is called from all over the place and should actually
do something;  contrary to lkpi_devm_kmalloc_release() it can also
take a const void *.  We have to __DECONST() that though as the
entire devres framework does otherwise not take a const argument.

This was discovered during the rtw89 upadte to 6.16.

Sponsored by:   The FreeBSD Foundation (initially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52082

(cherry picked from commit 4ab64e34911ab06e567caaf07ed18f7770a61cc8)
DeltaFile
+25-1sys/compat/linuxkpi/common/src/linux_devres.c
+3-2sys/compat/linuxkpi/common/include/linux/device.h
+28-32 files

FreeBSD/src 88122c8sys/compat/linuxkpi/common/include/linux math64.h

LinuxKPI: maths64: implement roundup_u64()

Needed by a wifi driver update.

Sponsored by:   The FreeBSD Foundation (initially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52080

(cherry picked from commit 2a44e10edb13e6b2be7fa2814b418a6959cb1171)
DeltaFile
+6-0sys/compat/linuxkpi/common/include/linux/math64.h
+6-01 files

FreeBSD/src 3753913sys/compat/linuxkpi/common/include/kunit static_stub.h, sys/compat/linuxkpi/dummy/include/kunit test-bug.h skbuff.h

LinuxKPI: kunit: add static_stub.h and more dummy headers

These came up during a wifi driver update.

Sponsored by:   The FreeBSD Foundation (initially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52079

(cherry picked from commit 7c473933624f701263a83da526cac680b1ca69ed)
DeltaFile
+15-0sys/compat/linuxkpi/common/include/kunit/static_stub.h
+0-0sys/compat/linuxkpi/dummy/include/kunit/test-bug.h
+0-0sys/compat/linuxkpi/dummy/include/kunit/skbuff.h
+0-0sys/compat/linuxkpi/dummy/include/kunit/test.h
+15-04 files

FreeBSD/src cd2bd8bsys/compat/linuxkpi/common/include/linux overflow.h

LinuxKPI: sync overflow.h from Linux v6.16

It seems overflow.h wsa imported directly from Linux in 3208d4ad2b8320a.
Update the file to the newer version as needed for wireless driver updates.

Sponsored by:   The FreeBSD Foundation (initially)
Obtained from:  git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
                038d61fd642278 (tag: v6.16)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52078

(cherry picked from commit 70c508e691de1ed0f70b4a6f0773bfb5d627050d)
DeltaFile
+157-31sys/compat/linuxkpi/common/include/linux/overflow.h
+157-311 files

FreeBSD/src 310885bsys/compat/linuxkpi/common/include/linux compiler.h

LinuxKPI: add __struct_size

Use __builtin_object_size() by default.
If __builtin_dynamic_object_size() is available use that instead.

I would hope that in a future version we can remove the conditional
checks but in order to be able to MFC this without checking all
compiler versions simply keep it this way for now.

Sponsored by:   The FreeBSD Foundation (initially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52077

(cherry picked from commit ff5bcb742899f8398ccb1b9e292b2e5aeeb7fedb)
DeltaFile
+6-0sys/compat/linuxkpi/common/include/linux/compiler.h
+6-01 files

FreeBSD/src 4d5a78csys/compat/linuxkpi/common/include/linux cleanup.h rcupdate.h

LinuxKPI: add DEFINE_LOCK_GUARD_0 for rcu

This adds guard support for non-real-types like rcu locking meaning
that we need to keep the lock state separately ourselves.  _T is still
special and needs to be updated.  Given it may not be used it needs
an __unused attribute (we are using the LinuxKPI __maybe_unused which
indeed is more expressive in this case).

Sponsored by:   The FreeBSD Foundation (initially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52076

(cherry picked from commit 3f48a0fe53ca7e001852f4a406c1bdfab1cd2f6d)
DeltaFile
+35-0sys/compat/linuxkpi/common/include/linux/cleanup.h
+4-1sys/compat/linuxkpi/common/include/linux/rcupdate.h
+39-12 files

FreeBSD/src 830cc67sys/compat/linuxkpi/common/include/linux cleanup.h slab.h

LinuxKPI: cleanup: implement __free() and DEFINE_FREE(); use for kfree()

A wifi driver update needs this.

Sponsored by:   The FreeBSD Foundation (initially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52075

(cherry picked from commit 39e9290d890b2aa07b68f2fe956b96e5df9a1da2)
DeltaFile
+13-1sys/compat/linuxkpi/common/include/linux/cleanup.h
+4-0sys/compat/linuxkpi/common/include/linux/slab.h
+17-12 files

FreeBSD/src 8819856sys/compat/linuxkpi/common/include/linux timer.h, sys/compat/linuxkpi/common/src linux_compat.c

LinuxKPI: timer KPI *_timer -> timer_*

del_timer() got renamed to timer_delete() approximately in Linux 6.2
(similar for *_sync and likely others).
Keep the old functions as compat; unclear when we can gc them.
We should also re-define them with a linuxkpi_ prefix to avoid possible
conflicts in the future if we do a full pass over this at some point.

Sponsored by:   The FreeBSD Foundation (intiially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52074

(cherry picked from commit 5cb64a1d3fe75526fb879ef4dce5860bbb4e4aea)
DeltaFile
+14-2sys/compat/linuxkpi/common/include/linux/timer.h
+2-9sys/compat/linuxkpi/common/src/linux_compat.c
+16-112 files

FreeBSD/src 352be5bsys/compat/linuxkpi/common/include/linux timer.h, sys/compat/linuxkpi/common/src linux_80211.c

LinuxKPI: rename from_timer() to timer_container_of()

With Linux 6.16 from_timer() got renamed to timer_container_of(); add
the LINUXKPI_VERSION check with a default to the current version.
Update all in-tree consumers (apart from wireless drivers managed
otherwise).

Sponsored by:   The FreeBSD Foundation (initially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52073

(cherry picked from commit 81cb7c4c8e7bc4951c77fe64a63a847ed6abee38)
DeltaFile
+5-0sys/compat/linuxkpi/common/include/linux/timer.h
+2-2sys/dev/irdma/irdma_utils.c
+1-1sys/dev/irdma/irdma_cm.c
+1-1sys/compat/linuxkpi/common/src/linux_80211.c
+1-1sys/dev/qat/qat_common/adf_gen4_timer.c
+10-55 files

FreeBSD/src aa673b7sys/compat/linuxkpi/common/include/acpi acpi.h

LinuxKPI: acpi; fix type to acpi_get_handle()

The native AcpiGetHandle() and acpi_get_handle() take a
const char * argument for pathname and not an acpi_string (char *).
For that they spell it out fully as 'const char *', so should we.

Sponsored by:   The FreeBSD Foundation (intially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52072

(cherry picked from commit c1264b6238c97810849bc38818d27c1ade1d4fc1)
DeltaFile
+1-1sys/compat/linuxkpi/common/include/acpi/acpi.h
+1-11 files

FreeBSD/src ab45c85sys/compat/linuxkpi/common/include/linux math.h

LinuxKPI: correct the LINUXKPI_VERSION check for abs_diff()

The code introduced abs_diff() as migrated from drm to standard
linux headers.  The LINUXKPI_VERSION check did not allow this to
be visible by default in-tree.  Make sure the v6.6 check is optional.
drm-kmod always defines LINUXKPI_VERSION so this should be fine.

Sponsored by:   The FreeBSD Foundation (initially)
Fixes:          afc450fac9f04
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52071

(cherry picked from commit 736b16e88d2384f9dd0ec11c0492e825b8d42193)
DeltaFile
+1-1sys/compat/linuxkpi/common/include/linux/math.h
+1-11 files

FreeBSD/src 8fca574sys/compat/linuxkpi/common/src linux_pci.c

LinuxKPI: pci: allow children to be attached to a pci_dev

This will be used for hooking suspend/resume in for LinuxKPI 802.11
based drivers.

Sponsored by:   The FreeBSD Foundation (initially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52070

(cherry picked from commit 627234627b51c2f12c29d10617d7bbd18936ea55)
DeltaFile
+3-0sys/compat/linuxkpi/common/src/linux_pci.c
+3-01 files

FreeBSD/src ff31767sys/compat/linuxkpi/common/include/linux pci.h, sys/compat/linuxkpi/common/src linux_pci.c

LinuxKPI: pci: implement [linuxkpi_]pcim_request_all_regions()

Factor out the pci_request_region() implementation into an internal
function and make pci_request_region() a simple wrapperaround it.
Likewise implement pcim_request_all_regions() as a loop calling
pci_request_region() for each entry.

In two cases which we returned an error before (bar index is valid but
bar is not (no len), and neither IO nor MEM) we now reutrn success
(nothing to do for us).  Otherwise callers, especially
pcim_request_all_regions() would error out for the wrong reasons.
This seems to also match the expected behaviour of pci_request_region().

Sponsored by:   The FreeBSD Foundation (intially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52068

(cherry picked from commit 7e21158d44cd46e720395604ca6f00f2fa36b20c)
DeltaFile
+48-7sys/compat/linuxkpi/common/src/linux_pci.c
+8-3sys/compat/linuxkpi/common/include/linux/pci.h
+56-102 files

FreeBSD/src cfb8f4bsys/compat/linuxkpi/common/include/linux pci.h, sys/compat/linuxkpi/common/src linux_pci.c

LinuxKPI: pci: implement pcim_iomap()

Like pci_iomap() add the devres version pcim_iomap() using the former
to get the resource.

Add a helper function to validate that the bar is within a valid range
and sprinkle that check also to other related functions.

Sponsored by:   The FreeBSD Foundation (intially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52067

(cherry picked from commit 2f9064a5d2b50f292cc8699d2be5c66c317f1dc7)
DeltaFile
+56-2sys/compat/linuxkpi/common/src/linux_pci.c
+3-0sys/compat/linuxkpi/common/include/linux/pci.h
+59-22 files

FreeBSD/src 68f8fa4sys/compat/linuxkpi/common/include/linux pci.h, sys/compat/linuxkpi/common/src linux_pci.c

LinuxKPI: pci: implement for_each_pci_dev() and improve pci_get_device()

Implement for_each_pci_dev() needed by a wireless driver update.
For that also improve pci_get_device() and add the functionality to
support the odev argument to start searching from that.

Sponsored by:   The FreeBSD Foundation (intially)
Reviewed by:    dumbbell
Differential Revision:  https://reviews.freebsd.org/D52066

(cherry picked from commit 910cf345d0ee9a5d72856a1ba35382eb4f0db951)
DeltaFile
+9-3sys/compat/linuxkpi/common/src/linux_pci.c
+3-0sys/compat/linuxkpi/common/include/linux/pci.h
+12-32 files

FreeBSD/src d566b6ashare/man/man4 udbc.4, sys/dev/usb/serial udbc.c

udbc: Add usb debug host mode driver

xhci offers a debugging interface which uses a special usb 3 cable with the D+,
D- and VBUS pairs disconnected. This interface allows a target device to
configure its xhci controller as a debugging channel which can then be used to
provide a serial link between the target and a debug host.

This change extracts the udbc host mode driver from hrs@'s xhci debug
implementation.

Reviewed by:    bcr (man page)
MFC after:      Before 15-ALPHA3 builds
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D51299
DeltaFile
+404-0sys/dev/usb/serial/udbc.c
+132-0share/man/man4/udbc.4
+9-0sys/modules/usb/udbc/Makefile
+3-4sys/modules/usb/Makefile
+548-44 files

FreeBSD/src f1b656fsys/vm vm_fault.c

vm_fault_busy_sleep(): update comment after addition of allocflags arg

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D52538
DeltaFile
+4-5sys/vm/vm_fault.c
+4-51 files

FreeBSD/src 081f0e3sys/contrib/openzfs/module/zfs vdev_raidz.c

zfs: Use the correct type for raidz_outlier_check_interval_ms

raidz_outlier_check_interval_ms has type hrtime_t, which is a long long,
which is 64 bits wide on all supported platforms.
DeltaFile
+1-1sys/contrib/openzfs/module/zfs/vdev_raidz.c
+1-11 files

FreeBSD/src 18fd3f8sys/netgraph/bluetooth/socket ng_btsocket_rfcomm.c

ng_btsocket_rfcomm: Mark a couple buffers as const in a helper function

Fixes:  680f9acc3657 ("ng_hci: Cast NG_HCI_BDADDR_ANY to const bdaddr_t *")
DeltaFile
+2-2sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
+2-21 files