Page 1 of 1
non-mapped enterys in the idt
Posted: Fri Feb 23, 2007 11:11 am
by GLneo
hi all, not really a problem but most likely just a stupid question: when you make an IDT table the unused INT's a just full of random data ( i know you can set a limit , but i need INT 0x60 and nothing below until 0x30 ), i tried and "INT $0x50" in my kernel and i got an ERROR: "???", in windows an "access violation", do i have to just wire 256 INT's to my ISR handler and give a "spurious interrupt:" error or am i missing something ?
thx!
Re: non-mapped enterys in the idt
Posted: Fri Feb 23, 2007 12:08 pm
by Brendan
Hi,
GLneo wrote:hi all, not really a problem but most likely just a stupid question: when you make an IDT table the unused INT's a just full of random data ( i know you can set a limit , but i need INT 0x60 and nothing below until 0x30 ), i tried and "INT $0x50" in my kernel and i got an ERROR: "???", in windows an "access violation", do i have to just wire 256 INT's to my ISR handler and give a "spurious interrupt:" error or am i missing something ?
Some interrupts aren't intended (by the OS developer) to be used by applications as software interrupts. Some of these will be exception handlers, some will be IRQ handlers, some will be for IPIs (if the OS ever supports SMP) and some will be unused.
For exceptions, IRQ handlers and IPIs it's easy to protect them with the CPUs built in protection, where applications get a general protection fault if they try to use them as software interrupts. Why not treat intentionally unused IDT entries the same (i.e. make them generate a general protection fault too, by making sure the "present' bit is not set)?
I guess what I'm saying is fill your IDT with zeros instead of leaving random trash in it....
Cheers,
Brendan
Posted: Fri Feb 23, 2007 12:29 pm
by GLneo
ok, I see... , but in my OS if you "int $0x0" you make a zero division error but in windows you get protection error or something, does this have to do with ring 3 privileges?
Posted: Fri Feb 23, 2007 12:47 pm
by Otter
In windows you are not allowed to call interrupts, especialliy not the hardware/processor interrupts ( 0x00 is a interrupt called by the processor )
Posted: Fri Feb 23, 2007 1:00 pm
by GLneo
but how does it know?
Posted: Fri Feb 23, 2007 1:26 pm
by Otter
Windows is a 32 bit protected mode system ( at least the modern versions ), which sets up the idt. If you call an interrupt, the system uses the idt, and if the idt entry is for ring 0 , ring 3 processes can not call it. But if you do a division by zero, the processor detects it, switches to ring0 and calls the isr.
If you try to call it manually, the processor checks whether you have the correct ring or not.
Posted: Fri Feb 23, 2007 1:29 pm
by JAAman
set the DPL of the entry to the highest ring you want to be able to call it
then if any soft-int occures, where CPL>int.DPL, then the CPU will trigger a GPF instead
for more information, read section 5.12.1.1
The Holy Intel Manual wrote:
the processor checks the DPL of the interrupt of trap gate only if an exception or interrupt is generated with an INT n, INT 3, or INTO instruction. Here, the CPL must be less than or equal to the DPL of the gate. This restriction prevents application programs or procedures running at privilege level 3 from using a software interrupt to access critical exception handlers, such as page-fault handler, providing that those handlers are placed in more privileged code segments (numerically lower privilege level). For hardware-generated interrupts and processor-detected exceptions, the processor ignores the DPL of interrupt and trap gates.