Interrupt Vector 0x08 Not Pushing Error Code
Posted: Thu Jul 04, 2013 5:12 pm
Hi,
I am trying to get software interrupts working. After loading the GDT, IDT, and then reloading the segment registers, shortly after I enable interrupts, a double fault (0x08) is set. I have done nothing with hardware interrupts yet.
While trying to track down the cause, it seems that the vector is not passing an error code. The Intel Docs say that it should.
I used a Bochs magic breakpoint to stop immediately after the interrupt fires. Using the idea here, all interrupt handlers push a dummy error code 0 if the CPU didn't, push the interrupt vector number, and then call a common subroutine.
In the following image, you can see the IDT entry 0x08 pointing to 0x0008:0x001035F1 (note that the code segment accounts for the 0x0008 in the address). 0x0008:0x001035F1 is shown on the left, where the magic breakpoint stopped us. Notice the surrounding interrupt vectors 0x07 and 0x09, neither of which are supposed to pass error codes. Consequently, they push 0 onto the stack first. However, since interrupt vector 0x08 is supposed to push an error code, it only pushes the interrupt number.
In the following image from an identical rerun, you can see the stack. According to the manual (pg. 247-248), it should push eflags, cs, eip, and the error code (if any). Address 0x0018490C is eflags, address 0x00184908 is cs, and address 0x00184904 was the eip. Notice the lack of error code.
When the next instruction happens, it pushes an 8 onto the stack, and the program continues. Unfortunately, since the interrupt handler was expecting an error code, the stack gets munged.
So: what causes the double fault, and why is it that the vector only pushed three values onto the stack?
Thanks,
P.S. if you need the source, the SVN in my signature has been updated with the whole thing.
I am trying to get software interrupts working. After loading the GDT, IDT, and then reloading the segment registers, shortly after I enable interrupts, a double fault (0x08) is set. I have done nothing with hardware interrupts yet.
While trying to track down the cause, it seems that the vector is not passing an error code. The Intel Docs say that it should.
I used a Bochs magic breakpoint to stop immediately after the interrupt fires. Using the idea here, all interrupt handlers push a dummy error code 0 if the CPU didn't, push the interrupt vector number, and then call a common subroutine.
In the following image, you can see the IDT entry 0x08 pointing to 0x0008:0x001035F1 (note that the code segment accounts for the 0x0008 in the address). 0x0008:0x001035F1 is shown on the left, where the magic breakpoint stopped us. Notice the surrounding interrupt vectors 0x07 and 0x09, neither of which are supposed to pass error codes. Consequently, they push 0 onto the stack first. However, since interrupt vector 0x08 is supposed to push an error code, it only pushes the interrupt number.
In the following image from an identical rerun, you can see the stack. According to the manual (pg. 247-248), it should push eflags, cs, eip, and the error code (if any). Address 0x0018490C is eflags, address 0x00184908 is cs, and address 0x00184904 was the eip. Notice the lack of error code.
When the next instruction happens, it pushes an 8 onto the stack, and the program continues. Unfortunately, since the interrupt handler was expecting an error code, the stack gets munged.
So: what causes the double fault, and why is it that the vector only pushed three values onto the stack?
Thanks,
P.S. if you need the source, the SVN in my signature has been updated with the whole thing.