mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
MdeModulePkg/Core/Dxe: Add interrupt-enable nesting guard
Add interrupt-enable recursion depth tracking using mInterruptEnableNestDepth and a bounded assertion in CoreSetInterruptState(). This provides early detection for unintended recursive interrupt-enable loops. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
parent
1d2e73c4af
commit
ef437b30ad
1 changed files with 20 additions and 0 deletions
|
|
@ -9,6 +9,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||
#include "DxeMain.h"
|
||||
#include "Event.h"
|
||||
|
||||
//
|
||||
// Maximum interrupt nesting depth allowed by the UEFI/PI specifications.
|
||||
// Comprised of 3 software TPL levels (TPL_APPLICATION, TPL_CALLBACK,
|
||||
// TPL_NOTIFY) plus 16 hardware interrupt priority levels (TPL 16..31).
|
||||
//
|
||||
#define MAX_INTERRUPT_ENABLE_NEST_DEPTH (3 + 16)
|
||||
|
||||
//
|
||||
// Counter for tracking interrupt enable recursion depth.
|
||||
// Incremented on entry to CoreSetInterruptState(TRUE) and decremented on exit.
|
||||
// Prevents stack overflow from infinite interrupt recursion loops.
|
||||
// Must not exceed MAX_INTERRUPT_ENABLE_NEST_DEPTH per UEFI/PI specs.
|
||||
//
|
||||
static volatile UINTN mInterruptEnableNestDepth = 0;
|
||||
|
||||
/**
|
||||
Set Interrupt State.
|
||||
|
||||
|
|
@ -39,7 +54,12 @@ CoreSetInterruptState (
|
|||
}
|
||||
}
|
||||
|
||||
mInterruptEnableNestDepth++;
|
||||
ASSERT (mInterruptEnableNestDepth < MAX_INTERRUPT_ENABLE_NEST_DEPTH);
|
||||
|
||||
gCpu->EnableInterrupt (gCpu);
|
||||
|
||||
mInterruptEnableNestDepth--;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue