[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1a7a28d2-5a49-4522-b6e6-a42a14397aa0@gmail.com>
Date: Thu, 23 Oct 2025 00:49:26 +0100
From: Usama Arif <usamaarif642@...il.com>
To: Dave Hansen <dave.hansen@...el.com>, dwmw@...zon.co.uk,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, ardb@...nel.org, hpa@...or.com
Cc: x86@...nel.org, apopple@...dia.com, thuth@...hat.com,
nik.borisov@...e.com, kas@...nel.org, linux-kernel@...r.kernel.org,
linux-efi@...r.kernel.org, kernel-team@...a.com,
Michael van der Westhuizen <rmikey@...a.com>, Tobias Fleig <tfleig@...a.com>
Subject: Re: [PATCH 1/3] x86/boot: Fix page table access in 5-level to 4-level
paging transition
On 23/10/2025 00:16, Dave Hansen 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!
haha yeah its a lot here.
>
> 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?
So we need to mask 2 things here:
- cr3, which is done by read_cr3_pa using CR3_ADDR_MASK/(__sme_clr(PHYSICAL_PAGE_MASK))
as you pointed out.
- pgdp[0] (the deferenced value), i.e. the p4d table pointer (This was previously
*(unsigned long *)__native_read_cr3()). This needs to be masked by PTE_PFN_MASK and
and not PAGE_MASK which was done previously in order to take care of _PAGE_BIT_NOPTISHADOW.
Powered by blists - more mailing lists