The processor pushes a 32-bit error code (if the current code segment's default operand size is 16-bits, it's a 16-bit error code) onto the stack for certain types of software exception conditions. Table 14-8 on page 287 lists the exceptions that return error codes. The format of the error code is shown in Figure 14-13 on page 290. The error code indicates the following:
The EXT bit = 1 if an event external to the program caused the error. As an example, EXT = 1 if a hardware interrupt selected a Task Gate pointing to an invalid TSS selector in the IDT.
The IDT bit = 1 if the error is associated with an entry in the IDT. In this case, the Selector Index field indicates the IDT entry in question.
A zero in the IDT bit indicates that the error is associated with an entry in the LDT or GDT. In this case, the state of the TI (Table Indicator) bit indicates whether the entry in question resides in the GDT (TI = 0), or LDT (TI = 1). The Selector Index field indicates the table entry in question.
Exception Type | Vector | Does the error code have the standard format shown in Figure 14-13 on page 290? |
---|---|---|
Double-Fault | 8 | No. Always pushes an error code value of 00000000h. |
Invalid TSS | 10 | Yes. The error code identifies the segment selector index for the segment descriptor that caused the violation. If EXT = 1, it indicates that the exception was caused by an event external to the currently running program (e.g., if an hardware interrupt handler using a Task Gate attempted a task switch to an invalid TSS). |
Segment Not Present | 11 | Yes. The error code identifies the segment selector index for the segment descriptor that caused the violation. If EXT = 1, it indicates that the exception resulted from an external event (NMI or INTR) that caused an interrupt, which subsequently referenced a segment that isn't present in memory. IDT = 1 if the error code refers to an IDT entry containing a descriptor with the Present bit = 0. |
Stack Fault | 12 | Yes. If the exception occurred because the stack segment isn't present in memory or due to a stack overflow of the newly created stack during an inter-privilege-level call, the error code contains a segment selector for the segment that caused the exception. The exception handler can test the Present bit in the segment descriptor pointed to by the segment selector to determine the cause of the exception. For a normal limit violation (on a stack segment already in use) the error code is set to 0. |
GP exception | 13 | Yes. If the fault was detected while loading a segment descriptor from memory, the error code contains either a segment selector or the IDT vector number for the descriptor; otherwise, the error code is 0. The source of the selector in an error code may be any of the following:
|
Page Fault | 14 | Special format (see Figure 14-14 on page 290). CR2 contains the 32-bit linear address that caused the fault. The error code tells the exception handler four things:
|
Alignment Check | 17 | No. Always pushes an error code value of 00000000h. |
3.144.107.193