diff mbox

[RFC,for-4.5,01/12] xen/common: grant-table: only call IOMMU if paging mode translate is disabled

Message ID 1391794991-5919-2-git-send-email-julien.grall@linaro.org
State Accepted
Commit e5a6f60206f58a35601b2bada6ec4fedf5d2ace7
Headers show

Commit Message

Julien Grall Feb. 7, 2014, 5:43 p.m. UTC
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 <julien.grall@linaro.org>
Cc: Keir Fraser <keir@xen.org>
---
 xen/common/grant_table.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Ian Campbell Feb. 19, 2014, 12:25 p.m. UTC | #1
On Fri, 2014-02-07 at 17:43 +0000, Julien Grall wrote:
> 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 <julien.grall@linaro.org>
> Cc: Keir Fraser <keir@xen.org>

Acked-by: Ian Campbell <ian.campbell@citrix.com>
diff mbox

Patch

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);