Skip to main content

Module iommu

Module iommu 

Source
Expand description

Intel VT-d backend (x86_64).

Implements the legacy (non-scalable) translation path:

  • DMAR/DRHD discovery and CAP/ECAP probing;
  • shadow root/context/second-level tables (4 KiB, 2 MiB, 1 GiB leaves);
  • queued invalidation (QI) with WAIT completion;
  • interrupt-remapping table (IRTA/IRTE) and MSI doorbell allocation.

Context entries follow the legacy format observed in ESXi (IOMMU-ANALYSE.md Β§3.4): TT = 00 (second-level translation), AGAW in bits 6:4, domain id in the high qword bits 23:8. QI descriptor types and the IR doorbell formula follow Β§3.6/Β§3.7 of the same document.

Activation remains gated by HARDWARE_ACTIVATION_ENABLED: the code is complete but must be validated under QEMU intel-iommu before a boot path may enable it. Until then is_ready() is false, SYS_IOMMU_ACTIVATE returns 0 and MSI stays on the physical path.

Re-exportsΒ§

use alloc::collections::BTreeMap; πŸ”’
use alloc::vec::Vec; πŸ”’
use core::sync::atomic::AtomicBool; πŸ”’
use core::sync::atomic::AtomicU16; πŸ”’
use core::sync::atomic::Ordering; πŸ”’
use super::super::iommu::Backend; πŸ”’
use super::super::iommu::Discovery; πŸ”’
use super::super::iommu::IommuError; πŸ”’
use super::super::iommu::MsiAllocation; πŸ”’
use crate::hardware::iommu::DmaProt; πŸ”’
use crate::hardware::iommu::DomainId; πŸ”’
use crate::hardware::iommu::MappingKind; πŸ”’
use crate::hardware::iommu::Sbdf; πŸ”’
use crate::memory; πŸ”’
use crate::sync::SpinLock; πŸ”’

StructsΒ§

DomainShadow πŸ”’
IrTable πŸ”’
Qi πŸ”’
Unit πŸ”’
VtdBackend πŸ”’
VtdState πŸ”’

ConstantsΒ§

CAP_CM πŸ”’
ECAP_IR πŸ”’
ECAP_PT πŸ”’
ECAP_QI πŸ”’
GCMD_IRE πŸ”’
GCMD_QI πŸ”’
GCMD_SIRTP πŸ”’
GCMD_SRTP πŸ”’
GCMD_TE πŸ”’
GSTS_IRES πŸ”’
GSTS_QIES πŸ”’
GSTS_RTPS πŸ”’
GSTS_SIRTPS πŸ”’
GSTS_TES πŸ”’
HARDWARE_ACTIVATION_ENABLED
Flip only after QEMU/hardware validation of the activation path.
INTERRUPT_REMAPPING_ENABLED
Interrupt remapping is not enabled yet: MSI messages are still physical. Enabling IRE without programming every device’s IRTE would drop MSI.
IRTE_COUNT πŸ”’
Number of 128-bit IRTEs (one 4 KiB page).
QI_CONTEXT πŸ”’
QI descriptor types (ESXi IOMMU-ANALYSE.md Β§3.6).
QI_ENTRIES πŸ”’
QI_IOTLB πŸ”’
QI_IRTE πŸ”’
QI_SIZE_BYTES πŸ”’
QI_WAIT πŸ”’
SL_ADDR_MASK πŸ”’
SL_PRESENT πŸ”’
Second-level page-table flags.
SL_SUPERPAGE πŸ”’
SL_WRITE πŸ”’
VTD_CAP πŸ”’
VTD_ECAP πŸ”’
VTD_GCMD πŸ”’
VTD_GSTS πŸ”’
VTD_IQA πŸ”’
VTD_IQH πŸ”’
VTD_IQT πŸ”’
VTD_IRTA πŸ”’
VTD_RTADDR πŸ”’

StaticsΒ§

ACTIVE πŸ”’
DISCOVERY πŸ”’
IR_ACTIVE πŸ”’
STATE πŸ”’
VTD πŸ”’

FunctionsΒ§

alloc_zeroed_table πŸ”’
backend
Backend handle, available only when a DMAR was found.
clear_leaf πŸ”’
discovery
Summary recorded by init.
flush_unit πŸ”’
init
Parse the DMAR, probe the units and build the shadow root table.
install_context_entry πŸ”’
Legacy context entry (ESXi IOMMU-ANALYSE.md Β§3.4).
install_leaf πŸ”’
install_passthrough_contexts πŸ”’
Give every PCI function a pass-through context entry unless it already has a translated one.
install_root_entry πŸ”’
ir_enable πŸ”’
map_mmio πŸ”’
mmio_read32 πŸ”’
mmio_read64 πŸ”’
mmio_write32 πŸ”’
mmio_write64 πŸ”’
next_table πŸ”’
qi_flush_ir πŸ”’
qi_setup πŸ”’
table_read πŸ”’ ⚠
table_write πŸ”’ ⚠
wait_bits πŸ”’
wait_gsts_clear πŸ”’
write_irte πŸ”’