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 69D16740032 for ; Thu, 16 Nov 2023 01:25:55 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Hhv3DAbZPeeUQUfRX2UxalcPgROGF2YleOJeVvqdZTg=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type; s=20140610; t=1700097953; v=1; b=CNok1XPOWcrWzcpbpA4sqscIy/emfXugLvS6xt4YN17OKvIfaOf+5q0q1yVUWcvOjUxZiH5v 6IH/sGIxk0ZloGIT226kAoGOI0sjmRcaMgbpezwlh1M3IOQBSWWhJ9K+HyFZ4sK+K8FYVXxC6S5 VULqjDzjc2xi1CgTTdE1tZRA= X-Received: by 127.0.0.2 with SMTP id IPJfYY7687511xkKFXcsyyuh; Wed, 15 Nov 2023 17:25:53 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web10.30733.1700097952994722333 for ; Wed, 15 Nov 2023 17:25:53 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10895"; a="9631792" X-IronPort-AV: E=Sophos;i="6.03,306,1694761200"; d="scan'208,217";a="9631792" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 17:25:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10895"; a="831105812" X-IronPort-AV: E=Sophos;i="6.03,306,1694761200"; d="scan'208,217";a="831105812" X-Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga008.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 15 Nov 2023 17:25:51 -0800 X-Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 15 Nov 2023 17:25:50 -0800 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 15 Nov 2023 17:25:50 -0800 X-Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Wed, 15 Nov 2023 17:25:50 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.101) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Wed, 15 Nov 2023 17:25:50 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kNXVei0LgSueqfw83KGcXPrf3wL3V5AnRi+ubaLgtT9qWr3TWF488nm1GWJoVuT2g8WlholDL0dUM83tjeZnZlzsVhbAbunprqlhZQadTFAkwnqCI89q+xZ1pfjltmzroxR85i5yQvoAum/k1OKFrPDQKBvvqoakYI5I2RdxTY6lXt+bEPF4Xc1N5YsJHHEzVRn2Y1Sv3rVPLMMirbG5NJns/p79ZdPGg1eNIk4CzdfVh3/QcDuRVIaTBBCqHvrm+vBIn+FYSXfKcfHbaDZtG27JzP0ruvDUoV0LergYXzRhShTF63ASeFeKzFFxfW5EALbO9g3Z0LIFE5fhAVQAgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K7wXmklmn/ht4y21Mc6vSd6MjkR4JLVzlSm6OISVHak=; b=ONg2gSIUmgUXG3GWpC7GQMeL2sIBhhAoirpWSHPSgdkg3iGxJui1pwxwjdz0M5Q4RHPk4MA0MRiuU/ureVst+XuvrFFaxhVOC7ma7FiZ6e+BpU/2+zYBgWtJnlZU1lJSbRn8reSAYpUa7EnHGWcOyp0BVJtoG2FVxtMkLQyLJuS1kVX8fDtFeGIBwlWEs4V+nX+m8Eqzc9Bt9dH1wE6e/NaOp/+Qhfw6G8GaQO7oswHwChnkcljts5LNdOgqzx+q8NO9KQuWUA9gIblNo7eN1yCF4EbqMTMQhv+Wo6fB/TAbJPKSx94X4+C9bpGNvovlA7gxpd/9xEHzdsskcFRA2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by MW3PR11MB4731.namprd11.prod.outlook.com (2603:10b6:303:2f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.20; Thu, 16 Nov 2023 01:25:47 +0000 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::b614:1f5e:8b0c:9858]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::b614:1f5e:8b0c:9858%4]) with mapi id 15.20.6977.029; Thu, 16 Nov 2023 01:25:47 +0000 From: "Ni, Ray" To: "Wu, Jiaxin" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann , "Zeng, Star" Subject: Re: [edk2-devel] [PATCH v2 1/3] UefiCpuPkg/BaseXApicLib: Fix CPUID_V2_EXTENDED_TOPOLOGY detection Thread-Topic: [PATCH v2 1/3] UefiCpuPkg/BaseXApicLib: Fix CPUID_V2_EXTENDED_TOPOLOGY detection Thread-Index: AQHaF7Ufm8qmyahyOU60Vtiurp/lbrB8KCUL Date: Thu, 16 Nov 2023 01:25:47 +0000 Message-ID: References: <20231115111553.6592-1-jiaxin.wu@intel.com> <20231115111553.6592-2-jiaxin.wu@intel.com> In-Reply-To: <20231115111553.6592-2-jiaxin.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|MW3PR11MB4731:EE_ x-ms-office365-filtering-correlation-id: e93a3423-1ea3-4c91-cf73-08dbe642f649 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: qUZlCAAhzGuAeCPgNkz9kVFTQy93O0XYMrw3+ha7gmvbYKDIo5sQ3dKvaFg1fun4REpG7YDwQ/rrFnlAyea76nnnImlTq5dKDynSX4lvJ2IrEESf+Tyr6dPmusvcPf4uDh9UgFjCObOzJrRn3ipowjQtMfz6bn72JteE5mAkxIzrZUVRC45YY3ipWKwJiL2TtZqegFpTY3Sb3UD+xPaMKpKrDwF+19Pk89JXWCPnnDXO9kbBxEsS6N4G/vGEex+SDgMpool238Rr0dU5nau4efB78njteKuN4Sj8KyleJuHSrh3OVuo6Fts8N0Qk1B3L0zXVe85Bizeh7Qz340o1amhnwddZnbsnGCoRWnqoAyzRrnouxVXtTqN3ha6m/kQY6y25s9jV1Dr72fg84MQEaJ1ekqGHJ0E1NXJ36GIBbGuWxm8qRbZu9mXDVyIp8p/WTz86VqVI8jNZL969f5h/EMo5GsSxk1BoKVSpDWlfZsK8HsOpuZs/sIg7MNDYX5wjK5P2JcGj5mZ/szd4yPUc8k8CnN7A396V8qd2q0vT9ZdQevqDyxBdtGwNj6S9DJxK+biztJCKZJfcXmaMMLvInrFCNoy6UkSJJ2XHT+m+HYpa8F5BE6zhtuTX6jBLVBT1 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Gth26yj1bIIzTg3pG7T65xssnGrNjSGHALVyr/QD/6Az1aSQQYDACOxJ1O0r?= =?us-ascii?Q?FfHrOVnt+cVWkUAiTvMIp4XYoNyar8QcL9xsRexZGFTwuKe05AYWehPnmXXg?= =?us-ascii?Q?6Szu3WUDVvTethcGUxOiiSA3B0zsSWzqGSUP7mSEIu00rBErJ5TYy2QuvWFQ?= =?us-ascii?Q?PvIJ+8zsybhxq38ZtBfzAAFi5wRTBOSBXtQk+UhS5942OIp+5TTTlwQhkmy0?= =?us-ascii?Q?6oBnJIa6OFMQURppccpIGoxCArgu6nChWxmL0A/E0Ag8BGkGaBQ4ofw8WTxd?= =?us-ascii?Q?vg0zOpjtDgpu4nuldLpzmIdd9RN6jdAq95cJfMiJPvvR3sWEeLa/2dTWL0HK?= =?us-ascii?Q?15V3UG7yE7tzmWWcRwgDWMnriPUIf7vnp8bDpaR+EIDrrC1sSLXMjiiLHofk?= =?us-ascii?Q?9PuA53iPdUo9+JNewV+djoROFFmH66Uwds1sfO6Gk49mQlXW6Oubm2zYgpIN?= =?us-ascii?Q?yiWxon6nub3KKYTx8SML7xaEXOkGFn8GwPOgk1IK5drqbQLkW4oYnrOXyZVG?= =?us-ascii?Q?qsvostTViD9yapYV/qkhwDWUbocH9AvEC3SA96xt07f9v/0J8GrQwX70ZlQ4?= =?us-ascii?Q?NUEKHzHuvFzdXtMJpSTkjYT4z18VT4pxQq9V0wZxSnZ93kPiPcq4U6v1R27e?= =?us-ascii?Q?95YE6FFHQcwTRonHxDdxgM5Vsla1bk3RLOLc3GXfalWaNGN1kvQZvYRYjUOk?= =?us-ascii?Q?ylCXL6T//f8XnVNXDeZ4zrSfB5+NoJ4fgJxKHbZ37IOEqB9jMTUp8l4iTpvK?= =?us-ascii?Q?9w0lLhphrc6kk3fPfJ+EfNxu5iOmLmmp0IWcUwM4tUgITRCgyg0gmNu7hWu0?= =?us-ascii?Q?PqhKCdsKcPsdR1v7Qa7VN+0XIvGrunTY7SlTvjtrPEiL/8K5idbBajzjxSwq?= =?us-ascii?Q?9wdmIn/vupCMqWpp0TXTqnpyTlU8lpccGjwUXbBjwa/DcixX8KmOVTq5Qr16?= =?us-ascii?Q?qD0SWYgvrKbQUwzvJ3w23f38oFvbv2K504kc0EQTlEH9Wqt2SYdoo7BLCvvJ?= =?us-ascii?Q?oFoKkgfnxqCWK2PxG/u4xqSxTZqAjRsbvx6Nw4jhqu3HhLkrVkAmCrwbhztp?= =?us-ascii?Q?3obx3z/Fw/NY8lCN4+9SKwJUopK7i/tX0CuruWwD7hRN5dtqU9TV5ABhJgdU?= =?us-ascii?Q?rrn+FUaziQfQUBdzwphGA+SXZ5clwnPzEPD4ghdEfWKGXLV/8irCGsFORIj7?= =?us-ascii?Q?KLRiGGsuXdEFRzF7tiK5ljrTSQ8IzYAPXZQvZ/eCfcSG0XtAcM2lpZrXjt2O?= =?us-ascii?Q?RtekIyLFNA8yp3kO9FwjcBjE1eOhqrimw9P1JQnIqSaNUsCcuOmDJ+suAL6K?= =?us-ascii?Q?Bd26h+KnV7qWjbvIZbZiZD9vwPHIG7y/hJVRB9aOAZcTuNhtd7mGwAyjXCzG?= =?us-ascii?Q?Uf6MN0IrEw5L7o0JlSzfS5NxUNYmqy9+MdZyFaSRy1rWVB/x5fOv2GNbQDGG?= =?us-ascii?Q?YYXjWAukCGMFp0GEN/UZJK3wDzKj3sP54T+r7e9IDwhTAxavUhotLT/0tDjU?= =?us-ascii?Q?0q1WOpQr8E1vvsvg3YnfZe7kp9IKMNXGBs+GWEON9DkaOtwulEcdIyC9t99i?= =?us-ascii?Q?I1dnyBNqgOTJW9ZucL4=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e93a3423-1ea3-4c91-cf73-08dbe642f649 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Nov 2023 01:25:47.7162 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: i22W7KCGaHxffvR41tENKrb8/lAoN+26Oe77XDDYcW9gDd5zsUQadDSoIpd5AQlPixaXHHa0UMxPafgkqCUMsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4731 X-OriginatorOrg: 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,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: wEGmgdzpo5KUSMe9hf7TwE63x7686176AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MN6PR11MB8244C99488A35432B8F85DC68CB0AMN6PR11MB8244namp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=CNok1XPO; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") --_000_MN6PR11MB8244C99488A35432B8F85DC68CB0AMN6PR11MB8244namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni Thanks, Ray ________________________________ From: Wu, Jiaxin Sent: Wednesday, November 15, 2023 7:15 PM To: devel@edk2.groups.io Cc: Laszlo Ersek ; Dong, Eric ; Ni,= Ray ; Kumar, Rahul R ; Gerd Hof= fmann ; Zeng, Star Subject: [PATCH v2 1/3] UefiCpuPkg/BaseXApicLib: Fix CPUID_V2_EXTENDED_TOPO= LOGY detection 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 --- 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; // // 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; } // - // 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; } if (Tile !=3D NULL) { -- 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 (#111296): https://edk2.groups.io/g/devel/message/111296 Mute This Topic: https://groups.io/mt/102602851/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --_000_MN6PR11MB8244C99488A35432B8F85DC68CB0AMN6PR11MB8244namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Ray Ni = <ray.ni@intel.com>

