From c851f32b02ba2c50cc5580efdb167ad670e30747 Mon Sep 17 00:00:00 2001 From: agicy Date: Fri, 14 Nov 2025 21:24:11 +0800 Subject: [PATCH] fix(arch/aarch64/iommu): make IOMMU initialization conditional on a feature flag This commit resolves the issue #212 by wrapping the SMMUv3 initialization logic in a `#[cfg(feature = "iommu")]` attribute. A corresponding empty `iommu_init` function is provided under `#[cfg(not(feature = "iommu"))]`. This change allows the hypervisor to be compiled without IOMMU support, enabling it to boot successfully on affected hardware by disabling the default feature. Fixes: #212 --- src/arch/aarch64/iommu.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/arch/aarch64/iommu.rs b/src/arch/aarch64/iommu.rs index 1b7110d5..a33d3f17 100644 --- a/src/arch/aarch64/iommu.rs +++ b/src/arch/aarch64/iommu.rs @@ -530,7 +530,14 @@ impl Smmuv3 { static SMMUV3: spin::Once> = spin::Once::new(); -/// smmuv3 init +/// iommu feature is disabled. +#[cfg(not(feature = "iommu"))] +pub fn iommu_init() { + info!("aarch64: iommu_init: do nothing now"); +} + +/// smmuv3 init (enabled) +#[cfg(feature = "iommu")] pub fn iommu_init() { info!("Smmuv3 init..."); SMMUV3.call_once(|| Mutex::new(Smmuv3::new()));