x86/efi: Load fixmap GDT in efi_call_phys_epilog() before setting %cr3
authorGuenter Roeck <[email protected]>
Tue, 11 Sep 2018 18:18:12 +0000 (11:18 -0700)
committerThomas Gleixner <[email protected]>
Wed, 12 Sep 2018 19:53:34 +0000 (21:53 +0200)
Commit eeb89e2bb1ac ("x86/efi: Load fixmap GDT in efi_call_phys_epilog()")
moved loading the fixmap in efi_call_phys_epilog() after load_cr3() since
it was assumed to be more logical.

Turns out this is incorrect: In efi_call_phys_prolog(), the gdt with its
physical address is loaded first, and when the %cr3 is reloaded in _epilog
from initial_page_table to swapper_pg_dir again the gdt is no longer
mapped.  This results in a triple fault if an interrupt occurs after
load_cr3() and before load_fixmap_gdt(0). Calling load_fixmap_gdt(0) first
restores the execution order prior to commit eeb89e2bb1ac and fixes the
problem.

Fixes: eeb89e2bb1ac ("x86/efi: Load fixmap GDT in efi_call_phys_epilog()")
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: Linus Torvalds <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: [email protected]
Cc: Andy Lutomirski <[email protected]>
Cc: Joerg Roedel <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
arch/x86/platform/efi/efi_32.c

index 05ca1422246336c6d3c923c22f06ad87113ac1d3..9959657127f476ae3018894ffc31909ee2c6d79e 100644 (file)
@@ -85,10 +85,9 @@ pgd_t * __init efi_call_phys_prolog(void)
 
 void __init efi_call_phys_epilog(pgd_t *save_pgd)
 {
+       load_fixmap_gdt(0);
        load_cr3(save_pgd);
        __flush_tlb_all();
-
-       load_fixmap_gdt(0);
 }
 
 void __init efi_runtime_update_mappings(void)