From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web08.15919.1667453877740586469 for ; Wed, 02 Nov 2022 22:38:01 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=CWch6IbS; spf=pass (domain: intel.com, ip: 192.55.52.93, 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=1667453881; x=1698989881; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YEAcs4lqEkzrCfiErEHKzXBJXXcGY20v+Y7ThA3cpS0=; b=CWch6IbSysJUGk4Nn++8+Z/ygib2tzkNfpBPkVLNSAOFHztB0fgZg6lX +dJNt74nIUDlpPNz09TXOHSXjjnbSPUSiKe9js+AGNzBw+78SolfUBkkg YLK0xm287yzIi9/j6ztRRtgK5m56JudgXOgdTAWfJ0+Mfq9Odm+Vz8tLc uiIysw/X2CkLjzhbvLMWmrgdjj9Anokxo0afc5YtGC0bAKsPVLQqVlRIP JrLlEMXBwr5EQbAbENF1Jg0/2+uibB++jKB2YNdPLswwsZz9/GsssZv/q Ftpq9GdgaJ2QcyZkojQ8eXFN1qIzS3jZqIDTShrqkxsBgk/eHAmCGB4cc A==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="307207604" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="307207604" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 22:38:01 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="963805702" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="963805702" Received: from shwdeopenlab705.ccr.corp.intel.com ([10.239.56.33]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2022 22:37:59 -0700 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: Yuanhao , Eric Dong , Ray Ni , Rahul Kumar Subject: [PATCH 1/3] UefiCpuPkg: Remove the duplicate loading of microcode in DXE stage Date: Thu, 3 Nov 2022 13:37:45 +0800 Message-Id: <20221103053747.289-2-yuanhao.xie@intel.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221103053747.289-1-yuanhao.xie@intel.com> References: <20221103053747.289-1-yuanhao.xie@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Yuanhao If both in the DXE and PEI phase Mp initialization is excuted, the microcode loading during Mp initialization of the DXE stage can be removed regardless of the bit modes. Signed-off-by: Yuanhao Xie Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 58 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index 1c053f87a4..5430688946 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -432,6 +432,27 @@ ApFuncEnableX2Apic ( SetApicMode (LOCAL_APIC_MODE_X2APIC); } +/** + Sync BSP's MTRR table to AP during waking upAp + + @param[in, out] Buffer Pointer to private data buffer. +**/ +VOID +EFIAPI +ApMtrrSync ( + IN OUT VOID *Buffer + ) +{ + CPU_MP_DATA *CpuMpData; + + CpuMpData = (CPU_MP_DATA *)Buffer; + + // + // Sync BSP's MTRR table to AP + // + MtrrSetAllMtrrs (&CpuMpData->MtrrTable); +} + /** Do sync on APs. @@ -1977,6 +1998,23 @@ MpInitLibInitialize ( // CollectProcessorCount (CpuMpData); } + + if (!GetMicrocodePatchInfoFromHob ( + &CpuMpData->MicrocodePatchAddress, + &CpuMpData->MicrocodePatchRegionSize + )) + { + // + // The microcode patch information cache HOB does not exist, which means + // the microcode patches data has not been loaded into memory yet + // + ShadowMicrocodeUpdatePatch (CpuMpData); + } + + // + // Detect and apply Microcode on BSP + // + MicrocodeDetect (CpuMpData, CpuMpData->BspNumber); } else { // // APs have been wakeup before, just get the CPU Information @@ -1994,22 +2032,6 @@ MpInitLibInitialize ( } } - if (!GetMicrocodePatchInfoFromHob ( - &CpuMpData->MicrocodePatchAddress, - &CpuMpData->MicrocodePatchRegionSize - )) - { - // - // The microcode patch information cache HOB does not exist, which means - // the microcode patches data has not been loaded into memory yet - // - ShadowMicrocodeUpdatePatch (CpuMpData); - } - - // - // Detect and apply Microcode on BSP - // - MicrocodeDetect (CpuMpData, CpuMpData->BspNumber); // // Store BSP's MTRR setting // @@ -2026,9 +2048,11 @@ MpInitLibInitialize ( // in DXE. // CpuMpData->InitFlag = ApInitReconfig; + WakeUpAP (CpuMpData, TRUE, 0, ApMtrrSync, CpuMpData, TRUE); + } else { + WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE); } - WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE); // // Wait for all APs finished initialization // -- 2.36.1.windows.1