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