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.web11.11788.1687942151408549511 for ; Wed, 28 Jun 2023 01:49:11 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=GnJXZwJW; 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=1687942151; x=1719478151; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9wXNX+60u7G0f0xlbcZ5z77GMkRXEeMt9QBzgoBnAkA=; b=GnJXZwJWtLQHT3ukUg9jJt36LWL9tRflKHrcTiL3wf+Hwjm5iQV/TSsr biPJXxi3PFyIrYlXSFj9uEZHqCZSNhQurCl4c9/yRUFJ569PvQ/Job4+F Jnk9Rxu1teRVgl1YMEd51haFdY4MPJ0DjKbExnqqDb3vR/SRRbUqbNsw9 MYEXccMuf7SV0cCLk3CwYNrSx1W9LUoihnmutnJ78QBqvZhBu0kf1l21t S4UetayUr7LXgFYE6M1WqVqkYTl3EEDalGgrdO6i1W8vEY58WKKmwkmVz Tbe4aVe7exk0cJH3jPnefCgkiQDr2J9KCLvdpPAiw8RaVYVvmsIN1tPmw g==; X-IronPort-AV: E=McAfee;i="6600,9927,10754"; a="341373507" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="341373507" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 01:47:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10754"; a="890964557" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="890964557" Received: from shwdeopenlab705.ccr.corp.intel.com ([10.239.55.55]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 01:47:45 -0700 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: Gerd Hoffmann , Eric Dong , Ray Ni , Rahul Kumar , Tom Lendacky , Yuanhao Xie Subject: [Patch V4 1/5] UefiCpuPkg: Refactor the logic for placing APs in HltLoop. Date: Wed, 28 Jun 2023 16:47:20 +0800 Message-Id: <20230628084724.57574-2-yuanhao.xie@intel.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20230628084724.57574-1-yuanhao.xie@intel.com> References: <20230628084724.57574-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