Author: tkreuzer
Date: Sat Sep 10 23:05:10 2011
New Revision: 53679
URL:
http://svn.reactos.org/svn/reactos?rev=53679&view=rev
Log:
[NTOSKRNL]
The handlers for unexpected interrupts that we generate from asm macros use a push
instruction with an 8 bit operand to push the interrupt number on the stack. Now the 8 bit
push has the unfortunate behaviour of sign extending to 32 bit. But since the assembler is
smart (or at least thinks so) it will not generate such a push instruction for values
larger than 0x7f. This resulted in 7 bytes long stubs in the range of 0x30 .. 0x7f and 10
bytes long stubs after that. To fix this 128 is substracted from the value and later
readded in the common code path. A second issue arose, because the assembler would start
to use 8 bit relative short jumps as soon as the target was less than 127 bytes away,
which happened for some of the higher interrupts, which then had a smaller stub then the
others. Fix this by moving the stubs up in the code further away from the target label, so
that always 32bit relative jumps will be used. These problems didn't show up so far,
since we used the PIC and interrupts in the range of 0x30 .. 0x40 and the code that relied
on the stubs all having the same length was working well. This changes with an APIC based
hal, where interrupts of much higher number are likely to be used.
Modified:
trunk/reactos/ntoskrnl/ke/i386/trap.s
Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] Sat Sep 10 23:05:10 2011
@@ -13,14 +13,16 @@
#include <ks386.inc>
#include <internal/i386/asmmacro.S>
-MACRO(GENERATE_IDT_STUB, Number)
-idt _KiUnexpectedInterrupt&Number, INT_32_DPL0
+MACRO(GENERATE_IDT_STUB, Vector)
+idt _KiUnexpectedInterrupt&Vector, INT_32_DPL0
ENDM
-MACRO(GENERATE_INT_HANDLER, Number)
+MACRO(GENERATE_INT_HANDLER, Vector)
//.func KiUnexpectedInterrupt&Number
-_KiUnexpectedInterrupt&Number:
- push PRIMARY_VECTOR_BASE + Number
+_KiUnexpectedInterrupt&Vector:
+ /* This is a push instruction with 8bit operand. Since the instruction
+ sign extends the value to 32 bits, we need to offset it */
+ push (Vector - 128)
jmp _KiEndUnexpectedRange@0
//.endfunc
ENDM
@@ -66,7 +68,7 @@
idt _KiDebugService, INT_32_DPL3 /* INT 2D: Debug Service Handler */
idt _KiSystemService, INT_32_DPL3 /* INT 2E: System Call Service Handler */
idt _KiTrap0F, INT_32_DPL0 /* INT 2F: RESERVED */
-i = 0
+i = HEX(30)
REPEAT 208
GENERATE_IDT_STUB %i
i = i + 1
@@ -80,10 +82,18 @@
PUBLIC _KiUnexpectedEntrySize
_KiUnexpectedEntrySize:
- .long _KiUnexpectedInterrupt1 - _KiUnexpectedInterrupt0
+ .long _KiUnexpectedInterrupt49 - _KiUnexpectedInterrupt48
/******************************************************************************/
.code
+
+PUBLIC _KiStartUnexpectedRange@0
+_KiStartUnexpectedRange@0:
+i = HEX(30)
+REPEAT 208
+ GENERATE_INT_HANDLER %i
+ i = i + 1
+ENDR
TRAP_ENTRY KiTrap00, KI_PUSH_FAKE_ERROR_CODE
TRAP_ENTRY KiTrap01, KI_PUSH_FAKE_ERROR_CODE
@@ -140,15 +150,10 @@
KiCallHandler @KiFastCallEntryHandler@8
.ENDP KiFastCallEntry
-PUBLIC _KiStartUnexpectedRange@0
-_KiStartUnexpectedRange@0:
-i = 0
-REPEAT 208
- GENERATE_INT_HANDLER %i
- i = i + 1
-ENDR
+
PUBLIC _KiEndUnexpectedRange@0
_KiEndUnexpectedRange@0:
+ add dword ptr[esp], 128
jmp _KiUnexpectedInterruptTail