From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH v3 01/13] xen/common: grant-table: only call IOMMU if paging mode translate is disabled Date: Tue, 11 Mar 2014 15:49:47 +0000 Message-ID: <1394552999-14171-2-git-send-email-julien.grall@linaro.org> References: <1394552999-14171-1-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.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WNOwU-0006kf-Rp for xen-devel@lists.xenproject.org; Tue, 11 Mar 2014 15:50:11 +0000 Received: by mail-wi0-f178.google.com with SMTP id n15so1098836wiw.5 for ; Tue, 11 Mar 2014 08:50:08 -0700 (PDT) In-Reply-To: <1394552999-14171-1-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: xen-devel@lists.xenproject.org Cc: stefano.stabellini@citrix.com, Keir Fraser , Julien Grall , tim@xen.org, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org >>From Xen point of view, ARM guests are PV guest with paging auto translate enabled. When IOMMU support will be added for ARM, mapping grant ref will always crash Xen due to the BUG_ON in __gnttab_map_grant_ref. On x86: - PV guests always have paging mode translate disabled - PVH and HVM guests have always paging mode translate enabled It means that we can safely replace the check that the domain is a PV guests by checking if the guest has paging mode translate enabled. Signed-off-by: Julien Grall Reviewed-by: Jan Beulich Acked-by: Ian Campbell Cc: Keir Fraser --- xen/common/grant_table.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 107b000..778bdb7 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -721,12 +721,10 @@ __gnttab_map_grant_ref( double_gt_lock(lgt, rgt); - if ( is_pv_domain(ld) && need_iommu(ld) ) + if ( !paging_mode_translate(ld) && need_iommu(ld) ) { unsigned int wrc, rdc; int err = 0; - /* Shouldn't happen, because you can't use iommu in a HVM domain. */ - BUG_ON(paging_mode_translate(ld)); /* We're not translated, so we know that gmfns and mfns are the same things, so the IOMMU entry is always 1-to-1. */ mapcount(lgt, rd, frame, &wrc, &rdc); @@ -931,11 +929,10 @@ __gnttab_unmap_common( act->pin -= GNTPIN_hstw_inc; } - if ( is_pv_domain(ld) && need_iommu(ld) ) + if ( !paging_mode_translate(ld) && need_iommu(ld) ) { unsigned int wrc, rdc; int err = 0; - BUG_ON(paging_mode_translate(ld)); mapcount(lgt, rd, op->frame, &wrc, &rdc); if ( (wrc + rdc) == 0 ) err = iommu_unmap_page(ld, op->frame); -- 1.7.10.4