]> git.proxmox.com Git - pve-kernel-jessie.git/blame - kvm-x86-obey-KVM_X86_QUIRK_CD_NW_CLEARED-in-kvm_set_cr0.patch
fix CVE-2015-8104
[pve-kernel-jessie.git] / kvm-x86-obey-KVM_X86_QUIRK_CD_NW_CLEARED-in-kvm_set_cr0.patch
CommitLineData
f74f8873
DM
1From 879ae1880449c88db11c1ebdaedc2da79b2fe73f Mon Sep 17 00:00:00 2001
2From: Laszlo Ersek <lersek@redhat.com>
3Date: Wed, 4 Nov 2015 12:54:41 +0100
4Subject: KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0()
5
6Commit b18d5431acc7 ("KVM: x86: fix CR0.CD virtualization") was
7technically correct, but it broke OVMF guests by slowing down various
8parts of the firmware.
9
10Commit fb279950ba02 ("KVM: vmx: obey KVM_QUIRK_CD_NW_CLEARED") quirked the
11first function modified by b18d5431acc7, vmx_get_mt_mask(), for OVMF's
12sake. This restored the speed of the OVMF code that runs before
13PlatformPei (including the memory intensive LZMA decompression in SEC).
14
15This patch extends the quirk to the second function modified by
16b18d5431acc7, kvm_set_cr0(). It eliminates the intrusive slowdown that
17hits the EFI_MP_SERVICES_PROTOCOL implementation of edk2's
18UefiCpuPkg/CpuDxe -- which is built into OVMF --, when CpuDxe starts up
19all APs at once for initialization, in order to count them.
20
21We also carry over the kvm_arch_has_noncoherent_dma() sub-condition from
22the other half of the original commit b18d5431acc7.
23
24Fixes: b18d5431acc7a2fd22767925f3a6f597aa4bd29e
25Cc: stable@vger.kernel.org
26Cc: Jordan Justen <jordan.l.justen@intel.com>
27Cc: Alex Williamson <alex.williamson@redhat.com>
28Reviewed-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
29Tested-by: Janusz Mocek <januszmk6@gmail.com>
30Signed-off-by: Laszlo Ersek <lersek@redhat.com>#
31Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
32---
33 arch/x86/kvm/x86.c | 4 +++-
34 1 file changed, 3 insertions(+), 1 deletion(-)
35
36diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
37index a24bae0..30723a4 100644
38--- a/arch/x86/kvm/x86.c
39+++ b/arch/x86/kvm/x86.c
40@@ -625,7 +625,9 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
41 if ((cr0 ^ old_cr0) & update_bits)
42 kvm_mmu_reset_context(vcpu);
43
44- if ((cr0 ^ old_cr0) & X86_CR0_CD)
45+ if (((cr0 ^ old_cr0) & X86_CR0_CD) &&
46+ kvm_arch_has_noncoherent_dma(vcpu->kvm) &&
47+ !kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_CD_NW_CLEARED))
48 kvm_zap_gfn_range(vcpu->kvm, 0, ~0ULL);
49
50 return 0;
51--
52cgit v0.11.2
53