MdePkg: MmUnblockMemoryLib: Added definition and null instance

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

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>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Message-Id: <MWHPR06MB31028AF0D0785B93E4E7CF63F3969@MWHPR06MB3102.namprd06.prod.outlook.com>
This commit is contained in:
Kun Qin 2021-03-04 20:12:47 -08:00 committed by mergify[bot]
parent c5740f3606
commit 7cda5d9e3a
6 changed files with 149 additions and 0 deletions

View File

@ -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_

View File

@ -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 <Base.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
)
{
return RETURN_UNSUPPORTED;
}

View File

@ -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 = 0x0001001B
BASE_NAME = MmUnblockMemoryLibNull
MODULE_UNI_FILE = MmUnblockMemoryLibNull.uni
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

View File

@ -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."

View File

@ -257,6 +257,11 @@
#
UnitTestHostBaseLib|Test/UnitTest/Include/Library/UnitTestHostBaseLib.h
## @libraryclass This library provides an interface to request non-MMRAM pages to be mapped
# or unblocked from inside MM environment.
#
MmUnblockMemoryLib|Include/Library/MmUnblockMemoryLib.h
[LibraryClasses.IA32, LibraryClasses.X64]
## @libraryclass Abstracts both S/W SMI generation and detection.
##

View File

@ -168,6 +168,7 @@
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