Skip to content

Commit eacf252

Browse files
Vladimir IsaevSergey Matyukevich
authored andcommitted
libbpf: add ARC support to bpf_tracing.h
Add PT_REGS macros suitable for ARCompact and ARCv2. Signed-off-by: Vladimir Isaev <isaev@synopsys.com>
1 parent 33e544e commit eacf252

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tools/include/uapi/asm/bpf_perf_event.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#if defined(__aarch64__)
22
#include "../../arch/arm64/include/uapi/asm/bpf_perf_event.h"
3+
#elif defined(__arc__)
4+
#include "../../arch/arc/include/uapi/asm/bpf_perf_event.h"
35
#elif defined(__s390__)
46
#include "../../arch/s390/include/uapi/asm/bpf_perf_event.h"
57
#elif defined(__riscv)

tools/lib/bpf/bpf_tracing.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#elif defined(__TARGET_ARCH_riscv)
2828
#define bpf_target_riscv
2929
#define bpf_target_defined
30+
#elif defined(__TARGET_ARCH_arc)
31+
#define bpf_target_arc
32+
#define bpf_target_defined
3033
#else
3134

3235
/* Fall back to what the compiler says */
@@ -54,6 +57,9 @@
5457
#elif defined(__riscv) && __riscv_xlen == 64
5558
#define bpf_target_riscv
5659
#define bpf_target_defined
60+
#elif defined(__arc__)
61+
#define bpf_target_arc
62+
#define bpf_target_defined
5763
#endif /* no compiler target */
5864

5965
#endif
@@ -320,6 +326,30 @@ struct pt_regs;
320326
#define PT_REGS_SP_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), sp)
321327
#define PT_REGS_IP_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), epc)
322328

329+
#elif defined(bpf_target_arc)
330+
331+
struct pt_regs;
332+
#define PT_REGS_ARC const volatile struct user_regs_struct
333+
#define PT_REGS_PARM1(x) (((PT_REGS_ARC *)(x))->scratch.r0)
334+
#define PT_REGS_PARM2(x) (((PT_REGS_ARC *)(x))->scratch.r1)
335+
#define PT_REGS_PARM3(x) (((PT_REGS_ARC *)(x))->scratch.r2)
336+
#define PT_REGS_PARM4(x) (((PT_REGS_ARC *)(x))->scratch.r3)
337+
#define PT_REGS_PARM5(x) (((PT_REGS_ARC *)(x))->scratch.r4)
338+
#define PT_REGS_RET(x) (((PT_REGS_ARC *)(x))->scratch.blink)
339+
#define PT_REGS_RC(x) (((PT_REGS_ARC *)(x))->scratch.r0)
340+
#define PT_REGS_SP(x) (((PT_REGS_ARC *)(x))->scratch.sp)
341+
#define PT_REGS_IP(x) (((PT_REGS_ARC *)(x))->scratch.ret)
342+
343+
#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((PT_REGS_ARC *)(x), scratch.r0)
344+
#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((PT_REGS_ARC *)(x), scratch.r1)
345+
#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((PT_REGS_ARC *)(x), scratch.r2)
346+
#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((PT_REGS_ARC *)(x), scratch.r3)
347+
#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((PT_REGS_ARC *)(x), scratch.r4)
348+
#define PT_REGS_RET_CORE(x) BPF_CORE_READ((PT_REGS_ARC *)(x), scratch.blink)
349+
#define PT_REGS_RC_CORE(x) BPF_CORE_READ((PT_REGS_ARC *)(x), scratch.r0)
350+
#define PT_REGS_SP_CORE(x) BPF_CORE_READ((PT_REGS_ARC *)(x), scratch.sp)
351+
#define PT_REGS_IP_CORE(x) BPF_CORE_READ((PT_REGS_ARC *)(x), scratch.ret)
352+
323353
#endif
324354

325355
#if defined(bpf_target_powerpc)

0 commit comments

Comments
 (0)