From d7bf1b8ea2756b6160d41bf377a85365dbd6f8f6 Mon Sep 17 00:00:00 2001 From: Roger Pau Monne Date: Mon, 27 Jul 2026 16:36:15 +0200 Subject: [PATCH] x86/mm: limit deferred TLB flushing to PV domain support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current logic on x86 will mark all domain owned pages as needing a TLB flush before being re-used. However such TLB flushing is only strictly needed when the pages might have been mapped by a PV domain, as those can keep a reference to the page in the TLB after it has been freed. Limit the flushing to builds with PV domain support, as tracking whether a page might have been mapped by a PV domain is not trivial (and possibly not worth the extra logic). Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- xen/common/page_alloc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 62ac89b824..fe150eccd7 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1538,8 +1538,13 @@ static bool mark_page_free(struct page_info *pg, mfn_t mfn) BUG(); } - /* If a page has no owner it will need no safety TLB flush. */ - pg->u.free.need_tlbflush = (page_get_owner(pg) != NULL); + /* + * If a page has no owner and there's no PV domain support it does not need + * a safety TLB flush. PV domains are the only domain types that can keep + * stale entries on the TLB, as they have (limited) control over the host + * MMU and when flushes are performed. + */ + pg->u.free.need_tlbflush = IS_ENABLED(CONFIG_PV) && page_get_owner(pg); if ( pg->u.free.need_tlbflush ) page_set_tlbflush_timestamp(pg);