summaryrefslogtreecommitdiff
path: root/SecurityPkg
diff options
context:
space:
mode:
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-06 03:20:10 +0000
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-06 03:20:10 +0000
commit8f3a9e58626b72e837dc5f389016a39ecadffcc5 (patch)
tree85ef1cf84650c8f2a9b5897920d3278cfb0533f2 /SecurityPkg
parent40ef06fc2a95bd55ea04f63cff53952bec6e1971 (diff)
downloadedk2-platforms-8f3a9e58626b72e837dc5f389016a39ecadffcc5.tar.xz
LastVariableOffset is wrongly set to 0 when FtwVariableSpace() fails. Recalculate the HwErrVariableTotalSize, HwErrVariableTotalSize and LastVariableOffset when FtwVariableSpace() fails.
Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Guo Dong <guo.dong@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13593 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SecurityPkg')
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
index 93d0e25eac..07fe99bee7 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
@@ -553,15 +553,13 @@ Reclaim (
EFI_STATUS Status;
CHAR16 *VariableNamePtr;
CHAR16 *UpdatingVariableNamePtr;
+ UINTN CommonVariableTotalSize;
+ UINTN HwErrVariableTotalSize;
VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) VariableBase);
- //
- // Recalculate the total size of Common/HwErr type variables in non-volatile area.
- //
- if (!IsVolatile) {
- mVariableModuleGlobal->CommonVariableTotalSize = 0;
- mVariableModuleGlobal->HwErrVariableTotalSize = 0;
- }
+
+ CommonVariableTotalSize = 0;
+ HwErrVariableTotalSize = 0;
//
// Start Pointers for the variable.
@@ -628,9 +626,9 @@ Reclaim (
CopyMem (CurrPtr, (UINT8 *) Variable, VariableSize);
CurrPtr += VariableSize;
if ((!IsVolatile) && ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {
- mVariableModuleGlobal->HwErrVariableTotalSize += VariableSize;
+ HwErrVariableTotalSize += VariableSize;
} else if ((!IsVolatile) && ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {
- mVariableModuleGlobal->CommonVariableTotalSize += VariableSize;
+ CommonVariableTotalSize += VariableSize;
}
}
Variable = NextVariable;
@@ -644,9 +642,9 @@ Reclaim (
CopyMem (CurrPtr, (UINT8 *) UpdatingVariable, VariableSize);
CurrPtr += VariableSize;
if ((!IsVolatile) && ((UpdatingVariable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {
- mVariableModuleGlobal->HwErrVariableTotalSize += VariableSize;
+ HwErrVariableTotalSize += VariableSize;
} else if ((!IsVolatile) && ((UpdatingVariable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {
- mVariableModuleGlobal->CommonVariableTotalSize += VariableSize;
+ CommonVariableTotalSize += VariableSize;
}
}
@@ -690,9 +688,9 @@ Reclaim (
((VARIABLE_HEADER *) CurrPtr)->State = VAR_ADDED;
CurrPtr += VariableSize;
if ((!IsVolatile) && ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {
- mVariableModuleGlobal->HwErrVariableTotalSize += VariableSize;
+ HwErrVariableTotalSize += VariableSize;
} else if ((!IsVolatile) && ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {
- mVariableModuleGlobal->CommonVariableTotalSize += VariableSize;
+ CommonVariableTotalSize += VariableSize;
}
}
}
@@ -720,8 +718,23 @@ Reclaim (
}
if (!EFI_ERROR (Status)) {
*LastVariableOffset = (UINTN) (CurrPtr - (UINT8 *) ValidBuffer);
+ if (!IsVolatile) {
+ mVariableModuleGlobal->HwErrVariableTotalSize = HwErrVariableTotalSize;
+ mVariableModuleGlobal->CommonVariableTotalSize = CommonVariableTotalSize;
+ }
} else {
- *LastVariableOffset = 0;
+ NextVariable = GetStartPointer ((VARIABLE_STORE_HEADER *)(UINTN)VariableBase);
+ while (IsValidVariableHeader (NextVariable)) {
+ VariableSize = NextVariable->NameSize + NextVariable->DataSize + sizeof (VARIABLE_HEADER);
+ if ((!IsVolatile) && ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {
+ mVariableModuleGlobal->HwErrVariableTotalSize += HEADER_ALIGN (VariableSize);
+ } else if ((!IsVolatile) && ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {
+ mVariableModuleGlobal->CommonVariableTotalSize += HEADER_ALIGN (VariableSize);
+ }
+
+ NextVariable = GetNextVariablePtr (NextVariable);
+ }
+ *LastVariableOffset = (UINTN) NextVariable - (UINTN) VariableBase;
}
FreePool (ValidBuffer);