]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
SecurityPkg/Tcg2: Add Support Laml, Lasa for TPM2 ACPI.
[mirror_edk2.git] / SecurityPkg / Tcg / Tcg2Dxe / Tcg2Dxe.c
index aa463b287e79819d1f20cdc9f0d27795b8cbd3c8..85f2e0ae3809efd6ba412061b18db619aca7f997 100644 (file)
@@ -1,15 +1,9 @@
 /** @file\r
   This module implements Tcg2 Protocol.\r
 \r
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -1473,17 +1467,37 @@ SetupEventLog (
   for (Index = 0; Index < sizeof(mTcg2EventInfo)/sizeof(mTcg2EventInfo[0]); Index++) {\r
     if ((mTcgDxeData.BsCap.SupportedEventLogs & mTcg2EventInfo[Index].LogFormat) != 0) {\r
       mTcgDxeData.EventLogAreaStruct[Index].EventLogFormat = mTcg2EventInfo[Index].LogFormat;\r
-      Status = gBS->AllocatePages (\r
-                      AllocateAnyPages,\r
-                      EfiBootServicesData,\r
-                      EFI_SIZE_TO_PAGES (PcdGet32 (PcdTcgLogAreaMinLen)),\r
-                      &Lasa\r
-                      );\r
+      if (PcdGet8(PcdTpm2AcpiTableRev) >= 4) {\r
+        Status = gBS->AllocatePages (\r
+                        AllocateAnyPages,\r
+                        EfiACPIMemoryNVS,\r
+                        EFI_SIZE_TO_PAGES (PcdGet32 (PcdTcgLogAreaMinLen)),\r
+                        &Lasa\r
+                        );\r
+      } else {\r
+        Status = gBS->AllocatePages (\r
+                        AllocateAnyPages,\r
+                        EfiBootServicesData,\r
+                        EFI_SIZE_TO_PAGES (PcdGet32 (PcdTcgLogAreaMinLen)),\r
+                        &Lasa\r
+                        );\r
+      }\r
       if (EFI_ERROR (Status)) {\r
         return Status;\r
       }\r
       mTcgDxeData.EventLogAreaStruct[Index].Lasa = Lasa;\r
       mTcgDxeData.EventLogAreaStruct[Index].Laml = PcdGet32 (PcdTcgLogAreaMinLen);\r
+\r
+      if ((PcdGet8(PcdTpm2AcpiTableRev) >= 4) ||\r
+          (mTcg2EventInfo[Index].LogFormat == EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)) {\r
+        //\r
+        // Report TCG2 event log address and length, so that they can be reported in TPM2 ACPI table.\r
+        // Ignore the return status, because those fields are optional.\r
+        //\r
+        PcdSet32S(PcdTpm2AcpiTableLaml, (UINT32)mTcgDxeData.EventLogAreaStruct[Index].Laml);\r
+        PcdSet64S(PcdTpm2AcpiTableLasa, mTcgDxeData.EventLogAreaStruct[Index].Lasa);\r
+      }\r
+\r
       //\r
       // To initialize them as 0xFF is recommended\r
       // because the OS can know the last entry for that.\r
@@ -2314,10 +2328,10 @@ OnReadyToBoot (
     //\r
     Status = TcgMeasureAction (\r
                4,\r
-               EFI_RETURNING_FROM_EFI_APPLICATOIN\r
+               EFI_RETURNING_FROM_EFI_APPLICATION\r
                );\r
     if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_RETURNING_FROM_EFI_APPLICATOIN));\r
+      DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_RETURNING_FROM_EFI_APPLICATION));\r
     }\r
 \r
     //\r
@@ -2425,10 +2439,7 @@ OnExitBootServicesFailed (
                                 EfiResetShutdown the data buffer starts with a Null-terminated\r
                                 string, optionally followed by additional binary data.\r
                                 The string is a description that the caller may use to further\r
-                                indicate the reason for the system reset. ResetData is only\r
-                                valid if ResetStatus is something other than EFI_SUCCESS\r
-                                unless the ResetType is EfiResetPlatformSpecific\r
-                                where a minimum amount of ResetData is always required.\r
+                                indicate the reason for the system reset.\r
                                 For a ResetType of EfiResetPlatformSpecific the data buffer\r
                                 also starts with a Null-terminated string that is followed\r
                                 by an EFI_GUID that describes the specific type of reset to perform.\r