X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/39236c6e673c41db228275375ab7fdb0f837b292..5ba3f43ea354af8ad55bea84372a2bc834d8757c:/osfmk/i386/bsd_i386_native.c?ds=sidebyside diff --git a/osfmk/i386/bsd_i386_native.c b/osfmk/i386/bsd_i386_native.c index 863344aa9..4ec100eff 100644 --- a/osfmk/i386/bsd_i386_native.c +++ b/osfmk/i386/bsd_i386_native.c @@ -25,7 +25,6 @@ * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ -#include #include #include @@ -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! */ }