diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2015-07-10 07:32:13 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-07-23 02:30:27 -0400 |
commit | 5492830370171b6a4ede8a3bfba687a8d0f25fa5 (patch) | |
tree | 44d7c401f31b3256be49f7f8db277b18506ce2d5 | |
parent | 5f3d45e7f2827f48e60eb821efd909713b43ac63 (diff) |
KVM: svm: handle KVM_X86_QUIRK_CD_NW_CLEARED in svm_get_mt_mask
We can disable CD unconditionally when there is no assigned device.
KVM now forces guest PAT to all-writeback in that case, so it makes
sense to also force CR0.CD=0.
When there are assigned devices, emulate cache-disabled operation
through the page tables. This behavior is consistent with VMX
microcode, where CD/NW are not touched by vmentry/vmexit. However,
keep this dependent on the quirk because OVMF enables the caches
too late.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/x86/kvm/svm.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 8e0c0844c6b9..d1a114d8d22b 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -1173,6 +1173,10 @@ static u64 svm_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) | |||
1173 | if (!is_mmio && !kvm_arch_has_assigned_device(vcpu->kvm)) | 1173 | if (!is_mmio && !kvm_arch_has_assigned_device(vcpu->kvm)) |
1174 | return 0; | 1174 | return 0; |
1175 | 1175 | ||
1176 | if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_CD_NW_CLEARED) && | ||
1177 | kvm_read_cr0(vcpu) & X86_CR0_CD) | ||
1178 | return _PAGE_NOCACHE; | ||
1179 | |||
1176 | mtrr = kvm_mtrr_get_guest_memory_type(vcpu, gfn); | 1180 | mtrr = kvm_mtrr_get_guest_memory_type(vcpu, gfn); |
1177 | return mtrr2protval[mtrr]; | 1181 | return mtrr2protval[mtrr]; |
1178 | } | 1182 | } |
@@ -1667,13 +1671,10 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) | |||
1667 | 1671 | ||
1668 | if (!vcpu->fpu_active) | 1672 | if (!vcpu->fpu_active) |
1669 | cr0 |= X86_CR0_TS; | 1673 | cr0 |= X86_CR0_TS; |
1670 | /* | 1674 | |
1671 | * re-enable caching here because the QEMU bios | 1675 | /* These are emulated via page tables. */ |
1672 | * does not do it - this results in some delay at | 1676 | cr0 &= ~(X86_CR0_CD | X86_CR0_NW); |
1673 | * reboot | 1677 | |
1674 | */ | ||
1675 | if (kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_CD_NW_CLEARED)) | ||
1676 | cr0 &= ~(X86_CR0_CD | X86_CR0_NW); | ||
1677 | svm->vmcb->save.cr0 = cr0; | 1678 | svm->vmcb->save.cr0 = cr0; |
1678 | mark_dirty(svm->vmcb, VMCB_CR); | 1679 | mark_dirty(svm->vmcb, VMCB_CR); |
1679 | update_cr0_intercept(svm); | 1680 | update_cr0_intercept(svm); |