22 Star 0 Fork 31

src-openEuler/libbpf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
add-sw_64-support.patch 2.59 KB
一键复制 编辑 原始数据 按行查看 历史
ZMY 提交于 2025-03-31 10:10 +08:00 . sync from openEuler-24.03-LTS-SP1
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/libbpf.git
git@gitee.com:src-openeuler/libbpf.git
src-openeuler
libbpf
libbpf
master

搜索帮助