From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web09.4082.1649840922150046074 for ; Wed, 13 Apr 2022 02:08:45 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=J1SXLXaI; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649840924; x=1681376924; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fHOY9kV2GGA0xNXdvRKglp58RWyfRjui5GbKjPLWlDw=; b=J1SXLXaIbEJGB2QSGneUtL7mizJKi/eAaKZ64PS+Q+mhGMpou2cwNhgA 8Mc9l2BbszqlHWwImwxE6I2vxarxZ4wfQxS/UdRXKGWwjUF40opmnrxeP RNCgwbw4mDQTFnIlAGQeWpt7nSZ5qYQm/DI13D4TbiUKYcSu/JmXmrJhf A+N6hcU0xPdcGwrSXyIMXBqHF2eVhxfAzJnr8Q985bxrRFDQ0pLoDTtN0 YhXPpFSiqUOmSrP8oEkm3X9WiAiM987+tdpACWIGguqzOQQbMGW5XuS/c swjHjGDiYFZ7csXL31jWPpheRsAerhIML3BFL5l6AX6WmwAnEd0/tlEhT A==; X-IronPort-AV: E=McAfee;i="6400,9594,10315"; a="242551930" X-IronPort-AV: E=Sophos;i="5.90,256,1643702400"; d="scan'208";a="242551930" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2022 02:08:44 -0700 X-IronPort-AV: E=Sophos;i="5.90,256,1643702400"; d="scan'208";a="573183427" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.28.56]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2022 02:08:41 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , James Bottomley , James Bottomley , Jiewen Yao , Gerd Hoffmann , Brijesh Singh , Erdem Aktas , Tom Lendacky Subject: [PATCH 2/4] OvmfPkg/IntelTdx: Add TdProbeLib Date: Wed, 13 Apr 2022 17:08:22 +0800 Message-Id: <33e5b210e9b3f5edd22d7fb4dad165baa1806893.1649840073.git.min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Liming Gao Cc: Zhiguang Liu Cc: James Bottomley Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Brijesh Singh Cc: Erdem Aktas Cc: Tom Lendacky Signed-off-by: Min Xu --- 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.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +/** + 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.
+# 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