NMI Support Patch 7:

[NTOS]: Improve UNHANDLED_PATH macro with a new "Reason" parameter which displays why the path is unhandled (ie: what the unexpected/unlikely/untested scenario is). This is better than just displaying the current PC which is typically useless.
    [NTOS]: Separate UNHANDLED_PATH from UNHANDLED_V86_PATH which is specifically for paths that are unimplemented due to lack of VDM support.
    [HAL]:  Update to new macros in V8086 support, and handle invalid opcode errors with a debug print (I encountered these when the NMI TSS was being used, since the IOPM was invalid).
    [HAL]:  If the V8086 GPF handler is called outside of V8086 mode, assume an NMI happened around the BIOS Call and just spin forever. We'll piggyback on the V8086 GPF handler during an NMI, in order to avoid the kernel's GPF handler which would attempt to panic/reset the display again (and cause endless NMI recursion/corruption).


svn path=/trunk/; revision=44861
This commit is contained in:
ReactOS Portable Systems Group 2010-01-01 21:03:22 +00:00
parent 6f0ef76efe
commit 1b1c2360bb
3 changed files with 81 additions and 31 deletions

View file

@ -34,8 +34,14 @@
_HalpSavedEsp: _HalpSavedEsp:
.long 0 .long 0
_InvalidMsg:
.asciz "HAL: An invalid V86 opcode was encountered at address %x:%x\n"
_InvalidGpfMsg:
.asciz "HAL: Trap0D while not in V86 mode\n"
_UnhandledMsg: _UnhandledMsg:
.asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx!!!\n" .asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx [%s]!!!\n"
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -143,8 +149,15 @@ _HalpRealModeEnd:
.func HalpOpcodeInvalid@0 .func HalpOpcodeInvalid@0
_HalpOpcodeInvalid@0: _HalpOpcodeInvalid@0:
/* Unhandled */ /* This should never happen -- is the IOPM damaged? */
UNHANDLED_PATH push [esi+HALP_BIOS_FRAME_EIP]
push [esi+HALP_BIOS_FRAME_CS]
push offset _InvalidMsg
call _DbgPrint
add esp, 12
/* Break */
int 3
/* Nothing to return */ /* Nothing to return */
xor eax, eax xor eax, eax
@ -376,7 +389,7 @@ _Ki16BitStackException:
add esp, [eax+KTHREAD_INITIAL_STACK] add esp, [eax+KTHREAD_INITIAL_STACK]
/* Switch to good stack segment */ /* Switch to good stack segment */
UNHANDLED_PATH UNHANDLED_PATH "16-Bit Stack"
.endfunc .endfunc
.globl _HalpTrap0D@0 .globl _HalpTrap0D@0
@ -391,8 +404,13 @@ _HalpTrap0D@0:
test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
jnz DoDispatch jnz DoDispatch
/* Unhandled */ /* This is weird -- but might happen during an NMI */
UNHANDLED_PATH push offset _InvalidGpfMsg
call _DbgPrint
add esp, 4
/* Loop forever */
jmp $
DoDispatch: DoDispatch:
/* Handle the opcode */ /* Handle the opcode */

View file

@ -87,19 +87,48 @@
// //
// @name UNHANDLED_PATH // @name UNHANDLED_PATH
// //
// This macro TODO // This macro prints out that the current code path is not expected yet
// //
// @param None // @param None
// //
// @remark None. // @remark None.
// //
.macro UNHANDLED_PATH .macro UNHANDLED_PATH Reason
/* Push reason */
push offset 1f
/* Get EIP */ /* Get EIP */
call $+5 call $+5
/* Print debug message */ /* Print debug message */
push offset _UnhandledMsg push offset _UnhandledMsg
call _DbgPrint call _DbgPrint
add esp, 12
/* Loop indefinitely */
jmp $
1:
.asciz \Reason
.endm
//
// @name UNHANDLED_V86_PATH
//
// This macro prints out that the current code path is for unhandled VDM support
//
// @param None
//
// @remark None.
//
.macro UNHANDLED_V86_PATH
/* Get EIP */
call $+5
/* Print debug message */
push offset _V86UnhandledMsg
call _DbgPrint
add esp, 8 add esp, 8
/* Loop indefinitely */ /* Loop indefinitely */

View file

