[kvm-unit-tests PATCH] intel_iommu: fix an incorrect address translation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reported-by: Alexander Gordeev <agordeev@xxxxxxxxxx>
Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
---
Tests: map one page twice and see whether dmar work

Alex, do you mind I add your s-o-b as well in this patch above mine? :)

Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
---
 lib/x86/intel-iommu.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/x86/intel-iommu.c b/lib/x86/intel-iommu.c
index 20b9240..7a3f324 100644
--- a/lib/x86/intel-iommu.c
+++ b/lib/x86/intel-iommu.c
@@ -166,9 +166,6 @@ static void vtd_install_pte(vtd_pte_t *root, iova_t iova,
 	}
 }
 
-#define  VTD_PHYS_TO_VIRT(x) \
-	((void *)(((uint64_t)phys_to_virt(x)) >> VTD_PAGE_SHIFT))
-
 /**
  * vtd_map_range: setup IO address mapping for specific memory range
  *
@@ -203,7 +200,7 @@ void vtd_map_range(uint16_t sid, iova_t iova, phys_addr_t pa, size_t size)
 		printf("allocated vt-d root entry for PCI bus %d\n",
 		       bus_n);
 	} else
-		ce = VTD_PHYS_TO_VIRT(re->context_table_p);
+		ce = phys_to_virt(re->context_table_p << VTD_PAGE_SHIFT);
 
 	/* Point to the correct context entry */
 	ce += devfn;
@@ -224,7 +221,7 @@ void vtd_map_range(uint16_t sid, iova_t iova, phys_addr_t pa, size_t size)
 		printf("allocated vt-d context entry for devfn 0x%x\n",
 		       devfn);
 	} else
-		slptptr = VTD_PHYS_TO_VIRT(ce->slptptr);
+		slptptr = phys_to_virt(ce->slptptr << VTD_PAGE_SHIFT);
 
 	while (size) {
 		/* TODO: currently we only map 4K pages (level = 1) */
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux