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

[PATCH] xen/arm: Enclose all iommu related access within CONFIG_HAS_PASSTHROUGH


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Date: Mon, 11 Nov 2024 18:06:35 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qw5Z636sXSB0JNWwb70Y7ZD3Tbbt5SfmO3r88nV8ySE=; b=fiNNSFruNIBVnAFwTTmTPoXHlqL0MqoJLFewsa66nKjNZiNWykPKHsPQutkxwoUGD3m3i68cMhp77wjmJ94j79sACWkXOkj9q0JSgpMZpO57DiMpnDYKU6W8xo0kp6ehhpoyDn+FijtgN/ZGYy9iDRq/k9tW4EQSZKWQTiFNPIjb6m7/36Ek4kNJcNSD+LQ8En8YjM4ihCytKpy6Y9QfljQZOHKgi1Vbl6poEJE+YErsc0FS/BP2djiZiPz4bliHZYexHi4hZU8AgHUIIgjiJDDsOBYTI1b5p7CznecMo5Yvb4LjbRmIEMi7jRtbub+/OAdjERdQOnbSp3nghCEc2Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jJZtfNNd1UdyKs1z9y8NawyD7rgVVnMK4vrS9HO24cJYsMKUr7B4aFkcugoWcXjVbk00ax9bBsPbfNwCDpwF9RTd4KWFxtuf6MWq7KnJ9U4XwOsr8wSE5vRWo7kFJIzHD08rfMCY/h/j2NdRmxgB47m1MVhm/ONLPt49jZCt350U30zdsORUH201GVD0UeOLhfsJdvXO3YBPNlqnaxduJyMdejwxivMnFXMQ+Dzunhqqv4NgoXlK1rHDDTozwHn4ekPgCnkxsgKoEpgf1K+UQk/xfea7ygMYkVnrTMAOfARcxKoj1mbiY0uXwao/A2qjS4P3DsTFnglUZTwXYjOYaw==
  • Cc: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 11 Nov 2024 18:07:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

As CONFIG_HAS_PASSTHROUGH is enabled only for MMU, thus any common code
accessing iommu needs to be enclosed within CONFIG_HAS_PASSTHROUGH.

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
 xen/arch/arm/Kconfig          | 4 ++--
 xen/arch/arm/device.c         | 2 ++
 xen/arch/arm/dom0less-build.c | 6 ++++++
 xen/arch/arm/domain.c         | 6 ++++++
 xen/arch/arm/domain_build.c   | 2 ++
 xen/arch/arm/p2m.c            | 2 ++
 xen/arch/arm/setup.c          | 2 ++
 7 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 701b2aa76b..4833f12d2a 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -14,9 +14,7 @@ config ARM
        select FUNCTION_ALIGNMENT_4B
        select HAS_ALTERNATIVE if HAS_VMAP
        select HAS_DEVICE_TREE
-       select HAS_PASSTHROUGH
        select HAS_UBSAN
-       select IOMMU_FORCE_PT_SHARE if MMU
 
 config ARCH_DEFCONFIG
        string
@@ -77,8 +75,10 @@ choice
 config MMU
        bool "MMU"
        select HAS_PAGING_MEMPOOL
+       select HAS_PASSTHROUGH
        select HAS_PMAP
        select HAS_VMAP
+       select IOMMU_FORCE_PT_SHARE
        help
          Select it if you plan to run Xen on A-profile Armv7+
 
diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
index 5610cddcba..9805bc7742 100644
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -279,6 +279,7 @@ int handle_device(struct domain *d, struct dt_device_node 
*dev, p2m_type_t p2mt,
     dt_dprintk("%s passthrough = %d naddr = %u\n",
                dt_node_full_name(dev), own_device, naddr);
 
+#ifdef CONFIG_HAS_PASSTHROUGH
     if ( own_device )
     {
         dt_dprintk("Check if %s is behind the IOMMU and add it\n",
@@ -304,6 +305,7 @@ int handle_device(struct domain *d, struct dt_device_node 
*dev, p2m_type_t p2mt,
             }
         }
     }
+#endif
 
     res = map_device_irqs_to_domain(d, dev, own_device, irq_ranges);
     if ( res < 0 )
diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
index 9575769b25..ecf81f5748 100644
--- a/xen/arch/arm/dom0less-build.c
+++ b/xen/arch/arm/dom0less-build.c
@@ -368,15 +368,21 @@ static int __init handle_passthrough_prop(struct 
kernel_info *kinfo,
     if ( res < 0 )
         return res;
 
+#ifdef CONFIG_HAS_PASSTHROUGH
     res = iommu_add_dt_device(node);
     if ( res < 0 )
         return res;
+#endif
 
     /* If xen_force, we allow assignment of devices without IOMMU protection. 
*/
     if ( xen_force && !dt_device_is_protected(node) )
         return 0;
 
+#ifdef CONFIG_HAS_PASSTHROUGH
     return iommu_assign_dt_device(kinfo->d, node);
+#else
+    return res;
+#endif
 }
 
 static int __init handle_prop_pfdt(struct kernel_info *kinfo,
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 3ba959f866..2da8eaed01 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -710,9 +710,11 @@ int arch_domain_create(struct domain *d,
     ioreq_domain_init(d);
 #endif
 
+#ifdef CONFIG_HAS_PASSTHROUGH
     /* p2m_init relies on some value initialized by the IOMMU subsystem */
     if ( (rc = iommu_domain_init(d, config->iommu_opts)) != 0 )
         goto fail;
+#endif
 
     if ( (rc = p2m_init(d)) != 0 )
         goto fail;
@@ -841,7 +843,9 @@ void arch_domain_destroy(struct domain *d)
     /* IOMMU page table is shared with P2M, always call
      * iommu_domain_destroy() before p2m_final_teardown().
      */
+#ifdef CONFIG_HAS_PASSTHROUGH
     iommu_domain_destroy(d);
+#endif
     p2m_final_teardown(d);
     domain_vgic_free(d);
     domain_vuart_free(d);
@@ -1059,9 +1063,11 @@ int domain_relinquish_resources(struct domain *d)
     switch ( d->arch.rel_priv )
     {
     case 0:
+#ifdef CONFIG_HAS_PASSTHROUGH
         ret = iommu_release_dt_devices(d);
         if ( ret )
             return ret;
+#endif
 
         /*
          * Release the resources allocated for vpl011 which were
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 2c30792de8..2b41a3c926 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2137,7 +2137,9 @@ static int __init construct_dom0(struct domain *d)
         dom0_mem = MB(512);
     }
 
+#ifdef CONFIG_HAS_PASSTHROUGH
     iommu_hwdom_init(d);
+#endif
 
     d->max_pages = dom0_mem >> PAGE_SHIFT;
 
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 65b70955e3..343d5b857c 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -434,6 +434,7 @@ void p2m_set_way_flush(struct vcpu *v, struct cpu_user_regs 
*regs,
     /* This function can only work with the current vCPU. */
     ASSERT(v == current);
 
+#ifdef CONFIG_HAS_PASSTHROUGH
     if ( iommu_use_hap_pt(current->domain) )
     {
         gprintk(XENLOG_ERR,
@@ -441,6 +442,7 @@ void p2m_set_way_flush(struct vcpu *v, struct cpu_user_regs 
*regs,
         inject_undef_exception(regs, hsr);
         return;
     }
+#endif
 
     if ( !(v->arch.hcr_el2 & HCR_TVM) )
     {
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 4b52fc314a..bdc0d810ee 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -419,6 +419,7 @@ void asmlinkage __init start_xen(unsigned long fdt_paddr)
     /* This should be done in a vpmu driver but we do not have one yet. */
     vpmu_is_available = cpu_has_pmu;
 
+#ifdef CONFIG_HAS_PASSTHROUGH
     /*
      * The IOMMU subsystem must be initialized before P2M as we need
      * to gather requirements regarding the maximum IPA bits supported by
@@ -427,6 +428,7 @@ void asmlinkage __init start_xen(unsigned long fdt_paddr)
     rc = iommu_setup();
     if ( !iommu_enabled && rc != -ENODEV )
         panic("Couldn't configure correctly all the IOMMUs.\n");
+#endif
 
     setup_virt_paging();
 
-- 
2.25.1




 


Rackspace

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