]> git.ameliathe1st.gay Git - voyage-au-centre-des-fichiers.git/commitdiff
Fixed STAR register, and %cr3 on yield
authorAmelia Coutard <eliottulio.coutard@gmail.com>
Sun, 6 Aug 2023 01:52:05 +0000 (03:52 +0200)
committerAmelia Coutard <eliottulio.coutard@gmail.com>
Sun, 6 Aug 2023 01:52:05 +0000 (03:52 +0200)
kernel/src/ring3.cpp

index b173ac490d1ddeeab83e1e83ce56e97675f33711..f4aeca2790a503968e24520b6703f70757e91cf9 100644 (file)
@@ -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 + 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() {