amd64/vmm: Don't advertise AMD PerfMonV2 or performance counters
vmm does not handle CPUID leaf 0x80000022, so a FreeBSD guest on a
Family 19h or later host panics on "kldload hwpmc", which trusts the
PerfMonV2 bit and writes AMD_PMC_GLOBAL_CTL.
Tested by: Osvaldo Janeri Filho <ojanerif at amd.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Reviewed by: markj, kib
Differential Revision: https://reviews.freebsd.org/D61141
(cherry picked from commit 8fb539b081dbfe3e93e607a5d4d36184c53c8aaf)
amd64/vmm: Don't advertise AMD PerfMonV2 or performance counters
vmm does not handle CPUID leaf 0x80000022, so a FreeBSD guest on a
Family 19h or later host panics on "kldload hwpmc", which trusts the
PerfMonV2 bit and writes AMD_PMC_GLOBAL_CTL.
Tested by: Osvaldo Janeri Filho <ojanerif at amd.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Reviewed by: markj, kib
Differential Revision: https://reviews.freebsd.org/D61141
(cherry picked from commit 8fb539b081dbfe3e93e607a5d4d36184c53c8aaf)
netlink: Pre-register the missing devctl event systems
devctl_notify() can be called with a mutex held. If the event system is
not listed in devctl_systems[], sysevent_get_group() calls
sysevent_new_group(), which calls strdup() with M_WAITOK, and we may end
up sleeping while holding a non-sleepable mutex.
Add the missing systems.
While here, remove the nonexistent KERNEL system.
PR: 299272
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61161
(cherry picked from commit 66d078c17294ca2ea225e4926a8cd9697dda57ed)
allwinner: a33: Fix the pin number of PE17
The PE17 entry of the pad table of the A33 had the pin number 16, the
one of PE16, so the pinctrl of PE17 configured PE16 and a <&pio 4 17>
specifier could not be mapped.
Reported by: llm-postcr
Fixes: cf72965fbf02 ("Allwinner: Add A33 support")
aw_ccu: h6: Allow the IR and W1 clocks to change their parent
The IR clock was defined without AW_CLK_REPARENT, so only the current
parent was used to find a rate. The firmware leaves the mux on osc32k,
from which the best rate is 32768Hz, and aw_cir asks for exactly 3MHz,
which osc24M can give. The request failed and r_ir did not attach. Do
the same as the main CCU for the CIR-TX clock and let the clock use the
best parent, and do the same for the 1-wire clock which is the same.
Reported by: llm-postcr
Fixes: 69919babdac7 ("aw_ccu: h6: Add the IR, W1, RSB and RTC clocks of the R CCU")
Tested on: H6
axp81x: Fix the number of steps of the first range of DCDC5
The voltage of DCDC5 goes from 800mV to 1120mV in 10mV steps with the
codes 0x00 to 0x20, then from 1140mV to 1840mV in 20mV steps with the
codes 0x21 to 0x44. The first range has 32 steps and not 42, so every
code above 32 was decoded and encoded wrongly: the driver read 1160mV
for the 1.2V that the firmware sets for the DRAM, did not see it in the
range of the FDT and wrote a code that is really 1280mV. The same
happens for the other voltages, 1.36V is set to 1.46V and 1.5V to 1.6V.
It also made the voltage reported for the regulator wrong.
Reported by: llm-postcr
Fixes: c175fd0fe8a3 ("axp81x: Add support for AXP803")
Tested on: A64
aw_ccu: h616: Set the lock enable bit of the PLLs
The lock status bit of a PLL is only updated when its lock enable bit,
bit 29, is set, and the firmware only sets it for the PLLs it uses.
Enabling another PLL, or changing the rate of an enabled one, then
waited for a lock that never came and ended after a second with an
error. Set the bit on all the PLLs when attaching, like Linux does.
Reported by: llm-postcr
Fixes: 92b59f3d010d ("aw_clk: Wait for the PLL to lock when enabling it")
axp209: Allow the interrupt handler to sleep
The interrupt handler reads and writes the registers of the PMU with
IIC_INTRWAIT, which can sleep when the bus is busy, and the I2C
controller the AXP209 is on in the A10 and A20 waits for the end of the
transfer. The handler runs in an interrupt thread, which cannot sleep
unless the interrupt is marked as sleepable, so an interrupt of the PMU
would panic a kernel with INVARIANTS. Mark it, the interrupt is not
shared, like it was done for the axp81x driver.
Reported by: llm-postcr
Fixes: 30068a1de9e3 ("Add support for interrupts, sensors and GPIO for AXP209 PMIC")
allwinner: a31s: Fix the pin number of PH28
The PH28 entry of the pad table of the A31s had the pin number 27, the
one of PH27, so the pinctrl of PH28 configured PH27 and a <&pio 7 28>
specifier could not be mapped. This was fixed for the A31 in
222947a74223 but not in the copy for the A31s.
Reported by: llm-postcr
Fixes: ccf8caad1413 ("Add the Allwinner A31 and A31s padconf support. It's currently unused, but")
aw_gpio: Return the error when an interrupt cannot be mapped
aw_gpio_pic_map_intr() returned success without setting the interrupt
source when aw_gpio_pic_map_gpio() failed, which happens for a pin that
has no interrupt function or for an unsupported mode. The caller then
went on with an uninitialized pointer. Return the error.
Reported by: llm-postcr
Fixes: 0fe5379c6a99 ("arm: allwinner: Add GPIO Interrupt support")
allwinner: h616: Put the PI pins in bank 8
The PI0 to PI16 entries of the pad table had port 9 and interrupt bank 9
but the PI bank is the ninth one, bank 8, at offset 0x120. Bank 9 is a
bank that does not exist, so the configuration, data, drive and pull of
these pins, and their interrupt registers, were accessed at the wrong
place and a <&pio 8 N> specifier, like the one of the card detect GPIO
of some boards, did not find its pin.
Use 8 for the port and the interrupt bank, like the other entries do
with the position of their letter.
Reported by: llm-postcr
Fixes: e506af08bb52 ("aw_gpio: Add support for H616")
aw_ccu: d1: Set the lock enable bit of the PLLs
The lock status bit of a PLL is only updated when its lock enable bit,
bit 29, is set, and the firmware only sets it for the PLLs it uses.
Enabling another PLL, or changing the rate of an enabled one, then
waited for a lock that never came and ended after a second with an
error. Set the bit on all the PLLs when attaching, like Linux does.
Reported by: llm-postcr
Fixes: 92b59f3d010d ("aw_clk: Wait for the PLL to lock when enabling it")
xdr: Fix xdr_string
Forcing maxsize to RPC_MAXDATASIZE breaks code that deliberately uses
XDR with longer strings than permitted by SunRPC.
MFC after: 1 week
Fixes: 6448ec89e739 (" * limit size of buffers to RPC_MAXDATASIZE")
Fixes: e17d7ab869bb ("xdr_string: don't leak strings with xdr_free")
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Reviewed by: kevans, brooks
Differential Revision: https://reviews.freebsd.org/D59994
(cherry picked from commit d2018cedb414ef17e77b7fc2fa19fd81328da46b)
xdr: Limit xdr_wrapstring
The previous commit (re)introduced the possibility that a malicious or
corrupt message can cause the receiver to allocate a very large amount
[11 lines not shown]
xdr_string: don't leak strings with xdr_free
Historically (and in a small amount of older software such as OpenAFS),
developers would attempt to free XDR strings with
xdr_free((xdrproc_t)xdr_string, &string)
This resulted in xdr_free calling xdr_string with only two intentional
arguments and whatever was left in the third argument register. If the
register held a sufficently small number, xdr_string would return FALSE
and not free the string (no one checks the return values).
Software should instead free strings with:
xdr_free((xdrproc_t)xdr_wrapstring, &string)
Because buggy software exists in the wild, act as though xdr_wrapstring
was used in the XDR_FREE case and plug these leaks.
[9 lines not shown]
aio_mlock.2: Expand document description
+ The old one renders broken because Xr is not correct/portable in Nd
+ Take this opportunity to explain it better using mlock description
MFC after: 3 days
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D61334
tests/sys/kern/ssl_sendfile: double timeouts for :grow and :truncate
The :grow and :truncate testcases fail semi-regularly in CI with
timeouts. Double the timeout to reduce false positives with the tests.
PR: 300699
MFC after: 1 week
Reviewed by: siva
Differential Revision: https://reviews.freebsd.org/D61444
asmc: include sys/kernel.h
This is needed for the `MODULE*` macros.
This include was accidentally removed in the linked commit.
MFC after: 1 week
Reported by: Ian Freislich <ianfreislich at gmail.com>
Fixes: c714cde179a4 ("asmc: split the sysctl layer into asmcsysctl.c")
iflib: Use a single tx dma map
The need for a separate map for TSO and non-TSO seems to have arisen from
a misunderstanding about the DMA requirements for Intel drivers like
ice/ixl/iavf. Specifically, this Intel hardware has a quirk where no
more than N (=8) segs can be DMA'ed per packet on the wire. This limit
was enforced using a DMA map with a low segment limit for non-TSO and a
driver specific check for TSO. This led to a *lot* of complexity in
iflib (~80 extra lines of code that this change removes) when the
limit can simply be enforced via the existing EFBIG mechanisms.
This change adds a new flag, IFLIB_SPARSE_TX, that drivers for hardware
with this quirk must set. When set, it causes non-TSO sends that
exceed isc_tx_nsegment to be treated as if bus_dmamap_load_mbuf_sg()
had returned EFBIG.
Due to the API/KABI change, I've bumped the FreeBSD version as well.
Note kgalazka suggested the flag, rather than a more awkward
[12 lines not shown]
snmp_hostres(3): strengthen work on the devd(8) socket
Use the SOCK_SEQPACKET version of the socket. This guarantees that
messages read won't be glued together. Use sufficient buffer size to
read any message.
Close socket on any kind of error or a short read.
This also fixes a bug when a SOCK_STREAM socket containing exactly
multiple of 512 bytes would block the daemon in read(2) until some
other devd(8) event. Thank to David for catching and analyzing it.
Reported by: David Pfitzner <dpfitzner at netflix.com>
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D61146
devd: expose maximum record size via sysconf(3)
Use UMA allocation size that holds the buffer. The buffer is actually
slightly smaller. Document the latter so that clients don't need to use
+1 if they later want to NUL-terminate a message.
Reviewed by: mjg, imp
Differential Revision: https://reviews.freebsd.org/D61346
devd: define _PATH_DEVD_SOCKET in <paths.h>
Sweep through consumers and use the define.
Reviewed by: kfv, imp
Differential Revision: https://reviews.freebsd.org/D61344
iflib: simplify TXQ_AVAIL
Simply the TXQ_AVAIL() macro to avoid using
get_inuse(txq->ift_size, txq->ift_cidx, txq->ift_pidx, txq->ift_gen)
and instead define it in terms of txq->ift_in_use.
Note that in_use is equivalent, because it is updated at the same time
as cidx/pidx and gen, and under the same serialization. The advantage
is that its cheaper due to using one read and no branches, and
safer, since unlocked reads get an atomic snapshot of availability,
but an unlocked read of multiple counters can produce inconsistent
results.
Reviewed by: kbowling, kgalazka
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D61279
(cherry picked from commit 44df82b11c535ae50b1e5888a361a2bd15d4182b)
iflib: rate limit deferred tx ring drain
When simple_tx gives up & return ENOBUFS because the tx ring is full,
we were doing a GROUPTASK_ENQUEUE(&txq->ift_task) each time.
On a tx ring that has overflowed and is being hammered on
by a fast UDP sender, this can result in a massive increase in
context switches (I've seen over 30M ctxw/sec due to this, and
the ctxsw codepath taking roughly 50% CPU).
This change removes the GROUPTASK_ENQUEUE() and replaces it
with a call to a callout which drains the tx ring. The callout time is
determined based on the link speed, estimating how long it would take
for a large fraction of of a ring containing full-MTU packets to drain.
This removes the 30M ctxsw / sec in my test case and reduces it
to roughly a doubling of ctxsws.
Reviewed by: kbowling
Sponsored by: Netflix
[3 lines not shown]
tpm: crb: Support the ACPI start method
Some AMD firmware TPMs report StartMethod 2 and had no driver. They never
acknowledge CTRL_REQ, so skip the idle and ready requests.
Do not harvest entropy from these TPMs on AMD: on a Ryzen 7 7735HS each
periodic TPM2_GetRandom froze every CPU, for up to 1.2 s (AMD PA-410).
Reviewed by: kbowling
Approved by: kbowling
Differential Revision: https://ron-dev.freebsd.org/FreeBSD/src/pulls/103
(cherry picked from commit 6af18560a124b84549713a5f2b667a1df0990929)
tpm_crb: Use locality registers only with plain CRB
The locality release wait times out on every command on a Framework 13
(Pluton start method), logging every 10 seconds.
Reported by: emaste, tuexen
Reviewed by: kbowling
Approved by: kbowling
Fixes: bfe4be85a935 ("tpm_crb: wait for idle and locality release after each command")
(cherry picked from commit 1dade7024457ee10df1ccae22e3c454e80f82b76)
tpm_crb: wait for idle and locality release after each command
transmit only requested GO_IDLE and the locality release, so a back-to-back
command could see stale state and fail with EIO.
A post-send idle timeout no longer discards a completed response.
Reviewed by: kbowling
Approved by: kbowling
Differential Revision: https://ron-dev.freebsd.org/FreeBSD/src/pulls/93
(cherry picked from commit bfe4be85a9354b92135e105028f2e1b3e0307ada)
tpm: crb: Dump register state on command failures
Include the command code in notification failures and the command code
and execution timeout in completion failures. Capture CRB control
registers on completion timeouts and Pluton mailbox readiness or
acknowledgement timeouts, before cancellation or cleanup changes them.
Include locality registers when present and mailbox registers for the
Pluton start method. The dump contains transport state without command
payloads or response data.
Tested by: olivier, tuexen
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D61128
(cherry picked from commit 915eb355d8fe8555f7a74c6db95bc3c02610a939)
tpm: crb: Correct the Pluton mailbox handshake
Pluton's REPLY register indicates readiness for a new notification, not
completion of the notification just sent. Wait for REPLY=1 before
ringing the mailbox, then wait for START=0 when a synchronous state
change needs acknowledgement.
Use a separate command notification callback that waits for mailbox
readiness but leaves command completion to the existing CRB_CTRL_START
polling. Bound readiness waits by TPM_TIMEOUT_C, including asynchronous
idle notifications, while retaining the command's execution timeout.
This resolves reported command timeouts on a Framework AMD laptop.
Tested by: olivier, tuexen
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D61128
(cherry picked from commit 4995fd4bf2c61e30363e588c5b90d7fc9145bf5e)