[tip:x86/urgent] x86/boot/compressed/64: Do not corrupt EDX on EFER.LME=1 setting

From: tip-bot for Kirill A. Shutemov
Date: Wed Feb 06 2019 - 13:05:29 EST

Commit-ID: 45b13b424faafb81c8c44541f093a682fdabdefc
Gitweb: https://git.kernel.org/tip/45b13b424faafb81c8c44541f093a682fdabdefc
Author: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
AuthorDate: Wed, 6 Feb 2019 14:52:53 +0300
Committer: Borislav Petkov <bp@xxxxxxx>
CommitDate: Wed, 6 Feb 2019 18:56:18 +0100

x86/boot/compressed/64: Do not corrupt EDX on EFER.LME=1 setting

RDMSR in the trampoline code overwrites EDX but that register is used
to indicate whether 5-level paging has to be enabled and if clobbered,
leads to failure to boot on a 5-level paging machine.

Preserve EDX on the stack while we are dealing with EFER.

Fixes: b677dfae5aa1 ("x86/boot/compressed/64: Set EFER.LME=1 in 32-bit trampoline before returning to long mode")
Reported-by: Kyle D Pelton <kyle.d.pelton@xxxxxxxxx>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
Signed-off-by: Borislav Petkov <bp@xxxxxxx>
Cc: dave.hansen@xxxxxxxxxxxxxxx
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Wei Huang <wei@xxxxxxxxxx>
Cc: x86-ml <x86@xxxxxxxxxx>
Link: https://lkml.kernel.org/r/20190206115253.1907-1-kirill.shutemov@xxxxxxxxxxxxxxx
arch/x86/boot/compressed/head_64.S | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index f105ae8651c9..f62e347862cc 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -602,10 +602,12 @@ ENTRY(trampoline_32bit_src)
/* Set EFER.LME=1 as a precaution in case hypervsior pulls the rug */
pushl %ecx
+ pushl %edx
movl $MSR_EFER, %ecx
btsl $_EFER_LME, %eax
+ popl %edx
popl %ecx

/* Enable PAE and LA57 (if required) paging modes */