From: Ian Campbell Subject: Re: [PATCH v4 18/21] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk Date: Mon, 28 Apr 2014 15:09:40 +0100 Message-ID: <1398694180.29700.126.camel@kazak.uk.xensource.com> References: <1398172475-27873-1-git-send-email-julien.grall@linaro.org> <1398172475-27873-19-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WemFd-0002Ss-3R for xen-devel@lists.xenproject.org; Mon, 28 Apr 2014 14:09:45 +0000 In-Reply-To: <1398172475-27873-19-git-send-email-julien.grall@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: xen-devel@lists.xenproject.org, tim@xen.org, stefano.stabellini@citrix.com List-Id: xen-devel@lists.xenproject.org On Tue, 2014-04-22 at 14:14 +0100, Julien Grall wrote: > Some IOMMU doesn't suppport coherent PT walk. When the p2m is shared with > the CPU, Xen has to make sure the PT changes have reached the memory. > > Introduce new IOMMU callback that will retrieve the IOMMU feature for a > specified domain. > > On ARM, the platform can contain multiple IOMMUs. Each of them may not > have the same set of feature. The domain parameter will be used to get the > set of features for IOMMUs used by this domain. > > Signed-off-by: Julien Grall > > --- > Changes in v4: > - Patch added > --- > xen/arch/arm/p2m.c | 24 ++++++++++++++++++------ > xen/drivers/passthrough/iommu.c | 11 +++++++++++ > xen/include/xen/iommu.h | 5 +++++ > 3 files changed, 34 insertions(+), 6 deletions(-) > > diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c > index 21219de..996d2bd 100644 > --- a/xen/arch/arm/p2m.c > +++ b/xen/arch/arm/p2m.c > @@ -274,6 +274,18 @@ enum p2m_operation { > CACHEFLUSH, > }; > > +static void unmap_coherent_domain_page(struct domain *d, const void *va) > +{ > + /* Some IOMMU doesn't support coherent PT walk. When the p2m is "don't support" > + * shared with the CPU, Xen has to make sure that the PT changes have > + * reached the memory > + */ > + if ( need_iommu(d) && !iommu_has_feature(d, IOMMU_FEAT_COHERENT_WALK) ) > + clean_xen_dcache_va_range(va, PAGE_SIZE); This is a fairly large hammer when you might only have touched a few bytes, if any, in the page. Wouldn't it be better to do this is write_pte, or just after the calls to write_pte? iommu_has_feature has a lot of callbacks -- worth calling once in apply_p2m_changes? Ian