Intel 64 and IA-32 Architectures Software Developers Manual Volume 2A, Instruction Set Reference, A-M

3-470 Vol. 2
INSTRUCTION SET REFERENCE, A-M
IF VM
= 0
THEN
GOTO INTER-PRIVILEGE-LEVEL-INTERRUPT;
(* PE
= 1, interrupt or trap gate, nonconforming
code segment, DPL < CPL, VM
= 0 *)
ELSE (* VM
= 1 *)
IF code segment DPL
0
THEN #GP; (new code segment selector);
GOTO INTERRUPT-FROM-VIRTUAL-8086-MODE; FI;
(* PE
= 1, interrupt or trap gate, DPL < CPL, VM = 1 *)
FI;
ELSE (* PE
= 1, interrupt or trap gate, DPL CPL *)
IF VM
= 1
THEN #GP(new code segment selector); FI;
IF code segment is conforming or code segment DPL
= CPL
THEN
GOTO INTRA-PRIVILEGE-LEVEL-INTERRUPT;
ELSE
#GP(CodeSegmentSelector + EXT);
(* PE
= 1, interrupt or trap gate, nonconforming
code segment, DPL > CPL *)
FI;
FI;
END;
INTER-PRIVILEGE-LEVEL-INTERRUPT:
(* PE
= 1, interrupt or trap gate, non-conforming code segment, DPL < CPL *)
(* Check segment selector and descriptor for stack of new privilege level in current TSS *)
IF current TSS is 32-bit TSS
THEN
TSSstackAddress (new code segment DPL 8) + 4;
IF (TSSstackAddress + 7) > TSS limit
THEN #TS(current TSS selector); FI;
NewSS TSSstackAddress + 4;
NewESP stack address;
ELSE
IF current TSS is 16-bit TSS
THEN(* TSS is 16-bit *)
TSSstackAddress (new code segment DPL 4) + 2
IF (TSSstackAddress + 4) > TSS limit
THEN #TS(current TSS selector); FI;
NewESP TSSstackAddress;
NewSS TSSstackAddress + 2;
ELSE (* TSS is 64-bit *)