From: Dave Hansen <dave.hansen@intel.com>
To: Usama Arif <usamaarif642@gmail.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 v2 1/2] x86/boot: Fix page table access in 5-level to 4-level paging transition
Date: Fri, 31 Oct 2025 08:51:03 -0700 [thread overview]
Message-ID: <a482fd68-ce54-472d-8df1-33d6ac9f6bb5@intel.com> (raw)
In-Reply-To: <20251028105637.769470-2-usamaarif642@gmail.com>
On 10/28/25 03:55, Usama Arif wrote:
> - native_read_cr3_pa(): Uses CR3_ADDR_MASK properly clearing SME encryption
> bit and extracting only the physical address portion.
I guess we can apply these as-is. They do fix a bug.
But I find these descriptions a bit unsatisfying. CR3_ADDR_MASK happens
to work here on 64-bit. Interestingly enough, it wouldn't have been as
good of a fix on PAE paging because it ignores those upper bits instead
of reserving them.
But CR3_ADDR_MASK doesn't "extract... only the physical address
portion". It also extracts reserved bits.
It also doesn't mention the LAM bits. It's not just SME.
This would be better:
- native_read_cr3_pa(): Uses CR3_ADDR_MASK to additionally mask
metadata out of CR3 (like SME or LAM bits). All remaining bits are
real address bits or reserved and must be 0.
> - mask pgd value with PTE_PFN_MASK instead of PAGE_MASK, accounting for
> flags above physical address (_PAGE_BIT_NOPTISHADOW in particular).
This also isn't _quite_ right. The "flags above physical" address are
dynamic. They move because the max physical address (MAXPHYADDR) is
enumerated and changes from CPU to CPU.
It's OK in this case because moving MAXPHYADDR down just changes bits
from address bits to reserved (must be 0).
In a perfect world, we would construct a kexec CR3 with the dynamic
MAXPHYADDR (plus masking out the lower 12 bits). That would be obviously
correct for *all* 32-bit and 64-bit cases and wouldn't even rely on
knowing where the boundary is between ignored and reserved. The approach
in these patches is a fine improvement We don't need to be perfect.
Ideally this second bullet would be:
- mask pgd value with PTE_PFN_MASK instead of PAGE_MASK, accounting for
flags above bit 51 (_PAGE_BIT_NOPTISHADOW in particular). Bits below
51, but above the max physical address are reserved and must be 0.
But it's fine-ish as-is.
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
next prev parent reply other threads:[~2025-10-31 15:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 10:55 [PATCH v2 0/2] x86: Fix kexec " Usama Arif
2025-10-28 10:55 ` [PATCH v2 1/2] x86/boot: Fix page table access in " Usama Arif
2025-10-31 15:51 ` Dave Hansen [this message]
2025-10-28 10:55 ` [PATCH v2 2/2] efi/libstub: " Usama Arif
2025-10-31 14:40 ` Borislav Petkov
2025-10-31 14:43 ` Ard Biesheuvel
2025-10-31 15:33 ` Borislav Petkov
2025-10-28 13:43 ` [PATCH v2 0/2] x86: Fix kexec " Ard Biesheuvel
2025-10-29 20:48 ` Borislav Petkov
2025-10-30 10:23 ` Kiryl Shutsemau
2025-10-31 12:29 ` Borislav Petkov
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=a482fd68-ce54-472d-8df1-33d6ac9f6bb5@intel.com \
--to=dave.hansen@intel.com \
--cc=apopple@nvidia.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--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=usamaarif642@gmail.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
all inboxes | Powered by JetHome®