beautypg.com

Intel IA-32 User Manual

Page 230

background image

5-54 Vol. 3A

INTERRUPT AND EXCEPTION HANDLING

When executing this code on one of the 32-bit IA-32 processors, it is possible to get a page fault,
general-protection fault (#GP), or alignment check fault (#AC) after the segment selector has
been loaded into the SS register but before the ESP register has been loaded. At this point, the
two parts of the stack pointer (SS and ESP) are inconsistent. The new stack segment is being
used with the old stack pointer.

The processor does not use the inconsistent stack pointer if the exception handler switches to a
well defined stack (that is, the handler is a task or a more privileged procedure). However, if the
exception handler is called at the same privilege level and from the same task, the processor will
attempt to use the inconsistent stack pointer.

In systems that handle page-fault, general-protection, or alignment check exceptions within the
faulting task (with trap or interrupt gates), software executing at the same privilege level as the
exception handler should initialize a new stack by using the LSS instruction rather than a pair
of MOV instructions, as described earlier in this note. When the exception handler is running at
privilege level 0 (the normal case), the problem is limited to procedures or tasks that run at priv-
ilege level 0, typically the kernel of the operating system.