Skip to content

powerpc/bpf: fix JIT code size calculation of bpf trampoline #8821

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 1 commit into
base: bpf-next_base
Choose a base branch
from

Conversation

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

Pull request for series with
subject: powerpc/bpf: fix JIT code size calculation of bpf trampoline
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 5709be4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: be2fea9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 5cffad0
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 53ebef5
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 6aca583
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: b9c09fb
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 60400cd
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4cc2048
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 46eb012
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 91dbac4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 224ee86
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 8e64c38
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 38d976c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 358b1c0
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 358b1c0
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=955580
version: 3

arch_bpf_trampoline_size() provides JIT size of the BPF trampoline
before the buffer for JIT'ing it is allocated. The total number of
instructions emitted for BPF trampoline JIT code depends on where
the final image is located. So, the size arrived at with the dummy
pass in arch_bpf_trampoline_size() can vary from the actual size
needed in  arch_prepare_bpf_trampoline().  When the instructions
accounted in  arch_bpf_trampoline_size() is less than the number of
instructions emitted during the actual JIT compile of the 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)) {

So, during the dummy pass, instead of providing some arbitrary image
location, account for maximum possible instructions if and when there
is a dependency with image location for JIT'ing.

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+
Acked-by: Naveen N Rao (AMD) <[email protected]>
Tested-by: Venkat Rao Bagalkote <[email protected]>
Signed-off-by: Hari Bathini <[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