From: Glauber Costa <glommer@redhat.com> Date: Tue, 3 Nov 2009 17:41:17 -0500 Subject: [x86] kvm: don't ask HV for tsc khz if not using kvmclock Message-id: <1257270077-25607-1-git-send-email-glommer@redhat.com> Patchwork-id: 21300 O-Subject: [PATCH] BZ531268 don't ask hypervisor for tsc khz if not using kvmclock Bugzilla: 531268 RH-Acked-by: Rik van Riel <riel@redhat.com> RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com> In my last patches, we started using the upstream version of kvm_get_tsc_khz, which depends on kvmclock being already initialized. The version that we had, did not depend on that, and thus, could be always used. However, now that we don't initialize tsc_khz ourselves, this leads to a crash. Keeping the behaviour of always being able to use tsc_khz is too complex, and does not match upstream anyway. So I propose we make it conditional on kvm-clock being used. I am sending as a separate patch, since the last series were already triple-acked, and are correct on its own. Signed-off-by: Glauber Costa <glommer@redhat.com> diff --git a/arch/i386/kernel/kvmclock.c b/arch/i386/kernel/kvmclock.c index 7ed58c0..4c96682 100644 --- a/arch/i386/kernel/kvmclock.c +++ b/arch/i386/kernel/kvmclock.c @@ -87,9 +87,12 @@ cycle_t kvm_clock_read(void) */ unsigned long kvm_get_tsc_khz(void) { - struct pvclock_vcpu_time_info *src; - src = &per_cpu(hv_clock, 0); - return pvclock_tsc_khz(src); + if (use_kvm_time > 0) { + struct pvclock_vcpu_time_info *src; + src = &per_cpu(hv_clock, 0); + return pvclock_tsc_khz(src); + } else + return 0; /* indicates we should not use this value */ }