From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [RFC][PATCH] KVM: SVM: Sync g_pat with guest-written PAT value Date: Mon, 13 Apr 2015 08:58:43 +0200 Message-ID: <552B6923.3020602@siemens.com> References: <552B5128.4010909@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Cc: Joel Schopp To: kvm Return-path: Received: from thoth.sbs.de ([192.35.17.2]:42693 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752086AbbDMG6s (ORCPT ); Mon, 13 Apr 2015 02:58:48 -0400 In-Reply-To: <552B5128.4010909@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: When hardware supports the g_pat VMCB field, we can use it for emulating the PAT configuration that the guest configures by writing to the corresponding MSR. Signed-off-by: Jan Kiszka --- RFC because it is only compile-tested. arch/x86/kvm/svm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index ce741b8..9439c6c 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -3245,6 +3245,15 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr) case MSR_VM_IGNNE: vcpu_unimpl(vcpu, "unimplemented wrmsr: 0x%x data 0x%llx\n", ecx, data); break; + case MSR_IA32_CR_PAT: + if (npt_enabled) { + if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data)) + return 1; + svm->vmcb->save.g_pat = data; + vcpu->arch.pat = data; + break; + } + /* fall through */ default: return kvm_set_msr_common(vcpu, msr); } -- 2.1.4