已开启
[sync] PR-162: add sw_64 support #166
AtomGit-Bot创建于 2025年3月19日
[sync] PR-162: add sw_64 support #166
已开启
共 2 个文件变更+77-1
| @@ -0,0 +1,72 @@ | |||
| 1 | +From 93391a6f90774d4e6ee3d21972ef937eb183067c Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: Super User <root@localhost.localdomain> | ||
| 3 | +Date: Fri, 14 Mar 2025 17:31:35 +0800 | ||
| 4 | +Subject: [PATCH] add sw_64 support | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + src/bpf_tracing.h | 35 +++++++++++++++++++++++++++++++++++ | ||
| 8 | + 1 file changed, 35 insertions(+) | ||
| 9 | + | ||
| 10 | +diff --git a/src/bpf_tracing.h b/src/bpf_tracing.h | ||
| 11 | +index 6fb3d0f..ba30c3f 100644 | ||
| 12 | +--- a/src/bpf_tracing.h | ||
| 13 | ++++ b/src/bpf_tracing.h | ||
| 14 | +@@ -35,6 +35,9 @@ | ||
| 15 | + #elif defined(__TARGET_ARCH_loongarch) | ||
| 16 | + #define bpf_target_loongarch | ||
| 17 | + #define bpf_target_defined | ||
| 18 | ++#elif defined(__TARGET_ARCH_sw_64) | ||
| 19 | ++ #define bpf_target_sw64 | ||
| 20 | ++ #define bpf_target_defined | ||
| 21 | + #else | ||
| 22 | + | ||
| 23 | + /* Fall back to what the compiler says */ | ||
| 24 | +@@ -68,6 +71,9 @@ | ||
| 25 | + #elif defined(__loongarch__) | ||
| 26 | + #define bpf_target_loongarch | ||
| 27 | + #define bpf_target_defined | ||
| 28 | ++#elif defined(__sw_64__) | ||
| 29 | ++ #define bpf_target_sw64 | ||
| 30 | ++ #define bpf_target_defined | ||
| 31 | + #endif /* no compiler target */ | ||
| 32 | + | ||
| 33 | + #endif | ||
| 34 | +@@ -442,6 +448,35 @@ struct pt_regs___arm64 { | ||
| 35 | + #define __PT_SP_REG regs[3] | ||
| 36 | + #define __PT_IP_REG csr_era | ||
| 37 | + | ||
| 38 | ++#elif defined(bpf_target_sw64) | ||
| 39 | ++ | ||
| 40 | ++/* sw64 provides struct user_pt_regs instead of struct pt_regs to userspace */ | ||
| 41 | ++struct pt_regs; | ||
| 42 | ++#define PT_REGS_SW64 const volatile struct user_pt_regs | ||
| 43 | ++#define PT_REGS_PARM1(x) (((PT_REGS_SW64 *)(x))->regs[16]) | ||
| 44 | ++#define PT_REGS_PARM2(x) (((PT_REGS_SW64 *)(x))->regs[17]) | ||
| 45 | ++#define PT_REGS_PARM3(x) (((PT_REGS_SW64 *)(x))->regs[18]) | ||
| 46 | ++#define PT_REGS_PARM4(x) (((PT_REGS_SW64 *)(x))->regs[19]) | ||
| 47 | ++#define PT_REGS_PARM5(x) (((PT_REGS_SW64 *)(x))->regs[20]) | ||
| 48 | ++#define PT_REGS_RET(x) (((PT_REGS_SW64 *)(x))->regs[26]) | ||
| 49 | ++/* Works only with CONFIG_FRAME_POINTER */ | ||
| 50 | ++#define PT_REGS_FP(x) (((PT_REGS_SW64 *)(x))->regs[15]) | ||
| 51 | ++#define PT_REGS_RC(x) (((PT_REGS_SW64 *)(x))->regs[0]) | ||
| 52 | ++#define PT_REGS_SP(x) (((PT_REGS_SW64 *)(x))->regs[30]) | ||
| 53 | ++#define PT_REGS_IP(x) (((PT_REGS_SW64 *)(x))->pc) | ||
| 54 | ++ | ||
| 55 | ++#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[16]) | ||
| 56 | ++#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[17]) | ||
| 57 | ++#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[18]) | ||
| 58 | ++#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[19]) | ||
| 59 | ++#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[20]) | ||
| 60 | ++#define PT_REGS_RET_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[26]) | ||
| 61 | ++#define PT_REGS_FP_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[15]) | ||
| 62 | ++#define PT_REGS_RC_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[0]) | ||
| 63 | ++#define PT_REGS_SP_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), regs[30]) | ||
| 64 | ++#define PT_REGS_IP_CORE(x) BPF_CORE_READ((PT_REGS_SW64 *)(x), pc) | ||
| 65 | ++ | ||
| 66 | ++ | ||
| 67 | + #endif | ||
| 68 | + | ||
| 69 | + #if defined(bpf_target_defined) | ||
| 70 | +-- | ||
| 71 | +2.43.0 | ||
| 72 | + | ||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | Name: %{githubname} | 5 | Name: %{githubname} |
| 6 | Version: %{githubver} | 6 | Version: %{githubver} |
| 7 | -Release: 6 | 7 | +Release: 7 |
| 8 | Summary: Libbpf library | 8 | Summary: Libbpf library |
| 9 | 9 | ||
| 10 | License: LGPLv2 or BSD | 10 | License: LGPLv2 or BSD |
| @@ -22,6 +22,7 @@ Patch0005: backport-libbpf-Avoid-uninitialized-value-in-BPF_CORE_READ_BI.pa | |||
| 22 | Patch0006: backport-libbpf-Add-NULL-checks-to-bpf_object__prev_map,next_.patch | 22 | Patch0006: backport-libbpf-Add-NULL-checks-to-bpf_object__prev_map,next_.patch |
| 23 | Patch0007: backport-libbpf-Apply-map_set_def_max_entries-for-inner_maps-.patch | 23 | Patch0007: backport-libbpf-Apply-map_set_def_max_entries-for-inner_maps-.patch |
| 24 | Patch0008: backport-libbpf-Dont-take-direct-pointers-into-BTF-data-from-.patch | 24 | Patch0008: backport-libbpf-Dont-take-direct-pointers-into-BTF-data-from-.patch |
| 25 | +Patch0009: add-sw_64-support.patch | ||
| 25 | 26 | ||
| 26 | # This package supersedes libbpf from kernel-tools, | 27 | # This package supersedes libbpf from kernel-tools, |
| 27 | # which has default Epoch: 0. By having Epoch: 1 | 28 | # which has default Epoch: 0. By having Epoch: 1 |
| @@ -74,6 +75,9 @@ developing applications that use %{name} | |||
| 74 | %{_libdir}/libbpf.a | 75 | %{_libdir}/libbpf.a |
| 75 | 76 | ||
| 76 | %changelog | 77 | %changelog |
| 78 | +* Fri Mar 14 2025 mahailiang <mahailiang@uniontech.com> 2:1.2.2-7 | ||
| 79 | +- add sw_64 support | ||
| 80 | + | ||
| 77 | * Mon Dec 23 2024 zhangmingyi <zhangmingyi5@huawei.com> 2:1.2.2-6 | 81 | * Mon Dec 23 2024 zhangmingyi <zhangmingyi5@huawei.com> 2:1.2.2-6 |
| 78 | - backport patch from upstream: | 82 | - backport patch from upstream: |
| 79 | backport-libbpf-Dont-take-direct-pointers-into-BTF-data-from-.patch | 83 | backport-libbpf-Dont-take-direct-pointers-into-BTF-data-from-.patch |