rstubs::arch::context

Function switch_to_user

source
pub unsafe extern "C" fn switch_to_user(
    ds: SegmentSelector,
    sp: *mut u32,
    cs: SegmentSelector,
    ip: *mut (),
    syscall_ret: u32,
) -> !
Expand description

Switch to the user by faking a return from an interrupt.

iretd expects the following stack layout:

OffsetValue
16SS (Ring 3)
12ESP
8EFLAGS
4CS (Ring 3)
0EIP

The top of stack (ESP) points the EIP at the bottom (stack grows downwards).