Author: sginsberg Date: Tue Sep 1 13:20:50 2015 New Revision: 68894
URL: http://svn.reactos.org/svn/reactos?rev=68894&view=rev Log: - Fix what should hopefully be the last bug in the floating point state save/load code -- in KiNpxHandler check if the state is loaded before unloading it instead of checking if it is *unloaded* before... unloading it. Also clear up some comments. - Thomas is da man.
Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.c... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Tue Sep 1 13:20:50 2015 @@ -262,8 +262,8 @@ } }
- /* User or kernel trap -- get ready to issue an exception */ - if (Thread->NpxState == NPX_STATE_NOT_LOADED) + /* User or kernel trap -- check if we need to unload the current state */ + if (Thread->NpxState == NPX_STATE_LOADED) { /* Update CR0 */ Cr0 = __readcr0(); @@ -310,8 +310,6 @@ }
/* Get legal exceptions that software should handle */ - /* We do this by first masking off from the Mask the bits we need, */ - /* This is done so we can keep the FSW_STACK_FAULT bit in Error. */ Mask &= (FSW_INVALID_OPERATION | FSW_DENORMAL | FSW_ZERO_DIVIDE | @@ -323,9 +321,10 @@ /* Check for invalid operation */ if (Error & FSW_INVALID_OPERATION) { - /* NOTE: Stack fault is handled differently than any other case. */ - /* 1. It's only raised for invalid operation. */ - /* 2. It's only raised if invalid operation is not masked. */ + /* + * Now check if this is actually a Stack Fault. This is needed because + * on x86 the Invalid Operation error is set for Stack Check faults as well. + */ if (Error & FSW_STACK_FAULT) { /* Issue stack check fault */ @@ -335,12 +334,14 @@ DataOffset, TrapFrame); } - - /* Issue fault */ - KiDispatchException1Args(STATUS_FLOAT_INVALID_OPERATION, - ErrorOffset, - 0, - TrapFrame); + else + { + /* This is an invalid operation fault after all, so raise that instead */ + KiDispatchException1Args(STATUS_FLOAT_INVALID_OPERATION, + ErrorOffset, + 0, + TrapFrame); + } }
/* Check for divide by zero */