summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/pvclock.h
diff options
context:
space:
mode:
authorMinfei Huang <mnghuan@gmail.com>2016-05-27 09:17:10 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2016-06-27 16:12:14 +0300
commit749d088b8e7f4b9826ede02b9a043e417fa84aa1 (patch)
tree03a21cc3d1eb86ecc2e0a45c889e63a1cb366a3f /arch/x86/include/asm/pvclock.h
parent4c2e07c6a29e0129e975727b9f57eede813eea85 (diff)
downloadlinux-749d088b8e7f4b9826ede02b9a043e417fa84aa1.tar.xz
pvclock: Add CPU barriers to get correct version value
Protocol for the "version" fields is: hypervisor raises it (making it uneven) before it starts updating the fields and raises it again (making it even) when it is done. Thus the guest can make sure the time values it got are consistent by checking the version before and after reading them. Add CPU barries after getting version value just like what function vread_pvclock does, because all of callees in this function is inline. Fixes: 502dfeff239e8313bfbe906ca0a1a6827ac8481b Cc: stable@vger.kernel.org Signed-off-by: Minfei Huang <mnghuan@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/include/asm/pvclock.h')
-rw-r--r--arch/x86/include/asm/pvclock.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index fdcc04020636..538ae944855e 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -85,6 +85,8 @@ unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src,
u8 ret_flags;
version = src->version;
+ /* Make the latest version visible */
+ smp_rmb();
offset = pvclock_get_nsec_offset(src);
ret = src->system_time + offset;