]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
Fix TCG PPI request EnableActivateClear failure.
[mirror_edk2.git] / SecurityPkg / Library / DxeTcgPhysicalPresenceLib / DxeTcgPhysicalPresenceLib.c
index 18d87ebe745ef7891a6a6a0bf0239656e7e3c709..515b0a5d7231ef5cd43505d5f4c9f1ee346df60b 100644 (file)
@@ -2,7 +2,7 @@
 \r
   Execute pending TPM requests from OS or BIOS and Lock TPM.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, 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
@@ -393,16 +393,23 @@ ExecutePhysicalPresence (
       return 0;\r
   \r
     case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:\r
-      TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_ENABLE_ACTIVATE, PpiFlags);\r
-      if (TpmResponse == 0) {\r
+      //\r
+      // PHYSICAL_PRESENCE_ENABLE_ACTIVATE + PHYSICAL_PRESENCE_CLEAR\r
+      // PHYSICAL_PRESENCE_CLEAR will be executed after reboot.\r
+      //\r
+      if ((*PpiFlags & FLAG_RESET_TRACK) == 0) {\r
+        TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_ENABLE_ACTIVATE, PpiFlags);\r
+        *PpiFlags |= FLAG_RESET_TRACK;\r
+      } else {\r
         TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_CLEAR, PpiFlags);\r
+        *PpiFlags &= ~FLAG_RESET_TRACK;\r
       }\r
       return TpmResponse;\r
 \r
     case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:\r
       //\r
       // PHYSICAL_PRESENCE_ENABLE_ACTIVATE + PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE\r
-      // PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE will be executed atfer reboot.\r
+      // PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE will be executed after reboot.\r
       //\r
       if ((*PpiFlags & FLAG_RESET_TRACK) == 0) {\r
         TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_ENABLE_ACTIVATE, PpiFlags);\r
@@ -936,6 +943,23 @@ ExecutePendingTpmRequest (
     case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_FALSE:\r
       RequestConfirmed = TRUE;\r
       break;\r
+      \r
+    default:\r
+      //\r
+      // Invalid operation request.\r
+      //\r
+      TcgPpData->PPResponse = TPM_PP_BIOS_FAILURE;\r
+      TcgPpData->LastPPRequest = TcgPpData->PPRequest;\r
+      TcgPpData->PPRequest = PHYSICAL_PRESENCE_NO_ACTION;\r
+      DataSize = sizeof (EFI_PHYSICAL_PRESENCE);\r
+      Status = gRT->SetVariable (\r
+                      PHYSICAL_PRESENCE_VARIABLE,\r
+                      &gEfiPhysicalPresenceGuid,\r
+                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                      DataSize,\r
+                      TcgPpData\r
+                      );\r
+      return;\r
   }\r
 \r
   if ((Flags & FLAG_RESET_TRACK) != 0) {\r
@@ -965,7 +989,7 @@ ExecutePendingTpmRequest (
   //\r
   if ((TcgPpData->Flags & FLAG_RESET_TRACK) == 0) {\r
     TcgPpData->LastPPRequest = TcgPpData->PPRequest;\r
-    TcgPpData->PPRequest = 0;    \r
+    TcgPpData->PPRequest = PHYSICAL_PRESENCE_NO_ACTION;    \r
   }\r
 \r
   //\r
@@ -1004,7 +1028,7 @@ ExecutePendingTpmRequest (
     case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:      \r
       break;\r
     default:\r
-      if (TcgPpData->PPRequest != 0) {\r
+      if (TcgPpData->PPRequest != PHYSICAL_PRESENCE_NO_ACTION) {\r
         break;\r
       }\r
       return;\r