Re: [edk2] [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported
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 > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405 > > Background as below. > > 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. > > Burden: > Platform developers need configure the PCDs accordingly for different > platforms. > > 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. > > This patch removes the using of PcdPeiCoreMaxFvSupported in PeiCore. > > 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(-) > > 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); > > + PrivateData->Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * > FV_GROWTH_STEP); > + ASSERT (PrivateData->Fv != NULL); > + PrivateData->MaxFvCount = FV_GROWTH_STEP; > + >// >// Update internal PEI_CORE_FV array. >// > @@ -560,6 +564,7 @@ FirmwareVolmeInfoPpiNotifyCallback ( >VOID *DepexData; >BOOLEAN IsFvInfo2; >UINTN CurFvCount; > + VOID *TempPtr; > >Status = EFI_SUCCESS; >PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); > @@ -626,10 +631,21 @@ FirmwareVolmeInfoPpiNotifyCallback ( >} > } > > -if (PrivateData->FvCount >= 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 >= PrivateData->MaxFvCount) { > + // > + // Run out of room, grow the buffer. > + // > + TempPtr = AllocateZeroPool ( > + sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount + > FV_GROWTH_STEP) > + ); > + ASSERT (TempPtr != NULL); > + CopyMem ( > +TempPtr, > +PrivateData->Fv, > +sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount > +); > + PrivateData->Fv = TempPtr; > + PrivateData->MaxFvCount = PrivateData->MaxFvCount + > FV_GROWTH_STEP; > } > > // > @@ -2157,7 +2173,6 @@ FindNextCoreFvHandle ( > } >} > > - ASSERT (Private->FvCount <= PcdGet32 (PcdPeiCoreMaxFvSupported)); >if (Instance >= Private->FvCount) { > return NULL; >} > @@ -2205,7 +2220,7 @@ PeiReinitializeFv ( >// >// Fixup all FvPpi pointers for the implementation in flash to permanent > memory. >// > - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) { > + for (Index = 0; Index < PrivateData->FvCount; Index ++) { > if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) { >PrivateData->Fv[Index].FvPpi = > } > @@ -2233,7 +2248,7 @@ PeiReinitializeFv ( >// >// Fixup all FvPpi pointers for the implementation in flash to permanent > memory. >// > - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) { > + for (Index = 0; Index < PrivateData->FvCount; Index ++) { > if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) { >PrivateData->Fv[Index].FvPpi = > } > @@ -2263,9 +2278,23 @@ AddUnknownFormatFvInfo ( >) > { >PEI_CORE_UNKNOW_FORMAT_FV_INFO*NewUnknownFv; > + VOID *TempPtr; > > - if (PrivateData->UnknownFvInfoCount + 1 >= PcdGet32 > (PcdPeiCoreMaxFvSupported)) { > -return EFI_OUT_OF_RESOURCES; > + if (PrivateData->UnknownFvInfoCount >= PrivateData- > >MaxUnknownFvInfoCount) { > +// >
Re: [edk2] [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported
Reviewed-by: Chasel Chiu -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 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405 Background as below. 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. Burden: Platform developers need configure the PCDs accordingly for different platforms. 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. This patch removes the using of PcdPeiCoreMaxFvSupported in PeiCore. 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(-) 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); + PrivateData->Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * + FV_GROWTH_STEP); ASSERT (PrivateData->Fv != NULL); + PrivateData->MaxFvCount = FV_GROWTH_STEP; + // // Update internal PEI_CORE_FV array. // @@ -560,6 +564,7 @@ FirmwareVolmeInfoPpiNotifyCallback ( VOID *DepexData; BOOLEAN IsFvInfo2; UINTN CurFvCount; + VOID *TempPtr; Status = EFI_SUCCESS; PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); @@ -626,10 +631,21 @@ FirmwareVolmeInfoPpiNotifyCallback ( } } -if (PrivateData->FvCount >= 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 >= PrivateData->MaxFvCount) { + // + // Run out of room, grow the buffer. + // + TempPtr = AllocateZeroPool ( + sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount + FV_GROWTH_STEP) + ); + ASSERT (TempPtr != NULL); + CopyMem ( +TempPtr, +PrivateData->Fv, +sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount +); + PrivateData->Fv = TempPtr; + PrivateData->MaxFvCount = PrivateData->MaxFvCount + + FV_GROWTH_STEP; } // @@ -2157,7 +2173,6 @@ FindNextCoreFvHandle ( } } - ASSERT (Private->FvCount <= PcdGet32 (PcdPeiCoreMaxFvSupported)); if (Instance >= Private->FvCount) { return NULL; } @@ -2205,7 +2220,7 @@ PeiReinitializeFv ( // // Fixup all FvPpi pointers for the implementation in flash to permanent memory. // - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) { + for (Index = 0; Index < PrivateData->FvCount; Index ++) { if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) { PrivateData->Fv[Index].FvPpi = } @@ -2233,7 +2248,7 @@ PeiReinitializeFv ( // // Fixup all FvPpi pointers for the implementation in flash to permanent memory. // - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) { + for (Index = 0; Index < PrivateData->FvCount; Index ++) { if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) { PrivateData->Fv[Index].FvPpi = } @@ -2263,9 +2278,23 @@ AddUnknownFormatFvInfo ( ) { PEI_CORE_UNKNOW_FORMAT_FV_INFO*NewUnknownFv; + VOID *TempPtr; - if (PrivateData->UnknownFvInfoCount + 1 >= PcdGet32 (PcdPeiCoreMaxFvSupported)) { -return EFI_OUT_OF_RESOURCES; + if (PrivateData->UnknownFvInfoCount >= PrivateData->MaxUnknownFvInfoCount) { +// +// Run out of room, grow the buffer. +// +TempPtr = AllocateZeroPool ( +sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * (PrivateData->MaxUnknownFvInfoCount + FV_GROWTH_STEP) +); +ASSERT (TempPtr != NULL); +
[edk2] [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405 Background as below. 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. Burden: Platform developers need configure the PCDs accordingly for different platforms. 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. This patch removes the using of PcdPeiCoreMaxFvSupported in PeiCore. 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(-) 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); + PrivateData->Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * FV_GROWTH_STEP); + ASSERT (PrivateData->Fv != NULL); + PrivateData->MaxFvCount = FV_GROWTH_STEP; + // // Update internal PEI_CORE_FV array. // @@ -560,6 +564,7 @@ FirmwareVolmeInfoPpiNotifyCallback ( VOID *DepexData; BOOLEAN IsFvInfo2; UINTN CurFvCount; + VOID *TempPtr; Status = EFI_SUCCESS; PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); @@ -626,10 +631,21 @@ FirmwareVolmeInfoPpiNotifyCallback ( } } -if (PrivateData->FvCount >= 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 >= PrivateData->MaxFvCount) { + // + // Run out of room, grow the buffer. + // + TempPtr = AllocateZeroPool ( + sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount + FV_GROWTH_STEP) + ); + ASSERT (TempPtr != NULL); + CopyMem ( +TempPtr, +PrivateData->Fv, +sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount +); + PrivateData->Fv = TempPtr; + PrivateData->MaxFvCount = PrivateData->MaxFvCount + FV_GROWTH_STEP; } // @@ -2157,7 +2173,6 @@ FindNextCoreFvHandle ( } } - ASSERT (Private->FvCount <= PcdGet32 (PcdPeiCoreMaxFvSupported)); if (Instance >= Private->FvCount) { return NULL; } @@ -2205,7 +2220,7 @@ PeiReinitializeFv ( // // Fixup all FvPpi pointers for the implementation in flash to permanent memory. // - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) { + for (Index = 0; Index < PrivateData->FvCount; Index ++) { if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) { PrivateData->Fv[Index].FvPpi = } @@ -2233,7 +2248,7 @@ PeiReinitializeFv ( // // Fixup all FvPpi pointers for the implementation in flash to permanent memory. // - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) { + for (Index = 0; Index < PrivateData->FvCount; Index ++) { if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) { PrivateData->Fv[Index].FvPpi = } @@ -2263,9 +2278,23 @@ AddUnknownFormatFvInfo ( ) { PEI_CORE_UNKNOW_FORMAT_FV_INFO*NewUnknownFv; + VOID *TempPtr; - if (PrivateData->UnknownFvInfoCount + 1 >= PcdGet32 (PcdPeiCoreMaxFvSupported)) { -return EFI_OUT_OF_RESOURCES; + if (PrivateData->UnknownFvInfoCount >= PrivateData->MaxUnknownFvInfoCount) { +// +// Run out of room, grow the buffer. +// +TempPtr = AllocateZeroPool ( +sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * (PrivateData->MaxUnknownFvInfoCount + FV_GROWTH_STEP) +); +ASSERT (TempPtr != NULL); +CopyMem ( + TempPtr, + PrivateData->UnknownFvInfo, + sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PrivateData->MaxUnknownFvInfoCount + ); +PrivateData->UnknownFvInfo = TempPtr; +PrivateData->MaxUnknownFvInfoCount = PrivateData->MaxUnknownFvInfoCount + FV_GROWTH_STEP; } NewUnknownFv = >UnknownFvInfo[PrivateData->UnknownFvInfoCount]; @@ -2368,6