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 2D953D801DE for ; Thu, 22 Feb 2024 00:37:28 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=v4kNG3QhQGcRLzLk1SWeseCcaEy9lVhhEuYdTnL9FDE=; 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=1708562247; v=1; b=lkTs9Yt6w4/BOa/lSPFhE3j88RrsULy6dw+5jbSXhyI7OVAcyFdwTrIgiPBC/8U+LZOGoA+F /ron2EMomiBBXXwXb6iy2xVD/qi6qIeLGOLZ55DVKW4KIU5DmxDWaX8hmqr7BJtjiYQR2swxZK1 tAFbcRZ2MXhs1yKHS0l7Skzo= X-Received: by 127.0.0.2 with SMTP id i78xYY7687511xbiaB4mb6VR; Wed, 21 Feb 2024 16:37:27 -0800 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.2493.1708562247098316320 for ; Wed, 21 Feb 2024 16:37:27 -0800 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-mf06_CKOOUmptjlIOT8OZg-1; Wed, 21 Feb 2024 19:37:23 -0500 X-MC-Unique: mf06_CKOOUmptjlIOT8OZg-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 425973C02786; Thu, 22 Feb 2024 00:37:21 +0000 (UTC) X-Received: from [10.39.192.46] (unknown [10.39.192.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3D1F492BC8; Thu, 22 Feb 2024 00:37:19 +0000 (UTC) Message-ID: Date: Thu, 22 Feb 2024 01:37:18 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2 2/5] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to GetBspNumber() To: devel@edk2.groups.io, kraxel@redhat.com Cc: Oliver Steffen , Rahul Kumar , Ray Ni References: <20240220174939.1288689-1-kraxel@redhat.com> <20240220174939.1288689-3-kraxel@redhat.com> From: "Laszlo Ersek" In-Reply-To: <20240220174939.1288689-3-kraxel@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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: onjhbL5mqiYs2paJq7pmklJex7686176AA= 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=lkTs9Yt6; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none) On 2/20/24 18:49, Gerd Hoffmann wrote: > Rename the MpHandOff parameter to FirstMpHandOff. Add a loop so the > function inspects all HOBs present in the system. >=20 > Signed-off-by: Gerd Hoffmann > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 23 +++++++++++++++-------- > 1 file changed, 15 insertions(+), 8 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/Mp= InitLib/MpLib.c > index e764bc9e4228..8f198ff6d817 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -1894,26 +1894,33 @@ CheckAllAPs ( > /** > This function Get BspNumber. > =20 > - @param[in] MpHandOff Pointer to MpHandOff > + @param[in] FirstMpHandOff Pointer to first MpHandOff HOB. > @return BspNumber > **/ > UINT32 > GetBspNumber ( > - IN CONST MP_HAND_OFF *MpHandOff > + IN CONST MP_HAND_OFF *FirstMpHandOff > ) > { > - UINT32 ApicId; > - UINT32 BspNumber; > - UINT32 Index; > + UINT32 ApicId; > + UINT32 BspNumber; > + UINT32 Index; > + CONST MP_HAND_OFF *MpHandOff; > =20 > // > // Get the processor number for the BSP > // > BspNumber =3D MAX_UINT32; > ApicId =3D GetInitialApicId (); > - for (Index =3D 0; Index < MpHandOff->CpuCount; Index++) { > - if (MpHandOff->Info[Index].ApicId =3D=3D ApicId) { > - BspNumber =3D Index; > + > + for (MpHandOff =3D FirstMpHandOff; > + MpHandOff !=3D NULL; > + MpHandOff =3D GetNextMpHandOffHob (MpHandOff)) > + { > + for (Index =3D 0; Index < MpHandOff->CpuCount; Index++) { > + if (MpHandOff->Info[Index].ApicId =3D=3D ApicId) { > + BspNumber =3D MpHandOff->ProcessorIndex + Index; > + } > } > } > =20 It's strange that the pre-patch code keeps looking even after finding the BSP by APIC-ID; now it's stranger yet, because we even go to further HOBs. In theory, the inner loop body could grow a "break", and the outer loop condition could be restricted with && (BspNumber =3D=3D MAX_UINT32) but that would be a separate patch. Reviewed-by: Laszlo Ersek -=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 (#115762): https://edk2.groups.io/g/devel/message/115762 Mute This Topic: https://groups.io/mt/104472310/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-