<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Calibri",sans-serif;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="#954F72">
<div class="WordSection1">
<p class="MsoPlainText">Hi Laszlo, Bret, Ray,<o:p></o:p></p>
<p class="MsoPlainText">Thank you for the review comments.<o:p></o:p></p>
<p class="MsoPlainText">I have updated the patches.<o:p></o:p></p>
<p class="MsoPlainText"><a href="https://edk2.groups.io/g/devel/message/67025?p=,,,20,0,0,0::relevance,,posterid%3A2558558,20,2,0,78044934">https://edk2.groups.io/g/devel/message/67025?p=,,,20,0,0,0::relevance,,posterid%3A2558558,20,2,0,78044934</a><o:p></o:p></p>
<p class="MsoPlainText"><a href="https://edk2.groups.io/g/devel/message/67027?p=,,,20,0,0,0::relevance,,posterid%3A2558558,20,2,0,78044936">https://edk2.groups.io/g/devel/message/67027?p=,,,20,0,0,0::relevance,,posterid%3A2558558,20,2,0,78044936</a><o:p></o:p></p>
<p class="MsoPlainText"><a href="https://edk2.groups.io/g/devel/message/67026?p=,,,20,0,0,0::relevance,,posterid%3A2558558,20,2,0,78044935">https://edk2.groups.io/g/devel/message/67026?p=,,,20,0,0,0::relevance,,posterid%3A2558558,20,2,0,78044935</a><o:p></o:p></p>
<p class="MsoNormal">I refine the coding style and update the comment / commit message.<o:p></o:p></p>
<p class="MsoPlainText">Could you help to review and merge the patch again?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">There is some description of the issue and its background.<o:p></o:p></p>
<p class="MsoNormal">    If mInternalCr3 is non zero, it will use the page table from mInternalCr3.<o:p></o:p></p>
<p class="MsoNormal">    And it will use mInternalIs5LevelPaging to reflect the paging type.<o:p></o:p></p>
<p class="MsoNormal">    If mInternalCr3 is zero, it will use the page table from CR3, and reflect<o:p></o:p></p>
<p class="MsoNormal">     the paging type by CR4 LA57 bit.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    This patch is a bug fix when enable CET feature with 5 level paging.<o:p></o:p></p>
<p class="MsoNormal">    The page table of SMM shadows shack memory is generated in PiCpuSmmEntry().<o:p></o:p></p>
<p class="MsoNormal">    This page table is not set to CR3 in PiCpuSmmEntry(), it is only for<o:p></o:p></p>
<p class="MsoNormal">     SMI entry. When CET feature is enabled, we need to set some attributes for<o:p></o:p></p>
<p class="MsoNormal">     SMM shadows shack memory in PiCpuSmmEntry().<o:p></o:p></p>
<p class="MsoNormal">    We set this page table to mInternalCr3 for update the memory attribute.<o:p></o:p></p>
<p class="MsoNormal">    The CR4 LA57 bit does not reflect the paging type of mInternalCr3,<o:p></o:p></p>
<p class="MsoNormal">     so we need to use a virable (mInternalIs5LevelPaging) to reflect if<o:p></o:p></p>
<p class="MsoNormal">    mInternalCr3 is 5 level paging or 4 level paging.<o:p></o:p></p>
<p class="MsoNormal">    We also use the same function to update the memory attribue with the<o:p></o:p></p>
<p class="MsoNormal">     page table in CR3, use CR4 LA57 bit to reflect the paging type of CR3.<o:p></o:p></p>
<p class="MsoNormal">    So we need to use GetPageTableBase() and Is5LevelPageTableBase() to return<o:p></o:p></p>
<p class="MsoNormal">     the page table and its paging type for GetPageTableEntry() when set the<o:p></o:p></p>
<p class="MsoNormal">     memory attribute.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">These patches are only used to fix the bug in current code. Not feature enabling.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you.<o:p></o:p></p>
<p class="MsoNormal">BR<o:p></o:p></p>
<p class="MsoNormal">Sheng Wei<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Bret Barkelew <Bret.Barkelew@microsoft.com> <br>
<b>Sent:</b> 2020<span lang="ZH-CN" style="font-family:宋体">年</span>11<span lang="ZH-CN" style="font-family:宋体">月</span>3<span lang="ZH-CN" style="font-family:宋体">日</span> 2:32<br>
<b>To:</b> devel@edk2.groups.io; lersek@redhat.com; Sheng, W <w.sheng@intel.com><br>
<b>Cc:</b> Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>; Yao, Jiewen <jiewen.yao@intel.com><br>
<b>Subject:</b> RE: [EXTERNAL] Re: [edk2-devel] [PATCH v3 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Return level paging type for Internal CR3<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I second the request for explanation.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- Bret <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From: </b><a href="mailto:lersek=redhat.com@groups.io">Laszlo Ersek via groups.io</a><br>
<b>Sent: </b>Monday, November 2, 2020 10:05 AM<br>
<b>To: </b><a href="mailto:w.sheng@intel.com">Sheng Wei</a>; <a href="mailto:devel@edk2.groups.io">
devel@edk2.groups.io</a><br>
<b>Cc: </b><a href="mailto:eric.dong@intel.com">Dong, Eric</a>; <a href="mailto:ray.ni@intel.com">
Ni, Ray</a>; <a href="mailto:rahul1.kumar@intel.com">Rahul Kumar</a>; <a href="mailto:jiewen.yao@intel.com">
Yao, Jiewen</a><br>
<b>Subject: </b>[EXTERNAL] Re: [edk2-devel] [PATCH v3 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Return level paging type for Internal CR3<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">On 11/02/20 05:53, Sheng Wei wrote:<br>
> When the functions called from entrypoint the page table is<br>
> set to mInternalCr3, mInternalIs5LevelPaging reflects<br>
> the page table type pointed by mInternalCr3.<br>
> <br>
> REF: <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3015&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C633ad8bea21243a5479c08d87f59df4e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637399371257436398%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=J5khqRr2cyZ%2FFpOXfX4V3juer6n4wvDxTRiQos%2BGJww%3D&amp;reserved=0">
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3015&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C633ad8bea21243a5479c08d87f59df4e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637399371257436398%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=J5khqRr2cyZ%2FFpOXfX4V3juer6n4wvDxTRiQos%2BGJww%3D&amp;reserved=0</a><br>
> <br>
> Change-Id: I9e44c6385a05930850f5ba60d10ed3e391b628bb<br>
<br>
(1) None of the patches should contain such a "Change-Id" line; they are<br>
meaningless for upstream edk2.<br>
<br>
They can be removed by the maintainer just before merging, of course.<br>
<br>
<br>
(2) However, I still have absolutely no idea what the problem is.<br>
<br>
Ray provided some great feedback here:<br>
<br>
<a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F66617&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C633ad8bea21243a5479c08d87f59df4e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637399371257436398%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=1jszRyYlHbQY5Kl%2F1uDuILrUFyIqFqbGbGmR2KDx5%2BE%3D&amp;reserved=0">https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F66617&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C633ad8bea21243a5479c08d87f59df4e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637399371257436398%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=1jszRyYlHbQY5Kl%2F1uDuILrUFyIqFqbGbGmR2KDx5%2BE%3D&amp;reserved=0</a><br>
<br>
In particular:<br>
<br>
    Better to explain the case when the functions called from entrypoint<br>
    the page table is set to mInternalCr3, gSmmFeatureEnable5LevelPaging<br>
    reflects the page table type pointed by mInternalCr3.<br>
<br>
And this has not been *explained*.<br>
<br>
The commit message should include a reminder *why* we sometimes use<br>
"mInternalCr3" (i.e., when it is nonzero), and why we use the CR3<br>
register in other cases. This reminder is not related to the change in<br>
this patch, it should re-state the *original* use case for "mInternalCr3".<br>
<br>
And then in the next paragraph, the commit message should explain that,<br>
*IF* we use "mInternalCr3", rather than CR3, *then* accessing CR4 for<br>
5-level paging is wrong -- because in that case, we should save the<br>
5-level paging status similarly (I guess?) to how we save "mInternalCr3".<br>
<br>
So, on the surface, the change seems to make sense, but without knowing<br>
why we use "mInternalCr3" in the first place, I find it difficult to<br>
reason about this change.<br>
<br>
...<br>
<br>
- According to git-blame, "mInternalCr3" comes from edk2 commit<br>
3eb69b081c68 ("UefiCpuPkg/PiSmmCpu: Add Shadow Stack Support for X86<br>
SMM.", 2019-02-28), and it is related to<br>
<<a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D1521&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C633ad8bea21243a5479c08d87f59df4e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637399371257436398%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=0SJTtV%2BOacJuIIrwErqO1z3HVQY3MakyWsyGRwSPOMc%3D&amp;reserved=0">https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D1521&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C633ad8bea21243a5479c08d87f59df4e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637399371257436398%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=0SJTtV%2BOacJuIIrwErqO1z3HVQY3MakyWsyGRwSPOMc%3D&amp;reserved=0</a>>.<br>
<br>
- Also according to git-blame, the original "Enable5LevelPaging"<br>
assignment, based on "Cr4.Bits.LA57", comes from commit 4eee0cc7cc0d<br>
("UefiCpuPkg/PiSmmCpu: Enable 5 level paging when CPU supports",<br>
2019-07-12), related to<br>
<<a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D1946&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C633ad8bea21243a5479c08d87f59df4e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637399371257436398%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=gbfshsEySndGIWKsCkbs%2F0%2BV2tA4bPflmH0Y3xcsEVI%3D&amp;reserved=0">https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D1946&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C633ad8bea21243a5479c08d87f59df4e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637399371257436398%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=gbfshsEySndGIWKsCkbs%2F0%2BV2tA4bPflmH0Y3xcsEVI%3D&amp;reserved=0</a>>.<br>
<br>
Commit 3eb69b081c68 (the "CET ShadowStack" feature) *precedes* commit<br>
4eee0cc7cc0d (the 5-level paging feature) in the git commit history.<br>
<br>
Therefore the bug was introduced commit 4eee0cc7cc0d -- the 5-level<br>
paging enablement did not take CET ShadowStack support in consideration.<br>
<br>
In other words, this patch fixes (or "completes") 5-level paging support<br>
for "CET ShadowStack".<br>
<br>
Is that correct?<br>
<br>
If so, then *WHY* is none of the expressions "CET ShadowStack" and<br>
"5-level paging" present in any of the subject lines? Why are there no<br>
references to commits 3eb69b081c68 and 4eee0cc7cc0d in the commit<br>
messages? Why does Bug 3015 not reference Bug 1521 and Bug 1946?<br>
<br>
After all, if I understand correctly, this patch covers a corner case in<br>
the intersection of two features. Why is that not documented clearly?<br>
<br>
I want to see a statement such as "if we are using a shadow stack, then<br>
we need to use a CR4 value that matches the shadow stack, for<br>
determining whether 5-level paging is enabled or not".<br>
<br>
Or *something* like this.<br>
<br>
<br>
> Signed-off-by: Sheng Wei <<a href="mailto:w.sheng@intel.com">w.sheng@intel.com</a>><br>
> Cc: Eric Dong <<a href="mailto:eric.dong@intel.com">eric.dong@intel.com</a>><br>
> Cc: Ray Ni <<a href="mailto:ray.ni@intel.com">ray.ni@intel.com</a>><br>
> Cc: Laszlo Ersek <<a href="mailto:lersek@redhat.com">lersek@redhat.com</a>><br>
> Cc: Rahul Kumar <<a href="mailto:rahul1.kumar@intel.com">rahul1.kumar@intel.com</a>><br>
> Cc: Jiewen Yao <<a href="mailto:jiewen.yao@intel.com">jiewen.yao@intel.com</a>><br>
> ---<br>
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h         | 10 ++++++<br>
>  UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 42 ++++++++++++++++++++--<br>
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c            |  2 ++<br>
>  3 files changed, 51 insertions(+), 3 deletions(-)<br>
> <br>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h<br>
> index 7fb3a2d9e4..3eb6af62a7 100644<br>
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h<br>
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h<br>
> @@ -951,6 +951,16 @@ GetPageTableBase (<br>
>    VOID<br>
>    );<br>
>  <br>
> +/**<br>
> +  This function set the internal page table type to 5 level paging or 4 level paging.<br>
> +<br>
> +  @param Is5LevelPaging TRUE means 5 level paging. FALSE means 4 level paging.<br>
> +**/<br>
> +VOID<br>
> +SetPageTableType (<br>
> +  IN BOOLEAN  Is5LevelPaging<br>
> +  );<br>
> +<br>
>  /**<br>
>    This function sets the attributes for the memory region specified by BaseAddress and<br>
>    Length from their current attributes to the attributes specified by Attributes.<br>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c<br>
> index d67f036aea..91c0fd6587 100644<br>
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c<br>
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c<br>
> @@ -33,6 +33,7 @@ PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] = {<br>
>  };<br>
>  <br>
>  UINTN  mInternalCr3;<br>
> +BOOLEAN mInternalIs5LevelPaging = FALSE;<br>
>  <br>
>  /**<br>
>    Set the internal page table base address.<br>
> @@ -65,6 +66,43 @@ GetPageTableBase (<br>
>    return (AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64);<br>
>  }<br>
>  <br>
> +/**<br>
> +  This function set the internal page table type to 5 level paging or 4 level paging.<br>
> +<br>
> +  @param Is5LevelPaging TRUE means 5 level paging. FALSE means 4 level paging.<br>
> +**/<br>
> +VOID<br>
> +SetPageTableType (<br>
> +  IN BOOLEAN  Is5LevelPaging<br>
> +  )<br>
> +{<br>
> +  mInternalIs5LevelPaging = Is5LevelPaging;<br>
> +}<br>
> +<br>
> +/**<br>
> +  Return if the page table is 5 level paging.<br>
> +<br>
> +  @return TRUE  The page table base is 5 level paging.<br>
> +  @return FALSE The page table base is 4 level paging.<br>
> +**/<br>
> +STATIC<br>
> +BOOLEAN<br>
> +Is5LevelPageTableBase (<br>
> +  VOID<br>
> +  )<br>
> +{<br>
> +  IA32_CR4              Cr4;<br>
> +<br>
> +  // If mInternalCr3 is non zero, it will not use the page table from CR3.<br>
> +  // So, return the page level type from mInternalIs5LevelPaging instead of the CR4 LA57 bit.<br>
<br>
(3) Invalid comment style. Missing empty "//" lines before and after.<br>
<br>
> +  if (mInternalCr3 != 0) {<br>
> +    return mInternalIs5LevelPaging;<br>
> +  }<br>
> +<br>
> +  Cr4.UintN = AsmReadCr4 ();<br>
> +  return (BOOLEAN) (Cr4.Bits.LA57 == 1);<br>
> +}<br>
> +<br>
>  /**<br>
>    Return length according to page attributes.<br>
>  <br>
> @@ -131,7 +169,6 @@ GetPageTableEntry (<br>
>    UINT64                *L3PageTable;<br>
>    UINT64                *L4PageTable;<br>
>    UINT64                *L5PageTable;<br>
> -  IA32_CR4              Cr4;<br>
>    BOOLEAN               Enable5LevelPaging;<br>
>  <br>
>    Index5 = ((UINTN)RShiftU64 (Address, 48)) & PAGING_PAE_INDEX_MASK;<br>
> @@ -140,8 +177,7 @@ GetPageTableEntry (<br>
>    Index2 = ((UINTN)Address >> 21) & PAGING_PAE_INDEX_MASK;<br>
>    Index1 = ((UINTN)Address >> 12) & PAGING_PAE_INDEX_MASK;<br>
>  <br>
> -  Cr4.UintN = AsmReadCr4 ();<br>
> -  Enable5LevelPaging = (BOOLEAN) (Cr4.Bits.LA57 == 1);<br>
> +  Enable5LevelPaging = Is5LevelPageTableBase();<br>
<br>
(4) Missing space character before the opening parenthesis.<br>
<br>
>  <br>
>    if (sizeof(UINTN) == sizeof(UINT64)) {<br>
>      if (Enable5LevelPaging) {<br>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c<br>
> index 810985df20..6f2f4adb7d 100644<br>
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c<br>
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c<br>
> @@ -387,6 +387,8 @@ SmmInitPageTable (<br>
>    SetSubEntriesNum (Pml4Entry, 3);<br>
>    PTEntry = Pml4Entry;<br>
>  <br>
> +  SetPageTableType(m5LevelPagingNeeded);<br>
<br>
(5) Missing space character before the opening parenthesis.<br>
<br>
> +<br>
>    if (m5LevelPagingNeeded) {<br>
>      //<br>
>      // Fill PML5 entry<br>
> <br>
<br>
Laszlo<br>
<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr> Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/67028">View/Reply Online (#67028)</a> |    |  <a target="_blank" href="https://groups.io/mt/78045102/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>