From nobody Sat May 4 20:25:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72464+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72464+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1614914115; cv=none; d=zohomail.com; s=zohoarc; b=DG9JLUsQ5MqOcUclIrLq83igKZtDwqEhTwErI10LI5cy3tnVFQwxGMdVJtIP8YMbyjfmipm9yzxzJ2X7VdsCPfq+nysm2xuudtDq82cnQt297BvzO1UYFRxdcn9nuGr0FSJZ5OAyPl9fMDdVSI62VB6savc3PPPPZYZz84dbsto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614914115; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=AsASAYtjqc/3ATQXE1OUi4ybdHopT5ca6AV7ZJDeH2A=; b=ElZCAM1xSH/egvLli/DxhaTuJep+XK0YfTOGQKwG+5ZxcretYZEtH+GowWiKdyM1cH5YgWWV412jJhPTT5q+XT/XwS4ew1SmmSu+AgBpYywSllNPyvon2nkpIQeyO4e1pgzdlmVKpgF+2Siem+2aAkZPAlYlXZZC0rptdGlC0tU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72464+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1614914115010308.0394585276084; Thu, 4 Mar 2021 19:15:15 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id vgbcYY1788612x1XVuU1jOIt; Thu, 04 Mar 2021 19:15:14 -0800 X-Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web10.7165.1614914112516581824 for ; Thu, 04 Mar 2021 19:15:13 -0800 X-Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Fri, 05 Mar 2021 11:15:08 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , , "'Michael D Kinney'" , "'Zhiguang Liu'" Cc: "'Hao A Wu'" , "'Jiewen Yao'" , "'Laszlo Ersek'" References: <20210304185814.1652-1-kun.q@outlook.com>, In-Reply-To: Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIIHY1IDEvN10gTWRlUGtnOiBNbVVuYmxvY2tNZW1vcnlMaWI6IEFkZGVkIGRlZmluaXRpb24gYW5kIG51bGwgaW5zdGFuY2U=?= Date: Fri, 5 Mar 2021 11:15:10 +0800 Message-ID: <007c01d7116d$c056a410$4103ec30$@byosoft.com.cn> MIME-Version: 1.0 Thread-Index: AQIL/CqWen5BQylgHygvr8i7xBCNtgJ7TPuxAHz2FBSp8wJK4A== Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,gaoliming@byosoft.com.cn X-Gm-Message-State: omt2LLel4VsEFYVZLqKe1EmTx1787277AA= Content-Type: multipart/alternative; boundary="----=_NextPart_000_007D_01D711B0.CE7BDFE0" Content-Language: zh-cn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1614914114; bh=Ot+ytpV/yjvdbGrIqsLkuwUr4QB8D6BGEvSfYGt8/ds=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=hvSBIACImkuL+Y2MLs4LDDCiXTzTYkTiBmXg0C5JShJ9rT9YcHAHly0YRhuar4oSUuZ zUc4qv3AJu1EK3tluLhWfUJwQhkSdQIdptefi92LGLVRDfA7oVl4wrKBY0wGZKuIDJUrr nnWC3+TcjQrlDlHl3R20Ku4i4fQ9A/mSf0U= X-ZohoMail-DKIM: pass (identity @groups.io) ------=_NextPart_000_007D_01D711B0.CE7BDFE0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Kun: I have one minor comment. Please see it.=20 =20 Thanks Liming =E5=8F=91=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io = =E4=BB=A3=E8=A1=A8 Kun Qin =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2021=E5=B9=B43=E6=9C=885=E6=97=A5 8:23 =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io; Michael D Kinney ; gaoliming ; Zhiguang Liu =E6=8A=84=E9=80=81: Hao A Wu ; Jiewen Yao ; Laszlo Ersek =E4=B8=BB=E9=A2=98: Re: [edk2-devel] [PATCH v5 1/7] MdePkg: MmUnblockMemory= Lib: Added definition and null instance =20 Hi Mike/Liming/Zhiguang, =20 Could you please review this patch and let me know if you have any feedback on this patch? Any input is appreciated. =20 Regards, Kun =20 From: Kun Qin =20 Sent: Thursday, March 4, 2021 10:58 To: devel@edk2.groups.io =20 Cc: Michael D Kinney ; Liming Gao ; Zhiguang Liu ; Hao A Wu ; Jiewen Yao ; Laszlo Ersek =20 Subject: [PATCH v5 1/7] MdePkg: MmUnblockMemoryLib: Added definition and null instance =20 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3168 This interface provides an abstration layer to allow MM modules to access requested areas that are outside of MMRAM. On MM model that blocks all non-MMRAM accesses, areas requested through this API will be mapped or unblocked for accessibility inside MM environment. For MM modules that need to access regions outside of MMRAMs, the agents that set up these regions are responsible for invoking this API in order for these memory areas to be accessible from inside MM. Example usages: 1. To enable runtime cache feature for variable service, Variable MM module will need to access the allocated runtime buffer. Thus the agent sets up these buffers, VariableSmmRuntimeDxe, will need to invoke this API to make these regions accessible by Variable MM. 2. For TPM ACPI table to communicate to physical presence handler, the corresponding NVS region has to be accessible from inside MM. Once the NVS region are assigned, it needs to be unblocked thourgh this API. Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu > Cc: Hao A Wu > Cc: Jiewen Yao > Cc: Laszlo Ersek > Signed-off-by: Kun Qin > --- Notes: v5: - Downgraded data types from EFI_* to RETURN_*. [Laszlo] v4: - Added more commit message [Laszlo] - Added UNI file [Hao] v3: - Move interface to MdePkg [Hao, Liming, Jiewen] - Remove Dxe prefix [Jiewen] v2: - Resend with practical usage. No change [Hao] MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c | 44 ++++++++++++++++++++ MdePkg/Include/Library/MmUnblockMemoryLib.h | 44 ++++++++++++++++++++ MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf | 34 +++++++++++++++ MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni | 21 ++++++++++ MdePkg/MdePkg.dec | 5 +++ MdePkg/MdePkg.dsc | 1 + 6 files changed, 149 insertions(+) diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c new file mode 100644 index 000000000000..b205c9122df8 --- /dev/null +++ b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c @@ -0,0 +1,44 @@ +/** @file + Null instance of MM Unblock Page Library. + + This library provides an interface to request non-MMRAM pages to be mapped/unblocked + from inside MM environment. + + For MM modules that need to access regions outside of MMRAMs, the agents that set up + these regions are responsible for invoking this API in order for these memory areas + to be accessed from inside MM. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + This API provides a way to unblock certain data pages to be accessible inside MM environment. + + @param UnblockAddress The address of buffer caller requests to unblock, the address + has to be page aligned. + @param NumberOfPages The number of pages requested to be unblocked from MM + environment. + + @retval RETURN_SUCCESS The request goes through successfully. + @retval RETURN_NOT_AVAILABLE_YET The requested functionality is not produced yet. + @retval RETURN_UNSUPPORTED The requested functionality is not supported on current platform. + @retval RETURN_SECURITY_VIOLATION The requested address failed to pass security check for + unblocking. + @retval RETURN_INVALID_PARAMETER Input address either NULL pointer or not page aligned. + @retval RETURN_ACCESS_DENIED The request is rejected due to system has passed certain boot + phase. + +**/ +RETURN_STATUS +EFIAPI +MmUnblockMemoryRequest ( + IN PHYSICAL_ADDRESS UnblockAddress, + IN UINT64 NumberOfPages + ) +{ + return RETURN_UNSUPPORTED; +} diff --git a/MdePkg/Include/Library/MmUnblockMemoryLib.h b/MdePkg/Include/Library/MmUnblockMemoryLib.h new file mode 100644 index 000000000000..00fab530a3bc --- /dev/null +++ b/MdePkg/Include/Library/MmUnblockMemoryLib.h @@ -0,0 +1,44 @@ +/** @file + MM Unblock Memory Library Interface. + + This library provides an interface to request non-MMRAM pages to be mapped/unblocked + from inside MM environment. + + For MM modules that need to access regions outside of MMRAMs, the agents that set up + these regions are responsible for invoking this API in order for these memory areas + to be accessed from inside MM. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef MM_UNBLOCK_MEMORY_LIB_H_ +#define MM_UNBLOCK_MEMORY_LIB_H_ + +/** + This API provides a way to unblock certain data pages to be accessible inside MM environment. + + @param UnblockAddress The address of buffer caller requests to unblock, the address + has to be page aligned. + @param NumberOfPages The number of pages requested to be unblocked from MM + environment. + + @retval RETURN_SUCCESS The request goes through successfully. + @retval RETURN_NOT_AVAILABLE_YET The requested functionality is not produced yet. + @retval RETURN_UNSUPPORTED The requested functionality is not supported on current platform. + @retval RETURN_SECURITY_VIOLATION The requested address failed to pass security check for + unblocking. + @retval RETURN_INVALID_PARAMETER Input address either NULL pointer or not page aligned. + @retval RETURN_ACCESS_DENIED The request is rejected due to system has passed certain boot + phase. + +**/ +RETURN_STATUS +EFIAPI +MmUnblockMemoryRequest ( + IN PHYSICAL_ADDRESS UnblockAddress, + IN UINT64 NumberOfPages +); + +#endif // MM_UNBLOCK_MEMORY_LIB_H_ diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf new file mode 100644 index 000000000000..8ecb767ff7bd --- /dev/null +++ b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf @@ -0,0 +1,34 @@ +## @file +# Null instance of MM Unblock Page Library. +# +# This library provides an interface to request non-MMRAM pages to be mapped/unblocked +# from inside MM environment. +# +# For MM modules that need to access regions outside of MMRAMs, the agents that set up +# these regions are responsible for invoking this API in order for these memory areas +# to be accessed from inside MM. +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D MmUnblockMemoryLibNull + MODULE_UNI_FILE =3D MmUnblockMemoryLibNull.uni + FILE_GUID =3D 9E890F68-5C95-4C31-95DD-59E6286F85EA + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D MmUnblockMemoryLib + +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + MmUnblockMemoryLibNull.c + +[Packages] + MdePkg/MdePkg.dec diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni new file mode 100644 index 000000000000..d7f2709a3dce --- /dev/null +++ b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni @@ -0,0 +1,21 @@ +// /** @file +// Null instance of MM Unblock Page Library. +// +// This library provides an interface to request non-MMRAM pages to be mapped/unblocked +// from inside MM environment. +// +// For MM modules that need to access regions outside of MMRAMs, the agents that set up +// these regions are responsible for invoking this API in order for these memory areas +// to be accessed from inside MM. +// +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Null instance of MM Unblock Page Library." + +#string STR_MODULE_DESCRIPTION #language en-US "This library provides an interface to request non-MMRAM pages to be mapped/unblocked from inside MM environment.\n" + "For MM modules that need to access regions outside of MMRAMs, the agents that set up these regions are responsible for invoking this API in order for these memory areas to be accessed from inside MM." + diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 3928db65d188..32a9e009c813 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -257,6 +257,11 @@ [LibraryClasses] # UnitTestHostBaseLib|Test/UnitTest/Include/Library/UnitTestHostBaseLib.h =20 + ## @libraryclass This library provides an interface for DXE drivers to request MM environment + # to map/unblock a memory region for accessibility inside MM. [Liming] Is this library for DXE driver only? If not, please update this comments.=20 Other part is good to me. Reviewed-by: Liming Gao =20 Thanks Liming + # + MmUnblockMemoryLib|Include/Library/MmUnblockMemoryLib.h + [LibraryClasses.IA32, LibraryClasses.X64] ## @libraryclass Abstracts both S/W SMI generation and detection. ## diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index ce009086815f..79629e3f93ba 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -168,6 +168,7 @@ [Components.IA32, Components.X64] MdePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf MdePkg/Library/SmiHandlerProfileLibNull/SmiHandlerProfileLibNull.inf MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf + MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf =20 [Components.EBC] MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf --=20 2.30.0.windows.1 =20 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#72464): https://edk2.groups.io/g/devel/message/72464 Mute This Topic: https://groups.io/mt/81094937/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- ------=_NextPart_000_007D_01D711B0.CE7BDFE0 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
Kun:

 I have one= minor comment. Please see it.

