Skip to contentSkip to conversation

libbpf: fix powerpc's stack register definition in bpf_tracing.h

PATCH Applied Andrii Nakryiko 3 participants 3 messages Oct 20, 2025 – Oct 23, 2025

Subsystems (2)
lore
Share & tools
lore

Andrii Nakryiko

author maintainer
#0 lore raw

PATCH 1/1 libbpf: fix powerpc's stack register definition in bpf_tracing.h

retsnoop's build on powerpc (ppc64le) architecture ([0]) failed due to wrong definition of PT_REGS_SP() macro. Looking at powerpc's implementation of stack unwinding in perf_callchain_user_64() clearly shows that stack pointer register is gpr[1].

Fix libbpf's definition of __PT_SP_REG for powerpc to fix all this.

[0] https://kojipkgs.fedoraproject.org/work/tasks/1544/137921544/build.log

Fixes 138d6153a139 ("samples/bpf: Enable powerpc support")
Cc Naveen N Rao <[email protected]>
---
 tools/lib/bpf/bpf_tracing.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/bpf_tracing.h +1 -1
index a8f6cd4841b0..dbe32a5d02cd 100644
@@ -311,7 +311,7 @@ struct pt_regs___arm64 {
 #define __PT_RET_REG regs[31]
 #define __PT_FP_REG __unsupported__
 #define __PT_RC_REG gpr[3]
-#define __PT_SP_REG sp
+#define __PT_SP_REG gpr[1]
 #define __PT_IP_REG nip
 
 #elif defined(bpf_target_sparc)
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Andrii Nakryiko

retsnoop's build on powerpc (ppc64le) architecture ([0]) failed due to wrong definition of PT_REGS_SP() macro. Looking at powerpc's implementation of stack unwinding in perf_callchain_user_64() clearly shows that stack pointer register is gpr[1].

Fix libbpf's definition of __PT_SP_REG for powerpc to fix all this.

[0] https://kojipkgs.fedoraproject.org/work/tasks/1544/137921544/build.log

Fixes 138d6153a139 ("samples/bpf: Enable powerpc support")
Cc Naveen N Rao <[email protected]>
---
 tools/lib/bpf/bpf_tracing.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/bpf_tracing.h +0 -0
index a8f6cd4841b0..dbe32a5d02cd 100644

tools/lib/bpf/bpf_tracing.h struct pt_regs___arm64 { · line 315

Quoted 6 lines
tools/lib/bpf/bpf_tracing.h +1 -1
@@ -311,7 +311,7 @@ struct pt_regs___arm64 {
 #define __PT_RET_REG regs[31]
 #define __PT_FP_REG __unsupported__
 #define __PT_RC_REG gpr[3]
-#define __PT_SP_REG sp
+#define __PT_SP_REG gpr[1]
 #define __PT_IP_REG nip

:facepalm:

Thanks for fixing this.

- Naveen

#2 lore raw
In reply to Andrii Nakryiko
This patch was applied to bpf/bpf.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <[email protected]>:

Quoted 8 lines · On Mon, 20 Oct 2025 13:36:43 -0700 you wrote:

retsnoop's build on powerpc (ppc64le) architecture ([0]) failed due to wrong definition of PT_REGS_SP() macro. Looking at powerpc's implementation of stack unwinding in perf_callchain_user_64() clearly shows that stack pointer register is gpr[1].

Fix libbpf's definition of __PT_SP_REG for powerpc to fix all this.

[...]

Here is the summary with links:
- [bpf-next] libbpf: fix powerpc's stack register definition in bpf_tracing.h

    https://git.kernel.org/bpf/bpf/c/7221b9caf84b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html