1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
.text .extern begin_userspace .global jump_userspace jump_userspace: mov $0x1b, %ax mov %ax, %ds mov %ax, %es mov %ax, %fs mov %ax, %gs mov $0xc0000082, %rcx wrmsr mov $0xc0000080, %rcx rdmsr or $1, %eax wrmsr mov $0xc0000081, %rcx rdmsr mov $0x00100008, %edx wrmsr mov $begin_userspace, %ecx mov $0x202, %r11 sysretq