]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Call CcProbe in SecMain.c instead of TsIsEnabled
authorMin Xu <min.m.xu@intel.com>
Tue, 19 Apr 2022 00:26:28 +0000 (08:26 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 19 Apr 2022 01:26:08 +0000 (01:26 +0000)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3902

TdIsEnabled() uses the CPUID instruction. At this point, exception
handling is not established and a CPUID instruction will generate
a #VC and cause the booting guest to crash.

CcProbe() checks Ovmf work area to return the guest type. So call
of CcProbe() instead of TdIsEnabled() to fix the above issue.

Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
OvmfPkg/IntelTdx/Sec/SecMain.c
OvmfPkg/IntelTdx/Sec/SecMain.inf
OvmfPkg/Sec/SecMain.c
OvmfPkg/Sec/SecMain.inf

index 26d56be335e13a8c82cdf795a0e398734eba3fc7..ab01ec9ab19c796738d41a0eb2b5754b4c7d890c 100644 (file)
@@ -25,7 +25,7 @@
 #include <Library/CpuExceptionHandlerLib.h>\r
 #include <IndustryStandard/Tdx.h>\r
 #include <Library/PlatformInitLib.h>\r
-\r
+#include <Library/CcProbeLib.h>\r
 #include <Library/PeilessStartupLib.h>\r
 \r
 #define SEC_IDT_ENTRY_COUNT  34\r
@@ -61,7 +61,7 @@ SecCoreStartupWithStack (
   UINT32                Index;\r
   volatile UINT8        *Table;\r
 \r
-  if (TdIsEnabled ()) {\r
+  if (CcProbe () == CcGuestTypeIntelTdx) {\r
     //\r
     // For Td guests, the memory map info is in TdHobLib. It should be processed\r
     // first so that the memory is accepted. Otherwise access to the unaccepted\r
@@ -119,7 +119,7 @@ SecCoreStartupWithStack (
   //\r
   AsmWriteIdtr (&IdtDescriptor);\r
 \r
-  if (TdIsEnabled ()) {\r
+  if (CcProbe () == CcGuestTypeIntelTdx) {\r
     //\r
     // InitializeCpuExceptionHandlers () should be called in Td guests so that\r
     // #VE exceptions can be handled correctly.\r
index df2e749c350535741823d2082664bbec3e4c1278..9cf1249d02e54fabf5eeecc1fd0f1d97cbb1d526 100644 (file)
@@ -49,6 +49,7 @@
   CpuExceptionHandlerLib\r
   PeilessStartupLib\r
   PlatformInitLib\r
+  CcProbeLib\r
 \r
 [Pcd]\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase\r
index ca9717a7b526f8544df0d54c6dee4381250ccff0..8949d10157087ba485dfd35aa70d7cbf761cb98d 100644 (file)
@@ -28,6 +28,7 @@
 #include <Library/CpuExceptionHandlerLib.h>\r
 #include <Ppi/TemporaryRamSupport.h>\r
 #include <Library/PlatformInitLib.h>\r
+#include <Library/CcProbeLib.h>\r
 #include "AmdSev.h"\r
 \r
 #define SEC_IDT_ENTRY_COUNT  34\r
@@ -738,7 +739,7 @@ SecCoreStartupWithStack (
   volatile UINT8        *Table;\r
 \r
  #if defined (TDX_GUEST_SUPPORTED)\r
-  if (TdIsEnabled ()) {\r
+  if (CcProbe () == CcGuestTypeIntelTdx) {\r
     //\r
     // For Td guests, the memory map info is in TdHobLib. It should be processed\r
     // first so that the memory is accepted. Otherwise access to the unaccepted\r
@@ -828,7 +829,7 @@ SecCoreStartupWithStack (
   }\r
 \r
  #if defined (TDX_GUEST_SUPPORTED)\r
-  if (TdIsEnabled ()) {\r
+  if (CcProbe () == CcGuestTypeIntelTdx) {\r
     //\r
     // InitializeCpuExceptionHandlers () should be called in Td guests so that\r
     // #VE exceptions can be handled correctly.\r
index 4b5b089ccd696efb812a8d015ae5cf00dda19f7f..27100595aecaa17e2b0702d5521a8d9a4376be89 100644 (file)
@@ -54,6 +54,7 @@
   LocalApicLib\r
   MemEncryptSevLib\r
   CpuExceptionHandlerLib\r
+  CcProbeLib\r
 \r
 [Ppis]\r
   gEfiTemporaryRamSupportPpiGuid                # PPI ALWAYS_PRODUCED\r