]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the return status when physical presence variable and MemoryOverwriteRequestContr...
authorDong Guo <guo.dong@intel.com>
Mon, 17 Mar 2014 05:46:53 +0000 (05:46 +0000)
committergdong1 <gdong1@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 17 Mar 2014 05:46:53 +0000 (05:46 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dong Guo <guo.dong@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15329 6f19259b-4bc3-4df7-8a09-765794883524

SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.c
SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.c
SecurityPkg/Tcg/TcgSmm/TcgSmm.c
SecurityPkg/Tcg/TrEESmm/TrEESmm.c

index ebc7367fae6e1506e5f8f5a842eeb0d0427e35f0..8a5e7d17c6fca9850ba1ae0be1bd982ef769652c 100644 (file)
@@ -8,7 +8,7 @@
 \r
   ExecutePendingTpmRequest() will receive untrusted input and do validation.\r
 \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 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
@@ -1059,6 +1059,9 @@ ExecutePendingTpmRequest (
                       sizeof (UINT8),\r
                       &NewFlags\r
                       ); \r
+    if (EFI_ERROR (Status)) {\r
+      return;\r
+    }\r
   }\r
 \r
 \r
@@ -1162,19 +1165,20 @@ TcgPhysicalPresenceLibProcessRequest (
                   &PpiFlags\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    if (Status == EFI_NOT_FOUND) {\r
-      PpiFlags = FLAG_NO_PPI_PROVISION;\r
-      Status   = gRT->SetVariable (\r
-                        PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
-                        &gEfiPhysicalPresenceGuid,\r
-                        EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                        sizeof (UINT8),\r
-                        &PpiFlags\r
-                        );\r
+    PpiFlags = FLAG_NO_PPI_PROVISION;\r
+    Status   = gRT->SetVariable (\r
+                      PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
+                      &gEfiPhysicalPresenceGuid,\r
+                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                      sizeof (UINT8),\r
+                      &PpiFlags\r
+                      );\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "[TPM] Set physical presence flag failed, Status = %r\n", Status));\r
+      return ;\r
     }\r
-    ASSERT_EFI_ERROR (Status);\r
   }\r
-      DEBUG ((EFI_D_ERROR, "[TPM] PpiFlags = %x, Status = %r\n", PpiFlags, Status));\r
+  DEBUG ((EFI_D_INFO, "[TPM] PpiFlags = %x\n", PpiFlags));\r
 \r
   //\r
   // This flags variable controls whether physical presence is required for TPM command. \r
@@ -1205,18 +1209,19 @@ TcgPhysicalPresenceLibProcessRequest (
                   &TcgPpData\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    if (Status == EFI_NOT_FOUND) {\r
-      ZeroMem ((VOID*)&TcgPpData, sizeof (TcgPpData));\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
+    ZeroMem ((VOID*)&TcgPpData, sizeof (TcgPpData));\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
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "[TPM] Set physical presence variable failed, Status = %r\n", Status));\r
+      return;\r
     }\r
-    ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
   DEBUG ((EFI_D_INFO, "[TPM] Flags=%x, PPRequest=%x\n", PpiFlags, TcgPpData.PPRequest));\r
index 28b809bce46a994f9f7d78adb9b1f14ec15527f0..b2b22e518b4c8a32e21681653a874dbd113ae479 100644 (file)
@@ -7,7 +7,7 @@
 \r
   TrEEExecutePendingTpmRequest() will receive untrusted input and do validation.\r
 \r
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 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
@@ -568,19 +568,20 @@ TrEEPhysicalPresenceLibProcessRequest (
                   &PpiFlags\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    if (Status == EFI_NOT_FOUND) {\r
-      PpiFlags = 0;\r
-      Status   = gRT->SetVariable (\r
-                        TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
-                        &gEfiTrEEPhysicalPresenceGuid,\r
-                        EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                        sizeof (UINT8),\r
-                        &PpiFlags\r
-                        );\r
+    PpiFlags = 0;\r
+    Status   = gRT->SetVariable (\r
+                      TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
+                      &gEfiTrEEPhysicalPresenceGuid,\r
+                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                      sizeof (UINT8),\r
+                      &PpiFlags\r
+                      );\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "[TPM2] Set physical presence flag failed, Status = %r\n", Status));\r
+      return ;\r
     }\r
-    ASSERT_EFI_ERROR (Status);\r
   }\r
-  DEBUG ((EFI_D_ERROR, "[TPM2] PpiFlags = %x, Status = %r\n", PpiFlags, Status));\r
+  DEBUG ((EFI_D_INFO, "[TPM2] PpiFlags = %x\n", PpiFlags));\r
 \r
   //\r
   // This flags variable controls whether physical presence is required for TPM command. \r
