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>
This commit is contained in:
Jiaxin Wu 2024-05-31 12:27:54 +08:00 committed by mergify[bot]
parent 8befdb1441
commit 0986faad97
5 changed files with 14 additions and 13 deletions

View File

@ -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
);

View File

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

View File

@ -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);
}
/**

View File

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

View File

@ -43,7 +43,7 @@ VariableSmmIsPrimaryBufferValid (
with SMRAM.
**/
BOOLEAN
VariableSmmIsBufferOutsideSmmValid (
VariableSmmIsNonPrimaryBufferValid (
IN EFI_PHYSICAL_ADDRESS Buffer,
IN UINT64 Length
)