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