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.65; helo=mga03.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 EB4FE20945BBA for ; Thu, 28 Sep 2017 17:23:24 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2017 17:26:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,451,1500966000"; d="scan'208";a="133393518" Received: from unknown (HELO ydong10-win10.ccr.corp.intel.com) ([10.239.158.57]) by orsmga004.jf.intel.com with ESMTP; 28 Sep 2017 17:26:39 -0700 From: Eric Dong To: edk2-devel@lists.01.org Cc: Jiewen Yao , Ruiyu Ni Date: Fri, 29 Sep 2017 08:26:35 +0800 Message-Id: <1506644796-11288-2-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1506644796-11288-1-git-send-email-eric.dong@intel.com> References: <1506644796-11288-1-git-send-email-eric.dong@intel.com> Subject: [Patch v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Combine INIT-SIPI-SIPI. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Sep 2017 00:23:25 -0000 In S3 resume path, current implementation do 2 separate INIT-SIPI-SIPI, this is not necessary. This change combine these 2 INIT-SIPI-SIPI to 1 and add CpuPause between them. Cc: Jiewen Yao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 51 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c index 9404501..ae4b516 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c @@ -39,6 +39,11 @@ typedef struct { // SPIN_LOCK *mMemoryMappedLock = NULL; +// +// Signal that SMM BASE relocation is complete. +// +volatile BOOLEAN mInitApsAfterSmmBaseReloc; + /** Get starting address and size of the rendezvous entry for APs. Information for fixing a jump instruction in the code is also returned. @@ -342,17 +347,21 @@ SetProcessorRegister ( } } + + /** - AP initialization before SMBASE relocation in the S3 boot path. + AP initialization before then after SMBASE relocation in the S3 boot path. **/ VOID -EarlyMPRendezvousProcedure ( +MPRendezvousProcedure ( VOID ) { CPU_REGISTER_TABLE *RegisterTableList; UINT32 InitApicId; UINTN Index; + UINTN TopOfStack; + UINT8 Stack[128]; LoadMtrrData (mAcpiCpuData.MtrrTable); @@ -368,25 +377,18 @@ EarlyMPRendezvousProcedure ( } } + // // Count down the number with lock mechanism. // InterlockedDecrement (&mNumberToFinish); -} -/** - AP initialization after SMBASE relocation in the S3 boot path. -**/ -VOID -MPRendezvousProcedure ( - VOID - ) -{ - CPU_REGISTER_TABLE *RegisterTableList; - UINT32 InitApicId; - UINTN Index; - UINTN TopOfStack; - UINT8 Stack[128]; + // + // Wait for BSP to signal SMM Base relocation done. + // + while (!mInitApsAfterSmmBaseReloc) { + CpuPause (); + } ProgramVirtualWireMode (); DisableLvtInterrupts (); @@ -500,7 +502,12 @@ EarlyInitializeCpu ( PrepareApStartupVector (mAcpiCpuData.StartupVector); mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1; - mExchangeInfo->ApFunction = (VOID *) (UINTN) EarlyMPRendezvousProcedure; + mExchangeInfo->ApFunction = (VOID *) (UINTN) MPRendezvousProcedure; + + // + // Execute code for before SmmBaseReloc. Note: This flag is maintained across S3 boots. + // + mInitApsAfterSmmBaseReloc = FALSE; // // Send INIT IPI - SIPI to all APs @@ -538,17 +545,11 @@ InitializeCpu ( } mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1; - // - // StackStart was updated when APs were waken up in EarlyInitializeCpu. - // Re-initialize StackAddress to original beginning address. - // - mExchangeInfo->StackStart = (VOID *) (UINTN) mAcpiCpuData.StackAddress; - mExchangeInfo->ApFunction = (VOID *) (UINTN) MPRendezvousProcedure; // - // Send INIT IPI - SIPI to all APs + // Signal that SMM base relocation is complete and to continue initialization. // - SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector); + mInitApsAfterSmmBaseReloc = TRUE; while (mNumberToFinish > 0) { CpuPause (); -- 2.7.0.windows.1