aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/amd_iommu.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 52e44af1570..0e068c9ca5f 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -2552,6 +2552,33 @@ static void amd_iommu_unmap_range(struct iommu_domain *dom,
2552 iommu_flush_tlb_pde(domain); 2552 iommu_flush_tlb_pde(domain);
2553} 2553}
2554 2554
2555static int amd_iommu_map(struct iommu_domain *dom, unsigned long iova,
2556 phys_addr_t paddr, int gfp_order, int iommu_prot)
2557{
2558 unsigned long page_size = 0x1000UL << gfp_order;
2559 struct protection_domain *domain = dom->priv;
2560 int prot = 0;
2561
2562 if (iommu_prot & IOMMU_READ)
2563 prot |= IOMMU_PROT_IR;
2564 if (iommu_prot & IOMMU_WRITE)
2565 prot |= IOMMU_PROT_IW;
2566
2567 return iommu_map_page(domain, iova, paddr, prot, page_size);
2568}
2569
2570static int amd_iommu_unmap(struct iommu_domain *dom, unsigned long iova,
2571 int gfp_order)
2572{
2573 struct protection_domain *domain = dom->priv;
2574 unsigned long page_size, unmap_size;
2575
2576 page_size = 0x1000UL << gfp_order;
2577 unmap_size = iommu_unmap_page(domain, iova, page_size);
2578
2579 return get_order(unmap_size);
2580}
2581
2555static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom, 2582static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom,
2556 unsigned long iova) 2583 unsigned long iova)
2557{ 2584{
@@ -2587,6 +2614,8 @@ static struct iommu_ops amd_iommu_ops = {
2587 .domain_destroy = amd_iommu_domain_destroy, 2614 .domain_destroy = amd_iommu_domain_destroy,
2588 .attach_dev = amd_iommu_attach_device, 2615 .attach_dev = amd_iommu_attach_device,
2589 .detach_dev = amd_iommu_detach_device, 2616 .detach_dev = amd_iommu_detach_device,
2617 .map = amd_iommu_map,
2618 .unmap = amd_iommu_unmap,
2590 .map_range = amd_iommu_map_range, 2619 .map_range = amd_iommu_map_range,
2591 .unmap_range = amd_iommu_unmap_range, 2620 .unmap_range = amd_iommu_unmap_range,
2592 .iova_to_phys = amd_iommu_iova_to_phys, 2621 .iova_to_phys = amd_iommu_iova_to_phys,