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 9D390941888 for ; Tue, 7 Nov 2023 18:44:17 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=kxQ1Wg53T7Fhgf1B+jBeMkOuuygjOoRozu3SBKUQsRE=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699382656; v=1; b=pFV44nzGiF8M3KOm6vaiJihW0CjEdeoSNHnXMOPZKiLcWgVfNrXxVRlKpXUG0PEBmwkFnosD hA5PJCrUrTkltpNNc3hk3RttYKPK6mHq5G1mA7NIqOREWqlKHXUU1T5MNAmY2KcgpRCqk1HB7rS XKnVzXU9ydulV+6IzD4Nws20= X-Received: by 127.0.0.2 with SMTP id V9IXYY7687511xapZ7eyurhW; Tue, 07 Nov 2023 10:44:16 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.2757.1699382655669623060 for ; Tue, 07 Nov 2023 10:44:15 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-396-YrkD4dv8MmKxHthcsP12WQ-1; Tue, 07 Nov 2023 13:44:10 -0500 X-MC-Unique: YrkD4dv8MmKxHthcsP12WQ-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1CB48833B43; Tue, 7 Nov 2023 18:44:10 +0000 (UTC) X-Received: from [10.39.193.64] (unknown [10.39.193.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB60A1121306; Tue, 7 Nov 2023 18:44:08 +0000 (UTC) Message-ID: Date: Tue, 7 Nov 2023 19:44:07 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v1] UefiCpuPkg/PiSmmCpuDxeSmm: Use processor extended information From: "Laszlo Ersek" To: devel@edk2.groups.io, jiaxin.wu@intel.com Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Star Zeng References: <20231107024311.14424-1-jiaxin.wu@intel.com> In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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 Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: QfznsLn8pctRgr11IepVBaKEx7686176AA= 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=pFV44nzG; 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 On 11/7/23 19:40, Laszlo Ersek wrote: > On 11/7/23 03:43, Wu, Jiaxin wrote: >> Processor extended information is filled when >> CPU_V2_EXTENDED_TOPOLOGY is set in parameter ProcessorNumber >> from GetProcessorInfo() (See commit: 1fadd18d). >> >> This filed value is retrieved from CPUID leaf 1FH, which is >> a preferred superset to leaf 0BH. >> >> Since Intel recommends first use the CPUID leaf 1FH instead of >> leaf 0BH, this patch change to use the processor extended >> information, which can reflect the value from CPUID leaf 1FH. >> >> Cc: Eric Dong >> Cc: Ray Ni >> Cc: Rahul Kumar >> Cc: Gerd Hoffmann >> Cc: Star Zeng >> Signed-off-by: Jiaxin Wu >> --- >> UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 10 ++++++++++ >> UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 6 +++--- >> 2 files changed, 13 insertions(+), 3 deletions(-) >> >> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c b/UefiCpuPkg/PiSmmCp= uDxeSmm/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.Locat= ion2.Package, >> + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Locat= ion2.Die, >> + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Locat= ion2.Tile, >> + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Locat= ion2.Module, >> + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Locat= ion2.Core, >> + &gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInformation.Locat= ion2.Thread >> + ); >> + >> *ProcessorNumber =3D Index; >> gSmmCpuPrivate->Operation[Index] =3D SmmCpuAdd; >> return EFI_SUCCESS; >> } >> } >> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpu= DxeSmm/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.Pa= ckage; >> + PackageIndex =3D gSmmCpuPrivate->ProcessorInfo[CpuIndex].ExtendedInf= ormation.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.Packa= ge) { >> - PackageId =3D gSmmCpuPrivate->ProcessorInfo[Index].Location.Packa= ge; >> + if (PackageId < gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInform= ation.Location2.Package) { >> + PackageId =3D gSmmCpuPrivate->ProcessorInfo[Index].ExtendedInform= ation.Location2.Package; >> } >> } >> =20 >> PackageCount =3D PackageId + 1; >> =20 >=20 > The patch looks OK to me, but: >=20 > - I would like to test it with CPU hotplug (later, likely under v2), and >=20 > - I think this should be two patches. >=20 > First, the SmmAddProcessor() function should be extended just to > complete commit 1fadd18d. (BTW I highly appreciate the reference to > commit 1fadd18d; otherwise I couldn't find where the *coldplugged* CPUs' > locations were retrieved!) >=20 > Then the Package calculations should be updated separately -- mostly > because I would appreciate a concrete description in that separate > commit message why the difference matters. Clearly you have a use case > where the v1 and v2 package numbers differ, and recording that in the > commit history would be great. Side note, just for completeness: the x2apic lib instance performs the v2 feature detection correctly since Gerd's commit 170d4ce8e90a ("UefiCpuPkg/BaseXApicX2ApicLib: fix CPUID_V2_EXTENDED_TOPOLOGY detection", 2023-10-25). Furthermore, OVMF uses the x2apic lib instance since commit decb365b0016 ("OvmfPkg: select LocalApicLib instance with x2apic support", 2015-11-30). Therefore, this patch looks fine for OVMF. However, for platforms that use the old xapic lib instance, there could be problems, as the v2 feature detection in *that* instance is not fixed -- it does not check EBX. Laszlo -=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 (#110873): https://edk2.groups.io/g/devel/message/110873 Mute This Topic: https://groups.io/mt/102436095/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-