Skip to content

bpf, arm64: relax constraint in BPF JIT compiler #5580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: bpf-next_base
Choose a base branch
from

Conversation

kernel-patches-daemon-bpf-rc[bot]
Copy link

Pull request for series with
subject: bpf, arm64: relax constraint in BPF JIT compiler
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=980393

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: ad97cb2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980393
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: d81526a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980393
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: eeec23a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980393
version: 1

Tropicao added 2 commits July 11, 2025 10:54
While introducing support for 9+ arguments for tracing programs on
ARM64, commit 9014cf5 ("bpf, arm64: Support up to 12 function
arguments") has also introduced a constraint preventing BPF trampolines
from being generated if the target function consumes a struct argument
passed on stack, because of uncertainties around the exact struct
location: if the struct has been marked as packed or with a custom
alignment, this info is not reflected in BTF data, and so generated
tracing trampolines could read the target function arguments at wrong
offsets.

This issue is not specific to ARM64: there has been an attempt (see [1])
to bring the same constraint to other architectures JIT compilers. But
discussions following this attempt led to the move of this constraint
out of the kernel (see [2]): instead of preventing the kernel from
generating trampolines for those functions consuming structs on stack,
it is simpler to just make sure that those functions with uncertain
struct arguments location are not encoded in BTF information, and so
that one can not even attempt to attach a tracing program to such
function. The task is then deferred to pahole (see [3]).

Now that the constraint is handled by pahole, remove it from the arm64
JIT compiler to keep it simple.

[1] https://lore.kernel.org/bpf/20250613-deny_trampoline_structs_on_stack-v1-0-5be9211768c3@bootlin.com/
[2] https://lore.kernel.org/bpf/CAADnVQ+sj9XhscN9PdmTzjVa7Eif21noAUH3y1K6x5bWcL-5pg@mail.gmail.com/
[3] https://lore.kernel.org/bpf/[email protected]/

Signed-off-by: Alexis Lothoré (eBPF Foundation) <[email protected]>
Now that the constraint preventing attachment to functions consuming
struct on stack has been removed from the kernel (and moved to pahole,
with a slightly smarter detection, to prevent only those that are
packed), re-enable the tracing_struct tests for arm64.

Signed-off-by: Alexis Lothoré (eBPF Foundation) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant