Re: [PATCH 1/3] x86/boot: Fix page table access in 5-level to 4-level paging transition
From: H. Peter Anvin
Date: Sat Oct 25 2025 - 17:51:05 EST
On October 22, 2025 4:16:34 PM PDT, Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
>On 10/22/25 15:06, Usama Arif wrote:
>> + pgdp = (pgd_t *)read_cr3_pa();
>> + new_cr3 = (u64 *)(pgd_val(pgdp[0]) & PTE_PFN_MASK);
>> + memcpy(trampoline_32bit, new_cr3, PAGE_SIZE);
>
>Heh, somebody like casting, I see!
>
>But seriously, read_cr3_pa() should be returning a physical address. No?
>Today it does:
>
>static inline unsigned long read_cr3_pa(void)
>{
> return __read_cr3() & CR3_ADDR_MASK;
>}
>
>So shouldn't CR3_ADDR_MASK be masking out any naughty non-address bits?
>Shouldn't we fix read_cr3_pa() and not do this in its caller?
Ah, the times when one can wish for C++.
Too bad they still haven't figured out tagged initializers.