From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org 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 A4D142119C8A7 for ; Mon, 17 Dec 2018 18:10:44 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Dec 2018 18:10:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,367,1539673200"; d="scan'208";a="101462402" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga006.jf.intel.com with ESMTP; 17 Dec 2018 18:10:44 -0800 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.408.0; Mon, 17 Dec 2018 18:10:43 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 17 Dec 2018 18:10:43 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.59]) by shsmsx102.ccr.corp.intel.com ([169.254.2.182]) with mapi id 14.03.0415.000; Tue, 18 Dec 2018 10:10:41 +0800 From: "Wang, Jian J" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Wu, Hao A" , "Gao, Liming" , "Ni, Ruiyu" , "Kinney, Michael D" , "Desimone, Nathaniel L" , "Chiu, Chasel" Thread-Topic: [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported Thread-Index: AQHUk5fmJ5HA4ubGrkSvE6Cjy0VfKaWDxn9w Date: Tue, 18 Dec 2018 02:10:41 +0000 Message-ID: References: <1544783322-17436-1-git-send-email-star.zeng@intel.com> <1544783322-17436-4-git-send-email-star.zeng@intel.com> In-Reply-To: <1544783322-17436-4-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGRlOTVmOTgtMjE5Ny00ZTg1LThkMzAtOTI2NWY3NjdmM2YwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiOUNEbFFyOXVRWVFBUjhzNEF4VUYrMjlsU1hBXC9mNVpoalFFdHNyRmtMbmRZaHVEYnRMTHFXNzlZNFY1aDYrYmwifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Dec 2018 02:10:44 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jian J Wang > -----Original Message----- > From: Zeng, Star > Sent: Friday, December 14, 2018 6:29 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Wang, Jian J ; > Wu, Hao A ; Gao, Liming ; Ni, > Ruiyu ; Kinney, Michael D ; > Desimone, Nathaniel L ; Chiu, Chasel > > Subject: [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of > PcdPeiCoreMaxFvSupported >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1405 >=20 > Background as below. >=20 > Problem: > As static configuration from the PCDs, the binary PeiCore (for example > in FSP binary with dispatch mode) could not predict how many FVs, > Files or PPIs for different platforms. >=20 > Burden: > Platform developers need configure the PCDs accordingly for different > platforms. >=20 > To solve the problem and remove the burden, we can update PeiCore to > remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv > and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV, > File and PPI management. >=20 > This patch removes the using of PcdPeiCoreMaxFvSupported in PeiCore. >=20 > Cc: Jian J Wang > Cc: Hao Wu > Cc: Liming Gao > Cc: Ruiyu Ni > Cc: Michael D Kinney > Cc: Nate DeSimone > Cc: Chasel Chiu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > MdeModulePkg/Core/Pei/FwVol/FwVol.c | 67 > ++++++++++++++++++++++++++------- > MdeModulePkg/Core/Pei/PeiMain.h | 15 +++++++- > MdeModulePkg/Core/Pei/PeiMain.inf | 1 - > MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 16 ++++---- > 4 files changed, 75 insertions(+), 24 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c > b/MdeModulePkg/Core/Pei/FwVol/FwVol.c > index 5629c9a1ce20..0a67b96bf1e3 100644 > --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c > +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c > @@ -503,6 +503,10 @@ PeiInitializeFv ( > ); > ASSERT_EFI_ERROR (Status); >=20 > + PrivateData->Fv =3D AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * > FV_GROWTH_STEP); > + ASSERT (PrivateData->Fv !=3D NULL); > + PrivateData->MaxFvCount =3D FV_GROWTH_STEP; > + > // > // Update internal PEI_CORE_FV array. > // > @@ -560,6 +564,7 @@ FirmwareVolmeInfoPpiNotifyCallback ( > VOID *DepexData; > BOOLEAN IsFvInfo2; > UINTN CurFvCount; > + VOID *TempPtr; >=20 > Status =3D EFI_SUCCESS; > PrivateData =3D PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); > @@ -626,10 +631,21 @@ FirmwareVolmeInfoPpiNotifyCallback ( > } > } >=20 > - if (PrivateData->FvCount >=3D PcdGet32 (PcdPeiCoreMaxFvSupported)) { > - DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max > supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32 > (PcdPeiCoreMaxFvSupported))); > - DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be > reconfigurated in DSC")); > - ASSERT (FALSE); > + if (PrivateData->FvCount >=3D PrivateData->MaxFvCount) { > + // > + // Run out of room, grow the buffer. > + // > + TempPtr =3D AllocateZeroPool ( > + sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount= + > FV_GROWTH_STEP) > + ); > + ASSERT (TempPtr !=3D NULL); > + CopyMem ( > + TempPtr, > + PrivateData->Fv, > + sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount > + ); > + PrivateData->Fv =3D TempPtr; > + PrivateData->MaxFvCount =3D PrivateData->MaxFvCount + > FV_GROWTH_STEP; > } >=20 > // > @@ -2157,7 +2173,6 @@ FindNextCoreFvHandle ( > } > } >=20 > - ASSERT (Private->FvCount <=3D PcdGet32 (PcdPeiCoreMaxFvSupported)); > if (Instance >=3D Private->FvCount) { > return NULL; > } > @@ -2205,7 +2220,7 @@ PeiReinitializeFv ( > // > // Fixup all FvPpi pointers for the implementation in flash to permane= nt > memory. > // > - for (Index =3D 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index += +) { > + for (Index =3D 0; Index < PrivateData->FvCount; Index ++) { > if (PrivateData->Fv[Index].FvPpi =3D=3D OldFfsFvPpi) { > PrivateData->Fv[Index].FvPpi =3D &mPeiFfs2FwVol.Fv; > } > @@ -2233,7 +2248,7 @@ PeiReinitializeFv ( > // > // Fixup all FvPpi pointers for the implementation in flash to permane= nt > memory. > // > - for (Index =3D 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index += +) { > + for (Index =3D 0; Index < PrivateData->FvCount; Index ++) { > if (PrivateData->Fv[Index].FvPpi =3D=3D OldFfsFvPpi) { > PrivateData->Fv[Index].FvPpi =3D &mPeiFfs3FwVol.Fv; > } > @@ -2263,9 +2278,23 @@ AddUnknownFormatFvInfo ( > ) > { > PEI_CORE_UNKNOW_FORMAT_FV_INFO *NewUnknownFv; > + VOID *TempPtr; >=20 > - if (PrivateData->UnknownFvInfoCount + 1 >=3D PcdGet32 > (PcdPeiCoreMaxFvSupported)) { > - return EFI_OUT_OF_RESOURCES; > + if (PrivateData->UnknownFvInfoCount >=3D PrivateData- > >MaxUnknownFvInfoCount) { > + // > + // Run out of room, grow the buffer. > + // > + TempPtr =3D AllocateZeroPool ( > + sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * (PrivateData- > >MaxUnknownFvInfoCount + FV_GROWTH_STEP) > + ); > + ASSERT (TempPtr !=3D NULL); > + CopyMem ( > + TempPtr, > + PrivateData->UnknownFvInfo, > + sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PrivateData- > >MaxUnknownFvInfoCount > + ); > + PrivateData->UnknownFvInfo =3D TempPtr; > + PrivateData->MaxUnknownFvInfoCount =3D PrivateData- > >MaxUnknownFvInfoCount + FV_GROWTH_STEP; > } >=20 > NewUnknownFv =3D &PrivateData->UnknownFvInfo[PrivateData- > >UnknownFvInfoCount]; > @@ -2368,6 +2397,7 @@ ThirdPartyFvPpiNotifyCallback ( > EFI_PEI_FILE_HANDLE FileHandle; > VOID *DepexData; > UINTN CurFvCount; > + VOID *TempPtr; >=20 > PrivateData =3D PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); > FvPpi =3D (EFI_PEI_FIRMWARE_VOLUME_PPI*) Ppi; > @@ -2403,10 +2433,21 @@ ThirdPartyFvPpiNotifyCallback ( > continue; > } >=20 > - if (PrivateData->FvCount >=3D PcdGet32 (PcdPeiCoreMaxFvSupported)) { > - DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max > supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32 > (PcdPeiCoreMaxFvSupported))); > - DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be > reconfigurated in DSC")); > - ASSERT (FALSE); > + if (PrivateData->FvCount >=3D PrivateData->MaxFvCount) { > + // > + // Run out of room, grow the buffer. > + // > + TempPtr =3D AllocateZeroPool ( > + sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount= + > FV_GROWTH_STEP) > + ); > + ASSERT (TempPtr !=3D NULL); > + CopyMem ( > + TempPtr, > + PrivateData->Fv, > + sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount > + ); > + PrivateData->Fv =3D TempPtr; > + PrivateData->MaxFvCount =3D PrivateData->MaxFvCount + > FV_GROWTH_STEP; > } >=20 > // > diff --git a/MdeModulePkg/Core/Pei/PeiMain.h > b/MdeModulePkg/Core/Pei/PeiMain.h > index ab914c7d2e44..b248118087ad 100644 > --- a/MdeModulePkg/Core/Pei/PeiMain.h > +++ b/MdeModulePkg/Core/Pei/PeiMain.h > @@ -107,6 +107,11 @@ typedef struct { > #define PEIM_STATE_REGISTER_FOR_SHADOW 0x02 > #define PEIM_STATE_DONE 0x03 >=20 > +// > +// Number of FV instances to grow by each time we run out of room > +// > +#define FV_GROWTH_STEP 8 > + > typedef struct { > EFI_FIRMWARE_VOLUME_HEADER *FvHeader; > EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi; > @@ -197,16 +202,22 @@ struct _PEI_CORE_INSTANCE { > UINTN FvCount; >=20 > /// > - /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of > entries. > + /// The max count of FVs which contains FFS and could be dispatched by > PeiCore. > + /// > + UINTN MaxFvCount; > + > + /// > + /// Pointer to the buffer with the MaxFvCount number of entries. > /// Each entry is for one FV which contains FFS and could be dispatche= d by > PeiCore. > /// > PEI_CORE_FV_HANDLE *Fv; >=20 > /// > - /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of > entries. > + /// Pointer to the buffer with the MaxUnknownFvInfoCount number of ent= ries. > /// Each entry is for one FV which could not be dispatched by PeiCore. > /// > PEI_CORE_UNKNOW_FORMAT_FV_INFO *UnknownFvInfo; > + UINTN MaxUnknownFvInfoCount; > UINTN UnknownFvInfoCount; >=20 > /// > diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf > b/MdeModulePkg/Core/Pei/PeiMain.inf > index d106c3606e97..dd41fe41bc89 100644 > --- a/MdeModulePkg/Core/Pei/PeiMain.inf > +++ b/MdeModulePkg/Core/Pei/PeiMain.inf > @@ -104,7 +104,6 @@ [Ppis] > gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES >=20 > [Pcd] > - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported = ## > CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported = ## > CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize = ## > CONSUMES >=20 > gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFir > st ## CONSUMES > diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c > b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c > index 52adefeb44b4..4869bf18f005 100644 > --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c > +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c > @@ -184,13 +184,15 @@ PeiCore ( > OldCoreData->CpuIo =3D &OldCoreData->ServiceTableShadow.CpuIo; > if (OldCoreData->HeapOffsetPositive) { > OldCoreData->HobList.Raw =3D (VOID *)(OldCoreData->HobList.Raw + > OldCoreData->HeapOffset); > - OldCoreData->UnknownFvInfo =3D > (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData- > >UnknownFvInfo + OldCoreData->HeapOffset); > + if (OldCoreData->UnknownFvInfo !=3D NULL) { > + OldCoreData->UnknownFvInfo =3D > (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData- > >UnknownFvInfo + OldCoreData->HeapOffset); > + } > if (OldCoreData->CurrentFvFileHandles !=3D NULL) { > OldCoreData->CurrentFvFileHandles =3D (EFI_PEI_FILE_HANDLE *) = ((UINT8 *) > OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset); > } > OldCoreData->PpiData.PpiListPtrs =3D (PEI_PPI_LIST_POINTERS *) = ((UINT8 *) > OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset); > OldCoreData->Fv =3D (PEI_CORE_FV_HANDLE *) ((U= INT8 *) > OldCoreData->Fv + OldCoreData->HeapOffset); > - for (Index =3D 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); I= ndex ++) { > + for (Index =3D 0; Index < OldCoreData->FvCount; Index ++) { > if (OldCoreData->Fv[Index].PeimState !=3D NULL) { > OldCoreData->Fv[Index].PeimState =3D (UINT8 *) OldCoreDa= ta- > >Fv[Index].PeimState + OldCoreData->HeapOffset; > } > @@ -202,13 +204,15 @@ PeiCore ( > OldCoreData->TempFileHandles =3D (EFI_PEI_FILE_HANDLE *) ((= UINT8 *) > OldCoreData->TempFileHandles + OldCoreData->HeapOffset); > } else { > OldCoreData->HobList.Raw =3D (VOID *)(OldCoreData->HobList.Raw - > OldCoreData->HeapOffset); > - OldCoreData->UnknownFvInfo =3D > (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData- > >UnknownFvInfo - OldCoreData->HeapOffset); > + if (OldCoreData->UnknownFvInfo !=3D NULL) { > + OldCoreData->UnknownFvInfo =3D > (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData- > >UnknownFvInfo - OldCoreData->HeapOffset); > + } > if (OldCoreData->CurrentFvFileHandles !=3D NULL) { > OldCoreData->CurrentFvFileHandles =3D (EFI_PEI_FILE_HANDLE *) = ((UINT8 *) > OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset); > } > OldCoreData->PpiData.PpiListPtrs =3D (PEI_PPI_LIST_POINTERS *) = ((UINT8 *) > OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset); > OldCoreData->Fv =3D (PEI_CORE_FV_HANDLE *) ((U= INT8 *) > OldCoreData->Fv - OldCoreData->HeapOffset); > - for (Index =3D 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); I= ndex ++) { > + for (Index =3D 0; Index < OldCoreData->FvCount; Index ++) { > if (OldCoreData->Fv[Index].PeimState !=3D NULL) { > OldCoreData->Fv[Index].PeimState =3D (UINT8 *) OldCoreDa= ta- > >Fv[Index].PeimState - OldCoreData->HeapOffset; > } > @@ -339,10 +343,6 @@ PeiCore ( > // > PrivateData.PpiData.PpiListPtrs =3D AllocateZeroPool (sizeof > (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported)); > ASSERT (PrivateData.PpiData.PpiListPtrs !=3D NULL); > - PrivateData.Fv =3D AllocateZeroPool (sizeof (PEI_C= ORE_FV_HANDLE) > * PcdGet32 (PcdPeiCoreMaxFvSupported)); > - ASSERT (PrivateData.Fv !=3D NULL); > - PrivateData.UnknownFvInfo =3D AllocateZeroPool (sizeof > (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PcdGet32 > (PcdPeiCoreMaxFvSupported)); > - ASSERT (PrivateData.UnknownFvInfo !=3D NULL); > } > InitializePpiServices (&PrivateData, OldCoreData); >=20 > -- > 2.7.0.windows.1