* [PATCH] do not try to register kvmclock if the host does not support it.
@ 2010-12-01 16:20 Glauber Costa
0 siblings, 0 replies; only message in thread
From: Glauber Costa @ 2010-12-01 16:20 UTC (permalink / raw)
To: linux-kernel; +Cc: avi
With the new Async PF code, some of our initiation code was moved to
kvm.c. With that, code that was being issued conditional to kvmclock
successful registration (primary cpu registering), started being
issued unconditionally.
This patch proposes that we protect all registrations inside
kvm_register_clock, re-using the kvmclock-enabled parameter for that.
This fixes this specific bug, and should protect us from similar
changes in the future.
Signed-off-by: Glauber Costa <glommer@redhat.com>
---
arch/x86/kernel/kvmclock.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index f98d3ea..fcdea34 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -130,6 +130,9 @@ int kvm_register_clock(char *txt)
int cpu = smp_processor_id();
int low, high, ret;
+ if (!kvmclock)
+ return 0;
+
low = (int)__pa(&per_cpu(hv_clock, cpu)) | 1;
high = ((u64)__pa(&per_cpu(hv_clock, cpu)) >> 32);
ret = native_write_msr_safe(msr_kvm_system_time, low, high);
@@ -182,14 +185,19 @@ void __init kvmclock_init(void)
if (kvmclock && kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE2)) {
msr_kvm_system_time = MSR_KVM_SYSTEM_TIME_NEW;
msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK_NEW;
- } else if (!(kvmclock && kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE)))
+ } else if (!(kvmclock && kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE))) {
+ kvmclock = 0;
return;
+ }
printk(KERN_INFO "kvm-clock: Using msrs %x and %x",
msr_kvm_system_time, msr_kvm_wall_clock);
- if (kvm_register_clock("boot clock"))
+ if (kvm_register_clock("boot clock")) {
+ kvmclock = 0;
return;
+ }
+
pv_time_ops.sched_clock = kvm_clock_read;
x86_platform.calibrate_tsc = kvm_get_tsc_khz;
x86_platform.get_wallclock = kvm_get_wallclock;
--
1.6.2.5
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-12-01 16:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-01 16:20 [PATCH] do not try to register kvmclock if the host does not support it Glauber Costa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®