Intel 253668-032US User Manual

Page of 806
6-48   Vol. 3
INTERRUPT AND EXCEPTION HANDLING
Interrupt 12—Stack Fault Exception (#SS)
Exception Class
Fault.
Description
Indicates that one of the following stack related conditions was detected:
A limit violation is detected during an operation that refers to the SS register. 
Operations that can cause a limit violation include stack-oriented instructions 
such as POP, PUSH, CALL, RET, IRET, ENTER, and LEAVE, as well as other memory 
references which implicitly or explicitly use the SS register (for example, MOV 
AX, [BP+6] or MOV AX, SS:[EAX+6]). The ENTER instruction generates this 
exception when there is not enough stack space for allocating local variables.
A not-present stack segment is detected when attempting to load the SS register. 
This violation can occur during the execution of a task switch, a CALL instruction 
to a different privilege level, a return to a different privilege level, an LSS 
instruction, or a MOV or POP instruction to the SS register.
A canonical violation is detected in 64-bit mode during an operation that 
reference memory using the stack pointer register containing a non-canonical 
memory address.
Recovery from this fault is possible by either extending the limit of the stack segment 
(in the case of a limit violation) or loading the missing stack segment into memory (in 
the case of a not-present violation. 
In the case of a canonical violation that was caused intentionally by software, 
recovery is possible by loading the correct canonical value into RSP. Otherwise, a 
canonical violation of the address in RSP likely reflects some register corruption in 
the software.
Exception Error Code
If the exception is caused by a not-present stack segment or by overflow of the new 
stack during an inter-privilege-level call, the error code contains a segment selector 
for the segment that caused the exception. Here, the exception handler can test the 
present flag in the segment descriptor pointed to by the segment selector to deter-
mine the cause of the exception. For a normal limit violation (on a stack segment 
already in use) the error code is set to 0.
Saved Instruction Pointer
The saved contents of CS and EIP registers generally point to the instruction that 
generated the exception. However, when the exception results from attempting to 
load a not-present stack segment during a task switch, the CS and EIP registers point 
to the first instruction of the new task.