REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3168
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 <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Hao A Wu <hao.a...@intel.com> Cc: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Kun Qin <ku...@outlook.com> --- 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 <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 +MmUnblockMemoryRequest ( + IN EFI_PHYSICAL_ADDRESS UnblockAddress, + IN UINT64 NumberOfPages + ) +{ + return EFI_UNSUPPORTED; +} diff --git a/MdePkg/Include/Library/MmUnblockMemoryLib.h b/MdePkg/Include/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 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 +MmUnblockMemoryRequest ( + IN EFI_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..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 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 = MmUnblockMemoryLibNull + FILE_GUID = 9E890F68-5C95-4C31-95DD-59E6286F85EA + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = MmUnblockMemoryLib + +# +# VALID_ARCHITECTURES = 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 -- 2.30.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#72240): https://edk2.groups.io/g/devel/message/72240 Mute This Topic: https://groups.io/mt/80939990/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-