]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
SecurityPkg: Fix TPM2 ACPI measurement.
[mirror_edk2.git] / SecurityPkg / Tcg / Tcg2Smm / Tcg2Smm.c
index bd786bf4791fb8c792ebb55cd0fd56a254a2516b..54966c83ce861319ccee39672041a9b3d5303f23 100644 (file)
@@ -664,7 +664,22 @@ PublishAcpiTable (
     ));\r
 \r
   //\r
-  // Update TPM2 HID before measuring it to PCR\r
+  // Measure to PCR[0] with event EV_POST_CODE ACPI DATA.\r
+  // The measurement has to be done before UpdateHID since TPM2 ACPI HID\r
+  // imply TPM Firmware Version. Otherwise, the PCR record would be\r
+  // different after TPM FW update.\r
+  //\r
+  TpmMeasureAndLogData(\r
+    0,\r
+    EV_POST_CODE,\r
+    EV_POSTCODE_INFO_ACPI_DATA,\r
+    ACPI_DATA_LEN,\r
+    Table,\r
+    TableSize\r
+    );\r
+\r
+  //\r
+  // Update TPM2 HID after measuring it to PCR\r
   //\r
   Status = UpdateHID(Table);\r
   if (EFI_ERROR(Status)) {\r
@@ -694,19 +709,6 @@ PublishAcpiTable (
     }\r
   }\r
 \r
-  //\r
-  // Measure to PCR[0] with event EV_POST_CODE ACPI DATA\r
-  //\r
-  TpmMeasureAndLogData(\r
-    0,\r
-    EV_POST_CODE,\r
-    EV_POSTCODE_INFO_ACPI_DATA,\r
-    ACPI_DATA_LEN,\r
-    Table,\r
-    TableSize\r
-    );\r
-\r
-\r
   ASSERT (Table->OemTableId == SIGNATURE_64 ('T', 'p', 'm', '2', 'T', 'a', 'b', 'l'));\r
   CopyMem (Table->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Table->OemId) );\r
   mTcgNvs = AssignOpRegion (Table, SIGNATURE_32 ('T', 'N', 'V', 'S'), (UINT16) sizeof (TCG_NVS));\r