From 9bf473da4c1d6d3656beca3a914861dcd1fe8a25 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 9 Dec 2022 10:20:21 +0000 Subject: [PATCH] OvmfPkg: Send EOI before RestoreTPL() in timer interrupt handlers Deferring the EOI until after the call to RestoreTPL() means that any callbacks invoked by RestoreTPL() will run with timer interrupt delivery disabled. If any such callbacks themselves rely on timers to implement timeout loops, then the callbacks will get stuck in an infinite loop from which the system will never recover. This reverts commit 239b50a86 ("OvmfPkg: End timer interrupt later to avoid stack overflow under load"). Cc: Paolo Bonzini Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4162 Signed-off-by: Michael Brown Acked-by: Laszlo Ersek --- OvmfPkg/8254TimerDxe/Timer.c | 5 ++--- OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/OvmfPkg/8254TimerDxe/Timer.c b/OvmfPkg/8254TimerDxe/Timer.c index e49a438b44..7feaaaba2b 100644 --- a/OvmfPkg/8254TimerDxe/Timer.c +++ b/OvmfPkg/8254TimerDxe/Timer.c @@ -80,6 +80,8 @@ TimerInterruptHandler ( OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL); + mLegacy8259->EndOfInterrupt (mLegacy8259, Efi8259Irq0); + if (mTimerNotifyFunction != NULL) { // // @bug : This does not handle missed timer interrupts @@ -88,9 +90,6 @@ TimerInterruptHandler ( } gBS->RestoreTPL (OriginalTPL); - - DisableInterrupts (); - mLegacy8259->EndOfInterrupt (mLegacy8259, Efi8259Irq0); } /** diff --git a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c index cbc17c979c..3e04b49d6b 100644 --- a/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c +++ b/OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c @@ -62,6 +62,8 @@ TimerInterruptHandler ( OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL); + SendApicEoi (); + if (mTimerNotifyFunction != NULL) { // // @bug : This does not handle missed timer interrupts @@ -70,9 +72,6 @@ TimerInterruptHandler ( } gBS->RestoreTPL (OriginalTPL); - - DisableInterrupts (); - SendApicEoi (); } /**