public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Hao A" <hao.a.wu@intel.com>
To: Kun Qin <kun.q@outlook.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Wang, Jian J" <jian.j.wang@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>
Subject: Re: [PATCH v3 2/7] MdeModulePkg: VariableSmmRuntimeDxe: Added request unblock memory interface
Date: Mon, 1 Mar 2021 02:03:04 +0000	[thread overview]
Message-ID: <BN8PR11MB366621331D1A5F9C7CDF1854CA9A9@BN8PR11MB3666.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MWHPR06MB3102B50F7C119B5CDA943234F39D9@MWHPR06MB3102.namprd06.prod.outlook.com>

> -----Original Message-----
> From: Kun Qin <kun.q@outlook.com>
> Sent: Saturday, February 27, 2021 6:52 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Liming Gao <gaoliming@byosoft.com.cn>
> Subject: [PATCH v3 2/7] MdeModulePkg: VariableSmmRuntimeDxe: Added
> request unblock memory interface
> 
> This changes added usage of MmUnblockMemoryLib to explicitly request
> runtime cache regions(and its indicators) to be accessible from MM
> environment when PcdEnableVariableRuntimeCache is enabled. It will bring
> in compatibility with architectures that supports full memory blockage inside
> MM.
> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> 
> Signed-off-by: Kun Qin <kun.q@outlook.com>
> ---
> 
> Notes:
>     v3:
>     - Removed Dxe prefix to match interface change. [Jiewen]
> 
>     v2:
>     - Newly added in v2.
> 
> 
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.
> c   | 42 ++++++++++++++++++++
>  MdeModulePkg/MdeModulePkg.dsc                                        |  1 +
> 
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.i
> nf |  1 +
>  3 files changed, 44 insertions(+)
> 
> diff --git
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx
> e.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx
> e.c
> index c47e614d81f4..a166d284dfe4 100644
> ---
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx
> e.c
> +++
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx
> e.c
> @@ -35,6 +35,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent  #include
> <Library/DebugLib.h>  #include <Library/UefiLib.h>  #include
> <Library/BaseLib.h>
> +#include <Library/MmUnblockMemoryLib.h>
> 
>  #include <Guid/EventGroup.h>
>  #include <Guid/SmmVariableCommon.h>
> @@ -165,6 +166,7 @@ InitVariableCache (
>    )
>  {
>    VARIABLE_STORE_HEADER   *VariableCacheStorePtr;
> +  EFI_STATUS              Status;
> 
>    if (TotalVariableCacheSize == NULL) {
>      return EFI_INVALID_PARAMETER;
> @@ -186,6 +188,18 @@ InitVariableCache (
>    if (*VariableCacheBuffer == NULL) {
>      return EFI_OUT_OF_RESOURCES;
>    }
> +
> +  //
> +  // Request to unblock the newly allocated cache region to be
> + accessible from inside MM  //  Status = MmUnblockMemoryRequest (
> +            (EFI_PHYSICAL_ADDRESS) (UINTN) *VariableCacheBuffer,
> +            EFI_SIZE_TO_PAGES (*TotalVariableCacheSize)
> +            );
> +  if (Status != EFI_UNSUPPORTED && EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
>    VariableCacheStorePtr = *VariableCacheBuffer;
>    SetMem32 ((VOID *) VariableCacheStorePtr, *TotalVariableCacheSize,
> (UINT32) 0xFFFFFFFF);
> 
> @@ -1536,6 +1550,34 @@ SendRuntimeVariableCacheContextToSmm (
>    SmmRuntimeVarCacheContext->ReadLock =
> &mVariableRuntimeCacheReadLock;
>    SmmRuntimeVarCacheContext->HobFlushComplete =
> &mHobFlushComplete;
> 
> +  //
> +  // Request to unblock this region to be accessible from inside MM
> + environment  // These fields "should" be all on the same page, but just to
> be on the safe side...
> +  //
> +  Status = MmUnblockMemoryRequest (
> +            (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN)
> SmmRuntimeVarCacheContext->PendingUpdate - EFI_PAGE_SIZE + 1,
> EFI_PAGE_SIZE),
> +            EFI_SIZE_TO_PAGES (sizeof(mVariableRuntimeCachePendingUpdate))
> +            );
> +  if (Status != EFI_UNSUPPORTED && EFI_ERROR (Status)) {
> +    goto Done;
> +  }
> +
> +  Status = MmUnblockMemoryRequest (
> +            (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN)
> SmmRuntimeVarCacheContext->ReadLock - EFI_PAGE_SIZE + 1,
> EFI_PAGE_SIZE),
> +            EFI_SIZE_TO_PAGES (sizeof(mVariableRuntimeCacheReadLock))
> +            );
> +  if (Status != EFI_UNSUPPORTED && EFI_ERROR (Status)) {
> +    goto Done;
> +  }
> +
> +  Status = MmUnblockMemoryRequest (
> +            (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN)
> SmmRuntimeVarCacheContext->HobFlushComplete - EFI_PAGE_SIZE + 1,
> EFI_PAGE_SIZE),
> +            EFI_SIZE_TO_PAGES (sizeof(mHobFlushComplete))
> +            );
> +  if (Status != EFI_UNSUPPORTED && EFI_ERROR (Status)) {
> +    goto Done;
> +  }
> +


Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


>    //
>    // Send data to SMM.
>    //
> diff --git a/MdeModulePkg/MdeModulePkg.dsc
> b/MdeModulePkg/MdeModulePkg.dsc index 7ca4a1bb3080..9272da89a998
> 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -100,6 +100,7 @@ [LibraryClasses]
>    SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
> 
> DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLi
> bGraphics/DisplayUpdateProgressLibGraphics.inf
> 
> VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Va
> riablePolicyHelperLib.inf
> +
> +
> MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblo
> ckMemoryLi
> + bNull.inf
> 
>  [LibraryClasses.EBC.PEIM]
>    IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
> diff --git
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx
> e.inf
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx
> e.inf
> index b6dbc839e023..a0d8b2267e92 100644
> ---
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx
> e.inf
> +++
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx
> e.i
> +++ nf
> @@ -60,6 +60,7 @@ [LibraryClasses]
>    TpmMeasurementLib
>    SafeIntLib
>    PcdLib
> +  MmUnblockMemoryLib
> 
>  [Protocols]
>    gEfiVariableWriteArchProtocolGuid             ## PRODUCES
> --
> 2.30.0.windows.1


  reply	other threads:[~2021-03-01  2:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210226225158.1378-1-kun.q@outlook.com>
2021-02-26 22:51 ` [PATCH v3 1/7] MdePkg: MmUnblockMemoryLib: Added definition and null instance Kun Qin
2021-03-01  2:05   ` Wu, Hao A
2021-03-01  8:58     ` Kun Qin
2021-03-01 16:40   ` [edk2-devel] " Laszlo Ersek
2021-03-01 19:03     ` Kun Qin
2021-03-02  8:39       ` Laszlo Ersek
2021-02-26 22:51 ` [PATCH v3 2/7] MdeModulePkg: VariableSmmRuntimeDxe: Added request unblock memory interface Kun Qin
2021-03-01  2:03   ` Wu, Hao A [this message]
2021-02-26 22:51 ` [PATCH v3 3/7] OvmfPkg: CI Build: Added new library for VariableSmmRuntimeDxe Kun Qin
2021-03-01 16:46   ` [edk2-devel] " Laszlo Ersek
2021-03-01 19:31     ` Laszlo Ersek
2021-03-01 19:35       ` Kun Qin
2021-02-26 22:51 ` [PATCH v3 4/7] SecurityPkg: Tcg2Smm: Switching from gSmst to gMmst Kun Qin
2021-02-26 22:51 ` [PATCH v3 5/7] SecurityPkg: Tcg2Smm: Separate Tcg2Smm into 2 modules Kun Qin
2021-02-26 22:51 ` [PATCH v3 6/7] SecurityPkg: Tcg2Smm: Added support for Standalone Mm Kun Qin
2021-02-26 22:51 ` [PATCH v3 7/7] SecurityPkg: Tcg2Acpi: Added unblock memory interface for NVS region Kun Qin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BN8PR11MB366621331D1A5F9C7CDF1854CA9A9@BN8PR11MB3666.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox