310119 Commits

Author SHA1 Message Date
chersbobers fa3531fc47 Update README.md 2026-06-17 00:10:08 +00:00
chersbobers d886b7b242 brand: Update readme with credits and changes. 2026-06-15 19:16:09 +12:00
chersbobers 5e674e848e brand: Edited files and removed bloat. 2026-06-15 18:53:37 +12:00
Kevin Lo fa75c1cc24 mwl: return ENOMEM when rx buffer allocation fails
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Has been cancelled
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Has been cancelled
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Has been cancelled
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Has been cancelled
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Has been cancelled
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Has been cancelled
The malloc() failure path returned error, which is 0 at this point,
so callers would treat the allocation failure as success.
Return ENOMEM instead to correctly propagate the out-of-memory condition.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D42282
2026-06-15 09:43:57 +08:00
Jim Huang Chen db887713de kldload: Improve error handling
Address a failure in linker_load_module (sys/kern/kern_linker.c) to
verify that an already-loaded module matches the version requirement,
which caused the method to return the error (EEXIST).  This was then
propagated back up to kldload, which incorrectly printed that the module
had already been loaded.

Add a lookup to modlist_lookup2 to distinguish between the two cases:
- A module is already loaded that is of the correct version, so the
  error EEXIST should be returned
- An already-loaded module is of the incorrect version, so the error
  ENOEXEC is returned (changed from ENOENT)

Reviewed by:	imp, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57002
2026-06-14 19:45:50 -04:00
Bjoern A. Zeeb 1c601bf516 LinuxKPI: 802.11: lock down mac80211 downcalls
Add lock assertions and "might_sleep" annotations to various
mac80211 operation downcalls into the driver.

Make sure the code to these is all covered by locks--pushing more wiphy
lock into the code--or lock assertions as well.  Split up parts of the
MC code up into an unlocked and locked version to avoid recurive locking.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-06-14 22:56:20 +00:00
Bjoern A. Zeeb 134e90e01d mt76: mt7921: depend on lindebugfs and turn debugfs support on
Add the missing MODULE_DEPEND() calls for lindebugfs.
It is unfortunate that they are shared code between various bus
implementations.  Ideally we would leave the MODULE_DEPEND() calls
in the debugfs.c file instead of adding extra #ifdef guards to the
bus attachment files.

Turn debugfs support on for mt76(core) and the mt7921 module for now.

Sponsonred by:	The FreeBSD Foundation
MFC after:	3 days
2026-06-14 22:55:53 +00:00
Bjoern A. Zeeb b662295ecb mt76: mt7921: terminate fw log messages with \n
In order to make the firmware messages spewed on the console readable
write one message per line and not one very long line.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-06-14 22:55:23 +00:00
Bjoern A. Zeeb baf8561bdc mt76: ensure net80211 com instance before returning from driver load
Do as we have done for iwlwifi (f808c43ad9,  bee60c9897) add a
completion event for device registration which calls into 802.11
and creates the wifi "device" (net80211 com instance).
This is needed as otherwise the deferred work in the mt76 drivers
(mt7915, mt7921, mt7925, mt7996; but not the 7615 [*]) would make
driver loading return before the wifi device is there.  We would then
continue, e.g., during rc startup and race possibly trying to create
a vap (wlan interface) with the underlying device not being registered
yet and fail.

[*] the 7615 does not seem to do this asynchronously so is fine.

Sponsored by:	The FreeBSD Foundation
Tested on:	7921, others to be tested at time
MFC after:	3 days
2026-06-14 22:55:14 +00:00
Bjoern A. Zeeb b8ec4929e9 callout: ddb: resolve symbol of callout function
In the ddb show callout function try to resolve the symbol of the
callout function to improve debugging.  In my case I went through
various callouts from show ktr to check what they were and this saved
me opening lldb/gdb next to it (and still having the old kernel as
the panic to debug was upon reboot).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	rlibby
Differential Revision: https://reviews.freebsd.org/D57521
2026-06-14 22:31:39 +00:00
Bjoern A. Zeeb 84008e34ce lindebugfs: improve an error message
In case the fill function fails do not report (read/write) but the
actual operation only given we can easily determine it.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell, emaste
Differential Revision: https://reviews.freebsd.org/D57523
2026-06-14 22:31:38 +00:00
Bjoern A. Zeeb 3fa40c5eb8 linudebugfs: fix simple_attr_write_common() kernel buffer
With 2cf15144da we added a kernel buffer for parsing input copying the
user buffer into that.  The problem is that we only copy exactly as many
bytes as the user supplied.  printf 1 would have a write_size of 1, while
echo 1 would have a write_size of 2 (1\n).  But in order to check and
parse we need a terminating '\0'.

