diff --git a/support/ebpf/native_stack_trace.ebpf.c b/support/ebpf/native_stack_trace.ebpf.c index f4727d6f..d6ca687f 100644 --- a/support/ebpf/native_stack_trace.ebpf.c +++ b/support/ebpf/native_stack_trace.ebpf.c @@ -84,30 +84,6 @@ ErrorCode push_native(Trace *trace, u64 file, u64 line, bool return_address) { return _push_with_return_address(trace, file, line, FRAME_MARKER_NATIVE, return_address); } -#ifdef __aarch64__ -// Strips the PAC tag from a pointer. -// -// While all pointers can contain PAC tags, we only apply this function to code pointers, because -// that's where normalization is required to make the stack delta lookups work. Note that if that -// should ever change, we'd need a different mask for the data pointers, because it might diverge -// from the mask for code pointers. -static inline u64 normalize_pac_ptr(u64 ptr) { - // Retrieve PAC mask from the system config. - u32 key = 0; - SystemConfig* syscfg = bpf_map_lookup_elem(&system_config, &key); - if (!syscfg) { - // Unreachable: array maps are always fully initialized. - return ptr; - } - - // Mask off PAC bits. Since we're always applying this to usermode pointers that should have all - // the high bits set to 0, we don't need to consider the case of having to fill up the resulting - // hole with 1s (like we'd have to for kernel ptrs). - ptr &= syscfg->inverse_pac_mask; - return ptr; -} -#endif - // A single step for the bsearch into the big_stack_deltas array. This is really a textbook bsearch // step, built in a way to update the value of *lo and *hi. This function will be called repeatedly // (since we cannot do loops). The return value signals whether the bsearch came to an end / found diff --git a/support/ebpf/tracemgmt.h b/support/ebpf/tracemgmt.h index e665f02e..ca9b8d90 100644 --- a/support/ebpf/tracemgmt.h +++ b/support/ebpf/tracemgmt.h @@ -455,6 +455,30 @@ void tail_call(void *ctx, int next) { #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3) #endif +#ifdef __aarch64__ +// Strips the PAC tag from a pointer. +// +// While all pointers can contain PAC tags, we only apply this function to code pointers, because +// that's where normalization is required to make the stack delta lookups work. Note that if that +// should ever change, we'd need a different mask for the data pointers, because it might diverge +// from the mask for code pointers. +static inline u64 normalize_pac_ptr(u64 ptr) { + // Retrieve PAC mask from the system config. + u32 key = 0; + SystemConfig* syscfg = bpf_map_lookup_elem(&system_config, &key); + if (!syscfg) { + // Unreachable: array maps are always fully initialized. + return ptr; + } + + // Mask off PAC bits. Since we're always applying this to usermode pointers that should have all + // the high bits set to 0, we don't need to consider the case of having to fill up the resulting + // hole with 1s (like we'd have to for kernel ptrs). + ptr &= syscfg->inverse_pac_mask; + return ptr; +} +#endif + // Initialize state from pt_regs static inline ErrorCode copy_state_regs(UnwindState *state, struct pt_regs *regs, diff --git a/support/ebpf/tracer.ebpf.release.arm64 b/support/ebpf/tracer.ebpf.release.arm64 index 8b702a62..7e605731 100644 Binary files a/support/ebpf/tracer.ebpf.release.arm64 and b/support/ebpf/tracer.ebpf.release.arm64 differ