Commit 2dd887e3 authored by Stefano Stabellini's avatar Stefano Stabellini Committed by David Vrabel

xen/time: use READ_ONCE

Use READ_ONCE through the code, rather than explicit barriers.
Suggested-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarStefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: default avatarDavid Vrabel <david.vrabel@citrix.com>
parent 187b26a9
...@@ -25,7 +25,7 @@ static u64 get64(const u64 *p) ...@@ -25,7 +25,7 @@ static u64 get64(const u64 *p)
if (BITS_PER_LONG < 64) { if (BITS_PER_LONG < 64) {
u32 *p32 = (u32 *)p; u32 *p32 = (u32 *)p;
u32 h, l; u32 h, l, h2;
/* /*
* Read high then low, and then make sure high is * Read high then low, and then make sure high is
...@@ -34,15 +34,14 @@ static u64 get64(const u64 *p) ...@@ -34,15 +34,14 @@ static u64 get64(const u64 *p)
* XXX some clean way to make this endian-proof? * XXX some clean way to make this endian-proof?
*/ */
do { do {
h = p32[1]; h = READ_ONCE(p32[1]);
barrier(); l = READ_ONCE(p32[0]);
l = p32[0]; h2 = READ_ONCE(p32[1]);
barrier(); } while(h2 != h);
} while (p32[1] != h);
ret = (((u64)h) << 32) | l; ret = (((u64)h) << 32) | l;
} else } else
ret = *p; ret = READ_ONCE(*p);
return ret; return ret;
} }
...@@ -66,9 +65,7 @@ void xen_get_runstate_snapshot(struct vcpu_runstate_info *res) ...@@ -66,9 +65,7 @@ void xen_get_runstate_snapshot(struct vcpu_runstate_info *res)
*/ */
do { do {
state_time = get64(&state->state_entry_time); state_time = get64(&state->state_entry_time);
barrier(); *res = READ_ONCE(*state);
*res = *state;
barrier();
} while (get64(&state->state_entry_time) != state_time); } while (get64(&state->state_entry_time) != state_time);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment