# `sysret`

[x86-64 Documentation](https://asm-editor.specy.app/documentation/x86.md) › [Instructions](https://asm-editor.specy.app/documentation/x86/instruction.md)

Web page: https://asm-editor.specy.app/documentation/x86/instruction/sysret

**Return from operating system** · Privileged

Category: System

Returns to user code from the operating system, as the counterpart of syscall for fast entry and exit.

x86-64 and later

## Flags

| Flag | Effect |
| --- | --- |
| CF | loaded from r11 |
| PF | loaded from r11 |
| AF | loaded from r11 |
| ZF | loaded from r11 |
| SF | loaded from r11 |
| TF | loaded from r11 |
| IF | loaded from r11 |
| DF | loaded from r11 |
| OF | loaded from r11 |

## Forms

- `sysret`

## Description

Only kernel code in 64-bit mode may run it; user code gets a fault.

The plain form returns to 32-bit compatibility-mode code using `ecx`, with `cs` from bits 63–48 of the `STAR` register. The 64-bit form (`o64 sysret`) returns to 64-bit code using all of `rcx`, with that selector plus 16. Either way `ss` is the selector plus 8, at privilege level 3.
