Arch support#
shirudo targets x86-64, arm64 and riscv64, and its code is written for all three. The project is under heavy development, and the three are not at the same stage yet: CI builds and tests x86-64, including tests that boot the test VM. On arm64, CI runs host tests and the test VM runs locally. No riscv64 target has booted shirudo so far. Some of the gaps are in shirudo, others in the kernel. This page lists both for anyone who wants to help close them.
Kernel facts on this page come from the bpf-next tree the test kernel builds. A later kernel can differ.
Comparison#
Area |
x86-64 |
arm64 |
riscv64 |
|---|---|---|---|
CI |
Every tier on every push |
Unit tests, |
None |
Test VM |
Boots on x86-64 hosts |
Boots on arm64 hosts; |
None; |
Packages |
Built in CI |
Not built in CI |
Not built in CI |
Toolchain hardening beyond the common flags |
Stack-clash protection, call-used register zeroing,
|
Stack-clash protection, call-used register zeroing,
|
None |
Kernel project patch set |
Included in the external kernel build |
Included in the external kernel build |
Included in the external kernel build |
BPF trampolines ( |
36 programs per function |
37 programs per function |
38 programs per function, and only on a kernel built without
|
BPF arenas |
Yes |
Yes; atomic read-modify-write on arena memory needs the LSE atomics of ARMv8.1 |
Only on CPUs with the Zacas extension, on a kernel built with
|
BPF stack per program |
2 KiB |
2 KiB |
512 bytes |
BPF exceptions and private stacks |
Yes; exceptions need the ORC unwinder |
Yes |
No |
|
Through ftrace |
Through a breakpoint |
Through a breakpoint |
Example packages |
|
|
|
x86-64#
Targets need upstream commit
31ac959c915c, which shirudo carried until bpf-next took it. Without it, a kernel whose functions can start at an odd address, such as one built with gcc 13 andCONFIG_CC_OPTIMIZE_FOR_SIZE=y, can crash when a BPF trampoline is updated. System requirements says which kernels need it.The
kernel-cvedetectors define__TARGET_ARCH_x86for theirkprobeprograms and load on x86-64 only.
arm64#
The arena tables of
kernel-obscount and link their records with atomic fetch-and-add and compare-and-exchange on arena memory. The arm64 JIT translates those only with the LSE atomics of ARMv8.1, so the package does not load on ARMv8.0 cores such as Cortex-A53 and Cortex-A72.A
kprobeon a function’s entry goes through a breakpoint exception rather than ftrace, because arm64 has no kprobes on ftrace.
riscv64#
Nothing has booted a riscv64 target yet: there is no test VM, no CI run and no package. The build has riscv64 settings, but no one runs it.
The toolchain hardening flags that x86-64 and arm64 get have no riscv64 counterpart in the build.
All of shirudo’s enforcement attaches through BPF trampolines. On riscv64 the kernel reaches a trampoline on a function that ftrace manages only through ftrace call ops, and it leaves call ops out of a kernel built with
CONFIG_CFI. Such a kernel refuses the attach withENOTSUPP, soinitcannot bring enforcement up. This is a reading of the kernel source.The riscv64 JIT supports arenas only when the CPU has the Zacas extension and the kernel is built with
CONFIG_RISCV_ISA_ZACAS: the arena allocator needs a 128-bit compare-and-exchange, and so does compare-and-exchange on arena memory.kernel-obsand every other upatch with an arena need it.The riscv64 JIT keeps BPF programs to 512 bytes of stack, where x86-64 and arm64 allow 2 KiB, and supports neither BPF exceptions nor private stacks. Whether shirudo’s own programs and
kernel-obsstay within 512 bytes has not been checked.
Open work#
shirudo#
Boot the test VM on an arm64 CI runner.
Add riscv64 to the test VM in
testing/vm/arch.sh, and boot a first riscv64 target with a TPM.Build the target binary and the packages for arm64 and riscv64 in CI.
Check that every library the target links builds and runs on riscv64, LuaJIT included.
Check the BPF stack use of shirudo’s programs and of
kernel-obsagainst the 512 bytes of riscv64.Let
kprobeupatches build for more than one architecture.shirudo buildpasses no__TARGET_ARCH_*define, so the source picks one, as thekernel-cvedetectors pick x86-64.
Linux kernel#
Get the remaining kernel changes upstream. The kernel project maintains them; Carried kernel patches describes each.
riscv64: BPF trampolines on a kernel built with
CONFIG_CFI.riscv64: arenas on CPUs without Zacas.
riscv64: large stacks, exceptions and private stacks in the BPF JIT.
arm64: arena atomics on ARMv8.0 CPUs without LSE atomics.