bpf, arm64: JIT support for private stack #9339
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Private stack is allocated in bpf_int_jit_compile() with an alignment of 16. Private stack allocation size includes the stack size determined by verifier and additional space to protect stack overflow and underflow. See below an illustration:
---> memory address increasing
[16 bytes to protect overflow] [normal stack] [16 bytes to protect underflow]
If overflow/underflow is detected, kernel messages will be emited in dmesg like
BPF private stack overflow/underflow detected for prog Fx
BPF Private stack overflow/underflow detected for prog bpf_prog_a41699c234a1567a_subprog1x
After commit bd737fc ("bpf, arm64: Get rid of fpb"), Jited BPF programs use the stack in two ways:
When a private stack is used, ARM64 callee-saved register x27 replaces the stack pointer. The frame pointer usage remains unchanged; but it now points to the top of the private stack.