From nobody Mon May 13 22:28:29 2024 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+111257+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+111257+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700046961; cv=none; d=zohomail.com; s=zohoarc; b=cd4SNfCBg9OEeZGMjGj1ZMz0ZMTluqasvtDxRc6a8ky7Heu+OKJgewtiIxsXRYa6VHrW4gS1JtWTJJcd6Nh96EbBs5kgYKKAeX0CXhqvgln8aZxTNpNe443l6uZsSFY1w2GLgYVGYV9cMah0iWojDeSfxeeZhesNjb1/YmwE2P4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700046961; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=KVeFspvakPXNNSb2HpqRW3SjH9ScrAA7lyjV3ZIbH7I=; b=TzUL805EOe54i4XYVvM4sknRXRMZogUhc2Bz/jIRM1034GCc1orHtLFlmjunBM67DHzqQEAGLwf7stmEZu1C6dS/jqyimOt0yhHzUc9QzfoRq1bbD7+So/WmNROCJ0Dd83THo/MmiJioxfi6Tjdb8CDkAfgeI2NZvPUdoGUM3KI= 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+111257+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 1700046961531656.898488075413; Wed, 15 Nov 2023 03:16:01 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=nbndrrZs86RSkWawWNCrhWWYulcc6UUAZAdTX7Twnwo=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe; s=20140610; t=1700046961; v=1; b=ihBp2Ppwr1ztt+Fss/c+oMHEAAySV/V/Vm6FRu1bvYw+1mIapCJooCEBKy0z/M7S3oqeXnQQ uf+m4R3EBZIDYQZA+tIHU7shSX4Yrf8XIU3xT1jeAD18TzilskUjZaU2uiJnZ5Q+GTXYF+tL48o zZHEW3p8IlggExU2Lv0Baov8= X-Received: by 127.0.0.2 with SMTP id fdtqYY1788612xda2to2mY8Z; Wed, 15 Nov 2023 03:16:01 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.10782.1700046959669687038 for ; Wed, 15 Nov 2023 03:16:00 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="455148438" X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="455148438" X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 03:16:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="1096420851" X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="1096420851" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmsmga005.fm.intel.com with ESMTP; 15 Nov 2023 03:15:58 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Laszlo Ersek , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Star Zeng Subject: [edk2-devel] [PATCH v2 1/3] UefiCpuPkg/BaseXApicLib: Fix CPUID_V2_EXTENDED_TOPOLOGY detection Date: Wed, 15 Nov 2023 19:15:51 +0800 Message-Id: <20231115111553.6592-2-jiaxin.wu@intel.com> In-Reply-To: <20231115111553.6592-1-jiaxin.wu@intel.com> References: <20231115111553.6592-1-jiaxin.wu@intel.com> 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,jiaxin.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: eycGaRUCM2pTlYTi5KNkq4vpx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700046963368100008 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch is to complete 170d4ce8, sync the change to BaseXApicLib. Checking the max cpuid leaf is not enough to figure whenever CPUID_V2_EXTENDED_TOPOLOGY is supported. Intel SDM says: Software must detect the presence of CPUID leaf 1FH by verifying (a) the highest leaf index supported by CPUID is >=3D 1FH, and (b) CPUID.1FH:EBX[15:0] reports a non-zero value. The same is true for CPUID leaf 0BH. This patch adds the EBX check to GetProcessorLocation2ByApicId(). The patch also fixes the existing check in GetProcessorLocationByApicId() to be in line with the spec by looking at bits 15:0. The comments are updated with a quote from the Intel SDM. Cc: Laszlo Ersek Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Star Zeng Signed-off-by: Gerd Hoffmann Signed-off-by: Jiaxin Wu Reviewed-by: Laszlo Ersek Reviewed-by: Ray Ni --- UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c b/UefiCpuPkg/Li= brary/BaseXApicLib/BaseXApicLib.c index d56c6275cc..efb9d71ca1 100644 --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c +++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c @@ -1053,15 +1053,16 @@ GetProcessorLocationByApicId ( &ExtendedTopologyEbx.Uint32, &ExtendedTopologyEcx.Uint32, NULL ); // - // If CPUID.(EAX=3D0BH, ECX=3D0H):EBX returns zero and maximum input v= alue for - // basic CPUID information is greater than 0BH, then CPUID.0BH leaf is= not - // supported on that processor. + // Quoting Intel SDM: + // Software must detect the presence of CPUID leaf 0BH by + // verifying (a) the highest leaf index supported by CPUID is >=3D + // 0BH, and (b) CPUID.0BH:EBX[15:0] reports a non-zero value. // - if (ExtendedTopologyEbx.Uint32 !=3D 0) { + if (ExtendedTopologyEbx.Bits.LogicalProcessors !=3D 0) { TopologyLeafSupported =3D TRUE; =20 // // Sub-leaf index 0 (ECX=3D 0 as input) provides enumeration paramet= ers to extract // the SMT sub-field of x2APIC ID. @@ -1183,10 +1184,11 @@ GetProcessorLocation2ByApicId ( OUT UINT32 *Core OPTIONAL, OUT UINT32 *Thread OPTIONAL ) { CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; + CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; UINT32 MaxStandardCpuIdIndex; UINT32 Index; UINTN LevelType; UINT32 Bits[CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_= DIE + 2]; @@ -1195,14 +1197,23 @@ GetProcessorLocation2ByApicId ( for (LevelType =3D 0; LevelType < ARRAY_SIZE (Bits); LevelType++) { Bits[LevelType] =3D 0; } =20 // - // Get max index of CPUID + // Quoting Intel SDM: + // Software must detect the presence of CPUID leaf 1FH by verifying + // (a) the highest leaf index supported by CPUID is >=3D 1FH, and (b) + // CPUID.1FH:EBX[15:0] reports a non-zero value. // AsmCpuid (CPUID_SIGNATURE, &MaxStandardCpuIdIndex, NULL, NULL, NULL); if (MaxStandardCpuIdIndex < CPUID_V2_EXTENDED_TOPOLOGY) { + ExtendedTopologyEbx.Bits.LogicalProcessors =3D 0; + } else { + AsmCpuidEx (CPUID_V2_EXTENDED_TOPOLOGY, 0, NULL, &ExtendedTopologyEbx.= Uint32, NULL, NULL); + } + + if (ExtendedTopologyEbx.Bits.LogicalProcessors =3D=3D 0) { if (Die !=3D NULL) { *Die =3D 0; } =20 if (Tile !=3D NULL) { --=20 2.16.2.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 (#111257): https://edk2.groups.io/g/devel/message/111257 Mute This Topic: https://groups.io/mt/102602851/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- From nobody Mon May 13 22:28:29 2024 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+111258+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+111258+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700046963; cv=none; d=zohomail.com; s=zohoarc; b=b4tfzBFm0nL3vdQGOuC+TMLCgwJwncIKec+o7PzRSPSlf1rJI0P8Qbm0XgiGEc7YTiXrpu42K4bels5RHBJxSIqwhow18BKzPZ+PW0sSJIvonM9+bjSAvP4nsMPnflz2l42jfNFc4qrsnaFfAgFzTP6Bh9zW9iB5w23BKZ5inbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700046963; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=THjrf3i+zUJP3bzxsahasgyJvaM4q+xstkW0bc/h4rk=; b=QhGggRTJfeZ2PWLIYYSdWErzP/1NCmhdrV+Uxl626r7PieX6d2iHdXxbHzMrekamJ5gaWqMl0FVGs60EvQlcYF61A7caPs06SCc1Xl2rtmmGvuVUytVSyGTjPKR81Mg0W2f9UUXJvRs//N8BzwoTjnyOxLfPZMHMUEzfmHMdHrE= 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+111258+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 1700046963147879.2095240121414; Wed, 15 Nov 2023 03:16:03 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=UVKPp4U/HnR7qMkmbCPFWzqHoZgg8XuimOBCMMn6bds=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe; s=20140610; t=1700046962; v=1; b=pNMmZOpNydkuL8aKnb1jlab4jRqEYSuKOJg/kNfvctj5mHPlpURCvYkOhpMXIL+aDxStgd31 n5S872khXnGmslW0l52yJ54I+FxEIA/EkE70Q21LlbrVQA7/Pm6cyzPhdSkLGRZd5qvekxtMs5Z UGj7CT+855hU/brFEvLelrIo= X-Received: by 127.0.0.2 with SMTP id g5cFYY1788612xjKbmzIQyUC; Wed, 15 Nov 2023 03:16:02 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.10782.1700046959669687038 for ; Wed, 15 Nov 2023 03:16:02 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="455148442" X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="455148442" X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 03:16:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="1096420855" X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="1096420855" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmsmga005.fm.intel.com with ESMTP; 15 Nov 2023 03:16:00 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Laszlo Ersek , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Star Zeng Subject: [edk2-devel] [PATCH v2 2/3] UefiCpuPkg/PiSmmCpuDxeSmm: Get processor extended information Date: Wed, 15 Nov 2023 19:15:52 +0800 Message-Id: <20231115111553.6592-3-jiaxin.wu@intel.com> In-Reply-To: <20231115111553.6592-1-jiaxin.wu@intel.com> References: <20231115111553.6592-1-jiaxin.wu@intel.com> 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,jiaxin.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: J8ej8XxGi09RtzAH5fXqvVKJx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700046963366100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch is to extend SmmAddProcessor function to get processor extended information. It's to complete commit 1fadd18d. Cc: Laszlo Ersek Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Star Zeng Signed-off-by: Jiaxin Wu Reviewed-by: Laszlo Ersek Regression-tested-by: Laszlo Ersek Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c b/UefiCpuPkg/PiSmmCpuDx= eSmm/CpuService.c index 391b64e9f2..c0485b0519 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c @@ -169,10 +169,20 @@ SmmAddProcessor ( &gSmmCpuPrivate->ProcessorInfo[Index].Location.Package, &gSmmCpuPrivate->ProcessorInfo[Index].Location.Core, &gSmmCpuPrivate->ProcessorInfo[Index].Location.Thread ); =20 + GetProcessorLocation2ByApicId ( + (UINT32)ProcessorId, + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Location= 2.Package, + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Location= 2.Die, + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Location= 2.Tile, + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Location= 2.Module, + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Location= 2.Core, + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Location= 2.Thread + ); + *ProcessorNumber =3D Index; gSmmCpuPrivate->Operation[Index] =3D SmmCpuAdd; return EFI_SUCCESS; } } --=20 2.16.2.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 (#111258): https://edk2.groups.io/g/devel/message/111258 Mute This Topic: https://groups.io/mt/102602852/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- From nobody Mon May 13 22:28:29 2024 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+111259+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+111259+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700046975; cv=none; d=zohomail.com; s=zohoarc; b=jdcl6nGTLmjb9lsRGDgYYtOXuzdlH8giNp2cqnrRuNA6bac9GKFmhrU84n3+jYMUIs5IF5siPEamP6FP0WHXSwgmOHnuogMNYHebO4BaNvm6wL81TGtd8LfZ6o/wG5A9XZ0jrL0T4ORQkmtArWEU2iHD1CIHx2YsRCeWjEtUPdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700046975; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=s4sRK2Hiva1xhS5ROKUy22OTpzYVIbJVPg02OoNtKkU=; b=U4YoFRh32pQskoKUnmPt80RajcNMPFHCoM2jxvgdNx0FNHK4AF4MpgDAkmVpaxSnZxZq9Xakmyz7HizdyQMmCWGcA27v8P6UbTliZE6V8xcSLTpJaTnhHkNIvjnilJIfXADE+Wr6cRXNDqrwbBIPQLn1S+Q7sGs4/ls8FE99e1k= 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+111259+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 1700046975243504.24138257149446; Wed, 15 Nov 2023 03:16:15 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=6LL9JIStzXJN/egOogy3MwuJkZ+VcaLwnTjgT3biLws=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe; s=20140610; t=1700046974; v=1; b=uRlTGBTf+mCBPRzhSP+PLGTjjP8NCTPzslTGj/0Vqa4IiQobUTeRolZrVrX4yLYq/RcyOOma QclftMbdiSi4bjB5oGsYJFI0tnSbAxgw+5VQddGb/S34gXp9Qj/cHX5k/vO9xisaa5rt/BNcjHY W1xRTull+x5qgz+kdzbpjTg0= X-Received: by 127.0.0.2 with SMTP id IFjqYY1788612xgBQihLu6Vj; Wed, 15 Nov 2023 03:16:14 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.10782.1700046959669687038 for ; Wed, 15 Nov 2023 03:16:04 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="455148446" X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="455148446" X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 03:16:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="1096420858" X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="1096420858" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmsmga005.fm.intel.com with ESMTP; 15 Nov 2023 03:16:02 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Laszlo Ersek , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Star Zeng Subject: [edk2-devel] [PATCH v2 3/3] UefiCpuPkg/PiSmmCpuDxeSmm: Use processor extended information Date: Wed, 15 Nov 2023 19:15:53 +0800 Message-Id: <20231115111553.6592-4-jiaxin.wu@intel.com> In-Reply-To: <20231115111553.6592-1-jiaxin.wu@intel.com> References: <20231115111553.6592-1-jiaxin.wu@intel.com> 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,jiaxin.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: cSLem0wT4DHWF94tkvtk6QNKx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700046977426100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch changes to use the processor extended information, which can reflect the value from CPUID leaf 1FH. The reasons are listed as below: 1. The processor package ID retrieved from CPUID 0x0Bh may be not correct/accurate if CPU has the module & die info, it depends on the CPUID implementation. See SDM statement: EAX Bits 04 - 00: Number of bits to shift right on x2APIC ID to get a unique topology ID of the next level type. ECX Bits 15 - 08: level type Level type field has the following encoding: 0: Invalid. 1: SMT. 2: Core. 3-255: Reserved So, if level type returned from ECX Bits 15 - 08 is 2 (Core), then it's not clear about the next level. It can be Module or Die or Package. SDM doesn't has explanation for the next level of Core. If so, the value will be decided by implementation. The value can be package info for compatibility consideration, but it's not standardized. 2. According SDM declaration, "CPUID leaf 1FH is a preferred superset to leaf 0BH. Intel recommends first checking for the existence of CPUID leaf 1FH before using leaf 0BH." This is perfect match the existing GetProcessorLocation2ByApicId() implementation. Cc: Laszlo Ersek Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Star Zeng Signed-off-by: Jiaxin Wu Reviewed-by: Laszlo Ersek Regression-tested-by: Laszlo Ersek --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index 25d058c5b9..c61562c867 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -177,11 +177,11 @@ IsPackageFirstThread ( IN UINTN CpuIndex ) { UINT32 PackageIndex; =20 - PackageIndex =3D gSmmCpuPrivate->ProcessorInfo[CpuIndex].Location.Packa= ge; + PackageIndex =3D gSmmCpuPrivate->ProcessorInfo[CpuIndex].ExtendedInform= ation.Location2.Package; =20 ASSERT (mPackageFirstThreadIndex !=3D NULL); =20 // // Set the value of mPackageFirstThreadIndex[PackageIndex]. @@ -1834,12 +1834,12 @@ InitPackageFirstThreadIndexInfo ( =20 // // Count the number of package, set to max PackageId + 1 // for (Index =3D 0; Index < mNumberOfCpus; Index++) { - if (PackageId < gSmmCpuPrivate->ProcessorInfo[Index].Location.Package)= { - PackageId =3D gSmmCpuPrivate->ProcessorInfo[Index].Location.Package; + if (PackageId < gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformati= on.Location2.Package) { + PackageId =3D gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformati= on.Location2.Package; } } =20 PackageCount =3D PackageId + 1; =20 --=20 2.16.2.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 (#111259): https://edk2.groups.io/g/devel/message/111259 Mute This Topic: https://groups.io/mt/102602853/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-