Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753344AbbGIPSl (ORCPT ); Thu, 9 Jul 2015 11:18:41 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:33242 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751547AbbGIPS3 (ORCPT ); Thu, 9 Jul 2015 11:18:29 -0400 Subject: Re: [PATCH 2/4] KVM: SVM: use NPT page attributes To: Xiao Guangrong , linux-kernel@vger.kernel.org, kvm@vger.kernel.org References: <1436276739-50326-1-git-send-email-pbonzini@redhat.com> <1436276739-50326-3-git-send-email-pbonzini@redhat.com> <559CBC4E.2090004@linux.intel.com> <559D0754.6030009@redhat.com> <559DDCD0.2090502@linux.intel.com> Cc: jroedel@suse.de, alex.williamson@redhat.com, ogerlitz@mellanox.com, amirv@mellanox.com From: Paolo Bonzini X-Enigmail-Draft-Status: N1110 Message-ID: <559E90C1.6000605@redhat.com> Date: Thu, 9 Jul 2015 17:18:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <559DDCD0.2090502@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2052 Lines: 65 On 09/07/2015 04:30, Xiao Guangrong wrote: >>>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c >>>> index 602b974a60a6..0f125c1860ec 100644 >>>> --- a/arch/x86/kvm/svm.c >>>> +++ b/arch/x86/kvm/svm.c >>>> @@ -1085,6 +1085,47 @@ static u64 svm_compute_tsc_offset(struct >>>> kvm_vcpu *vcpu, u64 target_tsc) >>>> return target_tsc - tsc; >>>> } >>>> >>>> +static void svm_set_guest_pat(struct vcpu_svm *svm, u64 *g_pat) >>>> +{ >>>> + struct kvm_vcpu *vcpu = &svm->vcpu; >>>> + >>>> + /* Unlike Intel, AMD takes the guest's CR0.CD into account. >>> >>> I noticed this code in svm_set_cr0(): >>> >>> if (!(vcpu->kvm->arch.disabled_quirks & KVM_QUIRK_CD_NW_CLEARED)) >>> cr0 &= ~(X86_CR0_CD | X86_CR0_NW); >>> >>> gCR0.CD is hidden to CPU if KVM_QUIRK_CD_NW_CLEARED is not set and looks >>> like it is the normal case after grepping Qemu code. Hi Xiao, yes, this is correct. QEMU still does not have support for disabling "quirks", so gCR0.CD is currently hidden on SVM. I would like to include this series in 4.2, while for 4.3 I will disable the quirk above altogether (it is superseded by the way PAT is forced to all-WB). In any case, this is just a KVM limitation. gCR0.CD is taken into account by the processor when computing the effective memory type. It uses all of these: - the guest page tables PAT/PCD/PWT - the guest page tables CR3.PCD/CR3.PWD - the nested page tables PAT/PCD/PWT - the guest page tables CR3.PCD/CR3.PWD - the host MTRRs - gCR0.CD - hCR0.CD Paolo > How about this one? I still do not know how SVM properly emulates > CR0.CD? :( > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/