From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.1822.1687759039189579056 for ; Sun, 25 Jun 2023 22:57:22 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Z9Ejgab8; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: yuanhao.xie@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687759041; x=1719295041; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9wXNX+60u7G0f0xlbcZ5z77GMkRXEeMt9QBzgoBnAkA=; b=Z9Ejgab8TX+76Kk6Ilz9sURKHUidMc2ltVRpg/2dmuoyUrKK3ZihsJZo Ze7l4chCLs+rVzKpCu7ORXm28iqjwr3Xa/HF7Rmsf5WowHGmF7dLbonQT hew5NKgnRjWuAsDEP2u+C+GxT1/pyb20gpnK/oKq1iagbDZT6SGhrNnLX qns8UN261g56lzX8qWQ+AfL5RYv5daT3OMiRDokApclfQL3fIFsTT5Puz iZKEcXzWOOtm5aqHXGiR31uLn3745jvAbXyk2DDxg8pWrK1KJFQ5XTK0J 4n6cmjbd9nRGqvIrVX+XkdFgetMCKrEjncVJLwNIr1Fb6d71tVFPWXNRm w==; X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="340768935" X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="340768935" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 22:57:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="786018009" X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="786018009" Received: from shwdeopenlab705.ccr.corp.intel.com ([10.239.55.55]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 22:57:20 -0700 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: Gerd Hoffmann , Eric Dong , Ray Ni , Rahul Kumar , Tom Lendacky , Yuanhao Xie Subject: [Patch V3 1/5] UefiCpuPkg: Refactor the logic for placing APs in HltLoop. Date: Mon, 26 Jun 2023 13:57:01 +0800 Message-Id: <20230626055705.57145-2-yuanhao.xie@intel.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20230626055705.57145-1-yuanhao.xie@intel.com> References: <20230626055705.57145-1-yuanhao.xie@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Refactor the logic for placing APs in HltLoop into a separate function. Cc: Gerd Hoffmann Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Tom Lendacky Signed-off-by: Yuanhao Xie --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index f1f2840714..9560b39220 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -636,6 +636,28 @@ InitializeApData ( SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateIdle); } +/** + This function place APs in Halt loop. + + @param[in] CpuMpData Pointer to CPU MP Data +**/ +VOID +PlaceAPInHltLoop ( + IN CPU_MP_DATA *CpuMpData + ) +{ + while (TRUE) { + DisableInterrupts (); + if (CpuMpData->UseSevEsAPMethod) { + SevEsPlaceApHlt (CpuMpData); + } else { + CpuSleep (); + } + + CpuPause (); + } +} + /** This function will be called from AP reset code if BSP uses WakeUpAP. @@ -812,19 +834,10 @@ ApWakeupFunction ( // Place AP is specified loop mode // if (CpuMpData->ApLoopMode == ApInHltLoop) { + PlaceAPInHltLoop (CpuMpData); // - // Place AP in HLT-loop + // Never run here // - while (TRUE) { - DisableInterrupts (); - if (CpuMpData->UseSevEsAPMethod) { - SevEsPlaceApHlt (CpuMpData); - } else { - CpuSleep (); - } - - CpuPause (); - } } while (TRUE) { -- 2.36.1.windows.1