[edk2-devel] [PATCH] UefiCpuPkg: Fix SMM code hangs when InitPaging

Gerd Hoffmann kraxel at redhat.com
Tue Jan 17 12:13:59 UTC 2023


On Tue, Jan 17, 2023 at 09:02:01AM +0000, Ni, Ray wrote:
> + Gerd.
> 
> > -----Original Message-----
> > From: Liu, Zhiguang <zhiguang.liu at intel.com>
> > Sent: Wednesday, January 4, 2023 1:41 PM
> > To: devel at edk2.groups.io
> > Cc: Liu, Zhiguang <zhiguang.liu at intel.com>; Ni, Ray <ray.ni at intel.com>; Kumar, Rahul R <rahul.r.kumar at intel.com>; Dong,
> > Eric <eric.dong at intel.com>
> > Subject: [PATCH] UefiCpuPkg: Fix SMM code hangs when InitPaging
> > 
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4246
> > 
> > In function InitPaging, NumberOfPml5Entries is calculated by below code
> > NumberOfPml5Entries = (UINTN)LShiftU64 (1, SizeOfMemorySpace - 48);
> > If the SizeOfMemorySpace is larger than 48, NumberOfPml5Entries will be
> > larger than 1. However, this doesn't make sense if the hardware doesn't
> > support 5 level page table.

> > +    ASSERT (SizeOfMemorySpace <= 52);
> > +
> >      //
> > -    // Calculate the table entries of PML4E and PDPTE.
> > +    // Calculate the table entries of PML5E, PML4E and PDPTE.
> >      //
> >      NumberOfPml5Entries = 1;
> > -    if (SizeOfMemorySpace > 48) {
> > +    if (Enable5LevelPaging && (SizeOfMemorySpace > 48)) {
> >        NumberOfPml5Entries = (UINTN)LShiftU64 (1, SizeOfMemorySpace - 48);
> > -      SizeOfMemorySpace   = 48;
> >      }
> > 
> > +    SizeOfMemorySpace   = SizeOfMemorySpace > 48 ? 48 : SizeOfMemorySpace;

if (SizeOfMemorySpace > 48) {
    if (Enable5LevelPaging) {
         NumberOfPml5Entries = ...
    }
    SizeOfMemorySpace = 48
}

That is a much more readable version.

The only effect I can see is that this avoids creating page tables which
would not be used anyway.

Can you explain where the hangs mentioned in the subject line are coming
from and why the patch fixes them?

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#98672): https://edk2.groups.io/g/devel/message/98672
Mute This Topic: https://groups.io/mt/96045489/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list