summaryrefslogtreecommitdiff
path: root/Kernel/Arch
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2023-04-17 15:13:39 +0200
committerAndreas Kling <kling@serenityos.org>2023-04-17 20:30:17 +0200
commitaefd6e9ee176a7741bee1d72189dd32c10109af2 (patch)
tree6ca23642c30f3362405938ce7f05e6815072865c /Kernel/Arch
parent0ee476948bd1a2f2cb6e0ef65636d1c57514b3e9 (diff)
downloadserenity-aefd6e9ee176a7741bee1d72189dd32c10109af2.zip
Kernel: Don't get rbp from internal context switch structures
This has been broken on x86_64 since its introduction, as it features more registers to be saved, and we never held up the "rbp has to be the last pushed register" there. Instead, just copy rbp from the thread structure, which is now properly updated since the last commit.
Diffstat (limited to 'Kernel/Arch')
-rw-r--r--Kernel/Arch/x86_64/Processor.cpp14
1 files changed, 1 insertions, 13 deletions
diff --git a/Kernel/Arch/x86_64/Processor.cpp b/Kernel/Arch/x86_64/Processor.cpp
index 4bb7c09963..67c73eac9c 100644
--- a/Kernel/Arch/x86_64/Processor.cpp
+++ b/Kernel/Arch/x86_64/Processor.cpp
@@ -863,23 +863,11 @@ ErrorOr<Vector<FlatPtr, 32>> Processor::capture_stack_trace(Thread& thread, size
case Thread::State::Blocked:
case Thread::State::Dying:
case Thread::State::Dead: {
- // We need to retrieve ebp from what was last pushed to the kernel
- // stack. Before switching out of that thread, it switch_context
- // pushed the callee-saved registers, and the last of them happens
- // to be ebp.
ScopedAddressSpaceSwitcher switcher(thread.process());
auto& regs = thread.regs();
- auto* stack_top = reinterpret_cast<FlatPtr*>(regs.sp());
- if (Memory::is_user_range(VirtualAddress(stack_top), sizeof(FlatPtr))) {
- if (copy_from_user(&frame_ptr, &((FlatPtr*)stack_top)[0]).is_error())
- frame_ptr = 0;
- } else {
- void* fault_at;
- if (!safe_memcpy(&frame_ptr, &((FlatPtr*)stack_top)[0], sizeof(FlatPtr), fault_at))
- frame_ptr = 0;
- }
ip = regs.ip();
+ frame_ptr = regs.rbp;
// TODO: We need to leave the scheduler lock here, but we also
// need to prevent the target thread from being run while