* [PATCH] x86/efi: Load fixmap GDT in efi_call_phys_epilog() before setting %cr3
@ 2018-09-11 18:18 Guenter Roeck
2018-09-12 19:57 ` [tip:x86/urgent] " tip-bot for Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2018-09-11 18:18 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Thomas Gleixner, Ingo Molnar, linux-efi, linux-kernel,
Linus Torvalds, Guenter Roeck, Andy Lutomirski, Joerg Roedel
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(), we load the gdt
with its physical address, and when we reload the %cr3 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.
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Joerg Roedel <jroedel@suse.de>
Fixes: eeb89e2bb1ac ("x86/efi: Load fixmap GDT in efi_call_phys_epilog()")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
arch/x86/platform/efi/efi_32.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
index 05ca14222463..9959657127f4 100644
--- a/arch/x86/platform/efi/efi_32.c
+++ b/arch/x86/platform/efi/efi_32.c
@@ -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)
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip:x86/urgent] x86/efi: Load fixmap GDT in efi_call_phys_epilog() before setting %cr3
2018-09-11 18:18 [PATCH] x86/efi: Load fixmap GDT in efi_call_phys_epilog() before setting %cr3 Guenter Roeck
@ 2018-09-12 19:57 ` tip-bot for Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Guenter Roeck @ 2018-09-12 19:57 UTC (permalink / raw)
To: linux-tip-commits
Cc: jroedel, linux-kernel, tglx, linux, ard.biesheuvel, hpa,
torvalds, mingo, luto
Commit-ID: cf40361ede6cf9dc09349e4c049dc0d166ca2d8b
Gitweb: https://git.kernel.org/tip/cf40361ede6cf9dc09349e4c049dc0d166ca2d8b
Author: Guenter Roeck <linux@roeck-us.net>
AuthorDate: Tue, 11 Sep 2018 11:18:12 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 12 Sep 2018 21:53:34 +0200
x86/efi: Load fixmap GDT in efi_call_phys_epilog() before setting %cr3
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 <linux@roeck-us.net>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: linux-efi@vger.kernel.org
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Joerg Roedel <jroedel@suse.de>
Link: https://lkml.kernel.org/r/1536689892-21538-1-git-send-email-linux@roeck-us.net
---
arch/x86/platform/efi/efi_32.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
index 05ca14222463..9959657127f4 100644
--- a/arch/x86/platform/efi/efi_32.c
+++ b/arch/x86/platform/efi/efi_32.c
@@ -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)
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-12 19:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11 18:18 [PATCH] x86/efi: Load fixmap GDT in efi_call_phys_epilog() before setting %cr3 Guenter Roeck
2018-09-12 19:57 ` [tip:x86/urgent] " tip-bot for Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).