acpi_support/acpi_ibm.c: move the 'key' definition to the block that uses it
This eliminates a warning from compilation of kernels without
EVDEV_SUPPORT.
Fixes: 7e7f8b2c6641 ("acpi_ibm: Report mic mute key evdev events")
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 31b7d80016a37e4de10f166bc7ff353c7d1ef534)
acpi_ibm: handle ThinkPad programmable star key
Handle extended HKEY events separately from legacy event mask indices.
Report the programmable star key as KEY_BOOKMARKS instead of treating it
as brightness down, and preserve extended event arguments for devd.
Tested on: ThinkPad X1 Carbon Gen 9
Pull Request: https://github.com/freebsd/freebsd-src/pull/2595
MFC after: 3 days
Reviewed by: ngie, adrian
Differential Revision: https://reviews.freebsd.org/D62159
(cherry picked from commit 225fadb1697803353f4664fa8618fdf1dbc8edff)
ure: add USB device IDs for additional RTL8152/RTL8153 adapters
Add device IDs for several USB Ethernet adapters that use
RTL8152 and RTL8153 chips but are not yet recognized by ure(4).
This includes adapters from Cisco/Linksys, D-Link, Lenovo,
Microsoft Surface, Realtek, Samsung, and TP-Link.
All added devices use chip revisions already handled by
ure_read_chipver().
Signed-off-by: Christos Longros <chris.longros at gmail.com>
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D55748
(cherry picked from commit 76c082180719f42481289eb837e44b055efc003a)
acpi_ibm.4: Remove extraneous .Tn
As flagged by mandoc linter.
Event: Halifax Hackathon 202606
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 8de929962a38855c8c38d117d20b71d7c9eaee77)
acpi_ibm: register all appropriate sysctls as uint
All sysctls except thermal sensor readings and the handlerevents
whitelist-separated string are bitmasks or small integers. This avoids some
bitmasks being erroneously displayed as negative values.
Signed-off-by: Quentin Thébault <quentin.thebault at defenso.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1824
(cherry picked from commit e881b8ee0bc7bf552c9c0a63c7d84542243f9f0d)
acpi_ibm(4): Refer to "mic *mute* led" instead of "mic led"
Event: Halifax Hackathon 202606
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 40ab0a05640051eed02ccbf1c5150e97e8cc27da)
acpi_ibm: Report mic mute key evdev events
While here, make the naming of micmute_led more consistent.
PR: 296140
Event: Halifax Hackathon 202606
Reported by: David Lundqvist
Reviewed by: olce
Tested by: David Lundqvist, Oleksandr Kryvulia
Co-authored-by: David Lundqvist
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 7e7f8b2c66410bcc6408482be73bd9c059e2bbe2)
acpi_ibm.4: Fix mic_led sysctl name
Fixes: 707347f88649 ("Add missing documentation for dev.acpi_ibm.0.mic_led added in r335304")
Event: Halifax Hackathon 202606
Sponsored by: The FreeBSD Foundation
(cherry picked from commit b9d6497bd1f16e906f4dc6e600368b86d3fe0317)
stdio: Add test cases for scansets
Add test cases that exercise scanf() / wscanf() scansets, including
hyphenated ranges and the missing closing bracket bug we recently fixed.
MFC after: 1 week
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D62201
(cherry picked from commit c24ab9f32d9bb63b426f346cb5f28c00e63922c2)
stdio: Fix negated wchar scansets
We were recording the start of the scanset before checking if it began
with a caret. We need to check for a caret first, then record whatever
comes next as the start of the scanset.
Note that scanf() did not have this bug, only wscanf(), but this adds
regression tests for both anyway.
MFC after: 1 week
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D62328
(cherry picked from commit 71c723518d22b2ae9c9c7819aa2625af3532bba5)
stdio: Fix typo in scanset test
Fixes: 71c723518d22 ("stdio: Fix negated wchar scansets")
(cherry picked from commit c5917853354369d9537c5a5aee4f0d2854325ed4)
stdio: Implement ranges for wchar scansets
The C and POSIX standards allow but do not require hyphenated ranges to
be supported in scanf() / wscanf() scansets. We implemented them for
scanf() but not for wscanf(). Do so using similar logic as for scanf().
This is hard to do efficiently for wide characters, which can in theory
span the full 32-bit range (and even the actual range of about 1 million
Unicode codepoints is difficult to handle), so we don't try to be
efficient, but just focus on producing the same results for wscanf() as
for scanf().
MFC after: 1 week
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D62200
(cherry picked from commit 50eb68efcb473c8c20c016d618a8cd674d3706dc)
stdio: Use correct comparison function
[2 lines not shown]
stdio: Handle unterminated scansets
In both vfscanf() and vfwscanf(), if the end of the format string was
reached before the closing bracket of a scanset, we treated the NUL as
the closing bracket and continued to read beyond the end of the format
string. Add an error check to catch this case.
MFC after: 1 week
Reported by: Nick L. Leppelmeier <nicklpmr at gmail.com>
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D62199
(cherry picked from commit c5e0899d9908da5935cfaaade073d6911880fcb5)
apex: add a driver for the Google Apex Edge TPU
The Apex is the accelerator on Coral PCI Express and M.2 modules,
appearing as 1ac1:089a
Google's Linux driver left staging in 5.16 and the out of tree
repository was archived; no BSD has had one.
Tested on: amd64, Coral M.2 Accelerator, running MobileNet v1
with the TensorFlow Lite 2.16 and LiteRT runtimes
Reviewed by: ziaee, adrian
Differential Revision: https://reviews.freebsd.org/D58563
gasket: add a framework for Google accelerator ASICs
Gasket is Google's name for the layer their accelerator drivers share:
Google ASIC Software, Kernel Extensions, and Tools. The chips differ,
but they present the same shape to the host. A control register BAR
with a few windows user space may map, an on-chip page table the host
fills in so the device can reach host memory, and a block of MSI-X
vectors.
Reviewed by: ziaee, adrian
Differential Revision: https://reviews.freebsd.org/D58561
linux: Fix handling of an empty argv
proc_getargv() can return an sbuf with length zero. In the Linux
note_prpsinfo() handler, this would cause "len" to underflow to -2,
resulting in a giant out-of-bounds memchr() loop.
There is no reason to subtract anything from the sbuf length to begin
with, the nul terminator is not included there. Simplify the code to
fix this bug, and modify the native note handler to match.
Reported by: Laam Alif at Ibteda Digital Library
Fixes: 00d17cf342cd ("elf_note_prpsinfo: handle more failures from proc_getargv()")
Reviewed by: des, kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D62449
bhyve: disable SIGPIPE for TCP uart backend
Currently, if a TCP uart client disconnects while the guest is writing
to the serial port, a subsequent write to the socket raises SIGPIPE and
kills the VM.
Set SO_NOSIGPIPE on the listening socket to prevent that. Accepted
connections inherit it.
Reviewed by: markj
Fixes: 1f903953fbf8 ("bhyve: Add raw tcp to uart backend")
MFC after: 3 days
MFC to: stable/15
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D62215
(cherry picked from commit cbfe766aac6f316007438c9f5557dd0c99bcbad3)
bhyve: disable SIGPIPE for vtcons
Currently, if a virtio-console socket client closes the connection or
shuts down the read side, the next guest write to the socket
raises SIGPIPE and kills the VM.
Set SO_NOSIGPIPE on this socket to prevent that.
Reviewed by: markj
Fixes: 13ee8dde0409 ("Add virtio-console support to bhyve.")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D62216
(cherry picked from commit 293dac30b9955d64cff74f3d31138950cc6bfafe)
linuxkpi: Make list_sort stable
Linux's list_sort() is intended to be stable, but linuxkpi implemented
it as a wrapper around qsort(), which is not. This used to work because
our qsort() had a bug that effectively turned it into insertion sort,
but this is no longer the case. Replace the qsort() call with an inline
implementation of insertion sort.
MFC after: 1 week
Reviewed by: bz, markj
Differential Revision: https://reviews.freebsd.org/D62194
(cherry picked from commit e79b273db1a92542c4efb90ed80b92643e6ea2a6)
kern.post.mk: Fix unprivileged ports module build
When building ports modules along with the kernel, we run the build
target during buildkernel, and the install target during installkernel.
This was fine back in the day when we installed ports straight from the
working directory, but these days we stage them first, then build a
package, and install the package. This staging and packaging should be
seen as part of the build process, not the installation process, so we
should use the package target, rather than the build target, during
buildkernel.
This fixes an issue where doing buildkernel as an unprivileged user,
then installkernel as root, left a root-owned staging directory in the
kernel object tree which the next unprivileged buildkernel would be
unable to remove or replace.
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D62195
[20 lines not shown]
kern_linker: Fix struct version mismatch
The kldstat(2) syscall supports two different structures, identified by
their size, which the application stores in the version field before the
call. Since one is a prefix of the other, instead of calling different
functions to fill each one in like modstat(2) does, we fill in the
larger of the two and simply don't copy out the extra fields if the
smaller one was requested. As a side effect, we failed to fill out the
version field in either case. This causes application code that sets
the version field once and calls kldstat(2) repeatedly to fail since the
version field is now incorrect for subsequent calls, whereas the same
pattern works fine for modstat(2) because it copies the same version
value back out. Fix this by setting the version field immediately
before copying the struct out.
While here, amend the manual pages for both kldstat(2) and modstat(2) to
clarify that the version field is unchanged on return and remove bad
advice about rebuilding world if either syscall returns EINVAL.
[5 lines not shown]
dtrace/powerpc: leave the stack walker's own frame out
dtrace_getpcstack() and dtrace_getstackdepth() started with their own
frame. They call nothing, so no return address is ever saved in it and
the first thing the walk read was whatever the stack had there. When
that didn't look like an address the walk ended at once, and stackdepth
and caller were 0. When it did, everything was off by one frame: stack()
had one of DTrace's own functions on top, profile probes showed the
interrupted function twice and caller pointed into the provider.
Start with the caller's frame.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62453
sdt: skip one more frame on powerpc64
sdt_dtrace_probe() ends with the call to dtrace_probe(), which is a
tail call elsewhere. On powerpc64 a call into another module can't be
one, so there is one more frame between the probe and dtrace_probe().
stack() began with sdt_probe() and caller was in sdt_probe(), which is
also what lockstat(1) printed as the caller of every lock.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62455
powerpc/powernv: keep OPAL async messages within one page
opal_wait_completion() gives firmware the physical address of the
caller's buffer, and firmware copies the whole message there. The
callers keep the buffer on the stack, and the pages of a kernel stack
aren't physically contiguous, so a message that crosses a page boundary
ends up partly in some unrelated page.
Use a local buffer that can't cross a page and copy it to the caller.
Reported by: llm-postcr
Approved by: jhibbits (blanket)
MFC after: 1 week