]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Remove redundant ASSERT in TcgDxe & TreeDxe. Some asserts are removed directly, some...
authorChao Zhang <chao.b.zhang@intel.com>
Fri, 31 Oct 2014 10:59:25 +0000 (10:59 +0000)
committerczhang46 <czhang46@Edk2>
Fri, 31 Oct 2014 10:59:25 +0000 (10:59 +0000)
ASSERT for SetupEventLog is kept. It is the foundation of TcgProtocol and TrEEProtocol

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16281 6f19259b-4bc3-4df7-8a09-765794883524

SecurityPkg/Tcg/TcgDxe/TcgDxe.c
SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c

index df9700a4d975c674f3ad24cbcfbd2c05960128d4..bf9c7521aaef71569a10af30d66322f36f4bcc41 100644 (file)
@@ -505,7 +505,10 @@ TcgDxeHashLogExtendEventI (
                (UINTN) HashDataLen,\r
                &NewEventHdr->Digest\r
                );\r
-    ASSERT_EFI_ERROR (Status);\r
+    if (EFI_ERROR(Status)) {\r
+      DEBUG ((DEBUG_ERROR, "TpmCommHashAll Failed. %x\n", Status));\r
+      return Status;\r
+    }\r
   }\r
 \r
   Status = TpmCommExtend (\r
@@ -745,9 +748,7 @@ MeasureHandoffTables (
              (VOID **) &SmbiosTable\r
              );\r
 \r
-  if (!EFI_ERROR (Status)) {\r
-    ASSERT (SmbiosTable != NULL);\r
-\r
+  if (!EFI_ERROR (Status) && SmbiosTable != NULL) {\r
     TcgEvent.PCRIndex  = 1;\r
     TcgEvent.EventType = EV_EFI_HANDOFF_TABLES;\r
     TcgEvent.EventSize = sizeof (HandoffTables);\r
@@ -1023,9 +1024,11 @@ MeasureAllBootVariables (
   if (Status == EFI_NOT_FOUND) {\r
     return EFI_SUCCESS;\r
   }\r
-  ASSERT (BootOrder != NULL);\r
 \r
   if (EFI_ERROR (Status)) {\r
+    //\r
+    // BootOrder can't be NULL if status is not EFI_NOT_FOUND\r
+    //\r
     FreePool (BootOrder);\r
     return Status;\r
   }\r
@@ -1091,14 +1094,18 @@ OnReadyToBoot (
     Status = TcgMeasureAction (\r
                EFI_CALLING_EFI_APPLICATION\r
                );\r
-    ASSERT_EFI_ERROR (Status);\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_CALLING_EFI_APPLICATION));\r
+    }\r
 \r
     //\r
     // 2. Draw a line between pre-boot env and entering post-boot env.\r
     //\r
     for (PcrIndex = 0; PcrIndex < 8; PcrIndex++) {\r
       Status = MeasureSeparatorEvent (PcrIndex);\r
-      ASSERT_EFI_ERROR (Status);\r
+      if (EFI_ERROR (Status)) {\r
+        DEBUG ((EFI_D_ERROR, "Seperator Event not Measured. Error!\n"));\r
+      }\r
     }\r
 \r
     //\r
@@ -1119,7 +1126,9 @@ OnReadyToBoot (
     Status = TcgMeasureAction (\r
                EFI_RETURNING_FROM_EFI_APPLICATOIN\r
                );\r
-    ASSERT_EFI_ERROR (Status);\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_RETURNING_FROM_EFI_APPLICATOIN));\r
+    }\r
   }\r
 \r
   DEBUG ((EFI_D_INFO, "TPM TcgDxe Measure Data when ReadyToBoot\n"));\r
@@ -1198,7 +1207,10 @@ InstallAcpiTable (
                             &TableKey\r
                             );\r
   }\r
