Interrupt Vector 0x08 Not Pushing Error Code
-
- Member
- Posts: 77
- Joined: Tue Nov 20, 2012 4:45 pm
- Contact:
Interrupt Vector 0x08 Not Pushing Error Code
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.
Last edited by Geometrian on Wed Jan 31, 2024 5:40 pm, edited 1 time in total.
Re: Interrupt Vector 0x08 Not Pushing Error Code
Without reading the whole post, I guess you haven't properly setup PIC and timer IRQ (INT08 upon boot) messed things up.Geometrian wrote: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.
-
- Member
- Posts: 77
- Joined: Tue Nov 20, 2012 4:45 pm
- Contact:
Re: Interrupt Vector 0x08 Not Pushing Error Code
I haven't done anything with hardware interrupts yet, including remap the PIC to different interrupt vectors. I had thought of this, especially since exactly where the interrupt happens varies, but based on skimming the PIC pages in the wiki, I had thought that hardware interrupts would not be available to the CPU until the PIC was configured. Is that incorrect?bluemoon wrote:Without reading the whole post, I guess you haven't properly setup PIC and timer IRQ (INT08 upon boot) messed things up.Geometrian wrote: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.
Re: Interrupt Vector 0x08 Not Pushing Error Code
No, the PIC is preconfigured And enabled by BIOS at boot. It will tick at a its lowest frequency however. By enabling interrupts you enable the CPU to receive external interrupts. If you only want software ones, don't do an STI
-
- Member
- Posts: 77
- Joined: Tue Nov 20, 2012 4:45 pm
- Contact:
-
- Member
- Posts: 77
- Joined: Tue Nov 20, 2012 4:45 pm
- Contact:
Re: Interrupt Vector 0x08 Not Pushing Error Code
I suppose this raises a different question though: does any PIC IRQ ever push an error code?
Re: Interrupt Vector 0x08 Not Pushing Error Code
No.
As IRQs are not errors.
As IRQs are not errors.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Interrupt Vector 0x08 Not Pushing Error Code
Interestingly, this whole sequence has been discussed in the FAQ... Maybe you should go read it before you end up with more surprises
-
- Member
- Posts: 77
- Joined: Tue Nov 20, 2012 4:45 pm
- Contact:
Re: Interrupt Vector 0x08 Not Pushing Error Code
It's a good suggestion. I have read all the basic pages completely at least once, and recently the ones on interrupts, the GDT, the IDT, and the PIC I've read and reread very thoroughly. Sometimes I don't understand all of them (in this case, I misunderstood them), but the fact I've made any progress at all shows that your wiki works . Thanks,Combuster wrote:Interestingly, this whole sequence has been discussed in the FAQ... Maybe you should go read it before you end up with more surprises
Re: Interrupt Vector 0x08 Not Pushing Error Code
It's your wiki now too.Geometrian wrote:but the fact I've made any progress at all shows that your wiki works . Thanks,
Learn to read.
-
- Member
- Posts: 77
- Joined: Tue Nov 20, 2012 4:45 pm
- Contact:
Re: Interrupt Vector 0x08 Not Pushing Error Code
Ostensibly so, although my edits so far have been mostly to fix typos (with which the wiki unfortunately abounds).dozniak wrote:It's your wiki now too.
Re: Interrupt Vector 0x08 Not Pushing Error Code
Hi Geometrian,
Show us the code that invokes the interrupt or that causes the #DF. Are you invoking it through an "INT 8" instruction?
Show us the code that invokes the interrupt or that causes the #DF. Are you invoking it through an "INT 8" instruction?
-
- Member
- Posts: 77
- Joined: Tue Nov 20, 2012 4:45 pm
- Contact:
Re: Interrupt Vector 0x08 Not Pushing Error Code
As established above, the problem was due to an IRQ from the PIC, which hadn't been remapped.JohnXiba wrote:Show us the code that invokes the interrupt or that causes the #DF. Are you invoking it through an "INT 8" instruction?
Cheers,
Re: Interrupt Vector 0x08 Not Pushing Error Code
Sorry, my mistake