]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0095-xen-x86-entry-64-Add-xen-NMI-trap-entry.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0095-xen-x86-entry-64-Add-xen-NMI-trap-entry.patch
CommitLineData
321d628a
FG
1From 47b64e9de8bba4e6ccd0976bce6cf99446daf82e Mon Sep 17 00:00:00 2001
2From: Juergen Gross <jgross@suse.com>
3Date: Thu, 2 Nov 2017 00:59:07 -0700
e4cdf2a5 4Subject: [PATCH 095/241] xen, x86/entry/64: Add xen NMI trap entry
321d628a
FG
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9CVE-2017-5754
10
11Instead of trying to execute any NMI via the bare metal's NMI trap
12handler use a Xen specific one for PV domains, like we do for e.g.
13debug traps. As in a PV domain the NMI is handled via the normal
14kernel stack this is the correct thing to do.
15
16This will enable us to get rid of the very fragile and questionable
17dependencies between the bare metal NMI handler and Xen assumptions
18believed to be broken anyway.
19
20Signed-off-by: Juergen Gross <jgross@suse.com>
21Signed-off-by: Andy Lutomirski <luto@kernel.org>
22Cc: Borislav Petkov <bpetkov@suse.de>
23Cc: Brian Gerst <brgerst@gmail.com>
24Cc: Dave Hansen <dave.hansen@intel.com>
25Cc: Linus Torvalds <torvalds@linux-foundation.org>
26Cc: Peter Zijlstra <peterz@infradead.org>
27Cc: Thomas Gleixner <tglx@linutronix.de>
28Link: http://lkml.kernel.org/r/5baf5c0528d58402441550c5770b98e7961e7680.1509609304.git.luto@kernel.org
29Signed-off-by: Ingo Molnar <mingo@kernel.org>
30(cherry picked from commit 43e4111086a70c78bedb6ad990bee97f17b27a6e)
31Signed-off-by: Andy Whitcroft <apw@canonical.com>
32Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
33(cherry picked from commit 20c970e03b42141abf6c45938ce6d4fdc3555921)
34Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
35---
36 arch/x86/include/asm/traps.h | 2 +-
37 arch/x86/xen/enlighten_pv.c | 2 +-
38 arch/x86/entry/entry_64.S | 2 +-
39 arch/x86/xen/xen-asm_64.S | 2 +-
40 4 files changed, 4 insertions(+), 4 deletions(-)
41
42diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h
43index 8e5bf86f87e5..b052a7621ca1 100644
44--- a/arch/x86/include/asm/traps.h
45+++ b/arch/x86/include/asm/traps.h
46@@ -55,9 +55,9 @@ asmlinkage void simd_coprocessor_error(void);
47
48 #if defined(CONFIG_X86_64) && defined(CONFIG_XEN_PV)
49 asmlinkage void xen_divide_error(void);
50+asmlinkage void xen_xennmi(void);
51 asmlinkage void xen_xendebug(void);
52 asmlinkage void xen_xenint3(void);
53-asmlinkage void xen_nmi(void);
54 asmlinkage void xen_overflow(void);
55 asmlinkage void xen_bounds(void);
56 asmlinkage void xen_invalid_op(void);
57diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
58index 69b9deff7e5c..8da4eff19c2a 100644
59--- a/arch/x86/xen/enlighten_pv.c
60+++ b/arch/x86/xen/enlighten_pv.c
61@@ -600,7 +600,7 @@ static struct trap_array_entry trap_array[] = {
62 #ifdef CONFIG_X86_MCE
63 { machine_check, xen_machine_check, true },
64 #endif
65- { nmi, xen_nmi, true },
66+ { nmi, xen_xennmi, true },
67 { overflow, xen_overflow, false },
68 #ifdef CONFIG_IA32_EMULATION
69 { entry_INT80_compat, xen_entry_INT80_compat, false },
70diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
71index 4eff3aca54ed..5a6aba7cf3bd 100644
72--- a/arch/x86/entry/entry_64.S
73+++ b/arch/x86/entry/entry_64.S
74@@ -1091,6 +1091,7 @@ idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
75 idtentry stack_segment do_stack_segment has_error_code=1
76
77 #ifdef CONFIG_XEN
78+idtentry xennmi do_nmi has_error_code=0
79 idtentry xendebug do_debug has_error_code=0
80 idtentry xenint3 do_int3 has_error_code=0
81 #endif
82@@ -1253,7 +1254,6 @@ ENTRY(error_exit)
83 END(error_exit)
84
85 /* Runs on exception stack */
86-/* XXX: broken on Xen PV */
87 ENTRY(nmi)
88 UNWIND_HINT_IRET_REGS
89 /*
90diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
91index dae2cc33afb5..286ecc198562 100644
92--- a/arch/x86/xen/xen-asm_64.S
93+++ b/arch/x86/xen/xen-asm_64.S
94@@ -29,7 +29,7 @@ xen_pv_trap debug
95 xen_pv_trap xendebug
96 xen_pv_trap int3
97 xen_pv_trap xenint3
98-xen_pv_trap nmi
99+xen_pv_trap xennmi
100 xen_pv_trap overflow
101 xen_pv_trap bounds
102 xen_pv_trap invalid_op
103--
1042.14.2
105