Hi Liming,

 

Noted, I will add the driver of StatusCodeHandlerStandaloneMm in v2 patches.

 

Regards,

Kun

 

From: gaoliming
Sent: Monday, December 28, 2020 17:24
To: devel@edk2.groups.io; kun.q@outlook.com; hao.a.wu@intel.com; 'Yao, Jiewen'
Cc: 'Wang, Jian J'; 'Bi, Dandan'
Subject: 回复: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm

 

Kun:

 I prefer to include StatusCodeHandlerSmm with the basic check. If so, the complete statuscode solution can be provided.

 

Thanks

Liming

发件人: bounce+27952+69443+4905953+8761045@groups.io <bounce+27952+69443+4905953+8761045@groups.io> 代表 Kun Qin
发送时间: 20201224 17:12
收件人: devel@edk2.groups.io; gaoliming@byosoft.com.cn; hao.a.wu@intel.com; 'Yao, Jiewen' <jiewen.yao@intel.com>
抄送: 'Wang, Jian J' <jian.j.wang@intel.com>; 'Bi, Dandan' <dandan.bi@intel.com>
主题: Re: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm

 

Liming,

 

I have not had a plan for StatusCodeHandlerSmm because our platforms are not using it currently (we used a MU version instead). So it would be difficult to fully validate the functionality after updates. Please let me know if you prefer to have this driver updated in this patch series, I can try to update it locally with some fundamental sanity checks.

 

Regards,

Kun

 

From: gaoliming
Sent: Wednesday, December 23, 2020 17:53
To: devel@edk2.groups.io; hao.a.wu@intel.com; kun.q@outlook.com; 'Yao, Jiewen'
Cc: 'Wang, Jian J'; 'Bi, Dandan'
Subject: 回复: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm

 

Kun:

 I am OK for this solution. Have you plan to update StatusCodeHandlerSmm?

 

Thanks

Liming

发件人: bounce+27952+69397+4905953+8761045@groups.io <bounce+27952+69397+4905953+8761045@groups.io> 代表 Wu, Hao A
发送时间: 20201223 14:10
收件人: devel@edk2.groups.io; kun.q@outlook.com; Liming Gao <gaoliming@byosoft.com.cn>; Yao, Jiewen <jiewen.yao@intel.com>
抄送: Wang, Jian J <jian.j.wang@intel.com>; Bi, Dandan <dandan.bi@intel.com>
主题: Re: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm

 

Hello Kun,

 

Got it, thanks for the explanation. My preference is the same with your current proposal in the patch.

 

 

Hello Liming and Jiewen,

 

Do you have comments for this case? Thanks in advance.

 

Best Regards,

Hao Wu

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Kun Qin
Sent: Wednesday, December 23, 2020 3:15 AM
To: devel@edk2.groups.io; Wu, Hao A <hao.a.wu@intel.com>
Cc: 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>
Subject: Re: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm

 

Hi Hao,

 

That was my original plan, but doing it might require a MmServiceTableLib instance for SMM_CORE type if PiSmmCore links in RSC lib (similar to PiSmmCoreSmmServicesTableLib). We can create such an instance just like PiSmmCoreSmmServicesTableLib, but the implementation will pull in gSmmCoreSmst as an external variable and cast it from `EFI_SMM_SYSTEM_TABLE2` to `EFI_MM_SYSTEM_TABLE`, which does not look clean. Thus I just abstract the routine to avoid it.

 

Please let me know if you have better ideas, I can add the change for next patch series.

 

Thanks,

Kun

 

From: Wu, Hao A
Sent: Tuesday, December 22, 2020 00:35
To: devel@edk2.groups.io; kun.q@outlook.com
Cc: Wang, Jian J; Bi, Dandan; Liming Gao; Yao, Jiewen
Subject: Re: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm

 

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Kun Qin
> Sent: Saturday, December 19, 2020 2:50 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Bi, Dandan <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
> Subject: [edk2-devel] [PATCH v1 06/15] MdeModulePkg:
> SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm
>
> This change added support of StandaloneMm for ReportStatusCodeLib. It
> adds a new instance of ReportStatusCodeLib for MM_STANDALONE type,
> and abstracts the references of gMmst and gSmst functionalities into
> separate files in order to link in proper Service Table for SMM core/drivers.


Sorry for a question.

Do you think it is feasible to use:
gMmst->MmLocateProtocol to locate gEfiMmStatusCodeProtocolGuid
and avoid introducing 2 separate implementations for internal function InternalLocateProtocol()?

Since I found that the definitions for gEfiMmStatusCodeProtocolGuid an gEfiSmmStatusCodeProtocolGuid are identical.

Best Regards,
Hao Wu


>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
>
> Signed-off-by: Kun Qin <kun.q@outlook.com>
> ---
>  MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c
> | 16 ++++----
>
> MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibSta
> ndaloneMm.c                                   | 39 ++++++++++++++++++++
>
> MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibTra
> ditional.c                                    | 39 ++++++++++++++++++++
>  MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.h
> | 37 +++++++++++++++++++
>
> MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi
> b.inf                                          |  4 +-
>
> MdeModulePkg/Library/SmmReportStatusCodeLib/{SmmReportStatusCode
> Lib.inf => StandaloneMmReportStatusCodeLib.inf} | 17 +++++----
>  MdeModulePkg/MdeModulePkg.dsc
> |  1 +
>  7 files changed, 137 insertions(+), 16 deletions(-)
>
> diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.
> c
> index 3a1772538cdf..fb1769db9223 100644
> ---
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c
> +++
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.
> c
> @@ -1,5 +1,5 @@
>  /** @file
> -  Report Status Code Library for SMM Phase.
> +  Report Status Code Library for MM Phase.
>
>    Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>    SPDX-License-Identifier: BSD-2-Clause-Patent @@ -8,7 +8,7 @@
>
>  #include <Library/ReportStatusCodeLib.h>  #include <Library/DebugLib.h> -
> #include <Library/SmmServicesTableLib.h>
> +#include <Library/MmServicesTableLib.h>
>  #include <Library/BaseLib.h>
>  #include <Library/BaseMemoryLib.h>
>  #include <Library/PcdLib.h>
> @@ -16,10 +16,12 @@
>
>  #include <Guid/StatusCodeDataTypeId.h>
>  #include <Guid/StatusCodeDataTypeDebug.h> -#include
> <Protocol/SmmStatusCode.h>
> +#include <Protocol/MmStatusCode.h>
>
> -EFI_SMM_REPORT_STATUS_CODE     mReportStatusCode = NULL;
> -EFI_SMM_STATUS_CODE_PROTOCOL   *mStatusCodeProtocol = NULL;
> +#include "ReportStatusCodeLib.h"
> +
> +EFI_MM_REPORT_STATUS_CODE     mReportStatusCode = NULL;
> +EFI_MM_STATUS_CODE_PROTOCOL   *mStatusCodeProtocol = NULL;
>
>
>  /**
> @@ -29,14 +31,14 @@ EFI_SMM_STATUS_CODE_PROTOCOL
> *mStatusCodeProtocol = NULL;
>              NULL is returned if no status code service is available.
>
>  **/
> -EFI_SMM_REPORT_STATUS_CODE
> +EFI_MM_REPORT_STATUS_CODE
>  InternalGetReportStatusCode (
>    VOID
>    )
>  {
>    EFI_STATUS                    Status;
>
> -  Status = gSmst->SmmLocateProtocol (&gEfiSmmStatusCodeProtocolGuid,
> NULL, (VOID**)&mStatusCodeProtocol);
> +  Status = InternalLocateProtocol (&gEfiMmStatusCodeProtocolGuid, NULL,
> + (VOID**)&mStatusCodeProtocol);
>    if (!EFI_ERROR (Status) && mStatusCodeProtocol != NULL) {
>      return mStatusCodeProtocol->ReportStatusCode;
>    }
> diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibS
> tandaloneMm.c
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibS
> tandaloneMm.c
> new file mode 100644
> index 000000000000..fc47dffe9ffb
> --- /dev/null
> +++
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibS
> ta
> +++ ndaloneMm.c
> @@ -0,0 +1,39 @@
> +/** @file
> +  Abstraction layer for MM service table used by MM ReportStatusCodeLib.
> +
> +  Copyright (c) Microsoft Corporation.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <PiMm.h>
> +
> +#include <Library/MmServicesTableLib.h>
> +
> +/**
> +  Returns the first protocol instance that matches the given protocol.
> +
> +  @param[in]  Protocol          Provides the protocol to search for.
> +  @param[in]  Registration      Optional registration key returned from
> +                                RegisterProtocolNotify().
> +  @param[out]  Interface        On return, a pointer to the first interface that
> matches Protocol and
> +                                Registration.
> +
> +  @retval EFI_SUCCESS           A protocol instance matching Protocol was
> found and returned in
> +                                Interface.
> +  @retval EFI_NOT_FOUND         No protocol instances were found that
> match Protocol and
> +                                Registration.
> +  @retval EFI_INVALID_PARAMETER Interface is NULL.
> +                                Protocol is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InternalLocateProtocol (
> +  IN  EFI_GUID  *Protocol,
> +  IN  VOID      *Registration, OPTIONAL
> +  OUT VOID      **Interface
> +  )
> +{
> +  return gMmst->MmLocateProtocol (Protocol, Registration, Interface); }
> diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibT
> raditional.c
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibT
> raditional.c
> new file mode 100644
> index 000000000000..6b3a7c6051c5
> --- /dev/null
> +++
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibT
> ra
> +++ ditional.c
> @@ -0,0 +1,39 @@
> +/** @file
> +  Abstraction layer for SMM service table used by SMM
> ReportStatusCodeLib.
> +
> +  Copyright (c) Microsoft Corporation.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <PiMm.h>
> +
> +#include <Library/SmmServicesTableLib.h>
> +
> +/**
> +  Returns the first protocol instance that matches the given protocol.
> +
> +  @param[in]  Protocol          Provides the protocol to search for.
> +  @param[in]  Registration      Optional registration key returned from
> +                                RegisterProtocolNotify().
> +  @param[out]  Interface        On return, a pointer to the first interface that
> matches Protocol and
> +                                Registration.
> +
> +  @retval EFI_SUCCESS           A protocol instance matching Protocol was
> found and returned in
> +                                Interface.
> +  @retval EFI_NOT_FOUND         No protocol instances were found that
> match Protocol and
> +                                Registration.
> +  @retval EFI_INVALID_PARAMETER Interface is NULL.
> +                                Protocol is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InternalLocateProtocol (
> +  IN  EFI_GUID  *Protocol,
> +  IN  VOID      *Registration, OPTIONAL
> +  OUT VOID      **Interface
> +  )
> +{
> +  return gSmst->SmmLocateProtocol (Protocol, Registration, Interface);
> +}
> diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.
> h
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.
> h
> new file mode 100644
> index 000000000000..9a16741e64f6
> --- /dev/null
> +++
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.
> h
> @@ -0,0 +1,37 @@
> +/** @file
> +  Report Status Code Library for MM Phase.
> +
> +  Copyright (c) 2009 - 2018, Intel Corporation. All rights
> + reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _MM_RSC_LIB_H_
> +#define _MM_RSC_LIB_H_
> +
> +/**
> +  Returns the first protocol instance that matches the given protocol.
> +
> +  @param[in]  Protocol          Provides the protocol to search for.
> +  @param[in]  Registration      Optional registration key returned from
> +                                RegisterProtocolNotify().
> +  @param[out]  Interface        On return, a pointer to the first interface that
> matches Protocol and
> +                                Registration.
> +
> +  @retval EFI_SUCCESS           A protocol instance matching Protocol was
> found and returned in
> +                                Interface.
> +  @retval EFI_NOT_FOUND         No protocol instances were found that
> match Protocol and
> +                                Registration.
> +  @retval EFI_INVALID_PARAMETER Interface is NULL.
> +                                Protocol is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InternalLocateProtocol (
> +  IN  EFI_GUID  *Protocol,
> +  IN  VOID      *Registration, OPTIONAL
> +  OUT VOID      **Interface
> +  );
> +
> +#endif // _MM_RSC_LIB_H_
> diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib.inf
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib.inf
> index 72496bfababd..02dce09a199d 100644
> ---
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib.inf
> +++
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib
> +++ .inf
> @@ -28,6 +28,8 @@ [Defines]
>
>  [Sources]
>    ReportStatusCodeLib.c
> +  ReportStatusCodeLib.h
> +  ReportStatusCodeLibTraditional.c
>
>  [Packages]
>    MdePkg/MdePkg.dec
> @@ -45,7 +47,7 @@ [Guids]
>    gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_CONSUMES
> ## UNDEFINED
>
>  [Protocols]
> -  gEfiSmmStatusCodeProtocolGuid                 ## CONSUMES
> +  gEfiMmStatusCodeProtocolGuid                  ## CONSUMES
>
>  [Pcd]
>    gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask  ##
> CONSUMES diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib.inf
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReport
> StatusCodeLib.inf
> similarity index 64%
> copy from
> MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi
> b.inf
> copy to
> MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportSt
> atusCodeLib.inf
> index 72496bfababd..11ecc67fc4fa 100644
> ---
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib.inf
> +++
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReport
> Stat
> +++ usCodeLib.inf
> @@ -12,13 +12,12 @@
>
>  [Defines]
>    INF_VERSION                    = 0x00010005
> -  BASE_NAME                      = SmmReportStatusCodeLib
> -  MODULE_UNI_FILE                = SmmReportStatusCodeLib.uni
> -  FILE_GUID                      = 67089D19-B3D6-4d9e-A0EB-FEDC1F83A1EE
> -  MODULE_TYPE                    = DXE_SMM_DRIVER
> +  BASE_NAME                      = StandaloneMmReportStatusCodeLib
> +  FILE_GUID                      = 17C7FC8C-8C5D-497E-9C0E-C21255B30E04
> +  MODULE_TYPE                    = MM_STANDALONE
>    VERSION_STRING                 = 1.0
> -  PI_SPECIFICATION_VERSION       = 0x0001000A
> -  LIBRARY_CLASS                  = ReportStatusCodeLib|DXE_SMM_DRIVER
> SMM_CORE
> +  PI_SPECIFICATION_VERSION       = 0x00010032
> +  LIBRARY_CLASS                  = ReportStatusCodeLib|MM_STANDALONE
>
>  #
>  # The following information is for reference only and not required by the
> build tools.
> @@ -28,6 +27,8 @@ [Defines]
>
>  [Sources]
>    ReportStatusCodeLib.c
> +  ReportStatusCodeLib.h
> +  ReportStatusCodeLibStandaloneMm.c
>
>  [Packages]
>    MdePkg/MdePkg.dec
> @@ -36,7 +37,7 @@ [Packages]
>  [LibraryClasses]
>    PcdLib
>    BaseMemoryLib
> -  SmmServicesTableLib
> +  MmServicesTableLib
>    DebugLib
>    MemoryAllocationLib
>
> @@ -45,7 +46,7 @@ [Guids]
>    gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_CONSUMES
> ## UNDEFINED
>
>  [Protocols]
> -  gEfiSmmStatusCodeProtocolGuid                 ## CONSUMES
> +  gEfiMmStatusCodeProtocolGuid                  ## CONSUMES
>
>  [Pcd]
>    gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask  ##
> CONSUMES diff --git a/MdeModulePkg/MdeModulePkg.dsc
> b/MdeModulePkg/MdeModulePkg.dsc index cd91a70b4fdd..05bf5fe08094
> 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -473,6 +473,7 @@ [Components.IA32, Components.X64]
>    }
>
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.i
> nf
>
> MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi
> b.inf
> +
> +
> MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportSt
> atusCo
> + deLib.inf
>
> MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSm
> m.inf
>
> MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCod
> eRouterSmm.inf
>    MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
> --
> 2.28.0.windows.1
>
>
>
>
>