From: Brian J. Johnson Date: Thu, 9 Jul 2015 02:29:58 +0000 (+0000) Subject: SourceLevelDebugPkg: Fix PEI timer interrupt regression X-Git-Tag: edk2-stable201903~9384 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=3b87e3881e6ea25885bf445c3d4278f7ef2668c3 SourceLevelDebugPkg: Fix PEI timer interrupt regression Recent changes to debug timer initialization (commit 2befbc82, svn 17572) modified the Sec/Pei InitializeDebugAgent() routine to enable debug timer interrupts. This causes problems in the DEBUG_AGENT_INIT_POSTMEM_SEC case: the callers appear to assume that if they block timer interrupts before the call, interrupts will remain blocked afterwards. It is not always safe to have interrupts enabled on return from InitializeDebugAgent(). For instance, after calling InitializeDebugAgent(), OvmfPkg's TemporaryRamMigration() moves the stack, heap, and IDT to RAM, then switches to the new stack. Only then does it reenable timer interrupts. Taking an interrupt during this process can corrupt state, causing crashes. Do not unmask the debug timer interrupt in the DEBUG_AGENT_INIT_POSTMEM_SEC case. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brian J. Johnson Reviewed-by: Jeff Fan git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17893 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c index ea757423d1..09216c20fe 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c @@ -612,9 +612,11 @@ InitializeDebugAgent ( } // - // Enable Debug Timer interrupt + // Enable Debug Timer interrupt. In post-memory SEC, the caller enables it. // - SaveAndSetDebugTimerInterrupt (TRUE); + if (InitFlag != DEBUG_AGENT_INIT_POSTMEM_SEC) { + SaveAndSetDebugTimerInterrupt (TRUE); + } // // Enable CPU interrupts so debug timer interrupts can be delivered //