From nobody Mon Feb 9 10:48:23 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1530181343715406.1757431689116; Thu, 28 Jun 2018 03:22:23 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 638EA202E5456; Thu, 28 Jun 2018 03:22:21 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8C43721BADAB3 for ; Thu, 28 Jun 2018 03:22:19 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jun 2018 03:22:19 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by fmsmga006.fm.intel.com with ESMTP; 28 Jun 2018 03:22:18 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,283,1526367600"; d="scan'208";a="241350789" From: Star Zeng To: edk2-devel@lists.01.org Date: Thu, 28 Jun 2018 18:22:15 +0800 Message-Id: <1530181335-174468-3-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1530181335-174468-1-git-send-email-star.zeng@intel.com> References: <1530181335-174468-1-git-send-email-star.zeng@intel.com> Subject: [edk2] [PATCH 2/2] MdeModulePkg Variable: Make sure no more than one Variable HOB X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Jiewen Yao , Liming Gao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Cc: Jiewen Yao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng --- MdeModulePkg/Universal/Variable/Pei/Variable.c | 24 ++++++++++++++++++= ++++ .../Universal/Variable/RuntimeDxe/Variable.c | 24 ++++++++++++++++++= ++++ 2 files changed, 48 insertions(+) diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c b/MdeModulePkg/= Universal/Variable/Pei/Variable.c index 1bcab3b770a5..d75a13e2b079 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; =20 + // + // Make sure there is no more than one Variable HOB. + // + DEBUG_CODE ( + GuidHob =3D GetFirstGuidHob (&gEfiAuthenticatedVariableGuid); + if (GuidHob !=3D NULL) { + if ((GetNextGuidHob (&gEfiAuthenticatedVariableGuid, GET_NEXT_HOB (G= uidHob)) !=3D NULL)) { + DEBUG ((DEBUG_ERROR, "ERROR: Found two Auth Variable HOBs\n")); + ASSERT (FALSE); + } else if (GetFirstGuidHob (&gEfiVariableGuid) !=3D NULL) { + DEBUG ((DEBUG_ERROR, "ERROR: Found one Auth + one Normal Variable = HOBs\n")); + ASSERT (FALSE); + } + } else { + GuidHob =3D GetFirstGuidHob (&gEfiVariableGuid); + if (GuidHob !=3D NULL) { + if ((GetNextGuidHob (&gEfiVariableGuid, GET_NEXT_HOB (GuidHob)) != =3D NULL)) { + DEBUG ((DEBUG_ERROR, "ERROR: Found two Normal Variable HOBs\n")); + ASSERT (FALSE); + } + } + } + ); + GuidHob =3D GetFirstGuidHob (&gEfiAuthenticatedVariableGuid); if (GuidHob !=3D NULL) { *VariableStoreHeader =3D (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (= GuidHob); diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeMod= ulePkg/Universal/Variable/RuntimeDxe/Variable.c index fca8d5380924..42b0bfda570d 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -4190,6 +4190,30 @@ GetHobVariableStore ( BOOLEAN NeedConvertNormalToAuth; =20 // + // Make sure there is no more than one Variable HOB. + // + DEBUG_CODE ( + GuidHob =3D GetFirstGuidHob (&gEfiAuthenticatedVariableGuid); + if (GuidHob !=3D NULL) { + if ((GetNextGuidHob (&gEfiAuthenticatedVariableGuid, GET_NEXT_HOB (G= uidHob)) !=3D NULL)) { + DEBUG ((DEBUG_ERROR, "ERROR: Found two Auth Variable HOBs\n")); + ASSERT (FALSE); + } else if (GetFirstGuidHob (&gEfiVariableGuid) !=3D NULL) { + DEBUG ((DEBUG_ERROR, "ERROR: Found one Auth + one Normal Variable = HOBs\n")); + ASSERT (FALSE); + } + } else { + GuidHob =3D GetFirstGuidHob (&gEfiVariableGuid); + if (GuidHob !=3D NULL) { + if ((GetNextGuidHob (&gEfiVariableGuid, GET_NEXT_HOB (GuidHob)) != =3D NULL)) { + DEBUG ((DEBUG_ERROR, "ERROR: Found two Normal Variable HOBs\n")); + ASSERT (FALSE); + } + } + } + ); + + // // Combinations supported: // 1. Normal NV variable store + // Normal HOB variable store --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel