From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932330AbdJZIR3 (ORCPT ); Thu, 26 Oct 2017 04:17:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52692 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932237AbdJZIR1 (ORCPT ); Thu, 26 Oct 2017 04:17:27 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EDE23C058EA3 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com Subject: Re: [PATCH] KVM: SVM: obey guest PAT To: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: stable@vger.kernel.org References: <20171026071327.15427-1-pbonzini@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <72749501-974d-e11c-1fa4-fda00e594264@redhat.com> Date: Thu, 26 Oct 2017 10:17:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171026071327.15427-1-pbonzini@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 26 Oct 2017 08:17:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26.10.2017 09:13, Paolo Bonzini wrote: > 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 > --- > arch/x86/kvm/svm.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index af256b786a70..af09baa3d736 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -3626,6 +3626,13 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr) > u32 ecx = msr->index; > u64 data = msr->data; > switch (ecx) { > + case MSR_IA32_CR_PAT: > + if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data)) > + return 1; > + vcpu->arch.pat = data; > + svm->vmcb->save.g_pat = data; > + mark_dirty(svm->vmcb, VMCB_NPT); > + break; > case MSR_IA32_TSC: > kvm_write_tsc(vcpu, msr); > break; > Although no SVM expert, looking at the way it is handled on VMX, this looks good to me. Reviewed-by: David Hildenbrand -- Thanks, David