From nobody Mon Feb 9 10:28:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+112222+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112222+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1702029315; cv=none; d=zohomail.com; s=zohoarc; b=Lli3n4E8QoRaxAxKm3TDtg1K6Y4uwKqHS6ekJGJqneKh3jdtbrEA8SzpffDbr9nrsm5GzBUkD911e6jGS/2fQEhpmJDdRQ7MeHjPBUg7U8YSvLug6w3DY3wBdQhbasORD4s6rCGTF47IhJ2kKUr2KRG8y999wJXKFQy7Mb19ACQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702029315; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=4aNA+tEp4iSiHRZgNt78RUDwZ+WVGqB9d/FdA0jcdo4=; b=Z06TS9bsPzWHtHsgfDorKYFptGvV21lc251cCiUNyk5wq1dXgRfKVZ9ME1eZrb+Tug5x95DrwYwa2qwGd/47esSMllZzGOT0/LpdvA0JegPyNsDTPssgpVKAtArqEDtvzzc5jtXOieUVLWwZq/sm9+/j57w/TwJh9cBRPrUFkvQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112222+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1702029315395496.559807458008; Fri, 8 Dec 2023 01:55:15 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=o8fmuJz8ldlosjtBFp7MxH8sSGqYhIxI7cbrnOtE5ms=; 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; s=20140610; t=1702029315; v=1; b=tSRhdqj2DDTzKU+yU4jWBdp8UodwJIrl7roSlHKzWE90BzvK7lchkbwCT+6mTMz3ZQLJiVGb QA4TYeIXRvEtyVVPYh74GkTPWGZWwZNRUD6pry8o1eDx4WPvGL+sY2UmNWnfEpyUWPVt+G8BUTM bn6ooQkBqy7BaW05xUNo6K+Y= X-Received: by 127.0.0.2 with SMTP id zS3oYY1788612x6U0hGj2kbx; Fri, 08 Dec 2023 01:55:15 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.16817.1702029313223455448 for ; Fri, 08 Dec 2023 01:55:14 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="397176399" X-IronPort-AV: E=Sophos;i="6.04,260,1695711600"; d="scan'208";a="397176399" X-Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2023 01:55:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,260,1695711600"; d="scan'208";a="20028198" X-Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.43]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2023 01:55:12 -0800 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [Patch V3 2/6] UefiCpuPkg: Build MpInfo2HOB in CpuMpPei Date: Fri, 8 Dec 2023 17:54:41 +0800 Message-Id: <20231208095443.1328-2-dun.tan@intel.com> In-Reply-To: <20231208095443.1328-1-dun.tan@intel.com> References: <20231208095443.1328-1-dun.tan@intel.com> MIME-Version: 1.0 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,dun.tan@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: TeOHJcrD7ew7sMGUjeF3voD1x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1702029316447100006 Content-Type: text/plain; charset="utf-8" Build MpInfo2HOB in CpuMpPei module so that later PiSmmCpuDxe or other StandaloneMm module can consume the HOB. Since there might be more one gMpInformationHobGuid2 in HOB list, CpuMpPei create a gMpInformationHobGuid2 with 0 value NumberOfProcessors field in the end of the process to indicate it's the last MP_INFORMATION2_HOB. Signed-off-by: Dun Tan Cc: Eric Dong Reviewed-by: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann --- UefiCpuPkg/CpuMpPei/CpuMpPei.c | 91 ++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++ UefiCpuPkg/CpuMpPei/CpuMpPei.h | 4 +++- UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 3 ++- 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index b504bea3cf..e96a76c9a5 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -541,6 +541,92 @@ InitializeMpExceptionStackSwitchHandlers ( FreePages (SwitchStackData, EFI_SIZE_TO_PAGES (NumberOfProcessors * size= of (EXCEPTION_STACK_SWITCH_CONTEXT))); } =20 +/** + Create gMpInformationHobGuid2. +**/ +VOID +BuildMpInformationHob ( + VOID + ) +{ + EFI_STATUS Status; + UINTN ProcessorIndex; + UINTN NumberOfProcessors; + UINTN NumberOfEnabledProcessors; + UINTN NumberOfProcessorsInHob; + UINTN MaxProcessorsPerHob; + MP_INFORMATION2_HOB_DATA *MpInformation2HobData; + MP_INFORMATION2_ENTRY *MpInformation2Entry; + UINTN Index; + + ProcessorIndex =3D 0; + MpInformation2HobData =3D NULL; + MpInformation2Entry =3D NULL; + + Status =3D MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberO= fEnabledProcessors); + ASSERT_EFI_ERROR (Status); + MaxProcessorsPerHob =3D ((MAX_UINT16 & ~7) - sizeof (EFI_HOB_GUID_TY= PE) - sizeof (MP_INFORMATION2_HOB_DATA)) / sizeof (MP_INFORMATION2_ENTRY); + NumberOfProcessorsInHob =3D MaxProcessorsPerHob; + + // + // Create MP_INFORMATION2_HOB. when the max HobLength 0xFFF8 is not enou= gh, there + // will be a MP_INFORMATION2_HOB series in the HOB list. + // In the HOB list, there is a gMpInformationHobGuid2 with 0 value Numbe= rOfProcessors + // fields to indicate it's the last MP_INFORMATION2_HOB. + // + while (NumberOfProcessorsInHob !=3D 0) { + NumberOfProcessorsInHob =3D MIN (NumberOfProcessors - ProcessorIndex, = MaxProcessorsPerHob); + MpInformation2HobData =3D BuildGuidHob ( + &gMpInformationHobGuid2, + sizeof (MP_INFORMATION2_HOB_DATA) + sizeof= (MP_INFORMATION2_ENTRY) * NumberOfProcessorsInHob + ); + ASSERT (MpInformation2HobData !=3D NULL); + + MpInformation2HobData->Version =3D MP_INFORMATION2_HOB_REVI= SION; + MpInformation2HobData->ProcessorIndex =3D ProcessorIndex; + MpInformation2HobData->NumberOfProcessors =3D (UINT16)NumberOfProcesso= rsInHob; + MpInformation2HobData->EntrySize =3D sizeof (MP_INFORMATION2_= ENTRY); + + DEBUG ((DEBUG_INFO, "Creating MpInformation2 HOB...\n")); + + for (Index =3D 0; Index < NumberOfProcessorsInHob; Index++) { + MpInformation2Entry =3D &MpInformation2HobData->Entry[Index]; + Status =3D MpInitLibGetProcessorInfo ( + (Index + ProcessorIndex) | CPU_V2_EXTENDED_T= OPOLOGY, + &MpInformation2Entry->ProcessorInfo, + NULL + ); + ASSERT_EFI_ERROR (Status); + DEBUG (( + DEBUG_INFO, + " Processor[%04d]: ProcessorId =3D 0x%lx, StatusFlag =3D 0x%x\n", + Index + ProcessorIndex, + MpInformation2Entry->ProcessorInfo.ProcessorId, + MpInformation2Entry->ProcessorInfo.StatusFlag + )); + DEBUG (( + DEBUG_INFO, + " Location =3D Package:%d Core:%d Thread:%d\n", + MpInformation2Entry->ProcessorInfo.Location.Package, + MpInformation2Entry->ProcessorInfo.Location.Core, + MpInformation2Entry->ProcessorInfo.Location.Thread + )); + DEBUG (( + DEBUG_INFO, + " Location2 =3D Package:%d Die:%d Tile:%d Module:%d Core:%d Thr= ead:%d\n", + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.P= ackage, + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.D= ie, + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.T= ile, + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.M= odule, + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.C= ore, + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.T= hread + )); + } + + ProcessorIndex +=3D NumberOfProcessorsInHob; + } +} + /** Initializes MP and exceptions handlers. =20 @@ -602,6 +688,11 @@ InitializeCpuMpWorker ( Status =3D PeiServicesInstallPpi (mPeiCpuMpPpiList); ASSERT_EFI_ERROR (Status); =20 + // + // Create gMpInformationHobGuid2 + // + BuildMpInformationHob (); + return Status; } =20 diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h index 1b9a94e18f..a40fd2c077 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h @@ -1,7 +1,7 @@ /** @file Definitions to install Multiple Processor PPI. =20 - Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -30,6 +30,8 @@ #include #include =20 +#include + extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc; =20 /** diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPe= i.inf index 865be5627e..812fa179bd 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf @@ -1,7 +1,7 @@ ## @file # CPU driver installs CPU PI Multi-processor PPI. # -# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -50,6 +50,7 @@ =20 [Guids] gEdkiiMigratedFvInfoGuid ## = SOMETIMES_CONSUMES ## HOB + gMpInformationHobGuid2 ## PRODUCES =20 [Ppis] gEfiPeiMpServicesPpiGuid ## PRODUCES --=20 2.31.1.windows.1 -=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 (#112222): https://edk2.groups.io/g/devel/message/112222 Mute This Topic: https://groups.io/mt/103052269/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-