Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752441AbbFDIg6 (ORCPT ); Thu, 4 Jun 2015 04:36:58 -0400 Received: from mail-wg0-f52.google.com ([74.125.82.52]:33092 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751340AbbFDIgv (ORCPT ); Thu, 4 Jun 2015 04:36:51 -0400 Message-ID: <55700E1F.9090803@redhat.com> Date: Thu, 04 Jun 2015 10:36:47 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Xiao Guangrong CC: gleb@kernel.org, mtosatti@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 14/15] KVM: MTRR: do not map huage page for non-consistent range References: <1432983566-15773-1-git-send-email-guangrong.xiao@linux.intel.com> <1432983566-15773-15-git-send-email-guangrong.xiao@linux.intel.com> <556C27A5.1040908@redhat.com> <556E6CF8.9070602@linux.intel.com> <556EB30F.8030100@redhat.com> <55700B0D.8080808@linux.intel.com> In-Reply-To: <55700B0D.8080808@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1490 Lines: 38 On 04/06/2015 10:23, Xiao Guangrong wrote: >> >> So, why do you need to always use IPAT=0? Can patch 15 keep the current >> logic for RAM, like this: >> >> if (is_mmio || kvm_arch_has_noncoherent_dma(vcpu->kvm)) >> ret = kvm_mtrr_get_guest_memory_type(vcpu, gfn) << >> VMX_EPT_MT_EPTE_SHIFT; >> else >> ret = (MTRR_TYPE_WRBACK << VMX_EPT_MT_EPTE_SHIFT) >> | VMX_EPT_IPAT_BIT; > > Yeah, it's okay, actually we considered this way, however > - it's light enough, it did not hurt guest performance based on our > benchmark. > - the logic has always used for noncherent_dma case, extend it to > normal case should have low risk and also help us to check the logic. But noncoherent_dma is not the common case, so it's not necessarily true that the risk is low. > - completely follow MTRRS spec would be better than host hides it. We are a virtualization platform, we know well when MTRRs are necessary. Tis a risk from blindly obeying the guest MTRRs: userspace can see stale data if the guest's accesses bypass the cache. AMD bypasses this by enabling snooping even in cases that ordinarily wouldn't snoop; for Intel the solution is that RAM-backed areas should always use IPAT. Paolo -- 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/