public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Min Xu" <min.m.xu@intel.com>
To: devel@edk2.groups.io
Cc: Min Xu <min.m.xu@intel.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Zhiguang Liu <zhiguang.liu@intel.com>,
	James Bottomley <jejb@linux.ibm.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Brijesh Singh <brijesh.singh@amd.com>,
	Erdem Aktas <erdemaktas@google.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Subject: [PATCH 2/4] OvmfPkg/IntelTdx: Add TdProbeLib
Date: Wed, 13 Apr 2022 17:08:22 +0800	[thread overview]
Message-ID: <33e5b210e9b3f5edd22d7fb4dad165baa1806893.1649840073.git.min.m.xu@intel.com> (raw)
In-Reply-To: <cover.1649840073.git.min.m.xu@intel.com>

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 <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>
Signed-off-by: Min Xu <min.m.xu@intel.com>
---
 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


  parent reply	other threads:[~2022-04-13  9:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13  9:08 [PATCH 0/4] Introduce TdProbe in MdePkg Min Xu
2022-04-13  9:08 ` [PATCH 1/4] MdePkg: Add TdProbeLib Min Xu
2022-04-13  9:08 ` Min Xu [this message]
2022-04-13  9:08 ` [PATCH 3/4] MdePkg: Probe Td guest in BaseIoLibIntrinsicSev Min Xu
2022-04-13  9:08 ` [PATCH 4/4] OvmfPkg: Add TdProbeLib in *.dsc Min Xu
2022-04-13 12:55 ` [PATCH 0/4] Introduce TdProbe in MdePkg James Bottomley
2022-04-13 13:12   ` [edk2-devel] " Yao, Jiewen
2022-04-13 13:27     ` Min Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33e5b210e9b3f5edd22d7fb4dad165baa1806893.1649840073.git.min.m.xu@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox