From 88eb16786872404c9279ac6b0decbd98dac7ca8d Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Tue, 29 Jun 2021 21:16:26 +0800 Subject: [PATCH] arch/x86: Save resume vector to stack in x86_64 mode In x86_64, the first function parameter is passed in rdi register, and the 32-bit code after exiting long mode reads the resume vector in 4(%esp), so it's needed to save the resume vector from rdi to 4(%rsp). Also note that the function attribute "regparm" only works on x86-32 targets according to the GCC manual, so "asmlinkage" doesn't change the ABI of an x86_64 function. Tested on HP EliteBook 2560p. The laptop can resume from S3 in x86_64 mode after this change. Change-Id: I45f2678071b2511c0af5dce9d9b73ac70dfd7252 Signed-off-by: Iru Cai Reviewed-on: https://review.coreboot.org/c/coreboot/+/55947 Reviewed-by: Arthur Heymans Tested-by: build bot (Jenkins) --- src/arch/x86/wakeup.S | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/arch/x86/wakeup.S b/src/arch/x86/wakeup.S index dc9510bb90..7462dadbe8 100644 --- a/src/arch/x86/wakeup.S +++ b/src/arch/x86/wakeup.S @@ -15,6 +15,13 @@ .globl __wakeup __wakeup: #if ENV_X86_64 + /* When called in x86_64 mode, the resume vector is in %rdi + * instead of the stack, save it in 4(%rsp) for the 32-bit code. + * It's OK to overwrite the return address at (%rsp) because this + * function doesn't return. + */ + mov %edi, 4(%rsp) + xor %rax,%rax mov %ss, %ax push %rax