xen/arm: Enclose all iommu related access within CONFIG_HAS_PASSTHROUGH
PATCH 1/1 xen/arm: Enclose all iommu related access within CONFIG_HAS_PASSTHROUGH
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 <[email protected]>
--- 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(-)
xen/arch/arm/Kconfig +2 -2
@@ -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+
xen/arch/arm/device.c +2 -0
@@ -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 )
xen/arch/arm/dom0less-build.c +6 -0
@@ -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,
xen/arch/arm/domain.c +6 -0
@@ -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
xen/arch/arm/domain_build.c +2 -0
@@ -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 ;
xen/arch/arm/p2m.c +2 -0
@@ -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 ) ) {
xen/arch/arm/setup.c +2 -0
@@ -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 ();
Signature · 1 line
2.25.1
Quoted 2 lines · Ayan Kumar Halder
As
CONFIG_HAS_PASSTHROUGHis enabled only for MMU, thus any common code accessing iommu needs to be enclosed withinCONFIG_HAS_PASSTHROUGH.
I'm not an Arm maintainer, so my opinion may not count much, but that's quite a bit of #ifdef-ary. In at least some of the cases using stubs instead may result in better legibility ...
Jan