From 5c344f4aeed218ef1b235b000a23e50770369181 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 18 Dec 2021 11:13:55 +0100 Subject: [PATCH] Kernel: Start perf event stack capture at RBP, not EBP on x86_64 --- Kernel/PerformanceEventBuffer.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp index c6561d9ad4..14ec6498cc 100644 --- a/Kernel/PerformanceEventBuffer.cpp +++ b/Kernel/PerformanceEventBuffer.cpp @@ -23,10 +23,15 @@ PerformanceEventBuffer::PerformanceEventBuffer(NonnullOwnPtr buffer) NEVER_INLINE ErrorOr PerformanceEventBuffer::append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread) { - FlatPtr ebp; + FlatPtr base_pointer; +#if ARCH(I386) asm volatile("movl %%ebp, %%eax" - : "=a"(ebp)); - return append_with_ip_and_bp(current_thread->pid(), current_thread->tid(), 0, ebp, type, 0, arg1, arg2, arg3); + : "=a"(base_pointer)); +#else + asm volatile("movq %%rbp, %%rax" + : "=a"(base_pointer)); +#endif + return append_with_ip_and_bp(current_thread->pid(), current_thread->tid(), 0, base_pointer, type, 0, arg1, arg2, arg3); } static Vector raw_backtrace(FlatPtr bp, FlatPtr ip)