Skip to content

Commit

Permalink
Use the right register type in arm64
Browse files Browse the repository at this point in the history
As we were using thhe x86 one, `bpf_user_pt_regs_t` is defined in
vmlinux as:

```
typedef struct pt_regs bpf_user_pt_regs_t;
```

in x86 and:

```
typedef struct user_pt_regs bpf_user_pt_regs_t;
```

in arm64

Future work
===========

Ensure `retrieve_task_registers` is correct for arm64.

Test Plan
=========

Tested on my x86 and arm64 machines.
  • Loading branch information
javierhonduco committed Apr 29, 2024
1 parent a932078 commit 4a3f25e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bpf/profiler.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static __always_inline bool retrieve_task_registers(u64 *ip, u64 *sp, u64 *bp) {
}

void *ptr = stack + THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING;
struct pt_regs *regs = ((struct pt_regs *)ptr) - 1;
bpf_user_pt_regs_t *regs = ((bpf_user_pt_regs_t *)ptr) - 1;

*ip = PT_REGS_IP_CORE(regs);
*sp = PT_REGS_SP_CORE(regs);
Expand Down Expand Up @@ -560,7 +560,7 @@ int dwarf_unwind(struct bpf_perf_event_data *ctx) {
}

// Set up the initial unwinding state.
static __always_inline bool set_initial_state(unwind_state_t *unwind_state, struct pt_regs *regs) {
static __always_inline bool set_initial_state(unwind_state_t *unwind_state, bpf_user_pt_regs_t *regs) {
unwind_state->stack.len = 0;
unwind_state->tail_calls = 0;

Expand Down

0 comments on commit 4a3f25e

Please sign in to comment.