Commit 6d568ef9 authored by Joerg Roedel's avatar Joerg Roedel

iommu/amd: Allow downgrading page-sizes in alloc_pte()

Before this patch it was not possible the downgrade a
mapping established with page-mode 7 to a mapping using
smaller page-sizes, because the pte_level != level check
prevented that.

Treat page-mode 7 like a non-present mapping and allow to
overwrite it in alloc_pte().
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 69be8852
...@@ -1460,10 +1460,13 @@ static u64 *alloc_pte(struct protection_domain *domain, ...@@ -1460,10 +1460,13 @@ static u64 *alloc_pte(struct protection_domain *domain,
while (level > end_lvl) { while (level > end_lvl) {
u64 __pte, __npte; u64 __pte, __npte;
int pte_level;
__pte = *pte; __pte = *pte;
pte_level = PM_PTE_LEVEL(__pte);
if (!IOMMU_PTE_PRESENT(__pte)) { if (!IOMMU_PTE_PRESENT(__pte) ||
pte_level == PAGE_MODE_7_LEVEL) {
page = (u64 *)get_zeroed_page(gfp); page = (u64 *)get_zeroed_page(gfp);
if (!page) if (!page)
return NULL; return NULL;
...@@ -1475,10 +1478,13 @@ static u64 *alloc_pte(struct protection_domain *domain, ...@@ -1475,10 +1478,13 @@ static u64 *alloc_pte(struct protection_domain *domain,
free_page((unsigned long)page); free_page((unsigned long)page);
continue; continue;
} }
if (pte_level == PAGE_MODE_7_LEVEL)
domain->updated = true;
} }
/* No level skipping support yet */ /* No level skipping support yet */
if (PM_PTE_LEVEL(*pte) != level) if (pte_level != level)
return NULL; return NULL;
level -= 1; level -= 1;
......
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