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 DA4A574003B for ; Tue, 20 Feb 2024 17:49:50 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=2aWUSikW/dSEkTz2JdAgKLhkxOiy9SuQhsm+K1oCBwQ=; 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=1708451389; v=1; b=VdyMNu1romjxUVa6n7hc7nDX7IGyRGQ7KNosce0JjOXBynv5E4DKp2FXdNOPFCg7ozMkv378 O7XsYzEgHCXkPVKFyz23tqrX7Co5geB+YwNjkZFziVtJI9mjJBSEpAdxew2xovoaT5A5SbinqW8 W2SDMxJW1YJNP8mVoumGlj5I= X-Received: by 127.0.0.2 with SMTP id XvahYY7687511x4oQSvjoffN; Tue, 20 Feb 2024 09:49:49 -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.19689.1708451388327703096 for ; Tue, 20 Feb 2024 09:49:48 -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-527-cpNZruoPNUijAA0oj5MGsQ-1; Tue, 20 Feb 2024 12:49:44 -0500 X-MC-Unique: cpNZruoPNUijAA0oj5MGsQ-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 5B995185A7A3; Tue, 20 Feb 2024 17:49:44 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.175]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B87B51C14B0C; Tue, 20 Feb 2024 17:49:43 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6AC6218017FC; Tue, 20 Feb 2024 18:49:39 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , Laszlo Ersek , Rahul Kumar , Ray Ni , Gerd Hoffmann Subject: [edk2-devel] [PATCH v2 4/5] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to MpInitLibInitialize Date: Tue, 20 Feb 2024 18:49:38 +0100 Message-ID: <20240220174939.1288689-5-kraxel@redhat.com> In-Reply-To: <20240220174939.1288689-1-kraxel@redhat.com> References: <20240220174939.1288689-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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: eUIqHiAqunUOhDU6vsQEUtHGx7686176AA= 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=VdyMNu1r; 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 | 68 +++++++++++++++++++--------- 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index c13de34e5769..80585f676b1d 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -2025,6 +2025,7 @@ MpInitLibInitialize ( VOID ) { + MP_HAND_OFF *FirstMpHandOff; MP_HAND_OFF *MpHandOff; CPU_INFO_IN_HOB *CpuInfoInHob; UINT32 MaxLogicalProcessorNumber; @@ -2038,17 +2039,31 @@ MpInitLibInitialize ( CPU_MP_DATA *CpuMpData; UINT8 ApLoopMode; UINT8 *MonitorBuffer; - UINTN Index; + UINT32 Index, HobIndex; UINTN ApResetVectorSizeBelow1Mb; UINTN ApResetVectorSizeAbove1Mb; UINTN BackupBufferAddr; UINTN ApIdtBase; - MpHandOff = GetNextMpHandOffHob (NULL); - if (MpHandOff == NULL) { + FirstMpHandOff = GetNextMpHandOffHob (NULL); + if (FirstMpHandOff != NULL) { + MaxLogicalProcessorNumber = 0; + for (MpHandOff = FirstMpHandOff; + MpHandOff != NULL; + MpHandOff = GetNextMpHandOffHob (MpHandOff)) + { + DEBUG (( + DEBUG_INFO, + "%a: ProcessorIndex=%u CpuCount=%u\n", + __func__, + MpHandOff->ProcessorIndex, + MpHandOff->CpuCount + )); + ASSERT (MaxLogicalProcessorNumber == MpHandOff->ProcessorIndex); + MaxLogicalProcessorNumber += MpHandOff->CpuCount; + } + } else { MaxLogicalProcessorNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); - } else { - MaxLogicalProcessorNumber = MpHandOff->CpuCount; } ASSERT (MaxLogicalProcessorNumber != 0); @@ -2192,7 +2207,7 @@ MpInitLibInitialize ( // ProgramVirtualWireMode (); - if (MpHandOff == NULL) { + if (FirstMpHandOff == NULL) { if (MaxLogicalProcessorNumber > 1) { // // Wakeup all APs and calculate the processor count in system @@ -2208,21 +2223,32 @@ MpInitLibInitialize ( AmdSevUpdateCpuMpData (CpuMpData); } - CpuMpData->CpuCount = MpHandOff->CpuCount; - CpuMpData->BspNumber = GetBspNumber (MpHandOff); + CpuMpData->CpuCount = MaxLogicalProcessorNumber; + CpuMpData->BspNumber = GetBspNumber (FirstMpHandOff); 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 = FirstMpHandOff; + MpHandOff != NULL; + MpHandOff = GetNextMpHandOffHob (MpHandOff)) + { + 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; + } } - DEBUG ((DEBUG_INFO, "MpHandOff->WaitLoopExecutionMode: %04d, sizeof (VOID *): %04d\n", MpHandOff->WaitLoopExecutionMode, sizeof (VOID *))); - if (MpHandOff->WaitLoopExecutionMode == sizeof (VOID *)) { + DEBUG (( + DEBUG_INFO, + "FirstMpHandOff->WaitLoopExecutionMode: %04d, sizeof (VOID *): %04d\n", + FirstMpHandOff->WaitLoopExecutionMode, + sizeof (VOID *) + )); + if (FirstMpHandOff->WaitLoopExecutionMode == sizeof (VOID *)) { ASSERT (CpuMpData->ApLoopMode != ApInHltLoop); CpuMpData->FinishedCount = 0; @@ -2238,7 +2264,7 @@ MpInitLibInitialize ( // enables the APs to switch to a different memory section and continue their // looping process there. // - SwitchApContext (MpHandOff); + SwitchApContext (FirstMpHandOff); // // Wait for all APs finished initialization // @@ -2287,7 +2313,7 @@ MpInitLibInitialize ( // Wakeup APs to do some AP initialize sync (Microcode & MTRR) // if (CpuMpData->CpuCount > 1) { - if (MpHandOff != NULL) { + if (FirstMpHandOff != NULL) { // // 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 @@ -2304,7 +2330,7 @@ MpInitLibInitialize ( CpuPause (); } - if (MpHandOff != NULL) { + if (FirstMpHandOff != NULL) { CpuMpData->InitFlag = ApInitDone; } -- 2.43.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115669): https://edk2.groups.io/g/devel/message/115669 Mute This Topic: https://groups.io/mt/104472311/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-