[edk2-devel] [PATCH v2 1/6] MdeModulePkg: DxeMmUnblockMemoryLib: Added definition and null instance

Kun Qin kun.q at outlook.com
Thu Feb 25 18:57:05 UTC 2021


Hi Liming,

Thanks for confirmation. Here is a preview implementation we have:
Introduce Standlone MM instance of MM unblock memory ・ kuqin12/mu_basecore at 16dfdc3 (github.com)<https://github.com/kuqin12/mu_basecore/commit/16dfdc320808d2bf34e81621af9a9871bc6a7a0d>

But please know that the real implementation will need to pair with the standalone mm solution that blocks all memory access. We would be happy to share it along with the real library implementation when all pieces are ready.

Thanks,
Kun

From: gaoliming<mailto:gaoliming at byosoft.com.cn>
Sent: Thursday, February 25, 2021 06:04
To: devel at edk2.groups.io<mailto:devel at edk2.groups.io>; kun.q at outlook.com<mailto:kun.q at outlook.com>; jiewen.yao at intel.com<mailto:jiewen.yao at intel.com>; 'Wu, Hao A'<mailto:hao.a.wu at intel.com>; 'Kinney, Michael D'<mailto:michael.d.kinney at intel.com>; 'Liu, Zhiguang'<mailto:zhiguang.liu at intel.com>
Cc: 'Wang, Jian J'<mailto:jian.j.wang at intel.com>; 'Dong, Eric'<mailto:eric.dong at intel.com>; 'Ni, Ray'<mailto:ray.ni at intel.com>
Subject: 回复: [edk2-devel] [PATCH v2 1/6] MdeModulePkg: DxeMmUnblockMemoryLib: Added definition and null instance

Kun:
 I agree to add new library class MmUnblockMemoryLib and its NULL implementation into MdePkg. I want to confirm where is the real implementation for MmUnblockMemoryLib.

Thanks
Liming
发件人: devel at edk2.groups.io <devel at edk2.groups.io> 代表 Kun Qin
发送时间: 2021年2月24日 9:49
收件人: devel at edk2.groups.io; jiewen.yao at intel.com; Wu, Hao A <hao.a.wu at intel.com>; gaoliming <gaoliming at byosoft.com.cn>; Kinney, Michael D <michael.d.kinney at intel.com>; Liu, Zhiguang <zhiguang.liu at intel.com>
抄送: Wang, Jian J <jian.j.wang at intel.com>; Dong, Eric <eric.dong at intel.com>; Ni, Ray <ray.ni at intel.com>; Yao, Jiewen <jiewen.yao at intel.com>
主题: Re: [edk2-devel] [PATCH v2 1/6] MdeModulePkg: DxeMmUnblockMemoryLib: Added definition and null instance

Hi Jiewen,

I agree with your  assessment that it could have a PEI and potentially MM instance. Will remove the prefix and change them to `MmUnblockMemoryLib` in v3 patches. Thanks for the input.

Regards,
Kun

From: Yao, Jiewen<mailto:jiewen.yao at intel.com>
Sent: Tuesday, February 23, 2021 17:33
To: Wu, Hao A<mailto:hao.a.wu at intel.com>; Kun Qin<mailto:kun.q at outlook.com>; devel at edk2.groups.io<mailto:devel at edk2.groups.io>; gaoliming<mailto:gaoliming at byosoft.com.cn>; Kinney, Michael D<mailto:michael.d.kinney at intel.com>; Liu, Zhiguang<mailto:zhiguang.liu at intel.com>
Cc: Wang, Jian J<mailto:jian.j.wang at intel.com>; Dong, Eric<mailto:eric.dong at intel.com>; Ni, Ray<mailto:ray.ni at intel.com>; Yao, Jiewen<mailto:jiewen.yao at intel.com>
Subject: Re: [edk2-devel] [PATCH v2 1/6] MdeModulePkg: DxeMmUnblockMemoryLib: Added definition and null instance

I feel the name is confusing.

The class name is DxeMmUnblockMemoryLib. But actually, this is not related to DXE phase.