-  ASSERT_EFI_ERROR (Status);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG((EFI_D_ERROR, "Tcg Acpi Table installation failure"));\r
+  }\r
 }\r
 \r
 /**\r
@@ -1225,7 +1237,9 @@ OnExitBootServices (
   Status = TcgMeasureAction (\r
              EFI_EXIT_BOOT_SERVICES_INVOCATION\r
              );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_INVOCATION));\r
+  }\r
 \r
   //\r
   // Measure success of ExitBootServices\r
@@ -1233,7 +1247,9 @@ OnExitBootServices (
   Status = TcgMeasureAction (\r
              EFI_EXIT_BOOT_SERVICES_SUCCEEDED\r
              );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)){\r
+    DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_SUCCEEDED));\r
+  }\r
 }\r
 \r
 /**\r
@@ -1260,8 +1276,9 @@ OnExitBootServicesFailed (
   Status = TcgMeasureAction (\r
              EFI_EXIT_BOOT_SERVICES_FAILED\r
              );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
+  if (EFI_ERROR (Status)){\r
+    DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_FAILED));\r
+  }\r
 }\r
 \r
 /**\r
index 09f8a364ad3d811e8c74c9d17f140c4ff1cd077b..8db0fa0df01ddbe737b0c7c48d4bc8088fd456e5 100644 (file)
@@ -1109,9 +1109,7 @@ MeasureHandoffTables (
              (VOID **) &SmbiosTable\r
              );\r
 \r
-  if (!EFI_ERROR (Status)) {\r
-    ASSERT (SmbiosTable != NULL);\r
-\r
+  if (!EFI_ERROR (Status) && SmbiosTable != NULL) {\r
     TcgEvent.PCRIndex  = 1;\r
     TcgEvent.EventType = EV_EFI_HANDOFF_TABLES;\r
     TcgEvent.EventSize = sizeof (HandoffTables);\r
@@ -1225,8 +1223,6 @@ MeasureVariable (
   UINTN                             VarNameLength;\r
   EFI_VARIABLE_DATA_TREE            *VarLog;\r
 \r
-  ASSERT ((VarSize == 0 && VarData == NULL) || (VarSize != 0 && VarData != NULL));\r
-\r
   DEBUG ((EFI_D_ERROR, "TrEEDxe: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)PCRIndex, (UINTN)EventType));\r
   DEBUG ((EFI_D_ERROR, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid));\r
 \r
@@ -1318,10 +1314,12 @@ ReadAndMeasureVariable (
       *VarSize = 0;\r
     }\r
   } else {\r
+    //\r
+    // if status error, VarData is freed and set NULL by GetVariable2\r
+    //\r
     if (EFI_ERROR (Status)) {\r
-      return Status;\r
+      return EFI_NOT_FOUND;\r
     }\r
-    ASSERT (*VarData != NULL);\r
   }\r
 \r
   Status = MeasureVariable (\r
@@ -1428,9 +1426,11 @@ MeasureAllBootVariables (
   if (Status == EFI_NOT_FOUND) {\r
     return EFI_SUCCESS;\r
   }\r
-  ASSERT (BootOrder != NULL);\r
 \r
   if (EFI_ERROR (Status)) {\r
+    //\r
+    // BootOrder can't be NULL if status is not EFI_NOT_FOUND\r
+    //\r
     FreePool (BootOrder);\r
     return Status;\r
   }\r
@@ -1721,7 +1721,10 @@ InstallAcpiTable (
                             &TableKey\r
                             );\r
   }\r
-  ASSERT_EFI_ERROR (Status);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG((EFI_D_ERROR, "Tcg Acpi Table installation failure"));\r
+  }\r
 }\r
 \r
 /**\r
@@ -1748,7 +1751,9 @@ OnExitBootServices (
   Status = TcgMeasureAction (\r
              EFI_EXIT_BOOT_SERVICES_INVOCATION\r
              );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_INVOCATION));\r
+  }\r
 \r
   //\r
   // Measure success of ExitBootServices\r
@@ -1756,7 +1761,9 @@ OnExitBootServices (
   Status = TcgMeasureAction (\r
              EFI_EXIT_BOOT_SERVICES_SUCCEEDED\r
              );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_SUCCEEDED));\r
+  }\r
 }\r
 \r
 /**\r
@@ -1783,7 +1790,9 @@ OnExitBootServicesFailed (
   Status = TcgMeasureAction (\r
              EFI_EXIT_BOOT_SERVICES_FAILED\r
              );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_FAILED));\r
+  }\r
 \r
 }\r
 \r