Overallocate the kernel buffer by 1 and make sure it is always '\0'
terminated.

Remove the check that the string needs to be of different length than
the write_size as this will always fail unless the user passes in, e.g.,
"1\02\n\0" somehow in which case we won't bother as kstrto*ll() will
not only handle the '\n' but also stop at '\0' and should be fine or
it will fail and we will error.

In theory we could use a static buffer here as well as we know a maximum
possible length of digits plus \n and \0 and take a min of that buffer
length and write_size and then error on a small buffer but given this is
an optional debug interface, do not bother with any alloc (size).

Fixes:		2cf15144da ("lindebugfs: Pass user buffer pointers ..")
Sponsored by:	The FreeBSD Foundation
Reviewed by:	dumbbell
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D57522
2026-06-14 22:31:38 +00:00
Bjoern A. Zeeb 009d92b25f mt76: mt7921: prevent PM from scheduling another delayed work on detach
Amongst others mt76_connac_pm_unref() is calling mt76_connac_power_save_sched()
which will (normaly) re-schedule the pm_work.
In various parts we also cancel that work, also during PCI detach ("shutdown",
"remove" in LinuxKPI terms).
However we also keep calling mt76_connac_pm_unref() in the detach path and thus
we get to a point where we re-scheduled the work but then the device goes away.
At that point LinuxKPI delayed work has a callput pending which is embedded in
the work structure (pm_work).  The moment we free the device that structure
and callout is gone but the callout is still on the list and once that list
is walked we panic.

Simply prevent mt76_connac_power_save_sched() from getting to the point of
possibly re-scheduling the pm_work by setting pm->enable to false in the
beginning of the detach path.

The are likely more paths which will need the same treatment as the code
is by far anything from "symmetric" (that is the attach path is highly
bus independent while the detach path is implemented per-bus).  Also
other chipsets share the same "logical paths" with their own names, so
they will need this too once we get to them.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-06-14 22:31:38 +00:00
Bjoern A. Zeeb 31ded414b1 LinuxKPI: 802.11: force update of net80211 crypto key flags
Several drivers (rtw8x, mt76) do not announce the supported ciphers suites
in the wiphy instance.  This means we never populate net80211 ic_cryptocaps
on device creation and thus not announcing any supported hw crypto
offload forcing a fallback to software crypto.

However when the mac80211 (*set_key) succeeds we know we can offload
crypto.  At that point the net80211 key flags have IEEE80211_KEY_SWCRYPT
set which we want to clear.  Historically the net80211 API does not
allow this though there should be no ill side effects (base on a
quick code inspection).  We thus have to DECONST the key argument
for now.  It is expected that with MFP support this will need to
become a common operation and the API will need to change as we
will only get the information of some details from the driver on a
per-cipher case when the (*set_key) downcall returns.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-06-14 22:31:38 +00:00
Bjoern A. Zeeb ff6c95d2c2 LinuxKPI: 802.11: improve hw_crypto key operations
mt7921 would happily receive traffic (MC/BC) and decrypt it correctly
when hw_crypto was used but TX would only have garbled data in frames.

The problem came from the fact with keys for which we do not have an
address the driver will pick the "sta" information from different places
(driver view of sta or vif).
In the downcall this is signalled by the sta argument being NULL as
the linux keyconf has no address field.

Us passing the sta for first the pairwise key and then also for the
group key likely overwrote the pairwise key on the sta and allowed
the MC/BC RX operations to succeed anyway (the observed behaviour).

Software crypto was fully fine for mt7921 and showed no problems.

Looking some other drivers:
- iwlwifi/mld picks the ap_sta if the sta argument is NULL; thus it
  always worked with our previous logic and this went unnoticed.
- rtw88 in rtw_sec_write_cam() decides whether to use the sta address
  or a broadcast address.
- rtw89 in rtw89_cam_attach_sec_cam() picks the rtwsta_link if sta is
  not NULL and has follow-up logic checking on that.

It is yet unclear if some of the MC problems observed on rtw8x
stem from the same problem.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-06-14 22:31:37 +00:00
Bjoern A. Zeeb f54e9d1b29 LinuxKPI: 802.11: set undefined link in TX control info
We are not doing MLO yet so set the undefined link bit in the
TX info control message in case a driver checks if the TX would be
link specific.

