mirror of https://github.com/acidanthera/audk.git
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 <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14463 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
0dda774c86
commit
2c4b18e095
|
@ -548,7 +548,7 @@
|
||||||
## The size of volatile buffer. This buffer is used to store VOLATILE attribute variable.
|
## The size of volatile buffer. This buffer is used to store VOLATILE attribute variable.
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x10000|UINT32|0x30000005
|
gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x10000|UINT32|0x30000005
|
||||||
|
|
||||||
## Size of the FTW spare block range. Note that this value should larger than PcdFlashNvStorageVariableSize
|
## Size of the FTW spare block range. Note that this value should larger than PcdFlashNvStorageVariableSize and block size aligned.
|
||||||
# The root cause is that variable driver will use FTW protocol to reclaim variable region.
|
# The root cause is that variable driver will use FTW protocol to reclaim variable region.
|
||||||
# If the length of variable region is larger than FTW spare size, it means the whole variable region can not
|
# If the length of variable region is larger than FTW spare size, it means the whole variable region can not
|
||||||
# be reflushed through the manner of fault tolerant write.
|
# be reflushed through the manner of fault tolerant write.
|
||||||
|
@ -679,7 +679,7 @@
|
||||||
## Base address of the NV variable range in flash device
|
## Base address of the NV variable range in flash device
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x0|UINT32|0x30000001
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x0|UINT32|0x30000001
|
||||||
|
|
||||||
## Base address of the FTW spare block range in flash device.
|
## Base address of the FTW spare block range in flash device. Note that this value should be block size aligned.
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x0|UINT32|0x30000013
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x0|UINT32|0x30000013
|
||||||
|
|
||||||
## Base address of the FTW working block range in flash device.
|
## Base address of the FTW working block range in flash device.
|
||||||
|
@ -688,7 +688,7 @@
|
||||||
## 64-bit Base address of the NV variable range in flash device
|
## 64-bit Base address of the NV variable range in flash device
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0x0|UINT64|0x80000001
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0x0|UINT64|0x80000001
|
||||||
|
|
||||||
## 64-bit Base address of the FTW spare block range in flash device.
|
## 64-bit Base address of the FTW spare block range in flash device. Note that this value should be block size aligned.
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0x0|UINT64|0x80000013
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0x0|UINT64|0x80000013
|
||||||
|
|
||||||
## 64-bit Base address of the FTW working block range in flash device.
|
## 64-bit Base address of the FTW working block range in flash device.
|
||||||
|
|
|
@ -32,6 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/ReportStatusCodeLib.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// Flash erase polarity is 1
|
// Flash erase polarity is 1
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
DebugLib
|
DebugLib
|
||||||
UefiLib
|
UefiLib
|
||||||
PcdLib
|
PcdLib
|
||||||
|
ReportStatusCodeLib
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gEdkiiWorkingBlockSignatureGuid ## CONSUMES ## FV Signature of Working Space Header
|
gEdkiiWorkingBlockSignatureGuid ## CONSUMES ## FV Signature of Working Space Header
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
DebugLib
|
DebugLib
|
||||||
UefiLib
|
UefiLib
|
||||||
PcdLib
|
PcdLib
|
||||||
|
ReportStatusCodeLib
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gEdkiiWorkingBlockSignatureGuid ## CONSUMES ## FV Signature of Working Space Header
|
gEdkiiWorkingBlockSignatureGuid ## CONSUMES ## FV Signature of Working Space Header
|
||||||
|
|
|
@ -1111,6 +1111,20 @@ FindFvbForFtw (
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return EFI_ABORTED;
|
return EFI_ABORTED;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// Check the alignment of spare area address and length, they should be block size aligned
|
||||||
|
//
|
||||||
|
if (((FtwDevice->SpareAreaAddress & (FtwDevice->BlockSize - 1)) != 0) ||
|
||||||
|
((FtwDevice->SpareAreaLength & (FtwDevice->BlockSize - 1)) != 0)) {
|
||||||
|
DEBUG ((EFI_D_ERROR, "Ftw: Spare area address or length is not block size aligned\n"));
|
||||||
|
FreePool (HandleBuffer);
|
||||||
|
//
|
||||||
|
// Report Status Code EFI_SW_EC_ABORTED.
|
||||||
|
//
|
||||||
|
REPORT_STATUS_CODE ( (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ABORTED));
|
||||||
|
ASSERT (FALSE);
|
||||||
|
CpuDeadLoop ();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,6 +335,7 @@ FtwNotificationEvent (
|
||||||
UINT64 Length;
|
UINT64 Length;
|
||||||
EFI_PHYSICAL_ADDRESS VariableStoreBase;
|
EFI_PHYSICAL_ADDRESS VariableStoreBase;
|
||||||
UINT64 VariableStoreLength;
|
UINT64 VariableStoreLength;
|
||||||
|
UINTN FtwMaxBlockSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Ensure FTW protocol is installed.
|
// Ensure FTW protocol is installed.
|
||||||
|
@ -344,6 +345,11 @@ FtwNotificationEvent (
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find the proper FVB protocol for variable.
|
// Find the proper FVB protocol for variable.
|
||||||
//
|
//
|
||||||
|
|
|
@ -792,6 +792,7 @@ SmmFtwNotificationEvent (
|
||||||
EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol;
|
EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol;
|
||||||
EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
|
EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
|
||||||
EFI_PHYSICAL_ADDRESS NvStorageVariableBase;
|
EFI_PHYSICAL_ADDRESS NvStorageVariableBase;
|
||||||
|
UINTN FtwMaxBlockSize;
|
||||||
|
|
||||||
if (mVariableModuleGlobal->FvbInstance != NULL) {
|
if (mVariableModuleGlobal->FvbInstance != NULL) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -805,6 +806,11 @@ SmmFtwNotificationEvent (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find the proper FVB protocol for variable.
|
// Find the proper FVB protocol for variable.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue