Commit 3c201105 authored by Christian Borntraeger's avatar Christian Borntraeger Committed by Greg Kroah-Hartman

ppc/kvm: Replace ACCESS_ONCE with READ_ONCE

commit 5ee07612 upstream.

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)

Change the ppc/kvm code to replace ACCESS_ONCE with READ_ONCE.
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Acked-by: default avatarAlexander Graf <agraf@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2a806d27
...@@ -152,7 +152,7 @@ static void icp_rm_down_cppr(struct kvmppc_xics *xics, struct kvmppc_icp *icp, ...@@ -152,7 +152,7 @@ static void icp_rm_down_cppr(struct kvmppc_xics *xics, struct kvmppc_icp *icp,
* in virtual mode. * in virtual mode.
*/ */
do { do {
old_state = new_state = ACCESS_ONCE(icp->state); old_state = new_state = READ_ONCE(icp->state);
/* Down_CPPR */ /* Down_CPPR */
new_state.cppr = new_cppr; new_state.cppr = new_cppr;
...@@ -211,7 +211,7 @@ unsigned long kvmppc_rm_h_xirr(struct kvm_vcpu *vcpu) ...@@ -211,7 +211,7 @@ unsigned long kvmppc_rm_h_xirr(struct kvm_vcpu *vcpu)
* pending priority * pending priority
*/ */
do { do {
old_state = new_state = ACCESS_ONCE(icp->state); old_state = new_state = READ_ONCE(icp->state);
xirr = old_state.xisr | (((u32)old_state.cppr) << 24); xirr = old_state.xisr | (((u32)old_state.cppr) << 24);
if (!old_state.xisr) if (!old_state.xisr)
...@@ -277,7 +277,7 @@ int kvmppc_rm_h_ipi(struct kvm_vcpu *vcpu, unsigned long server, ...@@ -277,7 +277,7 @@ int kvmppc_rm_h_ipi(struct kvm_vcpu *vcpu, unsigned long server,
* whenever the MFRR is made less favored. * whenever the MFRR is made less favored.
*/ */
do { do {
old_state = new_state = ACCESS_ONCE(icp->state); old_state = new_state = READ_ONCE(icp->state);
/* Set_MFRR */ /* Set_MFRR */
new_state.mfrr = mfrr; new_state.mfrr = mfrr;
...@@ -352,7 +352,7 @@ int kvmppc_rm_h_cppr(struct kvm_vcpu *vcpu, unsigned long cppr) ...@@ -352,7 +352,7 @@ int kvmppc_rm_h_cppr(struct kvm_vcpu *vcpu, unsigned long cppr)
icp_rm_clr_vcpu_irq(icp->vcpu); icp_rm_clr_vcpu_irq(icp->vcpu);
do { do {
old_state = new_state = ACCESS_ONCE(icp->state); old_state = new_state = READ_ONCE(icp->state);
reject = 0; reject = 0;
new_state.cppr = cppr; new_state.cppr = cppr;
......
...@@ -327,7 +327,7 @@ static bool icp_try_to_deliver(struct kvmppc_icp *icp, u32 irq, u8 priority, ...@@ -327,7 +327,7 @@ static bool icp_try_to_deliver(struct kvmppc_icp *icp, u32 irq, u8 priority,
icp->server_num); icp->server_num);
do { do {
old_state = new_state = ACCESS_ONCE(icp->state); old_state = new_state = READ_ONCE(icp->state);
*reject = 0; *reject = 0;
...@@ -512,7 +512,7 @@ static void icp_down_cppr(struct kvmppc_xics *xics, struct kvmppc_icp *icp, ...@@ -512,7 +512,7 @@ static void icp_down_cppr(struct kvmppc_xics *xics, struct kvmppc_icp *icp,
* in virtual mode. * in virtual mode.
*/ */
do { do {
old_state = new_state = ACCESS_ONCE(icp->state); old_state = new_state = READ_ONCE(icp->state);
/* Down_CPPR */ /* Down_CPPR */
new_state.cppr = new_cppr; new_state.cppr = new_cppr;
...@@ -567,7 +567,7 @@ static noinline unsigned long kvmppc_h_xirr(struct kvm_vcpu *vcpu) ...@@ -567,7 +567,7 @@ static noinline unsigned long kvmppc_h_xirr(struct kvm_vcpu *vcpu)
* pending priority * pending priority
*/ */
do { do {
old_state = new_state = ACCESS_ONCE(icp->state); old_state = new_state = READ_ONCE(icp->state);
xirr = old_state.xisr | (((u32)old_state.cppr) << 24); xirr = old_state.xisr | (((u32)old_state.cppr) << 24);
if (!old_state.xisr) if (!old_state.xisr)
...@@ -634,7 +634,7 @@ static noinline int kvmppc_h_ipi(struct kvm_vcpu *vcpu, unsigned long server, ...@@ -634,7 +634,7 @@ static noinline int kvmppc_h_ipi(struct kvm_vcpu *vcpu, unsigned long server,
* whenever the MFRR is made less favored. * whenever the MFRR is made less favored.
*/ */
do { do {
old_state = new_state = ACCESS_ONCE(icp->state); old_state = new_state = READ_ONCE(icp->state);
/* Set_MFRR */ /* Set_MFRR */
new_state.mfrr = mfrr; new_state.mfrr = mfrr;
...@@ -679,7 +679,7 @@ static int kvmppc_h_ipoll(struct kvm_vcpu *vcpu, unsigned long server) ...@@ -679,7 +679,7 @@ static int kvmppc_h_ipoll(struct kvm_vcpu *vcpu, unsigned long server)
if (!icp) if (!icp)
return H_PARAMETER; return H_PARAMETER;
} }
state = ACCESS_ONCE(icp->state); state = READ_ONCE(icp->state);
kvmppc_set_gpr(vcpu, 4, ((u32)state.cppr << 24) | state.xisr); kvmppc_set_gpr(vcpu, 4, ((u32)state.cppr << 24) | state.xisr);
kvmppc_set_gpr(vcpu, 5, state.mfrr); kvmppc_set_gpr(vcpu, 5, state.mfrr);
return H_SUCCESS; return H_SUCCESS;
...@@ -721,7 +721,7 @@ static noinline void kvmppc_h_cppr(struct kvm_vcpu *vcpu, unsigned long cppr) ...@@ -721,7 +721,7 @@ static noinline void kvmppc_h_cppr(struct kvm_vcpu *vcpu, unsigned long cppr)
BOOK3S_INTERRUPT_EXTERNAL_LEVEL); BOOK3S_INTERRUPT_EXTERNAL_LEVEL);
do { do {
old_state = new_state = ACCESS_ONCE(icp->state); old_state = new_state = READ_ONCE(icp->state);
reject = 0; reject = 0;
new_state.cppr = cppr; new_state.cppr = cppr;
...@@ -885,7 +885,7 @@ static int xics_debug_show(struct seq_file *m, void *private) ...@@ -885,7 +885,7 @@ static int xics_debug_show(struct seq_file *m, void *private)
if (!icp) if (!icp)
continue; continue;
state.raw = ACCESS_ONCE(icp->state.raw); state.raw = READ_ONCE(icp->state.raw);
seq_printf(m, "cpu server %#lx XIRR:%#x PPRI:%#x CPPR:%#x MFRR:%#x OUT:%d NR:%d\n", seq_printf(m, "cpu server %#lx XIRR:%#x PPRI:%#x CPPR:%#x MFRR:%#x OUT:%d NR:%d\n",
icp->server_num, state.xisr, icp->server_num, state.xisr,
state.pending_pri, state.cppr, state.mfrr, state.pending_pri, state.cppr, state.mfrr,
...@@ -1082,7 +1082,7 @@ int kvmppc_xics_set_icp(struct kvm_vcpu *vcpu, u64 icpval) ...@@ -1082,7 +1082,7 @@ int kvmppc_xics_set_icp(struct kvm_vcpu *vcpu, u64 icpval)
* the ICS states before the ICP states. * the ICS states before the ICP states.
*/ */
do { do {
old_state = ACCESS_ONCE(icp->state); old_state = READ_ONCE(icp->state);
if (new_state.mfrr <= old_state.mfrr) { if (new_state.mfrr <= old_state.mfrr) {
resend = false; resend = false;
......
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