<= span lang=3DEN-US style=3D'font-size:10.5pt;font-family:=B5=C8=CF=DF'>=  

Thanks

Liming

= =B7=A2=BC=FE=C8=CB: devel@edk2.groups.io <devel@edk2.groups.io> =B4=FA=B1=ED Kun Qin
=B7=A2=CB=CD=CA=B1=BC=E4:<= /span> 2021=C4=EA3= = =D4=C25=C8=D5 8:23
= =CA=D5=BC=FE=C8=CB: dev= el@edk2.groups.io; Michael D Kinney <michael.d.kinney@intel.com>; gao= liming <gaoliming@byosoft.com.cn>; Zhiguang Liu <zhiguang.liu@inte= l.com>
=B3=AD=CB=CD: Hao A Wu <hao.a.wu@intel.com>; Jiewen Yao <jiewen.yao@i= ntel.com>; Laszlo Ersek <lersek@redhat.com>
=D6=F7=CC= = =E2: Re: [edk2-devel] [PA= TCH v5 1/7] MdePkg: MmUnblockMemoryLib: Added definition and null instance<= o:p>

 

Hi= Mike/Liming/Zhiguang,

 

Could you please review this patch and let me know if you have any feedb= ack on this patch? Any input is appreciated.

 

Regards,

Kun

 

From: Kun Qin
Sent: Thursday, March 4, 2021 10:58
= To: devel@edk2.groups.io=
Cc: Michael D Kinn= ey; Liming Gao; Zhiguang Liu; Hao A Wu; Jiew= en Yao; Laszlo Ersek
Sub= ject: [PATCH v5 1/7] MdePkg: MmUnblockMemoryLib: Added definition and n= ull instance

 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3= 168

This interface provides an abstration layer to allow MM modu= les to access
requested areas that are outside of MMRAM. On MM model tha= t blocks all
non-MMRAM accesses, areas requested through this API will b= e mapped or
unblocked for accessibility inside MM environment.

Fo= r MM modules that need to access regions outside of MMRAMs, the agents
t= hat set up these regions are responsible for invoking this API in order
= for these memory areas to be accessible from inside MM.

Example usag= es:
1. To enable runtime cache feature for variable service, Variable MM=
module will need to access the allocated runtime buffer. Thus the agent=
sets up these buffers, VariableSmmRuntimeDxe, will need to invoke this<= br>API to make these regions accessible by Variable MM.
2. For TPM ACPI = table to communicate to physical presence handler, the
corresponding NVS= region has to be accessible from inside MM. Once the
NVS region are ass= igned, it needs to be unblocked thourgh this API.

