Skip to content

Commit

Permalink
x86/head/64: Load GDT after switch to virtual addresses
Browse files Browse the repository at this point in the history
Load the GDT right after switching to virtual addresses to make sure
there is a defined GDT for exception handling.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lkml.kernel.org/r/20200907131613.12703-31-joro@8bytes.org
  • Loading branch information
Joerg Roedel authored and Borislav Petkov committed Sep 7, 2020
1 parent 866b556 commit e04b883
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions arch/x86/kernel/head_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ SYM_CODE_START(secondary_startup_64)
1:
UNWIND_HINT_EMPTY

/*
* We must switch to a new descriptor in kernel space for the GDT
* because soon the kernel won't have access anymore to the userspace
* addresses where we're currently running on. We have to do that here
* because in 32bit we couldn't load a 64bit linear address.
*/
lgdt early_gdt_descr(%rip)

/* Check if nx is implemented */
movl $0x80000001, %eax
cpuid
Expand Down Expand Up @@ -185,14 +193,6 @@ SYM_CODE_START(secondary_startup_64)
pushq $0
popfq

/*
* We must switch to a new descriptor in kernel space for the GDT
* because soon the kernel won't have access anymore to the userspace
* addresses where we're currently running on. We have to do that here
* because in 32bit we couldn't load a 64bit linear address.
*/
lgdt early_gdt_descr(%rip)

/* set up data segments */
xorl %eax,%eax
movl %eax,%ds
Expand Down

0 comments on commit e04b883

Please sign in to comment.