From: Stefano Stabellini Subject: Re: [PATCH v3 3/3] xen/arm: introduce XENFEAT_grant_map_identity Date: Thu, 24 Jul 2014 15:14:00 +0100 Message-ID: References: <1406208666-23547-3-git-send-email-stefano.stabellini@eu.citrix.com> <53D10F2E.7040009@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53D10F2E.7040009@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: julien.grall@citrix.com, xen-devel@lists.xensource.com, Ian.Campbell@citrix.com, Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Thu, 24 Jul 2014, Julien Grall wrote: > Hi Stefano, > > On 07/24/2014 02:31 PM, Stefano Stabellini wrote: > > diff --git a/xen/common/kernel.c b/xen/common/kernel.c > > index 7e83353..dacbe38 100644 > > --- a/xen/common/kernel.c > > +++ b/xen/common/kernel.c > > @@ -15,6 +15,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -325,6 +326,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) > > break; > > } > > #endif > > + if ( gnttab_need_identity_mapping(d) ) > > Actually even platform the IOMMU support needs to have this flags on. > With this solution you break platform where not every DMA-capable device > are behind an SMMU. I see. > > + fi.submap |= 1U << XENFEAT_grant_map_identity; > > break; > > default: > > return -EINVAL; > > diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_table.h > > index eac8a70..6f7ccd9 100644 > > --- a/xen/include/asm-arm/grant_table.h > > +++ b/xen/include/asm-arm/grant_table.h > > @@ -36,6 +36,9 @@ static inline int replace_grant_supported(void) > > #define gnttab_need_iommu_mapping(d) \ > > (is_domain_direct_mapped(d) && need_iommu(d)) > > > > +#define gnttab_need_identity_mapping(d) \ > > + (is_domain_direct_mapped(d) && !need_iommu(d)) > > + > > Why didn't you drop the need_iommu(d) in is_domain_direct_mapped? I guess you mean why didn't you drop the need_iommu(d) in gnttab_need_iommu_mapping? Because how can you need an iommu mapping if an iommu is not present? > Hence the name is confusing. You may think that we don't need identity > mapping when IOMMU is used while it's actually the case, but we use a > different function. Yes, you are right. The whole thing is a bit confusing, I am trying to come up with a naming scheme that is as clear as possible. What if we simply define: #define gnttab_need_identity_mapping(d) (is_domain_direct_mapped(d))