From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web08.919.1647050070631942533 for ; Fri, 11 Mar 2022 17:54:41 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=MHaQVBO5; spf=pass (domain: intel.com, ip: 192.55.52.115, 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=1647050081; x=1678586081; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OCE6nrAkhShaF7mhLIT8Mcd7PqqafAUyQeWI60LL0DA=; b=MHaQVBO5/3n9FreF6TIfm0IH/8vBE9Y9qusutJHF7Hdg5m9kwvjH899z w6omcER2jxiaIGA67Bst/EyoTsTEF2bo4E8Bj+kk4kmMeDdH1gYaoX1Sr 69dtQOMU35QKye7suyajSCCSGjBIJMV7stVnzk5JYY5Yv/1jkX2oIBw+q RMN90haz8vzzYvrY7n33a5Pvaz4gqYN29BcOOW+0c2hosi3px0V5YVIX7 ywBUF2AyCiePad3NrNO1tg2ttpbIs2DgDTiN5U9BKI5T9+KiObav0pz85 BHWYNT2LaOJO9YgNwZ0DvMtMDmsvx/Z8b/63pubWD7Pjs0tifsbdQfXzM Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10283"; a="255894213" X-IronPort-AV: E=Sophos;i="5.90,175,1643702400"; d="scan'208";a="255894213" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2022 17:54:40 -0800 X-IronPort-AV: E=Sophos;i="5.90,175,1643702400"; d="scan'208";a="555564228" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.254]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2022 17:54:38 -0800 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 , Gerd Hoffmann Subject: [PATCH V8 04/47] UefiCpuPkg: Extend VmgExitLibNull to handle #VE exception Date: Sat, 12 Mar 2022 09:53:29 +0800 Message-Id: <19c615646fd8aac15a53adf3a4a5ef8e5a018383.1647047482.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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 VmgExitLib performs the necessary processing to handle a #VC exception. VmgExitLibNull is a NULL instance of VmgExitLib which provides a default limited interface. In this commit VmgExitLibNull is extended to handle a #VE exception with a default limited interface. A full feature version of #VE handler will be created later. Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- UefiCpuPkg/Include/Library/VmgExitLib.h | 28 ++++++++++++++ .../Library/VmgExitLibNull/VmTdExitNull.c | 38 +++++++++++++++++++ .../Library/VmgExitLibNull/VmgExitLibNull.inf | 1 + 3 files changed, 67 insertions(+) create mode 100644 UefiCpuPkg/Library/VmgExitLibNull/VmTdExitNull.c diff --git a/UefiCpuPkg/Include/Library/VmgExitLib.h b/UefiCpuPkg/Include/Library/VmgExitLib.h index ebda1c3d907c..f9f911099a7b 100644 --- a/UefiCpuPkg/Include/Library/VmgExitLib.h +++ b/UefiCpuPkg/Include/Library/VmgExitLib.h @@ -15,6 +15,8 @@ #include #include +#define VE_EXCEPTION 20 + /** Perform VMGEXIT. @@ -142,4 +144,30 @@ VmgExitHandleVc ( IN OUT EFI_SYSTEM_CONTEXT SystemContext ); +/** + 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 set + 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 value 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/VmgExitLibNull/VmTdExitNull.c b/UefiCpuPkg/Library/VmgExitLibNull/VmTdExitNull.c new file mode 100644 index 000000000000..6a4e8087cb89 --- /dev/null +++ b/UefiCpuPkg/Library/VmgExitLibNull/VmTdExitNull.c @@ -0,0 +1,38 @@ +/** @file + + Copyright (c) 2021, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#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 set + 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 value to + propagate provided + +**/ +EFI_STATUS +EFIAPI +VmTdExitHandleVe ( + IN OUT EFI_EXCEPTION_TYPE *ExceptionType, + IN OUT EFI_SYSTEM_CONTEXT SystemContext + ) +{ + *ExceptionType = VE_EXCEPTION; + + return EFI_UNSUPPORTED; +} diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf index d8770a21c355..4aab601939ff 100644 --- a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf +++ b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf @@ -17,6 +17,7 @@ [Sources.common] VmgExitLibNull.c + VmTdExitNull.c [Packages] MdePkg/MdePkg.dec -- 2.29.2.windows.2