kernel/x86: stores cpu number in TSC_AUX if rdtscp is available

On modern x86, one can use __rdtscp to get the current cpu in userland.

Change-Id: I1767e379606230a75e4622637c7a5aed9cdf9ab0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2248
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Jérôme Duval
2020-02-17 17:26:39 +00:00
committed by waddlesplash
parent b9db31f649
commit 073e295aa6
4 changed files with 67 additions and 0 deletions
+6
View File
@@ -1145,6 +1145,12 @@ arch_cpu_init_percpu(kernel_args* args, int cpu)
gCpuIdleFunc = halt_idle;
}
#ifdef __x86_64__
// if RDTSCP is available write cpu number in TSC_AUX
if (x86_check_feature(IA32_FEATURE_AMD_EXT_RDTSCP, FEATURE_EXT_AMD))
x86_write_msr(IA32_MSR_TSC_AUX, cpu);
#endif
return __x86_patch_errata_percpu(cpu);
}