On Tue, Jan 17, 2023 at 09:02:01AM +0000, Ni, Ray wrote:
> + Gerd.
> 
> > -----Original Message-----
> > From: Liu, Zhiguang <zhiguang....@intel.com>
> > Sent: Wednesday, January 4, 2023 1:41 PM
> > To: devel@edk2.groups.io
> > Cc: Liu, Zhiguang <zhiguang....@intel.com>; Ni, Ray <ray...@intel.com>; 
> > Kumar, Rahul R <rahul.r.ku...@intel.com>; Dong,
> > Eric <eric.d...@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/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to