Volume 3: General-Purpose and System Instructions - Stanford ...
Volume 3: General-Purpose and System Instructions - Stanford ... Volume 3: General-Purpose and System Instructions - Stanford ...
AMD64 Technology 24594 Rev. 3.10 February 2005INTInterrupt to VectorTransfers execution to the interrupt handler specified by an 8-bit unsigned immediatevalue. This value is an interrupt vector number (00h to FFh), which the processor usesas an index into the interrupt-descriptor table (IDT).For detailed descriptions of the steps performed by INTn instructions, see thefollowing:• Legacy-Mode Interrupts: “Legacy Protected-Mode Interrupt Control Transfers” inVolume 2.• Long-Mode Interrupts: “Long-Mode Interrupt Control Transfers” in Volume 2.See also the descriptions of the INT3 instruction on page 304 and the INTOinstruction on page 164.Mnemonic Opcode DescriptionINT imm8 CD ib Call interrupt service routine specified by interrupt vector imm8.Action// See “Pseudocode Definitions” on page 49.INT_N_START:IF (REAL_MODE)INT_N_REALELSIF (PROTECTED_MODE)INT_N_PROTECTEDELSE // (VIRTUAL_MODE)INT_N_VIRTUALINT_N_REAL:temp_int_n_vector = byte-sized interrupt vector specified in the instruction,zero-extended to 64 bitstemp_RIP = READ_MEM.w [idt:temp_int_n_vector*4]// read target CS:RIP from the real-mode idttemp_CS = READ_MEM.w [idt:temp_int_n_vector*4+2]PUSH.w old_RFLAGSPUSH.w old_CSPUSH.w next_RIP156 INT
24594 Rev. 3.10 February 2005 AMD64 TechnologyIF (temp_RIP>CS.limit)EXCEPTION [#GP]CS.sel = temp_CSCS.base = temp_CS SHL 4RFLAGS.AC,TF,IF,RF clearedRIP = temp_RIPEXITINT_N_PROTECTED:temp_int_n_vector = byte-sized interrupt vector specified in the instruction,zero-extended to 64 bitstemp_idt_desc = READ_IDT (temp_int_n_vector)IF (temp_idt_desc.attr.type = ’taskgate’)TASK_SWITCH // using tss selector in the task gate as the target tssIF (LONG_MODE) // The size of the gate controls the size of the// stack pushes.V=8-byte // Long mode only uses 64-bit gates.ELSIF ((temp_idt_desc.attr.type = ’intgate32’)|| (temp_idt_desc.attr.type = ’trapgate32’))V=4-byte // Legacy mode, using a 32-bit gateELSE // gate is intgate16 or trapgate16V=2-byte // Legacy mode, using a 16-bit gatetemp_RIP = temp_idt_desc.offsetIF (LONG_MODE){// In long mode, we need to read the 2nd half of a// 16-byte interrupt-gate from the IDT, to get the// upper 32 bits of the target RIPtemp_upper = READ_MEM.q [idt:temp_int_n_vector*16+8]}temp_RIP = tempRIP + (temp_upper SHL 32) // concatenate both halves of RIPCS = READ_DESCRIPTOR (temp_idt_desc.segment, intcs_chk)IF (CS.attr.conforming=1)temp_CPL = CPLELSEtemp_CPL = CS.attr.dplIF (CPL=temp_CPL){IF (LONG_MODE)// no privilege-level changeINT 157
- Page 136 and 137: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 138 and 139: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 140 and 141: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 142 and 143: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 144 and 145: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 146 and 147: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 148 and 149: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 150 and 151: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 152 and 153: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 154 and 155: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 156 and 157: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 158 and 159: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 160 and 161: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 162 and 163: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 164 and 165: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 166 and 167: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 168 and 169: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 170 and 171: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 172 and 173: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 174 and 175: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 176 and 177: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 178 and 179: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 180 and 181: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 182 and 183: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 184 and 185: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 188 and 189: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 190 and 191: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 192 and 193: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 194 and 195: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 196 and 197: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 198 and 199: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 200 and 201: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 202 and 203: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 204 and 205: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 206 and 207: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 208 and 209: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 210 and 211: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 212 and 213: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 214 and 215: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 216 and 217: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 218 and 219: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 220 and 221: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 222 and 223: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 224 and 225: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 226 and 227: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 228 and 229: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 230 and 231: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 232 and 233: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 234 and 235: AMD64 Technology 24594 Rev. 3.10 Fe
24594 Rev. 3.10 February 2005 AMD64 TechnologyIF (temp_RIP>CS.limit)EXCEPTION [#GP]CS.sel = temp_CSCS.base = temp_CS SHL 4RFLAGS.AC,TF,IF,RF clearedRIP = temp_RIPEXITINT_N_PROTECTED:temp_int_n_vector = byte-sized interrupt vector specified in the instruction,zero-extended to 64 bitstemp_idt_desc = READ_IDT (temp_int_n_vector)IF (temp_idt_desc.attr.type = ’taskgate’)TASK_SWITCH // using tss selector in the task gate as the target tssIF (LONG_MODE) // The size of the gate controls the size of the// stack pushes.V=8-byte // Long mode only uses 64-bit gates.ELSIF ((temp_idt_desc.attr.type = ’intgate32’)|| (temp_idt_desc.attr.type = ’trapgate32’))V=4-byte // Legacy mode, using a 32-bit gateELSE // gate is intgate16 or trapgate16V=2-byte // Legacy mode, using a 16-bit gatetemp_RIP = temp_idt_desc.offsetIF (LONG_MODE){// In long mode, we need to read the 2nd half of a// 16-byte interrupt-gate from the IDT, to get the// upper 32 bits of the target RIPtemp_upper = READ_MEM.q [idt:temp_int_n_vector*16+8]}temp_RIP = tempRIP + (temp_upper SHL 32) // concatenate both halves of RIPCS = READ_DESCRIPTOR (temp_idt_desc.segment, intcs_chk)IF (CS.attr.conforming=1)temp_CPL = CPLELSEtemp_CPL = CS.attr.dplIF (CPL=temp_CPL){IF (LONG_MODE)// no privilege-level changeINT 157