mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[NTOS:KD64,KE] IRQL is automatically adjusted during calls to KdEnterDebugger() and KdExitDebugger(). (#3942)
Addendum to608032bd
and835c3023
. The IRQL is actually raised by KeFreezeExecution() and lowered by KeThawExecution(), always to HIGH_IRQL on MP systems, or if necessary on UP. These functions are called respectively by KdEnterDebugger() and KdExitDebugger().
This commit is contained in:
parent
05590079cc
commit
6e9ff14e26
3 changed files with 39 additions and 16 deletions
|
@ -1890,7 +1890,7 @@ KdEnterDebugger(IN PKTRAP_FRAME TrapFrame,
|
||||||
/* Save the current IRQL */
|
/* Save the current IRQL */
|
||||||
KeGetCurrentPrcb()->DebuggerSavedIRQL = KeGetCurrentIrql();
|
KeGetCurrentPrcb()->DebuggerSavedIRQL = KeGetCurrentIrql();
|
||||||
|
|
||||||
/* Freeze all CPUs */
|
/* Freeze all CPUs, raising also the IRQL to HIGH_LEVEL */
|
||||||
Enable = KeFreezeExecution(TrapFrame, ExceptionFrame);
|
Enable = KeFreezeExecution(TrapFrame, ExceptionFrame);
|
||||||
|
|
||||||
/* Lock the port, save the state and set debugger entered */
|
/* Lock the port, save the state and set debugger entered */
|
||||||
|
@ -1929,7 +1929,7 @@ KdExitDebugger(IN BOOLEAN Enable)
|
||||||
KdRestore(FALSE);
|
KdRestore(FALSE);
|
||||||
if (KdpPortLocked) KdpPortUnlock();
|
if (KdpPortLocked) KdpPortUnlock();
|
||||||
|
|
||||||
/* Unfreeze the CPUs */
|
/* Unfreeze the CPUs, restoring also the IRQL */
|
||||||
KeThawExecution(Enable);
|
KeThawExecution(Enable);
|
||||||
|
|
||||||
/* Compare time with the one from KdEnterDebugger */
|
/* Compare time with the one from KdEnterDebugger */
|
||||||
|
|
|
@ -144,11 +144,6 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame,
|
||||||
BOOLEAN Handled;
|
BOOLEAN Handled;
|
||||||
NTSTATUS ReturnStatus;
|
NTSTATUS ReturnStatus;
|
||||||
USHORT ReturnLength;
|
USHORT ReturnLength;
|
||||||
KIRQL OldIrql = DISPATCH_LEVEL;
|
|
||||||
|
|
||||||
/* Raise if we have to. */
|
|
||||||
if (KeGetCurrentIrql() < DISPATCH_LEVEL)
|
|
||||||
OldIrql = KeRaiseIrqlToDpcLevel();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or
|
* Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or
|
||||||
|
@ -262,9 +257,6 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame,
|
||||||
SecondChanceException);
|
SecondChanceException);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OldIrql < DISPATCH_LEVEL)
|
|
||||||
KeLowerIrql(OldIrql);
|
|
||||||
|
|
||||||
/* Return TRUE or FALSE to caller */
|
/* Return TRUE or FALSE to caller */
|
||||||
return Handled;
|
return Handled;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,15 +27,33 @@ KeFreezeExecution(IN PKTRAP_FRAME TrapFrame,
|
||||||
IN PKEXCEPTION_FRAME ExceptionFrame)
|
IN PKEXCEPTION_FRAME ExceptionFrame)
|
||||||
{
|
{
|
||||||
BOOLEAN Enable;
|
BOOLEAN Enable;
|
||||||
|
KIRQL OldIrql;
|
||||||
|
|
||||||
/* Disable interrupts and get previous state */
|
#ifndef CONFIG_SMP
|
||||||
|
UNREFERENCED_PARAMETER(TrapFrame);
|
||||||
|
UNREFERENCED_PARAMETER(ExceptionFrame);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Disable interrupts, get previous state and set the freeze flag */
|
||||||
Enable = KeDisableInterrupts();
|
Enable = KeDisableInterrupts();
|
||||||
|
|
||||||
/* Save freeze flag */
|
|
||||||
KiFreezeFlag = 4;
|
KiFreezeFlag = 4;
|
||||||
|
|
||||||
/* Save the old IRQL */
|
#ifndef CONFIG_SMP
|
||||||
KiOldIrql = KeGetCurrentIrql();
|
/* Raise IRQL if we have to */
|
||||||
|
OldIrql = KeGetCurrentIrql();
|
||||||
|
if (OldIrql < DISPATCH_LEVEL)
|
||||||
|
OldIrql = KeRaiseIrqlToDpcLevel();
|
||||||
|
#else
|
||||||
|
/* Raise IRQL to HIGH_LEVEL */
|
||||||
|
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
// TODO: Add SMP support.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Save the old IRQL to be restored on unfreeze */
|
||||||
|
KiOldIrql = OldIrql;
|
||||||
|
|
||||||
/* Return whether interrupts were enabled */
|
/* Return whether interrupts were enabled */
|
||||||
return Enable;
|
return Enable;
|
||||||
|
@ -45,9 +63,22 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KeThawExecution(IN BOOLEAN Enable)
|
KeThawExecution(IN BOOLEAN Enable)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
// TODO: Add SMP support.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Clear the freeze flag */
|
||||||
|
KiFreezeFlag = 0;
|
||||||
|
|
||||||
/* Cleanup CPU caches */
|
/* Cleanup CPU caches */
|
||||||
KeFlushCurrentTb();
|
KeFlushCurrentTb();
|
||||||
|
|
||||||
|
/* Restore the old IRQL */
|
||||||
|
#ifndef CONFIG_SMP
|
||||||
|
if (KiOldIrql < DISPATCH_LEVEL)
|
||||||
|
#endif
|
||||||
|
KeLowerIrql(KiOldIrql);
|
||||||
|
|
||||||
/* Re-enable interrupts */
|
/* Re-enable interrupts */
|
||||||
if (Enable) _enable();
|
KeRestoreInterrupts(Enable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue