BlobMeasurementLib will be used to measure blobs fetching from QEMU's firmware config (fw_cfg) in platforms which implments EFI_CC_MEASUREMENT_PROTOCOL.
The null implementation BlobMeasurementLibNull always return EFI_SUCCESS. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Ashish Kalra <ashish.ka...@amd.com> Cc: Brijesh Singh <brijesh.si...@amd.com> Cc: Erdem Aktas <erdemak...@google.com> Cc: James Bottomley <j...@linux.ibm.com> Cc: Jiewen Yao <jiewen....@intel.com> Cc: Tom Lendacky <thomas.lenda...@amd.com> Cc: Sami Mujawar <sami.muja...@arm.com> Cc: Gerd Hoffmann <kra...@redhat.com> Signed-off-by: Min Xu <min.m...@intel.com> --- OvmfPkg/Include/Library/BlobMeasurementLib.h | 38 +++++++++++++++++++ .../BlobMeasurementLibNull.c | 34 +++++++++++++++++ .../BlobMeasurementLibNull.inf | 24 ++++++++++++ OvmfPkg/OvmfPkg.dec | 3 ++ 4 files changed, 99 insertions(+) create mode 100644 OvmfPkg/Include/Library/BlobMeasurementLib.h create mode 100644 OvmfPkg/Library/BlobMeasurementLibNull/BlobMeasurementLibNull.c create mode 100644 OvmfPkg/Library/BlobMeasurementLibNull/BlobMeasurementLibNull.inf diff --git a/OvmfPkg/Include/Library/BlobMeasurementLib.h b/OvmfPkg/Include/Library/BlobMeasurementLib.h new file mode 100644 index 000000000000..e54a41c2c9c1 --- /dev/null +++ b/OvmfPkg/Include/Library/BlobMeasurementLib.h @@ -0,0 +1,38 @@ +/** @file + + Blob measurement library + + This library class allows measuring blobs from external sources, such as QEMU's firmware config. + + Copyright (C) 2022, Intel Corporation. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef BLOB_MEASUREMENT_LIB_H_ +#define BLOB_MEASUREMENT_LIB_H_ + +#include <Uefi/UefiBaseType.h> +#include <Base.h> + +/** + Measure blob from an external source. + + @param[in] BlobName The name of the blob + @param[in] BlobNameSize Size of the blob name + @param[in] BlobBase The data of the blob + @param[in] BlobSize The size of the blob in bytes + + @retval EFI_SUCCESS The blob was measured successfully. + @retval Other errors +**/ +EFI_STATUS +EFIAPI +MeasureKernelBlob ( + IN CONST CHAR16 *BlobName, + IN UINT32 BlobNameSize, + IN CONST VOID *BlobBase, + IN UINT32 BlobSize + ); + +#endif diff --git a/OvmfPkg/Library/BlobMeasurementLibNull/BlobMeasurementLibNull.c b/OvmfPkg/Library/BlobMeasurementLibNull/BlobMeasurementLibNull.c new file mode 100644 index 000000000000..e93e3cf164c0 --- /dev/null +++ b/OvmfPkg/Library/BlobMeasurementLibNull/BlobMeasurementLibNull.c @@ -0,0 +1,34 @@ +/** @file + + Null implementation of the blob measurement library. + + Copyright (C) 2022, Intel Corporation. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include <Library/BaseLib.h> +#include <Library/BlobMeasurementLib.h> + +/** + Measure blob from an external source. + + @param[in] BlobName The name of the blob + @param[in] BlobNameSize Size of the blob name + @param[in] BlobBase The data of the blob + @param[in] BlobSize The size of the blob in bytes + + @retval EFI_SUCCESS The blob was measured successfully. + @retval Other errors +**/ +EFI_STATUS +EFIAPI +MeasureKernelBlob ( + IN CONST CHAR16 *BlobName, + IN UINT32 BlobNameSize, + IN CONST VOID *BlobBase, + IN UINT32 BlobSize + ) +{ + return EFI_SUCCESS; +} diff --git a/OvmfPkg/Library/BlobMeasurementLibNull/BlobMeasurementLibNull.inf b/OvmfPkg/Library/BlobMeasurementLibNull/BlobMeasurementLibNull.inf new file mode 100644 index 000000000000..5bf3710222c2 --- /dev/null +++ b/OvmfPkg/Library/BlobMeasurementLibNull/BlobMeasurementLibNull.inf @@ -0,0 +1,24 @@ +## @file +# +# Null implementation of the blob measurement library. +# +# Copyright (C) 2022, Intel Corporation. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = BlobMeasurementLibNull + FILE_GUID = fad119ff-8627-4661-a35f-920a6eeb2866 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = BlobMeasurementLib + +[Sources] + BlobMeasurementLibNull.c + +[Packages] + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 8c2048051bea..da94e4c7aa89 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -26,6 +26,9 @@ ## @libraryclass Verify blobs read from the VMM BlobVerifierLib|Include/Library/BlobVerifierLib.h + ## @libraryclass Measure blobs read from the VMM + BlobMeasurementLib|Include/Library/BlobMeasurementLib.h + ## @libraryclass Loads and boots a Linux kernel image # LoadLinuxLib|Include/Library/LoadLinuxLib.h -- 2.29.2.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#89955): https://edk2.groups.io/g/devel/message/89955 Mute This Topic: https://groups.io/mt/91282947/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-