diff options
author | Michael Brown <mcb30@ipxe.org> | 2022-12-09 10:20:27 +0000 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-12-23 14:44:48 +0000 |
commit | a086f4a63bc0295b0b02f8ee76381c6b437122bf (patch) | |
tree | 0b29dd5164aca8a8ce35803c0cc16b077e6f6780 /OvmfPkg/8254TimerDxe | |
parent | a24fbd6061254ca74d6c6ed953dec6f796a45c76 (diff) | |
download | edk2-a086f4a63bc0295b0b02f8ee76381c6b437122bf.tar.gz edk2-a086f4a63bc0295b0b02f8ee76381c6b437122bf.tar.bz2 edk2-a086f4a63bc0295b0b02f8ee76381c6b437122bf.zip |
OvmfPkg: Use NestedInterruptTplLib in nested interrupt handlers
Prevent stack underrun in the event of a timer interrupt storm in
LocalApicTimerDxe and 8254TimerDxe interrupt handlers by using the
helper functions provided by NestedInterruptTplLib.
This fixes the same problem as addressed in commit 239b50a86
("OvmfPkg: End timer interrupt later to avoid stack overflow under
load"), but does so without breaking nested timer interrupts.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2815
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4162
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'OvmfPkg/8254TimerDxe')
-rw-r--r-- | OvmfPkg/8254TimerDxe/8254Timer.inf | 1 | ||||
-rw-r--r-- | OvmfPkg/8254TimerDxe/Timer.c | 9 |
2 files changed, 7 insertions, 3 deletions
diff --git a/OvmfPkg/8254TimerDxe/8254Timer.inf b/OvmfPkg/8254TimerDxe/8254Timer.inf index 8a07c8247e..8fbab896f0 100644 --- a/OvmfPkg/8254TimerDxe/8254Timer.inf +++ b/OvmfPkg/8254TimerDxe/8254Timer.inf @@ -24,6 +24,7 @@ UefiBootServicesTableLib
BaseLib
DebugLib
+ NestedInterruptTplLib
UefiDriverEntryPoint
IoLib
diff --git a/OvmfPkg/8254TimerDxe/Timer.c b/OvmfPkg/8254TimerDxe/Timer.c index 7feaaaba2b..5382b01615 100644 --- a/OvmfPkg/8254TimerDxe/Timer.c +++ b/OvmfPkg/8254TimerDxe/Timer.c @@ -6,6 +6,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
+#include <Library/NestedInterruptTplLib.h>
+
#include "Timer.h"
//
@@ -76,9 +78,10 @@ TimerInterruptHandler ( IN EFI_SYSTEM_CONTEXT SystemContext
)
{
- EFI_TPL OriginalTPL;
+ STATIC NESTED_INTERRUPT_STATE NestedInterruptState;
+ EFI_TPL OriginalTPL;
- OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
+ OriginalTPL = NestedInterruptRaiseTPL ();
mLegacy8259->EndOfInterrupt (mLegacy8259, Efi8259Irq0);
@@ -89,7 +92,7 @@ TimerInterruptHandler ( mTimerNotifyFunction (mTimerPeriod);
}
- gBS->RestoreTPL (OriginalTPL);
+ NestedInterruptRestoreTPL (OriginalTPL, SystemContext, &NestedInterruptState);
}
/**
|