Skip to content

Commit 5043d7e

Browse files
committed
x86/xen: Fix Xen PV guest boot
A recent patch moving the call of sparse_init() to common mm code broke booting as a Xen PV guest. Reason is that the Xen PV specific boot code relied on struct page area being accessible rather early, but this changed by the move of the call of sparse_init(). Fortunately the fix is rather easy: there is a static branch available indicating whether struct page contents are usable by Xen. This static branch just needs to be tested in some places for avoiding the access of struct page. Fixes: 4267739 ("arch, mm: consolidate initialization of SPARSE memory model") Signed-off-by: Juergen Gross <jgross@suse.com> Message-ID: <20260214135035.119357-1-jgross@suse.com>
1 parent c307b6d commit 5043d7e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

arch/x86/xen/mmu_pv.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,9 @@ static pgd_t *xen_get_user_pgd(pgd_t *pgd)
509509
unsigned offset = pgd - pgd_page;
510510
pgd_t *user_ptr = NULL;
511511

512+
if (!static_branch_likely(&xen_struct_pages_ready))
513+
return NULL;
514+
512515
if (offset < pgd_index(USER_LIMIT)) {
513516
struct page *page = virt_to_page(pgd_page);
514517
user_ptr = (pgd_t *)page->private;
@@ -1098,7 +1101,8 @@ static void __init xen_cleanmfnmap_free_pgtbl(void *pgtbl, bool unpin)
10981101

10991102
if (unpin)
11001103
pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, PFN_DOWN(pa));
1101-
ClearPagePinned(virt_to_page(__va(pa)));
1104+
if (static_branch_likely(&xen_struct_pages_ready))
1105+
ClearPagePinned(virt_to_page(__va(pa)));
11021106
xen_free_ro_pages(pa, PAGE_SIZE);
11031107
}
11041108

0 commit comments

Comments
 (0)