[edk2-devel] [PATCH V2 5/6] OvmfPkg/TdxDxe: Install MpInitLibDepLib protocols

Min Xu min.m.xu at intel.com
Sat May 7 01:36:22 UTC 2022


From: Min M Xu <min.m.xu at intel.com>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3918

In Td guest CpuDxe driver uses the MpInitLibUp, the other guest type
use the MpInitLib. So we install different Protocols according to
the current working guest type.

Cc: Eric Dong <eric.dong at intel.com>
Cc: Ray Ni <ray.ni at intel.com>
Cc: Brijesh Singh <brijesh.singh at amd.com>
Cc: Erdem Aktas <erdemaktas at google.com>
Cc: James Bottomley <jejb at linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao at intel.com>
Cc: Tom Lendacky <thomas.lendacky at amd.com>
Cc: Gerd Hoffmann <kraxel at redhat.com>
Signed-off-by: Min Xu <min.m.xu at intel.com>
---
 OvmfPkg/TdxDxe/TdxDxe.c   | 22 +++++++++++++++++++++-
 OvmfPkg/TdxDxe/TdxDxe.inf |  2 ++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/TdxDxe/TdxDxe.c b/OvmfPkg/TdxDxe/TdxDxe.c
index f0929998233c..2318db989792 100644
--- a/OvmfPkg/TdxDxe/TdxDxe.c
+++ b/OvmfPkg/TdxDxe/TdxDxe.c
@@ -23,6 +23,7 @@
 #include <Library/UefiLib.h>
 #include <Library/HobLib.h>
 #include <Protocol/Cpu.h>
+#include <Protocol/MpInitLibDepProtocols.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <ConfidentialComputingGuestAttr.h>
 #include <IndustryStandard/Tdx.h>
@@ -250,13 +251,32 @@ TdxDxeEntryPoint (
 
   if (!TdIsEnabled ()) {
     //
-    // If it is Non-Td guest, we're done.
+    // If it is Non-Td guest, we install gEfiMpInitLibMpDepProtocolGuid so that
+    // MpInitLib will be used in CpuDxe driver.
     //
+    gBS->InstallProtocolInterface (
+           &ImageHandle,
+           &gEfiMpInitLibMpDepProtocolGuid,
+           EFI_NATIVE_INTERFACE,
+           NULL
+           );
+
     return EFI_SUCCESS;
   }
 
   SetMmioSharedBit ();
 
+  //
+  // It is Td guest, we install gEfiMpInitLibUpDepProtocolGuid so that
+  // MpInitLibUp will be used in CpuDxe driver.
+  //
+  gBS->InstallProtocolInterface (
+         &ImageHandle,
+         &gEfiMpInitLibUpDepProtocolGuid,
+         EFI_NATIVE_INTERFACE,
+         NULL
+         );
+
   //
   // Call TDINFO to get actual number of cpus in domain
   //
diff --git a/OvmfPkg/TdxDxe/TdxDxe.inf b/OvmfPkg/TdxDxe/TdxDxe.inf
index 2ec2ef2ed5f2..a7e0abda1522 100644
--- a/OvmfPkg/TdxDxe/TdxDxe.inf
+++ b/OvmfPkg/TdxDxe/TdxDxe.inf
@@ -50,6 +50,8 @@
   gQemuAcpiTableNotifyProtocolGuid                 ## CONSUMES
   gEfiAcpiSdtProtocolGuid                          ## CONSUMES
   gEfiAcpiTableProtocolGuid                        ## CONSUMES
+  gEfiMpInitLibMpDepProtocolGuid
+  gEfiMpInitLibUpDepProtocolGuid
 
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase
-- 
2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89567): https://edk2.groups.io/g/devel/message/89567
Mute This Topic: https://groups.io/mt/90946719/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list