<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: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=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><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 Hao,</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks for the feedback, I will remove the EFIAPI for this patch (as well as others you noted in other patches).</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">As per listing the driver under [Component.X64], this is because listing the driver under other section will trigger IA32 build, which needs a IA32 version of `MemLib`. I will modify “[PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib:
Extends support for X64 architecture” accordingly to make MemLib cover IA32 architecture as well.</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>
<p class="MsoNormal"><img width="345" height="1" style="width:3.5937in;height:.0052in" id="Horizontal_x0020_Line_x0020_1" src="cid:image002.png@01D6D85A.D50C7CF0"><o:p></o:p></p>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Wu, Hao A <hao.a.wu@intel.com><br>
<b>Sent:</b> Tuesday, December 22, 2020 12:36:03 AM<br>
<b>To:</b> Kun Qin <kun.q@outlook.com>; devel@edk2.groups.io <devel@edk2.groups.io><br>
<b>Cc:</b> Wang, Jian J <jian.j.wang@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Yao, Jiewen <jiewen.yao@intel.com><br>
<b>Subject:</b> Re: [edk2-devel] [PATCH v1 07/15] MdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm support</span>
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">> -----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: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;<br>
> Bi, Dandan <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn><br>
> Subject: [PATCH v1 07/15] MdeModulePkg: FirmwarePerformanceDataTable:<br>
> Added StandaloneMm support<br>
> <br>
> This change added support of FPDT driver under StandaloneMm. It replaces<br>
> SMM version ReportStatusCode protocol with MM version. This patch also<br>
> abstracts standalone and traditional MM interfaces into separate files to<br>
> support each corresponding function prototypes and implementations.<br>
<br>
<br>
Could you help to remove the 'EFIAPI' for functions:<br>
FirmwarePerformanceCommonEntryPoint()<br>
IsBufferOutsideMmValid()<br>
I found that they are internal functions.<br>
<br>
Another question I have is that is there any special consideration to list FirmwarePerformanceStandaloneMm.inf<br>
under the [Components.X64] section in the DSC file?<br>
<br>
Best Regards,<br>
Hao Wu<br>
<br>
<br>
> <br>
> Cc: Jian J Wang <jian.j.wang@intel.com><br>
> Cc: Hao A Wu <hao.a.wu@intel.com><br>
> Cc: Dandan Bi <dandan.bi@intel.com><br>
> Cc: Liming Gao <gaoliming@byosoft.com.cn><br>
> <br>
> Signed-off-by: Kun Qin <kun.q@outlook.com><br>
> ---<br>
> <br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/{Firm<br>
> warePerformanceSmm.c => FirmwarePerformanceCommon.c} | 72<br>
> ++++++++++----------<br>
> <br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm<br>
> warePerformanceStandaloneMm.c | 62<br>
> +++++++++++++++++<br>
> <br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm<br>
> warePerformanceTraditional.c | 62 +++++++++++++++++<br>
> MdeModulePkg/MdeModulePkg.dsc<br>
> | 2 +<br>
> <br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm<br>
> warePerformanceCommon.h | 55 +++++++++++++++<br>
> <br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm<br>
> warePerformanceSmm.inf | 11 +--<br>
> <br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/{Firm<br>
> warePerformanceSmm.inf => FirmwarePerformanceStandaloneMm.inf} | 31<br>
> ++++-----<br>
> 7 files changed, 237 insertions(+), 58 deletions(-)<br>
> <br>
> diff --git<br>
> a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceSmm.c<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceCommon.c<br>
> similarity index 77%<br>
> rename from<br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm<br>
> warePerformanceSmm.c<br>
> rename to<br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm<br>
> warePerformanceCommon.c<br>
> index d6c6e7693e4d..c2aa9455f9c4 100644<br>
> ---<br>
> a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceSmm.c<br>
> +++<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwa<br>
> +++ rePerformanceCommon.c<br>
> @@ -1,11 +1,11 @@<br>
> /** @file<br>
> - This module collects performance data for SMM driver boot records and S3<br>
> Suspend Performance Record.<br>
> + This module collects performance data for MM driver boot records and S3<br>
> Suspend Performance Record.<br>
> <br>
> This module registers report status code listener to collect performance<br>
> data<br>
> - for SMM driver boot records and S3 Suspend Performance Record.<br>
> + for MM driver boot records and S3 Suspend Performance Record.<br>
> <br>
> Caution: This module requires additional review when modified.<br>
> - This driver will have external input - communicate buffer in SMM mode.<br>
> + This driver will have external input - communicate buffer in MM mode.<br>
> This external input must be validated carefully to avoid security issue like<br>
> buffer overflow, integer overflow.<br>
> <br>
> @@ -16,13 +16,13 @@<br>
> <br>
> **/<br>
> <br>
> -#include <PiSmm.h><br>
> +#include <PiMm.h><br>
> <br>
> -#include <Protocol/SmmReportStatusCodeHandler.h><br>
> +#include <Protocol/MmReportStatusCodeHandler.h><br>
> <br>
> #include <Guid/FirmwarePerformance.h><br>
> <br>
> -#include <Library/SmmServicesTableLib.h><br>
> +#include <Library/MmServicesTableLib.h><br>
> #include <Library/BaseLib.h><br>
> #include <Library/DebugLib.h><br>
> #include <Library/TimerLib.h><br>
> @@ -30,23 +30,22 @@<br>
> #include <Library/PcdLib.h><br>
> #include <Library/BaseMemoryLib.h><br>
> #include <Library/MemoryAllocationLib.h> -#include<br>
> <Library/UefiBootServicesTableLib.h><br>
> #include <Library/SynchronizationLib.h> -#include <Library/SmmMemLib.h><br>
> +#include "FirmwarePerformanceCommon.h"<br>
> <br>
> -SMM_BOOT_PERFORMANCE_TABLE *mSmmBootPerformanceTable =<br>
> NULL;<br>
> +SMM_BOOT_PERFORMANCE_TABLE *mMmBootPerformanceTable =<br>
> NULL;<br>
> <br>
> -EFI_SMM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;<br>
> +EFI_MM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;<br>
> UINT64 mSuspendStartTime = 0;<br>
> BOOLEAN mS3SuspendLockBoxSaved = FALSE;<br>
> UINT32 mBootRecordSize = 0;<br>
> UINT8 *mBootRecordBuffer = NULL;<br>
> <br>
> -SPIN_LOCK mSmmFpdtLock;<br>
> -BOOLEAN mSmramIsOutOfResource = FALSE;<br>
> +SPIN_LOCK mMmFpdtLock;<br>
> +BOOLEAN mMmramIsOutOfResource = FALSE;<br>
> <br>
> /**<br>
> - Report status code listener for SMM. This is used to record the<br>
> performance<br>
> + Report status code listener for MM. This is used to record the<br>
> + performance<br>
> data for S3 Suspend Start and S3 Suspend End in FPDT.<br>
> <br>
> @param[in] CodeType Indicates the type of status code being<br>
> reported.<br>
> @@ -66,7 +65,7 @@ BOOLEAN mSmramIsOutOfResource = FALSE;<br>
> **/<br>
> EFI_STATUS<br>
> EFIAPI<br>
> -FpdtStatusCodeListenerSmm (<br>
> +FpdtStatusCodeListenerMm (<br>
> IN EFI_STATUS_CODE_TYPE CodeType,<br>
> IN EFI_STATUS_CODE_VALUE Value,<br>
> IN UINT32 Instance,<br>
> @@ -89,19 +88,19 @@ FpdtStatusCodeListenerSmm (<br>
> // Collect one or more Boot records in boot time<br>
> //<br>
> if (Data != NULL && CompareGuid (&Data->Type,<br>
> &gEdkiiFpdtExtendedFirmwarePerformanceGuid)) {<br>
> - AcquireSpinLock (&mSmmFpdtLock);<br>
> + AcquireSpinLock (&mMmFpdtLock);<br>
> //<br>
> // Get the boot performance data.<br>
> //<br>
> - CopyMem (&mSmmBootPerformanceTable, Data + 1, Data->Size);<br>
> - mBootRecordBuffer = ((UINT8 *) (mSmmBootPerformanceTable)) +<br>
> sizeof (SMM_BOOT_PERFORMANCE_TABLE);<br>
> + CopyMem (&mMmBootPerformanceTable, Data + 1, Data->Size);<br>
> + mBootRecordBuffer = ((UINT8 *) (mMmBootPerformanceTable)) + sizeof<br>
> + (SMM_BOOT_PERFORMANCE_TABLE);<br>
> <br>
> - ReleaseSpinLock (&mSmmFpdtLock);<br>
> + ReleaseSpinLock (&mMmFpdtLock);<br>
> return EFI_SUCCESS;<br>
> }<br>
> <br>
> if (Data != NULL && CompareGuid (&Data->Type,<br>
> &gEfiFirmwarePerformanceGuid)) {<br>
> - DEBUG ((DEBUG_ERROR, "FpdtStatusCodeListenerSmm: Performance<br>
> data reported through gEfiFirmwarePerformanceGuid will not be collected<br>
> by FirmwarePerformanceDataTableSmm\n"));<br>
> + DEBUG ((DEBUG_ERROR, "FpdtStatusCodeListenerMm: Performance<br>
> data<br>
> + reported through gEfiFirmwarePerformanceGuid will not be collected by<br>
> + FirmwarePerformanceDataTableMm\n"));<br>
> return EFI_UNSUPPORTED;<br>
> }<br>
> <br>
> @@ -157,7 +156,7 @@ FpdtStatusCodeListenerSmm (<br>
> /**<br>
> Communication service SMI Handler entry.<br>
> <br>
> - This SMI handler provides services for report SMM boot records.<br>
> + This SMI handler provides services for report MM boot records.<br>
> <br>
> Caution: This function may receive untrusted input.<br>
> Communicate buffer and buffer size are external input, so this function will<br>
> do basic validation.<br>
> @@ -166,7 +165,7 @@ FpdtStatusCodeListenerSmm (<br>
> @param[in] RegisterContext Points to an optional handler context which<br>
> was specified when the<br>
> handler was registered.<br>
> @param[in, out] CommBuffer A pointer to a collection of data in memory<br>
> that will<br>
> - be conveyed from a non-SMM environment into an SMM<br>
> environment.<br>
> + be conveyed from a non-MM environment into an MM<br>
> environment.<br>
> @param[in, out] CommBufferSize The size of the CommBuffer.<br>
> <br>
> @retval EFI_SUCCESS The interrupt was handled and quiesced.<br>
> No other handlers<br>
> @@ -207,8 +206,8 @@ FpdtSmiHandler (<br>
> return EFI_SUCCESS;<br>
> }<br>
> <br>
> - if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer,<br>
> TempCommBufferSize)) {<br>
> - DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM communication data<br>
> buffer in SMRAM or overflow!\n"));<br>
> + if (!IsBufferOutsideMmValid ((UINTN)CommBuffer,<br>
> TempCommBufferSize)) {<br>
> + DEBUG ((DEBUG_ERROR, "FpdtSmiHandler: MM communication data<br>
> buffer<br>
> + in MMRAM or overflow!\n"));<br>
> return EFI_SUCCESS;<br>
> }<br>
> <br>
> @@ -218,8 +217,8 @@ FpdtSmiHandler (<br>
> <br>
> switch (SmmCommData->Function) {<br>
> case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE :<br>
> - if (mSmmBootPerformanceTable != NULL) {<br>
> - mBootRecordSize = mSmmBootPerformanceTable->Header.Length -<br>
> sizeof (SMM_BOOT_PERFORMANCE_TABLE);<br>
> + if (mMmBootPerformanceTable != NULL) {<br>
> + mBootRecordSize = mMmBootPerformanceTable->Header.Length -<br>
> + sizeof (SMM_BOOT_PERFORMANCE_TABLE);<br>
> }<br>
> SmmCommData->BootRecordSize = mBootRecordSize;<br>
> break;<br>
> @@ -244,8 +243,8 @@ FpdtSmiHandler (<br>
> BootRecordSize = mBootRecordSize - BootRecordOffset;<br>
> }<br>
> SmmCommData->BootRecordSize = BootRecordSize;<br>
> - if (!SmmIsBufferOutsideSmmValid ((UINTN)BootRecordData,<br>
> BootRecordSize)) {<br>
> - DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM Data buffer in SMRAM<br>
> or overflow!\n"));<br>
> + if (!IsBufferOutsideMmValid ((UINTN)BootRecordData, BootRecordSize))<br>
> {<br>
> + DEBUG ((DEBUG_ERROR, "FpdtSmiHandler: MM Data buffer in<br>
> MMRAM<br>
> + or overflow!\n"));<br>
> Status = EFI_ACCESS_DENIED;<br>
> break;<br>
> }<br>
> @@ -267,7 +266,7 @@ FpdtSmiHandler (<br>
> }<br>
> <br>
> /**<br>
> - The module Entry Point of the Firmware Performance Data Table SMM<br>
> driver.<br>
> + The module Entry Point of the Firmware Performance Data Table MM<br>
> driver.<br>
> <br>
> @param[in] ImageHandle The firmware allocated handle for the EFI<br>
> image.<br>
> @param[in] SystemTable A pointer to the EFI System Table.<br>
> @@ -278,9 +277,8 @@ FpdtSmiHandler (<br>
> **/<br>
> EFI_STATUS<br>
> EFIAPI<br>
> -FirmwarePerformanceSmmEntryPoint (<br>
> - IN EFI_HANDLE ImageHandle,<br>
> - IN EFI_SYSTEM_TABLE *SystemTable<br>
> +FirmwarePerformanceCommonEntryPoint (<br>
> + VOID<br>
> )<br>
> {<br>
> EFI_STATUS Status;<br>
> @@ -289,13 +287,13 @@ FirmwarePerformanceSmmEntryPoint (<br>
> //<br>
> // Initialize spin lock<br>
> //<br>
> - InitializeSpinLock (&mSmmFpdtLock);<br>
> + InitializeSpinLock (&mMmFpdtLock);<br>
> <br>
> //<br>
> - // Get SMM Report Status Code Handler Protocol.<br>
> + // Get MM Report Status Code Handler Protocol.<br>
> //<br>
> - Status = gSmst->SmmLocateProtocol (<br>
> - &gEfiSmmRscHandlerProtocolGuid,<br>
> + Status = gMmst->MmLocateProtocol (<br>
> + &gEfiMmRscHandlerProtocolGuid,<br>
> NULL,<br>
> (VOID **) &mRscHandlerProtocol<br>
> );<br>
> @@ -304,14 +302,14 @@ FirmwarePerformanceSmmEntryPoint (<br>
> //<br>
> // Register report status code listener for BootRecords and S3 Suspend<br>
> Start and End.<br>
> //<br>
> - Status = mRscHandlerProtocol->Register (FpdtStatusCodeListenerSmm);<br>
> + Status = mRscHandlerProtocol->Register (FpdtStatusCodeListenerMm);<br>
> ASSERT_EFI_ERROR (Status);<br>
> <br>
> //<br>
> // Register SMI handler.<br>
> //<br>
> Handle = NULL;<br>
> - Status = gSmst->SmiHandlerRegister (FpdtSmiHandler,<br>
> &gEfiFirmwarePerformanceGuid, &Handle);<br>
> + Status = gMmst->MmiHandlerRegister (FpdtSmiHandler,<br>
> + &gEfiFirmwarePerformanceGuid, &Handle);<br>
> ASSERT_EFI_ERROR (Status);<br>
> <br>
> return Status;<br>
> diff --git<br>
> a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceStandaloneMm.c<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceStandaloneMm.c<br>
> new file mode 100644<br>
> index 000000000000..2c4f40eceaea<br>
> --- /dev/null<br>
> +++<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwa<br>
> +++ rePerformanceStandaloneMm.c<br>
> @@ -0,0 +1,62 @@<br>
> +/** @file<br>
> + This module collects performance data for MM driver boot records and S3<br>
> Suspend Performance Record.<br>
> +<br>
> + This module registers report status code listener to collect<br>
> + performance data for MM driver boot records and S3 Suspend<br>
> Performance Record.<br>
> +<br>
> + Caution: This module requires additional review when modified.<br>
> + This driver will have external input - communicate buffer in MM mode.<br>
> + This external input must be validated carefully to avoid security<br>
> + issue like buffer overflow, integer overflow.<br>
> +<br>
> + FpdtSmiHandler() will receive untrusted input and do basic validation.<br>
> +<br>
> + Copyright (c) 2011 - 2018, Intel Corporation. All rights<br>
> + reserved.<BR> Copyright (c), Microsoft Corporation.<br>
> + SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> +<br>
> +**/<br>
> +<br>
> +#include <PiMm.h><br>
> +<br>
> +#include <Library/StandaloneMmMemLib.h> #include<br>
> +"FirmwarePerformanceCommon.h"<br>
> +<br>
> +/**<br>
> + This function is an abstraction layer for implementation specific Mm buffer<br>
> validation routine.<br>
> +<br>
> + @param Buffer The buffer start address to be checked.<br>
> + @param Length The buffer length to be checked.<br>
> +<br>
> + @retval TRUE This buffer is valid per processor architecture and not<br>
> overlap with SMRAM.<br>
> + @retval FALSE This buffer is not valid per processor architecture or overlap<br>
> with SMRAM.<br>
> +**/<br>
> +BOOLEAN<br>
> +EFIAPI<br>
> +IsBufferOutsideMmValid (<br>
> + IN EFI_PHYSICAL_ADDRESS Buffer,<br>
> + IN UINT64 Length<br>
> + )<br>
> +{<br>
> + return MmIsBufferOutsideMmValid (Buffer, Length); }<br>
> +<br>
> +/**<br>
> + The module Entry Point of the Firmware Performance Data Table MM<br>
> driver.<br>
> +<br>
> + @param[in] ImageHandle The firmware allocated handle for the EFI<br>
> image.<br>
> + @param[in] SystemTable A pointer to the EFI System Table.<br>
> +<br>
> + @retval EFI_SUCCESS The entry point is executed successfully.<br>
> + @retval Other Some error occurs when executing this entry point.<br>
> +<br>
> +**/<br>
> +EFI_STATUS<br>
> +EFIAPI<br>
> +FirmwarePerformanceStandaloneMmEntryPoint (<br>
> + IN EFI_HANDLE ImageHandle,<br>
> + IN EFI_MM_SYSTEM_TABLE *SystemTable<br>
> + )<br>
> +{<br>
> + return FirmwarePerformanceCommonEntryPoint (); }<br>
> diff --git<br>
> a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceTraditional.c<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceTraditional.c<br>
> new file mode 100644<br>
> index 000000000000..507aabcb4e88<br>
> --- /dev/null<br>
> +++<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwa<br>
> +++ rePerformanceTraditional.c<br>
> @@ -0,0 +1,62 @@<br>
> +/** @file<br>
> + This module collects performance data for MM driver boot records and S3<br>
> Suspend Performance Record.<br>
> +<br>
> + This module registers report status code listener to collect<br>
> + performance data for MM driver boot records and S3 Suspend<br>
> Performance Record.<br>
> +<br>
> + Caution: This module requires additional review when modified.<br>
> + This driver will have external input - communicate buffer in MM mode.<br>
> + This external input must be validated carefully to avoid security<br>
> + issue like buffer overflow, integer overflow.<br>
> +<br>
> + FpdtSmiHandler() will receive untrusted input and do basic validation.<br>
> +<br>
> + Copyright (c) 2011 - 2018, Intel Corporation. All rights<br>
> + reserved.<BR> Copyright (c), Microsoft Corporation.<br>
> + SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> +<br>
> +**/<br>
> +<br>
> +#include <PiSmm.h><br>
> +<br>
> +#include <Library/SmmMemLib.h><br>
> +#include "FirmwarePerformanceCommon.h"<br>
> +<br>
> +/**<br>
> + This function is an abstraction layer for implementation specific Mm buffer<br>
> validation routine.<br>
> +<br>
> + @param Buffer The buffer start address to be checked.<br>
> + @param Length The buffer length to be checked.<br>
> +<br>
> + @retval TRUE This buffer is valid per processor architecture and not<br>
> overlap with SMRAM.<br>
> + @retval FALSE This buffer is not valid per processor architecture or overlap<br>
> with SMRAM.<br>
> +**/<br>
> +BOOLEAN<br>
> +EFIAPI<br>
> +IsBufferOutsideMmValid (<br>
> + IN EFI_PHYSICAL_ADDRESS Buffer,<br>
> + IN UINT64 Length<br>
> + )<br>
> +{<br>
> + return SmmIsBufferOutsideSmmValid (Buffer, Length); }<br>
> +<br>
> +/**<br>
> + The module Entry Point of the Firmware Performance Data Table MM<br>
> driver.<br>
> +<br>
> + @param[in] ImageHandle The firmware allocated handle for the EFI<br>
> image.<br>
> + @param[in] SystemTable A pointer to the EFI System Table.<br>
> +<br>
> + @retval EFI_SUCCESS The entry point is executed successfully.<br>
> + @retval Other Some error occurs when executing this entry point.<br>
> +<br>
> +**/<br>
> +EFI_STATUS<br>
> +EFIAPI<br>
> +FirmwarePerformanceSmmEntryPoint (<br>
> + IN EFI_HANDLE ImageHandle,<br>
> + IN EFI_SYSTEM_TABLE *SystemTable<br>
> + )<br>
> +{<br>
> + return FirmwarePerformanceCommonEntryPoint (); }<br>
> diff --git a/MdeModulePkg/MdeModulePkg.dsc<br>
> b/MdeModulePkg/MdeModulePkg.dsc index 05bf5fe08094..dc85d108d958<br>
> 100644<br>
> --- a/MdeModulePkg/MdeModulePkg.dsc<br>
> +++ b/MdeModulePkg/MdeModulePkg.dsc<br>
> @@ -168,6 +168,7 @@ [LibraryClasses.common.MM_STANDALONE]<br>
> <br>
> StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntry<br>
> Point/StandaloneMmDriverEntryPoint.inf<br>
> <br>
> MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Stan<br>
> daloneMmServicesTableLib.inf<br>
> <br>
> LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandalo<br>
> neMmLib.inf<br>
> +<br>
> +<br>
> MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMm<br>
> MemLib.i<br>
> + nf<br>
> <br>
> [LibraryClasses.ARM, LibraryClasses.AARCH64]<br>
> ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf<br>
> @@ -501,6 +502,7 @@ [Components.IA32, Components.X64]<br>
> <br>
> [Components.X64]<br>
> MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf<br>
> +<br>
> +<br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm<br>
> warePe<br>
> + rformanceStandaloneMm.inf<br>
> <br>
> [BuildOptions]<br>
> <br>
> diff --git<br>
> a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceCommon.h<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceCommon.h<br>
> new file mode 100644<br>
> index 000000000000..ba01e28f2493<br>
> --- /dev/null<br>
> +++<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwa<br>
> +++ rePerformanceCommon.h<br>
> @@ -0,0 +1,55 @@<br>
> +/** @file<br>
> + This module collects performance data for SMM driver boot records and S3<br>
> Suspend Performance Record.<br>
> +<br>
> + This module registers report status code listener to collect<br>
> + performance data for SMM driver boot records and S3 Suspend<br>
> Performance Record.<br>
> +<br>
> + Caution: This module requires additional review when modified.<br>
> + This driver will have external input - communicate buffer in SMM mode.<br>
> + This external input must be validated carefully to avoid security<br>
> + issue like buffer overflow, integer overflow.<br>
> +<br>
> + FpdtSmiHandler() will receive untrusted input and do basic validation.<br>
> +<br>
> + Copyright (c) 2011 - 2018, Intel Corporation. All rights<br>
> + reserved.<BR> Copyright (c), Microsoft Corporation.<br>
> + SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> +<br>
> +**/<br>
> +<br>
> +#ifndef _FW_PERF_COMMON_H_<br>
> +#define _FW_PERF_COMMON_H_<br>
> +<br>
> +/**<br>
> + This function is an abstraction layer for implementation specific Mm buffer<br>
> validation routine.<br>
> +<br>
> + @param Buffer The buffer start address to be checked.<br>
> + @param Length The buffer length to be checked.<br>
> +<br>
> + @retval TRUE This buffer is valid per processor architecture and not<br>
> overlap with SMRAM.<br>
> + @retval FALSE This buffer is not valid per processor architecture or overlap<br>
> with SMRAM.<br>
> +**/<br>
> +BOOLEAN<br>
> +EFIAPI<br>
> +IsBufferOutsideMmValid (<br>
> + IN EFI_PHYSICAL_ADDRESS Buffer,<br>
> + IN UINT64 Length<br>
> + );<br>
> +<br>
> +/**<br>
> + The module Entry Point of the Firmware Performance Data Table MM<br>
> driver.<br>
> +<br>
> + @param[in] ImageHandle The firmware allocated handle for the EFI<br>
> image.<br>
> + @param[in] SystemTable A pointer to the EFI System Table.<br>
> +<br>
> + @retval EFI_SUCCESS The entry point is executed successfully.<br>
> + @retval Other Some error occurs when executing this entry point.<br>
> +<br>
> +**/<br>
> +EFI_STATUS<br>
> +EFIAPI<br>
> +FirmwarePerformanceCommonEntryPoint (<br>
> + VOID<br>
> + );<br>
> +<br>
> +#endif // _FW_PERF_COMMON_H_<br>
> diff --git<br>
> a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceSmm.inf<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceSmm.inf<br>
> index 618cbd56ca59..b7194bd899dd 100644<br>
> ---<br>
> a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceSmm.inf<br>
> +++<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwa<br>
> +++ rePerformanceSmm.inf<br>
> @@ -26,7 +26,9 @@ [Defines]<br>
> #<br>
> <br>
> [Sources]<br>
> - FirmwarePerformanceSmm.c<br>
> + FirmwarePerformanceCommon.c<br>
> + FirmwarePerformanceCommon.h<br>
> + FirmwarePerformanceTraditional.c<br>
> <br>
> [Packages]<br>
> MdePkg/MdePkg.dec<br>
> @@ -34,7 +36,7 @@ [Packages]<br>
> <br>
> [LibraryClasses]<br>
> UefiDriverEntryPoint<br>
> - SmmServicesTableLib<br>
> + MmServicesTableLib<br>
> BaseLib<br>
> DebugLib<br>
> TimerLib<br>
> @@ -42,12 +44,11 @@ [LibraryClasses]<br>
> PcdLib<br>
> BaseMemoryLib<br>
> MemoryAllocationLib<br>
> - UefiBootServicesTableLib<br>
> SynchronizationLib<br>
> SmmMemLib<br>
> <br>
> [Protocols]<br>
> - gEfiSmmRscHandlerProtocolGuid ## CONSUMES<br>
> + gEfiMmRscHandlerProtocolGuid ## CONSUMES<br>
> <br>
> [Guids]<br>
> ## SOMETIMES_PRODUCES ## UNDEFINED # SaveLockBox<br>
> @@ -61,7 +62,7 @@ [Pcd]<br>
> gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeS3SuspendEnd ##<br>
> CONSUMES<br>
> <br>
> [Depex]<br>
> - gEfiSmmRscHandlerProtocolGuid<br>
> + gEfiMmRscHandlerProtocolGuid<br>
> <br>
> [UserExtensions.TianoCore."ExtraFiles"]<br>
> FirmwarePerformanceSmmExtra.uni<br>
> diff --git<br>
> a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceSmm.inf<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceStandaloneMm.inf<br>
> similarity index 65%<br>
> copy from<br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm<br>
> warePerformanceSmm.inf<br>
> copy to<br>
> MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm<br>
> warePerformanceStandaloneMm.inf<br>
> index 618cbd56ca59..e6aad88be0ef 100644<br>
> ---<br>
> a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwarePerformanceSmm.inf<br>
> +++<br>
> b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir<br>
> mwa<br>
> +++ rePerformanceStandaloneMm.inf<br>
> @@ -5,19 +5,19 @@<br>
> # for SMM boot performance records and S3 Suspend Performance Record.<br>
> #<br>
> # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR><br>
> +# Copyright (c) Microsoft Corporation.<br>
> # SPDX-License-Identifier: BSD-2-Clause-Patent # ##<br>
> <br>
> [Defines]<br>
> INF_VERSION = 0x00010005<br>
> - BASE_NAME = FirmwarePerformanceSmm<br>
> - MODULE_UNI_FILE = FirmwarePerformanceSmm.uni<br>
> - FILE_GUID = 044310AB-77FD-402a-AF1A-87D4120E7329<br>
> - MODULE_TYPE = DXE_SMM_DRIVER<br>
> + BASE_NAME = FirmwarePerformanceStandaloneMm<br>
> + FILE_GUID = 827AC29D-E52D-4B1A-874A-C6577E0699CF<br>
> + MODULE_TYPE = MM_STANDALONE<br>
> VERSION_STRING = 1.0<br>
> - PI_SPECIFICATION_VERSION = 0x0001000A<br>
> - ENTRY_POINT = FirmwarePerformanceSmmEntryPoint<br>
> + PI_SPECIFICATION_VERSION = 0x00010032<br>
> + ENTRY_POINT = FirmwarePerformanceStandaloneMmEntryPoint<br>
> <br>
> #<br>
> # The following information is for reference only and not required by the<br>
> build tools.<br>
> @@ -26,15 +26,18 @@ [Defines]<br>
> #<br>
> <br>
> [Sources]<br>
> - FirmwarePerformanceSmm.c<br>
> + FirmwarePerformanceCommon.c<br>
> + FirmwarePerformanceCommon.h<br>
> + FirmwarePerformanceStandaloneMm.c<br>
> <br>
> [Packages]<br>
> MdePkg/MdePkg.dec<br>
> MdeModulePkg/MdeModulePkg.dec<br>
> + StandaloneMmPkg/StandaloneMmPkg.dec<br>
> <br>
> [LibraryClasses]<br>
> - UefiDriverEntryPoint<br>
> - SmmServicesTableLib<br>
> + StandaloneMmDriverEntryPoint<br>
> + MmServicesTableLib<br>
> BaseLib<br>
> DebugLib<br>
> TimerLib<br>
> @@ -42,12 +45,11 @@ [LibraryClasses]<br>
> PcdLib<br>
> BaseMemoryLib<br>
> MemoryAllocationLib<br>
> - UefiBootServicesTableLib<br>
> SynchronizationLib<br>
> - SmmMemLib<br>
> + MemLib<br>
> <br>
> [Protocols]<br>
> - gEfiSmmRscHandlerProtocolGuid ## CONSUMES<br>
> + gEfiMmRscHandlerProtocolGuid ## CONSUMES<br>
> <br>
> [Guids]<br>
> ## SOMETIMES_PRODUCES ## UNDEFINED # SaveLockBox<br>
> @@ -61,7 +63,4 @@ [Pcd]<br>
> gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeS3SuspendEnd ##<br>
> CONSUMES<br>
> <br>
> [Depex]<br>
> - gEfiSmmRscHandlerProtocolGuid<br>
> -<br>
> -[UserExtensions.TianoCore."ExtraFiles"]<br>
> - FirmwarePerformanceSmmExtra.uni<br>
> + gEfiMmRscHandlerProtocolGuid<br>
> --<br>
> 2.28.0.windows.1<br>
<br>
<br>
<br>
<br>
<br>
<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/69387">View/Reply Online (#69387)</a> | | <a target="_blank" href="https://groups.io/mt/79068291/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>