<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" 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=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Jiewen,</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I did not fill these 2 variables for this patch because I thought to follow up fix for this issue separately because the AARCH64 instance does not fill it either and I meant for this patch to solely extends the coverage to x64 (and IA32).
 But please let me know if you think otherwise, I can add the x64 fix in this patch as well. But I do not have fix for AARCH64 since I am not familiar with how it should work.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">Kun</p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:jiewen.yao@intel.com">Yao, Jiewen</a><br>
<b>Sent: </b>Sunday, December 27, 2020 16:18<br>
<b>To: </b><a href="mailto:kun.q@outlook.com">Kun Qin</a>; <a href="mailto:devel@edk2.groups.io">
devel@edk2.groups.io</a><br>
<b>Cc: </b><a href="mailto:ard.biesheuvel@arm.com">Ard Biesheuvel</a>; <a href="mailto:sami.mujawar@arm.com">
Sami Mujawar</a>; <a href="mailto:supreeth.venkatesh@arm.com">Supreeth Venkatesh</a><br>
<b>Subject: </b>RE: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">May I know where is the code to fill below?<br>
EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges;<br>
UINTN                mMmMemLibInternalMmramCount;<br>
<br>
<br>
<br>
> -----Original Message-----<br>
> From: Kun Qin <kun.q@outlook.com><br>
> Sent: Saturday, December 19, 2020 2:50 AM<br>
> To: devel@edk2.groups.io<br>
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Sami Mujawar<br>
> <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>; Supreeth<br>
> Venkatesh <supreeth.venkatesh@arm.com><br>
> Subject: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib:<br>
> Extends support for X64 architecture<br>
> <br>
> This change extends StandaloneMmMemLib library to support X64<br>
> architecture. The implementation is ported from<br>
> MdePkg/Library/SmmMemLib.<br>
> <br>
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com><br>
> Cc: Sami Mujawar <sami.mujawar@arm.com><br>
> Cc: Jiewen Yao <jiewen.yao@intel.com><br>
> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com><br>
> <br>
> Signed-off-by: Kun Qin <kun.q@outlook.com><br>
> ---<br>
> <br>
> StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMmMe<br>
> mLibInternal.c | 67 ++++++++++++++++++++<br>
> <br>
> StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib<br>
> .inf           |  6 +-<br>
>  2 files changed, 72 insertions(+), 1 deletion(-)<br>
> <br>
> diff --git<br>
> a/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm<br>
> MemLibInternal.c<br>
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm<br>
> MemLibInternal.c<br>
> new file mode 100644<br>
> index 000000000000..c5e21c583f44<br>
> --- /dev/null<br>
> +++<br>
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm<br>
> MemLibInternal.c<br>
> @@ -0,0 +1,67 @@<br>
> +/** @file<br>
> +  Internal ARCH Specific file of MM memory check library.<br>
> +<br>
> +  MM memory check library implementation. This library consumes<br>
> MM_ACCESS_PROTOCOL<br>
> +  to get MMRAM information. In order to use this library instance, the<br>
> platform should produce<br>
> +  all MMRAM range via MM_ACCESS_PROTOCOL, including the range for<br>
> firmware (like MM Core<br>
> +  and MM driver) and/or specific dedicated hardware.<br>
> +<br>
> +  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR><br>
> +  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR><br>
> +<br>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> +<br>
> +**/<br>
> +#include <Library/BaseLib.h><br>
> +#include <Library/BaseMemoryLib.h><br>
> +#include <Library/DebugLib.h><br>
> +#include <Library/HobLib.h><br>
> +//<br>
> +// Maximum support address used to check input buffer<br>
> +//<br>
> +extern EFI_PHYSICAL_ADDRESS<br>
> mMmMemLibInternalMaximumSupportAddress;<br>
> +<br>
> +/**<br>
> +  Calculate and save the maximum support address.<br>
> +<br>
> +**/<br>
> +VOID<br>
> +MmMemLibInternalCalculateMaximumSupportAddress (<br>
> +  VOID<br>
> +  )<br>
> +{<br>
> +  VOID         *Hob;<br>
> +  UINT32       RegEax;<br>
> +  UINT8        PhysicalAddressBits;<br>
> +<br>
> +  //<br>
> +  // Get physical address bits supported.<br>
> +  //<br>
> +  Hob = GetFirstHob (EFI_HOB_TYPE_CPU);<br>
> +  if (Hob != NULL) {<br>
> +    PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace;<br>
> +  } else {<br>
> +    AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);<br>
> +    if (RegEax >= 0x80000008) {<br>
> +      AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);<br>
> +      PhysicalAddressBits = (UINT8) RegEax;<br>
> +    } else {<br>
> +      PhysicalAddressBits = 36;<br>
> +    }<br>
> +  }<br>
> +  //<br>
> +  // IA-32e paging translates 48-bit linear addresses to 52-bit physical<br>
> addresses.<br>
> +  //<br>
> +  ASSERT (PhysicalAddressBits <= 52);<br>
> +  if (PhysicalAddressBits > 48) {<br>
> +    PhysicalAddressBits = 48;<br>
> +  }<br>
> +<br>
> +  //<br>
> +  // Save the maximum support address in one global variable<br>
> +  //<br>
> +  mMmMemLibInternalMaximumSupportAddress =<br>
> (EFI_PHYSICAL_ADDRESS)(UINTN)(LShiftU64 (1, PhysicalAddressBits) - 1);<br>
> +  DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddress<br>
> = 0x%lx\n", mMmMemLibInternalMaximumSupportAddress));<br>
> +}<br>
> +<br>
> +<br>
> diff --git<br>
> a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem<br>
> Lib.inf<br>
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem<br>
> Lib.inf<br>
> index 49da02e54e6d..65ad0a48905c 100644<br>
> ---<br>
> a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem<br>
> Lib.inf<br>
> +++<br>
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem<br>
> Lib.inf<br>
> @@ -26,12 +26,15 @@ [Defines]<br>
>  #<br>
>  # The following information is for reference only and not required by the<br>
> build tools.<br>
>  #<br>
> -#  VALID_ARCHITECTURES           = AARCH64<br>
> +#  VALID_ARCHITECTURES           = X64 AARCH64<br>
>  #<br>
> <br>
>  [Sources.Common]<br>
>    StandaloneMmMemLib.c<br>
> <br>
> +[Sources.X64]<br>
> +  X64/StandaloneMmMemLibInternal.c<br>
> +<br>
>  [Sources.AARCH64]<br>
>    AArch64/StandaloneMmMemLibInternal.c<br>
> <br>
> @@ -42,3 +45,4 @@ [Packages]<br>
>  [LibraryClasses]<br>
>    BaseMemoryLib<br>
>    DebugLib<br>
> +  HobLib<br>
> --<br>
> 2.28.0.windows.1<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</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/69473">View/Reply Online (#69473)</a> |    |  <a target="_blank" href="https://groups.io/mt/79068287/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>