-
Notifications
You must be signed in to change notification settings - Fork 126
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
powerpc64/bpf: fix JIT code size calculation of bpf trampoline #8714
base: bpf-next_base
Are you sure you want to change the base?
Conversation
Upstream branch: 9aa8fe2 |
Upstream branch: 9aa8fe2 |
c3588fa
to
c0e3c74
Compare
Upstream branch: 9aa8fe2 |
c0e3c74
to
8397e95
Compare
35ab59d
to
bf339f7
Compare
Upstream branch: 9aa8fe2 |
8397e95
to
66328f6
Compare
bf339f7
to
9809c6b
Compare
Upstream branch: aa918db |
66328f6
to
f412339
Compare
9809c6b
to
0a09ea9
Compare
Upstream branch: 4e82c87 |
f412339
to
95b9f5b
Compare
0a09ea9
to
1a03c01
Compare
Upstream branch: 4e82c87 |
95b9f5b
to
e9d4cfe
Compare
1a03c01
to
a4b8db7
Compare
Upstream branch: 1e7857b |
e9d4cfe
to
751ee52
Compare
a4b8db7
to
17475dd
Compare
Upstream branch: 1e7857b |
751ee52
to
8f382fc
Compare
17475dd
to
f11a40d
Compare
The JIT compile of ldimm instructions can be anywhere between 1-5 instructions long depending on the value being loaded. arch_bpf_trampoline_size() provides JIT size of the BPF trampoline before the buffer for JIT'ing it is allocated. BPF trampoline JIT code has ldimm instructions that need to load the value of pointer to struct bpf_tramp_image. But this pointer value is not same while calling arch_bpf_trampoline_size() & arch_prepare_bpf_trampoline(). So, the size arrived at using arch_bpf_trampoline_size() can vary from the size needed in arch_prepare_bpf_trampoline(). When the number of ldimm instructions emitted in arch_bpf_trampoline_size() is less than the number of ldimm instructions emitted during the actual JIT compile of trampoline, the below warning is produced: WARNING: CPU: 8 PID: 204190 at arch/powerpc/net/bpf_jit_comp.c:981 __arch_prepare_bpf_trampoline.isra.0+0xd2c/0xdcc which is: /* Make sure the trampoline generation logic doesn't overflow */ if (image && WARN_ON_ONCE(&image[ctx->idx] > (u32 *)rw_image_end - BPF_INSN_SAFETY)) { Pass NULL as the first argument to __arch_prepare_bpf_trampoline() call from arch_bpf_trampoline_size() function, to differentiate it from how arch_prepare_bpf_trampoline() calls it and ensure maximum possible instructions are emitted in arch_bpf_trampoline_size() for ldimm instructions that load a different value during the actual JIT compile of BPF trampoline. Fixes: d243b62 ("powerpc64/bpf: Add support for bpf trampolines") Reported-by: Venkat Rao Bagalkote <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Cc: [email protected] # v6.13+ Signed-off-by: Hari Bathini <[email protected]> Tested-by: Venkat Rao Bagalkote <[email protected]>
Upstream branch: 25601e8 |
8f382fc
to
1bff14a
Compare
Pull request for series with
subject: powerpc64/bpf: fix JIT code size calculation of bpf trampoline
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=947435