From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 149D6940FFB for ; Mon, 6 May 2024 03:11:26 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=vbGo/DVNEFePvxqGY4T0ibNoPydngPTJIWdOewC/bqI=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type; s=20240206; t=1714965085; v=1; b=CnlU3UG5K1immFPM8xbUqn3o8wkbEfKaF7Gc+UDTw/sUJocGoMoMhxDcQARNquguIHU0xttS i8UcD/zfDcOnop0qADshklnzKGouf8fznD2d2lhJLJVTMZs/308qxnSjO7Hf9W8OfJ7mKQxbJ0w hPb/f78WFfvwlyWJRW9M1VcCSTOyWVYK2mtxAleJTLxhTe3JO2E53xPWzfXdnITBjU60JtIpk0J 4IA7RiqcLpv5s3qhS4cl/5A55ShxWPyZsutjbTGpt7g0aTRn2qWSgiEvTgxbXTzRS3EKOU7i6fJ MOIytnF8EMS23oZho9rmE58aYjSmuRUKt3Q+A19Z48Wwg== X-Received: by 127.0.0.2 with SMTP id ZJ0hYY7687511xU00Pt6Gf10; Sun, 05 May 2024 20:11:25 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by mx.groups.io with SMTP id smtpd.web11.12475.1714965079728799150 for ; Sun, 05 May 2024 20:11:19 -0700 X-CSE-ConnectionGUID: 0RGS2SycSsu0IwGgtzpZaw== X-CSE-MsgGUID: /SPa5xfCRFqfARiGSah9PQ== X-IronPort-AV: E=McAfee;i="6600,9927,11064"; a="10910385" X-IronPort-AV: E=Sophos;i="6.07,257,1708416000"; d="scan'208,217";a="10910385" X-Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2024 20:11:19 -0700 X-CSE-ConnectionGUID: X3/g1aBNQL2tlCadQDhz6A== X-CSE-MsgGUID: XfrUVhpQS/CJMInNM0ZrlA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,257,1708416000"; d="scan'208,217";a="51204324" X-Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmviesa002.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 05 May 2024 20:11:19 -0700 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Sun, 5 May 2024 20:11:18 -0700 X-Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Sun, 5 May 2024 20:11:18 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.169) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Sun, 5 May 2024 20:11:18 -0700 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by SA2PR11MB5050.namprd11.prod.outlook.com (2603:10b6:806:fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 03:11:16 +0000 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::41a4:c775:32e6:76a8]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::41a4:c775:32e6:76a8%4]) with mapi id 15.20.7544.041; Mon, 6 May 2024 03:11:16 +0000 From: "Ni, Ray" To: "Attar, AbdulLateef (Abdul Lateef)" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Handle the NULL gMpInformation2HobGuid Thread-Topic: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Handle the NULL gMpInformation2HobGuid Thread-Index: AQHamibihGNhkDX8TUCHuAqLc7tFyrGATwr0gAAhToCACSFfcA== Date: Mon, 6 May 2024 03:11:16 +0000 Message-ID: References: <7326146f-f0e4-4df3-a577-0a5cc89f4c38@amd.com> In-Reply-To: <7326146f-f0e4-4df3-a577-0a5cc89f4c38@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|SA2PR11MB5050:EE_ x-ms-office365-filtering-correlation-id: 53331d35-8938-4431-1e0f-08dc6d7a3181 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?us-ascii?Q?uCCRoCLu562gQYG3eAJKSurTQ9vdV8AmjWZfRodgW0LVQLs3qNNIL8+stdty?= =?us-ascii?Q?ZDd+txAD5dSam77LyNv3nef0qF9RsVMjGPuS+6Vor2N3xm1bfY/4MnEFrbjN?= =?us-ascii?Q?CxHtAmCjz0inz8BMjCrmDKXUJ31zU6TIORk7+dNhXod2MbYPSEfKLe4PyXnS?= =?us-ascii?Q?HMUzFEZRosld5Jw9cDWSYrLV4UzS6KT4eafNGRZVBsXXDqmdQydpw1MrTa7H?= =?us-ascii?Q?x/XHb5BExl8j4w8TFxm7PByMcH399/67KXhL25L84ibVBRb9ba+lcSwdZMqk?= =?us-ascii?Q?Ld4deyl3fChBXq1LWo06SJTAB+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Q?GA4SJCTN3gAESViCUQHM5tXMLq/PU0MxPS/I+A34jU/nnOsLDlPMo5y8dlGt?= =?us-ascii?Q?o3ch1Y2NTKaaGjsubVzcdaSSD1S2xjrbvJMjKTDTpxJ+R3XGd6AvnN5SJkct?= =?us-ascii?Q?eTIPOov/WNv5T91ibW9saXQiVUt8joqmGpuRs7uxEUwVGA=3D=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?/vdPWtskR+Ay9LLOBjLRGGZkOCt8K5kgvl7vN2kb7SfYSzIh9TUUz5CLFyf1?= =?us-ascii?Q?BMQkI7n8MWJOn8yh+l8otMiWHH7w2fNLD57Y7QFj/Yc7yU5tToSpFuL34H/4?= =?us-ascii?Q?YFPnhfzQLZIDLyVmEtwpLeIIJTSPxSKAg58dcB4t9EMSyQFEDsd/Vdf07Nlo?= =?us-ascii?Q?wrkO/M4Ag+RbcLK2axm/QRRTXweZm2/orgGhageeGxV5CH3NNR5ldAkqfu1L?= =?us-ascii?Q?oxS665uICKbqaAvjTBd48w3P+tm2SutZAxD7gmRQkYS6uy0ZM9avJT2Zt2hZ?= =?us-ascii?Q?mQAWyMJyVWThWLUFgAKCVyHx1sx61fZCm0iV9xQBkt4fnDEDMtsmR04uIAwz?= =?us-ascii?Q?0roiBfwvVBkpnEpLOUv8hrGbnnJAKMYwfl44aRILi4uepNERXX+h+aeNh6Tv?= =?us-ascii?Q?BfD1Y920dBF8ujmN/HCqfKWqJvBdJtLncMvA6GSFkage4umx/NbRViDzPUM1?= =?us-ascii?Q?IO7ZZXHqrcmVTk8Ai68k9Br2sHE9StlA3ZVNbfG926krqGwGlL4Ngp5a6e6j?= =?us-ascii?Q?7P+S7WaltytE+gCDx7WrkXucWdgKF9KYuE03z4YiG53en9NFq/mb2zhcoxaf?= =?us-ascii?Q?wYtpqrCqnTG6IfYMaE38pmhw2wHSGhtfh6sZ7MDx7urlN5If/IgdT+fj+nmk?= =?us-ascii?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YqSVJ3QNMqx7cKO?= =?us-ascii?Q?/U0LY4msd9PGX5q2h1U=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53331d35-8938-4431-1e0f-08dc6d7a3181 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 May 2024 03:11:16.3228 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BAdHvH7CMi3BqR4WAUu7T4AjY+3JqTLPfhMhL5XZuiwUa08ZB+ygqgqRCobMnTO3zTY8IQ9i7ulAwTg2lXE+Cg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5050 X-OriginatorOrg: intel.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 Resent-Date: Sun, 05 May 2024 20:11:19 -0700 Resent-From: ray.ni@intel.com Reply-To: devel@edk2.groups.io,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 58HnCEkDT5MJ7CezenXkOlSwx7686176AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MN6PR11MB8244F599C016A43E2C9C19218C1C2MN6PR11MB8244namp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=CnlU3UG5; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io --_000_MN6PR11MB8244F599C016A43E2C9C19218C1C2MN6PR11MB8244namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni Thanks, Ray ________________________________ From: Attar, AbdulLateef (Abdul Lateef) Sent: Tuesday, April 30, 2024 15:45 To: Ni, Ray ; devel@edk2.groups.io Cc: Laszlo Ersek ; Kumar, Rahul R ; Gerd Hoffmann Subject: Re: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Handle the NULL gMpInformat= ion2HobGuid Hi Ray, Some of AMD platform doesnt use CpuMpPeim. Also this patch helps not to enforce the platform to brinup all AP's in PEI= phase. Thanks AbduL On 30-04-2024 11:17, Ni, Ray wrote: Caution: This message originated from an External Source. Use proper cautio= n when opening attachments, clicking links, or responding. Abdul, Does Amd PEI include the CpuMpPeim? If it includes the PEIM, the MpInformation2Hob should be in the HOB databas= e. Thanks, Ray ________________________________ From: Abdul Lateef Attar Sent: Monday, April 29, 2024 19:17 To: devel@edk2.groups.io Cc: Abdul Lateef Attar ; Ni, Ray ; Laszlo Erse= k ; Kumar, Rahul R ; Gerd Hoffmann Subject: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Handle the NULL gMpInformation2= HobGuid If gMpInformation2HobGuid HOB is NULL, then fall back to an older way of collecting CPU information from the MP services library. Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Cc: Gerd Hoffmann Signed-off-by: Abdul Lateef Attar --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 87 +++++++++++++++++++- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 3 +- 2 files changed, 87 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmC= puDxeSmm/PiSmmCpuDxeSmm.c index 499f979d34..74e494f332 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -3,7 +3,7 @@ Agent Module to load other modules to deploy SMM Entry Vect= or for X86 CPU. Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
-Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved= .
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -750,6 +750,85 @@ MpInformation2HobCompare ( return 0; } +/** + Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORMATION for = all CPU from gEfiMpServiceProtocolGuid. + + @param[out] NumberOfCpus Pointer to NumberOfCpus. + @param[out] MaxNumberOfCpus Pointer to MaxNumberOfCpus. + + @retval ProcessorInfo Pointer to EFI_PROCESSOR_INFORMATION = buffer. +**/ +EFI_PROCESSOR_INFORMATION * +GetMpInformationFromMpServices ( + OUT UINTN *NumberOfCpus, + OUT UINTN *MaxNumberOfCpus + ) +{ + EFI_STATUS Status; + UINTN Index; + UINTN NumberOfEnabledProcessors; + UINTN NumberOfProcessors; + EFI_MP_SERVICES_PROTOCOL *MpService; + EFI_PROCESSOR_INFORMATION *ProcessorInfo; + + if ((NumberOfCpus =3D=3D NULL) || (MaxNumberOfCpus =3D=3D NULL)) { + ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); + return NULL; + } + + ProcessorInfo =3D NULL; + *NumberOfCpus =3D 0; + *MaxNumberOfCpus =3D 0; + + /// Get the MP Services Protocol + Status =3D gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID = **)&MpService); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return NULL; + } + + /// Get the number of processors + Status =3D MpService->GetNumberOfProcessors (MpService, &NumberOfProcess= ors, &NumberOfEnabledProcessors); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return NULL; + } + + ASSERT (NumberOfProcessors <=3D PcdGet32 (PcdCpuMaxLogicalProcessorNumbe= r)); + + /// Allocate buffer for processor information + ProcessorInfo =3D AllocateZeroPool (sizeof (EFI_PROCESSOR_INFORMATION) *= NumberOfProcessors); + if (ProcessorInfo =3D=3D NULL) { + ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES); + return NULL; + } + + /// Get processor information + for (Index =3D 0; Index < NumberOfProcessors; Index++) { + Status =3D MpService->GetProcessorInfo (MpService, Index | CPU_V2_EXTE= NDED_TOPOLOGY, &ProcessorInfo[Index]); + if (EFI_ERROR (Status)) { + FreePool (ProcessorInfo); + DEBUG ((DEBUG_ERROR, "%a: Failed to get processor information for pr= ocessor %d\n", __func__, Index)); + ASSERT_EFI_ERROR (Status); + return NULL; + } + } + + *NumberOfCpus =3D NumberOfEnabledProcessors; + + ASSERT (*NumberOfCpus <=3D PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); + // + // If support CPU hot plug, we need to allocate resources for possibly h= ot-added processors + // + if (FeaturePcdGet (PcdCpuHotPlugSupport)) { + *MaxNumberOfCpus =3D PcdGet32 (PcdCpuMaxLogicalProcessorNumber); + } else { + *MaxNumberOfCpus =3D *NumberOfCpus; + } + + return ProcessorInfo; +} + /** Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORMATION for = all CPU from MpInformation2 HOB. @@ -784,7 +863,11 @@ GetMpInformation ( HobCount =3D 0; FirstMpInfo2Hob =3D GetFirstGuidHob (&gMpInformation2HobGuid); - ASSERT (FirstMpInfo2Hob !=3D NULL); + if (FirstMpInfo2Hob =3D=3D NULL) { + DEBUG ((DEBUG_INFO, "%a: [INFO] gMpInformation2HobGuid HOB not found.\= n", __func__)); + return GetMpInformationFromMpServices (NumberOfCpus, MaxNumberOfCpus); + } + GuidHob =3D FirstMpInfo2Hob; while (GuidHob !=3D NULL) { MpInformation2HobData =3D GET_GUID_HOB_DATA (GuidHob); diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/UefiCpuPkg/PiSm= mCpuDxeSmm/PiSmmCpuDxeSmm.inf index a018954ed7..db99a63c5a 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf @@ -6,7 +6,7 @@ # # Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
# Copyright (c) 2017, AMD Incorporated. All rights reserved.
-# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -114,6 +114,7 @@ gEdkiiSmmMemoryAttributeProtocolGuid ## PRODUCES gEfiMmMpProtocolGuid ## PRODUCES gEdkiiSmmCpuRendezvousProtocolGuid ## PRODUCES + gEfiMpServiceProtocolGuid ## CONSUMES [Guids] gEfiAcpiVariableGuid ## SOMETIMES_CONSUMES ## HOB # = it is used for S3 boot. -- 2.34.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 (#118584): https://edk2.groups.io/g/devel/message/118584 Mute This Topic: https://groups.io/mt/105798412/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --_000_MN6PR11MB8244F599C016A43E2C9C19218C1C2MN6PR11MB8244namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Ray Ni <ray.ni@intel.com>

