From nobody Sun Apr 28 04:54:02 2024 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+53633+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+53633+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1580690085441812.959203410544; Sun, 2 Feb 2020 16:34:45 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id UjG5YY1788612xXkg2MBKvJL; Sun, 02 Feb 2020 16:34:44 -0800 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.6552.1580690083317825240 for ; Sun, 02 Feb 2020 16:34:43 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Feb 2020 16:34:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,395,1574150400"; d="scan'208";a="253903063" X-Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.8]) by fmsmga004.fm.intel.com with ESMTP; 02 Feb 2020 16:34:41 -0800 From: "Wu, Hao A" To: devel@edk2.groups.io Cc: Hao A Wu , Eric Dong , Ray Ni , Laszlo Ersek , Siyuan Fu , Michael D Kinney Subject: [edk2-devel] [PATCH v1] UefiCpuPkg/MpInitLib: Always get CPUID & PlatformID in MicrocodeDetect() Date: Mon, 3 Feb 2020 08:34:38 +0800 Message-Id: <20200203003438.6724-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: WRC499vESTXEk2ZXuQUA1Fgmx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580690084; bh=1GvqzPIZKbgxR8i3OyZvUK66qUEo0WevHTntdARt5Cw=; h=Cc:Date:From:Reply-To:Subject:To; b=f9PFVTJo5y7hH09wBlSxjEsTSayZjwPKQpm56kIjcjuLa1YE8HXHcJ0E0uqt7QGR4Am BsyA7h8WamHnU6FIRWN7ueIXvHND5dFE0s9Ruc7rheRXYCJWXBX6nAd//DD5tpABDjG2u VN2X0rS3FP8Qz4h0JDvu8ZnUD1pA2n+0w34= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2498 Commit fd30b00707 updated the logic in function MicrocodeDetect() that will directly use the CPUID and PlatformID information from the 'CpuData' field in the CPU_MP_DATA structure, instead of collecting these information 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, the CPUID and PlatformID information on APs will be used upon the 2nd entry of the MpInitLibInitialize(). But since the CPUID and PlatformID information has not been collected, it will bring issue to the microcode detection process. This commit will update the logic in MicrocodeDetect() back to always collecting 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 Reviewed-by: Eric Dong Reviewed-by: Siyuan Fu --- 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 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; + =20 // // Check whether AP has same processor with BSP. --=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 (#53633): https://edk2.groups.io/g/devel/message/53633 Mute This Topic: https://groups.io/mt/70934372/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-