From 2497ca5c32a9aae0ef890b58f3c1fe68716365a0 Mon Sep 17 00:00:00 2001 From: Mikhail Krichanov Date: Fri, 27 Sep 2024 15:43:46 +0300 Subject: [PATCH] Ring3: Fixed buggy timer interrupt handling for AARCH64. --- ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S | 2 +- ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c | 3 +++ MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S | 6 ------ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S b/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S index fbdccb921a..06a32d20ca 100644 --- a/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S +++ b/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S @@ -311,7 +311,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 fb413df348..ebf7aac2b6 100644 --- a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c +++ b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c @@ -276,6 +276,9 @@ CommonCExceptionHandler ( if (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.