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 CF8277803D9 for ; Thu, 4 Jan 2024 14:53:31 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=l/esevlwkuVmJS2K8ibW4GUpfkHhhdNKQcJmkjuai3E=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: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=1704380010; v=1; b=A4uEiqn0ZzQYv0SFgyAa0Er32FMCO04kaVeri8DIhz3afK80Ya1hG4SGF2AKI2J3YpN1Pqhv EuQf2itcDZTGNo2mMxXtJOAm/XekUMbDQkduXVgfjfZACJVujYEWFt6Nnn5gItCPci7wSgrphTp rw2rLWI0qCX8egDxYnxOr1KI= X-Received: by 127.0.0.2 with SMTP id E1Z2YY7687511xISTzDAdCt2; Thu, 04 Jan 2024 06:53:30 -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.web11.55653.1704380009891254326 for ; Thu, 04 Jan 2024 06:53:30 -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-484-0vmehv5wPge3D1twq4rTtg-1; Thu, 04 Jan 2024 09:53:25 -0500 X-MC-Unique: 0vmehv5wPge3D1twq4rTtg-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 A272985A58C; Thu, 4 Jan 2024 14:53:24 +0000 (UTC) X-Received: from [10.39.194.24] (unknown [10.39.194.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F0B51121313; Thu, 4 Jan 2024 14:53:23 +0000 (UTC) Message-ID: <9816c694-e5b1-1753-078e-66dfdd5f15bb@redhat.com> Date: Thu, 4 Jan 2024 15:53:22 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH 1/2] UefiCpuPkg: Retrive EXTENDED_PROCESSOR_INFORMATION To: devel@edk2.groups.io, dun.tan@intel.com Cc: Ray Ni , Rahul Kumar , Gerd Hoffmann , Min Xu References: <20240104073216.1327-1-dun.tan@intel.com> <20240104073216.1327-2-dun.tan@intel.com> From: "Laszlo Ersek" In-Reply-To: <20240104073216.1327-2-dun.tan@intel.com> 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: yZ1HZJk0hP3VFA1mm2HDIZi9x7686176AA= 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=A4uEiqn0; 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 1/4/24 08:32, duntan wrote: > Retrive EXTENDED_PROCESSOR_INFORMATION in the API > MpInitLibGetProcessorInfo() of MpInitLibUp instance > when the BIT24 of input ProcessorNumber is set. > It's to align with the behavior in PEI/DXE MpInitLib >=20 > Signed-off-by: Dun Tan > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Rahul Kumar > Cc: Gerd Hoffmann > Cc: Min Xu > --- > UefiCpuPkg/Include/Library/MpInitLib.h | 2 ++ > UefiCpuPkg/Library/MpInitLib/MpLib.c | 2 ++ > UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c | 12 ++++++++++++ > 3 files changed, 16 insertions(+) >=20 > diff --git a/UefiCpuPkg/Include/Library/MpInitLib.h b/UefiCpuPkg/Include/= Library/MpInitLib.h > index 1853c46415..842c6f7ff9 100644 > --- a/UefiCpuPkg/Include/Library/MpInitLib.h > +++ b/UefiCpuPkg/Include/Library/MpInitLib.h > @@ -63,6 +63,8 @@ MpInitLibGetNumberOfProcessors ( > instant this call is made. This service may only be called from the BS= P. > =20 > @param[in] ProcessorNumber The handle number of processor. > + Lower 24 bits contains the actual pr= ocessor number. > + BIT24 indicates if the EXTENDED_PROC= ESSOR_INFORMATION will be retrived. > @param[out] ProcessorInfoBuffer A pointer to the buffer where inform= ation for > the requested processor is deposited= . > @param[out] HealthData Return processor health data. > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/Mp= InitLib/MpLib.c > index a359906923..cdfb570e61 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -2333,6 +2333,8 @@ MpInitLibInitialize ( > instant this call is made. This service may only be called from the BS= P. > =20 > @param[in] ProcessorNumber The handle number of processor. > + Lower 24 bits contains the actual pr= ocessor number. > + BIT24 indicates if the EXTENDED_PROC= ESSOR_INFORMATION will be retrived. > @param[out] ProcessorInfoBuffer A pointer to the buffer where inform= ation for > the requested processor is deposited= . > @param[out] HealthData Return processor health data. > diff --git a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c b/UefiCpuPkg/Li= brary/MpInitLibUp/MpInitLibUp.c > index 86f9fbf903..3af4911d4b 100644 > --- a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c > +++ b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c > @@ -77,6 +77,8 @@ MpInitLibGetNumberOfProcessors ( > instant this call is made. This service may only be called from the BS= P. > =20 > @param[in] ProcessorNumber The handle number of processor. > + Lower 24 bits contains the actual pr= ocessor number. > + BIT24 indicates if the EXTENDED_PROC= ESSOR_INFORMATION will be retrived. > @param[out] ProcessorInfoBuffer A pointer to the buffer where inform= ation for > the requested processor is deposited= . > @param[out] HealthData Return processor health data. > @@ -115,6 +117,16 @@ MpInitLibGetProcessorInfo ( > ProcessorInfoBuffer->Location.Package =3D 0; > ProcessorInfoBuffer->Location.Core =3D 0; > ProcessorInfoBuffer->Location.Thread =3D 0; > + > + if ((ProcessorNumber & CPU_V2_EXTENDED_TOPOLOGY) !=3D 0) { > + ProcessorInfoBuffer->ExtendedInformation.Location2.Package =3D 0; > + ProcessorInfoBuffer->ExtendedInformation.Location2.Die =3D 0; > + ProcessorInfoBuffer->ExtendedInformation.Location2.Tile =3D 0; > + ProcessorInfoBuffer->ExtendedInformation.Location2.Module =3D 0; > + ProcessorInfoBuffer->ExtendedInformation.Location2.Core =3D 0; > + ProcessorInfoBuffer->ExtendedInformation.Location2.Thread =3D 0; > + } > + > if (HealthData !=3D NULL) { > GuidHob =3D GetFirstGuidHob (&gEfiSecPlatformInformationPpiGuid); > if (GuidHob !=3D NULL) { (1) For the UP implementation of MpInitLibGetProcessorInfo(): How about, for a *complete* solution (covering both pre-patch and post-patch functionality): ZeroMem (ProcessorInfoBuffer, sizeof *ProcessorInfoBuffer); ProcessorInfoBuffer->StatusFlag =3D PROCESSOR_AS_BSP_BIT | PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT; This approach is not slow (most of the time I expect the platform will have an optimized ZeroMem() implementation), it is frugal with code (replaces a bunch of manual zeroing of fields), and it is relatively future-proof (the next time EFI_PROCESSOR_INFORMATION is extended, you likely won't have to touch up the code again, because the ZeroMem() will cover the new fields automatically). Also, this approach will zero out ProcessorInfoBuffer->ExtendedInformation *regardless* of BIT24 in the input, which I kind of consider an advantage! (No garbage in the output structure.) Again, I don't think the zeroing is wasteful, regarding CPU cycles. I do agree that the leading function comments should mention BIT24 Thanks 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 (#113179): https://edk2.groups.io/g/devel/message/113179 Mute This Topic: https://groups.io/mt/103518742/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-