@@ -1446,15 +1446,18 @@ static bool increase_address_space(struct protection_domain *domain,
1446
1446
{
1447
1447
struct domain_pgtable pgtable ;
1448
1448
unsigned long flags ;
1449
- bool ret = false ;
1449
+ bool ret = true ;
1450
1450
u64 * pte , root ;
1451
1451
1452
1452
spin_lock_irqsave (& domain -> lock , flags );
1453
1453
1454
1454
amd_iommu_domain_get_pgtable (domain , & pgtable );
1455
1455
1456
- if (address <= PM_LEVEL_SIZE (pgtable .mode ) ||
1457
- WARN_ON_ONCE (pgtable .mode == PAGE_MODE_6_LEVEL ))
1456
+ if (address <= PM_LEVEL_SIZE (pgtable .mode ))
1457
+ goto out ;
1458
+
1459
+ ret = false;
1460
+ if (WARN_ON_ONCE (pgtable .mode == PAGE_MODE_6_LEVEL ))
1458
1461
goto out ;
1459
1462
1460
1463
pte = (void * )get_zeroed_page (gfp );
@@ -1499,19 +1502,15 @@ static u64 *alloc_pte(struct protection_domain *domain,
1499
1502
amd_iommu_domain_get_pgtable (domain , & pgtable );
1500
1503
1501
1504
while (address > PM_LEVEL_SIZE (pgtable .mode )) {
1502
- bool upd = increase_address_space (domain , address , gfp );
1503
-
1504
- /* Read new values to check if update was successful */
1505
- amd_iommu_domain_get_pgtable (domain , & pgtable );
1506
-
1507
1505
/*
1508
1506
* Return an error if there is no memory to update the
1509
1507
* page-table.
1510
1508
*/
1511
- if (!upd && ( address > PM_LEVEL_SIZE ( pgtable . mode ) ))
1509
+ if (!increase_address_space ( domain , address , gfp ))
1512
1510
return NULL ;
1513
1511
1514
- * updated = * updated || upd ;
1512
+ /* Read new values to check if update was successful */
1513
+ amd_iommu_domain_get_pgtable (domain , & pgtable );
1515
1514
}
1516
1515
1517
1516
@@ -1719,7 +1718,13 @@ static int iommu_map_page(struct protection_domain *dom,
1719
1718
unsigned long flags ;
1720
1719
1721
1720
spin_lock_irqsave (& dom -> lock , flags );
1722
- update_domain (dom );
1721
+ /*
1722
+ * Flush domain TLB(s) and wait for completion. Any Device-Table
1723
+ * Updates and flushing already happened in
1724
+ * increase_address_space().
1725
+ */
1726
+ domain_flush_tlb_pde (dom );
1727
+ domain_flush_complete (dom );
1723
1728
spin_unlock_irqrestore (& dom -> lock , flags );
1724
1729
}
1725
1730
0 commit comments