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 CD8E5D80144 for ; Tue, 5 Dec 2023 05:49:22 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=9BFOL6+GghpX2pFr4bOsBliu2Wx0332xvdMM2z84iSI=; 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=1701755361; v=1; b=WWEJH0lWvEfN9qYJw5QVSsJ1eNRit8QeWmEiABnTl9t2XSh6y55LlCWuK+51pz+WshFRMwU3 jvt0Etf8JMB29EGeIooa22gHwhT87zeQVd7fXZtL75blThmK22bXyMqnOf7lb99c1+SPQsOyLOp LeGTWexRmukpG9aHNQGa5/VA= X-Received: by 127.0.0.2 with SMTP id I8McYY7687511xXIq0sgvI6O; Mon, 04 Dec 2023 21:49:21 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.93095.1701755355027796431 for ; Mon, 04 Dec 2023 21:49:20 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="378875428" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="378875428" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 21:49:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="720580530" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="720580530" X-Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.43]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 21:49:19 -0800 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [PATCH 2/6] UefiCpuPkg: Build MpInfo2HOB in CpuMpPei Date: Tue, 5 Dec 2023 13:48:56 +0800 Message-Id: <20231205054900.926-3-dun.tan@intel.com> In-Reply-To: <20231205054900.926-1-dun.tan@intel.com> References: <20231205054900.926-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: bo3acZpC8Cgg6AjXy9hdYHfmx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=WWEJH0lW; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) 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 Cc: 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..4d80d52799 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -541,6 +541,92 @@ InitializeMpExceptionStackSwitchHandlers ( FreePages (SwitchStackData, EFI_SIZE_TO_PAGES (NumberOfProcessors * sizeof (EXCEPTION_STACK_SWITCH_CONTEXT))); } +/** + 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 = 0; + MpInformation2HobData = NULL; + MpInformation2Entry = NULL; + + Status = MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledProcessors); + ASSERT_EFI_ERROR (Status); + MaxProcessorsPerHob = ((MAX_UINT16 & 7) - sizeof (EFI_HOB_GUID_TYPE) - sizeof (MP_INFORMATION2_HOB_DATA)) / sizeof (MP_INFORMATION2_ENTRY); + NumberOfProcessorsInHob = MaxProcessorsPerHob; + + // + // Create MP_INFORMATION2_HOB. when the max HobLength 0xFFF8 is not enough, there + // will be a MP_INFORMATION2_HOB series in the HOB list. + // In the HOB list, there is a gMpInformationHobGuid2 with 0 value NumberOfProcessors + // fields to indicate it's the last MP_INFORMATION2_HOB. + // + while (NumberOfProcessorsInHob != 0) { + NumberOfProcessorsInHob = MIN (NumberOfProcessors - ProcessorIndex, MaxProcessorsPerHob); + MpInformation2HobData = BuildGuidHob ( + &gMpInformationHobGuid2, + sizeof (MP_INFORMATION2_HOB_DATA) + sizeof (MP_INFORMATION2_ENTRY) * NumberOfProcessorsInHob + ); + ASSERT (MpInformation2HobData != NULL); + + MpInformation2HobData->Version = MP_INFORMATION2_HOB_REVISION; + MpInformation2HobData->ProcessorIndex = ProcessorIndex; + MpInformation2HobData->NumberOfProcessors = (UINT16)NumberOfProcessorsInHob; + MpInformation2HobData->EntrySize = sizeof (MP_INFORMATION2_ENTRY); + + DEBUG ((DEBUG_INFO, "BuildMpInformationHob\n")); + + for (Index = 0; Index < NumberOfProcessorsInHob; Index++) { + MpInformation2Entry = GET_MP_INFORMATION_ENTRY (MpInformation2HobData, Index); + Status = MpInitLibGetProcessorInfo ( + (Index + ProcessorIndex) | CPU_V2_EXTENDED_TOPOLOGY, + &MpInformation2Entry->ProcessorInfo, + NULL + ); + ASSERT_EFI_ERROR (Status); + DEBUG (( + DEBUG_INFO, + "ProcessorIndex = %x, ProcessorId = %lx, StatusFlag = %x\n", + Index + ProcessorIndex, + MpInformation2Entry->ProcessorInfo.ProcessorId, + MpInformation2Entry->ProcessorInfo.StatusFlag + )); + DEBUG (( + DEBUG_INFO, + "Location (Package/Core/Thread) = %d/%d/%d\n", + MpInformation2Entry->ProcessorInfo.Location.Package, + MpInformation2Entry->ProcessorInfo.Location.Core, + MpInformation2Entry->ProcessorInfo.Location.Thread + )); + DEBUG (( + DEBUG_INFO, + "Location2 (Package/Die/Tile/Module/Core/Thread) = %d/%d/%d/%d/%d/%d\n", + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.Package, + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.Die, + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.Tile, + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.Module, + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.Core, + MpInformation2Entry->ProcessorInfo.ExtendedInformation.Location2.Thread + )); + } + + ProcessorIndex += NumberOfProcessorsInHob; + } +} + /** Initializes MP and exceptions handlers. @@ -602,6 +688,11 @@ InitializeCpuMpWorker ( Status = PeiServicesInstallPpi (mPeiCpuMpPpiList); ASSERT_EFI_ERROR (Status); + // + // Create gMpInformationHobGuid2 + // + BuildMpInformationHob (); + return Status; } 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. - 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 **/ @@ -30,6 +30,8 @@ #include #include +#include + extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc; /** diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.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 @@ [Guids] gEdkiiMigratedFvInfoGuid ## SOMETIMES_CONSUMES ## HOB + gMpInformationHobGuid2 ## PRODUCES [Ppis] gEfiPeiMpServicesPpiGuid ## PRODUCES -- 2.31.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112064): https://edk2.groups.io/g/devel/message/112064 Mute This Topic: https://groups.io/mt/102987138/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-