//\r
// 1 means an error code will be pushed, otherwise 0\r
//\r
-CONST UINT32 mErrorCodeFlag = 0x00227d00;\r
+CONST UINT32 mErrorCodeFlag = 0x20227d00;\r
\r
//\r
// Define the maximum message length\r
"#XM - SIMD floating-point",\r
"#VE - Virtualization",\r
"#CP - Control Protection"\r
+ "Reserved",\r
+ "Reserved",\r
+ "Reserved",\r
+ "Reserved",\r
+ "Reserved",\r
+ "Reserved",\r
+ "Reserved",\r
+ "#VC - VMM Communication",\r
};\r
\r
#define EXCEPTION_KNOWN_NAME_NUM (sizeof (mExceptionNameStr) / sizeof (CHAR8 *))\r
PeCoffGetEntryPointLib\r
MemoryAllocationLib\r
DebugLib\r
+ VmgExitLib\r
HobLib\r
MemoryAllocationLib\r
SynchronizationLib\r
+ VmgExitLib\r
\r
[Pcd]\r
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard # CONSUMES\r
\r
**/\r
\r
-#include "CpuExceptionCommon.h"\r
#include <Library/DebugLib.h>\r
+#include <Library/VmgExitLib.h>\r
+#include "CpuExceptionCommon.h"\r
\r
/**\r
Internal worker function for common exception handler.\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
+ }\r
+\r
ExceptionHandlerContext = (EXCEPTION_HANDLER_CONTEXT *) (UINTN) (SystemContext.SystemContextIa32);\r
ReservedVectors = ExceptionHandlerData->ReservedVectors;\r
ExternalInterruptHandler = ExceptionHandlerData->ExternalInterruptHandler;\r
**/\r
\r
#include <PiPei.h>\r
+#include <Library/VmgExitLib.h>\r
#include "CpuExceptionCommon.h"\r
\r
CONST UINTN mDoFarReturnFlag = 0;\r
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
+ }\r
+\r
//\r
// Initialize the serial port before dumping.\r
//\r
PrintLib\r
LocalApicLib\r
PeCoffGetEntryPointLib\r
+ VmgExitLib\r
LocalApicLib\r
PeCoffGetEntryPointLib\r
DebugLib\r
+ VmgExitLib\r
\r
; CommonExceptionHandler()\r
;\r
\r
+%define VC_EXCEPTION 29\r
+\r
extern ASM_PFX(mErrorCodeFlag) ; Error code flags for exceptions\r
extern ASM_PFX(mDoFarReturnFlag) ; Do far return flag\r
extern ASM_PFX(CommonExceptionHandler)\r
push rax\r
\r
;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;\r
+ cmp qword [rbp + 8], VC_EXCEPTION\r
+ je VcDebugRegs ; For SEV-ES (#VC) Debug registers ignored\r
+\r
mov rax, dr7\r
push rax\r
mov rax, dr6\r
push rax\r
mov rax, dr0\r
push rax\r
+ jmp DrFinish\r
+\r
+VcDebugRegs:\r
+;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7 are skipped for #VC to avoid exception recursion\r
+ xor rax, rax\r
+ push rax\r
+ push rax\r
+ push rax\r
+ push rax\r
+ push rax\r
+ push rax\r
\r
+DrFinish:\r
;; FX_SAVE_STATE_X64 FxSaveState;\r
sub rsp, 512\r
mov rdi, rsp\r
; CommonExceptionHandler()\r
;\r
\r
+%define VC_EXCEPTION 29\r
+\r
extern ASM_PFX(mErrorCodeFlag) ; Error code flags for exceptions\r
extern ASM_PFX(mDoFarReturnFlag) ; Do far return flag\r
extern ASM_PFX(CommonExceptionHandler)\r
push rax\r
\r
;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;\r
+ cmp qword [rbp + 8], VC_EXCEPTION\r
+ je VcDebugRegs ; For SEV-ES (#VC) Debug registers ignored\r
+\r
mov rax, dr7\r
push rax\r
mov rax, dr6\r
push rax\r
mov rax, dr0\r
push rax\r
+ jmp DrFinish\r
+\r
+VcDebugRegs:\r
+;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7 are skipped for #VC to avoid exception recursion\r
+ xor rax, rax\r
+ push rax\r
+ push rax\r
+ push rax\r
+ push rax\r
+ push rax\r
+ push rax\r
\r
+DrFinish:\r
;; FX_SAVE_STATE_X64 FxSaveState;\r
sub rsp, 512\r
mov rdi, rsp\r
PrintLib\r
LocalApicLib\r
PeCoffGetEntryPointLib\r
+ VmgExitLib\r