From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.92.19.40]) by mx.groups.io with SMTP id smtpd.web10.2239.1614625425575285304 for ; Mon, 01 Mar 2021 11:03:45 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=tZnAEi/u; spf=pass (domain: outlook.com, ip: 40.92.19.40, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IwLvM8gHwL/WR6x4z9+V0gmFnGsOOxpmjy5grYtjFo0EvLyYleNRZUW+kRkDZ1ueuUK4a+rbUPuYQuXJBTGrUcXhNJSHc9208rxsUDm5iwldyHKhtLFanbZb0rQXVlCLk1+x+CO8bPB4tBwYKRtV1X6TqXDJ7MgU8MB8SRrqDxQ1i6kn2S3rHo//fw10ZcOLeA6l6R7jU82zx+uZ4BGqdZM7MlezQT5DfsatILOUKqNsVfYpnIyn3rFLAswhl8UOyONAPsMhilElOWyVoXHM6hE495ib7NiKQRNJveQ3ewvNsl7RYYZejJxt557ELXbaeemCnWtQcd3/ZxtLiNwUQQ== 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=fqJQeaMwleNiZuaX6bwMxDbmMcwyAcr50L6tqMI4o54=; b=F/i54UtovaFNzv185HubiJt0T5HUlT6JYSz9oKoyyLHcAg4zaKPkGkXIFGR+UnSIR8eC/DAhHpLYP2C2bW9u7TXat5Gr0PJNGEhs13XhFJqjKHgJpdTqV1eGCKJYvjdyjpaUpoFetMXy0Kc8lpR7pOJhEa/11U2Irky5yFIO0aDT/LIfDmaEjPpyPW/nhulOBHSuDc2Rj8oF8EwWdUNuefY6xFHXmQHuNjrix7/yw9EpiwnVzO3PjCySK8lw1vnhmSn2h1wMlKxCV3JPi8eocYf9V+rgXWI/1am8AN750dncN17izq34lNVqxJllNbJUopD/647/GUQ2HSVW7Y77iw== 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=fqJQeaMwleNiZuaX6bwMxDbmMcwyAcr50L6tqMI4o54=; b=tZnAEi/uok9Gy9D6QsnlZenC94sWlUiNsoFp/BoOqa1/DX+TeZZf14+53K6fFkv9uQfSzxJiIt/VijswBf+T9+fNY157OlmPTMW0mmeUA8LgwmFrw5Sg42/+lUbZPBVglAs1Mr5zPmF/1viAcY6XmmAkAZEziFQ7l2keQE2Eu7Js6D+5L1igA1WQaGelGmz/xvU71SJlop+AIqF3uqKvudLQyQm6ke2s5zjFkgqR+pZMxVXvSehPUuIeOZKszY2U7Iv4uXvOpGuDppvcpdsJgdSZErtb83002tY5dYpF7Sh1ZZQz7t+4+5DsrlRAJCFaiTMV9tJzRoMItsqDPr8ZOw== Received: from DM6NAM11FT025.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::4a) by DM6NAM11HT141.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::377) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Mon, 1 Mar 2021 19:03:44 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:fc4d::4e) by DM6NAM11FT025.mail.protection.outlook.com (2a01:111:e400:fc4d::197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19 via Frontend Transport; Mon, 1 Mar 2021 19:03:44 +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; Mon, 1 Mar 2021 19:03:44 +0000 From: "Kun Qin" To: "devel@edk2.groups.io" , "lersek@redhat.com" CC: Michael D Kinney , Liming Gao , Zhiguang Liu , Hao A Wu , Jiewen Yao Subject: Re: [edk2-devel] [PATCH v3 1/7] MdePkg: MmUnblockMemoryLib: Added definition and null instance Thread-Topic: [edk2-devel] [PATCH v3 1/7] MdePkg: MmUnblockMemoryLib: Added definition and null instance Thread-Index: AQHXDJITTaEWrD6w1EqhOwHv545grKpvWeYAgAAWOpI= Date: Mon, 1 Mar 2021 19:03:43 +0000 Message-ID: References: <20210226225158.1378-1-kun.q@outlook.com> , In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:C92A191235B7BE80A86884A735D357AA11C99100BDAEDE10B187543D787117DC;UpperCasedChecksum:88D832585FFFBBF8790C141B9191060D435AD18BC8A1F6E8C274818DA670E2A6;SizeAsReceived:7223;Count:44 x-tmn: [AXVulWchQuxExcUctTtls4hXQhJGnmyK] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: e97a2faf-4a40-4388-08bb-08d8dce4bc2f x-ms-traffictypediagnostic: DM6NAM11HT141: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: hUqhd1gYNA7xksDXZ5YaEwnLIj59wbshqF4FMAU9Lwn8gg4CR51nPtDfsXKSaT4Lb4FesppGws4qitdgBxNLIegS95EK6QRS4+nK+Xnvszt3ybpSBCXybXIOCjhVLMZ0G+DKvjW+/NKTBd0F28DuecrxCEHcbKN6t9+IBNUvY9/v+apRzY3IiGYtijfTaLSmD7OlbuomIW4QYKJsp51Dp6862ZQfO0PcOLJcbnpmh7QQ3Adzu0MSFJPDas2yL5vICrt6ogCQ3Mg/D65PUgUVfg5Bx84pfS8eu8ACJsKItvjLHc/F2QppDtmxStbGyez6VXMJm9UgQ1u4UMI4Jd3U6wJxpSEiIp2G2NRNi3wgoVWKQS0Iw/OxMq/5BpK71VPW52z0fsJuEx1s1i1VEDgUzaGnad2PwiZNvIl9+Xy9Qu0= x-ms-exchange-antispam-messagedata: L9bHK0HFVVOZwr/SzCO2vHeIF3u1g2/6kRi5LKl5JUJ+CCz6xegmwLM/dglhLx2/5fg224jys5hkE4CnI1yJWOv8UJDrCQqxCaZsHNZERbP1kZ597wMJuCwzDRdDpvZiiz072A4kRpiQL1Fnh90plw== 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: DM6NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: e97a2faf-4a40-4388-08bb-08d8dce4bc2f X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Mar 2021 19:03:43.9459 (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: DM6NAM11HT141 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MWHPR06MB310245C7CFD9E521C2F1B56CF39A9MWHPR06MB3102namp_" --_000_MWHPR06MB310245C7CFD9E521C2F1B56CF39A9MWHPR06MB3102namp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi Laszlo, The library is intended to allow MM modules to access requested areas that= are outside of MMRAM. The idea behind this library is to create an MM mode= l that will block access to all non-MMRAM regions except the requested area= s for isolation/protection purpose. To resolve your confusion, the agents t= hat are responsible for unblocking memory are the ones that sets up these r= egions that need to be accessed by MM modules. For example: 1. To enable runtime cache feature for variable service, Variable MM mo= dule needs to access the allocated runtime buffer, which is set up in Varia= bleSmmRuntimeDxe; 2. For TPM ACPI table to communicate to physical presence handler, the = corresponding NVS regions has to be accessible from inside MM, which is set= up when assigning NVS region in DXE environment; So the library is not necessarily restricted to DXE_RUNTIME drivers, but c= ould be applicable to DXE drivers and even PEI modules as well. Thanks for the suggestion, I will replace the =93EFI_=94 error code with = =93RETURN_=94 error codes and add more statements in commit message to mak= e the purpose of this library more explanatory. Regards, Kun From: Laszlo Ersek Sent: Monday, March 1, 2021 08:40 To: devel@edk2.groups.io; kun.q@outlook.com Cc: Michael D Kinney; Liming Gao; Zhiguang Liu; Ha= o A Wu; Jiewen Yao Subject: Re: [edk2-devel] [PATCH v3 1/7] MdePkg: MmUnblockMemoryLib: Added= definition and null instance On 02/26/21 23:51, Kun Qin wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3168 > > This interface definition provides an abstraction layer for applicable > drivers to request certain memory blocks to be mapped/unblocked for > accessibility inside MM environment. > > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu > Cc: Hao A Wu > Cc: Jiewen Yao > > Signed-off-by: Kun Qin > --- > > Notes: > 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 | 40 +++++= +++++++++++++++ > MdePkg/Include/Library/MmUnblockMemoryLib.h | 40 +++++= +++++++++++++++ > MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf | 29 +++++= +++++++++ > MdePkg/MdePkg.dec | 5 +++ > MdePkg/MdePkg.dsc | 1 + > 5 files changed, 115 insertions(+) > > diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c = b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c > new file mode 100644 > index 000000000000..ed9a45587b64 > --- /dev/null > +++ b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c > @@ -0,0 +1,40 @@ > +/** @file > + Null instance of MM Unblock Page Library. > + > + This library provides an abstraction layer of requesting certain page= access to be unblocked > + by MM environment if applicable. > + > + Copyright (c) Microsoft Corporation. > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > +/** > + This API provides a way to unblock certain data pages to be accessibl= e 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 u= nblocked from MM > + environment. > + > + @return EFI_SUCCESS The request goes through successfully= . > + @return EFI_NOT_AVAILABLE_YET The requested functionality is not pr= oduced yet. > + @return EFI_UNSUPPORTED The requested functionality is not su= pported on current platform. > + @return EFI_SECURITY_VIOLATION The requested address failed to pass = security check for > + unblocking. > + @return EFI_INVALID_PARAMETER Input address either NULL pointer or = not page aligned. > + @return EFI_ACCESS_DENIED The request is rejected due to system= has passed certain boot > + phase. > + > +**/ > +EFI_STATUS > +EFIAPI > +MmUnblockMemoryRequest ( > + IN EFI_PHYSICAL_ADDRESS UnblockAddress, > + IN UINT64 NumberOfPages > + ) > +{ > + return EFI_UNSUPPORTED; > +} > diff --git a/MdePkg/Include/Library/MmUnblockMemoryLib.h b/MdePkg/Includ= e/Library/MmUnblockMemoryLib.h > new file mode 100644 > index 000000000000..adff8ddc8063 > --- /dev/null > +++ b/MdePkg/Include/Library/MmUnblockMemoryLib.h > @@ -0,0 +1,40 @@ > +/** @file > + MM Unblock Memory Library Interface. > + > + This library provides an abstraction layer of requesting certain page= access to be unblocked > + by MM environment if applicable. > + > + 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 accessibl= e 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 u= nblocked from MM > + environment. > + > + @return EFI_SUCCESS The request goes through successfully= . > + @return EFI_NOT_AVAILABLE_YET The requested functionality is not pr= oduced yet. > + @return EFI_UNSUPPORTED The requested functionality is not su= pported on current platform. > + @return EFI_SECURITY_VIOLATION The requested address failed to pass = security check for > + unblocking. > + @return EFI_INVALID_PARAMETER Input address either NULL pointer or = not page aligned. > + @return EFI_ACCESS_DENIED The request is rejected due to system= has passed certain boot > + phase. > + > +**/ > +EFI_STATUS > +EFIAPI > +MmUnblockMemoryRequest ( > + IN EFI_PHYSICAL_ADDRESS UnblockAddress, > + IN UINT64 NumberOfPages > +); > + > +#endif // MM_UNBLOCK_MEMORY_LIB_H_ > diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.in= f b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf > new file mode 100644 > index 000000000000..4c1f3d1c8e87 > --- /dev/null > +++ b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf > @@ -0,0 +1,29 @@ > +## @file > +# Null instance of MM Unblock Page Library. > +# > +# This library provides an abstraction layer of requesting certain pag= e access to be unblocked > +# by MM environment if applicable. > +# > +# Copyright (c) Microsoft Corporation. > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x0001001B > + BASE_NAME =3D MmUnblockMemoryLibNull > + FILE_GUID =3D 9E890F68-5C95-4C31-95DD-59E6286F85= EA > + MODULE_TYPE =3D BASE > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D MmUnblockMemoryLib (1) I think the applicability of this library class is not spelled out clearly enough. The commit message says "applicable drivers", and I have no idea what that means. The facts that MODULE_TYPE is BASE here, and LIBRARY_CLASS is not restricted to any particular module types, do not help either. (2) Assuming "MODULE_TYPE =3D BASE" is correct, then the EFI_ prefixes in the library class (and Null instance) look wrong. BASE libraries should use RETURN_ prefixes, to my understanding. (I.e., replace EFI_STATUS, EFI_SUCCESS etc with RETURN_STATUS, RETURN_SUCESS ...) So I would suggest either restricting this API to runtime DXE drivers, or using RETURN_... macros. Either way, it should be clarified what agents are responsible for "unblocking" memory areas for MM. Do you have something like "runtime DXE drivers that submit MM Communicate requests" in mind? Thanks Laszlo > + > +# > +# VALID_ARCHITECTURES =3D IA32 X64 > +# > + > +[Sources] > + MmUnblockMemoryLibNull.c > + > +[Packages] > + MdePkg/MdePkg.dec > 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 > --_000_MWHPR06MB310245C7CFD9E521C2F1B56CF39A9MWHPR06MB3102namp_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

Hi Laszlo,

 

The library is intended to allow MM modules to acce= ss requested areas that are outside of MMRAM. The idea behind this library = is to create an MM model that will block access to all non-MMRAM regions ex= cept the requested areas for isolation/protection purpose. To resolve your confusion, the agents that are responsible for u= nblocking memory are the ones that sets up these regions that need to be ac= cessed by MM modules.

 

For example:

  1. To enable runtime cache feature for variable service, Variable MM mo= dule needs to access the allocated runtime buffer, which is set up in Varia= bleSmmRuntimeDxe;
  2. For TPM ACPI table to communicate to physical p= resence handler, the corresponding NVS regions has to be accessible from in= side MM, which is set up when assigning NVS region in DXE environment;

 

So the library is not necessarily restricted to DXE= _RUNTIME drivers, but could be applicable to DXE drivers and even PEI modul= es as well.

 

Thanks for the suggestion, I will replace the =93EF= I_=94 error code with =93RETURN_=94 error codes and add more statements in = commit message to make the purpose of this library more explanatory.

 

Regards,

Kun

 

From: Laszlo Ersek
Sent: Monday, March 1, 2021 08:40
To: devel@edk2.groups.io; kun.q@outlook.com
Cc: Michael D Kinney<= /a>; Liming Gao; Zhiguang Liu= ; Hao A Wu; Jiewen Yao
Subject: Re: [edk2-devel] [PATCH v3 1/7] MdePkg: MmUnblockMemoryLib= : Added definition and null instance

 

On 02/26/21 23:51, K= un Qin wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3168
>
> This interface definition provides an abstraction layer for applicabl= e
> drivers to request certain memory blocks to be mapped/unblocked for > accessibility inside MM environment.
>
> 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>
>
> Signed-off-by: Kun Qin <kun.q@outlook.com>
> ---
>
> Notes:
>     v3:
>     - Move interface to MdePkg [Hao, Liming, Jiew= en]
>     - Remove Dxe prefix [Jiewen]
>    
>     v2:
>     - Resend with practical usage. No change [Hao= ]
>
>  MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c = ;  | 40 ++++++++++++++++++++
>  MdePkg/Include/Library/MmUnblockMemoryLib.h   &n= bsp;            = ;  | 40 ++++++++++++++++++++
>  MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf | = 29 ++++++++++++++
>  MdePkg/MdePkg.dec       &nbs= p;            &= nbsp;           &nbs= p;           |  5 ++= +
>  MdePkg/MdePkg.dsc       &nbs= p;            &= nbsp;           &nbs= p;           |  1 +<= br> >  5 files changed, 115 insertions(+)
>
> diff --git a/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull= .c b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c
> new file mode 100644
> index 000000000000..ed9a45587b64
> --- /dev/null
> +++ b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.c
> @@ -0,0 +1,40 @@
> +/** @file
> +  Null instance of MM Unblock Page Library.
> +
> +  This library provides an abstraction layer of requesting cert= ain page access to be unblocked
> +  by MM environment if applicable.
> +
> +  Copyright (c) Microsoft Corporation.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +
> +/**
> +  This API provides a way to unblock certain data pages to be a= ccessible inside MM environment.
> +
> +  @param  UnblockAddress     &nbs= p;    The address of buffer caller requests to unblock, the = address
> +           &n= bsp;            = ;          has to be page alig= ned.
> +  @param  NumberOfPages      = ;     The number of pages requested to be unblocked fro= m MM
> +           &n= bsp;            = ;          environment.
> +
> +  @return EFI_SUCCESS       =       The request goes through successfully.
> +  @return EFI_NOT_AVAILABLE_YET   The requested funct= ionality is not produced yet.
> +  @return EFI_UNSUPPORTED      &n= bsp;  The requested functionality is not supported on current platform= .
> +  @return EFI_SECURITY_VIOLATION  The requested address fa= iled to pass security check for
> +           &n= bsp;            = ;          unblocking.
> +  @return EFI_INVALID_PARAMETER   Input address eithe= r NULL pointer or not page aligned.
> +  @return EFI_ACCESS_DENIED      = The request is rejected due to system has passed certain boot
> +           &n= bsp;            = ;          phase.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MmUnblockMemoryRequest (
> +  IN EFI_PHYSICAL_ADDRESS   UnblockAddress,
> +  IN UINT64        &nbs= p;        NumberOfPages
> +  )
> +{
> +  return EFI_UNSUPPORTED;
> +}
> diff --git a/MdePkg/Include/Library/MmUnblockMemoryLib.h b/MdePkg/Inc= lude/Library/MmUnblockMemoryLib.h
> new file mode 100644
> index 000000000000..adff8ddc8063
> --- /dev/null
> +++ b/MdePkg/Include/Library/MmUnblockMemoryLib.h
> @@ -0,0 +1,40 @@
> +/** @file
> +  MM Unblock Memory Library Interface.
> +
> +  This library provides an abstraction layer of requesting cert= ain page access to be unblocked
> +  by MM environment if applicable.
> +
> +  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 a= ccessible inside MM environment.
> +
> +  @param  UnblockAddress     &nbs= p;    The address of buffer caller requests to unblock, the = address
> +           &n= bsp;            = ;          has to be page alig= ned.
> +  @param  NumberOfPages      = ;     The number of pages requested to be unblocked fro= m MM
> +           &n= bsp;            = ;          environment.
> +
> +  @return EFI_SUCCESS       =       The request goes through successfully.
> +  @return EFI_NOT_AVAILABLE_YET   The requested funct= ionality is not produced yet.
> +  @return EFI_UNSUPPORTED      &n= bsp;  The requested functionality is not supported on current platform= .
> +  @return EFI_SECURITY_VIOLATION  The requested address fa= iled to pass security check for
> +           &n= bsp;            = ;          unblocking.
> +  @return EFI_INVALID_PARAMETER   Input address eithe= r NULL pointer or not page aligned.
> +  @return EFI_ACCESS_DENIED      = The request is rejected due to system has passed certain boot
> +           &n= bsp;            = ;          phase.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MmUnblockMemoryRequest (
> +  IN EFI_PHYSICAL_ADDRESS   UnblockAddress,
> +  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..4c1f3d1c8e87
> --- /dev/null
> +++ b/MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf > @@ -0,0 +1,29 @@
> +## @file
> +#  Null instance of MM Unblock Page Library.
> +#
> +#  This library provides an abstraction layer of requesting cer= tain page access to be unblocked
> +#  by MM environment if applicable.
> +#
> +#  Copyright (c) Microsoft Corporation.
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION        &n= bsp;           =3D 0x0001= 001B
> +  BASE_NAME        &nbs= p;             = = =3D MmUnblockMemoryLibNull
> +  FILE_GUID        &nbs= p;             = = =3D 9E890F68-5C95-4C31-95DD-59E6286F85EA
> +  MODULE_TYPE        &n= bsp;           =3D BASE > +  VERSION_STRING        = ;         =3D 1.0
> +  LIBRARY_CLASS        =           =3D MmUnblockMemoryL= ib

(1) I think the applicability of this library class is not spelled out
clearly enough. The commit message says "applicable drivers", an= d I have
no idea what that means. The facts that MODULE_TYPE is BASE here, and
LIBRARY_CLASS is not restricted to any particular module types, do not
help either.

(2) Assuming "MODULE_TYPE =3D BASE" is correct, then the EFI_ pr= efixes in
the library class (and Null instance) look wrong. BASE libraries should use RETURN_ prefixes, to my understanding. (I.e., replace EFI_STATUS,
EFI_SUCCESS etc with RETURN_STATUS, RETURN_SUCESS ...)

So I would suggest either restricting this API to runtime DXE drivers,
or using RETURN_... macros.

Either way, it should be clarified what agents are responsible for
"unblocking" memory areas for MM. Do you have something like &qu= ot;runtime
DXE drivers that submit MM Communicate requests" in mind?

Thanks
Laszlo


> +
> +#
> +#  VALID_ARCHITECTURES       = ;    =3D IA32 X64
> +#
> +
> +[Sources]
> +  MmUnblockMemoryLibNull.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> 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/U= nitTestHostBaseLib.h

> +  ##  @libraryclass  This library provides an interfa= ce for DXE drivers to request MM environment
> +  #   to map/unblock a memory region for accessibilit= y 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.in= f
>    MdePkg/Library/SmiHandlerProfileLibNull/SmiHandlerP= rofileLibNull.inf
>    MdePkg/Library/MmServicesTableLib/MmServicesTableLi= b.inf
> +  MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf<= br> > 
>  [Components.EBC]
>    MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsi= c.inf
>





 

--_000_MWHPR06MB310245C7CFD9E521C2F1B56CF39A9MWHPR06MB3102namp_--