]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/IntelTdx: Add TdxHelperLibNull
authorMin M Xu <min.m.xu@intel.com>
Fri, 3 Feb 2023 03:31:37 +0000 (11:31 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 4 Feb 2023 03:38:15 +0000 (03:38 +0000)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4243

TdxHelperLib provides below helper functions for a td-guest.
 - TdxHelperProcessTdHob
 - TdxHelperMeasureTdHob
 - TdxHelperMeasureCfvImage
 - TdxHelperBuildGuidHobForTdxMeasurement

TdxHelperLibNull is the NULL instance of TdxHelperLib.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Michael Roth <michael.roth@amd.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
OvmfPkg/Include/Library/TdxHelperLib.h [new file with mode: 0644]
OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperLibNull.inf [new file with mode: 0644]
OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperNull.c [new file with mode: 0644]
OvmfPkg/OvmfPkg.dec

diff --git a/OvmfPkg/Include/Library/TdxHelperLib.h b/OvmfPkg/Include/Library/TdxHelperLib.h
new file mode 100644 (file)
index 0000000..199aade
--- /dev/null
@@ -0,0 +1,70 @@
+/** @file\r
+  TdxHelperLib header file\r
+\r
+  Copyright (c) 2021 - 2023, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef TDX_HELPER_LIB_H\r
+#define TDX_HELPER_LIB_H\r
+\r
+#include <PiPei.h>\r
+\r
+/**\r
+  In Tdx guest, some information need to be passed from host VMM to guest\r
+  firmware. For example, the memory resource, etc. These information are\r
+  prepared by host VMM and put in TdHob which is described in TdxMetadata.\r
+  TDVF processes the TdHob to accept memories.\r
+\r
+  @retval   EFI_SUCCESS   Successfully process the TdHob\r
+  @retval   Others        Other error as indicated\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TdxHelperProcessTdHob (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  In Tdx guest, TdHob is passed from host VMM to guest firmware and it contains\r
+  the information of the memory resource. From the security perspective before\r
+  it is consumed, it should be measured and extended.\r
+ *\r
+ * @retval EFI_SUCCESS Successfully measure the TdHob\r
+ * @retval Others      Other error as indicated\r
+ */\r
+EFI_STATUS\r
+EFIAPI\r
+TdxHelperMeasureTdHob (\r
+  VOID\r
+  );\r
+\r
+/**\r
+ * In Tdx guest, Configuration FV (CFV) is treated as external input because it\r
+ * may contain the data provided by VMM. From the sucurity perspective Cfv image\r
+ * should be measured before it is consumed.\r
+ *\r
+ * @retval EFI_SUCCESS Successfully measure the CFV image\r
+ * @retval Others      Other error as indicated\r
+ */\r
+EFI_STATUS\r
+EFIAPI\r
+TdxHelperMeasureCfvImage (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Build the GuidHob for tdx measurements which were done in SEC phase.\r
+  The measurement values are stored in WorkArea.\r
+\r
+  @retval EFI_SUCCESS  The GuidHob is built successfully\r
+  @retval Others       Other errors as indicated\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TdxHelperBuildGuidHobForTdxMeasurement (\r
+  VOID\r
+  );\r
+\r
+#endif\r
diff --git a/OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperLibNull.inf b/OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperLibNull.inf
new file mode 100644 (file)
index 0000000..27d07b3
--- /dev/null
@@ -0,0 +1,32 @@
+## @file\r
+#  TdxHelperLib NULL instance\r
+#\r
+#  Copyright (c) 2021 - 2023, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = TdxHelperLibNull\r
+  FILE_GUID                      = 853603b2-53ea-463d-93e6-35d09a79e358\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = TdxHelperLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = X64\r
+#\r
+\r
+[Sources]\r
+  TdxHelperNull.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
diff --git a/OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperNull.c b/OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperNull.c
new file mode 100644 (file)
index 0000000..a212519
--- /dev/null
@@ -0,0 +1,79 @@
+/** @file\r
+  NULL instance of TdxHelperLib\r
+\r
+  Copyright (c) 2022 - 2023, Intel Corporation. All rights reserved.<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Base.h>\r
+#include <PiPei.h>\r
+\r
+/**\r
+  In Tdx guest, some information need to be passed from host VMM to guest\r
+  firmware. For example, the memory resource, etc. These information are\r
+  prepared by host VMM and put in TdHob which is described in TdxMetadata.\r
+  TDVF processes the TdHob to accept memories.\r
+\r
+  @retval   EFI_SUCCESS   Successfully process the TdHob\r
+  @retval   Others        Other error as indicated\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TdxHelperProcessTdHob (\r
+  VOID\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  In Tdx guest, TdHob is passed from host VMM to guest firmware and it contains\r
+  the information of the memory resource. From the security perspective before\r
+  it is consumed, it should be measured and extended.\r
+ *\r
+ * @retval EFI_SUCCESS Successfully measure the TdHob\r
+ * @retval Others      Other error as indicated\r
+ */\r
+EFI_STATUS\r
+EFIAPI\r
+TdxHelperMeasureTdHob (\r
+  VOID\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+ * In Tdx guest, Configuration FV (CFV) is treated as external input because it\r
+ * may contain the data provided by VMM. From the sucurity perspective Cfv image\r
+ * should be measured before it is consumed.\r
+ *\r
+ * @retval EFI_SUCCESS Successfully measure the CFV image\r
+ * @retval Others      Other error as indicated\r
+ */\r
+EFI_STATUS\r
+EFIAPI\r
+TdxHelperMeasureCfvImage (\r
+  VOID\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Build the GuidHob for tdx measurements which were done in SEC phase.\r
+  The measurement values are stored in WorkArea.\r
+\r
+  @retval EFI_SUCCESS  The GuidHob is built successfully\r
+  @retval Others       Other errors as indicated\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TdxHelperBuildGuidHobForTdxMeasurement (\r
+  VOID\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
index a22eb246c6252880464b383ca8b16a177e05c27d..be30547474ae3cb75b0730c16619ac3173cc79e3 100644 (file)
   #\r
   SerializeVariablesLib|Include/Library/SerializeVariablesLib.h\r
 \r
+  ##  @libraryclass  TdxHelper\r
+  #\r
+  TdxHelperLib|Include/Library/TdxHelperLib.h\r
+\r
   ##  @libraryclass  Declares utility functions for virtio device drivers.\r
   VirtioLib|Include/Library/VirtioLib.h\r
 \r