]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuExceptionHandler: Add base support for the #VE exception
authorMin Xu <min.m.xu@intel.com>
Sun, 18 Jul 2021 02:20:21 +0000 (10:20 +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

Add base support to handle #VE exceptions. Update the common exception
handlers to invoke the VmTdExitHandleVe () function of the VmgExitLib
library when a #VE is encountered. A non-zero return code will propagate
to the targeted exception handler.

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/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c
UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c

index 762ea2460f9191ebe10026e43b97fe540dfe446a..f47a80dcab8f8226a130446a9aa9fe7f8a3bf689 100644 (file)
@@ -24,25 +24,48 @@ CommonExceptionHandlerWorker (
   IN EXCEPTION_HANDLER_DATA  *ExceptionHandlerData\r
   )\r
 {\r
+  EFI_STATUS                 Status;\r
   EXCEPTION_HANDLER_CONTEXT  *ExceptionHandlerContext;\r
   RESERVED_VECTORS_DATA      *ReservedVectors;\r
   EFI_CPU_INTERRUPT_HANDLER  *ExternalInterruptHandler;\r
 \r
-  if (ExceptionType == VC_EXCEPTION) {\r
-    EFI_STATUS  Status;\r
-    //\r
-    // #VC needs to be handled immediately upon enabling exception handling\r
-    // and therefore can't use the RegisterCpuInterruptHandler() interface.\r
-    //\r
-    // Handle the #VC:\r
-    //   On EFI_SUCCESS - Exception has been handled, return\r
-    //   On other       - ExceptionType contains (possibly new) exception\r
-    //                    value\r
-    //\r
-    Status = VmgExitHandleVc (&ExceptionType, SystemContext);\r
-    if (!EFI_ERROR (Status)) {\r
-      return;\r
-    }\r
+  switch (ExceptionType) {\r
+    case VC_EXCEPTION:\r
+      //\r
+      // #VC needs to be handled immediately upon enabling exception handling\r
+      // and therefore can't use the RegisterCpuInterruptHandler() interface.\r
+      //\r
+      // Handle the #VC:\r
+      //   On EFI_SUCCESS - Exception has been handled, return\r
+      //   On other       - ExceptionType contains (possibly new) exception\r
+      //                    value\r
+      //\r
+      Status = VmgExitHandleVc (&ExceptionType, SystemContext);\r
+      if (!EFI_ERROR (Status)) {\r
+        return;\r
+      }\r
+\r
+      break;\r
+\r
+    case VE_EXCEPTION:\r
+      //\r
+      // #VE needs to be handled immediately upon enabling exception handling\r
+      // and therefore can't use the RegisterCpuInterruptHandler() interface.\r
+      //\r
+      // Handle the #VE:\r
+      //   On EFI_SUCCESS - Exception has been handled, return\r
+      //   On other       - ExceptionType contains (possibly new) exception\r
+      //                    value\r
+      //\r
+      Status = VmTdExitHandleVe (&ExceptionType, SystemContext);\r
+      if (!EFI_ERROR (Status)) {\r
+        return;\r
+      }\r
+\r
+      break;\r
+\r
+    default:\r
+      break;\r
   }\r
 \r
   ExceptionHandlerContext  = (EXCEPTION_HANDLER_CONTEXT *)(UINTN)(SystemContext.SystemContextIa32);\r
index c614d5b0b6f17274ea3c6ed7e77f7d1e6b5c47a4..6e5216380da83acf8507ea6423bb105fb82a28a7 100644 (file)
@@ -25,22 +25,47 @@ CommonExceptionHandler (
   IN EFI_SYSTEM_CONTEXT  SystemContext\r
   )\r
 {\r
-  if (ExceptionType == VC_EXCEPTION) {\r
-    EFI_STATUS  Status;\r
-    //\r
-    // #VC needs to be handled immediately upon enabling exception handling\r
-    // and therefore can't use the RegisterCpuInterruptHandler() interface\r
-    // (which isn't supported under Sec and Pei anyway).\r
-    //\r
-    // Handle the #VC:\r
-    //   On EFI_SUCCESS - Exception has been handled, return\r
-    //   On other       - ExceptionType contains (possibly new) exception\r
-    //                    value\r
-    //\r
-    Status = VmgExitHandleVc (&ExceptionType, SystemContext);\r
-    if (!EFI_ERROR (Status)) {\r
-      return;\r
-    }\r
+  EFI_STATUS  Status;\r
+\r
+  switch (ExceptionType) {\r
+    case VC_EXCEPTION:\r
+      //\r
+      // #VC needs to be handled immediately upon enabling exception handling\r
+      // and therefore can't use the RegisterCpuInterruptHandler() interface\r
+      // (which isn't supported under Sec and Pei anyway).\r
+      //\r
+      // Handle the #VC:\r
+      //   On EFI_SUCCESS - Exception has been handled, return\r
+      //   On other       - ExceptionType contains (possibly new) exception\r
+      //                    value\r
+      //\r
+      Status = VmgExitHandleVc (&ExceptionType, SystemContext);\r
+      if (!EFI_ERROR (Status)) {\r
+        return;\r
+      }\r
+\r
+      break;\r
+\r
+    case VE_EXCEPTION:\r
+      //\r
+      // #VE needs to be handled immediately upon enabling exception handling\r
+      // and therefore can't use the RegisterCpuInterruptHandler() interface\r
+      // (which isn't supported under Sec and Pei anyway).\r
+      //\r
+      // Handle the #VE:\r
+      //   On EFI_SUCCESS - Exception has been handled, return\r
+      //   On other       - ExceptionType contains (possibly new) exception\r
+      //                    value\r
+      //\r
+      Status = VmTdExitHandleVe (&ExceptionType, SystemContext);\r
+      if (!EFI_ERROR (Status)) {\r
+        return;\r
+      }\r
+\r
+      break;\r
+\r
+    default:\r
+      break;\r
   }\r
 \r
   //\r