Skip to content

Commit d8508e4

Browse files
Sainath Grandhilijinxia
authored andcommitted
hv: init_iommu rework to enable IOMMU for partition mode ACRN
Current code enables IOMMU from init_iommu_vm0_domain which is called from vm0/sos boot sequence. For partition mode VMs, this is not called as VMs are numbered from 1. This patch adds support to initialize root table pointer for each IOMMU and enable all IOMMUs from init_iommu. Hence IOMMUs are enabled even though ACRN does not boot vm0. Tracked-On: #1246 Signed-off-by: Sainath Grandhi sainath.grandhi@intel.com
1 parent 2af08d9 commit d8508e4

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

hypervisor/arch/x86/vtd.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,18 @@ static void dmar_set_root_table(struct dmar_drhd_rt *dmar_uint)
662662
{
663663
uint64_t address;
664664
uint32_t status;
665+
void *root_table_vaddr = NULL;
665666

666667
spinlock_obtain(&(dmar_uint->lock));
667668

669+
root_table_vaddr = alloc_paging_struct();
670+
671+
if (root_table_vaddr != NULL) {
672+
dmar_uint->root_table_addr = hva2hpa(root_table_vaddr);
673+
} else {
674+
ASSERT(false, "failed to allocate root table!");
675+
}
676+
668677
/* Currently don't support extended root table */
669678
address = dmar_uint->root_table_addr;
670679

@@ -976,16 +985,7 @@ static int add_iommu_device(struct iommu_domain *domain, uint16_t segment,
976985
return 1;
977986
}
978987

979-
if (dmar_uint->root_table_addr == 0UL) {
980-
void *root_table_vaddr = alloc_paging_struct();
981-
982-
if (root_table_vaddr != NULL) {
983-
dmar_uint->root_table_addr = hva2hpa(root_table_vaddr);
984-
} else {
985-
ASSERT(false, "failed to allocate root table!");
986-
return 1;
987-
}
988-
}
988+
ASSERT(dmar_uint->root_table_addr != 0UL, "root table is not setup");
989989

990990
root_table =
991991
(struct dmar_root_entry *)hpa2hva(dmar_uint->root_table_addr);
@@ -1280,6 +1280,8 @@ void init_iommu(void)
12801280
spinlock_init(&domain_lock);
12811281

12821282
register_hrhd_units();
1283+
1284+
enable_iommu();
12831285
}
12841286

12851287
void init_iommu_vm0_domain(struct vm *vm0)
@@ -1299,5 +1301,4 @@ void init_iommu_vm0_domain(struct vm *vm0)
12991301
}
13001302
}
13011303
cache_flush_invalidate_all();
1302-
enable_iommu();
13031304
}

0 commit comments

Comments
 (0)