diff --git a/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S b/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S index 2de7be7c8b..687d22e852 100644 --- a/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S +++ b/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S @@ -294,7 +294,7 @@ ASM_PFX(CommonExceptionEntry): ldp x24, x25, [sp, #0xc0] ldp x26, x27, [sp, #0xd0] // Preserve return value for SVC. - mrs x1, esr_el1 + ldr x1, [x28, #(FP_CONTEXT_SIZE + 0x18)] // Exception syndrome register lsr x1, x1, #26 and x1, x1, #0x3F cmp x1, #0x15 diff --git a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c index 83d5543df3..1efb7f5c94 100644 --- a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c +++ b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c @@ -141,6 +141,9 @@ CommonCExceptionHandler ( if ((UINTN)ExceptionType <= gMaxExceptionNumber) { if (gExceptionHandlers[ExceptionType]) { gExceptionHandlers[ExceptionType](ExceptionType, SystemContext); +#if defined (MDE_CPU_AARCH64) + SystemContext.SystemContextAArch64->ESR = 0; +#endif return EFI_SUCCESS; } } else { diff --git a/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S index 1192c150de..8307e93392 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S +++ b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S @@ -107,7 +107,6 @@ ASM_FUNC(ArmCallRing3) // msr spsr_el1, x1 isb - dsb sy eret //------------------------------------------------------------------------------ @@ -119,11 +118,6 @@ ASM_FUNC(ArmCallRing3) // ); //------------------------------------------------------------------------------ ASM_FUNC(ReturnToCore) - // Zero Exception Syndrome Register to prevent QEMU from random crashing. - msr esr_el1, xzr - msr spsr_el1, xzr - msr elr_el1, xzr - msr far_el1, xzr // Switch to Core Stack. mov sp, x1 // Restore registers and Stack.