@@ -659,18 +659,9 @@ static void dmar_set_root_table(struct dmar_drhd_rt *dmar_uint)
659
659
{
660
660
uint64_t address ;
661
661
uint32_t status ;
662
- void * root_table_vaddr = NULL ;
663
662
664
663
spinlock_obtain (& (dmar_uint -> lock ));
665
664
666
- root_table_vaddr = alloc_paging_struct ();
667
-
668
- if (root_table_vaddr != NULL ) {
669
- dmar_uint -> root_table_addr = hva2hpa (root_table_vaddr );
670
- } else {
671
- ASSERT (false, "failed to allocate root table!" );
672
- }
673
-
674
665
/* Currently don't support extended root table */
675
666
address = dmar_uint -> root_table_addr ;
676
667
@@ -982,7 +973,16 @@ static int add_iommu_device(struct iommu_domain *domain, uint16_t segment,
982
973
return 1 ;
983
974
}
984
975
985
- ASSERT (dmar_uint -> root_table_addr != 0UL , "root table is not setup" );
976
+ if (dmar_uint -> root_table_addr == 0UL ) {
977
+ void * root_table_vaddr = alloc_paging_struct ();
978
+
979
+ if (root_table_vaddr != NULL ) {
980
+ dmar_uint -> root_table_addr = hva2hpa (root_table_vaddr );
981
+ } else {
982
+ ASSERT (false, "failed to allocate root table!" );
983
+ return 1 ;
984
+ }
985
+ }
986
986
987
987
root_table =
988
988
(struct dmar_root_entry * )hpa2hva (dmar_uint -> root_table_addr );
@@ -1277,8 +1277,6 @@ void init_iommu(void)
1277
1277
spinlock_init (& domain_lock );
1278
1278
1279
1279
register_hrhd_units ();
1280
-
1281
- enable_iommu ();
1282
1280
}
1283
1281
1284
1282
void init_iommu_vm0_domain (struct vm * vm0 )
@@ -1298,4 +1296,5 @@ void init_iommu_vm0_domain(struct vm *vm0)
1298
1296
}
1299
1297
}
1300
1298
cache_flush_invalidate_all ();
1299
+ enable_iommu ();
1301
1300
}
0 commit comments