From: Roger Pau Monne Date: Wed, 27 Nov 2024 09:55:12 +0000 (+0100) Subject: x86/mm: introduce helper to detect per-domain L1 entries that need freeing X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b5173c5aa0ad672c44869d6e1392b58482113a72;p=people%2Froyger%2Fxen.git x86/mm: introduce helper to detect per-domain L1 entries that need freeing L1 present entries that require the underlying page to be freed have the _PAGE_AVAIL0 bit set, introduce a helper to unify the checking logic into a single place. No functional change intended. Signed-off-by: Roger Pau Monné --- diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index fa21903eb2..3d5dd22b6c 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -6294,6 +6294,12 @@ void __iomem *__init ioremap_wc(paddr_t pa, size_t len) return (void __force __iomem *)(va + offs); } +static bool perdomain_l1e_needs_freeing(l1_pgentry_t l1e) +{ + return (l1e_get_flags(l1e) & (_PAGE_PRESENT | _PAGE_AVAIL0)) == + (_PAGE_PRESENT | _PAGE_AVAIL0); +} + int create_perdomain_mapping(struct domain *d, unsigned long va, unsigned int nr, l1_pgentry_t **pl1tab, struct page_info **ppg) @@ -6446,9 +6452,7 @@ void destroy_perdomain_mapping(struct domain *d, unsigned long va, for ( ; nr && i < L1_PAGETABLE_ENTRIES; --nr, ++i ) { - if ( (l1e_get_flags(l1tab[i]) & - (_PAGE_PRESENT | _PAGE_AVAIL0)) == - (_PAGE_PRESENT | _PAGE_AVAIL0) ) + if ( perdomain_l1e_needs_freeing(l1tab[i]) ) free_domheap_page(l1e_get_page(l1tab[i])); l1tab[i] = l1e_empty(); } @@ -6498,9 +6502,7 @@ void free_perdomain_mappings(struct domain *d) unsigned int k; for ( k = 0; k < L1_PAGETABLE_ENTRIES; ++k ) - if ( (l1e_get_flags(l1tab[k]) & - (_PAGE_PRESENT | _PAGE_AVAIL0)) == - (_PAGE_PRESENT | _PAGE_AVAIL0) ) + if ( perdomain_l1e_needs_freeing(l1tab[k]) ) free_domheap_page(l1e_get_page(l1tab[k])); unmap_domain_page(l1tab);