]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Tcg/TcgSmm/TcgSmm.c
Fix the return status when physical presence variable and MemoryOverwriteRequestContr...
[mirror_edk2.git] / SecurityPkg / Tcg / TcgSmm / TcgSmm.c
index 6fa383d46d640f0cd5fab86073b8948087815daa..6080eff3b7b880346e0a2b37b0a0add1a4f5a348 100644 (file)
@@ -8,7 +8,7 @@
 \r
   PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check.\r
 \r
-Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials \r
 are licensed and made available under the terms and conditions of the BSD License \r
 which accompanies this distribution.  The full text of the license may be found at \r
@@ -68,6 +68,8 @@ PhysicalPresenceCallback (
                            &PpData\r
                            );\r
   if (EFI_ERROR (Status)) {\r
+    mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;\r
+    DEBUG ((EFI_D_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status));\r
     return EFI_SUCCESS;\r
   }\r
 \r
@@ -103,7 +105,23 @@ PhysicalPresenceCallback (
     }\r
     mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_SUCCESS;\r
   } else if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST) {\r
-    Flags = PpData.Flags;  \r
+    //\r
+    // Get the Physical Presence flags\r
+    //\r
+    DataSize = sizeof (UINT8);\r
+    Status = mSmmVariable->SmmGetVariable (\r
+                             PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
+                             &gEfiPhysicalPresenceGuid,\r
+                             NULL,\r
+                             &DataSize,\r
+                             &Flags\r
+                             );\r
+    if (EFI_ERROR (Status)) {\r
+      mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;\r
+      DEBUG ((EFI_D_ERROR, "[TPM] Get PP flags failure! Status = %r\n", Status));\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
     RequestConfirmed = FALSE;\r
 \r
     switch (mTcgNvs->PhysicalPresence.Request) {\r
@@ -211,6 +229,8 @@ MemoryClearCallback (
                              &MorControl\r
                              );\r
     if (EFI_ERROR (Status)) {\r
+      mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE;\r
+      DEBUG ((EFI_D_ERROR, "[TPM] Get MOR variable failure! Status = %r\n", Status));\r
       return EFI_SUCCESS;\r
     }\r
 \r
@@ -230,6 +250,7 @@ MemoryClearCallback (
                            );\r
   if (EFI_ERROR (Status)) { \r
     mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE;\r
+    DEBUG ((EFI_D_ERROR, "[TPM] Set MOR variable failure! Status = %r\n", Status));\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -309,7 +330,22 @@ PublishAcpiTable (
              );\r
   ASSERT_EFI_ERROR (Status);\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', 'c', 'g', 'T', 'a', 'b', 'l', 'e'));\r
+  CopyMem (Table->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Table->OemId) );\r
   mTcgNvs = AssignOpRegion (Table, SIGNATURE_32 ('T', 'N', 'V', 'S'), (UINT16) sizeof (TCG_NVS));\r
   ASSERT (mTcgNvs != NULL);\r
 \r
@@ -356,6 +392,11 @@ InitializeTcgSmm (
   EFI_SMM_SW_REGISTER_CONTEXT    SwContext;\r
   EFI_HANDLE                     SwHandle;\r
 \r
+  if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){\r
+    DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n"));\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
   Status = PublishAcpiTable ();\r
   ASSERT_EFI_ERROR (Status);\r
 \r