Signed-off-by: zhang-mingyi66 <zhangmingyi5@huawei.com> (cherry picked from commit eacff27bc7b27303912aa67ee049687f367e375e)
73 lines
2.6 KiB
Diff
73 lines
2.6 KiB
Diff
From 93391a6f90774d4e6ee3d21972ef937eb183067c Mon Sep 17 00:00:00 2001
|
|
From: Super User <root@localhost.localdomain>
|
|
Date: Fri, 14 Mar 2025 17:31:35 +0800
|
|
Subject: [PATCH] add sw_64 support
|
|
|
|
---
|
|
src/bpf_tracing.h | 35 +++++++++++++++++++++++++++++++++++
|
|
1 file changed, 35 insertions(+)
|
|
|
|
diff --git a/src/bpf_tracing.h b/src/bpf_tracing.h
|
|
index 6fb3d0f..ba30c3f 100644
|
|
--- a/src/bpf_tracing.h
|
|
+++ b/src/bpf_tracing.h
|
|
@@ -35,6 +35,9 @@
|
|
#elif defined(__TARGET_ARCH_loongarch)
|
|
#define bpf_target_loongarch
|
|
#define bpf_target_defined
|
|
+#elif defined(__TARGET_ARCH_sw_64)
|
|
+ #define bpf_target_sw64
|
|
+ #define bpf_target_defined
|
|
#else
|
|
|
|
/* Fall back to what the compiler says */
|
|
@@ -68,6 +71,9 @@
|
|
#elif defined(__loongarch__)
|
|
#define bpf_target_loongarch
|
|
#define bpf_target_defined
|
|
+#elif defined(__sw_64__)
|
|
+ #define bpf_target_sw64
|
|
+ #define bpf_target_defined
|
|
#endif /* no compiler target */
|
|
|
|
#endif
|
|
@@ -442,6 +448,35 @@ struct pt_regs___arm64 {
|
|
#define __PT_SP_REG regs[3]
|
|
#define __PT_IP_REG csr_era
|
|
|
|
+#elif defined(bpf_target_sw64)
|
|
+
|
|
+/* sw64 provides struct user_pt_regs instead of struct pt_regs to userspace */
|
|
+struct pt_regs;
|
|
+#define PT_REGS_SW64 const volatile struct user_pt_regs
|
|
+#define PT_REGS_PARM1(x) (((PT_REGS_SW64 *)(x))->regs[16])
|
|
+#define PT_REGS_PARM2(x) (((PT_REGS_SW64 *)(x))->regs[17])
|
|
+#define PT_REGS_PARM3(x) (((PT_REGS_SW64 *)(x))->regs[18])
|
|
+#define PT_REGS_PARM4(x) (((PT_REGS_SW64 *)(x))->regs[19])
|
|
+#define PT_REGS_PARM5(x) (((PT_REGS_SW64 *)(x))->regs[20])
|
|
+#define PT_REGS_RET(x) (((PT_REGS_SW64 *)(x))->regs[26])
|
|
+/* Works only with CONFIG_FRAME_POINTER */
|
|
+#define PT_REGS_FP(x) (((PT_REGS_SW64 *)(x))->regs[15])
|
|
+#define PT_REGS_RC(x) (((PT_REGS_SW64 *)(x))->regs[0])
|
|
+#define PT_REGS_SP(x) (((PT_REGS_SW64 *)(x))->regs[30])
|
|
+#define PT_REGS_IP(x) (((PT_REGS_SW64 *)(x))->pc)
|
|
+
|
|
+#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[16])
|
|
+#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[17])
|
|
+#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[18])
|
|
+#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[19])
|
|
+#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[20])
|
|
+#define PT_REGS_RET_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[26])
|
|
+#define PT_REGS_FP_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[15])
|
|
+#define PT_REGS_RC_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[0])
|
|
+#define PT_REGS_SP_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[30])
|
|
+#define PT_REGS_IP_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), pc)
|
|
+
|
|
+
|
|
#endif
|
|
|
|
#if defined(bpf_target_defined)
|
|
--
|
|
2.43.0
|
|
|