aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-10-26 03:13:27 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2017-11-17 07:20:06 -0500
commit15038e14724799b8c205beb5f20f9e54896013c3 (patch)
tree906c5f721ef96e093d52884af1d6a857d8811179
parentfc3790fa0768a789d9163608b4414e2d595be5fe (diff)
KVM: SVM: obey guest PAT
For many years some users of assigned devices have reported worse performance on AMD processors with NPT than on AMD without NPT, Intel or bare metal. The reason turned out to be that SVM is discarding the guest PAT setting and uses the default (PA0=PA4=WB, PA1=PA5=WT, PA2=PA6=UC-, PA3=UC). The guest might be using a different setting, and especially might want write combining but isn't getting it (instead getting slow UC or UC- accesses). Thanks a lot to geoff@hostfission.com for noticing the relation to the g_pat setting. The patch has been tested also by a bunch of people on VFIO users forums. Fixes: 709ddebf81cb40e3c36c6109a7892e8b93a09464 Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=196409 Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Tested-by: Nick Sarnie <commendsarnex@gmail.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
-rw-r--r--arch/x86/kvm/svm.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index b71daed3cca2..59e13a79c2e3 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3671,6 +3671,13 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
3671 u32 ecx = msr->index; 3671 u32 ecx = msr->index;
3672 u64 data = msr->data; 3672 u64 data = msr->data;
3673 switch (ecx) { 3673 switch (ecx) {
3674 case MSR_IA32_CR_PAT:
3675 if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data))
3676 return 1;
3677 vcpu->arch.pat = data;
3678 svm->vmcb->save.g_pat = data;
3679 mark_dirty(svm->vmcb, VMCB_NPT);
3680 break;
3674 case MSR_IA32_TSC: 3681 case MSR_IA32_TSC:
3675 kvm_write_tsc(vcpu, msr); 3682 kvm_write_tsc(vcpu, msr);
3676 break; 3683 break;