From: "Ni, Ray" <ray.ni@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"Guenzel, Robert" <robert.guenzel@intel.com>
Subject: Re: [PATCH] UefiCpuPkg: Bug fix in 5LPage handling
Date: Wed, 16 Nov 2022 00:57:13 +0000 [thread overview]
Message-ID: <MWHPR11MB163138C892B9BFA33B92FE348C079@MWHPR11MB1631.namprd11.prod.outlook.com> (raw)
In-Reply-To: <SN6PR11MB2832842C203EEF0F55DA6D7697019@SN6PR11MB2832.namprd11.prod.outlook.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guenzel, Robert
> Sent: Thursday, November 10, 2022 9:51 PM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [PATCH] UefiCpuPkg: Bug fix in 5LPage handling
>
> When build in DEBUG, the code asserts that 5LPage support is there
> when the physical address width is larger than 48.
> In a RELEASE build it will just force LA57 to 1 in CR4
> even if CPUID(7).ECX[16] says it is not supported.
>
> The hang (in the ASSERT) in DEBUG is not warranted as there are
> legal configurations with CPUID(7).ECX[16](==LA57)=0
> and with a physical address width of larger than 48 (like 52).
>
> This is also supported by this code:
> https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c#L221
> There (as long as physical address width is smaller or equal to 52)
> any address width above 48 will be reduced to 48 and the
> system can and will work without 5LPaging.
>
> The forced setting of LA57 in CR4 (in the absence of LA57 in CPUID(7).ECX)
> is a spec violation and should not happen.
>
> Hence the proposed fix
> a) removes the assert.
> b) only returns TRUE from Is5LevelPagingNeeded if 5LPaging is actually
> supported by HW.
>
> Signed-off-by: Robert Guenzel mailto:robert.guenzel@intel.com
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> index 6587212f4e..f8b1ac31f1 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> @@ -104,8 +104,8 @@ Is5LevelPagingNeeded (
> ExtFeatureEcx.Bits.FiveLevelPage
> ));
>
> - if (VirPhyAddressSize.Bits.PhysicalAddressBits > 4 * 9 + 12) {
> - ASSERT (ExtFeatureEcx.Bits.FiveLevelPage == 1);
> + if ((VirPhyAddressSize.Bits.PhysicalAddressBits > 4 * 9 + 12) &&
> + (ExtFeatureEcx.Bits.FiveLevelPage == 1)) {
> return TRUE;
> } else {
> return FALSE;
> --
> 2.34.1
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
>
>
>
>
>
next prev parent reply other threads:[~2022-11-16 0:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 13:50 [PATCH] UefiCpuPkg: Bug fix in 5LPage handling Guenzel, Robert
2022-11-15 19:08 ` Michael D Kinney
2022-11-16 0:57 ` Ni, Ray [this message]
2022-11-30 0:47 ` [edk2-devel] " Wu, Jiaxin
2022-12-13 8:40 ` Zeng, Star
2022-12-13 9:04 ` Ni, Ray
2022-12-13 11:14 ` Zeng, Star
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-list 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=MWHPR11MB163138C892B9BFA33B92FE348C079@MWHPR11MB1631.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/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