diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-01-04 02:11:51 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-01-04 02:11:51 +0000 |
commit | 822360ee34e8b3e9274f371bc6cc020181851af6 (patch) | |
tree | 4be50127554b2a9952de692a98666f6a716828c3 /MdeModulePkg/Core/Dxe | |
parent | fa7f89da6f2399a048e24de896887d0ca243bde3 (diff) | |
download | edk2-822360ee34e8b3e9274f371bc6cc020181851af6.zip edk2-822360ee34e8b3e9274f371bc6cc020181851af6.tar.gz edk2-822360ee34e8b3e9274f371bc6cc020181851af6.tar.bz2 |
Measure PEimage and ActionString data according to TPM requirement.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4494 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core/Dxe')
-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 765db57..f0f57fe 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 3bd6762..9257fba 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 87d98e8..0f785dd 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 13936a5..8ad1f9b 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 e38dfae..56c5fe5 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 (
|