Revision: 14463
http://sourceforge.net/p/edk2/code/14463
Author: lzeng14
Date: 2013-07-11 08:15:47 +0000 (Thu, 11 Jul 2013)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Jiewen Yao <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Modified Paths:
--------------
trunk/edk2/MdeModulePkg/MdeModulePkg.dec
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
Modified: trunk/edk2/MdeModulePkg/MdeModulePkg.dec
===================================================================
--- trunk/edk2/MdeModulePkg/MdeModulePkg.dec 2013-07-11 01:40:10 UTC (rev
14462)
+++ trunk/edk2/MdeModulePkg/MdeModulePkg.dec 2013-07-11 08:15:47 UTC (rev
14463)
@@ -548,7 +548,7 @@
## The size of volatile buffer. This buffer is used to store VOLATILE
attribute variable.
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.
# 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.
@@ -679,7 +679,7 @@
## Base address of the NV variable range in flash device
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
## 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
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
## 64-bit Base address of the FTW working block range in flash device.
Modified:
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
===================================================================
---
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
2013-07-11 01:40:10 UTC (rev 14462)
+++
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
2013-07-11 08:15:47 UTC (rev 14463)
@@ -32,6 +32,7 @@
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <Library/ReportStatusCodeLib.h>
//
// Flash erase polarity is 1
Modified:
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
===================================================================
---
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
2013-07-11 01:40:10 UTC (rev 14462)
+++
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
2013-07-11 08:15:47 UTC (rev 14463)
@@ -47,6 +47,7 @@
DebugLib
UefiLib
PcdLib
+ ReportStatusCodeLib
[Guids]
gEdkiiWorkingBlockSignatureGuid ## CONSUMES ## FV Signature of
Working Space Header
Modified:
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
===================================================================
---
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
2013-07-11 01:40:10 UTC (rev 14462)
+++
trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
2013-07-11 08:15:47 UTC (rev 14463)
@@ -50,6 +50,7 @@
DebugLib
UefiLib
PcdLib
+ ReportStatusCodeLib
[Guids]
gEdkiiWorkingBlockSignatureGuid ## CONSUMES ## FV Signature
of Working Space Header
Modified: trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
2013-07-11 01:40:10 UTC (rev 14462)
+++ trunk/edk2/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
2013-07-11 08:15:47 UTC (rev 14463)
@@ -1111,6 +1111,20 @@
ASSERT (FALSE);
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;
}
}
@@ -1118,12 +1132,12 @@
}
}
FreePool (HandleBuffer);
-
+
if ((FtwDevice->FtwBackupFvb == NULL) || (FtwDevice->FtwFvBlock == NULL) ||
(FtwDevice->FtwWorkSpaceLba == (EFI_LBA) (-1)) || (FtwDevice->FtwSpareLba
== (EFI_LBA) (-1))) {
return EFI_ABORTED;
}
-
+
return EFI_SUCCESS;
}
Modified: trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
2013-07-11 01:40:10 UTC (rev 14462)
+++ trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
2013-07-11 08:15:47 UTC (rev 14463)
@@ -335,6 +335,7 @@
UINT64 Length;
EFI_PHYSICAL_ADDRESS VariableStoreBase;
UINT64 VariableStoreLength;
+ UINTN FtwMaxBlockSize;
//
// Ensure FTW protocol is installed.
@@ -343,7 +344,12 @@
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.
//
Modified: trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
2013-07-11 01:40:10 UTC (rev 14462)
+++ trunk/edk2/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
2013-07-11 08:15:47 UTC (rev 14463)
@@ -792,6 +792,7 @@
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 @@
return Status;
}
+ Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);
+ if (!EFI_ERROR (Status)) {
+ ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
+ }
+
//
// Find the proper FVB protocol for variable.
//
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits