]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Extend VmgExitLibNull to handle #VE exception
authorMin Xu <min.m.xu@intel.com>
Sat, 30 Oct 2021 06:29:09 +0000 (14:29 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 2 Apr 2022 08:15:12 +0000 (08:15 +0000)
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 <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
UefiCpuPkg/Include/Library/VmgExitLib.h
UefiCpuPkg/Library/VmgExitLibNull/VmTdExitNull.c [new file with mode: 0644]
UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf

index ebda1c3d907c9028165f8a529ca7fd9edde9625e..f9f911099a7b135ad6d2efc862d385b03b79f33d 100644 (file)
@@ -15,6 +15,8 @@
 #include <Protocol/DebugSupport.h>\r
 #include <Register/Amd/Ghcb.h>\r
 \r
+#define VE_EXCEPTION  20\r
+\r
 /**\r
   Perform VMGEXIT.\r
 \r
@@ -142,4 +144,30 @@ VmgExitHandleVc (
   IN OUT EFI_SYSTEM_CONTEXT  SystemContext\r
   );\r
 \r
+/**\r
+  Handle a #VE exception.\r
+\r
+  Performs the necessary processing to handle a #VE exception.\r
+\r
+  The base library function returns an error equal to VE_EXCEPTION,\r
+  to be propagated to the standard exception handling stack.\r
+\r
+  @param[in, out]  ExceptionType  Pointer to an EFI_EXCEPTION_TYPE to be set\r
+                                  as value to use on error.\r
+  @param[in, out]  SystemContext  Pointer to EFI_SYSTEM_CONTEXT\r
+\r
+  @retval  EFI_SUCCESS            Exception handled\r
+  @retval  EFI_UNSUPPORTED        #VE not supported, (new) exception value to\r
+                                  propagate provided\r
+  @retval  EFI_PROTOCOL_ERROR     #VE handling failed, (new) exception value to\r
+                                  propagate provided\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VmTdExitHandleVe (\r
+  IN OUT EFI_EXCEPTION_TYPE  *ExceptionType,\r
+  IN OUT EFI_SYSTEM_CONTEXT  SystemContext\r
+  );\r
+\r
 #endif\r
diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmTdExitNull.c b/UefiCpuPkg/Library/VmgExitLibNull/VmTdExitNull.c
new file mode 100644 (file)
index 0000000..6a4e808
--- /dev/null
@@ -0,0 +1,38 @@
+/** @file\r
+\r
+  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+#include <Base.h>\r
+#include <Uefi.h>\r
+#include <Library/VmgExitLib.h>\r
+\r
+/**\r
+  Handle a #VE exception.\r
+\r
+  Performs the necessary processing to handle a #VE exception.\r
+\r
+  @param[in, out]  ExceptionType  Pointer to an EFI_EXCEPTION_TYPE to be set\r
+                                  as value to use on error.\r
+  @param[in, out]  SystemContext  Pointer to EFI_SYSTEM_CONTEXT\r
+\r
+  @retval  EFI_SUCCESS            Exception handled\r
+  @retval  EFI_UNSUPPORTED        #VE not supported, (new) exception value to\r
+                                  propagate provided\r
+  @retval  EFI_PROTOCOL_ERROR     #VE handling failed, (new) exception value to\r
+                                  propagate provided\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VmTdExitHandleVe (\r
+  IN OUT EFI_EXCEPTION_TYPE  *ExceptionType,\r
+  IN OUT EFI_SYSTEM_CONTEXT  SystemContext\r
+  )\r
+{\r
+  *ExceptionType = VE_EXCEPTION;\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
index d8770a21c355662f05d97265cbb31619c35d3d88..4aab601939ff0df097b3689097eb5e6db958fb27 100644 (file)
@@ -17,6 +17,7 @@
 \r
 [Sources.common]\r
   VmgExitLibNull.c\r
+  VmTdExitNull.c\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r