diff --git a/hermit/arch/x86/include/asm/processor.h b/hermit/arch/x86/include/asm/processor.h index 21edf9001..8b1c57b60 100644 --- a/hermit/arch/x86/include/asm/processor.h +++ b/hermit/arch/x86/include/asm/processor.h @@ -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) { diff --git a/hermit/arch/x86/kernel/processor.c b/hermit/arch/x86/kernel/processor.c index b4de9309d..6cd03b7dc 100644 --- a/hermit/arch/x86/kernel/processor.c +++ b/hermit/arch/x86/kernel/processor.c @@ -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()) {