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:42 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=UKOcQ+Q3; 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=1649840922; x=1681376922; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lKQ+lWpSLUEoascumAH7xm3ZYfb1CUlKtBU0a81rW98=; b=UKOcQ+Q378+lg1G47nDv/yj1M4GWpvlPfVW6qFCVG0ScaR1Af3Rr95nI v7gWHAeBvn7POXLYP8VrbRb5wlbfWOZeg2I7xz4VViHfHa22ee0M2oZZa KNgGdc07ILsHRiuAshHeAq5k3+2JryTtU7VfdJUrfVlIKaKR6FEtpYkIF sLT91ysU1+HBihSx430Io6npuGw6Ow3KStZeyGFK4o7G8HHVCSLjh/UXV M5+hNETtvQNOiyEQ+j2vAFqD3dOLvl8HnrUSUs4S4OTGt0n3j3YPHl5sI ti4gg90SExN+tJa40yt9fUERyi3Z1o1GRx2+RQz9E8V/hfXxEOxqcsMU2 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10315"; a="242551910" X-IronPort-AV: E=Sophos;i="5.90,256,1643702400"; d="scan'208";a="242551910" 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:41 -0700 X-IronPort-AV: E=Sophos;i="5.90,256,1643702400"; d="scan'208";a="573183410" 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:39 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , James Bottomley , Jiewen Yao , Gerd Hoffmann Subject: [PATCH 1/4] MdePkg: Add TdProbeLib Date: Wed, 13 Apr 2022 17:08:21 +0800 Message-Id: <3fcbbc0d9b2b82f3a6bdc132c01462d73bfc02bc.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 TdProbeLib is used to probe if the working system is of Td guest. This library is designed to run on SEC / PEI / DXE phases. A null instance of the library returns Non-Td anyway. A platform specific TdProbeLib will be implemented, for example, in OvmfPkg. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Signed-off-by: Min Xu --- MdePkg/Include/Library/TdProbeLib.h | 26 +++++++++++++++++++ .../Library/TdProbeLibNull/TdProbeLibNull.c | 25 ++++++++++++++++++ .../Library/TdProbeLibNull/TdProbeLibNull.inf | 21 +++++++++++++++ MdePkg/MdePkg.dec | 5 ++++ MdePkg/MdePkg.dsc | 1 + 5 files changed, 78 insertions(+) create mode 100644 MdePkg/Include/Library/TdProbeLib.h create mode 100644 MdePkg/Library/TdProbeLibNull/TdProbeLibNull.c create mode 100644 MdePkg/Library/TdProbeLibNull/TdProbeLibNull.inf diff --git a/MdePkg/Include/Library/TdProbeLib.h b/MdePkg/Include/Library/TdProbeLib.h new file mode 100644 index 000000000000..363a30fce649 --- /dev/null +++ b/MdePkg/Include/Library/TdProbeLib.h @@ -0,0 +1,26 @@ +/** @file + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef TD_PROBE_LIB_H_ +#define TD_PROBE_LIB_H_ + +#define TD_PROBE_NON 0 +#define TD_PROBE_TDX 1 + +/** + Probe if it is Tdx guest. + + @return TD_PROBE_TDX if it is Tdx guest. Otherwise return TD_PROBE_NON. + +**/ +UINTN +EFIAPI +TdProbe ( + VOID + ); + +#endif diff --git a/MdePkg/Library/TdProbeLibNull/TdProbeLibNull.c b/MdePkg/Library/TdProbeLibNull/TdProbeLibNull.c new file mode 100644 index 000000000000..8aa2baf9053d --- /dev/null +++ b/MdePkg/Library/TdProbeLibNull/TdProbeLibNull.c @@ -0,0 +1,25 @@ +/** @file + + Null stub of TdProbeLib + + Copyright (c) 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#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 + ) +{ + return TD_PROBE_NON; +} diff --git a/MdePkg/Library/TdProbeLibNull/TdProbeLibNull.inf b/MdePkg/Library/TdProbeLibNull/TdProbeLibNull.inf new file mode 100644 index 000000000000..7db961e6ea2d --- /dev/null +++ b/MdePkg/Library/TdProbeLibNull/TdProbeLibNull.inf @@ -0,0 +1,21 @@ +## @file +# TdProbeLib null instance. +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = TdProbeLibNull + FILE_GUID = B15D67FE-0DAC-4316-8E26-8A6b85E43782 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = TdProbeLib + +[Sources] + TdProbeLibNull.c + +[Packages] + MdePkg/MdePkg.dec diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 1934c9840423..9cc713e3d5af 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -267,6 +267,11 @@ # RegisterFilterLib|Include/Library/RegisterFilterLib.h + ## @libraryclass This library provides interfances to probe Td guest. + # + # + TdProbeLib|Include/Library/TdProbeLib.h + [LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64] ## @libraryclass Provides services to generate random number. # diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index d6a7af412be7..c2a68056f48a 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -130,6 +130,7 @@ MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf + MdePkg/Library/TdProbeLibNull/TdProbeLibNull.inf [Components.IA32, Components.X64, Components.ARM, Components.AARCH64] # -- 2.29.2.windows.2