linux/Documentation
Tejun Heo f6c33c4479 bpf: Support __arena and __arena__nullable on struct_ops arguments
A struct_ops callback cannot receive an arena pointer directly, so
passing one takes two steps. The pointer arrives as a bare u64 that the
callback casts, and because the two sides address the arena through
different bases it also has to be rebased by hand on the way in.

Add the __arena and __arena__nullable stub argument suffixes to make this
convenient. The callback declares the parameter as an arena pointer,
receives it as a PTR_TO_ARENA register, and dereferences it directly,
while the kernel caller just passes the natural kernel arena address
(kaddr). The trampoline converts the value while saving the arguments
into the BPF ctx, ctx[slot] = (u32)(kaddr - kern_vm_start), so the
program never sees a kernel address and nothing rewrites the ctx after
the fact. The converted value keeps the upper 32 bits clear as the JITs
require of arena pointer registers and behaves like any cast_kern'ed
arena pointer, so cast_user recovers the full user-visible address.

__arena converts unconditionally and the kernel caller must not pass
NULL. __arena__nullable preserves NULL, tested on the full 64-bit kernel
pointer, and surfaces to the verifier as PTR_TO_ARENA (but not as a
PTR_TO_ARENA | PTR_MAYBE_NULL). The reason is that PTR_TO_ARENA in the
program's type state already encompasses NULL-ness, so it is not
meaningful to force a NULL check for the program.

The composite suffix intentionally ends in __nullable. Classify
__arena__nullable before the generic suffix so scalar arena pointees do
not take the generic nullable BTF pointer path.

This patch adds the generic side. prepare_arg_info() records arena and
nullable argument flags in the struct_ops function model, and
bpf_tramp_arena_base() returns the arena base for a single-program
struct_ops indirect trampoline. Only that trampoline converts: its
program's arena is fixed at generation time. Generic trampolines can mix
programs with different arenas and reject arena context arguments
defensively, which is unreachable today as only struct_ops programs
carry them. Architectures that do not implement the conversion are
gated out at verification time with bpf_jit_supports_arena_args().

Co-developed-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://patch.msgid.link/20260808003938.3486067-6-memxor@gmail.com
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-08 03:03:26 -07:00
..
ABI Power Supply Fixes for 7.2 cycle 2026-07-30 16:50:17 -07:00
accel
accounting
admin-guide Docs/admin-guide/cgroup-v2: document io.latency rotational vs non-rotational behavior 2026-08-02 11:29:33 -10:00
arch KVM: arm64: vgic: Avoid double-deactivate of IRQs in the nested context 2026-07-21 11:19:00 +01:00
block for-7.2/block-20260615 2026-06-16 13:02:47 +05:30
bpf bpf: Support __arena and __arena__nullable on struct_ops arguments 2026-08-08 03:03:26 -07:00
cdrom
core-api liveupdate: updates for 7.2-rc1 2026-06-21 09:46:14 -07:00
cpu-freq cpufreq: Use policy->min/max init as QoS request 2026-06-08 18:42:14 +02:00
crypto lib/crypto: docs: Improve introduction sentence 2026-07-09 11:06:05 -04:00
dev-tools linux_kselftest-next-7.2-rc1-second 2026-06-23 07:35:37 -07:00
devicetree SCSI fixes on 20260802 2026-08-02 09:32:07 -07:00
doc-guide
driver-api A handful of late-arriving docs fixes, along with one document update 2026-06-25 09:09:38 -07:00
edac
fault-injection
fb
features LoongArch: Add THREAD_INFO_IN_TASK implementation 2026-06-25 13:03:47 +08:00
filesystems ksmbd: doc: update feature support status for durable handles and compression 2026-06-30 21:29:46 -05:00
firmware_class
firmware-guide
fpga
gpu drm-next for 7.2-rc1 2026-06-17 10:21:00 +01:00
hid
hwmon docs: hwmon: ltc4283: fix malformed table docs build error 2026-06-29 08:47:44 -07:00
i2c
iio docs: iio: adc: ad4691: add driver documentation 2026-05-31 11:14:22 +01:00
images
infiniband docs: infiniband: correct name of option to enable the ib_uverbs module 2026-06-16 14:47:24 -03:00
input Input: userio - allow setting other id values 2026-06-01 21:49:14 -07:00
kbuild kconfig: add optional warnings for changed input values 2026-06-18 11:46:32 -07:00
kernel-hacking
leds LEDs for v7.2 2026-06-18 14:45:08 -07:00
litmus-tests
livepatch
locking Things have calmed down a bit on the docs front, with no earthshaking 2026-06-16 08:35:59 +05:30
maintainer
mhi
misc-devices
mm A handful of late-arriving docs fixes, along with one document update 2026-06-25 09:09:38 -07:00
netlabel
netlink ovpn: limit keepalive values to one day 2026-07-30 11:28:30 +02:00
networking xsk: reclaim invalid Tx descriptors in ZC batch path 2026-07-24 15:12:14 -07:00
nvdimm
nvme
PCI
pcmcia
peci
power
process docs, resolve_btfids: Document kfunc BTF annotation emission 2026-08-06 22:01:28 -07:00
RCU
rust s390 updates for 7.2 merge window 2026-06-16 05:08:13 +05:30
scheduler sched_ext: Documentation: Fix ops table header reference 2026-07-07 12:23:33 -10:00
scsi
security integrity-v7.2 2026-06-19 11:32:05 -07:00
sound Documentation: sound: tas675x: Fix temperature range and impedance documentation 2026-07-01 19:52:38 +01:00
sphinx
sphinx-includes
sphinx-static
spi
staging
sunrpc/xdr Documentation: Add the RPC language description of NLM version 3 2026-06-09 16:32:59 -04:00
target
tee
timers
tools A handful of late-arriving docs fixes, along with one document update 2026-06-25 09:09:38 -07:00
trace A handful of late-arriving docs fixes, along with one document update 2026-06-25 09:09:38 -07:00
translations MAINTAINERS: update ndesaulniers 2026-07-06 15:49:29 -07:00
usb
userspace-api Char/Misc/IIO/FPGA/GPIB/etc driver updates for 7.2-rc1 2026-06-22 12:20:21 -07:00
virt KVM/arm64 fixes for 7.2, take #3 2026-07-28 17:43:23 +02:00
w1
watchdog docs: watchdog: Fix brackets 2026-07-02 07:12:58 -07:00
wmi modpost: Handle malformed WMI GUID strings 2026-06-12 16:01:55 +03:00
.gitignore
.renames.txt
atomic_bitops.txt
atomic_t.txt
Changes
CodingStyle
conf.py
docutils.conf
index.rst
Kconfig
Makefile
memory-barriers.txt
SubmittingPatches
subsystem-apis.rst