From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web09.17699.1646032885667369347 for ; Sun, 27 Feb 2022 23:21:36 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Ii4nP4oq; spf=pass (domain: intel.com, ip: 134.134.136.24, 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=1646032896; x=1677568896; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OCE6nrAkhShaF7mhLIT8Mcd7PqqafAUyQeWI60LL0DA=; b=Ii4nP4oqFgZahJk91hivFZksO8wemFU46P0tMEfAh/8K8Xax2GwIYA8K g2JGO6mP94HRJTNIx1N5nkmGHggfhKfR7x50uI0eFbKzYyw2dPd8/v6xA 3OFebamN6ZfA/sqeNuTzB7vu4Mk0JtK7nYVaJHv0mPQ2+1V/DedFTFs0N q3z0JtL43OgzHuirTc1cv9o/UclgldHhEU5CvxMOlKhVCjcugB9NKOKHu 9iMXcu3jRTgHhFEiZar8mQsmPyVvKTGwcIWj3cgU4FNudxaslwBLGPW8J tnBhGBnTqspfKcEWstQsVL+0USUx+vsbwswuqUNv6f/TKIljQe55Chhh3 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10271"; a="252552629" X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="252552629" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2022 23:21:35 -0800 X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="534340765" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.2.184]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2022 23:21:33 -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 V7 04/37] UefiCpuPkg: Extend VmgExitLibNull to handle #VE exception Date: Mon, 28 Feb 2022 15:20:36 +0800 Message-Id: <0dcc151994ee228221a897d7cc07ac01a95eb713.1646031164.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