]> xenbits.xensource.com Git - people/larsk/xen.git/commitdiff
xen/arm: iommu: Panic if not all IOMMUs are initialized
authorJulien Grall <julien.grall@arm.com>
Tue, 20 Aug 2019 12:22:55 +0000 (13:22 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 20 Sep 2019 00:28:25 +0000 (17:28 -0700)
At the moment, the platform can come up with only part of the IOMMUs
initialized. This could lead to a failure later on when building the
hardware domain or even trying to assign a device to a guest.

To avoid unwanted behavior, Xen will not continue if one of the IOMMUs
has not been initialized correctly.

[stefano: fix typo in comment, add '\n' to panic message]

Signed-off-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
xen/arch/arm/setup.c
xen/drivers/passthrough/arm/iommu.c

index 077b8d02a06ec83cffeb5b274d44aec388db54be..581b262655840ed2f94e6b887f934b7ad3df19ea 100644 (file)
@@ -784,6 +784,7 @@ void __init start_xen(unsigned long boot_phys_offset,
         .max_grant_frames = gnttab_dom0_frames(),
         .max_maptrack_frames = opt_max_maptrack_frames,
     };
+    int rc;
 
     dcache_line_bytes = read_dcache_line_bytes();
 
@@ -923,7 +924,9 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     setup_virt_paging();
 
-    iommu_setup();
+    rc = iommu_setup();
+    if ( !iommu_enabled && rc != -ENODEV )
+        panic("Couldn't configure correctly all the IOMMUs.\n");
 
     do_initcalls();
 
index 9cfb5890836e6c9be45cc56138aa5823a2c50c8c..2678ef5c01a473fb326531b2fdbe5136e42904c5 100644 (file)
@@ -52,6 +52,14 @@ int __init iommu_hardware_setup(void)
         rc = device_init(np, DEVICE_IOMMU, NULL);
         if ( !rc )
             num_iommus++;
+        /*
+         * Ignore the following error codes:
+         *   - EBADF: Indicate the current is not an IOMMU
+         *   - ENODEV: The IOMMU is not present or cannot be used by
+         *     Xen.
+         */
+        else if ( rc != -EBADF && rc != -ENODEV )
+            return rc;
     }
 
     return ( num_iommus > 0 ) ? 0 : -ENODEV;