debuggers.hg
changeset 22872:699f22481479
amd iommu: reduce io page level for hvm guest (2/3)
Clean up amd_iommu_reserve_domain_unity_map function to reduce code
duplication.
Signed-off-by: Wei Wang <wei.wang2@amd.com>
Clean up amd_iommu_reserve_domain_unity_map function to reduce code
duplication.
Signed-off-by: Wei Wang <wei.wang2@amd.com>
author | Wei Wang <wei.wang2@amd.com> |
---|---|
date | Thu Jan 27 16:11:37 2011 +0000 (2011-01-27) |
parents | 969f26450ad5 |
children | 3b00ee057c4a |
files | xen/drivers/passthrough/amd/iommu_map.c |
line diff
1.1 --- a/xen/drivers/passthrough/amd/iommu_map.c Thu Jan 27 16:10:52 2011 +0000 1.2 +++ b/xen/drivers/passthrough/amd/iommu_map.c Thu Jan 27 16:11:37 2011 +0000 1.3 @@ -518,38 +518,26 @@ int amd_iommu_unmap_page(struct domain * 1.4 return 0; 1.5 } 1.6 1.7 -int amd_iommu_reserve_domain_unity_map( 1.8 - struct domain *domain, 1.9 - unsigned long phys_addr, 1.10 - unsigned long size, int iw, int ir) 1.11 +int amd_iommu_reserve_domain_unity_map(struct domain *domain, 1.12 + u64 phys_addr, 1.13 + unsigned long size, int iw, int ir) 1.14 { 1.15 - u64 iommu_l2e; 1.16 unsigned long npages, i; 1.17 - struct hvm_iommu *hd = domain_hvm_iommu(domain); 1.18 + unsigned long gfn; 1.19 + unsigned int flags = !!ir; 1.20 + int rt = 0; 1.21 + 1.22 + if ( iw ) 1.23 + flags |= IOMMUF_writable; 1.24 1.25 npages = region_to_pages(phys_addr, size); 1.26 - 1.27 - spin_lock(&hd->mapping_lock); 1.28 - for ( i = 0; i < npages; ++i ) 1.29 + gfn = phys_addr >> PAGE_SHIFT; 1.30 + for ( i = 0; i < npages; i++ ) 1.31 { 1.32 - iommu_l2e = iommu_l2e_from_pfn( 1.33 - hd->root_table, hd->paging_mode, phys_addr >> PAGE_SHIFT); 1.34 - 1.35 - if ( iommu_l2e == 0 ) 1.36 - { 1.37 - spin_unlock(&hd->mapping_lock); 1.38 - AMD_IOMMU_DEBUG("Invalid IO pagetable entry phys_addr = %lx\n", 1.39 - phys_addr); 1.40 - domain_crash(domain); 1.41 - return -EFAULT; 1.42 - } 1.43 - 1.44 - set_iommu_l1e_present(iommu_l2e, 1.45 - (phys_addr >> PAGE_SHIFT), phys_addr, iw, ir); 1.46 - 1.47 - phys_addr += PAGE_SIZE; 1.48 + rt = amd_iommu_map_page(domain, gfn +i, gfn +i, flags); 1.49 + if ( rt != 0 ) 1.50 + return rt; 1.51 } 1.52 - spin_unlock(&hd->mapping_lock); 1.53 return 0; 1.54 } 1.55