summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/XenTimerDxe/XenTimerDxe.c
diff options
context:
space:
mode:
authorIgor Druzhinin <igor.druzhinin@citrix.com>2020-06-16 03:49:42 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-06-18 10:20:39 +0000
commit239b50a863704f7960525799eda82de061c7c458 (patch)
treec5dc7fecccda786041f58421e48a285a0187edd3 /OvmfPkg/XenTimerDxe/XenTimerDxe.c
parent3a9f932d809e496be4961a568741175b254099d5 (diff)
downloadedk2-239b50a863704f7960525799eda82de061c7c458.tar.gz
edk2-239b50a863704f7960525799eda82de061c7c458.tar.bz2
edk2-239b50a863704f7960525799eda82de061c7c458.zip
OvmfPkg: End timer interrupt later to avoid stack overflow under load
RestoreTPL called while at TPL_HIGH_LEVEL unconditionally enables interrupts even if called in interrupt handler. That opens a window while interrupt is not completely handled but another interrupt could be accepted. If a VM starts on a heavily loaded host hundreds of periodic timer interrupts might be queued while vCPU is descheduled (the behavior is typical for a Xen host). The next time vCPU is scheduled again all of them get delivered back to back causing OVMF to accept each one without finishing a previous one and cleaning up the stack. That quickly results in stack overflow and a triple fault. Fix it by postponing sending EOI until we finished processing the current tick giving interrupt handler opportunity to clean up the stack before accepting the next tick. Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com> Message-Id: <1592275782-9369-1-git-send-email-igor.druzhinin@citrix.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2815 Acked-by: Laszlo Ersek <lersek@redhat.com> [lersek@redhat.com: add BZ ref; rewrap msg to silence PatchCheck.py]
Diffstat (limited to 'OvmfPkg/XenTimerDxe/XenTimerDxe.c')
-rw-r--r--OvmfPkg/XenTimerDxe/XenTimerDxe.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/OvmfPkg/XenTimerDxe/XenTimerDxe.c b/OvmfPkg/XenTimerDxe/XenTimerDxe.c
index 9f9e04766c..0bec59382b 100644
--- a/OvmfPkg/XenTimerDxe/XenTimerDxe.c
+++ b/OvmfPkg/XenTimerDxe/XenTimerDxe.c
@@ -61,8 +61,6 @@ TimerInterruptHandler (
OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
- SendApicEoi();
-
if (mTimerNotifyFunction != NULL) {
//
// @bug : This does not handle missed timer interrupts
@@ -71,6 +69,9 @@ TimerInterruptHandler (
}
gBS->RestoreTPL (OriginalTPL);
+
+ DisableInterrupts ();
+ SendApicEoi ();
}
/**