Exception Error Codes

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.

Table 14-8. Exceptions that Return Error Codes
Exception TypeVectorDoes the error code have the standard format shown in Figure 14-13 on page 290?
Double-Fault8No. Always pushes an error code value of 00000000h.
Invalid TSS10Yes. 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 Present11Yes. 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 Fault12Yes. 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 exception13Yes. 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:
  • An operand of the instruction.

  • A selector from a gate which is the operand of the instruction.

  • A selector from a TSS involved in a task switch.

  • IDT vector number.

Page Fault14Special 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:
  • P indicates whether the exception was due to a page not present, or to either an access rights violation or the use of a reserved bit.

  • W/R indicates whether the memory access that caused the exception was a read (0) or write (1).

  • U/S indicates whether the processor was executing at user mode (1) or supervisor mode (0) at the time of the exception.

  • The RSVD bit indicates that the processor detected 1s in one or more reserved bits of the selected PDE (when the CR4[PSE] or CR4[PAE] = 1). For more information on PSE, refer to “4MB Pages” on page 501. For more information on PAE, refer to “PAE-36 Mode” on page 554.

If a Page Fault is caused by a page-level protection violation, the Access bit in the PDE is set when the fault occurs. The behavior of IA32 processors regarding the Access flag in the corresponding PTE is model specific and not architecturally defined.
Alignment Check17No. Always pushes an error code value of 00000000h.

Figure 14-14. Page Fault Error Code Format (see Table 14-8 on page 287)


Figure 14-13. Standard Error Code Format (see “Exception Error Codes” on page 286for explanation)


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.107.193