From: Amelia Coutard Date: Sun, 6 Aug 2023 01:52:05 +0000 (+0200) Subject: Fixed STAR register, and %cr3 on yield X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=e1adeeab6cb2181eb8dcaa2016424640e5357e69;p=voyage-au-centre-des-fichiers.git Fixed STAR register, and %cr3 on yield --- diff --git a/kernel/src/ring3.cpp b/kernel/src/ring3.cpp index b173ac4..f4aeca2 100644 --- a/kernel/src/ring3.cpp +++ b/kernel/src/ring3.cpp @@ -31,8 +31,8 @@ void os::enable_syscalls() { // This is required to enable syscall/sysret on x86_64 intel. os::set_msr(0xC0000080, os::get_msr(0xC0000080) | (1 << 0)); os::set_msr(0xC0000081, - (std::uint64_t(8 - 8 + 0b11) << 48) + // sysret_cs_and_ss (e.g., userspace segments) - (std::uint64_t(24 - 8 + 0b00) << 32) + // syscall_cs_and_ss (e.g., kernelspace segments) + (std::uint64_t(24 - 8 + 0b11) << 48) + // sysret_cs_and_ss (e.g., userspace segments) + (std::uint64_t( 8 - 8 + 0b00) << 32) + // syscall_cs_and_ss (e.g., kernelspace segments) std::uint64_t(0) // syscall_target_eip, only relevant to 32-bits so useless here ); os::set_msr(0xC0000082, std::uint64_t(&syscall_64bit_handler)); // RIP for 64-bit program @@ -66,6 +66,7 @@ extern "C" void os::syscall_yield() { } else { os::current_pid = 0; } + os::paging::load_pml4t(os::processes.get(os::current_pid).PML4T); } extern "C" void os::syscall_rax_error_handler() {