mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
fa7f89da6f
commit
822360ee34
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -346,6 +354,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
|
||||
//
|
||||
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue