UefiCpuPkg/CpuExceptionHandler: Add base support for the #VC exception
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198 Add base support to handle #VC exceptions. Update the common exception handlers to invoke the VmgExitHandleVc () function of the VmgExitLib library when a #VC is encountered. A non-zero return code will propagate to the targeted exception handler. Under SEV-ES, a DR7 read or write intercept generates a #VC exception. To avoid exception recursion, a #VC exception will not try to read and push the actual debug registers into the EFI_SYSTEM_CONTEXT_X64 struct and instead push zeroes. The #VC exception handler does not make use of the debug registers from the saved context and the exception processing exit code does not attempt to restore the debug register values. Cc: Eric Dong <eric.dong@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
3a4a6ead32
commit
5277540e37
@@ -6,8 +6,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include "CpuExceptionCommon.h"
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/VmgExitLib.h>
|
||||
#include "CpuExceptionCommon.h"
|
||||
|
||||
/**
|
||||
Internal worker function for common exception handler.
|
||||
@@ -27,6 +28,23 @@ CommonExceptionHandlerWorker (
|
||||
RESERVED_VECTORS_DATA *ReservedVectors;
|
||||
EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler;
|
||||
|
||||
if (ExceptionType == VC_EXCEPTION) {
|
||||
EFI_STATUS Status;
|
||||
//
|
||||
// #VC needs to be handled immediately upon enabling exception handling
|
||||
// and therefore can't use the RegisterCpuInterruptHandler() interface.
|
||||
//
|
||||
// Handle the #VC:
|
||||
// On EFI_SUCCESS - Exception has been handled, return
|
||||
// On other - ExceptionType contains (possibly new) exception
|
||||
// value
|
||||
//
|
||||
Status = VmgExitHandleVc (&ExceptionType, SystemContext);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ExceptionHandlerContext = (EXCEPTION_HANDLER_CONTEXT *) (UINTN) (SystemContext.SystemContextIa32);
|
||||
ReservedVectors = ExceptionHandlerData->ReservedVectors;
|
||||
ExternalInterruptHandler = ExceptionHandlerData->ExternalInterruptHandler;
|
||||
|
Reference in New Issue
Block a user