Skip to content

Commit 5e652f3

Browse files
authored
Fix legacy eBPF register definition on ARM64 (#155)
1 parent 0e4aecc commit 5e652f3

3 files changed

Lines changed: 35 additions & 4 deletions

File tree

‎src/tracer/ebpf/kern/procmonEBPF_common.h‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,37 @@
5252

5353
#define EBPF_RET_UNUSED 0
5454

55+
#ifdef __BPF_TRACING__
56+
#ifdef EBPF_CO_RE
57+
typedef struct pt_regs procmon_pt_regs;
58+
#else
59+
typedef struct
60+
{
61+
unsigned long r15;
62+
unsigned long r14;
63+
unsigned long r13;
64+
unsigned long r12;
65+
unsigned long rbp;
66+
unsigned long rbx;
67+
unsigned long r11;
68+
unsigned long r10;
69+
unsigned long r9;
70+
unsigned long r8;
71+
unsigned long rax;
72+
unsigned long rcx;
73+
unsigned long rdx;
74+
unsigned long rsi;
75+
unsigned long rdi;
76+
unsigned long orig_rax;
77+
unsigned long rip;
78+
unsigned long cs;
79+
unsigned long eflags;
80+
unsigned long rsp;
81+
unsigned long ss;
82+
} procmon_pt_regs;
83+
#endif
84+
#endif
85+
5586
struct SyscallEvent
5687
{
5788
pid_t pid;

‎src/tracer/ebpf/kern/procmonGenericEntry_rawtp.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static inline int PopulateArguments(enum ProcmonArgTag type, unsigned long arg,
117117
// Populates the event with the arguments for the syscall.
118118
// ------------------------------------------------------------------------------------------
119119
__attribute__((always_inline))
120-
static inline bool set_eventArgs(unsigned long *a, const struct pt_regs *regs)
120+
static inline bool set_eventArgs(unsigned long *a, const procmon_pt_regs *regs)
121121
{
122122
int ret = 0;
123123
ret |= bpf_probe_read(&a[0], sizeof(a[0]), &SYSCALL_PT_REGS_PARM1(regs));
@@ -265,7 +265,7 @@ int genericRawEnter(struct bpf_our_raw_tracepoint_args *ctx)
265265
uint32_t cpuId = bpf_get_smp_processor_id();
266266
uint64_t pidTid = bpf_get_current_pid_tgid();
267267
int pid = pidTid >> 32;
268-
struct pt_regs* regs = NULL;
268+
procmon_pt_regs* regs = NULL;
269269

270270
//
271271
// Check all filters
@@ -304,7 +304,7 @@ int genericRawEnter(struct bpf_our_raw_tracepoint_args *ctx)
304304
sysEntry->userStackCount = bpf_get_stack(ctx, &sysEntry->userStack, MAX_STACK_FRAMES * sizeof(uint64_t), BPF_F_USER_STACK) / sizeof(uint64_t);
305305
sysEntry->timestamp = bpf_ktime_get_ns();
306306

307-
regs = (struct pt_regs *)ctx->args[0];
307+
regs = (procmon_pt_regs *)ctx->args[0];
308308
unsigned long a[8];
309309
if (!set_eventArgs(a, regs))
310310
{

‎src/tracer/ebpf/kern/procmonGenericExit_rawtp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ __attribute__((flatten))
3434
int genericRawExit(struct bpf_our_raw_tracepoint_args *ctx)
3535
{
3636
uint64_t pidTid = bpf_get_current_pid_tgid();
37-
const struct pt_regs *regs = (const struct pt_regs *)ctx->args[0];
37+
const procmon_pt_regs *regs = (const procmon_pt_regs *)ctx->args[0];
3838
int pid = pidTid >> 32;
3939

4040
//

0 commit comments

Comments
 (0)