3-325
INSTRUCTION SET REFERENCE
IRET/IRETDĀInterrupt Return (Continued)
THEN GP(selector; FI;
Read segment descriptor pointed to by the return code segment selector
IF return code segment descriptor is not a code segment THEN #GP(selector); FI;
IF return code segment selector RPL < CPL THEN #GP(selector); FI;
IF return code segment descriptor is conforming
AND return code segment DPL > return code segment selector RPL
THEN #GP(selector); FI;
IF return code segment descriptor is not present THEN #NP(selector); FI:
IF return code segment selector RPL > CPL
THEN GOTO RETURN-OUTER-PRIVILEGE-LEVEL;
ELSE GOTO RETURN-TO-SAME-PRIVILEGE-LEVEL
FI;
END;
RETURN-TO-SAME-PRIVILEGE-LEVEL: (* PE=1, VM=0 in flags image, RPL=CPL *)
IF EIP is not within code segment limits THEN #GP(0); FI;
EIP
<
tempEIP;
CS
<
tempCS; (* segment descriptor information also loaded *)
EFLAGS (CF, PF, AF, ZF, SF, TF, DF, OF, NT)
<
tempEFLAGS;
IF OperandSize=32
THEN
EFLAGS(RF, AC, ID)
<
tempEFLAGS;
FI;
IF CPL
?
IOPL
THEN
EFLAGS(IF)
<
tempEFLAGS;
FI;
IF CPL = 0
THEN
EFLAGS(IOPL)
<
tempEFLAGS;
IF OperandSize=32
THEN EFLAGS(VM, VIF, VIP)
<
tempEFLAGS;
FI;
FI;
END;
RETURN-TO-OUTER-PRIVILGE-LEVEL:
IF OperandSize=32
THEN
IF top 8 bytes on stack are not within limits THEN #SS(0); FI;
ELSE (* OperandSize=16 *)
IF top 4 bytes on stack are not within limits THEN #SS(0); FI;
FI;
Read return segment selector;
IF stack segment selector is null THEN #GP(0); FI;
IF return stack segment selector index is not within its descriptor table limits