From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.6337.1580824006788818620 for ; Tue, 04 Feb 2020 05:46:47 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: eric.dong@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Feb 2020 05:46:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,401,1574150400"; d="scan'208";a="431526581" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga006.fm.intel.com with ESMTP; 04 Feb 2020 05:46:45 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 4 Feb 2020 05:46:45 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 4 Feb 2020 05:46:45 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.126]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.76]) with mapi id 14.03.0439.000; Tue, 4 Feb 2020 21:46:43 +0800 From: "Dong, Eric" To: "devel@edk2.groups.io" , "Wu, Hao A" CC: "Ni, Ray" , Laszlo Ersek , "Fu, Siyuan" , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH v1] UefiCpuPkg/MpInitLib: Always get CPUID & PlatformID in MicrocodeDetect() Thread-Topic: [edk2-devel] [PATCH v1] UefiCpuPkg/MpInitLib: Always get CPUID & PlatformID in MicrocodeDetect() Thread-Index: AQHV2im/cy2d6xFwEUyPzzLydlZw9agKjwKg Date: Tue, 4 Feb 2020 13:46:42 +0000 Message-ID: References: <20200203003438.6724-1-hao.a.wu@intel.com> In-Reply-To: <20200203003438.6724-1-hao.a.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDJiZWJlODItMzlmOS00MzVmLWI3MGEtYjM4NGViNzc3YjBhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoidkhvY0ZmUUZWQVBRSklBMEh0a05VY2ViS21IWTRtMUdoaXdEa05XTjdoN3dTaXRod1VtallscDIrMUNOcVlJUCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: eric.dong@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong -----Original Message----- From: devel@edk2.groups.io On Behalf Of Wu, Hao A Sent: Monday, February 3, 2020 8:35 AM To: devel@edk2.groups.io Cc: Wu, Hao A ; Dong, Eric ; Ni, = Ray ; Laszlo Ersek ; Fu, Siyuan ; Kinney, Michael D Subject: [edk2-devel] [PATCH v1] UefiCpuPkg/MpInitLib: Always get CPUID & = PlatformID in MicrocodeDetect() REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2498 Commit fd30b00707 updated the logic in function MicrocodeDetect() that wil= l directly use the CPUID and PlatformID information from the 'CpuData' field in the CPU_MP_DATA structure, instead of collecting these informatio= n for each processor via AsmCpuid() and AsmReadMsr64() calls respectively. At that moment, this approach worked fine for APs. Since: a) When the APs are waken up for the 1st time (1st MpInitLibInitialize() entry at PEI phase), the function InitializeApData() will be called for each AP and the CPUID and PlatformID information will be collected. b) During the 2nd entry of MpInitLibInitialize() at DXE phase, when the APs are waken up again, the function InitializeApData() will not be called, which means the CPUID and PlatformID information will not be collected. However, the below logics in MicrocodeDetect() function: CurrentRevision =3D GetCurrentMicrocodeSignature (); IsBspCallIn =3D (ProcessorNumber =3D=3D (UINTN)CpuMpData->BspNumber)= ? TRUE : FALSE; if (CurrentRevision !=3D 0 && !IsBspCallIn) { // // Skip loading microcode if it has been loaded successfully // return; } will ensure that the microcode detection and application will be skipped due to the fact that such process has already been done in the PEI phase. But after commit 396e791059, which removes the above skip loading logic, t= he CPUID and PlatformID information on APs will be used upon the 2nd entry = of the MpInitLibInitialize(). But since the CPUID and PlatformID informatio= n has not been collected, it will bring issue to the microcode detection pr= ocess. This commit will update the logic in MicrocodeDetect() back to always coll= ecting the CPUID and PlatformID information explicitly. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Siyuan Fu Cc: Michael D Kinney Signed-off-by: Hao A Wu --- UefiCpuPkg/Library/MpInitLib/Microcode.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c b/UefiCpuPkg/Library= /MpInitLib/Microcode.c index b6675b9a60..67e214d463 100644 --- a/UefiCpuPkg/Library/MpInitLib/Microcode.c +++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c @@ -93,6 +93,7 @@ MicrocodeDetect ( UINT32 InCompleteCheckSum32; BOOLEAN CorrectMicrocode; VOID *MicrocodeData; + MSR_IA32_PLATFORM_ID_REGISTER PlatformIdMsr; UINT32 ThreadId; BOOLEAN IsBspCallIn; =20 @@ -115,8 +116,18 @@ MicrocodeDetect ( } =20 ExtendedTableLength =3D 0; - Eax.Uint32 =3D CpuMpData->CpuData[ProcessorNumber].ProcessorSignature; - PlatformId =3D CpuMpData->CpuData[ProcessorNumber].PlatformId; + // + // Here data of CPUID leafs have not been collected into context=20 + 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=20 + IA32_PLATFORM_ID // + PlatformIdMsr.Uint64 =3D AsmReadMsr64 (MSR_IA32_PLATFORM_ID); + PlatformId =3D (UINT8) PlatformIdMsr.Bits.PlatformId; + =20 // // Check whether AP has same processor with BSP. -- 2.12.0.windows.1