lkml.org 
[lkml]   [2023]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] KVM: s390: interrupt: use READ_ONCE() before cmpxchg()
On Mon, Jan 09, 2023 at 01:51:35PM +0100, Heiko Carstens wrote:
> Use READ_ONCE() before cmpxchg() to prevent that the compiler generates
> code that fetches the to be compared old value several times from memory.
>
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
> ---
> arch/s390/kvm/interrupt.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index 1dae78deddf2..a3bf1b6a7962 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -83,8 +83,9 @@ static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)
> struct esca_block *sca = vcpu->kvm->arch.sca;
> union esca_sigp_ctrl *sigp_ctrl =
> &(sca->cpu[vcpu->vcpu_id].sigp_ctrl);
> - union esca_sigp_ctrl new_val = {0}, old_val = *sigp_ctrl;
> + union esca_sigp_ctrl new_val = {0};
>
> + old_val = READ_ONCE(*sigp_ctrl);

FWIW, Claudio pointed out that this doesn't even compile.
Sending a new version - sorry about this!

\
 
 \ /
  Last update: 2023-03-26 23:33    [W:0.028 / U:0.768 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site