From 956bb743a3ba6939aaff2372fc45628cda6a9840 Mon Sep 17 00:00:00 2001 From: Aleksa Vuckovic Date: Mon, 5 Sep 2022 23:54:12 +0200 Subject: userspace finally working --- kernel/src/sys/userspace_asm.S | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'kernel/src/sys/userspace_asm.S') diff --git a/kernel/src/sys/userspace_asm.S b/kernel/src/sys/userspace_asm.S index 5838051..c722df0 100644 --- a/kernel/src/sys/userspace_asm.S +++ b/kernel/src/sys/userspace_asm.S @@ -4,17 +4,23 @@ .global jump_userspace jump_userspace: - mov $0x23, %ax + mov $0x1b, %ax mov %ax, %ds mov %ax, %es mov %ax, %fs mov %ax, %gs - mov %esp, %eax - push $0x23 - push %rax - pushf - push $0x1b - sub $8, %rsp - movabs $begin_userspace, %rsp - iretq + 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 -- cgit v1.2.3