]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/IntelTdx: Measure TdHob and Configuration FV in SecMain
authorMin M Xu <min.m.xu@intel.com>
Fri, 3 Feb 2023 03:31:43 +0000 (11:31 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 4 Feb 2023 03:38:15 +0000 (03:38 +0000)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4243

TdHob and Configuration FV (Cfv) are external inputs from VMM. From the
security perspective, they should be measured before they're consumed.
This patch measures TdHob and Cfv and stores the measurement values in
WorkArea.

After TdHob and Configuration FV (Cfv) are measured in SecMain, the
same measurements in PeilessStartupLib are deleted.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Michael Roth <michael.roth@amd.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
OvmfPkg/IntelTdx/IntelTdxX64.dsc
OvmfPkg/IntelTdx/Sec/SecMain.c
OvmfPkg/Library/PeilessStartupLib/PeilessStartup.c
OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf

index 920f1c6080d40269f999249f5fdd3e0e205317f6..41de2e9428171f662db63e0ac6813a85485d4e6f 100644 (file)
   OvmfPkg/IntelTdx/Sec/SecMain.inf {\r
     <LibraryClasses>\r
       NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
-      TpmMeasurementLib|SecurityPkg/Library/SecTpmMeasurementLib/SecTpmMeasurementLibTdx.inf\r
       NULL|OvmfPkg/IntelTdx/TdxHelperLib/SecTdxHelperLib.inf\r
       BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf\r
-      HashLib|SecurityPkg/Library/HashLibTdx/HashLibTdx.inf\r
-      NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf\r
   }\r
 \r
   #\r
index 41bd5c66ba29f8ec98b7a2b48a8a23e727e86bba..ccb217b709a002d0c31e7a62455f9b98c52ff9fe 100644 (file)
@@ -62,6 +62,19 @@ SecCoreStartupWithStack (
   volatile UINT8        *Table;\r
 \r
   if (CcProbe () == CcGuestTypeIntelTdx) {\r
+    //\r
+    // From the security perspective all the external input should be measured before\r
+    // it is consumed. TdHob and Configuration FV (Cfv) image are passed from VMM\r
+    // and should be measured here.\r
+    //\r
+    if (EFI_ERROR (TdxHelperMeasureTdHob ())) {\r
+      CpuDeadLoop ();\r
+    }\r
+\r
+    if (EFI_ERROR (TdxHelperMeasureCfvImage ())) {\r
+      CpuDeadLoop ();\r
+    }\r
+\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
index 79d3a178a65f2832256fa4f38fce6a8489ea629a..164aa2d61911e33cb8308c672654715f82828e85 100644 (file)
@@ -176,25 +176,7 @@ PeilessStartup (
 \r
   if (TdIsEnabled ()) {\r
     //\r
-    // Measure HobList\r
-    //\r
-    Status = TdxHelperMeasureTdHob ();\r
-    if (EFI_ERROR (Status)) {\r
-      ASSERT (FALSE);\r
-      CpuDeadLoop ();\r
-    }\r
-\r
-    //\r
-    // Measure Tdx CFV\r
-    //\r
-    Status = TdxHelperMeasureCfvImage ();\r
-    if (EFI_ERROR (Status)) {\r
-      ASSERT (FALSE);\r
-      CpuDeadLoop ();\r
-    }\r
-\r
-    //\r
-    // Build GuidHob for tdx measurement\r
+    // Build GuidHob for the tdx measurements which were done in SEC phase.\r
     //\r
     Status = TdxHelperBuildGuidHobForTdxMeasurement ();\r
     if (EFI_ERROR (Status)) {\r
index 4ced5dda99453cd057a92c2737da60a549cbc15f..e77ad7bc921e9f1a8b99ebae50f92b255d9be3b5 100644 (file)
@@ -56,8 +56,6 @@
   PrePiLib\r
   QemuFwCfgLib\r
   PlatformInitLib\r
-  HashLib\r
-  TpmMeasurementLib\r
 \r
 [Guids]\r
   gEfiHobMemoryAllocModuleGuid\r