clnt_rdma: Fixes for three issues listed below
There are three small issues:
1. An unused Reply chunk gets its descriptor freed, but the mbuf
and pages are left allocated, effectively leaking.
2. The reused send/receive buffers would probably need
DMA synchronization.
3. Some receive errors don't notify the RPC layer. A zero-credit
reply can also leave callers waiting.
This patch fixes these.
This patch also fixes positioning of NET_EPOCH().
Reviewed by: rmacklem
Sponsored by: VersatusHPC
MFC after: 1 month
clnt_rdma.c: Fix handling of a client reply retried reply
When the client does a retry (due to an expired RPCSEC_GSS credential),
the handling of the reply chunk was not done correctly.
This patch fixes this.
Reviewed by: rmacklem
Sponsored by: VersatusHPC
MFC after: 1 month
hwpmc_amd: Allow only system counting on L3, DF and UMC counters
These counters are shared by several CPUs, a CCX in the case of L3. A
process-mode PMC is loaded on every CPU that runs a target thread, so
two CPUs can program the same counter. Without PerfMonV2, an INVARIANTS
kernel then panics with "Starting active PMC"; otherwise the counts are
wrong. No privilege is needed: on Zen 1-3, "pmcstat -P LLC_MISSES" is
enough. System sampling is accepted too, but no interrupt handler
checks these counters.
Refuse every mode but PMC_MODE_SC, as the RAPL, PERF and TSC classes do.
Two system-mode PMCs on CPUs that share a counter can still conflict;
that is left to userland, as before.
PR: 296001
Reported by: asomers
Reviewed by: mhorne
Sponsored by: Advanced Micro Devices, Inc.
Signed-off-by: Osvaldo Janeri Filho <ojanerif at amd.com>
Differential Revision: https://reviews.freebsd.org/D61949
clnt_rdma.c: Fix client recovery from connect loss
After a local send or receive error, clnt_rdma_call() marks the
connection disconnected, but other RPCs can remain asleep on it.
The attached patch wakes those callers so they can reconnect.
I tested this by forcing a send failure while other RPCs were pending.
Without this patch the client simple stalls.
Reviewed by: rmacklem
Sponsored by: VersatusHPC
MFC after: 1 month
cryptodev: zero key material before freeing it
The /dev/crypto cipher and MAC keys are copied from userland and
released with free(), leaving the key bytes in freed kernel memory.
Use zfree() so the key material is cleared on session teardown and on
the setup error path.
Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61324
(cherry picked from commit edaa6ba7be8666d4f543317845899e1a1b684bbf)
gptzfsboot: Use snprintf() to format file names
The stack buffer in fs_list() can be overflowed if a file name is too
long.
Reported by: Yudi Yang <yudi.yang at rice.edu>
MFC after: 1 week
(cherry picked from commit 956a05c3cbf5f5cb9d1c4d58e3a5fc22db1446b8)
gve: Fix AdminQ buffer DMA sync directions
In gve_verify_driver_compatibility(), the driver populates the
gve_driver_info buffer for the device to read. Sync this buffer with
BUS_DMASYNC_PREWRITE instead of BUS_DMASYNC_PREREAD before issuing
the command.
In gve_adminq_describe_device(), the device populates the
gve_device_descriptor buffer for the driver to read. Sync this buffer
with BUS_DMASYNC_PREREAD instead of BUS_DMASYNC_PREWRITE before
issuing the command.
In gve_adminq_get_ptype_map_dqo(), the device populates the
gve_ptype_map buffer for the driver to read. Add the missing
BUS_DMASYNC_PREREAD and BUS_DMASYNC_POSTREAD syncs around the
command.
In normal GCP environments this did not cause a functional failure
because the underlying platforms are DMA cache-coherent and
[14 lines not shown]
pmap: Fix some bugs around accounting of wired mappings
The amd64 and arm64 pmaps failed to decrement the count when tearing
down a 1GB largepage mapping. The riscv pmap failed to decrement the
count when unwiring a superpage mapping.
Reported by: alc
Reviewed by: bnovkov, alc, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61414
(cherry picked from commit da507ac5503d9af35f5aff4a7a773f6a92746e4a)
procctl: Zero the output structure for the compat32 syscall
Otherwise the freebsd32 implementation of PROC_REAP_STATUS leaks
uninitialized kernel stack memory.
Reviewed by: kib
Reported by: Dennys Kaluzny Pereira <dennyskaluzny at gmail.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61510
(cherry picked from commit 5a834ad15f1f09d43a6840c74da194db6f890aa2)
vmm: Emulate the byte forms of OR and AND with an immediate
Opcode 0x80 (group 1: r/m8, imm8) is in the decode table and
emulate_cmp() handles 80 /7, but emulate_or() and emulate_and() only
accept 0x81 and 0x83. An "or byte ptr [mem], imm8" or "and byte ptr
[mem], imm8" on emulated memory therefore fails with EINVAL and bhyve
stops the guest with "Failed to emulate instruction sequence
[ 80 ... ]". Seen with macOS: VoodooHDA starts the HDA controller's
CORB with "or byte [rax+0x4c], 2" (CORBCTL |= CORBRUN), and the guest
died at the first sound.
Accept 0x80 in both, with a one byte operand as emulate_cmp() does.
The file is shared with bhyve(8), so the fix covers the in-kernel
devices (HPET, local APIC without APICv, I/O APIC) and the user space
device models alike.
Signed-off-by: Wanpeng Qian <wanpengqian at gmail.com>
Reviewed by: markj
[5 lines not shown]
imgact_elf: Pass program headers to the sv_protect hook
We handle program headers beyond the first page of the file, but
arm64_exec_protect() wasn't updated to handle this. Pass the program
header array directly to the sv_protect hook.
Also fix a pre-existing bug: imgp->et_dyn_addr isn't the right base
address to use for the SV_INTERP case.
Reported by: alc
Reviewed by: alc, kib
Fixes: 804daf166406 ("imgact_elf: read program headers if not contained in the first page")
Fixes: 670af174e27b ("arm64: Enable BTI in the kernel ELF loader")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61999
(cherry picked from commit 884e1a00151d181e5dd1ba9d83c1adcffd25e5e8)
gve: Page-align DQO descriptor and completion rings
Currently, gve_rx_alloc_ring_dqo() and gve_tx_alloc_ring_dqo() request
CACHE_LINE_SIZE alignment when allocating DMA memory for the DQO TX/RX
descriptor and completion rings. The device requires stronger alignment
than cache line alignment, which was incidentally being met due to how
the kernel allocates memory. Explicitly meet this requirement by
requesting page aligned memory.
Signed-off-by: Tim Hostetler <thostet at google.com>
Reviewed by: markj, Jasper Tran O'Leary <jtranoleary at google.com>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61211
(cherry picked from commit 9d48e88e023634e12530bf9db4a2e85d022b93db)
BSD.tests.dist: Add the new sys/libkern directory
Without that, 'make distributeworld' fails ('make buildworld' and 'make
installworld' do not need it).
Reported by: llm-postcr
Fixes: 1a80570a3940 ("tests/sys: Move libkern's tests in a separate directory")
Sponsored by: The FreeBSD Foundation
tests/sys/pmc/amd: Call pmc_cpuinfo() in amd_test_find_classinfo()
Every caller of amd_test_find_classinfo() calls pmc_cpuinfo() right
before it. Do that in the helper and drop the ibs_classinfo() and
rapl_classinfo() wrappers.
rapl_domains_test now fails instead of skipping when pmc_cpuinfo()
fails after pmc_init() succeeded, like the other tests.
Suggested by: mhorne
Reviewed by: mhorne
Sponsored by: Advanced Micro Devices, Inc.
Signed-off-by: Osvaldo Janeri Filho <ojanerif at amd.com>
Differential Revision: https://reviews.freebsd.org/D62106
tests/sys/pmc/amd: Skip in guests without a PMU
In a guest that shows an AMD Zen CPU but has no PMU, hwpmc(4) registers
neither the AMD core class nor IBS. pmc_rowalloc_test, pmu_mux_test and
pmu_detect_test check only the CPU and pmc_init(), and
pmc_ibs_fetch_op_test checks only CPUID leaf 0x8000001B, which bhyve
passes through. All four fail there instead of skipping.
Add amd_test_skip_unless_class() and use it in pmc_rowalloc_test,
pmu_mux_test and pmc_ibs_fetch_op_test. hwpmc_amd registers a class
only after amd_hwcheck() passes, so a missing class means there are no
usable counters; rapl_domains_test already skips that way.
pmu_detect_test asserts that the class is registered, so gate it on
PerfCtrExtCore instead, which bhyve clears and KVM sets only with a
vPMU.
PR: 300856
Reviewed by: mhorne
Fixes: 546a76463123 ("tests/sys/pmc: add pidtrack, callchain, pmc(8), RAPL and AMD tests")
[4 lines not shown]
nfsclrdma: Add code to support client side NFS over RDMA
These functions started life as sys/rpc/clnt_vc.c and
a couple of files in the Linux kernel that are dual
licensed (the same as the OFED stack). They have now
been heavily modified to work with the FreeBSD NFS client
and krpc. NFS over RDMA is based on RFC-8166 and RFC-8267.
I have not added my name to the copyrights. Should I do so?
One outstanding issue is that I see "mlx5_1: WARN: dump_cge.."
failures for the ConnectX4 NICs I have available for testing,
if I allow more than 8 concurrent RPCs or an I/O size greater
than 64Kbytes. Testing by others have not seen this issue
with newer Mellanox NICs, so the current code sets a limit of
8 concurrent RPCs and a 64Kbyte I/O size for ConnectX4 to
avoid the failures.
The build glue and man page updates will be done as
separate commits, once reviewed. There are also three
[21 lines not shown]
tests/sys/libkern: Add tests for sign extension and bitfield extraction
In order to avoid name collisions with standard library functions, wrap
everything but the functions to test in a !LIBKERN_TESTING section, so
that when LIBKERN_TESTING is defined, all untested parts are not
defined. Leave a comment there suggesting selective namespacing when
adding tests to string functions having same name in the standard
library.
Reviewed by: fuz
MFC with: a6e81841486a ("libkern: Bitfield extraction: Stick to standard, separate sign extension")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61963
tests/sys: Move libkern's tests in a separate directory
Use 'sys/libkern', to mimick the source hierarchy.
Reviewed by: emaste
MFC with: a6e81841486a ("libkern: Bitfield extraction: Stick to standard, separate sign extension")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61961
netlink/tests: Add permanent flag to test_add_6_flags
Now IFA_F_PERMANENT is reported, add test for it and expect
IFA_F_PERMANENT in nl_flags during tests.
Reported by: llm-postcr
Fixes: 10b94e406444 ("netlink: add support for adding/deleting interface addresses")
MFC after: 3 days
tcp: improve ISS checking for ghost ACKs
The check in tcp_adapt_iss_check() depends on SND.UNA and therefore
should be performed whenever SND.UNA is incremented.
PR: 298560
Reviewed by: Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61749
(cherry picked from commit 9e345ca583f702e7472f836136e766d3346c049d)
tcp: improve ISS checking for ghost ACKs
The check in tcp_adapt_iss_check() depends on SND.UNA and therefore
should be performed whenever SND.UNA is incremented.
PR: 298560
Reviewed by: Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61749
(cherry picked from commit 9e345ca583f702e7472f836136e766d3346c049d)
nd6: Keep addresses tentative in in6_if_up
in6_if_up() runs from the IFNET_EVENT_UP handler on every
IFF_UP 0->1 transition, whether or not the interface is ifdisabled.
Ignore state transitions in in6_if_up() for now.
Reported by: llm-postcr
Fixes: f0ce2ae67f9f ("nd6: Do not make SLAAC addresses usable with ifdisabled")
sysrc: Restore the ability to pin default value
Fix 1 issue identified in post-commit review of eaf7113:
POSTCR-1: "unchanged" short-circuit counts a value that only comes
from RC_DEFAULTS, so `sysrc -f file var=<default>` writes nothing.
Add an ATF test to ensure we preserve this functionality.
Reported by: llm-postcr
Fixes: eaf7113bef8f ("sysrc: Add "unchanged" messages")
lualoader: don't run a failed command twice from the prompt
interp_run() hands each command line to cli_execute, which runs
builtins through loader.command. If that returned an error, it then
ran the command again with interp_builtin_cmd(), as a fallback for when
lua couldn't run the command at all. A command that simply failed thus
ran twice, printing any errors twice and repeating whatever it did
before it failed.
Only fall back when the lua call itself failed, and otherwise take the
command's own result.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D61845
loader: i386: fix vectx handling in chain error paths
Once vectx_open() succeeds, the stat, device, root device and read error
paths all returned without freeing the context, leaking it.
We also closed the fd before calling vectx_close(), which may need to
read the remainder of the file to finish hashing it. This is harmless
as-is because we've always read the whole file by that point, but close
it afterwards so that we aren't relying on that.
Reviewed by: sjg
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D61840
stand/zfs: leave variables that nvstore doesn't own alone
Setting an nvstore variable also sets it in the loader's environment,
both when we store it and when we import the nvstore at startup. We
did that with EV_NOHOOK, which is right for our own variables, since
their hook is what stores them. A variable that something else in the
loader created, e.g., currdev or console, has hooks of its own that
validate it or act on it. We bypassed those, so a stored value never
really took effect, and we could set or discard a variable whose hooks
would have refused.
Refuse to set or unset such a variable with EPERM before we touch the
pool label, and skip it when we import the nvstore.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D61844
libsecureboot: don't remember files accepted unverified
verify_file() caches the result for each file by dev/ino, including
VE_UNVERIFIED_OK. That status only says that the file was unverified
but acceptable at the severity the caller asked for, but a later
request for the same file takes the cached result as-is: verify_prep()
and vectx_open() both treat it as "not verifying this", even at
VE_MUST.
As a result, anything that could be opened at a lower severity could
then be loaded where it must verify, e.g.:
include /boot/modules/evil.ko # VE_WANT, no fingerprint
load evil # VE_MUST, but cached as OK
Stop caching VE_UNVERIFIED_OK so that each request is judged by its own
severity, under whatever policy is in effect at the time. Files that
would be accepted unverified have no usable fingerprint, so there's
nothing to hash; they're just looked up again (and reported, if verbose)
[6 lines not shown]
loader: fix double free of vectx on verification failure
vectx_close() always frees the context it is handed, but both
file_loadraw() and the i386 chain command would free(vctx) again when
it reported a verification failure.
Reviewed by: imp, sjg
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D61839
lualoader: match the .lua extension literally
Both config.processFile() and try_include() checked for a .lua
extension with ".lua$", but '.' matches any character, so a name like
foo_lua also matched.
In processFile(), that meant that a config file such as /boot/foo_lua
was run as lua, though it was opened like any other config file.
With veriexec, that file only needs VE_WANT rather than the VE_MUST
that we expect for lua code, so an unverified file could be run as lua.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D61843
loader: efi: fix error check on fstat() in chain
fstat() returns -1 on failure, so testing for a return value less than
-1 could never catch an error, and we would carry on with whatever
garbage was in the stat buffer.
Reviewed by: imp, sjg, tsoome
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D61846