Thanks,
Ray

From: Wu, Jiaxin <jiaxin= .wu@intel.com>
Sent: Wednesday, November 15, 2023 7:15 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Laszlo Ersek <lersek@redhat.com>; Dong, Eric <eric.dong= @intel.com>; Ni, Ray <ray.ni@intel.com>; Kumar, Rahul R <rahul.= r.kumar@intel.com>; Gerd Hoffmann <kraxel@redhat.com>; Zeng, Star = <star.zeng@intel.com>
Subject: [PATCH v2 1/3] UefiCpuPkg/BaseXApicLib: Fix CPUID_V2_EXTEND= ED_TOPOLOGY detection
 
This patch is to complete 170d4ce8, sync the chang= e 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 <lersek@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
---
 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 value for
-    // basic CPUID information is greater than 0BH, then CP= UID.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 CP= UID 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;
 
       //
       // Sub-leaf index 0 (ECX=3D 0 as input= ) provides enumeration parameters 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         &n= bsp;            = ; MaxStandardCpuIdIndex;
   UINT32         &n= bsp;            = ; Index;
   UINTN         &nb= sp;            =   LevelType;
   UINT32         &n= bsp;            = ; Bits[CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE + 2];
@@ -1195,14 +1197,23 @@ GetProcessorLocation2ByApicId (
   for (LevelType =3D 0; LevelType < ARRAY_SIZE (Bits); LevelT= ype++) {
     Bits[LevelType] =3D 0;
   }
 
   //
-  // 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, an= d (b)
+  // CPUID.1FH:EBX[15:0] reports a non-zero value.
   //
   AsmCpuid (CPUID_SIGNATURE, &MaxStandardCpuIdIndex, NULL, N= ULL, NULL);
   if (MaxStandardCpuIdIndex < CPUID_V2_EXTENDED_TOPOLOGY) { +    ExtendedTopologyEbx.Bits.LogicalProcessors =3D 0;
+  } else {
+    AsmCpuidEx (CPUID_V2_EXTENDED_TOPOLOGY, 0, NULL, &E= xtendedTopologyEbx.Uint32, NULL, NULL);
+  }
+
+  if (ExtendedTopologyEbx.Bits.LogicalProcessors =3D=3D 0) {
     if (Die !=3D NULL) {
       *Die =3D 0;
     }
 
     if (Tile !=3D NULL) {
--
2.16.2.windows.1

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#111296) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_MN6PR11MB8244C99488A35432B8F85DC68CB0AMN6PR11MB8244namp_--