|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 3/3] xen/arm: p2m: support level 1 puts if the superpage cannot be split
If the P2M pool is exhausted while trying to split a level 1
superpage, p2m_put_page() does not perform put for that level. This
causes the references not to be dropped and the pages to never be
freed, meaning destroying the owner never completes in that case.
Add support for level 1 puts by reusing the original
p2m_put_l2_superpage(), making it generic for superpage mappings.
Signed-off-by: Gabriel Quintáns Souto <gabi.qs.mail@xxxxxxxxx>
---
xen/arch/arm/mmu/p2m.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c
index e7a27db..4da5c58 100644
--- a/xen/arch/arm/mmu/p2m.c
+++ b/xen/arch/arm/mmu/p2m.c
@@ -768,11 +768,16 @@ static void p2m_put_l3_page(mfn_t mfn, p2m_type_t type)
page_set_xenheap_gfn(mfn_to_page(mfn), INVALID_GFN);
}
-/* Put any references on the superpage referenced by mfn. */
-static void p2m_put_l2_superpage(mfn_t mfn, p2m_type_t type)
+/*
+ * Put any references on the superpage referenced by mfn. For a level 1
+ * superpage this can't be preempted, so relinquish_p2m_mapping() shatters
+ * it first when it can.
+ */
+static void p2m_put_superpage(mfn_t mfn, p2m_type_t type,
+ unsigned int level)
{
struct page_info *pg;
- unsigned int i;
+ unsigned long i;
/*
* TODO: Handle other p2m types, but be aware that any changes to handle
@@ -786,7 +791,7 @@ static void p2m_put_l2_superpage(mfn_t mfn, p2m_type_t type)
pg = mfn_to_page(mfn);
- for ( i = 0; i < XEN_PT_LPAE_ENTRIES; i++, pg++ )
+ for ( i = 0; i < 1UL << XEN_PT_LEVEL_ORDER(level); i++, pg++ )
p2m_put_foreign_page(pg);
}
@@ -797,15 +802,8 @@ static void p2m_put_page(const lpae_t pte, unsigned int
level)
ASSERT(p2m_is_valid(pte));
- /*
- * TODO: Currently we don't handle level 1 super-page, Xen is not
- * preemptible and therefore some work is needed to handle such
- * superpages, for which at some point Xen might end up freeing memory
- * and therefore for such a big mapping it could end up in a very long
- * operation.
- */
- if ( level == 2 )
- return p2m_put_l2_superpage(mfn, pte.p2m.type);
+ if ( level == 1 || level == 2 )
+ return p2m_put_superpage(mfn, pte.p2m.type, level);
else if ( level == 3 )
return p2m_put_l3_page(mfn, pte.p2m.type);
}
@@ -1633,6 +1631,8 @@ int relinquish_p2m_mapping(struct domain *d)
/*
* Shattering the foreign superpage needs a page from the P2M
* pool. If none is left, remove the whole superpage at once.
+ * This can't be preempted, but should only happen when the
+ * pool is exhausted.
*/
order = XEN_PT_LEVEL_ORDER(1);
rc = __p2m_set_entry(p2m, start, order, INVALID_MFN,
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |