From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.92.45.97]) by mx.groups.io with SMTP id smtpd.web11.5269.1614903786229554877 for ; Thu, 04 Mar 2021 16:23:06 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=SX18mbF6; spf=pass (domain: outlook.com, ip: 40.92.45.97, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kFF69PA4AUHKwZ8RfOWkw4wspqvomIKArgf4vTIx1i4gAr/E1f2F9RvFd92+voN5PPDzkNlYLdNEEFJl8TU1djPcgNiv7PHZam1YGU+kj4SHu5olP8LcfiWnWWh3bUVdFlFL953auz54G85SHJ74dh2RYTLIUb6emy/aMpewx+OyZuYnY59oj/trzo+Ra+FD5iwnYcwbN70rUqZEMg4ip4iJ8RgmL2+1sjzA6velQEvUG7pFnA+Z99pxK5tXNX5X3lfclyPIdX8j/f4w5y+9WsgIiujxpUbjr31TU9i1oyKhAQJEi1fAP+R+leXL53vs3/prN/auBAuUIijC6vWWJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MPAEK9ar401+ZPtERuRsQaSwyvsDfrMX38tWIkQQbHo=; b=PNfnaMN+1p2ABe0k/uiq5+zJFJLEAi/iYnkU/jlXn04L9hqiCm4vf3vLmsiTnro7KqQ06BqfMgzv/mWpcIT2Laa0fI+dEQr7BxPfBTXu50biL9mNhX9IpUQFGsowDsnH/RaLo1zXFF1v+/bYYWb4Gp5EKnsbvJZbWzUdSuwVancGYtIEXwm6+WbCS/cbM5OkjZ9AlPE8s8zxDD0qAHynFe5zsY37sQYaRnKa88jfflo0tmthwW+gUMKWum4mq1khfxZhTdfwc40QnLrbVdUjYrvzrdPHz5BFpgQ+Tb+RaNLVUiZkA3lxP0NsGf/96oTo/tT5jimo5zUMqXn0CIxJNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MPAEK9ar401+ZPtERuRsQaSwyvsDfrMX38tWIkQQbHo=; b=SX18mbF66RZzHcIKpxswoHrxSlq1ZJTH2a7kxbsHQ7tOxJf+a035oBPdmKVrvjin2qIrLkSslCWIJNRvzT0C4XnzvSMEIY/8moPemSny46sOQIDLBED8Qz4YwVLhb1Co8u8+pNT+1zu8XOzoqu18mv/nivvd20z1zNPzA1R5v/Xk0ldSi97nn6cXFR6xy3VvD557eOQZzHsxtbEjw229xdBeEtyLpBIEbCanVloDq0s2VFZi1KP993uhIDtFmXRJqoeAgMJRbjmn7RpbrcauYexwtTbvEWJxAlY0nwoa7gV8M3py5YnINey1uc7AKp5S7xiLzv2+uNonfVkFKPF9tA== Received: from BN3NAM04FT031.eop-NAM04.prod.protection.outlook.com (10.152.92.56) by BN3NAM04HT239.eop-NAM04.prod.protection.outlook.com (10.152.92.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Fri, 5 Mar 2021 00:23:03 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e4e::45) by BN3NAM04FT031.mail.protection.outlook.com (2a01:111:e400:7e4e::64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20 via Frontend Transport; Fri, 5 Mar 2021 00:23:03 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b%7]) with mapi id 15.20.3890.028; Fri, 5 Mar 2021 00:23:03 +0000 From: "Kun Qin" To: "devel@edk2.groups.io" , Michael D Kinney , gaoliming , Zhiguang Liu CC: Hao A Wu , Jiewen Yao , Laszlo Ersek Subject: Re: [PATCH v5 1/7] MdePkg: MmUnblockMemoryLib: Added definition and null instance Thread-Topic: [PATCH v5 1/7] MdePkg: MmUnblockMemoryLib: Added definition and null instance Thread-Index: AQHXEShe1TScOaJxikCweeb8j/8SGqp0iBUv Date: Fri, 5 Mar 2021 00:23:03 +0000 Message-ID: References: <20210304185814.1652-1-kun.q@outlook.com>, In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:925D96006FC5B27C0AD7828251D36181289A223BD3DBABE6CE27556848D16CA9;UpperCasedChecksum:415328AF82B764E35676FFB9D8D3E20FF8A53355CE9558776F6B0349018360E4;SizeAsReceived:7169;Count:44 x-tmn: [3mWaLpQ1ln1BtZw+oHEm0lVr3NRbBECP] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 01649d74-3869-4e39-2766-08d8df6cd73a x-ms-traffictypediagnostic: BN3NAM04HT239: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: zlnGBWGJdr1F9QwgDfQpWxnMlTogdafERkC81PCb6vdTKMoMAl7s1QI2SHTziMe8keYGKdVS7CDN7MK3P1AH+3LmpKgjITTLfP/QxkXzRHG3EEVFH1HrwveihL5dkv5IBHXQBp4pYAaqcKgxmtaAX+zG1yFPLqksLavo2FmlMVaL9JLpbbAHBPlkTgnDW4pFRe46pJ+zqS308ck690LbNjgmgudojfPUWmJ4wJSgX7jVQAsGdn39uRt3BZr2Aj6ra4+9ch9dTZM4wz60dv9l8d2j0zSb1iLNwuLqf3Hv3IuZkXRUmRfuwjIvl/st6RNijEgxvTTwtGKYzuRZz1oIUEGUP1LknbsrO5TnCj67CrKOZyRdDz/C7Q+Ez22ooDbFogj4SGcY+IZpDbvJbZatMehm7pZAGw4puKrUE0uZyRo/HZgXYBr0okGem8gQsShk x-ms-exchange-antispam-messagedata: xxeoaKnOCSv8A2ITmHoQ9fUEeoCn00mjgzr2dI3w33Q6kg6df7TmLk65asEy14vOqZD8FLsu+QYQ41TTa1sr1p5ao0Y8O0jelEeFZI4gQXVT5Es+AHjY7vRNaTe1paSXxCjA5e+DHy2aYYRqv4PHhQ== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: BN3NAM04FT031.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 01649d74-3869-4e39-2766-08d8df6cd73a X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2021 00:23:03.2270 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3NAM04HT239 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MWHPR06MB310285D87C90FB0CFCC36183F3969MWHPR06MB3102namp_" --_000_MWHPR06MB310285D87C90FB0CFCC36183F3969MWHPR06MB3102namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Mike/Liming/Zhiguang, Could you please review this patch and let me know if you have any feedback= 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 Kinney; Liming Gao; Zhiguang Liu; Hao= A Wu; Jiewen Yao; = Laszlo Ersek Subject: [PATCH v5 1/7] MdePkg: MmUnblockMemoryLib: Added definition and nu= ll instance 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/M= dePkg/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 mapp= ed/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 m= emory 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 i= nside MM environment. + + @param UnblockAddress The address of buffer caller request= s 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 successfull= y. + @retval RETURN_NOT_AVAILABLE_YET The requested functionality is not p= roduced yet. + @retval RETURN_UNSUPPORTED The requested functionality is not s= upported 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 syste= m 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/L= ibrary/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 mapp= ed/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 m= emory 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 i= nside MM environment. + + @param UnblockAddress The address of buffer caller request= s 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 successfull= y. + @retval RETURN_NOT_AVAILABLE_YET The requested functionality is not p= roduced yet. + @retval RETURN_UNSUPPORTED The requested functionality is not s= upported 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 syste= m 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 map= ped/unblocked +# from inside MM environment. +# +# 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. +# +# 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 map= ped/unblocked +// from inside MM environment. +// +// 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. +// +// 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 prov= ides an interface to request non-MMRAM pages to be mapped/unblocked from in= side MM environment.\n" + "For MM modules th= at need to access regions outside of MMRAMs, the agents that set up these r= egions are responsible for invoking this API in order for these memory area= s 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 + ## @libraryclass This library provides an interface for DXE drivers to= request MM environment + # to map/unblock a memory region for accessibility inside MM. + # + 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 [Components.EBC] MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf -- 2.30.0.windows.1 --_000_MWHPR06MB310285D87C90FB0CFCC36183F3969MWHPR06MB3102namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Mike/Liming/Zhiguang,

 

Could you please review this patch and let me know i= f you have any feedback 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 Kinney; Liming Gao; Zhiguang Liu;= Hao A Wu; Jiewen Yao; Laszlo Ersek
Subject: [PATCH v5 1/7] MdePkg: MmUnblockMemoryLib: Added definition= and null instance

 

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 <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.com>
Cc: Laszlo Ersek <lersek@redhat.com>

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

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    &n= bsp;            = ; | 44 ++++++++++++++++++++
 MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf | 34 +++= ++++++++++++
 MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.uni | 21 +++= +++++++
 MdePkg/MdePkg.dec        &nbs= p;            &= nbsp;           &nbs= p;          |  5 +++
 MdePkg/MdePkg.dsc        &nbs= p;            &= nbsp;           &nbs= p;          |  1 +
 6 files changed, 149 insertions(+)

diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c b/M= dePkg/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 a= gents that set up
+  these regions are responsible for invoking this API in order for th= ese memory areas
+  to be accessed from inside MM.
+
+  Copyright (c) Microsoft Corporation.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+
+/**
+  This API provides a way to unblock certain data pages to be accessi= ble inside MM environment.
+
+  @param  UnblockAddress      &nbs= p;       The address of buffer caller request= s to unblock, the address
+            &n= bsp;            = ;             h= as to be page aligned.
+  @param  NumberOfPages       = ;        The number of pages requested t= o be unblocked from MM
+            &n= bsp;            = ;             e= nvironment.
+
+  @retval RETURN_SUCCESS       &nb= sp;      The request goes through successfully. +  @retval RETURN_NOT_AVAILABLE_YET    The requested fu= nctionality 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
+            &n= bsp;            = ;             u= nblocking.
+  @retval RETURN_INVALID_PARAMETER    Input address ei= ther NULL pointer or not page aligned.
+  @retval RETURN_ACCESS_DENIED      &nb= sp; The request is rejected due to system has passed certain boot
+            &n= bsp;            = ;             p= hase.
+
+**/
+RETURN_STATUS
+EFIAPI
+MmUnblockMemoryRequest (
+  IN PHYSICAL_ADDRESS       UnblockAddr= ess,
+  IN UINT64         &nbs= p;       NumberOfPages
+  )
+{
+  return RETURN_UNSUPPORTED;
+}
diff --git a/MdePkg/Include/Library/MmUnblockMemoryLib.h b/MdePkg/Include/L= ibrary/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 a= gents that set up
+  these regions are responsible for invoking this API in order for th= ese 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 accessi= ble inside MM environment.
+
+  @param  UnblockAddress      &nbs= p;       The address of buffer caller request= s to unblock, the address
+            &n= bsp;            = ;             h= as to be page aligned.
+  @param  NumberOfPages       = ;        The number of pages requested t= o be unblocked from MM
+            &n= bsp;            = ;             e= nvironment.
+
+  @retval RETURN_SUCCESS       &nb= sp;      The request goes through successfully. +  @retval RETURN_NOT_AVAILABLE_YET    The requested fu= nctionality 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
+            &n= bsp;            = ;             u= nblocking.
+  @retval RETURN_INVALID_PARAMETER    Input address ei= ther NULL pointer or not page aligned.
+  @retval RETURN_ACCESS_DENIED      &nb= sp; The request is rejected due to system has passed certain boot
+            &n= bsp;            = ;             p= hase.
+
+**/
+RETURN_STATUS
+EFIAPI
+MmUnblockMemoryRequest (
+  IN PHYSICAL_ADDRESS       UnblockAddr= ess,
+  IN UINT64         &nbs= p;       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 b= e 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 t= hese memory areas
+#  to be accessed from inside MM.
+#
+#  Copyright (c) Microsoft Corporation.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+  INF_VERSION         &n= bsp;          =3D 0x0001001B +  BASE_NAME         &nbs= p;            =3D Mm= UnblockMemoryLibNull
+  MODULE_UNI_FILE        &nbs= p;       =3D MmUnblockMemoryLibNull.uni
+  FILE_GUID         &nbs= p;            =3D 9E= 890F68-5C95-4C31-95DD-59E6286F85EA
+  MODULE_TYPE         &n= bsp;          =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 map= ped/unblocked
+// from inside MM environment.
+//
+// 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.
+//
+// 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       &n= bsp;  #language en-US "This library provides an interface to requ= est non-MMRAM pages to be mapped/unblocked from inside MM environment.\n&qu= ot;
+            &n= bsp;            = ;            &n= bsp;            = ;      "For MM modules that need to access re= gions outside of MMRAMs, the agents that set up these regions are responsib= le for invoking this API in order for these memory areas to be accessed fro= m 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/UnitTestHost= BaseLib.h
 
+  ##  @libraryclass  This library provides an interface for= DXE drivers to request MM environment
+  #   to map/unblock a memory region for accessibility insi= de MM.
+  #
+  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/SmiHandlerProfileLibNu= ll.inf
   MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
+  MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
 
 [Components.EBC]
   MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
--
2.30.0.windows.1

 

--_000_MWHPR06MB310285D87C90FB0CFCC36183F3969MWHPR06MB3102namp_--