diff options
author | Glauber Costa <glommer@redhat.com> | 2010-05-11 12:17:45 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-19 04:41:05 -0400 |
commit | 3a0d7256a6fb8c13f9fac6cd63250f97a8f0d8de (patch) | |
tree | 27a710b0f7e54c243382d47c290061699d0e755c /arch/x86 | |
parent | 838815a78785022f6611e5c48386567aea7b818b (diff) |
x86, paravirt: don't compute pvclock adjustments if we trust the tsc
If the HV told us we can fully trust the TSC, skip any
correction
Signed-off-by: Glauber Costa <glommer@redhat.com>
Acked-by: Zachary Amsden <zamsden@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/kvm_para.h | 5 | ||||
-rw-r--r-- | arch/x86/include/asm/pvclock-abi.h | 1 | ||||
-rw-r--r-- | arch/x86/kernel/kvmclock.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/pvclock.c | 4 |
4 files changed, 13 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h index f019f8cb182e..05eba5e9a8e8 100644 --- a/arch/x86/include/asm/kvm_para.h +++ b/arch/x86/include/asm/kvm_para.h | |||
@@ -21,6 +21,11 @@ | |||
21 | */ | 21 | */ |
22 | #define KVM_FEATURE_CLOCKSOURCE2 3 | 22 | #define KVM_FEATURE_CLOCKSOURCE2 3 |
23 | 23 | ||
24 | /* The last 8 bits are used to indicate how to interpret the flags field | ||
25 | * in pvclock structure. If no bits are set, all flags are ignored. | ||
26 | */ | ||
27 | #define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 24 | ||
28 | |||
24 | #define MSR_KVM_WALL_CLOCK 0x11 | 29 | #define MSR_KVM_WALL_CLOCK 0x11 |
25 | #define MSR_KVM_SYSTEM_TIME 0x12 | 30 | #define MSR_KVM_SYSTEM_TIME 0x12 |
26 | 31 | ||
diff --git a/arch/x86/include/asm/pvclock-abi.h b/arch/x86/include/asm/pvclock-abi.h index ec5c41ac4bef..35f2d1948ada 100644 --- a/arch/x86/include/asm/pvclock-abi.h +++ b/arch/x86/include/asm/pvclock-abi.h | |||
@@ -39,5 +39,6 @@ struct pvclock_wall_clock { | |||
39 | u32 nsec; | 39 | u32 nsec; |
40 | } __attribute__((__packed__)); | 40 | } __attribute__((__packed__)); |
41 | 41 | ||
42 | #define PVCLOCK_TSC_STABLE_BIT (1 << 0) | ||
42 | #endif /* __ASSEMBLY__ */ | 43 | #endif /* __ASSEMBLY__ */ |
43 | #endif /* _ASM_X86_PVCLOCK_ABI_H */ | 44 | #endif /* _ASM_X86_PVCLOCK_ABI_H */ |
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index 59c740fcb9b3..eb9b76c716c2 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c | |||
@@ -215,4 +215,7 @@ void __init kvmclock_init(void) | |||
215 | clocksource_register(&kvm_clock); | 215 | clocksource_register(&kvm_clock); |
216 | pv_info.paravirt_enabled = 1; | 216 | pv_info.paravirt_enabled = 1; |
217 | pv_info.name = "KVM"; | 217 | pv_info.name = "KVM"; |
218 | |||
219 | if (kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE_STABLE_BIT)) | ||
220 | pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT); | ||
218 | } | 221 | } |
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c index f5bc40e1697e..239427ca02af 100644 --- a/arch/x86/kernel/pvclock.c +++ b/arch/x86/kernel/pvclock.c | |||
@@ -135,6 +135,10 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src) | |||
135 | barrier(); | 135 | barrier(); |
136 | } while (version != src->version); | 136 | } while (version != src->version); |
137 | 137 | ||
138 | if ((valid_flags & PVCLOCK_TSC_STABLE_BIT) && | ||
139 | (shadow.flags & PVCLOCK_TSC_STABLE_BIT)) | ||
140 | return ret; | ||
141 | |||
138 | /* | 142 | /* |
139 | * Assumption here is that last_value, a global accumulator, always goes | 143 | * Assumption here is that last_value, a global accumulator, always goes |
140 | * forward. If we are less than that, we should not be much smaller. | 144 | * forward. If we are less than that, we should not be much smaller. |