]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0232-kvm-vmx-Scrub-hardware-GPRs-at-VM-exit.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0232-kvm-vmx-Scrub-hardware-GPRs-at-VM-exit.patch
1 From c59a61438e9a8f24a50171ac9d3b98e8f3719d07 Mon Sep 17 00:00:00 2001
2 From: Jim Mattson <jmattson@google.com>
3 Date: Wed, 3 Jan 2018 14:31:38 -0800
4 Subject: [PATCH 232/241] kvm: vmx: Scrub hardware GPRs at VM-exit
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Guest GPR values are live in the hardware GPRs at VM-exit. Do not
10 leave any guest values in hardware GPRs after the guest GPR values are
11 saved to the vcpu_vmx structure.
12
13 This is a partial mitigation for CVE 2017-5715 and CVE 2017-5753.
14 Specifically, it defeats the Project Zero PoC for CVE 2017-5715.
15
16 Suggested-by: Eric Northup <digitaleric@google.com>
17 Signed-off-by: Jim Mattson <jmattson@google.com>
18 Reviewed-by: Eric Northup <digitaleric@google.com>
19 Reviewed-by: Benjamin Serebrin <serebrin@google.com>
20 Reviewed-by: Andrew Honig <ahonig@google.com>
21 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
22 ---
23 arch/x86/kvm/vmx.c | 14 +++++++++++++-
24 1 file changed, 13 insertions(+), 1 deletion(-)
25
26 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
27 index d61986a36575..9b4256fd589a 100644
28 --- a/arch/x86/kvm/vmx.c
29 +++ b/arch/x86/kvm/vmx.c
30 @@ -9140,6 +9140,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
31 /* Save guest registers, load host registers, keep flags */
32 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
33 "pop %0 \n\t"
34 + "setbe %c[fail](%0)\n\t"
35 "mov %%" _ASM_AX ", %c[rax](%0) \n\t"
36 "mov %%" _ASM_BX ", %c[rbx](%0) \n\t"
37 __ASM_SIZE(pop) " %c[rcx](%0) \n\t"
38 @@ -9156,12 +9157,23 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
39 "mov %%r13, %c[r13](%0) \n\t"
40 "mov %%r14, %c[r14](%0) \n\t"
41 "mov %%r15, %c[r15](%0) \n\t"
42 + "xor %%r8d, %%r8d \n\t"
43 + "xor %%r9d, %%r9d \n\t"
44 + "xor %%r10d, %%r10d \n\t"
45 + "xor %%r11d, %%r11d \n\t"
46 + "xor %%r12d, %%r12d \n\t"
47 + "xor %%r13d, %%r13d \n\t"
48 + "xor %%r14d, %%r14d \n\t"
49 + "xor %%r15d, %%r15d \n\t"
50 #endif
51 "mov %%cr2, %%" _ASM_AX " \n\t"
52 "mov %%" _ASM_AX ", %c[cr2](%0) \n\t"
53
54 + "xor %%eax, %%eax \n\t"
55 + "xor %%ebx, %%ebx \n\t"
56 + "xor %%esi, %%esi \n\t"
57 + "xor %%edi, %%edi \n\t"
58 "pop %%" _ASM_BP "; pop %%" _ASM_DX " \n\t"
59 - "setbe %c[fail](%0) \n\t"
60 ".pushsection .rodata \n\t"
61 ".global vmx_return \n\t"
62 "vmx_return: " _ASM_PTR " 2b \n\t"
63 --
64 2.14.2
65