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 2005• RFLAGS.RF is cleared to 0.For further details on the SYSCALL and SYSRET instructions and their associatedMSR registers (STAR, LSTAR, CSTAR, and SYSCALL_FLAG_MASK), see “FastSystem Call and Return” in Volume 2.Mnemonic Opcode DescriptionSYSCALL 0F 05 Call operating system.Action// See “Pseudocode Definitions” on page 49.SYSCALL_START:IF (MSR_EFER.SCE = 0)EXCEPTION [#UD]// Check if syscall/sysret are enabled.IF (LONG_MODE)SYSCALL_LONG_MODEELSE // (LEGACY_MODE)SYSCALL_LEGACY_MODESYSCALL_LONG_MODE:RCX.q = next_RIPR11.q = RFLAGS// with rf clearedIF (64BIT_MODE)temp_RIP.q = MSR_LSTARELSE // (COMPATIBILITY_MODE)temp_RIP.q = MSR_CSTARCS.sel = MSR_STAR.SYSCALL_CS AND 0xFFFCCS.attr = 64-bit code,dpl0 // Always switch to 64-bit mode in long mode.CS.base = 0x00000000CS.limit = 0xFFFFFFFFSS.sel = MSR_STAR.SYSCALL_CS + 8SS.attr = 64-bit stack,dpl0SS.base = 0x00000000SS.limit = 0xFFFFFFFFRFLAGS = RFLAGS AND ~MSR_SFMASKRFLAGS.RF = 0CPL = 0356 SYSCALL
24594 Rev. 3.10 February 2005 AMD64 TechnologyRIP = temp_RIPEXITSYSCALL_LEGACY_MODE:RCX.d = next_RIPtemp_RIP.d = MSR_STAR.EIPCS.sel = MSR_STAR.SYSCALL_CS AND 0xFFFCCS.attr = 32-bit code,dpl0 // Always switch to 32-bit mode in legacy mode.CS.base = 0x00000000CS.limit = 0xFFFFFFFFSS.sel = MSR_STAR.SYSCALL_CS + 8SS.attr = 32-bit stack,dpl0SS.base = 0x00000000SS.limit = 0xFFFFFFFFRFLAGS.VM,IF,RF=0CPL = 0RIP = temp_RIPEXITRelated InstructionsSYSRET, SYSENTER, SYSEXITrFLAGS AffectedID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CFM M M M 0 0 M M M M M M M M M M M21 20 19 18 17 16 14 13–12 11 10 9 8 7 6 4 2 0Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to one or cleared to zero is M (modified). Unaffected flags are blank. Undefinedflags are U.SYSCALL 357
- Page 336 and 337: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 338 and 339: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 340 and 341: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 342 and 343: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 344 and 345: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 346 and 347: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 348 and 349: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 350 and 351: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 352 and 353: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 354 and 355: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 356 and 357: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 358 and 359: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 360 and 361: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 362 and 363: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 364 and 365: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 366 and 367: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 368 and 369: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 370 and 371: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 372 and 373: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 374 and 375: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 376 and 377: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 378 and 379: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 380 and 381: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 382 and 383: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 384 and 385: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 388 and 389: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 390 and 391: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 392 and 393: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 394 and 395: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 396 and 397: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 398 and 399: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 400 and 401: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 402 and 403: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 404 and 405: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 406 and 407: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 408 and 409: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 410 and 411: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 412 and 413: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 414 and 415: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 416 and 417: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 418 and 419: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 420 and 421: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 422 and 423: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 424 and 425: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 426 and 427: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 428 and 429: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 430 and 431: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 432 and 433: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 434 and 435: AMD64 Technology 24594 Rev. 3.10 Fe
24594 Rev. 3.10 February 2005 AMD64 TechnologyRIP = temp_RIPEXITSYSCALL_LEGACY_MODE:RCX.d = next_RIPtemp_RIP.d = MSR_STAR.EIPCS.sel = MSR_STAR.SYSCALL_CS AND 0xFFFCCS.attr = 32-bit code,dpl0 // Always switch to 32-bit mode in legacy mode.CS.base = 0x00000000CS.limit = 0xFFFFFFFFSS.sel = MSR_STAR.SYSCALL_CS + 8SS.attr = 32-bit stack,dpl0SS.base = 0x00000000SS.limit = 0xFFFFFFFFRFLAGS.VM,IF,RF=0CPL = 0RIP = temp_RIPEXITRelated <strong>Instructions</strong>SYSRET, SYSENTER, SYSEXITrFLAGS AffectedID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CFM M M M 0 0 M M M M M M M M M M M21 20 19 18 17 16 14 13–12 11 10 9 8 7 6 4 2 0Note: Bits 31–22, 15, 5, 3, <strong>and</strong> 1 are reserved. A flag set to one or cleared to zero is M (modified). Unaffected flags are blank. Undefinedflags are U.SYSCALL 357