From nobody Tue Feb 10 04:17:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111524+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111524+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700552410; cv=none; d=zohomail.com; s=zohoarc; b=lKrcZcfVYcV01AYD7TCB4YkCqXRoKpdk5sUaiOZLCaYSbUKbhdJuSmsRfwY0RpITjA5Cah8YwTgUNdY9yTnD2+x9qzq7uCfBNXhXh4xJUvxsbil8bRgU0PAxn+L9NkHNEZc+utqmpdVwddeSSR76F0cZ7lYSTy2ZlA5FQCu6z8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700552410; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=aAVU8WdUssOU2ge27ISK2uJ8LOt1lV3K4kIL+Ip8f7U=; b=Nuta5n1j3GsZ6L+sZlDkhfbL7oqMGQjxfiVqHKo8SfHDPiiBYQoV5uge/wfjS46m53dhXGWvRTbukzdekvADDBIIOgOBPb6eU8zyBEx1/LXh8FWo91RPkiD20WZ4yWtJUDIgNFhYyjPX41UMtGzpacGZeQ6jbEEDwhS9ZeAaaIU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111524+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700552410696940.0524188294386; Mon, 20 Nov 2023 23:40:10 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=yTeXMKd4oIePJWh1dZIcoy6R5uXT9bjtf4wqRlQbDEI=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1700552410; v=1; b=e49LDkA1pNdj5NdbEtK/XQLwWMzURYsftEAu+ODA2rumDrqk5tMMjwsGinIVDFjlG7buVwON RmQ0rQVzr1r9+wnk3sXmLl5Mc97cHgy73OAP5YvKZg61A4tn4jDWv6uA6E9ZvZ4aRiJ/jSRuzgS pFinfAV8CfEEETVrx/CxS9V4= X-Received: by 127.0.0.2 with SMTP id JjqkYY1788612xvDILQtApbc; Mon, 20 Nov 2023 23:40:10 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web11.30780.1700552401980407888 for ; Mon, 20 Nov 2023 23:40:09 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="10449999" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="10449999" X-Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 23:40:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="7989985" X-Received: from shwdeopenlab813.ccr.corp.intel.com ([10.239.55.230]) by fmviesa002.fm.intel.com with ESMTP; 20 Nov 2023 23:40:08 -0800 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: xieyuanh , Ray Ni , Eric Dong , Rahul Kumar , Tom Lendacky , Laszlo Ersek Subject: [edk2-devel] [Patch V2 3/3] UefiCpuPkg/MpInitLib: Eliminate redundant microcode loading in DXE. Date: Tue, 21 Nov 2023 15:39:56 +0800 Message-Id: <20231121073956.2741-4-yuanhao.xie@intel.com> In-Reply-To: <20231121073956.2741-1-yuanhao.xie@intel.com> References: <20231121073956.2741-1-yuanhao.xie@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yuanhao.xie@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ohH7TIyJyRuN7DKBfG3QNfdDx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700552411723100008 Content-Type: text/plain; charset="utf-8" The DXE stage's Microcode loading process has been elimincated by: 1. Microcode HOB consumption in MP initialization within the DXE phase. 2. Restricting MicrocodeDetect to the PEI phase instead of DXE for BSP. 3. BSP now WakeUpAp only for synchronizing MTRR settings, with Microcode loading no longer a part of this process. Cc: Ray Ni Cc: Eric Dong Cc: Rahul Kumar Cc: Tom Lendacky Cc: Laszlo Ersek Signed-off-by: Yuanhao Xie Reviewed-by: Laszlo Ersek --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 54 ++++++++++++++++++++++++++++++++= +++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index bb5d4188f0..0cf3520f9e 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -434,7 +434,27 @@ ApFuncEnableX2Apic ( } =20 /** - Do sync on APs. + Sync BSP's MTRR table to AP during waking up APs. + @param[in, out] Buffer Pointer to private data buffer. +**/ +VOID +EFIAPI +ApMtrrSync ( + IN OUT VOID *Buffer + ) +{ + CPU_MP_DATA *CpuMpData; + + CpuMpData =3D (CPU_MP_DATA *)Buffer; + + // + // Sync BSP's MTRR table to AP + // + MtrrSetAllMtrrs (&CpuMpData->MtrrTable); +} + +/** + Do sync on APs, includes loading microcode, and sync MTRRs. =20 @param[in, out] Buffer Pointer to private data buffer. **/ @@ -2224,26 +2244,10 @@ MpInitLibInitialize ( } } =20 - if (!GetMicrocodePatchInfoFromHob ( - &CpuMpData->MicrocodePatchAddress, - &CpuMpData->MicrocodePatchRegionSize - )) - { - // - // The microcode patch information cache HOB does not exist, which mea= ns - // the microcode patches data has not been loaded into memory yet - // - ShadowMicrocodeUpdatePatch (CpuMpData); - } - // - // Wakeup APs to do some AP initialize sync (Microcode & MTRR) + // Wakeup APs to do some AP initialize sync. // if (CpuMpData->CpuCount > 1) { - // - // Detect and apply Microcode on BSP - // - MicrocodeDetect (CpuMpData, CpuMpData->BspNumber); // // Store BSP's MTRR setting // @@ -2256,8 +2260,20 @@ MpInitLibInitialize ( // in DXE. // CpuMpData->InitFlag =3D ApInitReconfig; - WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE); + // + // Wakeup APs to sync MTRR settings. + // For the case the PEI and DXE are in different bit mode. + // It is necessary to do the MTRRs syncing. + // + WakeUpAP (CpuMpData, TRUE, 0, ApMtrrSync, CpuMpData, TRUE); } else { + // + // Detect and apply Microcode on BSP + // + MicrocodeDetect (CpuMpData, CpuMpData->BspNumber); + // + // Wakeup APs to do some AP initialize sync load microcode and Sync = MTRRs + // WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE); } =20 --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111524): https://edk2.groups.io/g/devel/message/111524 Mute This Topic: https://groups.io/mt/102724548/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-