From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: hao.a.wu@intel.com) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by groups.io with SMTP; Thu, 03 Oct 2019 01:03:52 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Oct 2019 01:03:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,251,1566889200"; d="scan'208";a="366971140" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga005.jf.intel.com with ESMTP; 03 Oct 2019 01:03:51 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 3 Oct 2019 01:03:39 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 3 Oct 2019 01:03:39 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.166]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.119]) with mapi id 14.03.0439.000; Thu, 3 Oct 2019 16:03:37 +0800 From: "Wu, Hao A" To: "Kubacki, Michael A" , "devel@edk2.groups.io" CC: "Bi, Dandan" , Ard Biesheuvel , "Dong, Eric" , Laszlo Ersek , "Gao, Liming" , "Kinney, Michael D" , "Ni, Ray" , "Wang, Jian J" , "Yao, Jiewen" Subject: Re: [PATCH V2 3/9] MdeModulePkg/Variable: Parameterize VARIABLE_INFO_ENTRY buffer Thread-Topic: [PATCH V2 3/9] MdeModulePkg/Variable: Parameterize VARIABLE_INFO_ENTRY buffer Thread-Index: AQHVdZ61sWwVTyB4eUeIO+dh4/6Kh6dCNuWQ Date: Thu, 3 Oct 2019 08:03:36 +0000 Message-ID: References: <20190928014717.31372-1-michael.a.kubacki@intel.com> <20190928014717.31372-4-michael.a.kubacki@intel.com> In-Reply-To: <20190928014717.31372-4-michael.a.kubacki@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: hao.a.wu@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Kubacki, Michael A > Sent: Saturday, September 28, 2019 9:47 AM > To: devel@edk2.groups.io > Cc: Bi, Dandan; Ard Biesheuvel; Dong, Eric; Laszlo Ersek; Gao, Liming; Ki= nney, > Michael D; Ni, Ray; Wang, Jian J; Wu, Hao A; Yao, Jiewen > Subject: [PATCH V2 3/9] MdeModulePkg/Variable: Parameterize > VARIABLE_INFO_ENTRY buffer >=20 > 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 can be updated outside the fixed global variable. For: "... so structures can be updated outside the fixed global variable " Do you mean: VARIABLE_INFO_ENTRY structure pointers other than "&gVariableInfo" can be passed to UpdateVariableInfo(). Is my understanding correct? If so, Reviewed-by: Hao A Wu Best Regards, Hao Wu >=20 > 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(-) >=20 > diff --git > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h > index 0d231511ea..6f2000f3ee 100644 > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h > @@ -286,13 +286,14 @@ GetNextVariableEx ( > 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_ENTRY 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/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > index 816e8f7b8f..1a57d7e1ba 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, FALS= E, > TRUE, FALSE); > + UpdateVariableInfo (VariableName, VendorGuid, FALSE, FALSE, FALS= E, > 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, jus= t > return. > // > - UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, > FALSE, TRUE, FALSE, FALSE); > + UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, > FALSE, 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) > CacheVariable->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- > >CommonUserVariableTotalSize) > mVariableModuleGlobal- > >CommonMaxUserVariableSpace)) { > @@ -2156,7 +2156,7 @@ UpdateVariable ( > CacheVariable->CurrPtr =3D (VARIABLE_HEADER *)((UINTN) > CacheVariable->StartPtr + ((UINTN) Variable->CurrPtr - (UINTN) Variable- > >StartPtr)); > CacheVariable->InDeletedTransitionPtr =3D NULL; > } > - UpdateVariableInfo (VariableName, VendorGuid, TRUE, FALSE, TRUE, > FALSE, FALSE); > + UpdateVariableInfo (VariableName, VendorGuid, TRUE, FALSE, TRUE, > FALSE, FALSE, &gVariableInfo); > } > goto Done; > } > @@ -2227,7 +2227,7 @@ UpdateVariable ( > } >=20 > if (!EFI_ERROR (Status)) { > - UpdateVariableInfo (VariableName, VendorGuid, Volatile, FALSE, TRUE, > FALSE, FALSE); > + UpdateVariableInfo (VariableName, VendorGuid, Volatile, FALSE, TRUE, > FALSE, FALSE, &gVariableInfo); > if (!Volatile) { > FlushHobVariableToFlash (VariableName, VendorGuid); > } > @@ -2306,7 +2306,7 @@ VariableServiceGetVariable ( > } >=20 > *DataSize =3D VarDataSize; > - UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRU= E, > FALSE, FALSE, FALSE); > + UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRU= E, > 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 9bc5369a90..394195342d 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_ENTRY 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 || VariableIn= fo =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(CHAR1= 6), > 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->Ne= xt) { > 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; > } > - > } > } > } > -- > 2.16.2.windows.1