diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2015-11-20 10:02:44 -0500 |
---|---|---|
committer | David Vrabel <david.vrabel@citrix.com> | 2015-12-21 09:41:00 -0500 |
commit | 2dd887e32175b624375570a0361083eb2cd64a07 (patch) | |
tree | b411b03467af88a5ffa2ec147a70c80d6a97c3a7 | |
parent | 187b26a97244b1083d573175650f41b2267ac635 (diff) |
xen/time: use READ_ONCE
Use READ_ONCE through the code, rather than explicit barriers.
Suggested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
-rw-r--r-- | drivers/xen/time.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/xen/time.c b/drivers/xen/time.c index 433fe247c5ff..71078425c9ea 100644 --- a/drivers/xen/time.c +++ b/drivers/xen/time.c | |||
@@ -25,7 +25,7 @@ static u64 get64(const u64 *p) | |||
25 | 25 | ||
26 | if (BITS_PER_LONG < 64) { | 26 | if (BITS_PER_LONG < 64) { |
27 | u32 *p32 = (u32 *)p; | 27 | u32 *p32 = (u32 *)p; |
28 | u32 h, l; | 28 | u32 h, l, h2; |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * Read high then low, and then make sure high is | 31 | * Read high then low, and then make sure high is |
@@ -34,15 +34,14 @@ static u64 get64(const u64 *p) | |||
34 | * XXX some clean way to make this endian-proof? | 34 | * XXX some clean way to make this endian-proof? |
35 | */ | 35 | */ |
36 | do { | 36 | do { |
37 | h = p32[1]; | 37 | h = READ_ONCE(p32[1]); |
38 | barrier(); | 38 | l = READ_ONCE(p32[0]); |
39 | l = p32[0]; | 39 | h2 = READ_ONCE(p32[1]); |
40 | barrier(); | 40 | } while(h2 != h); |
41 | } while (p32[1] != h); | ||
42 | 41 | ||
43 | ret = (((u64)h) << 32) | l; | 42 | ret = (((u64)h) << 32) | l; |
44 | } else | 43 | } else |
45 | ret = *p; | 44 | ret = READ_ONCE(*p); |
46 | 45 | ||
47 | return ret; | 46 | return ret; |
48 | } | 47 | } |
@@ -66,9 +65,7 @@ void xen_get_runstate_snapshot(struct vcpu_runstate_info *res) | |||
66 | */ | 65 | */ |
67 | do { | 66 | do { |
68 | state_time = get64(&state->state_entry_time); | 67 | state_time = get64(&state->state_entry_time); |
69 | barrier(); | 68 | *res = READ_ONCE(*state); |
70 | *res = *state; | ||
71 | barrier(); | ||
72 | } while (get64(&state->state_entry_time) != state_time); | 69 | } while (get64(&state->state_entry_time) != state_time); |
73 | } | 70 | } |
74 | 71 | ||