Commit 5b8a9a04 authored by Joerg Roedel's avatar Joerg Roedel

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: default avatarJoerg Roedel <jroedel@suse.de>
Tested-by: default avatarQian Cai <cai@lca.pw>
Link: https://lore.kernel.org/r/20200504125413.16798-3-joro@8bytes.orgSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent eb791aa7
...@@ -1489,8 +1489,19 @@ static u64 *alloc_pte(struct protection_domain *domain, ...@@ -1489,8 +1489,19 @@ static u64 *alloc_pte(struct protection_domain *domain,
amd_iommu_domain_get_pgtable(domain, &pgtable); amd_iommu_domain_get_pgtable(domain, &pgtable);
while (address > PM_LEVEL_SIZE(pgtable.mode)) { while (address > PM_LEVEL_SIZE(pgtable.mode)) {
*updated = increase_address_space(domain, address, gfp) || *updated; bool upd = increase_address_space(domain, address, gfp);
/* Read new values to check if update was successful */
amd_iommu_domain_get_pgtable(domain, &pgtable); amd_iommu_domain_get_pgtable(domain, &pgtable);
/*
* Return an error if there is no memory to update the
* page-table.
*/
if (!upd && (address > PM_LEVEL_SIZE(pgtable.mode)))
return NULL;
*updated = *updated || upd;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment