exit_to_user_mode(9)
β¨ exit_to_user_mode β the manual page, but make it a vibe β¨
okay bestie, this one's a kernel API manual page (exit_to_user_mode(9)), and it's literally the "last looks in the mirror before you go out" function for the kernel. Let's get into it π
πΈ NAME πΈ
exit_to_user_mode β the fixup-state-when-you're-bouncing-back-to-user-mode situation π«Ά
π¦ SYNOPSIS π¦
void exit_to_user_mode (void );
π ARGUMENTS π
voidβ no arguments. none. zero. it takes nothing and it's iconic for it β¨
π DESCRIPTION π
so here's the tea: syscall/interrupt exit enables interrupts, but the kernel state is interrupts disabled when this gets invoked. and it also tells RCU about it, which is important, don't skip that part π₯
The steps, in order:
- Trace interrupts on state π
- Invoke context tracking if enabled to adjust RCU state π
- Invoke architecture specific last minute exit code, e.g. speculation mitigations, etc.:
arch_exit_to_user_modeπ§ - Tell lockdep that interrupts are enabled π
You invoke this from architecture specific code when syscall_exit_to_user_mode is not suitable as the last step before returning to userspace.
π¨ okay this part is important, no cap: it must be invoked with interrupts disabled, and the caller must be non-instrumentable. Also the caller has to invoke syscall_exit_to_user_mode_work before this. it's giving strict instructions, so follow them fr fr π
π SEE ALSO π
- Kernel file
./include/linux/irq-entry-common.hπ arch_enter_from_user_mode(9),arch_in_rcu_eqs(9),enter_from_user_mode(9),arch_exit_to_user_mode_work(9),arch_exit_to_user_mode_prepare(9),arch_exit_to_user_mode(9),arch_do_signal_or_restart(9),__exit_to_user_mode_prepare(9),syscall_exit_to_user_mode_prepare(9),irqentry_exit_to_user_mode_prepare(9),irqentry_enter_from_user_mode(9),irqentry_exit_to_user_mode(9),struct irqentry_state(9),irqentry_enter_from_kernel_mode(9),irqentry_exit_to_kernel_mode_preempt(9),irqentry_exit_to_kernel_mode_after_preempt(9),irqentry_exit_to_kernel_mode(9),irqentry_enter(9),irqentry_exit(9),irqentry_nmi_enter(9),irqentry_nmi_exit(9)β the whole friend group, honestly π
that's the whole page, bestie π it's from ./include/linux, dated October 2026, and it's the exit_to_user_mode(9) manual page β mwah, go slay your syscalls ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms