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 5DE6294157E for ; Mon, 19 Feb 2024 11:25:43 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=OvZEwWTRQqnd34Ork0ftOxdXdQ4H1r8lqW91BwTVDaA=; 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=1708341941; v=1; b=bJCEdnlnDprCHOqDGDe3+ZokTIRU5SU2iBRscY1OBORRRqdkQAwploAnLBJ/K9bKmf+v8YaO HwUlTZwWQs2UabqFCkDNFbuBW5AJ21DDEFy0QgRDQXEs6rnLP/Luw3SzDHHUlbWSpZTdIKBQyIR YiMehp0xYvKjn1PVsUSvswPE= X-Received: by 127.0.0.2 with SMTP id HZPpYY7687511xyvCk8IZTNp; Mon, 19 Feb 2024 03:25:41 -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.39396.1708341941187002798 for ; Mon, 19 Feb 2024 03:25:41 -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-570-SwurueLENcCIxbe1PR7TNQ-1; Mon, 19 Feb 2024 06:25:36 -0500 X-MC-Unique: SwurueLENcCIxbe1PR7TNQ-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 4657F85A588; Mon, 19 Feb 2024 11:25:36 +0000 (UTC) X-Received: from [10.39.194.20] (unknown [10.39.194.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 413C4492BE2; Mon, 19 Feb 2024 11:25:35 +0000 (UTC) Message-ID: <1c39fc2a-560f-5d16-abf8-8f7616a9bdb7@redhat.com> Date: Mon, 19 Feb 2024 12:25:34 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH 3/5] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to SwitchApContext() To: devel@edk2.groups.io, kraxel@redhat.com Cc: Oliver Steffen , Ray Ni , Rahul Kumar References: <20240215093149.251319-1-kraxel@redhat.com> <20240215093149.251319-4-kraxel@redhat.com> From: "Laszlo Ersek" In-Reply-To: <20240215093149.251319-4-kraxel@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 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: CERlBzFpPjN7d2Tme1AbFMdZx7686176AA= 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=bJCEdnln; 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 2/15/24 10:31, Gerd Hoffmann wrote: > Remove the MpHandOff parameter. This is not useful in case multiple > HOBs are present in the system. The function will use GetMpHandOffHob() > to loop over all HOBs instead. >=20 > Signed-off-by: Gerd Hoffmann > --- > UefiCpuPkg/Library/MpInitLib/MpLib.h | 2 +- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 35 +++++++++++++++++----------- > 2 files changed, 23 insertions(+), 14 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/Mp= InitLib/MpLib.h > index 7e409cceaddf..a141a95b45ea 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h > @@ -482,7 +482,7 @@ GetWakeupBuffer ( > **/ > VOID > SwitchApContext ( > - IN MP_HAND_OFF *MpHandOff > + VOID > ); > =20 > /** > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/Mp= InitLib/MpLib.c > index 8e6cf50ed171..35f47d3b1289 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -1936,32 +1936,41 @@ GetBspNumber ( > begin running the procedure called SwitchContextPerAp. > This procedure allows the AP to switch to another section of > memory and continue its loop there. > - > - @param[in] MpHandOff Pointer to MP hand-off data structure. > **/ > VOID > SwitchApContext ( > - IN MP_HAND_OFF *MpHandOff > + VOID > ) > { > - UINTN Index; > - UINT32 BspNumber; > + UINTN Index; > + UINT32 BspNumber; > + MP_HAND_OFF *MpHandOff; > =20 > BspNumber =3D GetBspNumber (); > =20 > - for (Index =3D 0; Index < MpHandOff->CpuCount; Index++) { > - if (Index !=3D BspNumber) { > - *(UINTN *)(UINTN)MpHandOff->Info[Index].StartupProcedureAddress = =3D (UINTN)SwitchContextPerAp; > - *(UINT32 *)(UINTN)MpHandOff->Info[Index].StartupSignalAddress = =3D MpHandOff->StartupSignalValue; > + for (MpHandOff =3D GetMpHandOffHob (0); > + MpHandOff !=3D NULL; > + MpHandOff =3D GetMpHandOffHob (MpHandOff->ProcessorIndex + MpHand= Off->CpuCount)) > + { > + for (Index =3D 0; Index < MpHandOff->CpuCount; Index++) { > + if (MpHandOff->ProcessorIndex + Index !=3D BspNumber) { > + *(UINTN *)(UINTN)MpHandOff->Info[Index].StartupProcedureAddress = =3D (UINTN)SwitchContextPerAp; > + *(UINT32 *)(UINTN)MpHandOff->Info[Index].StartupSignalAddress = =3D MpHandOff->StartupSignalValue; > + } > } > } > =20 > // > // Wait all APs waken up if this is not the 1st broadcast of SIPI > // > - for (Index =3D 0; Index < MpHandOff->CpuCount; Index++) { > - if (Index !=3D BspNumber) { > - WaitApWakeup ((UINT32 *)(UINTN)(MpHandOff->Info[Index].StartupSign= alAddress)); > + for (MpHandOff =3D GetMpHandOffHob (0); > + MpHandOff !=3D NULL; > + MpHandOff =3D GetMpHandOffHob (MpHandOff->ProcessorIndex + MpHand= Off->CpuCount)) > + { > + for (Index =3D 0; Index < MpHandOff->CpuCount; Index++) { > + if (MpHandOff->ProcessorIndex + Index !=3D BspNumber) { > + WaitApWakeup ((UINT32 *)(UINTN)(MpHandOff->Info[Index].StartupSi= gnalAddress)); > + } > } > } > } > @@ -2226,7 +2235,7 @@ MpInitLibInitialize ( > // enables the APs to switch to a different memory section and con= tinue their > // looping process there. > // > - SwitchApContext (MpHandOff); > + SwitchApContext (); > // > // Wait for all APs finished initialization > // Same comment as under the previous patch. We could just iterate with MpHandOff over the GUID HOB list in the outer loops, and perform the proper actions upon MpHandOff->ProcessorIndex + Index !=3D BspNumber in the inner loop. It is not necessary for us to ask for the HOBs in any particular sequence, so we shouldn't pay the O(n) lookup price for every HOB in turn. 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 (#115592): https://edk2.groups.io/g/devel/message/115592 Mute This Topic: https://groups.io/mt/104369847/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-