X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/d1ecb069dfe24481e4a83f44cb5217a2b06746d7..0b4c1975fb5e4eccf1012a35081f7e7799b81046:/osfmk/i386/bsd_i386.c diff --git a/osfmk/i386/bsd_i386.c b/osfmk/i386/bsd_i386.c index 66939fac9..4b933d763 100644 --- a/osfmk/i386/bsd_i386.c +++ b/osfmk/i386/bsd_i386.c @@ -498,6 +498,7 @@ kern_return_t thread_fast_set_cthread_self64(uint64_t self) { pcb_t pcb = current_thread()->machine.pcb; + cpu_data_t *cdp; /* check for canonical address, set 0 otherwise */ if (!IS_USERADDR64_CANONICAL(self)) @@ -505,11 +506,13 @@ thread_fast_set_cthread_self64(uint64_t self) pcb->cthread_self = self; mp_disable_preemption(); + cdp = current_cpu_datap(); #if defined(__x86_64__) - if (current_cpu_datap()->cpu_uber.cu_user_gs_base != self) + 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); #endif - current_cpu_datap()->cpu_uber.cu_user_gs_base = self; + cdp->cpu_uber.cu_user_gs_base = self; mp_enable_preemption(); return (USER_CTHREAD); }