Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752039AbbFAJg4 (ORCPT ); Mon, 1 Jun 2015 05:36:56 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:34608 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751380AbbFAJgp (ORCPT ); Mon, 1 Jun 2015 05:36:45 -0400 Message-ID: <556C27A5.1040908@redhat.com> Date: Mon, 01 Jun 2015 11:36:37 +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> In-Reply-To: <1432983566-15773-15-git-send-email-guangrong.xiao@linux.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1552 Lines: 46 On 30/05/2015 12:59, Xiao Guangrong wrote: > Currently guest MTRR is completely prohibited if cache snoop is supported on > IOMMU (!noncoherent_dma) and host does the emulation based on the knowledge > from host side, however, host side is not the good point to know > what the purpose of guest is. A good example is that pass-throughed VGA > frame buffer is not always UC as host expected Can you explain how? The original idea was that such a framebuffer would be kvm_is_reserved_pfn and thus be unconditionally UC. > +bool kvm_mtrr_check_gfn_range_consistency(struct kvm_vcpu *vcpu, gfn_t gfn, > + int page_num) > +{ > + struct mtrr_looker looker; > + struct kvm_mtrr *mtrr_state = &vcpu->arch.mtrr_state; > + u64 start = gfn_to_gpa(gfn), end = gfn_to_gpa(gfn + page_num); > + int type = -1; > + > + mtrr_for_each_mem_type(&looker, mtrr_state, start, end) { > + if (type == -1) { > + type = looker.mem_type; > + continue; > + } > + > + if (type != looker.mem_type) > + return false; > + } > + > + if ((type != -1) && looker.partial_map && > + (mtrr_state->def_type != type)) > + return false; > + No Pascal-like parentheses. Does this have a performance impact on shadow? Perhaps we could cache in struct kvm_arch_memory_slot whether the memslot is covered by MTRRs? 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/