@@ -83,6 +83,10 @@ SYM_FUNC_START(__efi64_thunk)
movq 0x38(%rsp), %rbx
movq 0x40(%rsp), %rax
+ /* Switch to the firmware's stack */
+ movq %rsp, %r11
+ movl efi32_boot_sp(%rip), %esp
+
/*
* Convert x86-64 ABI params to i386 ABI
*/
@@ -120,7 +124,7 @@ SYM_FUNC_START(__efi64_thunk)
pushq %rax
lretq
-1: addq $64, %rsp
+1: movq %r11, %rsp
movq %rdi, %rax
pop %rbx
@@ -254,6 +258,9 @@ SYM_FUNC_START_LOCAL(efi32_entry)
/* Store firmware IDT descriptor */
sidtl (efi32_boot_idt - 1b)(%ebx)
+ /* Store firmware stack pointer */
+ movl %esp, (efi32_boot_sp - 1b)(%ebx)
+
/* Store boot arguments */
leal (efi32_boot_args - 1b)(%ebx), %ebx
movl %ecx, 0(%ebx)
@@ -318,5 +325,6 @@ SYM_DATA_END(efi32_boot_idt)
SYM_DATA_LOCAL(efi32_boot_cs, .word 0)
SYM_DATA_LOCAL(efi32_boot_ds, .word 0)
+SYM_DATA_LOCAL(efi32_boot_sp, .long 0)
SYM_DATA_LOCAL(efi32_boot_args, .long 0, 0, 0)
SYM_DATA(efi_is64, .byte 1)