mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
detect cpu instrcution "rdtscp"
This commit is contained in:
parent
43308244dc
commit
38a6694d46
2 changed files with 9 additions and 2 deletions
|
@ -76,6 +76,7 @@ extern "C" {
|
|||
#define CPU_FEATURE_SYSCALL (1 << 11)
|
||||
#define CPU_FEATURE_NX (1 << 20)
|
||||
#define CPU_FEATURE_1GBHP (1 << 26)
|
||||
#define CPU_FEATURE_RDTSCP (1 << 27)
|
||||
#define CPU_FEATURE_LM (1 << 29)
|
||||
|
||||
// feature list 0x00000007:0
|
||||
|
@ -291,6 +292,10 @@ inline static uint32_t has_avx2(void) {
|
|||
return cpu_info.feature4 & CPU_FEATURE_AVX2;
|
||||
}
|
||||
|
||||
inline static uint32_t has_rdtscp(void) {
|
||||
return (cpu_info.feature3 & CPU_FEATURE_RDTSCP);
|
||||
}
|
||||
|
||||
/// clear TS bit in cr0
|
||||
static inline void clts(void)
|
||||
{
|
||||
|
|
|
@ -207,6 +207,7 @@ int cpu_detection(void) {
|
|||
cr4 |= CR4_OSXSAVE;
|
||||
if (has_pge())
|
||||
cr4 |= CR4_PGE;
|
||||
cr4 &= ~CR4_TSD; // => every privilege level is able to use rdtsc
|
||||
write_cr4(cr4);
|
||||
|
||||
if (has_xsave())
|
||||
|
@ -268,7 +269,7 @@ int cpu_detection(void) {
|
|||
a = b = c = d = 0;
|
||||
cpuid(1, &a, &b, &cpu_info.feature2, &cpu_info.feature1);
|
||||
|
||||
kprintf("CPU features: %s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
|
||||
kprintf("CPU features: %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
|
||||
has_sse() ? "SSE " : "",
|
||||
has_sse2() ? "SSE2 " : "",
|
||||
has_sse3() ? "SSE3 " : "",
|
||||
|
@ -282,7 +283,8 @@ int cpu_detection(void) {
|
|||
has_fpu() ? "FPU " : "",
|
||||
has_fxsr() ? "FXSR " : "",
|
||||
has_xsave() ? "XSAVE " : "",
|
||||
has_osxsave() ? "OSXSAVE " : "");
|
||||
has_osxsave() ? "OSXSAVE " : "",
|
||||
has_rdtscp() ? "RDTSCP " : "");
|
||||
}
|
||||
|
||||
if (first_time && has_osxsave()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue