From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.24058.1653285360652591392 for ; Sun, 22 May 2022 22:56:03 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=WVqV38Rw; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653285362; x=1684821362; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0yQ3Ca4SieVYRglmuYPaAiHt4z61YYRb2zEETLdlHDg=; b=WVqV38Rw9u78Lhl+GG292nLh8Z/G04z4/PehCUQKm2U/amqLzLT2Zge0 xX/JCUSkKW/dDLv2a9DxMCIO7Qr3+URFZwgNqtB3AYYgeOOErIpE/HiY5 kWM9I4xQDD3Fzff9pX1+n2wwxPfrqM6JH7hg1xeEFYwaVdbpEU2Y4pgiy KC+KW9VRjIV6f8Eb1jcCVht6eDs2Q1YZtbbuFymFlfZFnmLF7JPe+jCOS Q/KRjnit6M7b82/OxBrw55MelJ7bP11BGio/34XmLZbOMerf5tkx49Cux mmUiYQHCSxBajr1Ij2XN7YwAgeb9cnTntdLAdPuZwiJ9Cm6oopdohafLE A==; X-IronPort-AV: E=McAfee;i="6400,9594,10355"; a="272833036" X-IronPort-AV: E=Sophos;i="5.91,245,1647327600"; d="scan'208";a="272833036" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2022 22:56:02 -0700 X-IronPort-AV: E=Sophos;i="5.91,245,1647327600"; d="scan'208";a="600459704" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.174.148]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2022 22:55:59 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Ard Biesheuvel , Jordan Justen , Ashish Kalra , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Sami Mujawar , Gerd Hoffmann Subject: [PATCH 1/4] OvmfPkg: Add library class BlobMeasurementLib with null implementation Date: Mon, 23 May 2022 13:55:39 +0800 Message-Id: <23b823d3e53725efb2f6b290973d905a7a020e34.1653284206.git.min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Jordan Justen Cc: Ashish Kalra Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Sami Mujawar Cc: Gerd Hoffmann Signed-off-by: Min Xu --- 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 +#include + +/** + 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 +#include + +/** + 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