Initializing the Interrupt Descriptor Table
Now that you understand what the Intel processor does with interrupts and exceptions at the hardware level, we can move on to describe how the Interrupt Descriptor Table is initialized.
Remember that before the kernel enables the interrupts, it must load
the initial address of the IDT table into the idtr
register and initialize all the entries of that table. This activity
is done while initializing the system (see Appendix A).
The int
instruction allows a User Mode
process to issue an interrupt signal that has an arbitrary vector
ranging from 0 to 255. Therefore, initialization of the IDT must be
done carefully, to block illegal interrupts and exceptions simulated
by User Mode processes via int instructions. This
can be achieved by setting the DPL field of the Interrupt or Trap
Gate Descriptor to 0. If the process attempts to issue one of these
interrupt signals, the control unit checks the CPL value against the
DPL field and issues a “General
protection” exception.
In a few cases, however, a User Mode process must be able to issue a programmed exception. To allow this, it is sufficient to set the DPL field of the corresponding Interrupt or Trap Gate Descriptors to 3 — that is, as high as possible.
Let’s now see how Linux implements this strategy.
Interrupt, Trap, and System Gates
As mentioned in the earlier section Section 4.2.3, Intel provides three types of interrupt descriptors: Task, Interrupt, and Trap Gate Descriptors. Task Gate ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access