Sposnored by:	The FreeBSD Foundation
MFC after:	3 days
2026-06-14 22:31:37 +00:00
Bjoern A. Zeeb 0cb3b92298 LinuxKPI: 802.11: add print masks for tx status flags
Add print masks for tx status flags and use them in the TX tracing
in order to more easily debug TX problems.

As a result it was easier to determine that some dirver like the mt7921
(or mt76) do not always zero the status bits of the tx status information
(it is a union with the control bits passed on TX) and thus we get bogus
values back (rather than having flags in a different place than we thought).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-06-14 22:31:37 +00:00
Abdelkader Boudih 142cba958b bge: read MAC from loader hint for boards without NVRAM/EEPROM
BCM57766 on Apple T2 Macs (Macmini8,1) has no dedicated EEPROM and the
chip firmware handshake fails (the T2 intercepts PCI config space),
leaving the SRAM mailbox unpopulated.  All four existing MAC retrieval
paths (SRAM mailbox, NVRAM, EEPROM, firmware stub) fail, causing bge to
abort attach with "failed to read station address".

Work around this with two changes:

  1. Tolerate EEPROM read failure on BCM57766.  The chip is copper-only
     so hwcfg=0 is correct; skip the fatal error that aborts attach
     before bge_get_eaddr() is ever called.

  2. Implement bge_get_eaddr_fw() to read a "hint.bge.N.mac" string
     (e.g. "f0:18:98:f4:1e:2f") from loader(8) tunable / kenv.

This is a workaround until the T2 BCE API is understood well enough to
either poke the chip firmware into completing its handshake or read the
MAC from the T2 directly.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D57090
2026-06-14 13:56:59 -07:00
Abdelkader Boudih e37e49bfaa asmc: fix asmc_key_dump() page fault on T2 MMIO backend
asmc_key_dump() used I/O port macros (ASMC_DATAPORT_WRITE/READ,
asmc_command()) unconditionally. On T2 Macs, sc_ioport is NULL
(MMIO backend is used instead), causing a page fault when
ASMC_DEBUG triggers asmc_dumpall() during attach.

Add an MMIO guard at the top of asmc_key_dump(): delegate to
asmc_key_dump_by_index() + asmc_key_read() for MMIO devices,
consistent with the rest of the T2 code paths.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D56748
2026-06-14 13:56:56 -07:00
Abdelkader Boudih 9f90536c74 apple_bce/vhci: add T2 virtual USB host controller
Implements a VHCI driver on top of the BCE transport:
- Virtual USB bus registration via usb_controller
- Port discovery and device enumeration
- Control, interrupt, and bulk endpoint support
- Firmware event handling with taskqueue
- Suspend/resume via BCE mailbox

Provides keyboard, trackpad, and Touch Bar access on T2 Macs.

Tested-on: MacBookPro16,2 (A2251), Mac mini 8,1 (A1993)

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D57089
2026-06-14 13:56:53 -07:00
Abdelkader Boudih 6fd2ad9aa3 apple_bce: add Apple T2 Buffer Copy Engine driver
DMA ring transport between the host and the T2 coprocessor.
Provides mailbox handshake, queue setup, and firmware keepalive
for higher-level T2 services (VHCI, audio, etc.).

Tested-on: MacBookPro16,2 (A2251), Mac mini 8,1 (A1993)

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D57088
2026-06-14 13:56:50 -07:00
Abdelkader Boudih 5e0ba47aa0 nvme: add Apple T2 ANS2 NVMe quirks
The Apple T2 (ANS2, PCI 106b:2005) requires several quirks:

- 128-byte submission queue entries (CC.IOSQES = 7)
- Single MSI vector, one IO queue
- Admin and IO queues share a CID table; IO CIDs offset by
  adminq.num_trackers to avoid overlap
- No async event support
- IDENTIFY CNS >= 2 rejected to avoid firmware confusion

Tested-on:
- MacBookPro16,2 (A2251)
- Mac mini 8,1 (A1993)
- Multiple Non-Apple computers

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D57087
2026-06-14 13:56:43 -07:00
Baptiste Daroussin a74c77cc7b grep(1): optimize -w/--word-regexp word boundary check
The -w option checks word boundaries before and after each potential
match by decoding the adjacent character.  This was done via the
heavyweight sscanf(3) with "%lc", which goes through the full scanf
parser and locale-aware mbrtowc(3) machinery even for simple ASCII.

Replace with a three-tier fast path:

