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 A94B5D80047 for ; Mon, 29 Apr 2024 11:17:53 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=6MjwE3SsT82rD2k20ZRajUtsAxD5mTsA58VQTRpZnH0=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Received-SPF:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1714389472; v=1; b=ZOlHSyy4w9UPd0RVaeTPcEtwk4FKi2FV1SKKIw2k6zhKc/bkc3dFh8leNlJ5nV1j++18Ksiz 078hdWOQWuUhfCGU4CNCWDzUWtNJagc4ed04qg8DcIwe5rZ89DnHauqv9mmOlD2z6wfRAAOy8Zk +tkYZMYi4h6tWC2055OVfXQISmoqqynacDqRxLWRqF3w+SJL2Y81Dx62FkiGvwKiKKv0orT/KiD 4mKZcjP6dMbHPdK+xts1OoDGO6UBkP/DueDFm8m+CYOckn2xRRLbK3VGWtL7z1DHlErzNytYxM2 dSH/m8mCuvDA/475jDbQ+yQHfJ2bvgo7MILpVdT9n4uVQ== X-Received: by 127.0.0.2 with SMTP id t3xWYY7687511xd4DkV4MOgT; Mon, 29 Apr 2024 04:17:52 -0700 X-Received: from NAM02-SN1-obe.outbound.protection.outlook.com (NAM02-SN1-obe.outbound.protection.outlook.com [40.107.96.85]) by mx.groups.io with SMTP id smtpd.web11.18089.1714389466507345772 for ; Mon, 29 Apr 2024 04:17:46 -0700 X-Received: from MN2PR17CA0008.namprd17.prod.outlook.com (2603:10b6:208:15e::21) by CH2PR12MB4327.namprd12.prod.outlook.com (2603:10b6:610:7d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 11:17:44 +0000 X-Received: from BL6PEPF0001AB71.namprd02.prod.outlook.com (2603:10b6:208:15e:cafe::24) by MN2PR17CA0008.outlook.office365.com (2603:10b6:208:15e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.35 via Frontend Transport; Mon, 29 Apr 2024 11:17:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB71.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Mon, 29 Apr 2024 11:17:43 +0000 X-Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 29 Apr 2024 06:17:42 -0500 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 29 Apr 2024 06:17:41 -0500 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Ray Ni , Laszlo Ersek , Rahul Kumar , "Gerd Hoffmann" Subject: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Handle the NULL gMpInformation2HobGuid Date: Mon, 29 Apr 2024 16:47:30 +0530 Message-ID: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: AbdulLateef.Attar@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB71:EE_|CH2PR12MB4327:EE_ X-MS-Office365-Filtering-Correlation-Id: 48401d51-7520-4d24-4a5e-08dc683dfdbe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lLejlzqFLt6G9sEl2055VkSNM6LwQCjXtIMipglSdJo4ewYhz0V9d72g+WM3?= =?us-ascii?Q?CGT7CyF88r/fQzOP3ZZsNDo/eaVayRRm0gNa3sBY6Wnys5ltztERSZdR1wHn?= =?us-ascii?Q?gqjUF7RoAi2USh2S8RC8CP2QiDRd/Zuut7Z8iCjTxAWJNuTT4NzMVEeXCYOo?= =?us-ascii?Q?e8McXiPzQt8XZOzdGiWFkv1zPFjywwAqr+9pBbJJ81F81SuaDWFuUwIqEUsD?= =?us-ascii?Q?NlhYly24rolf2864eBTUBeMrcwo+Hlm3IPYRkFvw36dgtHwbkA7VBp0ozGEP?= =?us-ascii?Q?9154zzOx5yCMDAuOhcDL2yfr1iSBFnJ3SU8bdQ2g/6XoF0iPEw97bSM4RtdK?= =?us-ascii?Q?qL0y3bVWTjK3w9BAbcvIE2+Lt/6Mu87UCNt+OVtrE4/pCqPITSqYy4wwgsdh?= =?us-ascii?Q?gF8ZaGPA1BOdQVsdoFwWLZDag4YT4m64oy9uR5ZJ1TQe83VBbRLqmPDZ2zoC?= =?us-ascii?Q?7UL8eYtEOiz0feoRp2oqaverGJFQ/PfR2O9MrNxdBvvZ1rz9sqoXlPW9RQNF?= =?us-ascii?Q?KcUpgiRkNlerOOkzRL0E5bbs1Cdn6Ln/3ZZt/WUtFcrT3Y+eRFWrY7dxt7HQ?= =?us-ascii?Q?J/d2ZViFLP0Wdw3vqNjxhvkT417IoiSypJlSumO4KwM+Ezq+YUlL3fcFwRP+?= =?us-ascii?Q?GNV0+GbOQKhACzbGIp7XOF8kVZhyg48hmKY7mY1o1RxqrJjiM7CuXJqgCSQT?= =?us-ascii?Q?vxwBY8/N8o+hnAjjfGI+A+uS0AEbaOT0pX+4cl3IYgNSA0l199D4kUKj4w9t?= =?us-ascii?Q?Zc0g88+be2VMMl7XKclm01zFA6s83klflGvpWz54WkZ0JHTV1HTmCLCrYsC+?= =?us-ascii?Q?th7Ww3PO4q7WVxf3ioeenMDfK/DnIbrKq+ZXQ9v/vYlDEWJs2bcra9G7JaF7?= =?us-ascii?Q?AWJgR6WjFKjBvPuL1fDl+N2gc3aL0BNAdvKtj7G286SRAcY7tmMNt5kh2E7S?= =?us-ascii?Q?Xm5CfvQIuBFYNIkagPKvDczhBXs/WdHzdZzCHxdQO3Bh7A0vKTUD8sIPvwSN?= =?us-ascii?Q?N5jqC2hPvkj9nTG+LmLwVOOnPgylR3OTIrZsjESXLpl01cjsA0ryWokf2u/k?= =?us-ascii?Q?lwQlIa0litk+JGkbuGUvSoSxOFO7XWxQxCl2t5s2/KcGWPGiQfalaSYZeQRz?= =?us-ascii?Q?R+Y6PKble2OSZA7mrbbePLshhkU7tBPjwqAMshkmjHbHmNOMD+mO4KMbgRrK?= =?us-ascii?Q?Ukekwj0WCI6aohcy7HXDF3sz1Yl4A5jV55ehPNJBjaFRfHcMY0zXBp2IgaL1?= =?us-ascii?Q?w8Tl9UkFvcnLu/9s3nRQyF/AX7IjgnC6IgYPuuzHQ8fjnKGOlwRKPxwH0VEk?= =?us-ascii?Q?ExQ8957LcYVu0r+llmNOOCf3fQ4YWHAcxIywh4lqAZfROjLvtf4idW0GxGLt?= =?us-ascii?Q?YZTZGuAA8E1xkmiTUnArJJaPLhKp?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 11:17:43.8699 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48401d51-7520-4d24-4a5e-08dc683dfdbe X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB71.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4327 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: Mon, 29 Apr 2024 04:17:46 -0700 Resent-From: AbdulLateef.Attar@amd.com Reply-To: devel@edk2.groups.io,AbdulLateef.Attar@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 2BqsiKxPnRZvIfzKqYu2plPMx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=ZOlHSyy4; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=pass (policy=none) header.from=groups.io 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. =20 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= .
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -750,6 +750,85 @@ MpInformation2HobCompare ( return 0; } =20 +/** + 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. =20 @@ -784,7 +863,11 @@ GetMpInformation ( HobCount =3D 0; =20 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 =20 [Guids] gEfiAcpiVariableGuid ## SOMETIMES_CONSUMES ## HOB # = it is used for S3 boot. --=20 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 (#118387): https://edk2.groups.io/g/devel/message/118387 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-