[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v8 01/65] x86/mm: mask _PAGE_AVAIL0 out of populate_perdomain_mapping()'s flags



In the per-domain area, _PAGE_AVAIL0 in an L1 entry marks a page owned
by the area itself: destroy_perdomain_mapping() frees the page of any
present entry carrying it.  populate_perdomain_mapping() maps pages
owned by its caller, with the page-table flags the caller passes.  If
those flags included _PAGE_AVAIL0, tearing the mapping down would free
the caller's page, and the caller would then free it a second time.

Nothing prevents a caller from passing it.  Assert that the bit is
clear, and mask it out, so that release builds install an ordinary
mapping of the caller's page: dropping a bit that does not belong there
is preferable to crashing.

Fixes: 9f9e2532c20d ("x86/mm: introduce populate_perdomain_mapping()")
Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
Changes in v8:
- New in this version.
---
 xen/arch/x86/mm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index dee06828b3..15f1825bc4 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -6381,6 +6381,10 @@ void populate_perdomain_mapping(const struct vcpu *v, 
unsigned long va,
     ASSERT(!nr || !l3_table_offset(va ^ (va + nr * PAGE_SIZE - 1)));
     ASSERT(local_irq_is_enabled());
 
+    /* Area-owned pages are installed by create_perdomain_mapping() only. */
+    ASSERT(!(flags & _PAGE_AVAIL0));
+    flags &= ~_PAGE_AVAIL0;
+
     if ( !nr )
         return;
 
-- 
2.56.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.