Skip to content

Commit 5de72a2

Browse files
committed
s390/kvm: REPLACE barrier fixup with READ_ONCE
ACCESS_ONCE does not work reliably on non-scalar types. For example gcc 4.6 and 4.7 might remove the volatile tag for such accesses during the SRA (scalar replacement of aggregates) step (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145) Commit 1365039 ("KVM: s390: Fix ipte locking") replace ACCESS_ONCE with barriers. Lets use READ_ONCE instead. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
1 parent 488beef commit 5de72a2

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

arch/s390/kvm/gaccess.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,10 @@ static void ipte_lock_simple(struct kvm_vcpu *vcpu)
229229
goto out;
230230
ic = &vcpu->kvm->arch.sca->ipte_control;
231231
do {
232-
old = *ic;
233-
barrier();
232+
old = READ_ONCE(*ic);
234233
while (old.k) {
235234
cond_resched();
236-
old = *ic;
237-
barrier();
235+
old = READ_ONCE(*ic);
238236
}
239237
new = old;
240238
new.k = 1;
@@ -253,8 +251,7 @@ static void ipte_unlock_simple(struct kvm_vcpu *vcpu)
253251
goto out;
254252
ic = &vcpu->kvm->arch.sca->ipte_control;
255253
do {
256-
old = *ic;
257-
barrier();
254+
old = READ_ONCE(*ic);
258255
new = old;
259256
new.k = 0;
260257
} while (cmpxchg(&ic->val, old.val, new.val) != old.val);
@@ -269,12 +266,10 @@ static void ipte_lock_siif(struct kvm_vcpu *vcpu)
269266

270267
ic = &vcpu->kvm->arch.sca->ipte_control;
271268
do {
272-
old = *ic;
273-
barrier();
269+
old = READ_ONCE(*ic);
274270
while (old.kg) {
275271
cond_resched();
276-
old = *ic;
277-
barrier();
272+
old = READ_ONCE(*ic);
278273
}
279274
new = old;
280275
new.k = 1;
@@ -288,8 +283,7 @@ static void ipte_unlock_siif(struct kvm_vcpu *vcpu)
288283

289284
ic = &vcpu->kvm->arch.sca->ipte_control;
290285
do {
291-
old = *ic;
292-
barrier();
286+
old = READ_ONCE(*ic);
293287
new = old;
294288
new.kh--;
295289
if (!new.kh)

0 commit comments

Comments
 (0)