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 7484E78003C for ; Wed, 28 Feb 2024 11:49:04 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=LnYXJavoeONwo8UGmDAnlQlm8OUFNt6xYaxYXzNXTsU=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID: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=1709120943; v=1; b=Yy6BpW+N3hOFg7GsKUn4mD4VaW5+Cz/ijssnYktv60SOhCftaAFosVaXJHdy3OK/3nU0FTmP ADerOfCLPk+NFCSrLM+2emRiCcngsIFtgXch2YNGLtutoohAlIJsKRuOwDG48Amj9zsn2KN+mDp URcEut0BiQ6ufq6sxw38lDc4= X-Received: by 127.0.0.2 with SMTP id KH69YY7687511xvfiyLONDvI; Wed, 28 Feb 2024 03:49:03 -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.11198.1709120942398907184 for ; Wed, 28 Feb 2024 03:49:02 -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-67-95agyYckMYeW4B4CrJp2Hw-1; Wed, 28 Feb 2024 06:48:57 -0500 X-MC-Unique: 95agyYckMYeW4B4CrJp2Hw-1 X-Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 EA9748432B1; Wed, 28 Feb 2024 11:48:56 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.249]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7080040C94AB; Wed, 28 Feb 2024 11:48:56 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 5E9451801480; Wed, 28 Feb 2024 12:48:55 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Rahul Kumar , Ray Ni , Laszlo Ersek , Oliver Steffen , Gerd Hoffmann Subject: [edk2-devel] [PATCH v2 1/1] UefiCpuPkg/MpInitLib: add struct MP_HAND_OFF_CONFIG Date: Wed, 28 Feb 2024 12:48:55 +0100 Message-ID: <20240228114855.1615788-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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: G352P1pETH6ooxgXZjUJs7tox7686176AA= 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=Yy6BpW+N; 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 Move the WaitLoopExecutionMode and StartupSignalValue fields to a separate HOB with the new struct. WaitLoopExecutionMode and StartupSignalValue are independent of processor index ranges; they are global to MpInitLib (i.e., the entire system). Therefore they shouldn't be repeated in every MpHandOff GUID HOB. Signed-off-by: Gerd Hoffmann --- UefiCpuPkg/Library/MpInitLib/MpHandOff.h | 13 ++++++- UefiCpuPkg/Library/MpInitLib/MpLib.h | 3 +- UefiCpuPkg/Library/MpInitLib/MpLib.c | 47 +++++++++++++++++++++--- UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 34 ++++++++++------- 4 files changed, 75 insertions(+), 22 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpHandOff.h b/UefiCpuPkg/Library/MpInitLib/MpHandOff.h index 77854d6a81f8..ae93b7e3d7c9 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpHandOff.h +++ b/UefiCpuPkg/Library/MpInitLib/MpHandOff.h @@ -15,7 +15,13 @@ 0x11e2bd88, 0xed38, 0x4abd, {0xa3, 0x99, 0x21, 0xf2, 0x5f, 0xd0, 0x7a, 0x60 } \ } +#define MP_HANDOFF_CONFIG_GUID \ + { \ + 0xdabbd793, 0x7b46, 0x4144, {0x8a, 0xd4, 0x10, 0x1c, 0x7c, 0x08, 0xeb, 0xfa } \ + } + extern EFI_GUID mMpHandOffGuid; +extern EFI_GUID mMpHandOffConfigGuid; // // The information required to transfer from the PEI phase to the @@ -43,8 +49,11 @@ typedef struct { // UINT32 ProcessorIndex; UINT32 CpuCount; - UINT32 WaitLoopExecutionMode; - UINT32 StartupSignalValue; PROCESSOR_HAND_OFF Info[]; } MP_HAND_OFF; + +typedef struct { + UINT32 WaitLoopExecutionMode; + UINT32 StartupSignalValue; +} MP_HAND_OFF_CONFIG; #endif diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h index 3a7b9896cff4..d26035559f22 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -482,7 +482,8 @@ GetWakeupBuffer ( **/ VOID SwitchApContext ( - IN CONST MP_HAND_OFF *FirstMpHandOff + IN CONST MP_HAND_OFF_CONFIG *MpHandOffConfig, + IN CONST MP_HAND_OFF *FirstMpHandOff ); /** diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index 8c186211fb38..9bac62f289e0 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -15,6 +15,7 @@ EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID; EFI_GUID mMpHandOffGuid = MP_HANDOFF_GUID; +EFI_GUID mMpHandOffConfigGuid = MP_HANDOFF_CONFIG_GUID; /** Save the volatile registers required to be restored following INIT IPI. @@ -1935,11 +1936,13 @@ GetBspNumber ( This procedure allows the AP to switch to another section of memory and continue its loop there. - @param[in] FirstMpHandOff Pointer to first MP hand-off HOB body. + @param[in] MpHandOffConfig Pointer to MP hand-off config HOB body. + @param[in] FirstMpHandOff Pointer to first MP hand-off HOB body. **/ VOID SwitchApContext ( - IN CONST MP_HAND_OFF *FirstMpHandOff + IN CONST MP_HAND_OFF_CONFIG *MpHandOffConfig, + IN CONST MP_HAND_OFF *FirstMpHandOff ) { UINTN Index; @@ -1955,7 +1958,7 @@ SwitchApContext ( for (Index = 0; Index < MpHandOff->CpuCount; Index++) { if (MpHandOff->ProcessorIndex + Index != BspNumber) { *(UINTN *)(UINTN)MpHandOff->Info[Index].StartupProcedureAddress = (UINTN)SwitchContextPerAp; - *(UINT32 *)(UINTN)MpHandOff->Info[Index].StartupSignalAddress = MpHandOff->StartupSignalValue; + *(UINT32 *)(UINTN)MpHandOff->Info[Index].StartupSignalAddress = MpHandOffConfig->StartupSignalValue; } } } @@ -1975,6 +1978,26 @@ SwitchApContext ( } } +/** + Get pointer to MP_HAND_OFF_CONFIG GUIDed HOB body. + + @return The pointer to MP_HAND_OFF_CONFIG structure. +**/ +MP_HAND_OFF_CONFIG * +GetMpHandOffConfigHob ( + VOID + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + + GuidHob = GetFirstGuidHob (&mMpHandOffConfigGuid); + if (GuidHob == NULL) { + return NULL; + } + + return (MP_HAND_OFF_CONFIG *)GET_GUID_HOB_DATA (GuidHob); +} + /** Get pointer to next MP_HAND_OFF GUIDed HOB body. @@ -2022,6 +2045,7 @@ MpInitLibInitialize ( VOID ) { + MP_HAND_OFF_CONFIG *MpHandOffConfig; MP_HAND_OFF *FirstMpHandOff; MP_HAND_OFF *MpHandOff; CPU_INFO_IN_HOB *CpuInfoInHob; @@ -2239,13 +2263,24 @@ MpInitLibInitialize ( } } + MpHandOffConfig = GetMpHandOffConfigHob (); + if (MpHandOffConfig == NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: at least one MpHandOff HOB, but no MpHandOffConfig HOB\n", + __func__ + )); + ASSERT (MpHandOffConfig != NULL); + CpuDeadLoop (); + } + DEBUG (( DEBUG_INFO, "FirstMpHandOff->WaitLoopExecutionMode: %04d, sizeof (VOID *): %04d\n", - FirstMpHandOff->WaitLoopExecutionMode, + MpHandOffConfig->WaitLoopExecutionMode, sizeof (VOID *) )); - if (FirstMpHandOff->WaitLoopExecutionMode == sizeof (VOID *)) { + if (MpHandOffConfig->WaitLoopExecutionMode == sizeof (VOID *)) { ASSERT (CpuMpData->ApLoopMode != ApInHltLoop); CpuMpData->FinishedCount = 0; @@ -2261,7 +2296,7 @@ MpInitLibInitialize ( // enables the APs to switch to a different memory section and continue their // looping process there. // - SwitchApContext (FirstMpHandOff); + SwitchApContext (MpHandOffConfig, FirstMpHandOff); // // Wait for all APs finished initialization // diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c index ec1aa666923d..4d3acb491f36 100644 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c @@ -126,14 +126,15 @@ SaveCpuMpData ( IN CPU_MP_DATA *CpuMpData ) { - UINT32 MaxCpusPerHob; - UINT32 CpusInHob; - UINT64 Data64; - UINT32 Index; - UINT32 HobBase; - CPU_INFO_IN_HOB *CpuInfoInHob; - MP_HAND_OFF *MpHandOff; - UINTN MpHandOffSize; + UINT32 MaxCpusPerHob; + UINT32 CpusInHob; + UINT64 Data64; + UINT32 Index; + UINT32 HobBase; + CPU_INFO_IN_HOB *CpuInfoInHob; + MP_HAND_OFF *MpHandOff; + MP_HAND_OFF_CONFIG MpHandOffConfig; + UINTN MpHandOffSize; MaxCpusPerHob = (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE) - sizeof (MP_HAND_OFF)) / sizeof (PROCESSOR_HAND_OFF); @@ -155,11 +156,6 @@ SaveCpuMpData ( MpHandOff->ProcessorIndex = HobBase; MpHandOff->CpuCount = CpusInHob; - - if (CpuMpData->ApLoopMode != ApInHltLoop) { - MpHandOff->StartupSignalValue = MP_HAND_OFF_SIGNAL; - MpHandOff->WaitLoopExecutionMode = sizeof (VOID *); - } } MpHandOff->Info[Index-HobBase].ApicId = CpuInfoInHob[Index].ApicId; @@ -170,6 +166,18 @@ SaveCpuMpData ( } } + ZeroMem (&MpHandOffConfig, sizeof (MpHandOffConfig)); + if (CpuMpData->ApLoopMode != ApInHltLoop) { + MpHandOffConfig.StartupSignalValue = MP_HAND_OFF_SIGNAL; + MpHandOffConfig.WaitLoopExecutionMode = sizeof (VOID *); + } + + BuildGuidDataHob ( + &mMpHandOffConfigGuid, + (VOID *)&MpHandOffConfig, + sizeof (MpHandOffConfig) + ); + // // Build location of CPU MP DATA buffer in HOB // -- 2.44.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116115): https://edk2.groups.io/g/devel/message/116115 Mute This Topic: https://groups.io/mt/104621270/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-