> On 7/13/26 06:55, Yeoreum Yun wrote:
> > @@ -134,11 +129,12 @@ static inline void
> > resume_init_first_level_page_table(pgd_t *pg_dir)
> > {
> > #ifdef CONFIG_X86_PAE
> > int i;
> > + pud_t *pud = pud_offset(p4d_offset(pg_dir, 0), 0);
> >
> > /* Init entries of the first-level page table to the zero page */
> > for (i = 0; i < PTRS_PER_PGD; i++)
> > - set_pgd(pg_dir + i,
> > - __pgd(__pa(empty_zero_page) | _PAGE_PRESENT));
> > + set_pud(pud + i,
> > + __pud(__pa(empty_zero_page) | _PAGE_PRESENT));
> > #endif
> > }
>
> If this is the way forward, it's going to require the retraining of some
> awfully old brain cells.
>
> It also doesn't really read correctly. Loop over each PGD entry:
>
> for (i = 0; i < PTRS_PER_PGD; i++)
>
> ... and set a pud?
>
> set_pud(...)
>
> I'm not sure how I'd ever learn the rules to write this code from
> scratch. Right now, the code says: "The pgd_t is the top level of the
> page tables. I know there are PTRS_PER_PGD of those top level entries
> entries I need to 'zero'."
>
> You don't have to know what is folded, just that you're dealing with the
> top level.
>
> But *this* code says:
>
> 1. The pgd_t is the top level of the page tables. Start there.
> 2. "Walk" down *two* (folded) levels
> 3. Set the third-level (pud) entries to 'zero'
>
> So the code now *has* to know how the folding occurs.
>
> This seems really hard to work with to me.
Actually, This is what the patch series want.
IOW, the "code" need to consider the folded pgtable level and
use a proper APIs.
Might for the clarification, change a PTRS_PER_PGD to PTRS_PER_PUD
seems better. but the using set_pgd() seems much more worse since
second argument type is p4d_t which doesn't exist in the p4d folded case.
IOW, this patch wants to use proper API for the real first page table
level. for example, X86_PAE's pgtable level is 3 so not use pgd friends function
but use a pud to setup first page table entries.
--
Sincerely,
Yeoreum Yun