From nobody Tue Nov 26 16:39:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+49724+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49724+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1572504340; cv=none; d=zoho.com; s=zohoarc; b=AQVWrxRDUzAzfJME4y2CSjsQST+wIBZn46ppIR3IoSPPjBGQECK5R9upFDvD+zwDqiaIU2STV5Fj9EeHAKyFmKihG1W7uyS3D50w6qikCfuMt9rLvOF9qG4OR+KZLaVBJrGDYWH+d255n+mF/xImZcGOLLELOZj4XUkQojulpmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572504340; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=2yfnHUd7BQ7USpwzTXvBKgdO50CF3TY6j44TEp2bhA4=; b=QBEpwxHItEFrCCIBdhc0lZFYUSIXfKg6ZdZjFGVpL+aEY35WZBW4F9NvNLVamn5gMgZq8n9DNYaIKKFbEP34V38E13k3WeAftX228+LDzi2vUlIm9OPLK/sSGQdR8XLhGSAie6wsIAMUlj/eQLdvVnzA1bSETJ34g5Vd57dDqpM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49724+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1572504340227701.7341793308065; Wed, 30 Oct 2019 23:45:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id bCp1YY1788612xalOLrepKCi; Wed, 30 Oct 2019 23:45:39 -0700 X-Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web10.2575.1572504335480868589 for ; Wed, 30 Oct 2019 23:45:39 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2019 23:45:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,250,1569308400"; d="scan'208";a="351547355" X-Received: from makuback-desk1.amr.corp.intel.com ([10.7.159.162]) by orsmga004.jf.intel.com with ESMTP; 30 Oct 2019 23:45:38 -0700 From: "Kubacki, Michael A" To: devel@edk2.groups.io Cc: Dandan Bi , Ard Biesheuvel , Eric Dong , Laszlo Ersek , Liming Gao , Michael D Kinney , Ray Ni , Jian J Wang , Hao A Wu , Jiewen Yao Subject: [edk2-devel] [PATCH V6 03/10] MdeModulePkg/Variable: Parameterize VARIABLE_INFO_ENTRY buffer Date: Wed, 30 Oct 2019 23:45:03 -0700 Message-Id: <20191031064510.23948-4-michael.a.kubacki@intel.com> In-Reply-To: <20191031064510.23948-1-michael.a.kubacki@intel.com> References: <20191031064510.23948-1-michael.a.kubacki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.a.kubacki@intel.com X-Gm-Message-State: j9SzzIm0RGZL4hObqHCtCrckx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1572504339; bh=/+15HUsG1JOKfEKJZE8txOdEUlX0B9EG9UzbV3B6r6k=; h=Cc:Date:From:Reply-To:Subject:To; b=wT23OUYjlKAmJtVyPu6f5T/xUpeWdOehGxxkQegVumfA0fNJ5QKqf9zq9aT6HCyAvV6 ICfHykZNHCjZXnhqZF244SWVBd8t6Jpon9NQP198umkWjBtlpmZ18m02SkzH4dLwg4huG LCSf0M1eGqlzONu4XYkgXNnTdu1IAjQ7aDA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" UpdateVariableInfo () currently accepts parameters regarding updates to be made to a global variable of type VARIABLE_INFO_ENTRY. This change passes the structure by pointer to UpdateVariableInfo () so structures other than the fixed global variable can be updated. Cc: Dandan Bi Cc: Ard Biesheuvel Cc: Eric Dong Cc: Laszlo Ersek Cc: Liming Gao Cc: Michael D Kinney Cc: Ray Ni Cc: Jian J Wang Cc: Hao A Wu Cc: Jiewen Yao Signed-off-by: Michael Kubacki --- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h | 18 +++++---- MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 14 +++---- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c | 41 ++++++++= +++--------- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h b= /MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h index 6555316f52..1777ce0e69 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h @@ -286,13 +286,14 @@ VariableServiceGetNextVariableInternal ( the transaction. Data is allocated by this routine, but never freed. =20 - @param[in] VariableName Name of the Variable to track. - @param[in] VendorGuid Guid of the Variable to track. - @param[in] Volatile TRUE if volatile FALSE if non-volatile. - @param[in] Read TRUE if GetVariable() was called. - @param[in] Write TRUE if SetVariable() was called. - @param[in] Delete TRUE if deleted via SetVariable(). - @param[in] Cache TRUE for a cache hit. + @param[in] VariableName Name of the Variable to track. + @param[in] VendorGuid Guid of the Variable to track. + @param[in] Volatile TRUE if volatile FALSE if non-volatile. + @param[in] Read TRUE if GetVariable() was called. + @param[in] Write TRUE if SetVariable() was called. + @param[in] Delete TRUE if deleted via SetVariable(). + @param[in] Cache TRUE for a cache hit. + @param[in,out] VariableInfo Pointer to a pointer of VARIABLE_INFO_ENT= RY structures. =20 **/ VOID @@ -303,7 +304,8 @@ UpdateVariableInfo ( IN BOOLEAN Read, IN BOOLEAN Write, IN BOOLEAN Delete, - IN BOOLEAN Cache + IN BOOLEAN Cache, + IN OUT VARIABLE_INFO_ENTRY **VariableInfo ); =20 #endif diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeMod= ulePkg/Universal/Variable/RuntimeDxe/Variable.c index 70af86db24..5cc12c2ae0 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -1641,7 +1641,7 @@ UpdateVariable ( // go to delete this variable in variable HOB and // try to flush other variables from HOB to flash. // - UpdateVariableInfo (VariableName, VendorGuid, FALSE, FALSE, FALSE,= TRUE, FALSE); + UpdateVariableInfo (VariableName, VendorGuid, FALSE, FALSE, FALSE,= TRUE, FALSE, &gVariableInfo); FlushHobVariableToFlash (VariableName, VendorGuid); return EFI_SUCCESS; } @@ -1758,7 +1758,7 @@ UpdateVariable ( &State ); if (!EFI_ERROR (Status)) { - UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, = FALSE, FALSE, TRUE, FALSE); + UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, = FALSE, FALSE, TRUE, FALSE, &gVariableInfo); if (!Variable->Volatile) { CacheVariable->CurrPtr->State =3D State; FlushHobVariableToFlash (VariableName, VendorGuid); @@ -1777,7 +1777,7 @@ UpdateVariable ( // // Variable content unchanged and no need to update timestamp, just = return. // - UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, FA= LSE, TRUE, FALSE, FALSE); + UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, FA= LSE, TRUE, FALSE, FALSE, &gVariableInfo); Status =3D EFI_SUCCESS; goto Done; } else if ((CacheVariable->CurrPtr->State =3D=3D VAR_ADDED) || @@ -2006,7 +2006,7 @@ UpdateVariable ( CacheVariable->CurrPtr =3D (VARIABLE_HEADER *)((UINTN) CacheVari= able->StartPtr + ((UINTN) Variable->CurrPtr - (UINTN) Variable->StartPtr)); CacheVariable->InDeletedTransitionPtr =3D NULL; } - UpdateVariableInfo (VariableName, VendorGuid, FALSE, FALSE, TRUE, = FALSE, FALSE); + UpdateVariableInfo (VariableName, VendorGuid, FALSE, FALSE, TRUE, = FALSE, FALSE, &gVariableInfo); FlushHobVariableToFlash (VariableName, VendorGuid); } else { if (IsCommonUserVariable && ((VarSize + mVariableModuleGlobal->Com= monUserVariableTotalSize) > mVariableModuleGlobal->CommonMaxUserVariableSpa= ce)) { @@ -2156,7 +2156,7 @@ UpdateVariable ( CacheVariable->CurrPtr =3D (VARIABLE_HEADER *)((UINTN) CacheVari= able->StartPtr + ((UINTN) Variable->CurrPtr - (UINTN) Variable->StartPtr)); CacheVariable->InDeletedTransitionPtr =3D NULL; } - UpdateVariableInfo (VariableName, VendorGuid, TRUE, FALSE, TRUE, F= ALSE, FALSE); + UpdateVariableInfo (VariableName, VendorGuid, TRUE, FALSE, TRUE, F= ALSE, FALSE, &gVariableInfo); } goto Done; } @@ -2227,7 +2227,7 @@ UpdateVariable ( } =20 if (!EFI_ERROR (Status)) { - UpdateVariableInfo (VariableName, VendorGuid, Volatile, FALSE, TRUE, F= ALSE, FALSE); + UpdateVariableInfo (VariableName, VendorGuid, Volatile, FALSE, TRUE, F= ALSE, FALSE, &gVariableInfo); if (!Volatile) { FlushHobVariableToFlash (VariableName, VendorGuid); } @@ -2306,7 +2306,7 @@ VariableServiceGetVariable ( } =20 *DataSize =3D VarDataSize; - UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE,= FALSE, FALSE, FALSE); + UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE,= FALSE, FALSE, FALSE, &gVariableInfo); =20 Status =3D EFI_SUCCESS; goto Done; diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c b= /MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c index d6bb916e68..870c9e3742 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c @@ -660,13 +660,14 @@ Done: the transaction. Data is allocated by this routine, but never freed. =20 - @param[in] VariableName Name of the Variable to track. - @param[in] VendorGuid Guid of the Variable to track. - @param[in] Volatile TRUE if volatile FALSE if non-volatile. - @param[in] Read TRUE if GetVariable() was called. - @param[in] Write TRUE if SetVariable() was called. - @param[in] Delete TRUE if deleted via SetVariable(). - @param[in] Cache TRUE for a cache hit. + @param[in] VariableName Name of the Variable to track. + @param[in] VendorGuid Guid of the Variable to track. + @param[in] Volatile TRUE if volatile FALSE if non-volatile. + @param[in] Read TRUE if GetVariable() was called. + @param[in] Write TRUE if SetVariable() was called. + @param[in] Delete TRUE if deleted via SetVariable(). + @param[in] Cache TRUE for a cache hit. + @param[in,out] VariableInfo Pointer to a pointer of VARIABLE_INFO_ENT= RY structures. =20 **/ VOID @@ -677,35 +678,38 @@ UpdateVariableInfo ( IN BOOLEAN Read, IN BOOLEAN Write, IN BOOLEAN Delete, - IN BOOLEAN Cache + IN BOOLEAN Cache, + IN OUT VARIABLE_INFO_ENTRY **VariableInfo ) { VARIABLE_INFO_ENTRY *Entry; =20 if (FeaturePcdGet (PcdVariableCollectStatistics)) { - + if (VariableName =3D=3D NULL || VendorGuid =3D=3D NULL || VariableInfo= =3D=3D NULL) { + return; + } if (AtRuntime ()) { // Don't collect statistics at runtime. return; } =20 - if (gVariableInfo =3D=3D NULL) { + if (*VariableInfo =3D=3D NULL) { // // On the first call allocate a entry and place a pointer to it in // the EFI System Table. // - gVariableInfo =3D AllocateZeroPool (sizeof (VARIABLE_INFO_ENTRY)); - ASSERT (gVariableInfo !=3D NULL); + *VariableInfo =3D AllocateZeroPool (sizeof (VARIABLE_INFO_ENTRY)); + ASSERT (*VariableInfo !=3D NULL); =20 - CopyGuid (&gVariableInfo->VendorGuid, VendorGuid); - gVariableInfo->Name =3D AllocateZeroPool (StrSize (VariableName)); - ASSERT (gVariableInfo->Name !=3D NULL); - StrCpyS (gVariableInfo->Name, StrSize(VariableName)/sizeof(CHAR16), = VariableName); - gVariableInfo->Volatile =3D Volatile; + CopyGuid (&(*VariableInfo)->VendorGuid, VendorGuid); + (*VariableInfo)->Name =3D AllocateZeroPool (StrSize (VariableName)); + ASSERT ((*VariableInfo)->Name !=3D NULL); + StrCpyS ((*VariableInfo)->Name, StrSize(VariableName)/sizeof(CHAR16)= , VariableName); + (*VariableInfo)->Volatile =3D Volatile; } =20 =20 - for (Entry =3D gVariableInfo; Entry !=3D NULL; Entry =3D Entry->Next) { + for (Entry =3D (*VariableInfo); Entry !=3D NULL; Entry =3D Entry->Next= ) { if (CompareGuid (VendorGuid, &Entry->VendorGuid)) { if (StrCmp (VariableName, Entry->Name) =3D=3D 0) { if (Read) { @@ -739,7 +743,6 @@ UpdateVariableInfo ( StrCpyS (Entry->Next->Name, StrSize(VariableName)/sizeof(CHAR16), = VariableName); Entry->Next->Volatile =3D Volatile; } - } } } --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#49724): https://edk2.groups.io/g/devel/message/49724 Mute This Topic: https://groups.io/mt/40103016/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-