From 1f3e837e4bececc598339aebbf314073cb682d0b Mon Sep 17 00:00:00 2001 From: Jianyong Wu Date: Wed, 28 Jun 2023 01:51:27 +0000 Subject: [PATCH] runtime-rs: fix build error on AArch64 Vfio support introduce build error on AArch64. Remove arch related annotation can avoid this error. Fixes: #7187 Signed-off-by: Jianyong Wu --- .../crates/hypervisor/src/device/driver/vfio.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs index 7d71e4e1ef..132535dbdc 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs @@ -4,7 +4,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] use std::{ collections::HashMap, fs, @@ -40,6 +39,7 @@ const VFIO_PCI_DRIVER_UNBIND: &str = "/sys/bus/pci/drivers/vfio-pci/unbind"; const SYS_CLASS_IOMMU: &str = "/sys/class/iommu"; const INTEL_IOMMU_PREFIX: &str = "dmar"; const AMD_IOMMU_PREFIX: &str = "ivhd"; +const ARM_IOMMU_PREFIX: &str = "smmu"; lazy_static! { static ref GUEST_DEVICE_ID: Arc = Arc::new(AtomicU8::new(0_u8)); @@ -89,7 +89,9 @@ pub fn do_check_iommu_on() -> Result { Ok(element .map(|e| { let x = e.file_name().to_string_lossy().into_owned(); - x.starts_with(INTEL_IOMMU_PREFIX) || x.starts_with(AMD_IOMMU_PREFIX) + x.starts_with(INTEL_IOMMU_PREFIX) + || x.starts_with(AMD_IOMMU_PREFIX) + || x.starts_with(ARM_IOMMU_PREFIX) }) .unwrap()) } @@ -578,10 +580,10 @@ pub fn bind_device_to_vfio(bdf: &str, host_driver: &str, _vendor_device_id: &str if cmdline.contains("iommu=off") || !cmdline.contains("iommu=") { return Err(anyhow!("iommu isn't set on kernel cmdline")); } + } - if !do_check_iommu_on().context("check iommu on failed")? { - return Err(anyhow!("IOMMU not enabled yet.")); - } + if !do_check_iommu_on().context("check iommu on failed")? { + return Err(anyhow!("IOMMU not enabled yet.")); } // if it's already bound to vfio