From 166fed6ea0ff1a5e990f20bae708aa619d669db8 Mon Sep 17 00:00:00 2001 From: Amelia Coutard Date: Mon, 13 Mar 2023 23:43:45 +0100 Subject: [PATCH] Changed the instruction that jumps to ring 3 from sysretq to iretq --- kernel/src/ring3.S | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/kernel/src/ring3.S b/kernel/src/ring3.S index 2b6a783..6d9b55f 100644 --- a/kernel/src/ring3.S +++ b/kernel/src/ring3.S @@ -15,10 +15,19 @@ .globl ftl_to_userspace ftl_to_userspace: - mov %rdi, %rcx - mov %rsi, %rsp - mov $0x202, %r11 # EFLAGS - sysretq + mov $(8 * 3) | 3, %ax + mov %ax, %ds + mov %ax, %es + mov %ax, %fs + mov %ax, %gs + # iretq handles cs and ss + + pushq $(8 * 3) | 3 + pushq %rsi + pushfq + pushq $(8 * 4) | 3 + pushq %rdi + iretq .globl load_tss load_tss: -- 2.47.0