Re: [PATCH RFC 02/11] x86/mm: Factor out phys_pgd_init()

From: Brendan Jackman
Date: Mon Mar 17 2025 - 12:24:59 EST


On Thu, Mar 13, 2025 at 10:14:33PM +0000, Yosry Ahmed wrote:
> > @@ -771,15 +770,29 @@ __kernel_physical_mapping_init(unsigned long paddr_start,
> > (pud_t *) p4d, init);
> >
> > spin_unlock(&init_mm.page_table_lock);
> > - pgd_changed = true;
> > + *pgd_changed = true;
> > }
> >
> > - if (pgd_changed)
> > - sync_global_pgds(vaddr_start, vaddr_end - 1);
> > -
> > return paddr_last;
> > }
> >
> > +static unsigned long __meminit
> > +__kernel_physical_mapping_init(unsigned long paddr_start,
> > + unsigned long paddr_end,
> > + unsigned long page_size_mask,
> > + pgprot_t prot, bool init)
> > +{
> > + bool pgd_changed;
> > + unsigned long paddr_last;
> > +
> > + paddr_last = phys_pgd_init(init_mm.pgd, paddr_start, paddr_end, page_size_mask,
> > + prot, init, &pgd_changed);
> > + if (pgd_changed)
> > + sync_global_pgds((unsigned long)__va(paddr_start),
> > + (unsigned long)__va(paddr_end) - 1);
>
> This patch keeps the sync_global_pgds() in
> __kernel_physical_mapping_init(), then a following patch adds it back in
> phys_pgd_init() (but still leaves it here).
>
> Should we just leave sync_global_pgds() in phys_pgd_init() and eliminate
> the pgd_changed argument?

Oops, thanks. IIUC we only need the sync_global_pgds() call in
__kernel_physical_mapping_init(). We don't want to call it a second
time just because we mirrored changes into the ASI PGD.