cpu/x86/64bit: Back up/restore CR3 on mode switch
Store CR3 on stack and restore it when returning from protected mode call, since the stage might have set up different page tables than the default ones linked into all stages. Tested: intel/archercity still boots to payload in x86_64. Change-Id: If94a24925994ac9599be24f6454ea28d02ff0c67 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/82164 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
This commit is contained in:
parent
de8e4d930d
commit
a1f82532f2
1 changed files with 10 additions and 3 deletions
|
|
@ -26,6 +26,10 @@ protected_mode_call_wrapper:
|
|||
/* Store stack pointer */
|
||||
mov %rsp, %rbp
|
||||
|
||||
/* Backup cr3 to stack */
|
||||
mov %cr3, %rax
|
||||
push %rax
|
||||
|
||||
/* New IDT to stack */
|
||||
pushq $0
|
||||
pushq $0
|
||||
|
|
@ -47,7 +51,7 @@ protected_mode_call_wrapper:
|
|||
#include <cpu/x86/64bit/exit32.inc>
|
||||
|
||||
/* Load zero IDT. x86_32 FSP doesn't like to find a x86_64 IDT */
|
||||
lidt -16(%ebp)
|
||||
lidt -24(%ebp)
|
||||
|
||||
/* Fetch function to call */
|
||||
movl 12(%esp), %ebx
|
||||
|
|
@ -56,8 +60,11 @@ protected_mode_call_wrapper:
|
|||
call *%ebx
|
||||
movl %eax, %ebx
|
||||
|
||||
/* Preserves ebx */
|
||||
setup_longmode $PM4LE
|
||||
/*
|
||||
* Back to long mode by using cr3 previously stored on stack.
|
||||
* Preserves ebx.
|
||||
*/
|
||||
setup_longmode -8(%ebp)
|
||||
|
||||
/* Place return value in rax */
|
||||
movl %ebx, %eax
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue