From: Usama Arif <usamaarif642@gmail.com>
To: Dave Hansen <dave.hansen@intel.com>,
dwmw@amazon.co.uk, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, ardb@kernel.org,
hpa@zytor.com
Cc: x86@kernel.org, apopple@nvidia.com, thuth@redhat.com,
nik.borisov@suse.com, kas@kernel.org,
linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
kernel-team@meta.com,
Michael van der Westhuizen <rmikey@meta.com>,
Tobias Fleig <tfleig@meta.com>
Subject: Re: [PATCH 1/3] x86/boot: Fix page table access in 5-level to 4-level paging transition
Date: Thu, 23 Oct 2025 00:49:26 +0100 [thread overview]
Message-ID: <1a7a28d2-5a49-4522-b6e6-a42a14397aa0@gmail.com> (raw)
In-Reply-To: <8283c1b6-1487-49e2-b220-7dbd043a2913@intel.com>
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.
next prev parent reply other threads:[~2025-10-22 23:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 22:06 [PATCH 0/3] x86: Fix kexec 5-level to 4-level paging transition Usama Arif
2025-10-22 22:06 ` [PATCH 1/3] x86/boot: Fix page table access in " Usama Arif
2025-10-22 23:16 ` Dave Hansen
2025-10-22 23:49 ` Usama Arif [this message]
2025-10-25 21:50 ` H. Peter Anvin
2025-10-23 17:43 ` kernel test robot
2025-10-24 8:07 ` kernel test robot
2025-10-22 22:06 ` [PATCH 2/3] efi/libstub: " Usama Arif
2025-10-23 14:13 ` Ard Biesheuvel
2025-10-23 14:28 ` Kiryl Shutsemau
2025-10-22 22:06 ` [PATCH 3/3] x86/mm: Move _PAGE_BIT_NOPTISHADOW from bit 58 to bit 9 Usama Arif
2025-10-22 23:35 ` Dave Hansen
2025-10-22 23:58 ` Usama Arif
2025-10-23 14:05 ` Dave Hansen
2025-10-23 14:24 ` Kiryl Shutsemau
2025-10-23 15:12 ` Dave Hansen
2025-10-23 15:25 ` Kiryl Shutsemau
2025-10-23 22:15 ` Usama Arif
2025-10-22 22:25 ` [PATCH 0/3] x86: Fix kexec 5-level to 4-level paging transition Usama Arif
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a7a28d2-5a49-4522-b6e6-a42a14397aa0@gmail.com \
--to=usamaarif642@gmail.com \
--cc=apopple@nvidia.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw@amazon.co.uk \
--cc=hpa@zytor.com \
--cc=kas@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nik.borisov@suse.com \
--cc=rmikey@meta.com \
--cc=tfleig@meta.com \
--cc=tglx@linutronix.de \
--cc=thuth@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox