From: "Jan Beulich" Subject: Re: [RFC PATCH 2/2] xen/arm: introduce XENFEAT_grant_map_11 Date: Wed, 23 Jul 2014 15:15:03 +0100 Message-ID: <53CFDF8702000078000252F5@mail.emea.novell.com> References: <1404834794-16055-2-git-send-email-stefano.stabellini@eu.citrix.com> <53CFB5FC02000078000250C0@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X9xK1-0007xI-Q2 for xen-devel@lists.xenproject.org; Wed, 23 Jul 2014 14:15:09 +0000 In-Reply-To: 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: Stefano Stabellini Cc: julien.grall@citrix.com, xen-devel , Ian.Campbell@citrix.com List-Id: xen-devel@lists.xenproject.org >>> On 23.07.14 at 15:31, wrote: > On Wed, 23 Jul 2014, Jan Beulich wrote: >> >>> On 08.07.14 at 17:53, wrote: >> > --- a/xen/include/asm-arm/grant_table.h >> > +++ b/xen/include/asm-arm/grant_table.h >> > @@ -33,8 +33,7 @@ static inline int replace_grant_supported(void) >> > ( ((i >= nr_grant_frames(d->grant_table)) && \ >> > (i < max_nr_grant_frames)) ? 0 : (d->arch.grant_table_gpfn[i])) >> > >> > -#define gnttab_need_iommu_mapping(d) \ >> > - (is_domain_direct_mapped(d) && need_iommu(d)) >> > +#define gnttab_need_iommu_mapping(d) > (is_domain_direct_mapped(d)) >> >> How is this change related to the subject of the patch? > > This change is the one that actually enables the second mapping on ARM. > gnttab_need_iommu_mapping needs to return true for dom0, so that > arch_iommu_grant_map_page gets called by __gnttab_map_grant_ref. > > I understand that actually XENFEAT_grant_map_11 doesn't have much to do > with IOMMUs or SMMUs, however it would still be nice to share the code > under: > > if ( gnttab_need_iommu_mapping(ld) ) > { > > in __gnttab_map_grant_ref. > An alternative to this change that would also get rid of patch #1 of > this series could be something like: > > diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c > index 464007e..e4e945a 100644 > --- a/xen/common/grant_table.c > +++ b/xen/common/grant_table.c > @@ -727,7 +727,7 @@ __gnttab_map_grant_ref( > > double_gt_lock(lgt, rgt); > > - if ( gnttab_need_iommu_mapping(ld) ) > + if ( gnttab_need_iommu_mapping(ld) || is_domain_direct_mapped(ld) ) > { > unsigned int wrc, rdc; > int err = 0; > @@ -738,13 +738,23 @@ __gnttab_map_grant_ref( > !(old_pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) ) > { > if ( wrc == 0 ) > - err = iommu_map_page(ld, frame, frame, > - IOMMUF_readable|IOMMUF_writable); > + { > + if ( gnttab_need_iommu_mapping(ld) ) > + err = iommu_map_page(ld, frame, frame, > + IOMMUF_readable|IOMMUF_writable); > + else > + err = arch_grant_map_page(ld, frame, IOMMUF_readable|IOMMUF_writable); > + } > } > else if ( act_pin && !old_pin ) > { > if ( (wrc + rdc) == 0 ) > - err = iommu_map_page(ld, frame, frame, IOMMUF_readable); > + { > + if ( gnttab_need_iommu_mapping(ld) ) > + err = iommu_map_page(ld, frame, frame, IOMMUF_readable); > + else > + err = arch_grant_map_page(ld, frame, IOMMUF_readable); > + } > } > if ( err ) > { > > do you think this would be better? Hmm, overall readability suffers, but at least it makes more obvious what arch_grant_map_page() is about. Jan