diff options
author | Bryan Cantrill <bryan@joyent.com> | 2011-08-06 21:13:48 -0700 |
---|---|---|
committer | Bryan Cantrill <bryan@joyent.com> | 2011-08-06 21:13:48 -0700 |
commit | ad9d28f9acc05a6292ac47c0f7cd0b31446724e9 (patch) | |
tree | ff2125982bcd6717ecf1e3af15866f05e03937c7 | |
parent | 782aa34d7351dc6571dc1aae41800e5357897865 (diff) | |
download | illumos-kvm-ad9d28f9acc05a6292ac47c0f7cd0b31446724e9.tar.gz |
HVM-570 KVM: Fix wallclock version writing race
-rw-r--r-- | kvm_x86.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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)); |