From: "Gabriel Quintáns Souto" <gabi.qs.mail@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: "Luca Fancellu" <luca.fancellu@arm.com>,
"Gabriel Quintáns Souto" <gabi.qs.mail@gmail.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>,
"Bertrand Marquis" <bertrand.marquis@arm.com>,
"Michal Orzel" <michal.orzel@amd.com>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>
Subject: [PATCH 3/3] xen/arm: p2m: support level 1 puts if the superpage cannot be split
Date: Mon, 30 Nov 2026 17:43:24 +0100 [thread overview]
Message-ID: <20261130164324.47726-4-gabi.qs.mail@gmail.com> (raw)
In-Reply-To: <20261130164324.47726-1-gabi.qs.mail@gmail.com>
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@gmail.com>
---
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
prev parent reply other threads:[~2026-11-30 16:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 16:43 [PATCH 0/3] xen/arm: p2m: free 1GB static shared memory on domain destroy Gabriel Quintáns Souto
2026-11-30 16:43 ` [PATCH 1/3] xen/arm: p2m: add __p2m_free_entry() with a put argument Gabriel Quintáns Souto
2026-11-30 16:43 ` [PATCH 2/3] xen/arm: p2m: split level 1 foreign superpages for preemption Gabriel Quintáns Souto
2026-12-02 10:06 ` Grall, Julien
2026-12-02 11:08 ` Gabriel Quintáns Souto
2026-11-30 16:43 ` Gabriel Quintáns Souto [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130164324.47726-4-gabi.qs.mail@gmail.com \
--to=gabi.qs.mail@gmail.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=julien@xen.org \
--cc=luca.fancellu@arm.com \
--cc=michal.orzel@amd.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.