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 87ABAAC0AEA for ; Tue, 30 Apr 2024 07:45:22 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=896aB6sGxu+Gw8K/2+vNs27G0/PUsBBMFgNb499D2k4=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From:In-Reply-To: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-Type:Content-Language; s=20240206; t=1714463121; v=1; b=Lf5BMg/3hCbkU7HvHL41D+NxNHTGW/A8Nib024FaG0whAlmcctfoyFOXbHZtSL0sABYfS2Rr 1XP21+IIqlkxPotxm7dtjnkPASwrL9AfymuTZaz2ImduL/D/QzYA7zFL08KbK43f6Gd+Z4P3KPO KtOlKCteJH5sE7m1FYEegm1Klk+3BX+NjWEd+iU0h6+26zCpIHT8AVy9A6fzdKV9kv/Ov2D+iRz 7FZj+ZCtgLWpEpu80AOWBPF89wTCyc1OgiHnqXLafeOFJvx1rUV7bpC6/sjgrdVIPSjsBMXSsPi dq3qmkVJcuWAnPic/Bln8pVvo0yD+C88zClqYqRrYFgdA== X-Received: by 127.0.0.2 with SMTP id wO0FYY7687511xKTulIL6Aae; Tue, 30 Apr 2024 00:45:21 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.56]) by mx.groups.io with SMTP id smtpd.web11.9732.1714463120013748171 for ; Tue, 30 Apr 2024 00:45:20 -0700 X-Received: from IA1PR12MB6458.namprd12.prod.outlook.com (2603:10b6:208:3aa::22) by DM4PR12MB5891.namprd12.prod.outlook.com (2603:10b6:8:67::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.35; Tue, 30 Apr 2024 07:45:17 +0000 X-Received: from IA1PR12MB6458.namprd12.prod.outlook.com ([fe80::1a52:ef3a:cf04:e56d]) by IA1PR12MB6458.namprd12.prod.outlook.com ([fe80::1a52:ef3a:cf04:e56d%3]) with mapi id 15.20.7519.031; Tue, 30 Apr 2024 07:45:17 +0000 Message-ID: <7326146f-f0e4-4df3-a577-0a5cc89f4c38@amd.com> Date: Tue, 30 Apr 2024 13:15:09 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Handle the NULL gMpInformation2HobGuid To: "Ni, Ray" , "devel@edk2.groups.io" Cc: Laszlo Ersek , "Kumar, Rahul R" , Gerd Hoffmann References: From: "Abdul Lateef Attar via groups.io" In-Reply-To: X-ClientProxiedBy: MA0PR01CA0099.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:af::7) To IA1PR12MB6458.namprd12.prod.outlook.com (2603:10b6:208:3aa::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR12MB6458:EE_|DM4PR12MB5891:EE_ X-MS-Office365-Filtering-Correlation-Id: b6494b2f-16d1-40f6-6641-08dc68e97ab6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?utf-8?B?R3FpZ3pYdWdHdjBhU1QwYzIrNU1BL2lLaXZtQWg5d3JmK0lWMzN5cVRDbFIw?= =?utf-8?B?QzVWOGF6aC9ibnAyamY5K0dpL3VNbVNWSnZRZGRiOXVzT0hUYzc4L0U0NEc5?= =?utf-8?B?Uk9pZnNYWnZ1VkluYnoxWHRvZ1FBUkJSTmNoR29UQXJvZnJ2Vjk4VGdpaVUv?= =?utf-8?B?WGNJcWwxeWdyUjVTUkg2U0ZCQy9zLzRmTlR0a21CZTJ4R0FSU0JqU3FvT1kz?= =?utf-8?B?TWVXeWl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aUYrY1FoTi9Ib2VlUFJhallU?= =?utf-8?B?blAyeWw0eHhvb2twVHZ0QVd6WmZzbGc4SU0ySmQ0eklIdmdJOEd2Sm55QWtw?= =?utf-8?Q?cFsQ78tyyzLLk1j0RknXqwLm1?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6494b2f-16d1-40f6-6641-08dc68e97ab6 X-MS-Exchange-CrossTenant-AuthSource: IA1PR12MB6458.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2024 07:45:17.9007 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SD9yMU3XzrkF+2l9PuMGySZjq3326d4Rs0IK1oxKwYjf1MGPwFcmF8HaIYY2OBXx1nH1RhpNstcnTdbKzfsi/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5891 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: Tue, 30 Apr 2024 00:45:20 -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: vGNWj6ozOZ6nUcw9iaTmWfIpx7686176AA= Content-Type: multipart/alternative; boundary="------------YN5xkwxcVqM7ZGsHwgwJqkz8" Content-Language: en-US X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="Lf5BMg/3"; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io --------------YN5xkwxcVqM7ZGsHwgwJqkz8 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 > 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 > database. > > 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 Ersek ; Kumar, Rahul R > ; Gerd Hoffmann > *Subject:* [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Handle the NULL > gMpInformation2HobGuid > 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/PiSmmCpuDxeSmm/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 > Vector 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 == NULL) || (MaxNumberOfCpus == NULL)) { > +    ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); > +    return NULL; > +  } > + > +  ProcessorInfo    = NULL; > +  *NumberOfCpus    = 0; > +  *MaxNumberOfCpus = 0; > + > +  /// Get the MP Services Protocol > +  Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, > (VOID **)&MpService); > +  if (EFI_ERROR (Status)) { > +    ASSERT_EFI_ERROR (Status); > +    return NULL; > +  } > + > +  /// Get the number of processors > +  Status = MpService->GetNumberOfProcessors (MpService, > &NumberOfProcessors, &NumberOfEnabledProcessors); > +  if (EFI_ERROR (Status)) { > +    ASSERT_EFI_ERROR (Status); > +    return NULL; > +  } > + > +  ASSERT (NumberOfProcessors <= PcdGet32 > (PcdCpuMaxLogicalProcessorNumber)); > + > +  /// Allocate buffer for processor information > +  ProcessorInfo = AllocateZeroPool (sizeof > (EFI_PROCESSOR_INFORMATION) * NumberOfProcessors); > +  if (ProcessorInfo == NULL) { > +    ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES); > +    return NULL; > +  } > + > +  /// Get processor information > +  for (Index = 0; Index < NumberOfProcessors; Index++) { > +    Status = MpService->GetProcessorInfo (MpService, Index | > CPU_V2_EXTENDED_TOPOLOGY, &ProcessorInfo[Index]); > +    if (EFI_ERROR (Status)) { > +      FreePool (ProcessorInfo); > +      DEBUG ((DEBUG_ERROR, "%a: Failed to get processor information > for processor %d\n", __func__, Index)); > +      ASSERT_EFI_ERROR (Status); > +      return NULL; > +    } > +  } > + > +  *NumberOfCpus = NumberOfEnabledProcessors; > + > +  ASSERT (*NumberOfCpus <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); > +  // > +  // If support CPU hot plug, we need to allocate resources for > possibly hot-added processors > +  // > +  if (FeaturePcdGet (PcdCpuHotPlugSupport)) { > +    *MaxNumberOfCpus = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); > +  } else { > +    *MaxNumberOfCpus = *NumberOfCpus; > +  } > + > +  return ProcessorInfo; > +} > + >  /** >    Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORMATION > for all CPU from MpInformation2 HOB. > > @@ -784,7 +863,11 @@ GetMpInformation ( >    HobCount              = 0; > >    FirstMpInfo2Hob = GetFirstGuidHob (&gMpInformation2HobGuid); > -  ASSERT (FirstMpInfo2Hob != NULL); > +  if (FirstMpInfo2Hob == NULL) { > +    DEBUG ((DEBUG_INFO, "%a: [INFO] gMpInformation2HobGuid HOB not > found.\n", __func__)); > +    return GetMpInformationFromMpServices (NumberOfCpus, > MaxNumberOfCpus); > +  } > + >    GuidHob = FirstMpInfo2Hob; >    while (GuidHob != NULL) { >      MpInformation2HobData = GET_GUID_HOB_DATA (GuidHob); > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf > b/UefiCpuPkg/PiSmmCpuDxeSmm/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 > reserved.
>  # >  # 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 > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#118421): https://edk2.groups.io/g/devel/message/118421 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] -=-=-=-=-=-=-=-=-=-=-=- --------------YN5xkwxcVqM7ZGsHwgwJqkz8 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

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 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 database.

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 gMpInformation2HobGuid
 
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/PiSmmCpuDxeSmm/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 Vector for X86 CPU.
 
 Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.<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 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           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 == NULL) || (MaxNumberOfCpus == NULL)) {
+    ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
+    return NULL;
+  }
+
+  ProcessorInfo    = NULL;
+  *NumberOfCpus    = 0;
+  *MaxNumberOfCpus = 0;
+
+  /// Get the MP Services Protocol
+  Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpService);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    return NULL;
+  }
+
+  /// Get the number of processors
+  Status = MpService->GetNumberOfProcessors (MpService, &NumberOfProcessors, &NumberOfEnabledProcessors);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    return NULL;
+  }
+
+  ASSERT (NumberOfProcessors <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
+
+  /// Allocate buffer for processor information
+  ProcessorInfo = AllocateZeroPool (sizeof (EFI_PROCESSOR_INFORMATION) * NumberOfProcessors);
+  if (ProcessorInfo == NULL) {
+    ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
+    return NULL;
+  }
+
+  /// Get processor information
+  for (Index = 0; Index < NumberOfProcessors; Index++) {
+    Status = MpService->GetProcessorInfo (MpService, Index | CPU_V2_EXTENDED_TOPOLOGY, &ProcessorInfo[Index]);
+    if (EFI_ERROR (Status)) {
+      FreePool (ProcessorInfo);
+      DEBUG ((DEBUG_ERROR, "%a: Failed to get processor information for processor %d\n", __func__, Index));
+      ASSERT_EFI_ERROR (Status);
+      return NULL;
+    }
+  }
+
+  *NumberOfCpus = NumberOfEnabledProcessors;
+
+  ASSERT (*NumberOfCpus <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
+  //
+  // If support CPU hot plug, we need to allocate resources for possibly hot-added processors
+  //
+  if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
+    *MaxNumberOfCpus = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
+  } else {
+    *MaxNumberOfCpus = *NumberOfCpus;
+  }
+
+  return ProcessorInfo;
+}
+
 /**
   Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORMATION for all CPU from MpInformation2 HOB.
 
@@ -784,7 +863,11 @@ GetMpInformation (
   HobCount              = 0;
 
   FirstMpInfo2Hob = GetFirstGuidHob (&gMpInformation2HobGuid);
-  ASSERT (FirstMpInfo2Hob != NULL);
+  if (FirstMpInfo2Hob == NULL) {
+    DEBUG ((DEBUG_INFO, "%a: [INFO] gMpInformation2HobGuid HOB not found.\n", __func__));
+    return GetMpInformationFromMpServices (NumberOfCpus, MaxNumberOfCpus);
+  }
+
   GuidHob = FirstMpInfo2Hob;
   while (GuidHob != NULL) {
     MpInformation2HobData = GET_GUID_HOB_DATA (GuidHob);
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/UefiCpuPkg/PiSmmCpuDxeSmm/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.<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 reserved.<BR>
 #
 # 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

_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#118421) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--------------YN5xkwxcVqM7ZGsHwgwJqkz8--