From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web08.9091.1645271832752102625 for ; Sat, 19 Feb 2022 03:57:23 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=QA+ZdCJS; spf=pass (domain: intel.com, ip: 192.55.52.151, 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=1645271843; x=1676807843; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OCE6nrAkhShaF7mhLIT8Mcd7PqqafAUyQeWI60LL0DA=; b=QA+ZdCJSqBeAWDYG5WaeyCNm9rfOLmTY5UPrb7yQ66vCQPYLQiMsWn5w R0lE9OhLnvBQgxHZreCBY2g17vOObvUeD4HFXtbY5saLIBkBqS5/vNmLJ sEjSiPqVv2i5Wgm1a7DOcYC+9LHJaA0m9F6dizmV5lgjDM5TOF1Yhs1jT ifpNQg0XTNV/g/dzNi5sFa9y6yrazrQFntfIkMZrq+FntJ9G4/5VSSLaq +WsLE6M5aygrB5bOp9B13UG/evvFXMGbZoNLiD+XvTSWqTSLKHXeSbXZR icdeddmzvQLaqREzNsBhZfw4Igk55OF+w652+AHcJKMNgICplDsX4RdqB g==; X-IronPort-AV: E=McAfee;i="6200,9189,10262"; a="231915185" X-IronPort-AV: E=Sophos;i="5.88,381,1635231600"; d="scan'208";a="231915185" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 03:57:22 -0800 X-IronPort-AV: E=Sophos;i="5.88,381,1635231600"; d="scan'208";a="546690941" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.175.253]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 03:57:20 -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 V6 04/42] UefiCpuPkg: Extend VmgExitLibNull to handle #VE exception Date: Sat, 19 Feb 2022 19:56:17 +0800 Message-Id: <0077acfe0d5b2750ac3497710f962387926a1343.1645261990.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