Thanks,
Ray

From: Attar, AbdulLateef (A= bdul Lateef) <AbdulLateef.Attar@amd.com>
Sent: Tuesday, April 30, 2024 15:45
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io <devel= @edk2.groups.io>
Cc: Laszlo Ersek <lersek@redhat.com>; Kumar, Rahul R <rahul= .r.kumar@intel.com>; Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Handle the NULL gMpI= nformation2HobGuid
 

Hi Ray,

    Some of AMD platform doesnt use CpuMpPeim.

Also this patch helps not to enforce the platform to brinup all AP's in = PEI phase.


Thanks

AbduL


On 30-04-2024 11:17, Ni, Ray wrote:

C= aution: This message originated from an External Source. Use proper = caution when opening attachments, clicking links, or responding.

Abdul,
Does Amd PEI include the CpuMpPeim?
If it includes the PEIM, the MpInformation2Hob should be in the HOB databas= e.

Thanks,
Ray

From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Sent: Monday, April 29, 2024 19:17
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>; Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>; Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Handle the NULL gMpInfor= mation2HobGuid
 
If gMpInformation2HobGuid HOB is NULL,
then fall back to an older way of collecting
CPU information from the MP services library.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c   | 87 +++++++++= ++++++++++-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf |  3 +-
 2 files changed, 87 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmC= puDxeSmm/PiSmmCpuDxeSmm.c
