From nobody Sat Feb 7 06:35:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52587+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52587+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1577431966; cv=none; d=zohomail.com; s=zohoarc; b=Vq0A42Q/Rn5V+nLUQpv4oxLXqi6i6bFSegQ184+2PmXy5/ojY6n0vhQxOlxE3xT5QuqG2YOKttIZnXDmJz1mKiEDGZO8U0lJxqZAguOaP69GoBQ0PovLT0Pa7iEdsA9t/pJI6hw9/G5/oVHPv7mkKlPRygeUQk09sIamQ2GBylY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577431966; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=3rQ5MKzBHcL1yueHEqFeCZ2RNciYdCaY46N9AREg5KY=; b=HP6CULwArmAvCyBLZ3tM6TVxlVsMyOw/gWSI74YQ0uAdr5GqFX/xd7LPlDEOoDKONeLJppRQ0hKtfhNKefZ8eB1IBkZ76UI6otoLtZQfdOmFEbK3O6RVaBFJPm3pEKLc8iqC/5GOgkxFbN8LYrWnH1ySdz0MB2Km4CVF9C2py90= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52587+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1577431966922210.0803115948528; Thu, 26 Dec 2019 23:32:46 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id gyvTYY1788612xa59yzZ4IKI; Thu, 26 Dec 2019 23:32:44 -0800 X-Received: from mga06.intel.com (mga06.intel.com []) by mx.groups.io with SMTP id smtpd.web12.29151.1577431953513368188 for ; Thu, 26 Dec 2019 23:32:43 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2019 23:32:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,362,1571727600"; d="scan'208";a="220445520" X-Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.8]) by orsmga003.jf.intel.com with ESMTP; 26 Dec 2019 23:32:41 -0800 From: "Wu, Hao A" To: devel@edk2.groups.io Cc: Hao A Wu , Eric Dong , Ray Ni , Laszlo Ersek , Star Zeng , Siyuan Fu , Michael D Kinney Subject: [edk2-devel] [PATCH v4 6/6] UefiCpuPkg/MpInitLib: Remove redundant microcode fields in CPU_MP_DATA Date: Fri, 27 Dec 2019 15:32:29 +0800 Message-Id: <20191227073229.9416-7-hao.a.wu@intel.com> In-Reply-To: <20191227073229.9416-1-hao.a.wu@intel.com> References: <20191227073229.9416-1-hao.a.wu@intel.com> Precedence: Bulk List-Unsubscribe: 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,hao.a.wu@intel.com X-Gm-Message-State: SYKtZFB6wgO5SAgwQaiSpQotx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1577431964; bh=UgGDeCRpu+1+JvIMeFDgrEebIBelJKv7ORZHQd6rQAI=; h=Cc:Date:From:Reply-To:Subject:To; b=iyICJd7gTXVnLQoRswP4GCLtN0CCfTXM3SZzRb5832NR5WYG+CyZZFPS5DAy8CvhuhG I/3bAycKIcu3vTYUDHCeHR07MrcoFgla3jpZHNoGNwdizEPkSMuaIU4MqU28TH1LfuO9W YAKNrpieEwYgc/lElcUXUL+Zx4R+gRAfScw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Previous commits have introduced below fields in structure CPU_AP_DATA: UINT32 ProcessorSignature; UINT8 PlatformId; UINT64 MicrocodeEntryAddr; which store the information of: A. CPUID B. Platform ID C. Detected microcode patch entry address (including the microcode patch header) for each processor within system. Therefore, the below fields in structure CPU_MP_DATA: UINT32 ProcessorSignature; UINT32 ProcessorFlags; UINT64 MicrocodeDataAddress; UINT32 MicrocodeRevision; which store the BSP's information of: A. CPUID B. Platform ID C. The address and revision of detected microcode patch are redundant and can be removed. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Star Zeng Cc: Siyuan Fu Cc: Michael D Kinney Signed-off-by: Hao A Wu Reviewed-by: Eric Dong --- UefiCpuPkg/Library/MpInitLib/MpLib.h | 5 -- UefiCpuPkg/Library/MpInitLib/Microcode.c | 51 ++++++-------------- 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpIn= itLib/MpLib.h index 5f50e79744..6609c958ce 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -263,11 +263,6 @@ struct _CPU_MP_DATA { BOOLEAN PeriodicMode; BOOLEAN TimerInterruptState; =20 - UINT32 ProcessorSignature; - UINT32 ProcessorFlags; - UINT64 MicrocodeDataAddress; - UINT32 MicrocodeRevision; - // // Whether need to use Init-Sipi-Sipi to wake up the APs. // Two cases need to set this value to TRUE. One is in HLT diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c b/UefiCpuPkg/Library/= MpInitLib/Microcode.c index 74a34c48fa..4ec54b6220 100644 --- a/UefiCpuPkg/Library/MpInitLib/Microcode.c +++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c @@ -85,6 +85,7 @@ MicrocodeDetect ( UINTN Index; UINT8 PlatformId; CPUID_VERSION_INFO_EAX Eax; + CPU_AP_DATA *CpuData; UINT32 CurrentRevision; UINT32 LatestRevision; UINTN TotalSize; @@ -92,16 +93,9 @@ MicrocodeDetect ( UINT32 InCompleteCheckSum32; BOOLEAN CorrectMicrocode; VOID *MicrocodeData; - MSR_IA32_PLATFORM_ID_REGISTER PlatformIdMsr; - UINT32 ProcessorFlags; UINT32 ThreadId; BOOLEAN IsBspCallIn; =20 - // - // set ProcessorFlags to suppress incorrect compiler/analyzer warnings - // - ProcessorFlags =3D 0; - if (CpuMpData->MicrocodePatchRegionSize =3D=3D 0) { // // There is no microcode patches @@ -127,28 +121,25 @@ MicrocodeDetect ( } =20 ExtendedTableLength =3D 0; - // - // Here data of CPUID leafs have not been collected into context buffer,= so - // GetProcessorCpuid() cannot be used here to retrieve CPUID data. - // - AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL); - - // - // The index of platform information resides in bits 50:52 of MSR IA32_P= LATFORM_ID - // - PlatformIdMsr.Uint64 =3D AsmReadMsr64 (MSR_IA32_PLATFORM_ID); - PlatformId =3D (UINT8) PlatformIdMsr.Bits.PlatformId; + Eax.Uint32 =3D CpuMpData->CpuData[ProcessorNumber].ProcessorSignature; + PlatformId =3D CpuMpData->CpuData[ProcessorNumber].PlatformId; =20 // // Check whether AP has same processor with BSP. // If yes, direct use microcode info saved by BSP. // if (!IsBspCallIn) { - if ((CpuMpData->ProcessorSignature =3D=3D Eax.Uint32) && - (CpuMpData->ProcessorFlags & (1 << PlatformId)) !=3D 0) { - MicrocodeData =3D (VOID *)(UINTN) CpuMpData->MicrocodeDataAddress; - LatestRevision =3D CpuMpData->MicrocodeRevision; - goto Done; + // + // Get the CPU data for BSP + // + CpuData =3D &(CpuMpData->CpuData[CpuMpData->BspNumber]); + if ((CpuData->ProcessorSignature =3D=3D Eax.Uint32) && + (CpuData->PlatformId =3D=3D PlatformId) && + (CpuData->MicrocodeEntryAddr !=3D 0)) { + MicrocodeEntryPoint =3D (CPU_MICROCODE_HEADER *)(UINTN) CpuData->Mic= rocodeEntryAddr; + MicrocodeData =3D (VOID *) (MicrocodeEntryPoint + 1); + LatestRevision =3D MicrocodeEntryPoint->UpdateRevision; + goto Done; } } =20 @@ -216,7 +207,6 @@ MicrocodeDetect ( CheckSum32 +=3D MicrocodeEntryPoint->Checksum; if (CheckSum32 =3D=3D 0) { CorrectMicrocode =3D TRUE; - ProcessorFlags =3D MicrocodeEntryPoint->ProcessorFlags; } } else if ((MicrocodeEntryPoint->DataSize !=3D 0) && (MicrocodeEntryPoint->UpdateRevision > LatestRevision)) { @@ -260,7 +250,6 @@ MicrocodeDetect ( // Find one // CorrectMicrocode =3D TRUE; - ProcessorFlags =3D ExtendedTable->ProcessorFlag; break; } } @@ -332,18 +321,6 @@ Done: CpuMpData->CpuData[ProcessorNumber].MicrocodeEntryAddr =3D (UINTN) MicrocodeData - sizeof (CPU_MICROCODE_HEADER); } - - if (IsBspCallIn && (LatestRevision !=3D 0)) { - // - // Save BSP processor info and microcode info for later AP use. - // - CpuMpData->ProcessorSignature =3D Eax.Uint32; - CpuMpData->ProcessorFlags =3D ProcessorFlags; - CpuMpData->MicrocodeDataAddress =3D (UINTN) MicrocodeData; - CpuMpData->MicrocodeRevision =3D LatestRevision; - DEBUG ((DEBUG_INFO, "BSP Microcode:: signature [0x%08x], ProcessorFlag= s [0x%08x], \ - MicroData [0x%08x], Revision [0x%08x]\n", Eax.Uint32, ProcessorFlag= s, (UINTN) MicrocodeData, LatestRevision)); - } } =20 /** --=20 2.12.0.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 (#52587): https://edk2.groups.io/g/devel/message/52587 Mute This Topic: https://groups.io/mt/69283210/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-