Skip to contentSkip to conversation

riscv, libbpf: use a0 for RC register

PATCH Applied Yixun Lan 4 participants 4 messages Jul 6, 2022 – Jul 7, 2022

Subsystems (5)
lore
Share & tools
lore

Yixun Lan

author
#0 lore raw

PATCH 1/1 riscv, libbpf: use a0 for RC register

According to the RISC-V calling convention register usage here[1], a0 is used as return value register, so rename it to make it consistent with the spec.

[1] section 18.2, table 18.2
https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf

Fixes 589fed479ba1 ("riscv, libbpf: Add RISC-V (RV64) support to bpf_tracing.h")

---

I'm adding a Fixes tag here, although the original version may just work fine, and shouldn't be considered as a real error. But, the benefit is that we could make it consistent with RISC-V spec, and all other tools will follow the same usage.

thanks, and let's me if there is any issue that I may not noticed..

---
 tools/lib/bpf/bpf_tracing.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/bpf_tracing.h +1 -1
index 01ce121c302df..11f9096407fc4 100644
@@ -233,7 +233,7 @@ struct pt_regs___arm64 {
 #define __PT_PARM5_REG a4
 #define __PT_RET_REG ra
 #define __PT_FP_REG s0
-#define __PT_RC_REG a5
+#define __PT_RC_REG a0
 #define __PT_SP_REG sp
 #define __PT_IP_REG pc
 /* riscv does not select ARCH_HAS_SYSCALL_WRAPPER. */
Signature · 1 line
2.35.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Yixun Lan

According to the RISC-V calling convention register usage here[1], a0 is used as return value register, so rename it to make it consistent with the spec.

[1] section 18.2, table 18.2
https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf

Fixes 589fed479ba1 ("riscv, libbpf: Add RISC-V (RV64) support to bpf_tracing.h")

Nice catch!

#3 lore raw
In reply to Yixun Lan
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Quoted 8 lines · On Wed, 6 Jul 2022 22:02:04 +0800 you wrote:

According to the RISC-V calling convention register usage here[1], a0 is used as return value register, so rename it to make it consistent with the spec.

[1] section 18.2, table 18.2
https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf

[...]

Here is the summary with links:
- riscv, libbpf: use a0 for RC register

    https://git.kernel.org/bpf/bpf-next/c/935dc35c7531

You are awesome, thank you!

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