Skip to content

Commit

Permalink
Fix for verifier error on arm64
Browse files Browse the repository at this point in the history
See comments for more details. Not sure what commits changed the behaviour but this
hack works around this issue.
  • Loading branch information
javierhonduco committed Apr 23, 2024
1 parent 5bfb47c commit a8094d1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/bpf/profiler.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ struct {
} rate_limits SEC(".maps");


// On arm64 running 6.8.4-200.fc39.aarch64 the verifier fails with argument list too long. This
// did not use to happen before and it's probably due to a regression in the way the verifier
// accounts for the explored paths. I have tried many other things, such as two mid variables
// but that did not do it. The theory of why this works is that perhaps it's making the verifier
// reset the state it had about the program exploration so the branches its exploring per iteration
// do not grow as much.
#ifdef __TARGET_ARCH_arm64
static u32 __attribute__((optnone)) verifier_workaround(u32 value) {
return value;
}
#endif
#ifdef __TARGET_ARCH_x86
static __always_inline u32 verifier_workaround(u32 value) {
return value;
}
#endif

// Binary search the unwind table to find the row index containing the unwind
// information for a given program counter (pc) relative to the object file.
static __always_inline u64 find_offset_for_pc(stack_unwind_table_t *table, u64 pc, u64 left,
Expand All @@ -85,8 +102,7 @@ static __always_inline u64 find_offset_for_pc(stack_unwind_table_t *table, u64 p
return found;
}

u32 mid = (left + right) / 2;

u32 mid = verifier_workaround((left + right) / 2);
// Appease the verifier.
if (mid < 0 || mid >= MAX_UNWIND_TABLE_SIZE) {
LOG("\t.should never happen, mid: %lu, max: %lu", mid,
Expand Down

0 comments on commit a8094d1

Please sign in to comment.