浏览代码

Kernel: Fix {read,write}_gs_ptr() for 64-bit addresses

Gunnar Beutner 4 年之前
父节点
当前提交
741ca5477c
共有 2 个文件被更改,包括 7 次插入12 次删除
  1. 5 10
      Kernel/Arch/x86/ASM_wrapper.h
  2. 2 2
      Kernel/Arch/x86/Processor.h

+ 5 - 10
Kernel/Arch/x86/ASM_wrapper.h

@@ -62,25 +62,20 @@ ALWAYS_INLINE u16 get_gs()
 }
 }
 #endif
 #endif
 
 
-ALWAYS_INLINE u32 read_gs_u32(u32 offset)
+ALWAYS_INLINE FlatPtr read_gs_ptr(FlatPtr offset)
 {
 {
-    u32 val;
+    FlatPtr val;
     asm volatile(
     asm volatile(
-        "movl %%gs:%a[off], %k[val]"
+        "mov %%gs:%a[off], %[val]"
         : [val] "=r"(val)
         : [val] "=r"(val)
         : [off] "ir"(offset));
         : [off] "ir"(offset));
     return val;
     return val;
 }
 }
 
 
-ALWAYS_INLINE FlatPtr read_gs_ptr(u32 offset)
-{
-    return read_gs_u32(offset);
-}
-
-ALWAYS_INLINE void write_gs_u32(u32 offset, u32 val)
+ALWAYS_INLINE void write_gs_ptr(u32 offset, FlatPtr val)
 {
 {
     asm volatile(
     asm volatile(
-        "movl %k[val], %%gs:%a[off]" ::[off] "ir"(offset), [val] "ir"(val)
+        "mov %[val], %%gs:%a[off]" ::[off] "ir"(offset), [val] "ir"(val)
         : "memory");
         : "memory");
 }
 }
 
 

+ 2 - 2
Kernel/Arch/x86/Processor.h

@@ -256,7 +256,7 @@ public:
 #if ARCH(I386)
 #if ARCH(I386)
             get_gs() == GDT_SELECTOR_PROC &&
             get_gs() == GDT_SELECTOR_PROC &&
 #endif
 #endif
-            read_gs_u32(__builtin_offsetof(Processor, m_self)) != 0;
+            read_gs_ptr(__builtin_offsetof(Processor, m_self)) != 0;
     }
     }
 
 
     ALWAYS_INLINE void set_scheduler_data(SchedulerPerProcessorData& scheduler_data)
     ALWAYS_INLINE void set_scheduler_data(SchedulerPerProcessorData& scheduler_data)
@@ -298,7 +298,7 @@ public:
     ALWAYS_INLINE static void set_current_thread(Thread& current_thread)
     ALWAYS_INLINE static void set_current_thread(Thread& current_thread)
     {
     {
         // See comment in Processor::current_thread
         // See comment in Processor::current_thread
-        write_gs_u32(__builtin_offsetof(Processor, m_current_thread), FlatPtr(&current_thread));
+        write_gs_ptr(__builtin_offsetof(Processor, m_current_thread), FlatPtr(&current_thread));
     }
     }
 
 
     ALWAYS_INLINE static Thread* idle_thread()
     ALWAYS_INLINE static Thread* idle_thread()