]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Measure PEimage and ActionString data according to TPM requirement.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 4 Jan 2008 02:11:51 +0000 (02:11 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 4 Jan 2008 02:11:51 +0000 (02:11 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4494 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg/Core/Dxe/DxeMain.inf
MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
MdeModulePkg/Core/Dxe/Image.h
MdeModulePkg/Core/Dxe/Image/Image.c

index 765db57f0ce5ca3aa614ec9342f76ff64e300b7f..f0f57fe2074242e13af7529bdce00921c15ae543 100644 (file)
@@ -60,6 +60,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/Capsule.h>\r
 #include <Protocol/BusSpecificDriverOverride.h>\r
 #include <Protocol/Performance.h>\r
+#include <Uefi/UefiTcgPlatform.h>\r
+#include <Protocol/TcgPlatform.h>\r
 \r
 #include <Library/DxeCoreEntryPoint.h>\r
 #include <Library/DebugLib.h>\r
index 3bd6762c636c0c087ef1c283e1c0ce2d87310ea9..9257fbaed4e97becf5f96a584b08df29cbd93346 100644 (file)
   gEfiDevicePathProtocolGuid                    # PROTOCOL ALWAYS_CONSUMED\r
   gEfiLoadedImageProtocolGuid                   # PROTOCOL ALWAYS_PRODUCED\r
   gEfiEbcProtocolGuid                           # PROTOCOL SOMETIMES_CONSUMED\r
+  gEfiTcgPlatformProtocolGuid\r
 \r
 [FixedPcd.common]\r
   gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueDxeCoreEntry | 0x3041000          # EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT\r
index 87d98e8b02fdf3aacd6ff8a7eb7a2cc116df989c..0f785ddbe0d94db1f0da179c6a61ca75c806aec6 100644 (file)
@@ -753,12 +753,37 @@ Returns:
 --*/\r
 {\r
   EFI_STATUS    Status;\r
+  EFI_STATUS    StatusTemp;\r
+  EFI_TCG_PLATFORM_PROTOCOL *TcgPlatformProtocol;\r
+\r
+  //\r
+  // Measure invocation of ExitBootServices, \r
+  // which is defined by TCG_EFI_Platform_1_20_Final Specification\r
+  //\r
+  TcgPlatformProtocol = NULL;\r
+  Status = CoreLocateProtocol (\r
+             &gEfiTcgPlatformProtocolGuid,\r
+             NULL,\r
+             (VOID **) &TcgPlatformProtocol\r
+             );\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_INVOCATION);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
 \r
   //\r
   // Terminate memory services if the MapKey matches\r
   //\r
   Status = CoreTerminateMemoryMap (MapKey);\r
   if (EFI_ERROR (Status)) {\r
+    //\r
+    // Measure failure of ExitBootServices\r
+    //\r
+    if (TcgPlatformProtocol != NULL) {\r
+      StatusTemp = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_FAILED);\r
+      ASSERT_EFI_ERROR (StatusTemp);\r
+    }\r
+\r
     return Status;\r
   }\r
 \r
@@ -811,6 +836,14 @@ Returns:
   //\r
   gRuntime->AtRuntime = TRUE;\r
 \r
+  //\r
+  // Measure success of ExitBootServices\r
+  //\r
+  if (TcgPlatformProtocol != NULL) {\r
+    StatusTemp = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_SUCCEEDED);\r
+    ASSERT_EFI_ERROR (StatusTemp);\r
+  }\r
\r
   return Status;\r
 }\r
 \r
index 13936a518eb618c229edd59d4097e78f64ed7ce7..8ad1f9b72ec8be4288e01deed4768a4be3dfecfc 100644 (file)
@@ -223,6 +223,7 @@ Returns:
 \r
 EFI_STATUS\r
 CoreLoadPeImage (\r
+  IN  BOOLEAN                    BootPolicy,\r
   IN  VOID                       *Pe32Handle,\r
   IN  LOADED_IMAGE_PRIVATE_DATA  *Image,\r
   IN  EFI_PHYSICAL_ADDRESS       DstBuffer   OPTIONAL,\r
@@ -237,6 +238,7 @@ Routine Description:
 \r
 Arguments:\r
 \r
+  BootPolicy       - Policy for Open Image File.\r
   Pe32Handle       - The handle of PE32 image\r
   Image            - PE image to be loaded\r
   DstBuffer        - The buffer to store the image\r
index e38dfaed7b0669a941eb4d2565abc1ef0a0910f9..56c5fe5ea2812ca434eb22513fc30d7d3849dbe7 100644 (file)
@@ -169,6 +169,7 @@ Returns:
 \r
 EFI_STATUS\r
 CoreLoadPeImage (\r
+  IN BOOLEAN                     BootPolicy,  \r
   IN VOID                        *Pe32Handle,\r
   IN LOADED_IMAGE_PRIVATE_DATA   *Image,\r
   IN EFI_PHYSICAL_ADDRESS        DstBuffer    OPTIONAL,\r
@@ -182,7 +183,8 @@ Routine Description:
   Loads, relocates, and invokes a PE/COFF image\r
 \r
 Arguments:\r
-\r
+  BootPolicy       - If TRUE, indicates that the request originates from the boot manager,\r
+                     and that the boot manager is attempting to load FilePath as a boot selection.\r
   Pe32Handle       - The handle of PE32 image\r
   Image            - PE image to be loaded\r
   DstBuffer        - The buffer to store the image\r
@@ -201,9 +203,11 @@ Returns:
 \r
 --*/\r
 {\r
-  EFI_STATUS      Status;\r
-  BOOLEAN         DstBufAlocated;\r
-  UINTN           Size;\r
+  EFI_STATUS                Status;\r
+  BOOLEAN                   DstBufAlocated;\r
+  UINTN                     Size;\r
+  UINTN                     LinkTimeBase;\r
+  EFI_TCG_PLATFORM_PROTOCOL *TcgPlatformProtocol;\r
 \r
   ZeroMem (&Image->ImageContext, sizeof (Image->ImageContext));\r
 \r
@@ -247,6 +251,10 @@ Returns:
     Image->ImageContext.ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM;\r
     return EFI_UNSUPPORTED;\r
   }\r
+  //\r
+  // Get the image base address in the original PeImage.\r
+  //\r
+  LinkTimeBase = (UINTN) Image->ImageContext.ImageAddress;\r
 \r
   //\r
   // Allocate memory of the correct memory type aligned on the required image boundry\r
@@ -346,6 +354,28 @@ Returns:
     }\r
   }\r
 \r
+  //\r
+  // Measure the image before applying fixup\r
+  //\r
+  Status = CoreLocateProtocol (\r
+             &gEfiTcgPlatformProtocolGuid,\r
+             NULL,\r
+             (VOID **) &TcgPlatformProtocol\r
+             );\r
+  if (!EFI_ERROR (Status)) {    \r
+    Status = TcgPlatformProtocol->MeasurePeImage (\r
+                                    BootPolicy,\r
+                                    Image->ImageContext.ImageAddress,\r
+                                    (UINTN) Image->ImageContext.ImageSize,\r
+                                    LinkTimeBase,\r
+                                    Image->ImageContext.ImageType,\r
+                                    Image->Info.DeviceHandle,\r
+                                    Image->Info.FilePath\r
+                                    );\r
+    \r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
   //\r
   // Relocate the image in memory\r
   //\r
@@ -722,7 +752,7 @@ Returns:
   //\r
   // Load the image.  If EntryPoint is Null, it will not be set.\r
   //\r
-  Status = CoreLoadPeImage (&FHand, Image, DstBuffer, EntryPoint, Attribute);\r
+  Status = CoreLoadPeImage (BootPolicy, &FHand, Image, DstBuffer, EntryPoint, Attribute);\r
   if (EFI_ERROR (Status)) {\r
     if ((Status == EFI_BUFFER_TOO_SMALL) || (Status == EFI_OUT_OF_RESOURCES)) {\r
       if (NumberOfPages != NULL) {\r
@@ -904,9 +934,6 @@ Returns:
            );\r
 }\r
 \r
-\r
-\r
-\r
 EFI_STATUS\r
 EFIAPI\r
 CoreStartImage (\r