-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TPM Replay FW CFG Input Channel library instance
Adds a new library instance for QEMU platforms that allows a TPM Replay event log to optionally be passed from the QEMU command line. See https://github.com/microsoft/mu_tiano_platforms/blob/main/Platforms/Docs/Q35/Features/feature_tpm_replay.md for more information about passing a TPM Replay log through the FW CFG interface. Signed-off-by: Michael Kubacki <[email protected]>
- Loading branch information
Showing
4 changed files
with
119 additions
and
3 deletions.
There are no files selected for viewing
Submodule MU
updated
12 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
QemuPkg/Library/BaseFwCfgInputChannelLib/BaseFwCfgInputChannelLib.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** @file | ||
QEMU FW CFG TPM Event Log Input Channel Library | ||
Allows a TPM replay log to be passed through the FW CFG interface on QEMU. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <Uefi.h> | ||
|
||
#include <IndustryStandard/QemuFwCfg.h> | ||
|
||
#include <Library/DebugLib.h> | ||
#include <Library/InputChannelLib.h> | ||
#include <Library/MemoryAllocationLib.h> | ||
#include <Library/QemuFwCfgLib.h> | ||
|
||
/** | ||
Retrieves a TPM Replay Event Log through a custom interface. | ||
This library instance returns a log from the QEMU FW CFG interface. | ||
https://www.qemu.org/docs/master/specs/fw_cfg.html | ||
@param[out] ReplayEventLog A pointer to a pointer to the buffer to hold the event log data. | ||
@param[out] ReplayEventLogSize The size of the data placed in the buffer. | ||
@retval EFI_SUCCESS The TPM Replay event log was returned successfully. | ||
@retval EFI_INVALID_PARAMETER A pointer argument given is NULL. | ||
@retval EFI_UNSUPPORTED The function is not implemented yet. The arguments are not used. | ||
@retval EFI_COMPROMISED_DATA The event log data found is not valid. | ||
@retval EFI_NOT_FOUND The event log data was not found. | ||
**/ | ||
EFI_STATUS | ||
EFIAPI | ||
GetReplayEventLogFromCustomInterface ( | ||
OUT VOID **ReplayEventLog, | ||
OUT UINTN *ReplayEventLogSize | ||
) | ||
{ | ||
EFI_STATUS Status; | ||
FIRMWARE_CONFIG_ITEM LogItem; | ||
UINTN LogSize; | ||
UINTN LogPageCount; | ||
VOID *LogBase; | ||
|
||
if ((ReplayEventLog == NULL) || (ReplayEventLogSize == NULL)) { | ||
return EFI_INVALID_PARAMETER; | ||
} | ||
|
||
Status = QemuFwCfgFindFile ("opt/tpmreplay", &LogItem, &LogSize); | ||
if (EFI_ERROR (Status)) { | ||
DEBUG ((DEBUG_ERROR, "[%a] - TPM Replay FW CFG event log not found (%r).\n", __func__, Status)); | ||
return EFI_NOT_FOUND; | ||
} | ||
|
||
DEBUG ((DEBUG_INFO, "[%a] - TPM Replay FW CFG log found. Item 0x%x of size 0x%x.\n", __func__, LogItem, LogSize)); | ||
|
||
LogPageCount = EFI_SIZE_TO_PAGES (LogSize); | ||
LogBase = AllocatePages (LogPageCount); | ||
if (LogBase == NULL) { | ||
ASSERT (LogBase != NULL); | ||
return EFI_OUT_OF_RESOURCES; | ||
} | ||
|
||
QemuFwCfgSelectItem (LogItem); | ||
QemuFwCfgReadBytes (LogSize, LogBase); | ||
|
||
*ReplayEventLog = LogBase; | ||
*ReplayEventLogSize = LogSize; | ||
|
||
return EFI_SUCCESS; | ||
} |
30 changes: 30 additions & 0 deletions
30
QemuPkg/Library/BaseFwCfgInputChannelLib/BaseFwCfgInputChannelLib.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## @file | ||
# FW CFG TPM Event Log Input Channel Library | ||
# | ||
# Copyright (c) Microsoft Corporation. | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = BaseFwCfgInputChannelLib | ||
FILE_GUID = 8B3828C5-DC85-49F0-8AF2-0F50391EC0BC | ||
MODULE_TYPE = BASE | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = InputChannelLib | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
SecurityPkg/SecurityPkg.dec | ||
QemuPkg/QemuPkg.dec | ||
TpmTestingPkg/TpmTestingPkg.dec | ||
|
||
[LibraryClasses] | ||
DebugLib | ||
MemoryAllocationLib | ||
QemuFwCfgLib | ||
|
||
[Sources] | ||
BaseFwCfgInputChannelLib.c |