summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/Library/CcProbeLib
diff options
context:
space:
mode:
authorMin M Xu <min.m.xu@intel.com>2022-07-07 10:47:31 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-09-06 06:03:45 +0000
commitc4bc1a9498f4e176cefaeba3211287b444a53882 (patch)
treede8d899df7a801ac54dfb82ce493a6bba5cb161d /OvmfPkg/Library/CcProbeLib
parentc05a218a9758225ddf94eedb365633f2154551da (diff)
downloadedk2-c4bc1a9498f4e176cefaeba3211287b444a53882.tar.gz
OvmfPkg: Add SecPeiCcProbeLib
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3974 SecPeiCcProbeLib is designed to probe the Confidential Computing guest type in SEC/PEI phase. The CC guest type was set by each CC guest at the beginning of boot up and saved in PcdOvmfWorkArea. 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> Signed-off-by: Min Xu <min.m.xu@intel.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'OvmfPkg/Library/CcProbeLib')
-rw-r--r--OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.c31
-rw-r--r--OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf25
2 files changed, 56 insertions, 0 deletions
diff --git a/OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.c b/OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.c
new file mode 100644
index 0000000000..d698e5c8d7
--- /dev/null
+++ b/OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.c
@@ -0,0 +1,31 @@
+/** @file
+
+ CcProbeLib is used to probe the Confidential computing guest type.
+
+ Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/CcProbeLib.h>
+#include <WorkArea.h>
+
+/**
+ Probe the ConfidentialComputing Guest type. See defition of
+ CC_GUEST_TYPE in <ConfidentialComputingGuestAttr.h>.
+
+ @return The guest type
+
+**/
+UINT8
+EFIAPI
+CcProbe (
+ VOID
+ )
+{
+ OVMF_WORK_AREA *WorkArea;
+
+ WorkArea = (OVMF_WORK_AREA *)FixedPcdGet32 (PcdOvmfWorkAreaBase);
+
+ return WorkArea != NULL ? WorkArea->Header.GuestType : CcGuestTypeNonEncrypted;
+}
diff --git a/OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf b/OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf
new file mode 100644
index 0000000000..f63ed71e7c
--- /dev/null
+++ b/OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf
@@ -0,0 +1,25 @@
+## @file
+# CcProbeLib is used to probe Confidential Computing guest type.
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SecPeiCcProbeLib
+ FILE_GUID = 78eb7f2a-a42a-4b01-b160-5a05a0a52bac
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = CcProbeLib|SEC PEIM PEI_CORE
+
+[Sources]
+ SecPeiCcProbeLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[Pcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase