diff --git a/add-sw_64-support.patch b/add-sw_64-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..194737d7b597a4b21566019c07b1e139a851807e --- /dev/null +++ b/add-sw_64-support.patch @@ -0,0 +1,60 @@ + +From 636f4e3060af9cd29365d8ee5f2b3cc4261bdcf6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=E9=A9=AC=E6=B5=B7=E4=BA=AE?= +Date: Fri, 13 Jun 2025 10:02:57 +0800 +Subject: [PATCH] add sw_64 support +--- + libbpf/src/bpf_tracing.h | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) +diff --git a/libbpf/src/bpf_tracing.h b/libbpf/src/bpf_tracing.h +index 6fb3d0f..b5bc4d3 100644 +--- a/libbpf/src/bpf_tracing.h ++++ b/libbpf/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,24 @@ 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_CAST(x) ((PT_REGS_SW64 *)(x)) ++#define __PT_PARM1_REG regs[16] ++#define __PT_PARM2_REG regs[17] ++#define __PT_PARM3_REG regs[18] ++#define __PT_PARM4_REG regs[19] ++#define __PT_PARM5_REG regs[20] ++#define __PT_RET_REG regs[26] ++/* Works only with CONFIG_FRAME_POINTER */ ++#define __PT_FP_REG regs[15] ++#define __PT_RC_REG regs[0] ++#define __PT_SP_REG regs[30] ++#define __PT_IP_REG pc ++ + #endif + + #if defined(bpf_target_defined) +-- +2.20.1 + diff --git a/bpftool.spec b/bpftool.spec index 946c75472ff9d97a7003f5d04582b2f466bea90e..dda173c64f8043737fe9c0a9b166821e5c3dc907 100644 --- a/bpftool.spec +++ b/bpftool.spec @@ -1,6 +1,6 @@ Name: bpftool Version: 7.2.0 -Release: 1 +Release: 2 Summary: Tool for inspection and manipulation of BPF programs and maps License: GPL-2.0-only URL: https://www.kernel.org/ @@ -12,6 +12,7 @@ Patch0: bpftool-use-a-local-copy-of-perf_event-to-fix-access.patch Patch1: bpftool-define-a-local-bpf_perf_link-to-fix-accessin.patch Patch2: bpftool-use-a-local-copy-of-bpf_link_type_perf_event.patch Patch3: bpftool-use-a-local-bpf_perf_event_value-to-fix-acce.patch +Patch4: add-sw_64-support.patch %description bpftool allows for inspection and simple modification of BPF objects (programs @@ -38,5 +39,8 @@ mv %{buildroot}%{_datadir}/bash-completion/completions/bpftool %{buildroot}%{_sy %{_sysconfdir}/bash_completion.d/bpftool %changelog +* Wed Sep 03 2025 liweigang - 7.2.0-2 +- add sw_64 support + * Sat Jan 20 2024 liuxin - 7.2.0-1 - Init package