Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6355120rwl; Mon, 9 Jan 2023 07:23:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXu4dTJVWwAyn8hwOV377BgU1GUlTh8DOzWCiMLZqBl0qk1/A35bBel33okCOKBOU8jgGm22 X-Received: by 2002:a05:6a20:4d8a:b0:ad:d182:cd50 with SMTP id gj10-20020a056a204d8a00b000add182cd50mr70725399pzb.36.1673277806803; Mon, 09 Jan 2023 07:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673277806; cv=none; d=google.com; s=arc-20160816; b=HCdSKMybLpS7pa9ZxDlkc27T7t1TNcqFgFqZjV4OjXmJ2ac+uPqGecZAeqQUocOcct QHqkk3AZHpQMjHqfNKCR81Jm40WasBL7Nybbdj7EkUoAewCzQRxCmn/1nPOvifpwe/mP +OYw3vRURGn9I6XDwVpQEGtHH3j2u1Rx3HvMRS84+KZce6ZAi/XU1MCuKKId0W1VBDB7 axO6mKEUCfXgLbtwVrfdSUCVsfaRwn69Aq6XQevvZ8Oss5SI7A4ftgnC1LaEVEh2T4jN +A3RAFyuRZbPoZB1Q0PgIn1oYrYmWmE0bvA8tKU0jlZ+Pm+6fOH1J+zYYUy/PUG0taZo YCNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FHx/pK7UbHd7cF/C7/sPVqB5iCoXCLVTjdEuHXQA9mg=; b=JG6GcABgvo1R009s0RxKlDbwOrTdlo5DVJPEQUqGWIVifkTx74a3c6jwoEjccTbkcJ QlVdbNon9QprEd2R5COfrKw/hn+G3DDk573re7NZroYEssbqTXd5RxTYQtqD6SOSUHbM N+2GQUVTVw4JjeIGYf7oVRZk39IwyU6z/dC6FSpb9vr5Zq9xF3Cfw7Z/lX3IIKTqUXHY dTz+1PSiwU1XuLkorCIkSn+0JGt79V4d7JiJkPMiJ2lpF0gJq42lEleoUF6IRC779AoM msgVobbpEVpIzp4zLSuTtjeGdUoojkharcVPzSPZitRPcSkBOPoAdbdMHIm6Vp9+/YM9 2mvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=CiLnUYul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a656bd1000000b004468ff8fd57si9072573pgw.680.2023.01.09.07.23.20; Mon, 09 Jan 2023 07:23:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=CiLnUYul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234962AbjAIOwh (ORCPT + 53 others); Mon, 9 Jan 2023 09:52:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234146AbjAIOwG (ORCPT ); Mon, 9 Jan 2023 09:52:06 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A25AD373AA; Mon, 9 Jan 2023 06:50:41 -0800 (PST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 309DLcBA020828; Mon, 9 Jan 2023 14:50:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=FHx/pK7UbHd7cF/C7/sPVqB5iCoXCLVTjdEuHXQA9mg=; b=CiLnUYulcd3Y2FXk5Lj5WAh4KgxsfZcYKjxfCQ08zGWcNBqLvTSEqOgEDQKQGyTK9VcX BGDmbrW07oViNhu/TsJ6VkK+ta4f5V7BNRo4EWtEm/eFh+LFf/ru6aVuI3mqLsGu3+8L 1EcK6JeiyqXdsSeBXwcdasCFXOf6DXR86xRFvd4rkGU0ixTBA1w+QOZ52pMEe9ufLsqd tm+Zzg+56oLusXSwc+NJEXmkI1ZR3x+p+xdUEU+wsYY+yvVy1r136SZK8w1uvRkL9KeL qd6R2az87Gp5cPIrfzaX2GENftn2xDngAV8MgiFVKu/GpOSgaLc7db9STQK77mx5FT/n +Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3myjasrgbp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Jan 2023 14:50:40 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 309EJob6023203; Mon, 9 Jan 2023 14:50:39 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3myjasrgbc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Jan 2023 14:50:39 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3096uNxd021763; Mon, 9 Jan 2023 14:50:38 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3my0c6a78w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Jan 2023 14:50:38 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 309EoYss48300328 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Jan 2023 14:50:34 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 40FD120043; Mon, 9 Jan 2023 14:50:34 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6C7020040; Mon, 9 Jan 2023 14:50:33 +0000 (GMT) Received: from osiris (unknown [9.179.30.90]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTPS; Mon, 9 Jan 2023 14:50:33 +0000 (GMT) Date: Mon, 9 Jan 2023 15:50:32 +0100 From: Heiko Carstens To: Heiko Carstens Cc: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: s390: interrupt: use READ_ONCE() before cmpxchg() Message-ID: References: <20230109125135.393784-1-hca@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230109125135.393784-1-hca@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: E0byUrtvdsaVDdFIqd8wf89HkzzhtxVg X-Proofpoint-ORIG-GUID: A517Jdb_YGqdvI4fVmwSzimZXdRCWZKs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-09_08,2023-01-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 mlxlogscore=623 clxscore=1015 spamscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 malwarescore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301090105 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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!