From: "Jan Beulich" Subject: Re: [PATCH] Avoid needless flush cache when guest change MTRR Date: Wed, 04 Feb 2015 08:50:43 +0000 Message-ID: <54D1EB73020000780005CAE0@mail.emea.novell.com> References: <1423020482-4765-1-git-send-email-liang.z.li@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1423020482-4765-1-git-send-email-liang.z.li@intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Liang Li Cc: Yang Zhang , andrew.cooper3@citrix.com, kevin.tian@intel.com, keir@xen.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 04.02.15 at 04:28, wrote: > --- a/xen/arch/x86/hvm/mtrr.c > +++ b/xen/arch/x86/hvm/mtrr.c > @@ -791,7 +791,7 @@ HVM_REGISTER_SAVE_RESTORE(MTRR, hvm_save_mtrr_msr, hvm_load_mtrr_msr, > > void memory_type_changed(struct domain *d) > { > - if ( iommu_enabled && d->vcpu && d->vcpu[0] ) > + if ( need_iommu(d) && d->vcpu && d->vcpu[0] ) > { > p2m_memory_type_changed(d); > flush_all(FLUSH_CACHE); This doesn't do what title and description say: You not only suppress the flush, but also the EPT table adjustments. Either adjust at least the description accordingly, or make the code do what the description says. > --- a/xen/drivers/passthrough/pci.c > +++ b/xen/drivers/passthrough/pci.c > @@ -1365,6 +1365,11 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) > } > } > d->need_iommu = 1; > + /* There may be dirty cache lines when a device is assigned > + * and before need_iommu(d) becoming true, this will cause > + * memory_type_changed lose effect if memory type changes. > + * Call memory_type_changed here to amend this. */ > + memory_type_changed(d); The comment formatting does not adhere to ./CODING_STYLE. Jan