@@ -138,15 +138,6 @@ static struct protection_domain *to_pdomain(struct iommu_domain *dom)
138138 return container_of (dom , struct protection_domain , domain );
139139}
140140
141- void amd_iommu_domain_get_pgtable (struct protection_domain * domain ,
142- struct domain_pgtable * pgtable )
143- {
144- u64 pt_root = atomic64_read (& domain -> iop .pt_root );
145-
146- pgtable -> root = (u64 * )(pt_root & PAGE_MASK );
147- pgtable -> mode = pt_root & 7 ; /* lowest 3 bits encode pgtable mode */
148- }
149-
150141static struct iommu_dev_data * alloc_dev_data (u16 devid )
151142{
152143 struct iommu_dev_data * dev_data ;
@@ -1483,7 +1474,6 @@ static void clear_dte_entry(u16 devid)
14831474static void do_attach (struct iommu_dev_data * dev_data ,
14841475 struct protection_domain * domain )
14851476{
1486- struct domain_pgtable pgtable ;
14871477 struct amd_iommu * iommu ;
14881478 bool ats ;
14891479
@@ -1499,7 +1489,6 @@ static void do_attach(struct iommu_dev_data *dev_data,
14991489 domain -> dev_cnt += 1 ;
15001490
15011491 /* Update device table */
1502- amd_iommu_domain_get_pgtable (domain , & pgtable );
15031492 set_dte_entry (dev_data -> devid , domain ,
15041493 ats , dev_data -> iommu_v2 );
15051494 clone_aliases (dev_data -> pdev );
@@ -1826,10 +1815,7 @@ void amd_iommu_update_and_flush_device_table(struct protection_domain *domain)
18261815
18271816void amd_iommu_domain_update (struct protection_domain * domain )
18281817{
1829- struct domain_pgtable pgtable ;
1830-
18311818 /* Update device table */
1832- amd_iommu_domain_get_pgtable (domain , & pgtable );
18331819 amd_iommu_update_and_flush_device_table (domain );
18341820
18351821 /* Flush domain TLB(s) and wait for completion */
@@ -2079,12 +2065,10 @@ static int amd_iommu_map(struct iommu_domain *dom, unsigned long iova,
20792065 gfp_t gfp )
20802066{
20812067 struct protection_domain * domain = to_pdomain (dom );
2082- struct domain_pgtable pgtable ;
20832068 int prot = 0 ;
20842069 int ret ;
20852070
2086- amd_iommu_domain_get_pgtable (domain , & pgtable );
2087- if (pgtable .mode == PAGE_MODE_NONE )
2071+ if (domain -> iop .mode == PAGE_MODE_NONE )
20882072 return - EINVAL ;
20892073
20902074 if (iommu_prot & IOMMU_READ )
@@ -2104,10 +2088,8 @@ static size_t amd_iommu_unmap(struct iommu_domain *dom, unsigned long iova,
21042088 struct iommu_iotlb_gather * gather )
21052089{
21062090 struct protection_domain * domain = to_pdomain (dom );
2107- struct domain_pgtable pgtable ;
21082091
2109- amd_iommu_domain_get_pgtable (domain , & pgtable );
2110- if (pgtable .mode == PAGE_MODE_NONE )
2092+ if (domain -> iop .mode == PAGE_MODE_NONE )
21112093 return 0 ;
21122094
21132095 return iommu_unmap_page (domain , iova , page_size );
@@ -2118,11 +2100,9 @@ static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom,
21182100{
21192101 struct protection_domain * domain = to_pdomain (dom );
21202102 unsigned long offset_mask , pte_pgsize ;
2121- struct domain_pgtable pgtable ;
21222103 u64 * pte , __pte ;
21232104
2124- amd_iommu_domain_get_pgtable (domain , & pgtable );
2125- if (pgtable .mode == PAGE_MODE_NONE )
2105+ if (domain -> iop .mode == PAGE_MODE_NONE )
21262106 return iova ;
21272107
21282108 pte = fetch_pte (domain , iova , & pte_pgsize );
@@ -2492,11 +2472,9 @@ static u64 *__get_gcr3_pte(u64 *root, int level, u32 pasid, bool alloc)
24922472static int __set_gcr3 (struct protection_domain * domain , u32 pasid ,
24932473 unsigned long cr3 )
24942474{
2495- struct domain_pgtable pgtable ;
24962475 u64 * pte ;
24972476
2498- amd_iommu_domain_get_pgtable (domain , & pgtable );
2499- if (pgtable .mode != PAGE_MODE_NONE )
2477+ if (domain -> iop .mode != PAGE_MODE_NONE )
25002478 return - EINVAL ;
25012479
25022480 pte = __get_gcr3_pte (domain -> gcr3_tbl , domain -> glx , pasid , true);
@@ -2510,11 +2488,9 @@ static int __set_gcr3(struct protection_domain *domain, u32 pasid,
25102488
25112489static int __clear_gcr3 (struct protection_domain * domain , u32 pasid )
25122490{
2513- struct domain_pgtable pgtable ;
25142491 u64 * pte ;
25152492
2516- amd_iommu_domain_get_pgtable (domain , & pgtable );
2517- if (pgtable .mode != PAGE_MODE_NONE )
2493+ if (domain -> iop .mode != PAGE_MODE_NONE )
25182494 return - EINVAL ;
25192495
25202496 pte = __get_gcr3_pte (domain -> gcr3_tbl , domain -> glx , pasid , false);
0 commit comments