From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id CD518D80F71 for ; Tue, 21 Nov 2023 07:40:11 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=V6KkKm2rlfU6cYHkd/hTix+ruVzm1oNtXOpok+hfdtc=; 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=FGSzJMjl2H45WxLAd3MIIAZK/EMU3mNVuPW0VHpJDkIN1MT1He3E3cpvMxGaCBZsDnigDvtN PAGfCbUkYibWnZb+gQAUZIxLghodkGHsGm1u4C/7zBggKiSJwMX8/k6KWA7RaJvPqDDfW0uw/5V 3I95cF7vXx6uBXf4qm9/eseU= X-Received: by 127.0.0.2 with SMTP id 65Y6YY7687511xS2MMtacWRe; 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: 13Nhd6TVhD6laJLZ7zFtPSW3x7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=FGSzJMjl; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) 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 --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 54 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index bb5d4188f0..0cf3520f9e 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -434,7 +434,27 @@ ApFuncEnableX2Apic ( } /** - 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 = (CPU_MP_DATA *)Buffer; + + // + // Sync BSP's MTRR table to AP + // + MtrrSetAllMtrrs (&CpuMpData->MtrrTable); +} + +/** + Do sync on APs, includes loading microcode, and sync MTRRs. @param[in, out] Buffer Pointer to private data buffer. **/ @@ -2224,26 +2244,10 @@ 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); - } - // - // 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 = 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); } -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- 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/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-