[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen staging] iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...



commit 52633db2c5ed2df352004f97e2272edc90af3cb4
Author:     Paul Durrant <paul.durrant@xxxxxxxxxx>
AuthorDate: Thu Sep 26 11:03:08 2019 +0100
Commit:     Julien Grall <julien.grall@xxxxxxx>
CommitDate: Thu Sep 26 14:30:32 2019 +0100

    iommu: avoid triggering ASSERT_UNREACHABLE() on ARM...
    
    ...when the IOMMU is not enabled.
    
    80ff3d338dc9 "iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync()
    macros" introduced CONFIG_IOMMU_FORCE_PT_SHARE, which causes the global
    'iommu_hap_pt_share' option to be replaced with a #define-d value of true.
    In this configuration, calling clear_iommu_hap_pt_share() will result
    trigger the aforementioned ASSERT.
    
    CONFIG_IOMMU_FORCE_PT_SHARE is always selected for ARM builds and,
    because clear_iommu_hap_pt_share() is called by the common iommu_setup()
    function if the IOMMU is not enabled, it is no longer safe to disable the
    IOMMU on ARM systems.
    
    However, running with the IOMMU disabled is a valid configuration for ARM
    systems, so this patch rectifies the problem by removing the call to
    clear_iommu_hap_pt_share() from common code. As a side effect of this,
    however, it becomes possible on x86 systems for iommu_enabled to be false
    but iommu_hap_pt_share to be true. Thus the code in sysctl.c
    needs to be changed to make sure that XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share
    is not erroneously advertised when the IOMMU has been disabled.
    
    Reported-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
    Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
    Acked-by: Julien Grall <julien.grall@xxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/common/sysctl.c             | 6 ++++--
 xen/drivers/passthrough/iommu.c | 3 ---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index e8763c7fdf..f88a285e7f 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -268,9 +268,11 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
         pi->max_mfn = get_upper_mfn_bound();
         arch_do_physinfo(pi);
         if ( iommu_enabled )
+        {
             pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio;
-        if ( iommu_hap_pt_share )
-            pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share;
+            if ( iommu_hap_pt_share )
+                pi->capabilities |= XEN_SYSCTL_PHYSCAP_iommu_hap_pt_share;
+        }
 
         if ( copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index e8fddc2dc7..2733b320ec 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -454,10 +454,7 @@ int __init iommu_setup(void)
         iommu_enabled = (rc == 0);
     }
     if ( !iommu_enabled )
-    {
         iommu_intremap = 0;
-        clear_iommu_hap_pt_share();
-    }
 
     if ( (force_iommu && !iommu_enabled) ||
          (force_intremap && !iommu_intremap) )
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.