MdeModulePkg Variable: Make sure no more than one Variable HOB

VariableHob may be built in PcdPeim (by PcdNvStoreDefaultValueBuffer)
or some platform module (by some tool).
The two solutions should not be co-exist.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Star Zeng 2018-06-21 13:42:41 +08:00
parent 09808bd39b
commit fdd3e77a42
2 changed files with 48 additions and 0 deletions

View File

@ -507,6 +507,30 @@ GetHobVariableStore (
{
EFI_HOB_GUID_TYPE *GuidHob;
//
// Make sure there is no more than one Variable HOB.
//
DEBUG_CODE (
GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);
if (GuidHob != NULL) {
if ((GetNextGuidHob (&gEfiAuthenticatedVariableGuid, GET_NEXT_HOB (GuidHob)) != NULL)) {
DEBUG ((DEBUG_ERROR, "ERROR: Found two Auth Variable HOBs\n"));
ASSERT (FALSE);
} else if (GetFirstGuidHob (&gEfiVariableGuid) != NULL) {
DEBUG ((DEBUG_ERROR, "ERROR: Found one Auth + one Normal Variable HOBs\n"));
ASSERT (FALSE);
}
} else {
GuidHob = GetFirstGuidHob (&gEfiVariableGuid);
if (GuidHob != NULL) {
if ((GetNextGuidHob (&gEfiVariableGuid, GET_NEXT_HOB (GuidHob)) != NULL)) {
DEBUG ((DEBUG_ERROR, "ERROR: Found two Normal Variable HOBs\n"));
ASSERT (FALSE);
}
}
}
);
GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);
if (GuidHob != NULL) {
*VariableStoreHeader = (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (GuidHob);

View File

@ -4189,6 +4189,30 @@ GetHobVariableStore (
EFI_HOB_GUID_TYPE *GuidHob;
BOOLEAN NeedConvertNormalToAuth;
//
// Make sure there is no more than one Variable HOB.
//
DEBUG_CODE (
GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);
if (GuidHob != NULL) {
if ((GetNextGuidHob (&gEfiAuthenticatedVariableGuid, GET_NEXT_HOB (GuidHob)) != NULL)) {
DEBUG ((DEBUG_ERROR, "ERROR: Found two Auth Variable HOBs\n"));
ASSERT (FALSE);
} else if (GetFirstGuidHob (&gEfiVariableGuid) != NULL) {
DEBUG ((DEBUG_ERROR, "ERROR: Found one Auth + one Normal Variable HOBs\n"));
ASSERT (FALSE);
}
} else {
GuidHob = GetFirstGuidHob (&gEfiVariableGuid);
if (GuidHob != NULL) {
if ((GetNextGuidHob (&gEfiVariableGuid, GET_NEXT_HOB (GuidHob)) != NULL)) {
DEBUG ((DEBUG_ERROR, "ERROR: Found two Normal Variable HOBs\n"));
ASSERT (FALSE);
}
}
}
);
//
// Combinations supported:
// 1. Normal NV variable store +