BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3902
This is the OvmfPkg specific TdProbeLib. It checks the Ovmf WorkArea (PcdOvmfWorkAreaBase) to determine if the working system is of Td guest. Cc: Michael D Kinney <[email protected]> Cc: Liming Gao <[email protected]> Cc: Zhiguang Liu <[email protected]> Cc: James Bottomley <[email protected]> Cc: James Bottomley <[email protected]> Cc: Jiewen Yao <[email protected]> Cc: Gerd Hoffmann <[email protected]> Cc: Brijesh Singh <[email protected]> Cc: Erdem Aktas <[email protected]> Cc: Tom Lendacky <[email protected]> Signed-off-by: Min Xu <[email protected]> --- OvmfPkg/IntelTdx/TdProbeLib/TdProbeLib.c | 38 ++++++++++++++++++++++ OvmfPkg/IntelTdx/TdProbeLib/TdProbeLib.inf | 25 ++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 OvmfPkg/IntelTdx/TdProbeLib/TdProbeLib.c create mode 100644 OvmfPkg/IntelTdx/TdProbeLib/TdProbeLib.inf diff --git a/OvmfPkg/IntelTdx/TdProbeLib/TdProbeLib.c b/OvmfPkg/IntelTdx/TdProbeLib/TdProbeLib.c new file mode 100644 index 000000000000..85b9c5b614e5 --- /dev/null +++ b/OvmfPkg/IntelTdx/TdProbeLib/TdProbeLib.c @@ -0,0 +1,38 @@ +/** @file + + TdProbeLib is used to probe the Td guest. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include <Library/TdProbeLib.h> +#include <WorkArea.h> +#include <ConfidentialComputingGuestAttr.h> + +/** + Probe if it is Tdx guest. + + @return TD_PROBE_TDX if it is Tdx guest. Otherwise return TD_PROBE_NON. + +**/ +UINTN +EFIAPI +TdProbe ( + VOID + ) +{ + OVMF_WORK_AREA *WorkArea; + + WorkArea = (OVMF_WORK_AREA *)FixedPcdGet32 (PcdOvmfWorkAreaBase); + + // + // Check if it is TDX guest. + // + if ((WorkArea != NULL) && (WorkArea->Header.GuestType == GUEST_TYPE_INTEL_TDX)) { + return TD_PROBE_TDX; + } else { + return TD_PROBE_NON; + } +} diff --git a/OvmfPkg/IntelTdx/TdProbeLib/TdProbeLib.inf b/OvmfPkg/IntelTdx/TdProbeLib/TdProbeLib.inf new file mode 100644 index 000000000000..7535008b3a51 --- /dev/null +++ b/OvmfPkg/IntelTdx/TdProbeLib/TdProbeLib.inf @@ -0,0 +1,25 @@ +## @file +# TdProbeLib is used to probe Td guest. +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = TdProbeLib + FILE_GUID = 05184ec9-abb0-4491-8584-e388639a7c48 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = TdProbeLib + +[Sources] + TdProbeLib.c + +[Packages] + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase -- 2.29.2.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#88863): https://edk2.groups.io/g/devel/message/88863 Mute This Topic: https://groups.io/mt/90436751/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
