From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 C374E1A1E44 for ; Wed, 24 Aug 2016 07:45:30 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP; 24 Aug 2016 07:45:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,570,1464678000"; d="scan'208";a="160352199" Received: from jfan12-desk.ccr.corp.intel.com ([10.239.9.5]) by fmsmga004.fm.intel.com with ESMTP; 24 Aug 2016 07:45:29 -0700 From: Jeff Fan To: edk2-devel@lists.01.org Cc: Michael Kinney , Feng Tian Date: Wed, 24 Aug 2016 22:45:20 +0800 Message-Id: <1472049924-8228-3-git-send-email-jeff.fan@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 In-Reply-To: <1472049924-8228-1-git-send-email-jeff.fan@intel.com> References: <1472049924-8228-1-git-send-email-jeff.fan@intel.com> Subject: [Patch 2/6] UefiCpuPkg/MpInitLib: Move allocating reserved memory for AP loop code X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Aug 2016 14:45:31 -0000 In Exit Boot Services callback function, we cannot use allocate memory services because it may change the memory map that has been gotten by OS. This fix is to move allocating reserved memory for AP loop code to InitMpGlobalData() and save the memory address in one global variable. Cc: Michael Kinney Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan --- UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c index 42d320f..383eec9 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -23,7 +23,7 @@ CPU_MP_DATA *mCpuMpData = NULL; EFI_EVENT mCheckAllApsEvent = NULL; EFI_EVENT mMpInitExitBootServicesEvent = NULL; volatile BOOLEAN mStopCheckAllApsStatus = TRUE; - +VOID *mReservedApLoopFunc = NULL; /** Get the pointer to CPU MP Data structure. @@ -258,19 +258,11 @@ MpInitExitBootServicesCallback ( ) { CPU_MP_DATA *CpuMpData; - VOID *ReservedApLoopFunc; - // - // Avoid APs access invalid buff data which allocated by BootServices, - // so we will allocate reserved data for AP loop code. - // + CpuMpData = GetCpuMpData (); CpuMpData->PmCodeSegment = GetProtectedModeCS (); CpuMpData->ApLoopMode = PcdGet8 (PcdCpuApLoopMode); - ReservedApLoopFunc = AllocateReservedCopyPool ( - CpuMpData->AddressMap.RelocateApLoopFuncSize, - CpuMpData->AddressMap.RelocateApLoopFuncAddress - ); - WakeUpAP (CpuMpData, TRUE, 0, RelocateApLoop, ReservedApLoopFunc); + WakeUpAP (CpuMpData, TRUE, 0, RelocateApLoop, mReservedApLoopFunc); DEBUG ((DEBUG_INFO, "MpInitExitBootServicesCallback() done!\n")); } @@ -288,6 +280,18 @@ InitMpGlobalData ( SaveCpuMpData (CpuMpData); + // + // Avoid APs access invalid buff data which allocated by BootServices, + // so we will allocate reserved data for AP loop code. + // Allocating it in advance since memory services are not available in + // Exit Boot Services callback function. + // + mReservedApLoopFunc = AllocateReservedCopyPool ( + CpuMpData->AddressMap.RelocateApLoopFuncSize, + CpuMpData->AddressMap.RelocateApLoopFuncAddress + ); + ASSERT (mReservedApLoopFunc != NULL); + Status = gBS->CreateEvent ( EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_NOTIFY, -- 2.7.4.windows.1