Revision: 17006
          http://sourceforge.net/p/edk2/code/17006
Author:   hwu1225
Date:     2015-03-04 02:24:52 +0000 (Wed, 04 Mar 2015)
Log Message:
-----------
Add performance optimization for Tcg/TrEE.

Add error check for Tcg/TrEE Pei/Dxe driver to avoid unnecessary hardware check 
for performance optimization.

(Sync patch r17004 from main trunk.)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <[email protected]>
Reviewed-by: "Zeng, Star" <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/17004

Modified Paths:
--------------
    branches/UDK2014.SP1/SecurityPkg/SecurityPkg.dec
    branches/UDK2014.SP1/SecurityPkg/Tcg/TcgDxe/TcgDxe.c
    branches/UDK2014.SP1/SecurityPkg/Tcg/TcgPei/TcgPei.c
    branches/UDK2014.SP1/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c
    branches/UDK2014.SP1/SecurityPkg/Tcg/TrEEPei/TrEEPei.c

Modified: branches/UDK2014.SP1/SecurityPkg/SecurityPkg.dec
===================================================================
--- branches/UDK2014.SP1/SecurityPkg/SecurityPkg.dec    2015-03-04 02:20:35 UTC 
(rev 17005)
+++ branches/UDK2014.SP1/SecurityPkg/SecurityPkg.dec    2015-03-04 02:24:52 UTC 
(rev 17006)
@@ -192,6 +192,7 @@
 # [Error.gEfiSecurityPkgTokenSpaceGuid]
 #   0x80000001 | Invalid value provided.
 #   0x80000002 | Reserved bits must be set to zero.
+#   0x80000003 | Incorrect progress or error code provided.
 #
 
 [PcdsFixedAtBuild, PcdsPatchableInModule]

Modified: branches/UDK2014.SP1/SecurityPkg/Tcg/TcgDxe/TcgDxe.c
===================================================================
--- branches/UDK2014.SP1/SecurityPkg/Tcg/TcgDxe/TcgDxe.c        2015-03-04 
02:20:35 UTC (rev 17005)
+++ branches/UDK2014.SP1/SecurityPkg/Tcg/TcgDxe/TcgDxe.c        2015-03-04 
02:24:52 UTC (rev 17006)
@@ -1355,6 +1355,11 @@
     return EFI_UNSUPPORTED;
   }
 
+  if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) {
+    DEBUG ((EFI_D_ERROR, "TPM error!\n"));
+    return EFI_DEVICE_ERROR;
+  }
+
   mTcgDxeData.TpmHandle = (TIS_TPM_HANDLE)(UINTN)TPM_BASE_ADDRESS;
   Status = TisPcRequestUseTpm (mTcgDxeData.TpmHandle);
   if (EFI_ERROR (Status)) {
@@ -1362,10 +1367,6 @@
     return Status;
   }
 
-  if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) {
-    mTcgDxeData.BsCap.TPMPresentFlag = FALSE;
-  }
-
   Status = GetTpmStatus (&mTcgDxeData.BsCap.TPMDeactivatedFlag);
   if (EFI_ERROR (Status)) {
     DEBUG ((

Modified: branches/UDK2014.SP1/SecurityPkg/Tcg/TcgPei/TcgPei.c
===================================================================
--- branches/UDK2014.SP1/SecurityPkg/Tcg/TcgPei/TcgPei.c        2015-03-04 
02:20:35 UTC (rev 17005)
+++ branches/UDK2014.SP1/SecurityPkg/Tcg/TcgPei/TcgPei.c        2015-03-04 
02:24:52 UTC (rev 17006)
@@ -752,6 +752,11 @@
     return EFI_UNSUPPORTED;
   }
 
+  if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) {
+    DEBUG ((EFI_D_ERROR, "TPM error!\n"));
+    return EFI_DEVICE_ERROR;
+  }
+
   //
   // Initialize TPM device
   //
@@ -808,6 +813,14 @@
   }
 
 Done:
+  if (EFI_ERROR (Status)) {
+    DEBUG ((EFI_D_ERROR, "TPM error! Build Hob\n"));
+    BuildGuidHob (&gTpmErrorHobGuid,0);
+    REPORT_STATUS_CODE (
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,
+      (PcdGet32 (PcdStatusCodeSubClassTpmDevice) | EFI_P_EC_INTERFACE_ERROR)
+      );
+  }
   //
   // Always intall TpmInitializationDonePpi no matter success or fail.
   // Other driver can know TPM initialization state by TpmInitializedPpi.

Modified: branches/UDK2014.SP1/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c
===================================================================
--- branches/UDK2014.SP1/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c      2015-03-04 
02:20:35 UTC (rev 17005)
+++ branches/UDK2014.SP1/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c      2015-03-04 
02:24:52 UTC (rev 17006)
@@ -1815,16 +1815,17 @@
     return EFI_UNSUPPORTED;
   }
 
+  if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) {
+    DEBUG ((EFI_D_ERROR, "TPM2 error!\n"));
+    return EFI_DEVICE_ERROR;
+  }
+  
   Status = Tpm2RequestUseTpm ();
   if (EFI_ERROR (Status)) {
-    DEBUG ((EFI_D_ERROR, "TPM not detected!\n"));
+    DEBUG ((EFI_D_ERROR, "TPM2 not detected!\n"));
     return Status;
   }
   
-  if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) {
-    mTcgDxeData.BsCap.TrEEPresentFlag = FALSE;
-  }
-
   //
   // Fill information
   //

Modified: branches/UDK2014.SP1/SecurityPkg/Tcg/TrEEPei/TrEEPei.c
===================================================================
--- branches/UDK2014.SP1/SecurityPkg/Tcg/TrEEPei/TrEEPei.c      2015-03-04 
02:20:35 UTC (rev 17005)
+++ branches/UDK2014.SP1/SecurityPkg/Tcg/TrEEPei/TrEEPei.c      2015-03-04 
02:24:52 UTC (rev 17006)
@@ -636,6 +636,11 @@
     return EFI_UNSUPPORTED;
   }
 
+  if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) {
+    DEBUG ((EFI_D_ERROR, "TPM2 error!\n"));
+    return EFI_DEVICE_ERROR;
+  }
+
   Status = PeiServicesGetBootMode (&BootMode);
   ASSERT_EFI_ERROR (Status);
 
@@ -701,6 +706,14 @@
   }
 
 Done:
+  if (EFI_ERROR (Status)) {
+    DEBUG ((EFI_D_ERROR, "TPM2 error! Build Hob\n"));
+    BuildGuidHob (&gTpmErrorHobGuid,0);
+    REPORT_STATUS_CODE (
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,
+      (PcdGet32 (PcdStatusCodeSubClassTpmDevice) | EFI_P_EC_INTERFACE_ERROR)
+      );
+  }
   //
   // Always intall TpmInitializationDonePpi no matter success or fail.
   // Other driver can know TPM initialization state by TpmInitializedPpi.


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to