@ -91,8 +91,11 @@ _KiUnexpectedEntrySize:
_UnexpectedMsg: _UnexpectedMsg:
.asciz "\n\x7\x7!!! Unexpected Interrupt %02lx !!!\n" .asciz "\n\x7\x7!!! Unexpected Interrupt %02lx !!!\n"
_V86UnhandledMsg:
.asciz "\n\x7\x7!!! Unhandled V8086 (VDM) support at line: %lx!!!\n"
_UnhandledMsg: _UnhandledMsg:
.asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx!!!\n" .asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx [%s]!!!\n"
_IsrTimeoutMsg: _IsrTimeoutMsg:
.asciz "\n*** ISR at %lx took over .5 second\n" .asciz "\n*** ISR at %lx took over .5 second\n"
@ -133,7 +136,7 @@ _KiTrapIoTable:
_KiGetTickCount: _KiGetTickCount:
_KiCallbackReturn: _KiCallbackReturn:
/* FIXME: TODO */ /* FIXME: TODO */
UNHANDLED_PATH UNHANDLED_PATH "TickCount/Callback Interrupts\n"
.func KiSystemService .func KiSystemService
TRAP_FIXUPS kss_a, kss_t, DoNotFixupV86, DoNotFixupAbios TRAP_FIXUPS kss_a, kss_t, DoNotFixupV86, DoNotFixupAbios
@ -458,7 +461,7 @@ V86_Exit:
AbiosExit: AbiosExit:
/* FIXME: TODO */ /* FIXME: TODO */
UNHANDLED_PATH UNHANDLED_PATH "ABIOS Exit"
.func KiRaiseAssertion .func KiRaiseAssertion
TRAP_FIXUPS kira_a, kira_t, DoFixupV86, DoFixupAbios TRAP_FIXUPS kira_a, kira_t, DoFixupV86, DoFixupAbios
@ -697,7 +700,7 @@ _DispatchTwoParam:
_KiFixupFrame: _KiFixupFrame:
/* TODO: Routine to fixup a KTRAP_FRAME when faulting from a syscall. */ /* TODO: Routine to fixup a KTRAP_FRAME when faulting from a syscall. */
UNHANDLED_PATH UNHANDLED_PATH "Trap Frame Fixup"
.endfunc .endfunc
.func KiTrap0 .func KiTrap0
@ -738,7 +741,7 @@ VdmCheck:
/* We don't support this yet! */ /* We don't support this yet! */
V86Int0: V86Int0:
/* FIXME: TODO */ /* FIXME: TODO */
UNHANDLED_PATH UNHANDLED_V86_PATH
.endfunc .endfunc
.func KiTrap1 .func KiTrap1
@ -781,7 +784,7 @@ V86Int1:
jz EnableInterrupts jz EnableInterrupts
/* We don't support VDM! */ /* We don't support VDM! */
UNHANDLED_PATH UNHANDLED_V86_PATH
.endfunc .endfunc
.globl _KiTrap2 .globl _KiTrap2
@ -847,7 +850,7 @@ V86Int3:
jz EnableInterrupts3 jz EnableInterrupts3
/* We don't support VDM! */ /* We don't support VDM! */
UNHANDLED_PATH UNHANDLED_V86_PATH
.endfunc .endfunc
.func KiTrap4 .func KiTrap4
@ -888,7 +891,7 @@ VdmCheck4:
/* We don't support this yet! */ /* We don't support this yet! */
V86Int4: V86Int4:
UNHANDLED_PATH UNHANDLED_V86_PATH
.endfunc .endfunc
.func KiTrap5 .func KiTrap5
@ -933,7 +936,7 @@ VdmCheck5:
/* We don't support this yet! */ /* We don't support this yet! */
V86Int5: V86Int5:
UNHANDLED_PATH UNHANDLED_V86_PATH
.endfunc .endfunc
.func KiTrap6 .func KiTrap6
@ -949,7 +952,7 @@ _KiTrap6:
VdmOpCodeFault: VdmOpCodeFault:
/* Not yet supported (Invalid OPCODE from V86) */ /* Not yet supported (Invalid OPCODE from V86) */
UNHANDLED_PATH UNHANDLED_V86_PATH
NotV86UD: NotV86UD:
/* Push error code */ /* Push error code */
@ -1025,7 +1028,7 @@ LockCrash:
IsVdmOpcode: IsVdmOpcode:
/* Unhandled yet */ /* Unhandled yet */
UNHANDLED_PATH UNHANDLED_V86_PATH
/* Return to caller */ /* Return to caller */
jmp _Kei386EoiHelper@0 jmp _Kei386EoiHelper@0
@ -1332,7 +1335,7 @@ V86Npx:
jz HandleUserNpx jz HandleUserNpx
/* V86 NPX not handled */ /* V86 NPX not handled */
UNHANDLED_PATH UNHANDLED_V86_PATH
EmulationEnabled: EmulationEnabled:
/* Did this come from kernel-mode? */ /* Did this come from kernel-mode? */
@ -1499,7 +1502,7 @@ RaiseIrql:
jnz NoReflect jnz NoReflect
/* FIXME: TODO */ /* FIXME: TODO */
UNHANDLED_PATH UNHANDLED_V86_PATH
NoReflect: NoReflect:
@ -1540,7 +1543,7 @@ NotV86:
jae KmodeGpf jae KmodeGpf
/* FIXME: TODO */ /* FIXME: TODO */
UNHANDLED_PATH UNHANDLED_PATH "Double GPF"
/* Get the opcode and trap frame */ /* Get the opcode and trap frame */
KmodeGpf: KmodeGpf:
@ -1629,7 +1632,7 @@ TrapCopy:
MsrCheck: MsrCheck:
/* FIXME: Handle RDMSR/WRMSR */ /* FIXME: Handle RDMSR/WRMSR */
UNHANDLED_PATH UNHANDLED_PATH "RDMSR/WRMSR"
NotIretGpf: NotIretGpf:
@ -1913,7 +1916,7 @@ SetException:
DispatchV86Gpf: DispatchV86Gpf:
/* FIXME */ /* FIXME */
UNHANDLED_PATH UNHANDLED_V86_PATH
.endfunc .endfunc
.func KiTrap14 .func KiTrap14
@ -2003,12 +2006,12 @@ AccessFail:
jnz CheckVdmPf jnz CheckVdmPf
/* FIXME: TODO */ /* FIXME: TODO */
UNHANDLED_PATH UNHANDLED_PATH "SYSENTER Fault"
jmp _Kei386EoiHelper@0 jmp _Kei386EoiHelper@0
SysCallCopyFault: SysCallCopyFault:
/* FIXME: TODO */ /* FIXME: TODO */
UNHANDLED_PATH UNHANDLED_PATH "SYSENTER Fault"
jmp _Kei386EoiHelper@0 jmp _Kei386EoiHelper@0
/* Check if the fault occured in a V86 mode */ /* Check if the fault occured in a V86 mode */
@ -2033,7 +2036,7 @@ CheckVdmPf:
VdmPF: VdmPF:
/* FIXME: TODO */ /* FIXME: TODO */
UNHANDLED_PATH UNHANDLED_V86_PATH
/* Save EIP and check what kind of status failure we got */ /* Save EIP and check what kind of status failure we got */
CheckStatus: CheckStatus:
@ -2067,7 +2070,7 @@ SpecialCode:
SlistFault: SlistFault:
/* FIXME: TODO */ /* FIXME: TODO */
UNHANDLED_PATH UNHANDLED_PATH "SLIST Fault"
IllegalState: IllegalState:
@ -2083,7 +2086,7 @@ IllegalState:
VdmAlertGpf: VdmAlertGpf:
/* FIXME: NOT SUPPORTED */ /* FIXME: NOT SUPPORTED */
UNHANDLED_PATH UNHANDLED_V86_PATH
HandleLockErrata: HandleLockErrata:
@ -2328,7 +2331,7 @@ VdmXmmi:
V86Xmmi: V86Xmmi:
/* V86 XMMI not handled */ /* V86 XMMI not handled */
UNHANDLED_PATH UNHANDLED_V86_PATH
KernelXmmi: KernelXmmi:
/* Another weird situation */ /* Another weird situation */
@ -2394,7 +2397,7 @@ _Ki16BitStackException:
add esp, [eax+KTHREAD_INITIAL_STACK] add esp, [eax+KTHREAD_INITIAL_STACK]
/* Switch to good stack segment */ /* Switch to good stack segment */
UNHANDLED_PATH UNHANDLED_PATH "16-Bit Stack"
.endfunc .endfunc
/* UNEXPECTED INTERRUPT HANDLERS **********************************************/ /* UNEXPECTED INTERRUPT HANDLERS **********************************************/