@@ -611,27 +612,28 @@ TrEEPhysicalPresenceLibProcessRequest (
                   &TcgPpData\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    if (Status == EFI_NOT_FOUND) {\r
-      ZeroMem ((VOID*)&TcgPpData, sizeof (TcgPpData));\r
-      DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE);\r
-      Status   = gRT->SetVariable (\r
-                        TREE_PHYSICAL_PRESENCE_VARIABLE,\r
-                        &gEfiTrEEPhysicalPresenceGuid,\r
-                        EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                        DataSize,\r
-                        &TcgPpData\r
-                        );\r
+    ZeroMem ((VOID*)&TcgPpData, sizeof (TcgPpData));\r
+    DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE);\r
+    Status   = gRT->SetVariable (\r
+                      TREE_PHYSICAL_PRESENCE_VARIABLE,\r
+                      &gEfiTrEEPhysicalPresenceGuid,\r
+                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                      DataSize,\r
+                      &TcgPpData\r
+                      );\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "[TPM2] Set physical presence variable failed, Status = %r\n", Status));\r
+      return ;\r
     }\r
-    ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
-  DEBUG ((EFI_D_ERROR, "[TPM2] Flags=%x, PPRequest=%x (LastPPRequest=%x)\n", PpiFlags, TcgPpData.PPRequest, TcgPpData.LastPPRequest));\r
+  DEBUG ((EFI_D_INFO, "[TPM2] Flags=%x, PPRequest=%x (LastPPRequest=%x)\n", PpiFlags, TcgPpData.PPRequest, TcgPpData.LastPPRequest));\r
 \r
   //\r
   // Execute pending TPM request.\r
   //  \r
   TrEEExecutePendingTpmRequest (PlatformAuth, &TcgPpData, PpiFlags);\r
-  DEBUG ((EFI_D_ERROR, "[TPM2] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags));\r
+  DEBUG ((EFI_D_INFO, "[TPM2] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags));\r
 \r
 }\r
 \r
index def965f13853cf1acdc84998307f5ab1294c5899..a4acc14e9a883f669d322237283a287984e2af84 100644 (file)
@@ -4,7 +4,7 @@
   This driver initilize MemoryOverwriteRequestControl variable. It \r
   will clear MOR_CLEAR_MEMORY_BIT bit if it is set.\r
 \r
-Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 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
@@ -35,6 +35,7 @@ OnReadyToBoot (
   IN      VOID                      *Context\r
   )\r
 {\r
+  EFI_STATUS  Status;\r
   UINTN       DataSize;\r
   \r
   if (MOR_CLEAR_MEMORY_VALUE (mMorControl) == 0x0) {\r
@@ -50,14 +51,16 @@ OnReadyToBoot (
   mMorControl &= 0xFE;  \r
 \r
   DataSize = sizeof (mMorControl);\r
-  gRT->SetVariable (\r
-         MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, \r
-         &gEfiMemoryOverwriteControlDataGuid, \r
-         EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-         DataSize, \r
-         &mMorControl\r
-         );\r
-\r
+  Status   = gRT->SetVariable (\r
+               MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, \r
+               &gEfiMemoryOverwriteControlDataGuid, \r
+               EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+               DataSize, \r
+               &mMorControl\r
+               );\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "TcgMor: Clear MOR_CLEAR_MEMORY_BIT failure, Status = %r\n"));\r
+  }\r
 }\r
 \r
 \r
@@ -98,7 +101,6 @@ MorDriverEntryPoint (
     // Set default value to 0\r
     //\r
     mMorControl = 0;\r
-    DEBUG ((EFI_D_INFO, "TcgMor: Create gEfiMemoryOverwriteControlDataGuid!\n"));\r
     Status = gRT->SetVariable (\r
                     MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, \r
                     &gEfiMemoryOverwriteControlDataGuid, \r
@@ -106,8 +108,7 @@ MorDriverEntryPoint (
                     DataSize, \r
                     &mMorControl\r
                     );\r
-    ASSERT_EFI_ERROR (Status);\r
-    \r
+    DEBUG ((EFI_D_INFO, "TcgMor: Create MOR variable! Status = %r\n", Status));\r
   } else {\r
     //\r
     // Create a Ready To Boot Event and Clear the MorControl bit in the call back function.\r
index 045c1846fc8446b10004100000bd3e79547c99b8..6080eff3b7b880346e0a2b37b0a0add1a4f5a348 100644 (file)
@@ -8,7 +8,7 @@
 \r
   PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check.\r
 \r
-Copyright (c) 2011 - 2013, 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
@@ -116,6 +118,7 @@ PhysicalPresenceCallback (
                              );\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
@@ -226,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
@@ -245,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
index 4826b7916dca3a41a4cf3335c67da7b4fe09dcc9..14303d5458da44035bfb3e245fd6b668751f7015 100644 (file)
@@ -9,7 +9,7 @@
 \r
   PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check.\r
 \r
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 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
@@ -84,6 +84,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
@@ -116,6 +118,7 @@ PhysicalPresenceCallback (
 \r
     if (EFI_ERROR (Status)) { \r
       mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;\r
+      DEBUG ((EFI_D_ERROR, "[TPM] Set PP variable failure! Status = %r\n", Status));\r
       return EFI_SUCCESS;\r
     }\r
     mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_SUCCESS;\r
@@ -133,6 +136,7 @@ PhysicalPresenceCallback (
                              );\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
@@ -220,6 +224,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
@@ -239,6 +245,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