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 3AA3D740038 for ; Thu, 15 Feb 2024 09:31:59 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=G6MXf0zpOW7k1ofVtvgq0TqZHa5acAR+VGgeQf2tKWQ=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1707989517; v=1; b=qLhhn/aYu/ZL16OL9U5MmQP7Qjt4+VcOo4k3VLDJC94rpnLoQJOxQ4IgNBYBW+r16pFyHRjG Do5p+JqDQPoOJTwqQCVoZPl6EFSd95MEAHu+sE+uw77L1739CT0Cco4Rl3g9Zy0mhLpq1uZiJU5 ciDkXdC3DF/kH7XpuMotQDsg= X-Received: by 127.0.0.2 with SMTP id tAkyYY7687511x3n0ptH6S8x; Thu, 15 Feb 2024 01:31:57 -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.web10.10347.1707989516610818944 for ; Thu, 15 Feb 2024 01:31:56 -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-193-65v4uT6NOAemXEO-vD2tJQ-1; Thu, 15 Feb 2024 04:31:53 -0500 X-MC-Unique: 65v4uT6NOAemXEO-vD2tJQ-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 A5B05280FEC1; Thu, 15 Feb 2024 09:31:53 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AD2F2166B32; Thu, 15 Feb 2024 09:31:53 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3D9351800DFB; Thu, 15 Feb 2024 10:31:49 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , Ray Ni , Laszlo Ersek , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [PATCH 4/5] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to MpInitLibInitialize Date: Thu, 15 Feb 2024 10:31:48 +0100 Message-ID: <20240215093149.251319-5-kraxel@redhat.com> In-Reply-To: <20240215093149.251319-1-kraxel@redhat.com> References: <20240215093149.251319-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 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,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 1v5QcBQIdE7Lpo1q9KQYBoL6x7686176AA= Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="qLhhn/aY"; 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 Loop over all MP_HAND_OFF HOBs instead of expecting a single HOB covering all CPUs in the system. Add a new HaveMpHandOff variable to track whenever MP_HAND_OFF HOBs are present, using the MpHandOff pointer for that does not work because the variable will be NULL after looping over all HOBs. Signed-off-by: Gerd Hoffmann --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 54 +++++++++++++++++++--------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index 35f47d3b1289..1547b7e74a1a 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -2023,6 +2023,7 @@ MpInitLibInitialize ( ) { MP_HAND_OFF *MpHandOff; + BOOLEAN HaveMpHandOff; CPU_INFO_IN_HOB *CpuInfoInHob; UINT32 MaxLogicalProcessorNumber; UINT32 ApStackSize; @@ -2035,17 +2036,29 @@ MpInitLibInitialize ( CPU_MP_DATA *CpuMpData; UINT8 ApLoopMode; UINT8 *MonitorBuffer; - UINTN Index; + UINTN Index, HobIndex; UINTN ApResetVectorSizeBelow1Mb; UINTN ApResetVectorSizeAbove1Mb; UINTN BackupBufferAddr; UINTN ApIdtBase; - MpHandOff = GetMpHandOffHob (0); - if (MpHandOff == NULL) { + MaxLogicalProcessorNumber = 0; + HaveMpHandOff = FALSE; + + while ((MpHandOff = GetMpHandOffHob (MaxLogicalProcessorNumber)) != 0) { + DEBUG (( + DEBUG_INFO, + "%a: ProcessorIndex=%u CpuCount=%u\n", + __func__, + MpHandOff->ProcessorIndex, + MpHandOff->CpuCount + )); + MaxLogicalProcessorNumber += MpHandOff->CpuCount; + HaveMpHandOff = TRUE; + } + + if (!HaveMpHandOff) { MaxLogicalProcessorNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); - } else { - MaxLogicalProcessorNumber = MpHandOff->CpuCount; } ASSERT (MaxLogicalProcessorNumber != 0); @@ -2189,7 +2202,7 @@ MpInitLibInitialize ( // ProgramVirtualWireMode (); - if (MpHandOff == NULL) { + if (!HaveMpHandOff) { if (MaxLogicalProcessorNumber > 1) { // // Wakeup all APs and calculate the processor count in system @@ -2205,19 +2218,26 @@ MpInitLibInitialize ( AmdSevUpdateCpuMpData (CpuMpData); } - CpuMpData->CpuCount = MpHandOff->CpuCount; + CpuMpData->CpuCount = MaxLogicalProcessorNumber; CpuMpData->BspNumber = GetBspNumber (); CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob; - for (Index = 0; Index < CpuMpData->CpuCount; Index++) { - InitializeSpinLock (&CpuMpData->CpuData[Index].ApLock); - CpuMpData->CpuData[Index].CpuHealthy = (MpHandOff->Info[Index].Health == 0) ? TRUE : FALSE; - CpuMpData->CpuData[Index].ApFunction = 0; - CpuInfoInHob[Index].InitialApicId = MpHandOff->Info[Index].ApicId; - CpuInfoInHob[Index].ApTopOfStack = CpuMpData->Buffer + (Index + 1) * CpuMpData->CpuApStackSize; - CpuInfoInHob[Index].ApicId = MpHandOff->Info[Index].ApicId; - CpuInfoInHob[Index].Health = MpHandOff->Info[Index].Health; + for (MpHandOff = GetMpHandOffHob (0); + MpHandOff != NULL; + MpHandOff = GetMpHandOffHob (MpHandOff->ProcessorIndex + MpHandOff->CpuCount)) + { + for (HobIndex = 0; HobIndex < MpHandOff->CpuCount; HobIndex++) { + Index = MpHandOff->ProcessorIndex + HobIndex; + InitializeSpinLock (&CpuMpData->CpuData[Index].ApLock); + CpuMpData->CpuData[Index].CpuHealthy = (MpHandOff->Info[HobIndex].Health == 0) ? TRUE : FALSE; + CpuMpData->CpuData[Index].ApFunction = 0; + CpuInfoInHob[Index].InitialApicId = MpHandOff->Info[HobIndex].ApicId; + CpuInfoInHob[Index].ApTopOfStack = CpuMpData->Buffer + (Index + 1) * CpuMpData->CpuApStackSize; + CpuInfoInHob[Index].ApicId = MpHandOff->Info[HobIndex].ApicId; + CpuInfoInHob[Index].Health = MpHandOff->Info[HobIndex].Health; + } } + MpHandOff = GetMpHandOffHob (0); DEBUG ((DEBUG_INFO, "MpHandOff->WaitLoopExecutionMode: %04d, sizeof (VOID *): %04d\n", MpHandOff->WaitLoopExecutionMode, sizeof (VOID *))); if (MpHandOff->WaitLoopExecutionMode == sizeof (VOID *)) { ASSERT (CpuMpData->ApLoopMode != ApInHltLoop); @@ -2284,7 +2304,7 @@ MpInitLibInitialize ( // Wakeup APs to do some AP initialize sync (Microcode & MTRR) // if (CpuMpData->CpuCount > 1) { - if (MpHandOff != NULL) { + if (HaveMpHandOff) { // // Only needs to use this flag for DXE phase to update the wake up // buffer. Wakeup buffer allocated in PEI phase is no longer valid @@ -2301,7 +2321,7 @@ MpInitLibInitialize ( CpuPause (); } - if (MpHandOff != NULL) { + if (HaveMpHandOff) { CpuMpData->InitFlag = ApInitDone; } -- 2.43.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115498): https://edk2.groups.io/g/devel/message/115498 Mute This Topic: https://groups.io/mt/104369843/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-