1. ASCII bytes (< 0x80): simple isalnum(3) / '_' comparison
2. UTF-8 continuation bytes (0x80-0xBF): interior bytes of a multi-byte
   character are always word characters -> no further decoding needed
3. Multi-byte start bytes (>= 0xC0): decode with mbrtowc(3) directly
   instead of sscanf(3)/%lc, avoiding scanf parser overhead

Benchmark with ministat(1) (10 runs each):

Worst-case ASCII (100k lines of 100 'a' chars, -w 'a'):
    Difference at 95.0% confidence: -15.3% +/- 3.1%

Worst-case Unicode (50k lines of 100 accented 'e', -w 'e'):
    Difference at 95.0% confidence: -11.2% +/- 4.7%

Normal -w (500k lines, -w 'the'):
    Difference at 95.0% confidence: -18.1% +/- 3.6%

French text (100k lines, -w accented 'ete'):
    Difference at 95.0% confidence: -18.0% +/- 4.1%

Non -w case shows no regression.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D57587
2026-06-14 20:14:31 +02:00
Alan Somers b4af6a4ccc fusefs: fix error handling when reading a directory's sticky bit
When trying to delete or rename a file, fuse_vnop_lookup must check
whether its parent directory's sticky bit is set.  Realistically, the
parent directory's attributes will almost always be cached.  But it's
possible that they won't be, and in that case we must send a new
FUSE_GETATTR request to the server.  If that request fails for some
reason, then we must fail the lookup.  Prior to this change fusefs would
ignore failure of that request.

Reported by:	Yuxiang Yang, Yizhou Zhao, Ao Wang, Xuewei Feng, Qi Li,
                and Ke Xu of Tsinghua University
MFC after:	2 weeks
Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D57588
2026-06-14 11:55:22 -06:00
Haoxiang Li 836d0d341a arm/bcm2835: Release mailbox resources on attach failure
Also remove the rid variable since it was unused.

Signed-off-by:	Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Reviewed-by:	vexeduxr
Pull-Request:	https://github.com/freebsd/freebsd-src/pull/2255
2026-06-14 19:51:04 +03:00
Haoxiang Li 39217ebb8a arm: allwinner: Fix A10 INTC MMIO resource cleanup
Do not jump to the resource release path when bus_alloc_resource_any()
fails, since no MMIO resource was allocated. If a10_intr_pic_attach()
fails after the MMIO resource has been allocated, release it before
returning.

Signed-off-by:	Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Reviewed-by:	vexeduxr
Pull-Request:	https://github.com/freebsd/freebsd-src/pull/2253
2026-06-14 19:51:04 +03:00
Quentin Thébault 746c374aa9 evdev: add devnum sysctl
Add a sysctl entry for the evdev device number (devnum) to allow
libudev-devd to populate the corresponding device information
fields (MAJOR and MINOR) when running in a jail with no input devices
exposed through devfs.

Signed-off-by: Quentin Thébault <quentin.thebault@defenso.fr>

Reviewed by:	wulf
Sponsored by:	Defenso
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D56968
2026-06-14 11:34:51 -05:00
Ahmad Khalifa 2e1f5b7897 loader.efi(8): document the ia32 loader
Reviewed by:	kib
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D57569
2026-06-14 19:26:30 +03:00
Ahmad Khalifa f771deb193 loader.efi(8): the amd64 loader doesn't do protected mode
The amd64 UEFI loader executes in long mode, not protected mode.

Reviewed by:	kib
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D57568
2026-06-14 19:26:16 +03:00
Baptiste Daroussin ffe47c424e grep: periodic timer-based fflush instead of unconditional per-line flush
Replace the unconditional fflush(stdout) in grep_printline and
procmatches with a periodic timer that flushes at most once every
100ms.  This preserves interactive responsiveness (grep | tee,
grep | tail -f) while avoiding 1M+ write(2) syscalls when
processing large inputs.

The flush interval is tracked via clock_gettime(CLOCK_MONOTONIC)
and a static timespec.  --line-buffered continues to flush
immediately via setlinebuf(3), as before.

Benchmark on 1M lines (37MB output to file):
  unconditional fflush:  1.90s  (sys 1.22s)
  periodic 100ms timer:   0.49s  (sys 0.007s)

Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D57528
2026-06-14 16:26:30 +02:00
Gordon Bergling 8a13adf80c d.7: Correct a few typos in the manual page
- s/occurance/occurrence/
- s/Univeristy/University/

