There is potential problem with PEI Core's usage of the TemporaryRamSupport PPI. The issue is described in the previous patch:
"MdeModulePkg/Core/Pei: Add interface for assembly based TemporaryRamSupport" Now that assembly paths are available for all supported architectures, we can make use of the assembly based PEI Core code path. Signed-off-by: Jordan Justen <jordan.l.jus...@intel.com> Cc: Jian J Wang <jian.j.w...@intel.com> Cc: Hao Wu <hao.a...@intel.com> Cc: Ray Ni <ray...@intel.com> Cc: Star Zeng <star.z...@intel.com> --- MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 59 ++++++++++++------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c index ba2fd0cae1..116124d6f8 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -682,6 +682,7 @@ PeiCheckAndSwitchStack ( EFI_PHYSICAL_ADDRESS TempBase2; UINTN TempSize2; UINTN Index; + PEI_CORE_TEMPORARY_RAM_TRANSITION TempRamTransitionData; PeiServices = (CONST EFI_PEI_SERVICES **) &Private->Ps; @@ -816,30 +817,20 @@ PeiCheckAndSwitchStack ( Private = (PEI_CORE_INSTANCE *)((UINTN)(VOID *)Private - StackOffset); } - // - // Temporary Ram Support PPI is provided by platform, it will copy - // temporary memory to permanent memory and do stack switching. - // After invoking Temporary Ram Support PPI, the following code's - // stack is in permanent memory. - // - TemporaryRamSupportPpi->TemporaryRamMigration ( - PeiServices, - TemporaryRamBase, - (EFI_PHYSICAL_ADDRESS)(UINTN)(TopOfNewStack - TemporaryStackSize), - TemporaryRamSize - ); - - // - // Migrate memory pages allocated in pre-memory phase. - // It could not be called before calling TemporaryRamSupportPpi->TemporaryRamMigration() - // as the migrated memory pages may be overridden by TemporaryRamSupportPpi->TemporaryRamMigration(). - // - MigrateMemoryPages (Private, TRUE); + TempRamTransitionData.TemporaryRamMigration = + TemporaryRamSupportPpi->TemporaryRamMigration; + TempRamTransitionData.PeiServices = PeiServices; + TempRamTransitionData.TemporaryMemoryBase = TemporaryRamBase; + TempRamTransitionData.PermanentMemoryBase = + (EFI_PHYSICAL_ADDRESS)(UINTN)(TopOfNewStack - TemporaryStackSize); + TempRamTransitionData.CopySize = TemporaryRamSize; + TempRamTransitionData.Private = Private; + TempRamTransitionData.SecCoreData = SecCoreData; // - // Entry PEI Phase 2 + // Migrate Temporary RAM and enter PEI Phase 2 // - PeiCore (SecCoreData, NULL, Private); + PeiTemporaryRamMigration(&TempRamTransitionData); } else { // // Migrate memory pages allocated in pre-memory phase. @@ -952,6 +943,32 @@ PeiCheckAndSwitchStack ( } } +VOID +EFIAPI +PeiTemporaryRamMigrated ( + IN VOID *CallbackContext + ) +{ + PEI_CORE_TEMPORARY_RAM_TRANSITION *TempRamTransitionData = + (PEI_CORE_TEMPORARY_RAM_TRANSITION*)CallbackContext; + + // + // Migrate memory pages allocated in pre-memory phase. + // It could not be called before calling TemporaryRamSupportPpi->TemporaryRamMigration() + // as the migrated memory pages may be overridden by TemporaryRamSupportPpi->TemporaryRamMigration(). + // + MigrateMemoryPages (TempRamTransitionData->Private, TRUE); + + // + // Entry PEI Phase 2 + // + PeiCore ( + TempRamTransitionData->SecCoreData, + NULL, + TempRamTransitionData->Private + ); +} + /** Conduct PEIM dispatch. -- 2.20.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#38790): https://edk2.groups.io/g/devel/message/38790 Mute This Topic: https://groups.io/mt/31016932/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-