intel_iommu: fix an incorrect address translation
PATCH 1/1 intel_iommu: fix an incorrect address translation
Reported-by Alexander Gordeev <[email protected]>
Signed-off-by Peter Xu <[email protected]>
---
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 <[email protected]>
--- lib/x86/intel-iommu.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
lib/x86/intel-iommu.c +2 -5
@@ -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) */
Signature · 1 line
2.7.4
Quoted 6 lines · Peter Xu
Reported-by Alexander Gordeev <[email protected]>Signed-off-by Peter Xu <[email protected]>---
Tests: map one page twice and see whether dmar workAlex, do you mind I add your s-o-b as well in this patch above mine? :)
I am fine with either :)
Quoted 40 lines
Signed-off-by Peter Xu <[email protected]>--- lib/x86/intel-iommu.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)lib/x86/intel-iommu.c +2
-5@@ -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) */ Signature · 1 line
2.7.4
Quoted 37 lines · Peter Xu
Reported-by Alexander Gordeev <[email protected]>Signed-off-by Peter Xu <[email protected]>---
Tests: map one page twice and see whether dmar workAlex, do you mind I add your s-o-b as well in this patch above mine? :)
Signed-off-by Peter Xu <[email protected]>--- lib/x86/intel-iommu.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)lib/x86/intel-iommu.c +1
-4@@ -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;
lib/x86/intel-iommu.c void vtd_map_range(uint16_t sid, iova_t iova, phys_addr_t pa, size_t size) · line 227
Quoted 8 lines
lib/x86/intel-iommu.c +1
-1@@ -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) */
Queued, thanks.
Paolo