From 2c4b18e09590e50c95b95fd485144d00b3b7f39f Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Thu, 11 Jul 2013 08:15:47 +0000 Subject: MdeModulePkg: Add the alignment check for FTW spare area address and length, and add the check for PcdFlashNvStorageVariableSize <= PcdFlashNvStorageFtwSpareSize. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Jiewen Yao Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14463 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c | 8 +++++++- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'MdeModulePkg/Universal/Variable/RuntimeDxe') diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c index a697ae1c3a..c02d637699 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c @@ -335,6 +335,7 @@ FtwNotificationEvent ( UINT64 Length; EFI_PHYSICAL_ADDRESS VariableStoreBase; UINT64 VariableStoreLength; + UINTN FtwMaxBlockSize; // // Ensure FTW protocol is installed. @@ -343,7 +344,12 @@ FtwNotificationEvent ( if (EFI_ERROR (Status)) { return ; } - + + Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize); + if (!EFI_ERROR (Status)) { + ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize); + } + // // Find the proper FVB protocol for variable. // diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c index 1ffa74e6cc..a80948bce8 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c @@ -792,6 +792,7 @@ SmmFtwNotificationEvent ( EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol; EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol; EFI_PHYSICAL_ADDRESS NvStorageVariableBase; + UINTN FtwMaxBlockSize; if (mVariableModuleGlobal->FvbInstance != NULL) { return EFI_SUCCESS; @@ -805,6 +806,11 @@ SmmFtwNotificationEvent ( return Status; } + Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize); + if (!EFI_ERROR (Status)) { + ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize); + } + // // Find the proper FVB protocol for variable. // -- cgit v1.2.3