From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=ray.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7053F211F26AD for ; Wed, 3 Apr 2019 01:09:56 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 01:09:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,304,1549958400"; d="scan'208";a="288278824" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga004.jf.intel.com with ESMTP; 03 Apr 2019 01:09:55 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 3 Apr 2019 01:09:49 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 3 Apr 2019 01:09:48 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.92]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.21]) with mapi id 14.03.0415.000; Wed, 3 Apr 2019 16:09:46 +0800 From: "Ni, Ray" To: "Dong, Eric" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] UefiCpuPkg/Cpuid: Dump leaf 1FH information correctly Thread-Index: AQHU6egLU42aGnf5y0+evHF3+ykOlqYqFRUQ Date: Wed, 3 Apr 2019 08:09:45 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C0C82C1@SHSMSX104.ccr.corp.intel.com> References: <20190329084159.69164-1-ray.ni@intel.com> In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] UefiCpuPkg/Cpuid: Dump leaf 1FH information correctly X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 08:09:56 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, April 3, 2019 2:40 PM > To: Ni, Ray ; edk2-devel@lists.01.org > Subject: RE: [PATCH] UefiCpuPkg/Cpuid: Dump leaf 1FH information correctl= y >=20 > Hi Ray, >=20 > > -----Original Message----- > > From: Ni, Ray > > Sent: Friday, March 29, 2019 4:42 PM > > To: edk2-devel@lists.01.org > > Cc: Dong, Eric > > Subject: [PATCH] UefiCpuPkg/Cpuid: Dump leaf 1FH information correctly > > > > Leaf 1FH is very similar to leaf 0BH. Both return the CPU topology > information. > > Leaf 0BH returns 3-level (Package/Core/Thread) CPU topology info. > > Leaf 1FH returns 6-level (Package/Die/Tile/Module/Core/Thread) CPU > > topology info. > > The logic to enumerate the topology info is the same. > > > > But today's logic to handle 1FH is completely wrong. > > The patch combines them together to fix the 1FH issue. > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Ray Ni > > Cc: Eric Dong > > --- > > UefiCpuPkg/Application/Cpuid/Cpuid.c | 83 > > ++++++++++------------------ > > 1 file changed, 28 insertions(+), 55 deletions(-) > > > > diff --git a/UefiCpuPkg/Application/Cpuid/Cpuid.c > > b/UefiCpuPkg/Application/Cpuid/Cpuid.c > > index 67cacf2714..3d242a0cbf 100644 > > --- a/UefiCpuPkg/Application/Cpuid/Cpuid.c > > +++ b/UefiCpuPkg/Application/Cpuid/Cpuid.c > > @@ -1,7 +1,7 @@ > > /** @file > > UEFI Application to display CPUID leaf information. > > > > - Copyright (c) 2016 - 2018, Intel Corporation. All rights > > reserved.
> > + Copyright (c) 2016 - 2019, Intel Corporation. All rights > > + reserved.
> > This program and the accompanying materials > > are licensed and made available under the terms and conditions of > > the BSD License > > which accompanies this distribution. The full text of the license > > may be found at @@ -717,36 +717,42 @@ > > CpuidArchitecturalPerformanceMonitoring ( **/ VOID > > CpuidExtendedTopology ( > > - VOID > > + UINT32 LeafFunction > > ) > > { > > - CPUID_EXTENDED_TOPOLOGY_EAX Eax; > > - CPUID_EXTENDED_TOPOLOGY_EBX Ebx; > > - CPUID_EXTENDED_TOPOLOGY_ECX Ecx; > > - UINT32 Edx; > > - UINT32 LevelNumber; > > + CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EAX Eax; > > + CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EBX Ebx; > > + CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX Ecx; > > + UINT32 Edx; > > + UINT32 LevelNumber; > > > > - if (CPUID_EXTENDED_TOPOLOGY > gMaximumBasicFunction) { > > + if (LeafFunction > gMaximumBasicFunction) { > > + return; > > + } > > + if ((LeafFunction !=3D CPUID_EXTENDED_TOPOLOGY) && (LeafFunction != =3D > > + CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION)) { > > return; > > } > > > > LevelNumber =3D 0; > > - do { > > + for (LevelNumber =3D 0; ; LevelNumber++) { > > AsmCpuidEx ( > > - CPUID_EXTENDED_TOPOLOGY, LevelNumber, > > + LeafFunction, LevelNumber, > > &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx > > ); > > - if (Eax.Bits.ApicIdShift !=3D 0) { > > - Print (L"CPUID_EXTENDED_TOPOLOGY (Leaf %08x, Sub-Leaf %08x)\n", > > CPUID_EXTENDED_TOPOLOGY, LevelNumber); > > - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32= , > > Ebx.Uint32, Ecx.Uint32, Edx); > > - PRINT_BIT_FIELD (Eax, ApicIdShift); > > - PRINT_BIT_FIELD (Ebx, LogicalProcessors); > > - PRINT_BIT_FIELD (Ecx, LevelNumber); > > - PRINT_BIT_FIELD (Ecx, LevelType); > > - PRINT_VALUE (Edx, x2APIC_ID); > > + if (Ecx.Bits.LevelType =3D=3D > > CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_INVALID) > { > > + break; > > } > > - LevelNumber++; > > - } while (Eax.Bits.ApicIdShift !=3D 0); > > + Print ( > > + L"%a (Leaf %08x, Sub-Leaf %08x)\n", > > + LeafFunction =3D=3D CPUID_EXTENDED_TOPOLOGY ? > > "CPUID_EXTENDED_TOPOLOGY" : > > "CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION-2", > > + LeafFunction, LevelNumber); > > + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, > > Ebx.Uint32, Ecx.Uint32, Edx); > > + PRINT_BIT_FIELD (Eax, BitsNum); > > + PRINT_BIT_FIELD (Ebx, ProcessorsNum); > > + PRINT_BIT_FIELD (Ecx, LevelNum); > > + PRINT_BIT_FIELD (Ecx, LevelType); > > + PRINT_VALUE (Edx, x2APIC_ID); >=20 > The name for above fields are different in CPUID_EXTENDED_TOPOLOGY and > CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION, > So I think above print are not correct for CPUID_EXTENDED_TOPOLOGY, right= ? >=20 Per IA32 SDM, CPUID leaf 0BH and 1FH are very similar except 1FH returns mo= re level types than that of 0BH. If you compare the accordingly output EAX/EBX, ECX, EDX, the structure defi= nitions are the same except the field names are different. I don't know why the field names are different when the new structure defin= itions were added for 1FH.