diff options
Diffstat (limited to 'include/asm-i386/tsc.h')
| -rw-r--r-- | include/asm-i386/tsc.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/include/asm-i386/tsc.h b/include/asm-i386/tsc.h index 84016ff481b9..3f3c1fa000b4 100644 --- a/include/asm-i386/tsc.h +++ b/include/asm-i386/tsc.h | |||
| @@ -35,25 +35,30 @@ static inline cycles_t get_cycles(void) | |||
| 35 | static __always_inline cycles_t get_cycles_sync(void) | 35 | static __always_inline cycles_t get_cycles_sync(void) |
| 36 | { | 36 | { |
| 37 | unsigned long long ret; | 37 | unsigned long long ret; |
| 38 | #ifdef X86_FEATURE_SYNC_RDTSC | ||
| 39 | unsigned eax; | 38 | unsigned eax; |
| 40 | 39 | ||
| 41 | /* | 40 | /* |
| 41 | * Use RDTSCP if possible; it is guaranteed to be synchronous | ||
| 42 | * and doesn't cause a VMEXIT on Hypervisors | ||
| 43 | */ | ||
| 44 | alternative_io(ASM_NOP3, ".byte 0x0f,0x01,0xf9", X86_FEATURE_RDTSCP, | ||
| 45 | "=A" (ret), "0" (0ULL) : "ecx", "memory"); | ||
| 46 | if (ret) | ||
| 47 | return ret; | ||
| 48 | |||
| 49 | /* | ||
| 42 | * Don't do an additional sync on CPUs where we know | 50 | * Don't do an additional sync on CPUs where we know |
| 43 | * RDTSC is already synchronous: | 51 | * RDTSC is already synchronous: |
| 44 | */ | 52 | */ |
| 45 | alternative_io("cpuid", ASM_NOP2, X86_FEATURE_SYNC_RDTSC, | 53 | alternative_io("cpuid", ASM_NOP2, X86_FEATURE_SYNC_RDTSC, |
| 46 | "=a" (eax), "0" (1) : "ebx","ecx","edx","memory"); | 54 | "=a" (eax), "0" (1) : "ebx","ecx","edx","memory"); |
| 47 | #else | ||
| 48 | sync_core(); | ||
| 49 | #endif | ||
| 50 | rdtscll(ret); | 55 | rdtscll(ret); |
| 51 | 56 | ||
| 52 | return ret; | 57 | return ret; |
| 53 | } | 58 | } |
| 54 | 59 | ||
| 55 | extern void tsc_init(void); | 60 | extern void tsc_init(void); |
| 56 | extern void mark_tsc_unstable(void); | 61 | extern void mark_tsc_unstable(char *reason); |
| 57 | extern int unsynchronized_tsc(void); | 62 | extern int unsynchronized_tsc(void); |
| 58 | extern void init_tsc_clocksource(void); | 63 | extern void init_tsc_clocksource(void); |
| 59 | 64 | ||
