mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-04 11:07:51 +00:00
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. This patch also has changes to fix #1270. Tracked-On: #1246 #1270 Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
This commit is contained in:
parent
53731905d7
commit
8c9e0d17db
@ -659,9 +659,27 @@ static void dmar_set_root_table(struct dmar_drhd_rt *dmar_uint)
|
|||||||
{
|
{
|
||||||
uint64_t address;
|
uint64_t address;
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
|
void *root_table_vaddr = NULL;
|
||||||
|
|
||||||
spinlock_obtain(&(dmar_uint->lock));
|
spinlock_obtain(&(dmar_uint->lock));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* dmar_set_root_table is called from init_iommu and
|
||||||
|
* resume_iommu. So NULL check on this pointer is needed
|
||||||
|
* so that we do not change the root table pointer in the
|
||||||
|
* resume flow.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (dmar_uint->root_table_addr == 0UL) {
|
||||||
|
root_table_vaddr = alloc_paging_struct();
|
||||||
|
|
||||||
|
if (root_table_vaddr != NULL) {
|
||||||
|
dmar_uint->root_table_addr = hva2hpa(root_table_vaddr);
|
||||||
|
} else {
|
||||||
|
ASSERT(false, "failed to allocate root table!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Currently don't support extended root table */
|
/* Currently don't support extended root table */
|
||||||
address = dmar_uint->root_table_addr;
|
address = dmar_uint->root_table_addr;
|
||||||
|
|
||||||
@ -973,16 +991,7 @@ static int add_iommu_device(struct iommu_domain *domain, uint16_t segment,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmar_uint->root_table_addr == 0UL) {
|
ASSERT(dmar_uint->root_table_addr != 0UL, "root table is not setup");
|
||||||
void *root_table_vaddr = alloc_paging_struct();
|
|
||||||
|
|
||||||
if (root_table_vaddr != NULL) {
|
|
||||||
dmar_uint->root_table_addr = hva2hpa(root_table_vaddr);
|
|
||||||
} else {
|
|
||||||
ASSERT(false, "failed to allocate root table!");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
root_table =
|
root_table =
|
||||||
(struct dmar_root_entry *)hpa2hva(dmar_uint->root_table_addr);
|
(struct dmar_root_entry *)hpa2hva(dmar_uint->root_table_addr);
|
||||||
@ -1277,6 +1286,8 @@ void init_iommu(void)
|
|||||||
spinlock_init(&domain_lock);
|
spinlock_init(&domain_lock);
|
||||||
|
|
||||||
register_hrhd_units();
|
register_hrhd_units();
|
||||||
|
|
||||||
|
enable_iommu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_iommu_vm0_domain(struct vm *vm0)
|
void init_iommu_vm0_domain(struct vm *vm0)
|
||||||
@ -1296,5 +1307,4 @@ void init_iommu_vm0_domain(struct vm *vm0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cache_flush_invalidate_all();
|
cache_flush_invalidate_all();
|
||||||
enable_iommu();
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user