Skip to content

Commit aec1b7f

Browse files
committed
ArmPkg/SmmuDxe: Add per-streamId isolation for each DMA capable device
Replaces the previous shared-root model with on-demand per-StreamID stage-2 isolation: * Each StreamID gets its own stage-2 page-table root and VMID, allocated lazily on the first IoMmuSetAttribute call and promoted via break-before-make. * Aliases (multiple StreamIDs for one logical device) share the primary's root + VMID, so a single page-table update covers all of them and TLB invalidation by (VMID, IPA) is alias-safe. * DeviceHandleToStreamId resolves an EFI_HANDLE to its StreamID(s) and owning SMMU base via PciIo->GetLocation: real PCIe goes through the IORT Root Complex node; non-discoverable devices are detected when GetLocation() returns Segment 0xFF, from which the UniqueId is extracted and looked up in the NC HOB table to find the matching IORT Named Component node. * IoMmuSetAttributeById provides the same isolation for handle-less DMA agents using (IommuBase, StreamId) directly. * GIC EVTQ/GERR IRQs are registered per SMMU so faults surface immediately via SmmuV3LogErrors. * ExitBootServices is per-SMMU: RMR-bearing SMMUs go to bypass, others go to global-abort. Platform interface additions: * SMMU_CONFIG gains NcDeviceListSize / NcDeviceListOffset. * SMMU_NC_DEVICE_ENTRY {UniqueId, ObjName[32]} maps each platform UniqueId to an IORT Named Component name. See ArmPkg/Drivers/SmmuDxe/README.md for flow diagrams, HOB layout, and platform integration steps.
1 parent 4691635 commit aec1b7f

8 files changed

Lines changed: 2679 additions & 230 deletions

File tree

ArmPkg/Drivers/SmmuDxe/IoMmu.c

Lines changed: 607 additions & 61 deletions
Large diffs are not rendered by default.

ArmPkg/Drivers/SmmuDxe/IoMmu.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#define PAGE_TABLE_DESCRIPTOR (0x1 << 1)
2424
#define PAGE_TABLE_READ_WRITE_FROM_IOMMU_ACCESS(IoMmuAccess) (IoMmuAccess << 6)
2525

26+
// Forward declaration; full definition lives in SmmuV3.h.
27+
typedef struct _SMMU_INFO SMMU_INFO;
28+
2629
typedef UINT64 PAGE_TABLE_ENTRY;
2730

2831
#define PAGE_TABLE_SIZE (EFI_PAGE_SIZE / sizeof(PAGE_TABLE_ENTRY)) // Number of entries in a page table
@@ -35,7 +38,9 @@ typedef struct _PAGE_TABLE {
3538
/**
3639
Update the page table mapping with the given physical address and flags.
3740
41+
@param [in] SmmuInfo SMMU instance.
3842
@param [in] Root Pointer to the root page table.
43+
@param [in] Vmid VMID for associated page table root.
3944
@param [in] PhysicalAddress Physical address to map.
4045
@param [in] Bytes Number of bytes to map.
4146
@param [in] Flags Flags to set for the mapping. 12 bits or less.
@@ -47,7 +52,9 @@ typedef struct _PAGE_TABLE {
4752
**/
4853
EFI_STATUS
4954
UpdatePageTable (
55+
IN SMMU_INFO *SmmuInfo,
5056
IN PAGE_TABLE *Root,
57+
IN UINT16 Vmid,
5158
IN UINT64 PhysicalAddress,
5259
IN UINT64 Bytes,
5360
IN UINT16 Flags,

ArmPkg/Drivers/SmmuDxe/README.md

Lines changed: 478 additions & 75 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)