diff options
author | Kun Qin <kun.q@outlook.com> | 2021-03-04 20:14:11 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-03-05 15:25:07 +0000 |
commit | f463dbadede138dc96a66dae6f361c54f0b3093c (patch) | |
tree | 75a879203e74a20d67e5ba3490050ed392903468 /MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c | |
parent | 05a757c9c61fd562093060a67c4eb64eecaad8bd (diff) | |
download | edk2-f463dbadede138dc96a66dae6f361c54f0b3093c.tar.gz edk2-f463dbadede138dc96a66dae6f361c54f0b3093c.tar.bz2 edk2-f463dbadede138dc96a66dae6f361c54f0b3093c.zip |
MdeModulePkg: VariableSmmRuntimeDxe: Added request unblock memory interface
This changes added usage of MmUnblockMemoryLib to explicitly request
runtime cache regions(and its indicators) to be accessible from MM
environment when PcdEnableVariableRuntimeCache is enabled. It will bring
in compatibility with architectures that supports full memory blockage
inside MM.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Message-Id: <MWHPR06MB31026EA41F28F2CE12B68574F3969@MWHPR06MB3102.namprd06.prod.outlook.com>
Diffstat (limited to 'MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c')
-rw-r--r-- | MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c index c47e614d81..a166d284df 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c @@ -35,6 +35,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
+#include <Library/MmUnblockMemoryLib.h>
#include <Guid/EventGroup.h>
#include <Guid/SmmVariableCommon.h>
@@ -165,6 +166,7 @@ InitVariableCache ( )
{
VARIABLE_STORE_HEADER *VariableCacheStorePtr;
+ EFI_STATUS Status;
if (TotalVariableCacheSize == NULL) {
return EFI_INVALID_PARAMETER;
@@ -186,6 +188,18 @@ InitVariableCache ( if (*VariableCacheBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
+ //
+ // Request to unblock the newly allocated cache region to be accessible from inside MM
+ //
+ Status = MmUnblockMemoryRequest (
+ (EFI_PHYSICAL_ADDRESS) (UINTN) *VariableCacheBuffer,
+ EFI_SIZE_TO_PAGES (*TotalVariableCacheSize)
+ );
+ if (Status != EFI_UNSUPPORTED && EFI_ERROR (Status)) {
+ return Status;
+ }
+
VariableCacheStorePtr = *VariableCacheBuffer;
SetMem32 ((VOID *) VariableCacheStorePtr, *TotalVariableCacheSize, (UINT32) 0xFFFFFFFF);
@@ -1537,6 +1551,34 @@ SendRuntimeVariableCacheContextToSmm ( SmmRuntimeVarCacheContext->HobFlushComplete = &mHobFlushComplete;
//
+ // Request to unblock this region to be accessible from inside MM environment
+ // These fields "should" be all on the same page, but just to be on the safe side...
+ //
+ Status = MmUnblockMemoryRequest (
+ (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN) SmmRuntimeVarCacheContext->PendingUpdate - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE),
+ EFI_SIZE_TO_PAGES (sizeof(mVariableRuntimeCachePendingUpdate))
+ );
+ if (Status != EFI_UNSUPPORTED && EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ Status = MmUnblockMemoryRequest (
+ (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN) SmmRuntimeVarCacheContext->ReadLock - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE),
+ EFI_SIZE_TO_PAGES (sizeof(mVariableRuntimeCacheReadLock))
+ );
+ if (Status != EFI_UNSUPPORTED && EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ Status = MmUnblockMemoryRequest (
+ (EFI_PHYSICAL_ADDRESS) ALIGN_VALUE ((UINTN) SmmRuntimeVarCacheContext->HobFlushComplete - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE),
+ EFI_SIZE_TO_PAGES (sizeof(mHobFlushComplete))
+ );
+ if (Status != EFI_UNSUPPORTED && EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
// Send data to SMM.
//
Status = mMmCommunication2->Communicate (mMmCommunication2, CommBuffer, CommBuffer, &CommSize);
|