I believe, it is also applicable to PEI phase, if we have a PEI instance. Please correct me if I am wrong.
Also, we can have SMM instance, right?

If that is true, then I prefer to remove Dxe prefix.

From: Wu, Hao A <hao.a.wu at intel.com<mailto:hao.a.wu at intel.com>>
Sent: Wednesday, February 24, 2021 9:27 AM
To: Kun Qin <kun.q at outlook.com<mailto:kun.q at outlook.com>>; devel at edk2.groups.io<mailto:devel at edk2.groups.io>; Yao, Jiewen <jiewen.yao at intel.com<mailto:jiewen.yao at intel.com>>; gaoliming <gaoliming at byosoft.com.cn<mailto:gaoliming at byosoft.com.cn>>; Kinney, Michael D <michael.d.kinney at intel.com<mailto:michael.d.kinney at intel.com>>; Liu, Zhiguang <zhiguang.liu at intel.com<mailto:zhiguang.liu at intel.com>>
Cc: Wang, Jian J <jian.j.wang at intel.com<mailto:jian.j.wang at intel.com>>; Dong, Eric <eric.dong at intel.com<mailto:eric.dong at intel.com>>; Ni, Ray <ray.ni at intel.com<mailto:ray.ni at intel.com>>
Subject: RE: [edk2-devel] [PATCH v2 1/6] MdeModulePkg: DxeMmUnblockMemoryLib: Added definition and null instance

Thanks Kun,

For putting the new library in MdePkg, I am not sure whether this is a similar case to SmmMemLib.
I looped Jiewen, Liming and Mike to check if they have comments on this.

Best Regards,
Hao Wu

From: Kun Qin <kun.q at outlook.com<mailto:kun.q at outlook.com>>
Sent: Wednesday, February 24, 2021 3:30 AM
To: devel at edk2.groups.io<mailto:devel at edk2.groups.io>; Wu, Hao A <hao.a.wu at intel.com<mailto:hao.a.wu at intel.com>>; Yao, Jiewen <jiewen.yao at intel.com<mailto:jiewen.yao at intel.com>>; gaoliming <gaoliming at byosoft.com.cn<mailto:gaoliming at byosoft.com.cn>>; Kinney, Michael D <michael.d.kinney at intel.com<mailto:michael.d.kinney at intel.com>>; Liu, Zhiguang <zhiguang.liu at intel.com<mailto:zhiguang.liu at intel.com>>
Cc: Wang, Jian J <jian.j.wang at intel.com<mailto:jian.j.wang at intel.com>>; Dong, Eric <eric.dong at intel.com<mailto:eric.dong at intel.com>>; Ni, Ray <ray.ni at intel.com<mailto:ray.ni at intel.com>>
Subject: RE: [edk2-devel] [PATCH v2 1/6] MdeModulePkg: DxeMmUnblockMemoryLib: Added definition and null instance

Hi Hao,

Thanks for the suggestion. I can move the library to MdePkg similar to SmmMemLib and add the change for OVMF.

Liming/Zhiguang,

I am happy to prepare patches to cover the dependency change in ed2-platform in a separate patch series. But please let me know if you would like to proceed otherwise.

Thanks,
Kun

From: Wu, Hao A<mailto:hao.a.wu at intel.com>
Sent: Monday, February 22, 2021 17:42
To: Kun Qin<mailto:kun.q at outlook.com>; devel at edk2.groups.io<mailto:devel at edk2.groups.io>; Yao, Jiewen<mailto:jiewen.yao at intel.com>; gaoliming<mailto:gaoliming at byosoft.com.cn>; Kinney, Michael D<mailto:michael.d.kinney at intel.com>; Liu, Zhiguang<mailto:zhiguang.liu at intel.com>
Cc: Wang, Jian J<mailto:jian.j.wang at intel.com>; Dong, Eric<mailto:eric.dong at intel.com>; Ni, Ray<mailto:ray.ni at intel.com>
Subject: Re: [edk2-devel] [PATCH v2 1/6] MdeModulePkg: DxeMmUnblockMemoryLib: Added definition and null instance

Hello Kun,

Sorry for the delayed response.

Except for missing the UNI file for the newly added library, I do not have other comment for the implementation at this moment.
But I am wondering if this library can be added into the MdePkg as the case for MdePkg\Library\SmmMemLib\
I have looped in Jiewen, Liming and Mike for comments.

Also, since:
* New library dependency for VariableSmmRuntimeDxe.inf
* INF file separation and new library dependency in Tcg2Smm
I think the series needs to prepare the changes for platforms under edk2 (OVMF) and edk2-platforms repositories that consume the above 2 modules.
I am not exactly sure on how this should be handled within edk2-platforms, so I added Liming and Zhiguang here for comments.

Best Regards,
Hao Wu

From: Kun Qin <kun.q at outlook.com<mailto:kun.q at outlook.com>>
Sent: Tuesday, February 23, 2021 6:15 AM
To: devel at edk2.groups.io<mailto:devel at edk2.groups.io>; Wu, Hao A <hao.a.wu at intel.com<mailto:hao.a.wu at intel.com>>
Cc: Wang, Jian J <jian.j.wang at intel.com<mailto:jian.j.wang at intel.com>>; Dong, Eric <eric.dong at intel.com<mailto:eric.dong at intel.com>>; Ni, Ray <ray.ni at intel.com<mailto:ray.ni at intel.com>>; Yao, Jiewen <jiewen.yao at intel.com<mailto:jiewen.yao at intel.com>>
Subject: RE: [PATCH v2 1/6] MdeModulePkg: DxeMmUnblockMemoryLib: Added definition and null instance

Hi Hao,

The patch series was resent with intended usage in VariableRuntime and Tcg2 drivers. Could you please provide feedback on them? Any input is appreciated.

Regards,
Kun

From: Kun Qin<mailto:kun.q at outlook.com>
Sent: Tuesday, February 9, 2021 17:25
To: devel at edk2.groups.io<mailto:devel at edk2.groups.io>
Cc: Jian J Wang<mailto:jian.j.wang at intel.com>; Hao A Wu<mailto:hao.a.wu at intel.com>; Eric Dong<mailto:eric.dong at intel.com>; Ray Ni<mailto:ray.ni at intel.com>; Jiewen Yao<mailto:jiewen.yao at intel.com>
Subject: [PATCH v2 1/6] MdeModulePkg: DxeMmUnblockMemoryLib: Added definition and null instance

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3168

This interface definition provides an abstraction layer for DXE drivers
to request certain memory blocks to be mapped/unblocked for accessibility
inside MM environment.

Cc: Jian J Wang <jian.j.wang at intel.com<mailto:jian.j.wang at intel.com>>
Cc: Hao A Wu <hao.a.wu at intel.com<mailto:hao.a.wu at intel.com>>
Cc: Eric Dong <eric.dong at intel.com<mailto:eric.dong at intel.com>>
Cc: Ray Ni <ray.ni at intel.com<mailto:ray.ni at intel.com>>
Cc: Jiewen Yao <jiewen.yao at intel.com<mailto:jiewen.yao at intel.com>>

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

Notes:
    v2:
    - Resend with practical usage. No change [Hao]

 MdeModulePkg/Library/DxeMmUnblockMemoryLib/DxeMmUnblockMemoryLibNull.c   | 40 ++++++++++++++++++++
 MdeModulePkg/Include/Library/DxeMmUnblockMemoryLib.h                     | 40 ++++++++++++++++++++
 MdeModulePkg/Library/DxeMmUnblockMemoryLib/DxeMmUnblockMemoryLibNull.inf | 29 ++++++++++++++
 MdeModulePkg/MdeModulePkg.dec                                            |  5 +++
 MdeModulePkg/MdeModulePkg.dsc                                            |  2 +
 5 files changed, 116 insertions(+)

diff --git a/MdeModulePkg/Library/DxeMmUnblockMemoryLib/DxeMmUnblockMemoryLibNull.c b/MdeModulePkg/Library/DxeMmUnblockMemoryLib/DxeMmUnblockMemoryLibNull.c
new file mode 100644
index 000000000000..774a7e41cfb0
--- /dev/null
+++ b/MdeModulePkg/Library/DxeMmUnblockMemoryLib/DxeMmUnblockMemoryLibNull.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 <Uefi.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.
+
+  @return EFI_SUCCESS             The request goes through successfully.
+  @return EFI_NOT_AVAILABLE_YET   The requested functionality is not produced yet.
+  @return EFI_UNSUPPORTED         The requested functionality is not supported 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
+DxeMmUnblockMemoryRequest (
+  IN EFI_PHYSICAL_ADDRESS   UnblockAddress,
+  IN UINT64                 NumberOfPages
+  )
+{
+  return EFI_UNSUPPORTED;
+}
diff --git a/MdeModulePkg/Include/Library/DxeMmUnblockMemoryLib.h b/MdeModulePkg/Include/Library/DxeMmUnblockMemoryLib.h
new file mode 100644
index 000000000000..8b63eb74a078
--- /dev/null
+++ b/MdeModulePkg/Include/Library/DxeMmUnblockMemoryLib.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 _DXE_MM_UNBLOCK_MEMORY_LIB_H_
+#define _DXE_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.
+
+  @return EFI_SUCCESS             The request goes through successfully.
+  @return EFI_NOT_AVAILABLE_YET   The requested functionality is not produced yet.
+  @return EFI_UNSUPPORTED         The requested functionality is not supported 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
+DxeMmUnblockMemoryRequest (
+  IN EFI_PHYSICAL_ADDRESS   UnblockAddress,
+  IN UINT64                 NumberOfPages
+);
+
+#endif // _DXE_MM_UNBLOCK_MEMORY_LIB_H_
diff --git a/MdeModulePkg/Library/DxeMmUnblockMemoryLib/DxeMmUnblockMemoryLibNull.inf b/MdeModulePkg/Library/DxeMmUnblockMemoryLib/DxeMmUnblockMemoryLibNull.inf
new file mode 100644
index 000000000000..e40462e5ab81
--- /dev/null
+++ b/MdeModulePkg/Library/DxeMmUnblockMemoryLib/DxeMmUnblockMemoryLibNull.inf
@@ -0,0 +1,29 @@
+## @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
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = DxeMmUnblockMemoryLibNull
+  FILE_GUID                      = 9E890F68-5C95-4C31-95DD-59E6286F85EA
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = DxeMmUnblockMemoryLib
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  DxeMmUnblockMemoryLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 148395511034..1bb5017da2c5 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -154,6 +154,11 @@ [LibraryClasses]
   #
   VariablePolicyHelperLib|Include/Library/VariablePolicyHelperLib.h

+  ##  @libraryclass  This library provides an interface for DXE drivers to request MM environment
+  #   to map/unblock a memory region for accessibility inside MM.
+  #
+  DxeMmUnblockMemoryLib|Include/Library/DxeMmUnblockMemoryLib.h
+
 [Guids]
   ## MdeModule package token space guid
   # Include/Guid/MdeModulePkgTokenSpace.h
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 7ca4a1bb3080..2bc6b8730b8b 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -100,6 +100,7 @@ [LibraryClasses]
   SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
   DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf
   VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  DxeMmUnblockMemoryLib|MdeModulePkg/Library/DxeMmUnblockMemoryLib/DxeMmUnblockMemoryLibNull.inf

 [LibraryClasses.EBC.PEIM]
   IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
@@ -332,6 +333,7 @@ [Components]
   MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
   MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf
   MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.inf
+  MdeModulePkg/Library/DxeMmUnblockMemoryLib/DxeMmUnblockMemoryLibNull.inf

   MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
   MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
--
2.30.0.windows.1







-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#72206): https://edk2.groups.io/g/devel/message/72206
Mute This Topic: https://groups.io/mt/80909643/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20210225/d0386306/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 42C13E93F70C492C960618AE78817471.png
Type: image/png
Size: 135 bytes
Desc: 42C13E93F70C492C960618AE78817471.png
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20210225/d0386306/attachment.png>


More information about the edk2-devel-archive mailing list