From nobody Sat Feb 7 04:47:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+81480+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+81480+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1633405221; cv=none; d=zohomail.com; s=zohoarc; b=C4LTsCR7tMTSoI4ajfboZagJZs/71Xod2mMzn2VWNc3FVRO2gn1jikmV5OknJd1jOZOw0e60uZq07Mj8n+GwDaLjxLT0usN75wuUyi1d63V0+ImLgL0ztoNZ1sJyBQhqTD0Gi764gCH4SQqWytUkl6DAZrbDUAAUhw9Fvfg/u2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633405221; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=w6uzQA3wDsZ4ze0FPoXF2yV/3Dm+799vfwqsFs1AFfg=; b=FdjWOEJyMDaQ6rXDrl65ffh9glxnDTjmKWV45TuDYsHID9WvfM5kx4HrZpxc1pLbEB81GM6iG+GSMxAAp4I2UIE8lfWYbyii9Z/8v/0YkvAlQoWONPQKxYnJ6eApCmX/iRuM8SNQ6dhibJSCX3+eRlrfCaFBOGe/nnstztwx+Ok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+81480+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1633405221795378.64497469576975; Mon, 4 Oct 2021 20:40:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id CxclYY1788612xwtY6HMPycD; Mon, 04 Oct 2021 20:40:21 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.20667.1633405209770974351 for ; Mon, 04 Oct 2021 20:40:21 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10127"; a="225958116" X-IronPort-AV: E=Sophos;i="5.85,347,1624345200"; d="scan'208";a="225958116" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2021 20:40:20 -0700 X-IronPort-AV: E=Sophos;i="5.85,347,1624345200"; d="scan'208";a="487828539" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.239]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2021 20:40:18 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Eric Dong , Ray Ni , Rahul Kumar Subject: [edk2-devel] [PATCH V2 08/28] UefiCpuPkg: Add VmTdExitLibNull Date: Tue, 5 Oct 2021 11:39:19 +0800 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com X-Gm-Message-State: 50xNl9mAP1cByWXvWmJqTLTIx1787277AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633405221; bh=NUSydC2oQwL19sxylUkhV0gX7aTC4b32/tN3H6g767k=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=oey5PHH/DpMuysHUswa1XpWryYGHy7Jdn29uD2xJzOxGwTo+YU1fDadxTd5uptQaLGF osZqO0a/d2aVRt5J5WAqyE0sUiW4FgqTDrbpchdN/dOwVGPRCBLk78kBeT+yMtf0Rgkaq Lw/MEUqwYELZ0WubmLFa3N2l+JtFW2lRc/s= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633405223293100005 RFC=EF=BC=9A https://bugzilla.tianocore.org/show_bug.cgi?id=3D3429 VmTdExitLib performs the necessary processing to handle a #VE exception. VmTdExitLibNull is a NULL instance of VmTdExitLib which provides a default limited interface. A full feature version of VmTdExitLib should be created later (for example in OvmfPkg). Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Signed-off-by: Min Xu --- UefiCpuPkg/Include/Library/VmTdExitLib.h | 47 +++++++++++++++++++ .../Library/VmTdExitLibNull/VmTdExitLibNull.c | 37 +++++++++++++++ .../VmTdExitLibNull/VmTdExitLibNull.inf | 34 ++++++++++++++ UefiCpuPkg/UefiCpuPkg.dec | 3 ++ UefiCpuPkg/UefiCpuPkg.dsc | 2 + 5 files changed, 123 insertions(+) create mode 100644 UefiCpuPkg/Include/Library/VmTdExitLib.h create mode 100644 UefiCpuPkg/Library/VmTdExitLibNull/VmTdExitLibNull.c create mode 100644 UefiCpuPkg/Library/VmTdExitLibNull/VmTdExitLibNull.inf diff --git a/UefiCpuPkg/Include/Library/VmTdExitLib.h b/UefiCpuPkg/Include/= Library/VmTdExitLib.h new file mode 100644 index 000000000000..a55a76dc7a30 --- /dev/null +++ b/UefiCpuPkg/Include/Library/VmTdExitLib.h @@ -0,0 +1,47 @@ +/** @file + Public header file for the VMTDEXIT Support library class. + + This library class defines some routines used when invoking the VMEXIT + instruction in support of VMX and TDX to handle #VE exceptions. + + Copyright (c) 2020 - 2021, Intel Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef VMTD_EXIT_LIB_H_ +#define VMTD_EXIT_LIB_H_ + +#include +#include +#include + +#define VE_EXCEPTION 20 + +/** + Handle a #VE exception. + + Performs the necessary processing to handle a #VE exception. + + The base library function returns an error equal to VE_EXCEPTION, + to be propagated to the standard exception handling stack. + + @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE to be s= et + as value to use on error. + @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT + + @retval EFI_SUCCESS Exception handled + @retval EFI_UNSUPPORTED #VE not supported, (new) exception value= to + propagate provided + @retval EFI_PROTOCOL_ERROR #VE handling failed, (new) exception val= ue to + propagate provided + +**/ +EFI_STATUS +EFIAPI +VmTdExitHandleVe ( + IN OUT EFI_EXCEPTION_TYPE *ExceptionType, + IN OUT EFI_SYSTEM_CONTEXT SystemContext + ); + +#endif diff --git a/UefiCpuPkg/Library/VmTdExitLibNull/VmTdExitLibNull.c b/UefiCpu= Pkg/Library/VmTdExitLibNull/VmTdExitLibNull.c new file mode 100644 index 000000000000..a632abfab498 --- /dev/null +++ b/UefiCpuPkg/Library/VmTdExitLibNull/VmTdExitLibNull.c @@ -0,0 +1,37 @@ +/** @file + + Copyright (c) 2021, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include + +/** + Handle a #VE exception. + + Performs the necessary processing to handle a #VE exception. + + @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE to be s= et + as value to use on error. + @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT + + @retval EFI_SUCCESS Exception handled + @retval EFI_UNSUPPORTED #VE not supported, (new) exception value= to + propagate provided + @retval EFI_PROTOCOL_ERROR #VE handling failed, (new) exception val= ue to + propagate provided + +**/ +EFI_STATUS +EFIAPI +VmTdExitHandleVe ( + IN OUT EFI_EXCEPTION_TYPE *ExceptionType, + IN OUT EFI_SYSTEM_CONTEXT SystemContext + ) +{ + *ExceptionType =3D VE_EXCEPTION; + + return EFI_UNSUPPORTED; +} diff --git a/UefiCpuPkg/Library/VmTdExitLibNull/VmTdExitLibNull.inf b/UefiC= puPkg/Library/VmTdExitLibNull/VmTdExitLibNull.inf new file mode 100644 index 000000000000..ae9af1b7f56b --- /dev/null +++ b/UefiCpuPkg/Library/VmTdExitLibNull/VmTdExitLibNull.inf @@ -0,0 +1,34 @@ +## @file +# VMTDEXIT Support Library. +# +# Copyright (c) 2020, Intel Inc. All rights reserved.
+# Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D VmTdExitLibNull + FILE_GUID =3D 79BD5323-6CF4-4ECF-A132-F7D31EEADC1E + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D VmTdExitLib + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D X64 IA32 +# + +[Sources.common] + VmTdExitLibNull.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 62acb291f309..439bfc86a112 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -62,6 +62,9 @@ ## @libraryclass Provides function for loading microcode. MicrocodeLib|Include/Library/MicrocodeLib.h =20 + ## @libraryclass Provides function to support VMTDEXIT processing. + VmgExitLib|Include/Library/VmTdExitLib.h + [Guids] gUefiCpuPkgTokenSpaceGuid =3D { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa,= 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }} gMsegSmramGuid =3D { 0x5802bce4, 0xeeee, 0x4e33, { 0xa1,= 0x30, 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }} diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc index e5e6bf77c8e2..50bb49f95b17 100644 --- a/UefiCpuPkg/UefiCpuPkg.dsc +++ b/UefiCpuPkg/UefiCpuPkg.dsc @@ -60,6 +60,7 @@ PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeC= offExtraActionLibNull.inf TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurem= entLibNull.inf VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf + VmTdExitLib|UefiCpuPkg/Library/VmTdExitLibNull/VmTdExitLibNull.inf MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf TdxLib|MdePkg/Library/TdxLib/TdxLib.inf =20 @@ -159,6 +160,7 @@ UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf + UefiCpuPkg/Library/VmTdExitLibNull/VmTdExitLibNull.inf UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf UefiCpuPkg/SecCore/SecCore.inf --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#81480): https://edk2.groups.io/g/devel/message/81480 Mute This Topic: https://groups.io/mt/86085737/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-