From 403076e6b95d685024283b7f2c048c34c50b80fc Mon Sep 17 00:00:00 2001 From: Jason Chen CJ Date: Tue, 10 Apr 2018 21:34:12 +0800 Subject: [PATCH] vtd: dmar_uint->root_table_addr should be hpa add necessary HPA2HVA/HVA2HPA transition for root_table_addr Signed-off-by: Jason Chen CJ Acked-by: Tian, Kevin Acked-by: Xu, Anthony --- hypervisor/arch/x86/vtd.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index cea4e56a3..3d1c61ad9 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -965,14 +965,10 @@ static int add_iommu_device(struct iommu_domain *domain, uint16_t segment, } if (dmar_uint->root_table_addr == 0) { - /* 1:1 mapping for hypervisor HEAP, - * physical address equals virtual address - */ - dmar_uint->root_table_addr = - (uint64_t)alloc_paging_struct(); + dmar_uint->root_table_addr = HVA2HPA(alloc_paging_struct()); } - root_table = (uint64_t *)dmar_uint->root_table_addr; + root_table = (uint64_t *)HPA2HVA(dmar_uint->root_table_addr); root_entry = (struct dmar_root_entry *)&root_table[bus * 2]; @@ -1071,7 +1067,7 @@ remove_iommu_device(struct iommu_domain *domain, uint16_t segment, return 1; } - root_table = (uint64_t *)dmar_uint->root_table_addr; + root_table = (uint64_t *)HPA2HVA(dmar_uint->root_table_addr); root_entry = (struct dmar_root_entry *)&root_table[bus * 2]; context_table_addr = DMAR_GET_BITSLICE(root_entry->lower,