libbpf: Add LoongArch support to bpf_tracing.h
PATCH 1/1 libbpf: Add LoongArch support to bpf_tracing.h
Add PT_REGS macros for LoongArch64 ([0]).
[0]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
--- tools/lib/bpf/bpf_tracing.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
tools/lib/bpf/bpf_tracing.h +21 -0
@@ -32,6 +32,9 @@#elif defined(__TARGET_ARCH_arc)#define bpf_target_arc#define bpf_target_defined +#elif defined(__TARGET_ARCH_loongarch) +#define bpf_target_loongarch +#define bpf_target_defined#else /* Fall back to what the compiler says */
@@ -62,6 +65,9 @@#elif defined(__arc__)#define bpf_target_arc#define bpf_target_defined +#elif defined(__loongarch__) && __loongarch_grlen ==64 +#define bpf_target_loongarch +#define bpf_target_defined#endif /* no compiler target */ #endif
@@ -258,6 +264,21 @@ struct pt_regs___arm64 {/* arc does not select ARCH_HAS_SYSCALL_WRAPPER. */ #define PT_REGS_SYSCALL_REGS (ctx) ctx +#elif defined(bpf_target_loongarch) + +#define __PT_PARM1_REG regs[4] +#define __PT_PARM2_REG regs[5] +#define __PT_PARM3_REG regs[6] +#define __PT_PARM4_REG regs[7] +#define __PT_PARM5_REG regs[8] +#define __PT_RET_REG regs[1] +#define __PT_FP_REG regs[22] +#define __PT_RC_REG regs[4] +#define __PT_SP_REG regs[3] +#define __PT_IP_REG csr_era +/* loongarch does not select ARCH_HAS_SYSCALL_WRAPPER. */ +#define PT_REGS_SYSCALL_REGS (ctx) ctx +#endif #if defined(bpf_target_defined)
--
2.31.1
WANG Xuerui
reviewerHi,
Quoted 24 lines · Hengqi Chen
Add
PT_REGSmacros for LoongArch64 ([0]).[0]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
Signed-off-by Hengqi Chen <[email protected]>--- tools/lib/bpf/bpf_tracing.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)tools/lib/bpf/bpf_tracing.h +3
-0@@ -32,6 +32,9 @@#elif defined(__TARGET_ARCH_arc)#define bpf_target_arc#define bpf_target_defined +#elif defined(__TARGET_ARCH_loongarch) +#define bpf_target_loongarch +#define bpf_target_defined#else /* Fall back to what the compiler says */
tools/lib/bpf/bpf_tracing.h line 68
Quoted 4 lines
tools/lib/bpf/bpf_tracing.h +1
-0@@ -62,6 +65,9 @@#elif defined(__arc__)#define bpf_target_arc#define bpf_target_defined +#elif defined(__loongarch__) && __loongarch_grlen ==64
Isn't the whole patch independent of bitness? I'd suggest just removing this GRLen check so we don't need another change when we want LoongArch32 too.
Please adjust the commit message wording accordingly too.
Quoted 30 lines
tools/lib/bpf/bpf_tracing.h +17
-1+#define bpf_target_loongarch +#define bpf_target_defined#endif /* no compiler target */ #endif @@ -258,6 +264,21 @@ struct pt_regs___arm64 {/* arc does not select ARCH_HAS_SYSCALL_WRAPPER. */ #define PT_REGS_SYSCALL_REGS (ctx) ctx +#elif defined(bpf_target_loongarch) + +#define __PT_PARM1_REG regs[4] +#define __PT_PARM2_REG regs[5] +#define __PT_PARM3_REG regs[6] +#define __PT_PARM4_REG regs[7] +#define __PT_PARM5_REG regs[8] +#define __PT_RET_REG regs[1] +#define __PT_FP_REG regs[22] +#define __PT_RC_REG regs[4] +#define __PT_SP_REG regs[3] +#define __PT_IP_REG csr_era +/* loongarch does not select ARCH_HAS_SYSCALL_WRAPPER. */ +#define PT_REGS_SYSCALL_REGS (ctx) ctx +#endif #if defined(bpf_target_defined) --2.31.1
Signature · 3 lines
WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
Quoted 35 lines · Hengqi Chen
Add
PT_REGSmacros for LoongArch64 ([0]).[0]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
Signed-off-by Hengqi Chen <[email protected]>--- tools/lib/bpf/bpf_tracing.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)tools/lib/bpf/bpf_tracing.h +6
-0@@ -32,6 +32,9 @@#elif defined(__TARGET_ARCH_arc)#define bpf_target_arc#define bpf_target_defined +#elif defined(__TARGET_ARCH_loongarch) +#define bpf_target_loongarch +#define bpf_target_defined#else /* Fall back to what the compiler says */ @@ -62,6 +65,9 @@#elif defined(__arc__)#define bpf_target_arc#define bpf_target_defined +#elif defined(__loongarch__) && __loongarch_grlen ==64 +#define bpf_target_loongarch +#define bpf_target_defined#endif /* no compiler target */ #endif
tools/lib/bpf/bpf_tracing.h struct pt_regs___arm64 { · line 268
Quoted 5 lines
tools/lib/bpf/bpf_tracing.h +2
-0@@ -258,6 +264,21 @@ struct pt_regs___arm64 {/* arc does not select ARCH_HAS_SYSCALL_WRAPPER. */ #define PT_REGS_SYSCALL_REGS (ctx) ctx +#elif defined(bpf_target_loongarch) +
please put https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
in a comment somewhere here
Quoted 18 lines
tools/lib/bpf/bpf_tracing.h +13
-1+#define __PT_PARM1_REG regs[4] +#define __PT_PARM2_REG regs[5] +#define __PT_PARM3_REG regs[6] +#define __PT_PARM4_REG regs[7] +#define __PT_PARM5_REG regs[8] +#define __PT_RET_REG regs[1] +#define __PT_FP_REG regs[22] +#define __PT_RC_REG regs[4] +#define __PT_SP_REG regs[3] +#define __PT_IP_REG csr_era +/* loongarch does not select ARCH_HAS_SYSCALL_WRAPPER. */ +#define PT_REGS_SYSCALL_REGS (ctx) ctx +#endif #if defined(bpf_target_defined) --2.31.1