summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@joyent.com>2011-08-06 21:13:48 -0700
committerBryan Cantrill <bryan@joyent.com>2011-08-06 21:13:48 -0700
commitad9d28f9acc05a6292ac47c0f7cd0b31446724e9 (patch)
treeff2125982bcd6717ecf1e3af15866f05e03937c7
parent782aa34d7351dc6571dc1aae41800e5357897865 (diff)
downloadillumos-kvm-ad9d28f9acc05a6292ac47c0f7cd0b31446724e9.tar.gz
HVM-570 KVM: Fix wallclock version writing race
-rw-r--r--kvm_x86.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/kvm_x86.c b/kvm_x86.c
index b83dbf0..010dfc2 100644
--- a/kvm_x86.c
+++ b/kvm_x86.c
@@ -652,13 +652,19 @@ do_set_msr(struct kvm_vcpu *vcpu, unsigned index, uint64_t *data)
static void
kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
{
- static int version;
+ int version;
struct pvclock_wall_clock wc;
struct timespec boot;
if (!wall_clock)
return;
+ if (kvm_read_guest(kvm, wall_clock, &version, sizeof (version)) != 0)
+ return;
+
+ if (version & 1)
+ version++; /* first time write, random junk */
+
version++;
kvm_write_guest(kvm, wall_clock, &version, sizeof (version));