Skip to content

Commit 5b8a9a0

Browse files
committed
iommu/amd: Do not loop forever when trying to increase address space
When increase_address_space() fails to allocate memory, alloc_pte() will call it again until it succeeds. Do not loop forever while trying to increase the address space and just return an error instead. Signed-off-by: Joerg Roedel <[email protected]> Tested-by: Qian Cai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent eb791aa commit 5b8a9a0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,8 +1489,19 @@ static u64 *alloc_pte(struct protection_domain *domain,
14891489
amd_iommu_domain_get_pgtable(domain, &pgtable);
14901490

14911491
while (address > PM_LEVEL_SIZE(pgtable.mode)) {
1492-
*updated = increase_address_space(domain, address, gfp) || *updated;
1492+
bool upd = increase_address_space(domain, address, gfp);
1493+
1494+
/* Read new values to check if update was successful */
14931495
amd_iommu_domain_get_pgtable(domain, &pgtable);
1496+
1497+
/*
1498+
* Return an error if there is no memory to update the
1499+
* page-table.
1500+
*/
1501+
if (!upd && (address > PM_LEVEL_SIZE(pgtable.mode)))
1502+
return NULL;
1503+
1504+
*updated = *updated || upd;
14941505
}
14951506

14961507

0 commit comments

Comments
 (0)