index 499f979d34..74e494f332 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -3,7 +3,7 @@ Agent Module to load other modules to deploy SMM Entry Vect= or for X86 CPU.
 
 Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.<= ;BR>
 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR><= br> -Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR= >
+Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved= .<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -750,6 +750,85 @@ MpInformation2HobCompare (
   return 0;
 }
 
+/**
+  Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORMATION= for all CPU from gEfiMpServiceProtocolGuid.
+
+  @param[out] NumberOfCpus       &= nbsp;   Pointer to NumberOfCpus.
+  @param[out] MaxNumberOfCpus      &nbs= p; Pointer to MaxNumberOfCpus.
+
+  @retval ProcessorInfo       &nbs= p;      Pointer to EFI_PROCESSOR_INFORMATION buffe= r.
+**/
+EFI_PROCESSOR_INFORMATION *
+GetMpInformationFromMpServices (
+  OUT UINTN  *NumberOfCpus,
+  OUT UINTN  *MaxNumberOfCpus
+  )
+{
+  EFI_STATUS         &nb= sp;       Status;
+  UINTN          &n= bsp;           Index;
+  UINTN          &n= bsp;           NumberOfEn= abledProcessors;
+  UINTN          &n= bsp;           NumberOfPr= ocessors;
+  EFI_MP_SERVICES_PROTOCOL   *MpService;
+  EFI_PROCESSOR_INFORMATION  *ProcessorInfo;
+
+  if ((NumberOfCpus =3D=3D NULL) || (MaxNumberOfCpus =3D=3D NULL)) {<= br> +    ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
+    return NULL;
+  }
+
+  ProcessorInfo    =3D NULL;
+  *NumberOfCpus    =3D 0;
+  *MaxNumberOfCpus =3D 0;
+
+  /// Get the MP Services Protocol
+  Status =3D gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, = NULL, (VOID **)&MpService);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    return NULL;
+  }
+
+  /// Get the number of processors
+  Status =3D MpService->GetNumberOfProcessors (MpService, &Num= berOfProcessors, &NumberOfEnabledProcessors);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    return NULL;
+  }
+
+  ASSERT (NumberOfProcessors <=3D PcdGet32 (PcdCpuMaxLogicalProces= sorNumber));
+
+  /// Allocate buffer for processor information
+  ProcessorInfo =3D AllocateZeroPool (sizeof (EFI_PROCESSOR_INFORMATI= ON) * NumberOfProcessors);
+  if (ProcessorInfo =3D=3D NULL) {
+    ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
+    return NULL;
+  }
+
+  /// Get processor information
+  for (Index =3D 0; Index < NumberOfProcessors; Index++) {
+    Status =3D MpService->GetProcessorInfo (MpService, I= ndex | CPU_V2_EXTENDED_TOPOLOGY, &ProcessorInfo[Index]);
+    if (EFI_ERROR (Status)) {
+      FreePool (ProcessorInfo);
+      DEBUG ((DEBUG_ERROR, "%a: Failed to ge= t processor information for processor %d\n", __func__, Index));
+      ASSERT_EFI_ERROR (Status);
+      return NULL;
+    }
+  }
+
+  *NumberOfCpus =3D NumberOfEnabledProcessors;
+
+  ASSERT (*NumberOfCpus <=3D PcdGet32 (PcdCpuMaxLogicalProcessorNu= mber));
+  //
+  // If support CPU hot plug, we need to allocate resources for possi= bly hot-added processors
+  //
+  if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
+    *MaxNumberOfCpus =3D PcdGet32 (PcdCpuMaxLogicalProcesso= rNumber);
+  } else {
+    *MaxNumberOfCpus =3D *NumberOfCpus;
+  }
+
+  return ProcessorInfo;
+}
+
 /**
   Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORM= ATION for all CPU from MpInformation2 HOB.
 
@@ -784,7 +863,11 @@ GetMpInformation (
   HobCount         =      =3D 0;
 
   FirstMpInfo2Hob =3D GetFirstGuidHob (&gMpInformation2HobGu= id);
-  ASSERT (FirstMpInfo2Hob !=3D NULL);
+  if (FirstMpInfo2Hob =3D=3D NULL) {
+    DEBUG ((DEBUG_INFO, "%a: [INFO] gMpInformation2Hob= Guid HOB not found.\n", __func__));
+    return GetMpInformationFromMpServices (NumberOfCpus, Ma= xNumberOfCpus);
+  }
+
   GuidHob =3D FirstMpInfo2Hob;
   while (GuidHob !=3D NULL) {
     MpInformation2HobData =3D GET_GUID_HOB_DATA (GuidH= ob);
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/UefiCpuPkg/PiSm= mCpuDxeSmm/PiSmmCpuDxeSmm.inf
index a018954ed7..db99a63c5a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
@@ -6,7 +6,7 @@
 #
 # Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.&= lt;BR>
 # Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>= ;
-# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<= BR>
+# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -114,6 +114,7 @@
   gEdkiiSmmMemoryAttributeProtocolGuid     #= # PRODUCES
   gEfiMmMpProtocolGuid       =             &nb= sp; ## PRODUCES
   gEdkiiSmmCpuRendezvousProtocolGuid    &nbs= p;  ## PRODUCES
+  gEfiMpServiceProtocolGuid       =          ## CONSUMES
 
 [Guids]
   gEfiAcpiVariableGuid       =             &nb= sp; ## SOMETIMES_CONSUMES ## HOB # it is used for S3 boot.
--
2.34.1

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#118584) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_MN6PR11MB8244F599C016A43E2C9C19218C1C2MN6PR11MB8244namp_--