]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Add PrePiHobListPointerLibTdx
authorMin Xu <min.m.xu@intel.com>
Wed, 1 Dec 2021 07:52:31 +0000 (15:52 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 2 Apr 2022 10:09:47 +0000 (10:09 +0000)
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429

This library sets / gets the Hob list pointer in TDX_WORK_AREA.
This is because it is designed to be used in SEC where the value of
global variable cannot be saved, so the Hob list pointer is saved
in TDX_WORK_AREA.

TDX_WORK_AREA shares the same base address as SEV_WORK_AREA which is
pointed by PcdSevEsWorkAreaBase. This PCD will be renamed to
PcdCcWorkAreaBase as Gerd suggested.
See https://edk2.groups.io/g/devel/message/86642

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.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/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointer.c [new file with mode: 0644]
OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointerLibTdx.inf [new file with mode: 0644]

diff --git a/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointer.c b/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointer.c
new file mode 100644 (file)
index 0000000..1b41a39
--- /dev/null
@@ -0,0 +1,57 @@
+/** @file\r
+*\r
+*  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
+*  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+*\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/PrePiHobListPointerLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
+#include <WorkArea.h>\r
+\r
+/**\r
+  Returns the pointer to the HOB list.\r
+\r
+  This function returns the pointer to first HOB in the list.\r
+\r
+  @return The pointer to the HOB list.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+PrePeiGetHobList (\r
+  VOID\r
+  )\r
+{\r
+  TDX_WORK_AREA  *TdxWorkArea;\r
+\r
+  TdxWorkArea = (TDX_WORK_AREA *)(UINTN)FixedPcdGet32 (PcdSevEsWorkAreaBase);\r
+  ASSERT (TdxWorkArea != NULL);\r
+  ASSERT (TdxWorkArea->SecTdxWorkArea.HobList != 0);\r
+\r
+  return (VOID *)(UINTN)TdxWorkArea->SecTdxWorkArea.HobList;\r
+}\r
+\r
+/**\r
+  Updates the pointer to the HOB list.\r
+\r
+  @param  HobList       Hob list pointer to store\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PrePeiSetHobList (\r
+  IN  VOID  *HobList\r
+  )\r
+{\r
+  TDX_WORK_AREA  *TdxWorkArea;\r
+\r
+  TdxWorkArea = (TDX_WORK_AREA *)(UINTN)FixedPcdGet32 (PcdSevEsWorkAreaBase);\r
+  ASSERT (TdxWorkArea != NULL);\r
+\r
+  TdxWorkArea->SecTdxWorkArea.HobList = (UINTN)HobList;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointerLibTdx.inf b/OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointerLibTdx.inf
new file mode 100644 (file)
index 0000000..2667f84
--- /dev/null
@@ -0,0 +1,29 @@
+#/** @file\r
+#\r
+#  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PrePiHobListPointerLibTdx\r
+  FILE_GUID                      = 28297DB9-4CE7-4679-80E6-0270B215A2F2\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PrePiHobListPointerLib\r
+\r
+[Sources]\r
+  PrePiHobListPointer.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
+  EmbeddedPkg/EmbeddedPkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[Pcd]\r
+  gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase\r
+\r
+[LibraryClasses]\r
+  PcdLib\r