Cc: Michael D Kinn= ey <michael.d.kinney@intel= .com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Hao A Wu = <hao.a.wu@intel.com>
Cc:= Jiewen Yao <jiewen.yao@intel.co= m>
Cc: Laszlo Ersek <lers= ek@redhat.com>

Signed-off-by: Kun Qin <kun.q@outlook.com>
---

Notes:
 &= nbsp;  v5:
    - Downgraded data types from EFI_* to= RETURN_*. [Laszlo]
   
    v4:
&nb= sp;   - Added more commit message [Laszlo]
    = - Added UNI file [Hao]
   
    v3:
=     - Move interface to MdePkg [Hao, Liming, Jiewen]
&nbs= p;   - Remove Dxe prefix [Jiewen]
   
 = ;   v2:
    - Resend with practical usage. No c= hange [Hao]

 MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryL= ibNull.c   | 44 ++++++++++++++++++++
 MdePkg/Include/Libr= ary/MmUnblockMemoryLib.h        &nb= sp;         | 44 ++++++++++++++++++= ++
 MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf | = 34 +++++++++++++++
 MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemo= ryLibNull.uni | 21 ++++++++++
 MdePkg/MdePkg.dec   &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;   |  5 +++
 MdePkg/MdePkg.dsc   &n= bsp;            = ;            &n= bsp;            = ;   |  1 +
 6 files changed, 149 insertions(+)
diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c b= /MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c
new file mod= e 100644
index 000000000000..b205c9122df8
--- /dev/null
+++ b/MdeP= kg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c
@@ -0,0 +1,44 @@<= br>+/** @file
+  Null instance of MM Unblock Page Library.
+
= +  This library provides an interface to request non-MMRAM pages to be= mapped/unblocked
+  from inside MM environment.
+
+  Fo= r MM modules that need to access regions outside of MMRAMs, the agents that= set up
+  these regions are responsible for invoking this API in o= rder for these memory areas
+  to be accessed from inside MM.
+<= br>+  Copyright (c) Microsoft Corporation.
+  SPDX-License-Ide= ntifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h><= br>+
+/**
+  This API provides a way to unblock certain data pag= es to be accessible inside MM environment.
+
+  @param  Unb= lockAddress          &nbs= p;   The address of buffer caller requests to unblock, the addres= s
+           &nb= sp;            =             &nb= sp; has to be page aligned.
+  @param  NumberOfPages &nbs= p;             = The number of pages requested to be unblocked from MM
+   = ;            &n= bsp;            = ;          environment.
++  @retval RETURN_SUCCESS       &= nbsp;      The request goes through successfully.<= br>+  @retval RETURN_NOT_AVAILABLE_YET    The requested= functionality is not produced yet.
+  @retval RETURN_UNSUPPORTED&n= bsp;         The requested function= ality is not supported on current platform.
+  @retval RETURN_SECUR= ITY_VIOLATION   The requested address failed to pass security che= ck for
+          &nbs= p;            &= nbsp;           &nbs= p;  unblocking.
+  @retval RETURN_INVALID_PARAMETER  = ;  Input address either NULL pointer or not page aligned.
+  @= retval RETURN_ACCESS_DENIED        The r= equest is rejected due to system has passed certain boot
+  &n= bsp;            = ;            &n= bsp;          phase.
+
+= **/
+RETURN_STATUS
+EFIAPI
+MmUnblockMemoryRequest (
+  IN= PHYSICAL_ADDRESS       UnblockAddress,
+&= nbsp; IN UINT64          =        NumberOfPages
+  )
+{
+&= nbsp; return RETURN_UNSUPPORTED;
+}
diff --git a/MdePkg/Include/Libra= ry/MmUnblockMemoryLib.h b/MdePkg/Include/Library/MmUnblockMemoryLib.h
ne= w file mode 100644
index 000000000000..00fab530a3bc
--- /dev/null
= +++ b/MdePkg/Include/Library/MmUnblockMemoryLib.h
@@ -0,0 +1,44 @@
+/= ** @file
+  MM Unblock Memory Library Interface.
+
+  Th= is library provides an interface to request non-MMRAM pages to be mapped/un= blocked
+  from inside MM environment.
+
+  For MM modul= es that need to access regions outside of MMRAMs, the agents that set up+  these regions are responsible for invoking this API in order for t= hese memory areas
+  to be accessed from inside MM.
+
+ = Copyright (c) Microsoft Corporation.
+  SPDX-License-Identifier: B= SD-2-Clause-Patent
+
+**/
+
+#ifndef MM_UNBLOCK_MEMORY_LIB_H_+#define MM_UNBLOCK_MEMORY_LIB_H_
+
+/**
+  This API provid= es a way to unblock certain data pages to be accessible inside MM environme= nt.
+
+  @param  UnblockAddress    &nbs= p;         The address of buffer ca= ller requests to unblock, the address
+     &nb= sp;            =             &nb= sp;       has to be page aligned.
+  = @param  NumberOfPages        &= nbsp;      The number of pages requested to be unb= locked from MM
+         &n= bsp;            = ;            &n= bsp;   environment.
+
+  @retval RETURN_SUCCESS &= nbsp;            The= request goes through successfully.
+  @retval RETURN_NOT_AVAILABLE= _YET    The requested functionality is not produced yet.
= +  @retval RETURN_UNSUPPORTED       = ;   The requested functionality is not supported on current platf= orm.
+  @retval RETURN_SECURITY_VIOLATION   The requested= address failed to pass security check for
+    &nbs= p;            &= nbsp;           &nbs= p;        unblocking.
+  @retval= RETURN_INVALID_PARAMETER    Input address either NULL point= er or not page aligned.
+  @retval RETURN_ACCESS_DENIED  =       The request is rejected due to system has pa= ssed certain boot
+         = ;            &n= bsp;            = ;    phase.
+
+**/
+RETURN_STATUS
+EFIAPI
+Mm= UnblockMemoryRequest (
+  IN PHYSICAL_ADDRESS   &nbs= p;   UnblockAddress,
+  IN UINT64    =              Nu= mberOfPages
+);
+
+#endif // MM_UNBLOCK_MEMORY_LIB_H_
diff --gi= t a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf b/MdePkg/L= ibrary/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
new file mode 10064= 4
index 000000000000..8ecb767ff7bd
--- /dev/null
+++ b/MdePkg/Libr= ary/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
@@ -0,0 +1,34 @@
+#= # @file
+#  Null instance of MM Unblock Page Library.
+#
+#&n= bsp; This library provides an interface to request non-MMRAM pages to be ma= pped/unblocked
+#  from inside MM environment.
+#
+#  Fo= r MM modules that need to access regions outside of MMRAMs, the agents that= set up
+#  these regions are responsible for invoking this API in = order for these memory areas
+#  to be accessed from inside MM.
= +#
+#  Copyright (c) Microsoft Corporation.
+#  SPDX-Licens= e-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
= +  INF_VERSION         &n= bsp;          =3D 0x0001001B+  BASE_NAME         &n= bsp;            =3D = MmUnblockMemoryLibNull
+  MODULE_UNI_FILE    &n= bsp;           =3D MmUnbl= ockMemoryLibNull.uni
+  FILE_GUID     &nbs= p;            &= nbsp;   =3D 9E890F68-5C95-4C31-95DD-59E6286F85EA
+  MODUL= E_TYPE           &nb= sp;        =3D BASE
+  VERSION_S= TRING           &nbs= p;     =3D 1.0
+  LIBRARY_CLASS  &nbs= p;            &= nbsp;  =3D MmUnblockMemoryLib
+
+#
+#  VALID_ARCHITECTUR= ES           =3D IA32 X64=
+#
+
+[Sources]
+  MmUnblockMemoryLibNull.c
+
+[Pac= kages]
+  MdePkg/MdePkg.dec
diff --git a/MdePkg/Library/MmUnbloc= kMemoryLib/MmUnblockMemoryLibNull.uni b/MdePkg/Library/MmUnblockMemoryLib/M= mUnblockMemoryLibNull.uni
new file mode 100644
index 000000000000..d7= f2709a3dce
--- /dev/null
+++ b/MdePkg/Library/MmUnblockMemoryLib/MmUn= blockMemoryLibNull.uni
@@ -0,0 +1,21 @@
+// /** @file
+// Null ins= tance of MM Unblock Page Library.
+//
+// This library provides an in= terface to request non-MMRAM pages to be mapped/unblocked
+// from insid= e MM environment.
+//
+// For MM modules that need to access regions = outside of MMRAMs, the agents that set up
+// these regions are responsi= ble for invoking this API in order for these memory areas
+// to be acce= ssed from inside MM.
+//
+// Copyright (c) Microsoft Corporation.
= +// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
= +
+#string STR_MODULE_ABSTRACT       =       #language en-US "Null instance of MM Un= block Page Library."
+
+#string STR_MODULE_DESCRIPTION &nbs= p;        #language en-US "This lib= rary provides an interface to request non-MMRAM pages to be mapped/unblocke= d from inside MM environment.\n"
+     &nb= sp;            =             &nb= sp;            =              &q= uot;For MM modules that need to access regions outside of MMRAMs, the agent= s that set up these regions are responsible for invoking this API in order = for these memory areas to be accessed from inside MM."
+
diff --= git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 3928db65d188..32a9e009= c813 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -25= 7,6 +257,11 @@ [LibraryClasses]
   #
   UnitTestH= ostBaseLib|Test/UnitTest/Include/Library/UnitTestHostBaseLib.h
 +  ##  @libraryclass  This library provides an interface fo= r DXE drivers to request MM environment
+  #   to map/unb= lock a memory region for accessibility inside MM.
[Liming] Is this libra= ry for DXE driver only? If not, please update this comments.

Other part is good to me. Reviewed-by: Liming Gao <gaoliming@byosoft= .com.cn>

 

Thanks

Liming

+  #
+  MmUnblockMemoryLib|Include/L= ibrary/MmUnblockMemoryLib.h
+

 [Libr= aryClasses.IA32, LibraryClasses.X64]
   ##  @libraryclass=   Abstracts both S/W SMI generation and detection.
   ##<= br>diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index ce009086815f= ..79629e3f93ba 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc=
@@ -168,6 +168,7 @@ [Components.IA32, Components.X64]
   M= dePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf
   MdePkg/= Library/SmiHandlerProfileLibNull/SmiHandlerProfileLibNull.inf
 &nbs= p; MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
+  MdeP= kg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
 
 = ;[Components.EBC]
   MdePkg/Library/BaseIoLibIntrinsic/BaseIoL= ibIntrinsic.inf
--
2.30.0.windows.1

 

_._,_._,_

Gr= oups.io Links:

You receive all messages sent to this group.

Vie= w/Reply Online (#72464) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [importer@patchew.org]

_._,_._,_
=20 ------=_NextPart_000_007D_01D711B0.CE7BDFE0--