From 3d119713b4e876012b7f72ca1e2a04f7e2df214e Mon Sep 17 00:00:00 2001 From: Stefan Ginsberg Date: Fri, 6 Apr 2012 20:13:33 +0000 Subject: [PATCH] - Even while I love having the trap/fpu/context code in C, the bugs this switch introduced continue to amaze me. This time, fix a bug from 45156 when KiFlushNPXState was rewritten in C. The C version could miss to restore the interrupt state, which would lead to interrupts being disabled when it was not expected. This "interrupt leak" was seen in the page fault handler if a page fault occurred after interrupts had been disabled (which had sometimes been observed to occur on the test server during exception handling and thread creation when KiFlushNPXState had been called). This didn't completely hang the system because during thread creation (and other system calls where this may have happened) interrupts would be re-enabled when returning to user mode when restoring eflags, and the exception handling would result in a system call which would enable interrupts again (it appears exception handler would have run with interrupts disabled, though!). This is now fixed, as well as any other issues this might have caused. The hack in the page fault handler remains until another issue has been fixed. svn path=/trunk/; revision=56333 --- reactos/ntoskrnl/ke/i386/cpu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/ke/i386/cpu.c b/reactos/ntoskrnl/ke/i386/cpu.c index a1c44a81184..8e63a9e5c35 100644 --- a/reactos/ntoskrnl/ke/i386/cpu.c +++ b/reactos/ntoskrnl/ke/i386/cpu.c @@ -1323,7 +1323,12 @@ KiFlushNPXState(IN PFLOATING_SAVE_AREA SaveArea) if (Thread->NpxState != NPX_STATE_LOADED) { /* If there's nothing to load, quit */ - if (!SaveArea) return; + if (!SaveArea) + { + /* Restore interrupt state and return */ + __writeeflags(EFlags); + return; + } /* Need FXSR support for this */ ASSERT(KeI386FxsrPresent == TRUE);