]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0009-KVM-SVM-obey-guest-PAT.patch
rebase patches on top of Ubuntu-4.13.0-43.48
[pve-kernel.git] / patches / kernel / 0009-KVM-SVM-obey-guest-PAT.patch
CommitLineData
59d5af67 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
9e94988c
FG
2From: Paolo Bonzini <pbonzini@redhat.com>
3Date: Thu, 26 Oct 2017 09:13:27 +0200
59d5af67 4Subject: [PATCH] KVM: SVM: obey guest PAT
9e94988c
FG
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9For many years some users of assigned devices have reported worse
10performance on AMD processors with NPT than on AMD without NPT,
11Intel or bare metal.
12
13The reason turned out to be that SVM is discarding the guest PAT
14setting and uses the default (PA0=PA4=WB, PA1=PA5=WT, PA2=PA6=UC-,
15PA3=UC). The guest might be using a different setting, and
16especially might want write combining but isn't getting it
17(instead getting slow UC or UC- accesses).
18
19Thanks a lot to geoff@hostfission.com for noticing the relation
20to the g_pat setting. The patch has been tested also by a bunch
21of people on VFIO users forums.
22
23Fixes: 709ddebf81cb40e3c36c6109a7892e8b93a09464
24Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=196409
25Cc: stable@vger.kernel.org
26Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
27Reviewed-by: David Hildenbrand <david@redhat.com>
28Tested-by: Nick Sarnie <commendsarnex@gmail.com>
29Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
30(cherry picked from commit 15038e14724799b8c205beb5f20f9e54896013c3)
31Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
32---
33 arch/x86/kvm/svm.c | 7 +++++++
34 1 file changed, 7 insertions(+)
35
36diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
1f1e1833 37index 6b1744499a90..5c37c1a1a949 100644
9e94988c
FG
38--- a/arch/x86/kvm/svm.c
39+++ b/arch/x86/kvm/svm.c
3adc5321 40@@ -3650,6 +3650,13 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
9e94988c
FG
41 u32 ecx = msr->index;
42 u64 data = msr->data;
43 switch (ecx) {
44+ case MSR_IA32_CR_PAT:
45+ if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data))
46+ return 1;
47+ vcpu->arch.pat = data;
48+ svm->vmcb->save.g_pat = data;
49+ mark_dirty(svm->vmcb, VMCB_NPT);
50+ break;
51 case MSR_IA32_TSC:
52 kvm_write_tsc(vcpu, msr);
53 break;
54--
552.14.2
56