From aeaf103166e0611eb01e7f0cbf2d83bcec065ccc Mon Sep 17 00:00:00 2001 From: Zejun Zhao Date: Thu, 28 Aug 2025 12:18:32 +0800 Subject: [PATCH] Add an explicit end of call stack for x86_64 --- ostd/src/arch/x86/task/switch.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ostd/src/arch/x86/task/switch.S b/ostd/src/arch/x86/task/switch.S index 9c365a49a..f0c14d447 100644 --- a/ostd/src/arch/x86/task/switch.S +++ b/ostd/src/arch/x86/task/switch.S @@ -31,6 +31,8 @@ first_context_switch: # (nxt: *const TaskContext) mov r13, [rdi + 32] mov r14, [rdi + 40] mov r15, [rdi + 48] - mov rax, [rdi + 56] # restore return address - mov [rsp], rax # for stack balance, must use mov instead of push + mov rax, [rdi + 56] + # for stack balance, we have to use mov instead of push here + mov qword ptr [rsp + 8], 0 # kernel_task_entry's return address + mov [rsp], rax # first_context_switch's return address ret