linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] powerpc64/bpf: fix tail calls for PCREL addressing
@ 2024-04-02 10:58 Hari Bathini
  2024-04-02 10:58 ` [PATCH v3 2/2] powerpc/bpf: enable kfunc call Hari Bathini
  2024-04-02 11:35 ` [PATCH v3 1/2] powerpc64/bpf: fix tail calls for PCREL addressing Christophe Leroy
  0 siblings, 2 replies; 5+ messages in thread
From: Hari Bathini @ 2024-04-02 10:58 UTC (permalink / raw)
  To: linuxppc-dev, bpf
  Cc: Song Liu, Daniel Borkmann, Alexei Starovoitov, stable,
	Andrii Nakryiko, Naveen N. Rao, Martin KaFai Lau

With PCREL addressing, there is no kernel TOC. So, it is not setup in
prologue when PCREL addressing is used. But the number of instructions
to skip on a tail call was not adjusted accordingly. That resulted in
not so obvious failures while using tailcalls. 'tailcalls' selftest
crashed the system with the below call trace:

  bpf_test_run+0xe8/0x3cc (unreliable)
  bpf_prog_test_run_skb+0x348/0x778
  __sys_bpf+0xb04/0x2b00
  sys_bpf+0x28/0x38
  system_call_exception+0x168/0x340
  system_call_vectored_common+0x15c/0x2ec

Fixes: 7e3a68be42e1 ("powerpc/64: vmlinux support building with PCREL addresing")
Cc: stable@vger.kernel.org
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
---

* Changes in v3:
  - New patch to fix tailcall issues with PCREL addressing.


 arch/powerpc/net/bpf_jit_comp64.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
index 79f23974a320..7f62ac4b4e65 100644
--- a/arch/powerpc/net/bpf_jit_comp64.c
+++ b/arch/powerpc/net/bpf_jit_comp64.c
@@ -285,8 +285,10 @@ static int bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 o
 	int b2p_index = bpf_to_ppc(BPF_REG_3);
 	int bpf_tailcall_prologue_size = 8;
 
+#ifndef CONFIG_PPC_KERNEL_PCREL
 	if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V2))
 		bpf_tailcall_prologue_size += 4; /* skip past the toc load */
+#endif
 
 	/*
 	 * if (index >= array->map.max_entries)
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-15  7:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-02 10:58 [PATCH v3 1/2] powerpc64/bpf: fix tail calls for PCREL addressing Hari Bathini
2024-04-02 10:58 ` [PATCH v3 2/2] powerpc/bpf: enable kfunc call Hari Bathini
2024-04-02 11:38   ` Christophe Leroy
2024-04-15  7:12   ` Naveen N Rao
2024-04-02 11:35 ` [PATCH v3 1/2] powerpc64/bpf: fix tail calls for PCREL addressing Christophe Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).