summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMin Xu <min.m.xu@intel.com>2022-04-19 08:26:25 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-04-19 01:26:08 +0000
commit2f44d77c685bff190661393b5e14cb7da2851946 (patch)
treeff8a415c3cb822eea00daa184c13a9c38a4f8044
parent74a3eb975da7059b825c84bed759d2845de8de68 (diff)
downloadedk2-2f44d77c685bff190661393b5e14cb7da2851946.tar.gz
edk2-2f44d77c685bff190661393b5e14cb7da2851946.tar.bz2
edk2-2f44d77c685bff190661393b5e14cb7da2851946.zip
OvmfPkg: Add CcProbeLib
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3902 This is the OvmfPkg specific CcProbeLib. It checks the Ovmf WorkArea (PcdOvmfWorkAreaBase) to return the guest type. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Cc: James Bottomley <jejb@linux.ibm.com> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Brijesh Singh <brijesh.singh@amd.com> Cc: Erdem Aktas <erdemaktas@google.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Min Xu <min.m.xu@intel.com>
-rw-r--r--OvmfPkg/Library/CcProbeLib/CcProbeLib.c31
-rw-r--r--OvmfPkg/Library/CcProbeLib/CcProbeLib.inf25
2 files changed, 56 insertions, 0 deletions
diff --git a/OvmfPkg/Library/CcProbeLib/CcProbeLib.c b/OvmfPkg/Library/CcProbeLib/CcProbeLib.c
new file mode 100644
index 0000000000..d698e5c8d7
--- /dev/null
+++ b/OvmfPkg/Library/CcProbeLib/CcProbeLib.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/CcProbeLib.inf b/OvmfPkg/Library/CcProbeLib/CcProbeLib.inf
new file mode 100644
index 0000000000..5300c9ba26
--- /dev/null
+++ b/OvmfPkg/Library/CcProbeLib/CcProbeLib.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 = CcProbeLib
+ FILE_GUID = 05184ec9-abb0-4491-8584-e388639a7c48
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = CcProbeLib
+
+[Sources]
+ CcProbeLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[Pcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase