summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2018-06-21 13:42:41 +0800
committerStar Zeng <star.zeng@intel.com>2018-07-02 11:23:24 +0800
commitfdd3e77a42a4d3d91536b6d1619b58562b47b0c3 (patch)
treed49eede9775c2fc3417b641b1ac730cce03e008f /MdeModulePkg
parent09808bd39b0c76559354253639766458ec24da79 (diff)
downloadedk2-fdd3e77a42a4d3d91536b6d1619b58562b47b0c3.tar.gz
edk2-fdd3e77a42a4d3d91536b6d1619b58562b47b0c3.tar.bz2
edk2-fdd3e77a42a4d3d91536b6d1619b58562b47b0c3.zip
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>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/Variable/Pei/Variable.c24
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c24
2 files changed, 48 insertions, 0 deletions
diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c b/MdeModulePkg/Universal/Variable/Pei/Variable.c
index 1bcab3b770..d75a13e2b0 100644
--- a/MdeModulePkg/Universal/Variable/Pei/Variable.c
+++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c
@@ -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);
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index fca8d53809..42b0bfda57 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -4190,6 +4190,30 @@ GetHobVariableStore (
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 +
// Normal HOB variable store