From: Ian Campbell Subject: Re: [PATCH v4 3/5] xen/arm: clean and invalidate all guest caches by VMID after domain build. Date: Fri, 7 Feb 2014 15:01:18 +0000 Message-ID: <1391785278.2162.108.camel@kazak.uk.xensource.com> References: <1391775139.2162.88.camel@kazak.uk.xensource.com> <1391775176-30313-3-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: keir@xen.org, ian.jackson@eu.citrix.com, julien.grall@linaro.org, tim@xen.org, xen-devel@lists.xen.org, jbeulich@suse.com List-Id: xen-devel@lists.xenproject.org On Fri, 2014-02-07 at 14:49 +0000, Stefano Stabellini wrote: > > diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c > > index 77a4e64..b9d1015 100644 > > --- a/tools/libxc/xc_dom_core.c > > +++ b/tools/libxc/xc_dom_core.c > > @@ -603,6 +603,8 @@ void xc_dom_unmap_one(struct xc_dom_image *dom, xen_pfn_t pfn) > > prev->next = phys->next; > > else > > dom->phys_pages = phys->next; > > + > > + xc_domain_cacheflush(dom->xch, dom->guest_domid, phys->first, phys->count); > > I am not sure I understand the semantic of xc_dom_unmap_one: from the > name of the function and the parameters I would think that it is > supposed to unmap just one page. In that case we should flush just one > page. However the implementation calls > > munmap(phys->ptr, phys->count << page_shift) > > so it actually can unmap more than a single page, so I think that you > did the right thing by calling xc_domain_cacheflush with phys->first and > phys->count. "one" in the name means "one struct xc_dom_phys", which is a range starting at the given pfn, which is why using phys->{first,count} is correct. > > +void sync_page_to_ram(unsigned long mfn) > > +{ > > + void *p, *v = map_domain_page(mfn); > > + > > + dsb(); /* So the CPU issues all writes to the range */ > > + for ( p = v; p < v + PAGE_SIZE ; p += cacheline_bytes ) > > What about the last few bytes on a page? > Can we assume that PAGE_SIZE is a multiple of cacheline_bytes? I sure hope so! A non power of two cache line size would be pretty crazy! The cacheline is always a 2^N (the register contains log2(cacheline size)) and so is PAGE_SIZE. Ian.