summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2024-05-31 12:27:54 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-07-07 08:40:03 +0000
commit0986faad973c8d2e98cb8733f9c58d0210f458f4 (patch)
tree0a48fa91952ad641f54698bde7c3b5324db6bdfd
parent8befdb144193f0fe10c39ab0c21e138c59018b05 (diff)
downloadedk2-0986faad973c8d2e98cb8733f9c58d0210f458f4.tar.gz
edk2-0986faad973c8d2e98cb8733f9c58d0210f458f4.tar.bz2
edk2-0986faad973c8d2e98cb8733f9c58d0210f458f4.zip
MdeModulePkg/VariableSmm: Fix NonPrimary Buffer check issue
VariableSmmIsBufferOutsideSmmValid function is to check the buffer is outside SMM or not. This patch fix the issue that always return true for MM. Meanwhile, this patch renames VariableSmmIsBufferOutsideSmmValid to VariableSmmIsNonPrimaryBufferValid. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Dun Tan <dun.tan@intel.com> Cc: Yuanhao Xie <yuanhao.xie@intel.com>
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h4
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c12
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c6
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf3
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c2
5 files changed, 14 insertions, 13 deletions
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
index 23e950aaed..e7bd4c9706 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
@@ -123,7 +123,7 @@ MmVariableServiceInitialize (
);
/**
- This function checks if the communication buffer is valid.
+ This function checks if the Primary Buffer (CommBuffer) is valid.
@param Buffer The buffer start address to be checked.
@param Length The buffer length to be checked.
@@ -150,7 +150,7 @@ VariableSmmIsPrimaryBufferValid (
with SMRAM.
**/
BOOLEAN
-VariableSmmIsBufferOutsideSmmValid (
+VariableSmmIsNonPrimaryBufferValid (
IN EFI_PHYSICAL_ADDRESS Buffer,
IN UINT64 Length
);
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
index 189880c817..12b76a9746 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
@@ -864,7 +864,7 @@ SmmVariableHandler (
// Verify runtime buffers do not overlap with SMRAM ranges.
//
if ((RuntimeVariableCacheContext->RuntimeHobCache != NULL) &&
- !VariableSmmIsBufferOutsideSmmValid (
+ !VariableSmmIsNonPrimaryBufferValid (
(UINTN)RuntimeVariableCacheContext->RuntimeHobCache,
(UINTN)RuntimeVariableCacheContext->RuntimeHobCache->Size
))
@@ -874,7 +874,7 @@ SmmVariableHandler (
goto EXIT;
}
- if (!VariableSmmIsBufferOutsideSmmValid (
+ if (!VariableSmmIsNonPrimaryBufferValid (
(UINTN)RuntimeVariableCacheContext->RuntimeVolatileCache,
(UINTN)RuntimeVariableCacheContext->RuntimeVolatileCache->Size
))
@@ -884,7 +884,7 @@ SmmVariableHandler (
goto EXIT;
}
- if (!VariableSmmIsBufferOutsideSmmValid (
+ if (!VariableSmmIsNonPrimaryBufferValid (
(UINTN)RuntimeVariableCacheContext->RuntimeNvCache,
(UINTN)RuntimeVariableCacheContext->RuntimeNvCache->Size
))
@@ -894,7 +894,7 @@ SmmVariableHandler (
goto EXIT;
}
- if (!VariableSmmIsBufferOutsideSmmValid (
+ if (!VariableSmmIsNonPrimaryBufferValid (
(UINTN)RuntimeVariableCacheContext->PendingUpdate,
sizeof (*(RuntimeVariableCacheContext->PendingUpdate))
))
@@ -904,7 +904,7 @@ SmmVariableHandler (
goto EXIT;
}
- if (!VariableSmmIsBufferOutsideSmmValid (
+ if (!VariableSmmIsNonPrimaryBufferValid (
(UINTN)RuntimeVariableCacheContext->ReadLock,
sizeof (*(RuntimeVariableCacheContext->ReadLock))
))
@@ -914,7 +914,7 @@ SmmVariableHandler (
goto EXIT;
}
- if (!VariableSmmIsBufferOutsideSmmValid (
+ if (!VariableSmmIsNonPrimaryBufferValid (
(UINTN)RuntimeVariableCacheContext->HobFlushComplete,
sizeof (*(RuntimeVariableCacheContext->HobFlushComplete))
))
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
index 1e1e933405..1b9cf6dfd9 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
@@ -7,7 +7,7 @@ Copyright (c) 2018, Linaro, Ltd. All rights reserved. <BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
+#include <Library/StandaloneMmMemLib.h>
#include "Variable.h"
/**
@@ -41,12 +41,12 @@ VariableSmmIsPrimaryBufferValid (
with SMRAM.
**/
BOOLEAN
-VariableSmmIsBufferOutsideSmmValid (
+VariableSmmIsNonPrimaryBufferValid (
IN EFI_PHYSICAL_ADDRESS Buffer,
IN UINT64 Length
)
{
- return TRUE;
+ return MmIsBufferOutsideMmValid (Buffer, Length);
}
/**
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
index f09bed40cf..c4185718aa 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
@@ -18,7 +18,7 @@
# may not be modified without authorization. If platform fails to protect these resources,
# the authentication service provided in this driver will be broken, and the behavior is undefined.
#
-# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2024, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -71,6 +71,7 @@
BaseMemoryLib
DebugLib
HobLib
+ MemLib
MemoryAllocationLib
MmServicesTableLib
SafeIntLib
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
index 35f6f4b04f..7247f7574d 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
@@ -43,7 +43,7 @@ VariableSmmIsPrimaryBufferValid (
with SMRAM.
**/
BOOLEAN
-VariableSmmIsBufferOutsideSmmValid (
+VariableSmmIsNonPrimaryBufferValid (
IN EFI_PHYSICAL_ADDRESS Buffer,
IN UINT64 Length
)