]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/bsd_i386_native.c
xnu-4570.1.46.tar.gz
[apple/xnu.git] / osfmk / i386 / bsd_i386_native.c
index 863344aa9a170dd7711cc115a9a850d9436580ec..4ec100effaf994f038c1f5978ebc3333a62ae86d 100644 (file)
@@ -25,7 +25,6 @@
  * 
  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
-#include <mach_rt.h>
 #include <mach_debug.h>
 #include <mach_ldebug.h>
 
@@ -157,28 +156,8 @@ thread_set_parent(thread_t parent, int pid)
 kern_return_t
 thread_fast_set_cthread_self(uint32_t self)
 {
-       thread_t thread = current_thread();
-       pcb_t pcb = THREAD_TO_PCB(thread);
-       struct real_descriptor desc = {
-               .limit_low = 1,
-               .limit_high = 0,
-               .base_low = self & 0xffff,
-               .base_med = (self >> 16) & 0xff,
-               .base_high = (self >> 24) & 0xff,
-               .access = ACC_P|ACC_PL_U|ACC_DATA_W,
-               .granularity = SZ_32|SZ_G,
-       };
-
-       current_thread()->machine.cthread_self = (uint64_t) self;       /* preserve old func too */
-
-       /* assign descriptor */
-       mp_disable_preemption();
-       pcb->cthread_desc = desc;
-       *ldt_desc_p(USER_CTHREAD) = desc;
-       saved_state32(pcb->iss)->gs = USER_CTHREAD;
-       mp_enable_preemption();
-
-       return (USER_CTHREAD);
+       machine_thread_set_tsd_base(current_thread(), self);
+       return (USER_CTHREAD); /* N.B.: not a kern_return_t! */
 }
 
 /*
@@ -193,21 +172,7 @@ thread_fast_set_cthread_self(uint32_t self)
 kern_return_t
 thread_fast_set_cthread_self64(uint64_t self)
 {
-       pcb_t pcb = THREAD_TO_PCB(current_thread());
-       cpu_data_t              *cdp;
-
-       /* check for canonical address, set 0 otherwise  */
-       if (!IS_USERADDR64_CANONICAL(self))
-               self = 0ULL;
-
-       pcb->cthread_self = self;
-       mp_disable_preemption();
-       cdp = current_cpu_datap();
-       if ((cdp->cpu_uber.cu_user_gs_base != pcb->cthread_self) ||
-           (pcb->cthread_self != rdmsr64(MSR_IA32_KERNEL_GS_BASE)))
-               wrmsr64(MSR_IA32_KERNEL_GS_BASE, self);
-       cdp->cpu_uber.cu_user_gs_base = self;
-       mp_enable_preemption();
+       machine_thread_set_tsd_base(current_thread(), self);
        return (USER_CTHREAD); /* N.B.: not a kern_return_t! */
 }