]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c
SecurityPkg: Tcg2Dxe: Report correct FinalEventLog size
[mirror_edk2.git] / SecurityPkg / Tcg / TrEEDxe / TrEEDxe.c
index 41e7207eaffac9065dec43bd8c0a8f8078dd18de..fb69fa1860e86320786c62f2c6606b09dc6bd03e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This module implements TrEE Protocol.\r
   \r
-Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2016, 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
@@ -55,8 +55,6 @@ typedef struct {
   EFI_GUID                               *VendorGuid;\r
 } VARIABLE_TYPE;\r
 \r
-#define  EFI_TCG_LOG_AREA_SIZE        0x10000\r
-\r
 #define  TREE_DEFAULT_MAX_COMMAND_SIZE        0x1000\r
 #define  TREE_DEFAULT_MAX_RESPONSE_SIZE       0x1000\r
 \r
@@ -181,6 +179,8 @@ EFI_HANDLE mImageHandle;
   PE/COFF image is external input, so this function will validate its data structure\r
   within this image buffer before use.\r
 \r
+  Notes: PE/COFF image is checked by BasePeCoffLib PeCoffLoaderGetImageInfo().\r
+\r
   @param[in]  PCRIndex       TPM PCR index\r
   @param[in]  ImageAddress   Start address of image buffer.\r
   @param[in]  ImageSize      Image size\r
@@ -624,41 +624,6 @@ TcgDxeLogEvent (
   return Status;\r
 }\r
 \r
-/**\r
-  This function get digest from digest list.\r
-\r
-  @param HashAlg    digest algorithm\r
-  @param DigestList digest list\r
-  @param Digest     digest\r
-\r
-  @retval EFI_SUCCESS   Sha1Digest is found and returned.\r
-  @retval EFI_NOT_FOUND Sha1Digest is not found.\r
-**/\r
-EFI_STATUS\r
-Tpm2GetDigestFromDigestList (\r
-  IN TPMI_ALG_HASH      HashAlg,\r
-  IN TPML_DIGEST_VALUES *DigestList,\r
-  IN VOID               *Digest\r
-  )\r
-{\r
-  UINTN  Index;\r
-  UINT16 DigestSize;\r
-\r
-  DigestSize = GetHashSizeFromAlgo (HashAlg);\r
-  for (Index = 0; Index < DigestList->count; Index++) {\r
-    if (DigestList->digests[Index].hashAlg == HashAlg) {\r
-      CopyMem (\r
-        Digest,\r
-        &DigestList->digests[Index].digest,\r
-        DigestSize\r
-        );\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
 /**\r
   Add a new entry to the Event Log.\r
 \r
@@ -686,7 +651,7 @@ TcgDxeLogHashEvent (
       DEBUG ((EFI_D_INFO, "  LogFormat - 0x%08x\n", mTreeEventInfo[Index].LogFormat));\r
       switch (mTreeEventInfo[Index].LogFormat) {\r
       case TREE_EVENT_LOG_FORMAT_TCG_1_2:\r
-        Status = Tpm2GetDigestFromDigestList (TPM_ALG_SHA1, DigestList, &NewEventHdr->Digest);\r
+        Status = GetDigestFromDigestList (TPM_ALG_SHA1, DigestList, &NewEventHdr->Digest);\r
         if (!EFI_ERROR (Status)) {\r
           //\r
           // Enter critical region\r
@@ -895,10 +860,10 @@ TreeSubmitCommand (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  if (InputParameterBlockSize >= mTcgDxeData.BsCap.MaxCommandSize) {\r
+  if (InputParameterBlockSize > mTcgDxeData.BsCap.MaxCommandSize) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  if (OutputParameterBlockSize >= mTcgDxeData.BsCap.MaxResponseSize) {\r
+  if (OutputParameterBlockSize > mTcgDxeData.BsCap.MaxResponseSize) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -949,19 +914,19 @@ SetupEventLog (
       Status = gBS->AllocatePages (\r
                       AllocateMaxAddress,\r
                       EfiACPIMemoryNVS,\r
-                      EFI_SIZE_TO_PAGES (EFI_TCG_LOG_AREA_SIZE),\r
+                      EFI_SIZE_TO_PAGES (PcdGet32 (PcdTcgLogAreaMinLen)),\r
                       &Lasa\r
                       );\r
       if (EFI_ERROR (Status)) {\r
         return Status;\r
       }\r
       mTcgDxeData.EventLogAreaStruct[Index].Lasa = Lasa;\r
-      mTcgDxeData.EventLogAreaStruct[Index].Laml = EFI_TCG_LOG_AREA_SIZE;\r
+      mTcgDxeData.EventLogAreaStruct[Index].Laml = PcdGet32 (PcdTcgLogAreaMinLen);\r
       //\r
       // To initialize them as 0xFF is recommended \r
       // because the OS can know the last entry for that.\r
       //\r
-      SetMem ((VOID *)(UINTN)Lasa, EFI_TCG_LOG_AREA_SIZE, 0xFF);\r
+      SetMem ((VOID *)(UINTN)Lasa, PcdGet32 (PcdTcgLogAreaMinLen), 0xFF);\r
   }\r
 \r
   //\r
@@ -969,10 +934,10 @@ SetupEventLog (
   //\r
     if (PcdGet8 (PcdTpmPlatformClass) == TCG_PLATFORM_TYPE_CLIENT) {\r
       mTcgClientAcpiTemplate.Lasa = mTcgDxeData.EventLogAreaStruct[0].Lasa;\r
-      mTcgClientAcpiTemplate.Laml = EFI_TCG_LOG_AREA_SIZE;\r
+      mTcgClientAcpiTemplate.Laml = PcdGet32 (PcdTcgLogAreaMinLen);\r
     } else {\r
       mTcgServerAcpiTemplate.Lasa = mTcgDxeData.EventLogAreaStruct[0].Lasa;\r
-      mTcgServerAcpiTemplate.Laml = EFI_TCG_LOG_AREA_SIZE;\r
+      mTcgServerAcpiTemplate.Laml = PcdGet32 (PcdTcgLogAreaMinLen);\r
     }\r
 \r
   //\r
@@ -1525,7 +1490,7 @@ OnReadyToBoot (
                EFI_CALLING_EFI_APPLICATION\r
                );\r
     if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_CALLING_EFI_APPLICATION));\r
+      DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_CALLING_EFI_APPLICATION));\r
     }\r
 \r
     //\r
@@ -1558,7 +1523,7 @@ OnReadyToBoot (
                EFI_RETURNING_FROM_EFI_APPLICATOIN\r
                );\r
     if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_RETURNING_FROM_EFI_APPLICATOIN));\r
+      DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_RETURNING_FROM_EFI_APPLICATOIN));\r
     }\r
   }\r
 \r
@@ -1671,7 +1636,7 @@ OnExitBootServices (
              EFI_EXIT_BOOT_SERVICES_INVOCATION\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_INVOCATION));\r
+    DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_INVOCATION));\r
   }\r
 \r
   //\r
@@ -1681,7 +1646,7 @@ OnExitBootServices (
              EFI_EXIT_BOOT_SERVICES_SUCCEEDED\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_SUCCEEDED));\r
+    DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_SUCCEEDED));\r
   }\r
 }\r
 \r
@@ -1710,7 +1675,7 @@ OnExitBootServicesFailed (
              EFI_EXIT_BOOT_SERVICES_FAILED\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "%s not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_FAILED));\r
+    DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_FAILED));\r
   }\r
 \r
 }\r