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 E55A17803E7 for ; Tue, 24 Oct 2023 12:30:44 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=q79H5zWl6DRr1Za/YhH2uj6vBnTcZsg5DrwEV4TyL9c=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:Reply-To:References:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1698150643; v=1; b=vebXqPEuWGmpnWhircAeNsBTP3Ic7GeELFLtHiL5pi6+cOrXUM/pZzq4Fvnc0eUO0zKNZXG1 maBa6m724c6fFk+rTL1ghskwDBN9fXM0JMhwic9v1jYSyJ+o9Thx4ME0vxevRlz/zlrnQsUYQUG IAUK7hm8nIFgx3eTuC9KTlF0= X-Received: by 127.0.0.2 with SMTP id HBnMYY7687511xISz1g0W59l; Tue, 24 Oct 2023 05:30:43 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.16739.1698150642942938416 for ; Tue, 24 Oct 2023 05:30:43 -0700 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-321-P-zZ08ZPNJysMCX0WT6Rcw-1; Tue, 24 Oct 2023 08:30:37 -0400 X-MC-Unique: P-zZ08ZPNJysMCX0WT6Rcw-1 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F2CF3C1CC2A; Tue, 24 Oct 2023 12:30:37 +0000 (UTC) X-Received: from [10.39.195.39] (unknown [10.39.195.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E4DC25C0; Tue, 24 Oct 2023 12:30:35 +0000 (UTC) Message-ID: Date: Tue, 24 Oct 2023 14:30:34 +0200 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2 1/1] UefiCpuPkg/BaseXApicX2ApicLib: fix CPUID_V2_EXTENDED_TOPOLOGY detection From: "Laszlo Ersek" To: Gerd Hoffmann , devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Oliver Steffen , Rahul Kumar Reply-To: devel@edk2.groups.io,lersek@redhat.com References: <20231017112807.1244254-1-kraxel@redhat.com> <40508466-1387-51f7-d421-a25b778011b3@redhat.com> In-Reply-To: <40508466-1387-51f7-d421-a25b778011b3@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.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 List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: zk3bAAHWWF56d1c6AOQrt5Spx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=vebXqPEu; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.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 Eric, Ray, Rahul -- can you ACK this patch please? I intend to merge it in one or two days. Thanks Laszlo On 10/17/23 13:42, Laszlo Ersek wrote: > On 10/17/23 13:28, Gerd Hoffmann wrote: >> 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. >> >> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=3D2241388 >> Signed-off-by: Gerd Hoffmann >> --- >> .../BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 21 ++++++++++++++----- >> 1 file changed, 16 insertions(+), 5 deletions(-) >> >> diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c = b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c >> index aa4eb11181f6..c0a847583330 100644 >> --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c >> +++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c >> @@ -1294,11 +1294,12 @@ GetProcessorLocationByApicId ( >> NULL >> ); >> // >> - // If CPUID.(EAX=3D0BH, ECX=3D0H):EBX returns zero and maximum inpu= t value 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 >> // >> @@ -1424,6 +1425,7 @@ GetProcessorLocation2ByApicId ( >> ) >> { >> CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; >> + CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; >> CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; >> UINT32 MaxStandardCpuIdIndex; >> UINT32 Index; >> @@ -1436,10 +1438,19 @@ GetProcessorLocation2ByApicId ( >> } >> =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, &ExtendedTopologyE= bx.Uint32, NULL, NULL); >> + } >> + >> + if (ExtendedTopologyEbx.Bits.LogicalProcessors =3D=3D 0) { >> if (Die !=3D NULL) { >> *Die =3D 0; >> } >=20 > Reviewed-by: Laszlo Ersek >=20 > Thanks! > Laszlo >=20 >=20 >=20 >=20 >=20 >=20 -=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 (#110000): https://edk2.groups.io/g/devel/message/110000 Mute This Topic: https://groups.io/mt/102015439/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-