MFC after:	5 days
2026-06-14 11:36:36 +02:00
Gordon Bergling 89234ff7bd umass.4: Correct a typo in the manual page
- s/Sotrage/Storage/

MFC after:	5 days
2026-06-14 11:34:06 +02:00
Gordon Bergling f257497856 acpi(4): Fix a typo in a source code comment
- s/freqency/frequency/

MFC after:	3 days
2026-06-14 10:52:48 +02:00
Gordon Bergling 58cf810066 clk: Fix a typo in a source code comment
- s/freqency/frequency/

MFC after:	3 days
2026-06-14 10:51:59 +02:00
Gordon Bergling 0ea84e9cce et(4): Fix a typo in a source code comment
- s/Diable/Disable/

MFC after:	3 days
2026-06-14 10:50:59 +02:00
Gordon Bergling 6280a06300 qcom_clk: Fix a typo in a source code comment
- s/freqency/frequency/

MFC after:	3 days
2026-06-14 10:50:02 +02:00
Gordon Bergling 54e4b9c9fa ufshci(4): Fix a typo in a source code comment
- s/Diable/Disable/

MFC after:	3 days
2026-06-14 10:48:18 +02:00
Gordon Bergling dd8ba1f2fc sdhci(4): Fix a typo in a source code comment
- s/freqency/frequency/

MFC after:	3 days
2026-06-14 10:47:14 +02:00
Gordon Bergling 49ced8d765 aic7xxx: Fix two typos in source code comments
- s/Diable/Disable/
- s/connonical/canonical/

MFC after:	3 days
2026-06-14 10:45:52 +02:00
Konstantin Belousov 59b0df3441 linux_ntsync(9): check the file type before calling native ntsync(9)
Reported by:	Alex S <iwtcex@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-06-14 07:11:08 +03:00
Konstantin Belousov 64467d2ec3 vnode: move VIRF_KNOTE to v_v2flag
The semantic of the flag has the natural march to the code scope that is
protected by the vnode lock.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D56912
2026-06-14 05:08:20 +03:00
Konstantin Belousov da6aa0648c struct vnode: assign v_rl.resv1 as v_type and v_rl.resv2 as v_state
Use the avaliable space to introduce vnode-locked flag v_v2flag.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D56912
2026-06-14 05:02:38 +03:00
Konstantin Belousov 3d505310b1 sys/rangelock.h: explicitly enumerate padding at the end of the structure
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D56912
2026-06-14 05:02:38 +03:00
Konstantin Belousov 36b155a2b3 vfs: work around the race between vget() and vnlru
Specifically, do not let vtryrecycle() to recycle a used vnode. It is
possible for a vnode to be vref-ed or vuse-ed lockless after it is held
by vhold_recycle_free(). Then, since vtryrecycle() does not recheck the
hold count, we might end up freeing vused vnode.

Since vget_finish() increments v_usecount after obtaining the vnode
lock, we would observe the hold reference anyway when the parallel
vget() is blocked waiting on the vnode lock.

PR:	281749
Reported and tested by:	Steve Peurifoy <ssw01@mathistry.net>, Vladimir Grebenshchikov <vova@zote.me>
Reviewed by:	olce
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57305
2026-06-14 05:02:38 +03:00
Konstantin Belousov 3eafe01884 rtld-elf: add some tests for parse_integer()
Reviewed by:	des, dim
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57549
2026-06-14 04:02:00 +03:00
Konstantin Belousov 4249a9bc09 rtld parse_integer(): support binary, octal, and hex C notations
Reviewed by:	des, dim
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D57549
2026-06-14 04:01:55 +03:00
Nick Price 69e20977a4 acl_to_text_nfs4.c: Fix a snprintf() for large uid
Commit 6e7c10c79d fixed a couple of snprintf()s for large
uid/gid numbers above 2Gig.  This patch fixes another one.

Reviewed by:	rmacklem
Differential Revision:	https://reviews.freebsd.org/D57561
2026-06-13 14:15:17 -07:00
Vladimir Kondratyev 511d749ecc LinuxKPI: sync linuxkpi_video with Linux 6.12
MFC after:	1 week
2026-06-13 21:08:58 +03:00
Christos Margiolis de2a136602 mixer(8): Retire deprecated control values
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-06-13 19:29:40 +03:00
Mateusz Piotrowski 4ef1a73c22 style.mdoc.5: Document Nd style
The Nd macro takes the rest of the line as an argument,
so there is no need for extra quoting.

MFC after:	3 days
2026-06-13 12:57:05 +02:00