From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: jordan.l.justen@intel.com) Received: from mga11.intel.com (mga11.intel.com []) by groups.io with SMTP; Wed, 10 Apr 2019 01:41:49 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2019 01:41:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,332,1549958400"; d="scan'208";a="130116391" Received: from askirtik-mobl1.amr.corp.intel.com (HELO jljusten-skl.amr.corp.intel.com) ([10.254.188.249]) by orsmga007.jf.intel.com with ESMTP; 10 Apr 2019 01:41:12 -0700 From: "Jordan Justen" To: devel@edk2.groups.io Cc: Jordan Justen , Jian J Wang , Hao Wu , Ray Ni , Star Zeng Subject: [PATCH v2 6/6] MdeModulePkg/Core/Pei: Use code path for assembly based TemporaryRamSupport Date: Wed, 10 Apr 2019 01:40:00 -0700 Message-Id: <20190410084000.19660-7-jordan.l.justen@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190410084000.19660-1-jordan.l.justen@intel.com> References: <20190410084000.19660-1-jordan.l.justen@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Jian J Wang Cc: Hao Wu Cc: Ray Ni Cc: Star Zeng --- 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