فهرست منبع

Kernel: Set CS selector when initializing thread context on x86_64

These are not technically required, since the Thread constructor
already sets these, but they are set on i686, so let's try and keep
consistent behaviour between the different archs.
Idan Horowitz 3 سال پیش
والد
کامیت
011bd06053
2فایلهای تغییر یافته به همراه2 افزوده شده و 1 حذف شده
  1. 1 0
      Kernel/Arch/x86/x86_64/Processor.cpp
  2. 1 1
      Kernel/Syscalls/execve.cpp

+ 1 - 0
Kernel/Arch/x86/x86_64/Processor.cpp

@@ -160,6 +160,7 @@ FlatPtr Processor::init_context(Thread& thread, bool leave_crit)
     regs.rip = FlatPtr(&thread_context_first_enter);
     regs.rsp0 = kernel_stack_top;
     regs.rsp = stack_top;
+    regs.cs = GDT_SELECTOR_CODE0;
     return stack_top;
 }
 

+ 1 - 1
Kernel/Syscalls/execve.cpp

@@ -608,8 +608,8 @@ ErrorOr<void> Process::do_exec(NonnullRefPtr<OpenFileDescription> main_program_d
     new_main_thread->reset_fpu_state();
 
     auto& regs = new_main_thread->m_regs;
-#if ARCH(I386)
     regs.cs = GDT_SELECTOR_CODE3 | 3;
+#if ARCH(I386)
     regs.ds = GDT_SELECTOR_DATA3 | 3;
     regs.es = GDT_SELECTOR_DATA3 | 3;
     regs.ss = GDT_SELECTOR_DATA3 | 3;