mirror of https://github.com/acidanthera/audk.git
SourceLevelDebugPkg/SecPeiDebugAgentLib: Restore CPU interrupt state
In DEBUG_AGENT_INIT_POSTMEM_SEC case, caller may disable/restore CPU interrupt to protect the stack/heap migration. SecPeiDebugAgentLib cannot always enable CPU interrupt. Otherwise system may crash during stack/heap migration. SecPeiDebugAgentLib should restore original CPU interrupt state in DEBUG_AGENT_INIT_POSTMEM_SEC case. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Brian J. Johnson <bjohnson@sgi.com> Tested-by: Brian J. Johnson <bjohnson@sgi.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17916 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
db42930da9
commit
2638c11107
|
@ -376,8 +376,12 @@ InitializeDebugAgent (
|
||||||
UINT64 *MailboxLocationPointer;
|
UINT64 *MailboxLocationPointer;
|
||||||
EFI_PHYSICAL_ADDRESS Address;
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
UINT32 DebugTimerFrequency;
|
UINT32 DebugTimerFrequency;
|
||||||
|
BOOLEAN CpuInterruptState;
|
||||||
|
|
||||||
DisableInterrupts ();
|
//
|
||||||
|
// Disable interrupts and save current interrupt state
|
||||||
|
//
|
||||||
|
CpuInterruptState = SaveAndDisableInterrupts();
|
||||||
|
|
||||||
switch (InitFlag) {
|
switch (InitFlag) {
|
||||||
|
|
||||||
|
@ -611,17 +615,22 @@ InitializeDebugAgent (
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
if (InitFlag == DEBUG_AGENT_INIT_POSTMEM_SEC) {
|
||||||
// Enable Debug Timer interrupt. In post-memory SEC, the caller enables it.
|
//
|
||||||
//
|
// Restore CPU Interrupt state and keep debug timer interrupt state as is
|
||||||
if (InitFlag != DEBUG_AGENT_INIT_POSTMEM_SEC) {
|
// in DEBUG_AGENT_INIT_POSTMEM_SEC case
|
||||||
|
//
|
||||||
|
SetInterruptState (CpuInterruptState);
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Enable Debug Timer interrupt
|
||||||
|
//
|
||||||
SaveAndSetDebugTimerInterrupt (TRUE);
|
SaveAndSetDebugTimerInterrupt (TRUE);
|
||||||
|
//
|
||||||
|
// Enable CPU interrupts so debug timer interrupts can be delivered
|
||||||
|
//
|
||||||
|
EnableInterrupts ();
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// Enable CPU interrupts so debug timer interrupts can be delivered
|
|
||||||
//
|
|
||||||
EnableInterrupts ();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// If Function is not NULL, invoke it always whatever debug agent was initialized sucesssfully or not.
|
// If Function is not NULL, invoke it always whatever debug agent was initialized sucesssfully or not.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue