From nobody Thu Apr 25 00:03:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1596128878; cv=none; d=zohomail.com; s=zohoarc; b=EIbe4NUNRsNKTSDQsTvXFBtBOWUjWqJzbi1Q1xkmfgomO8ERiqgkgyektrU0Vur+evgyo80CmdTcGsKaQdM/E7NDWbBievpvWDnUmLiWEIrAdfMeqiezcZeVc1NoHTSUZXk0gRZCOERst/LRDztq/p771UT99tC48d7Gz0WYsSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596128878; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=F0zBWlFRrrkUpoa8qvY/9++vofGF25KtTzc2Y4E7dkU=; b=JIzDlPCiWcQv110DltcxuBkIIAYIAEx42MdLtRcy1uI+PbWHrRATjfiHXSdGX8CAMJv5yXWwHCXaIiRNXjeUJ0sJ30WAkKZkCIW/gGZ4wppLow6Iaqpi/8khUZiqF/8Dv2eA8YJBUnkOGV4DyDhn73H4qLHy5XLA39ENHjdsOjo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1596128878246814.9822999899561; Thu, 30 Jul 2020 10:07:58 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1C1h-0003Un-S4; Thu, 30 Jul 2020 17:07:29 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1C1g-0003Ui-GY for xen-devel@lists.xenproject.org; Thu, 30 Jul 2020 17:07:28 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 25161424-d287-11ea-aaf6-12813bfff9fa; Thu, 30 Jul 2020 17:07:27 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1C1e-0006Eg-Pc; Thu, 30 Jul 2020 17:07:26 +0000 Received: from 54-240-197-227.amazon.com ([54.240.197.227] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k1C1e-0002Kp-Ei; Thu, 30 Jul 2020 17:07:26 +0000 X-Inumbo-ID: 25161424-d287-11ea-aaf6-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=F0zBWlFRrrkUpoa8qvY/9++vofGF25KtTzc2Y4E7dkU=; b=BrkwV+KkCZPJ9e0pbzZAHuD6l/ WscBnrngt7t03XBAw4v16wIZj2MVbckFpiOQnr3gaOWqYkAotQ3sK/GHPNrSXIAdEV9UXgbsAIIxJ MFOAwfkvhYlk2jEGwVFt/azbUrQyWIk/Sv0cEnFT/xxKO0jHvNe9hcCtiSNot6ZNumIU=; From: Julien Grall To: xen-devel@lists.xenproject.org Subject: [PATCH] xen/arm: cmpxchg: Add missing memory barriers in __cmpxchg_mb_timeout() Date: Thu, 30 Jul 2020 18:07:21 +0100 Message-Id: <20200730170721.23393-1-julien@xen.org> X-Mailer: git-send-email 2.17.1 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Volodymyr Babchuk , Julien Grall , Stefano Stabellini , julien@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall The function __cmpxchg_mb_timeout() was intended to have the same semantics as __cmpxchg_mb(). Unfortunately, the memory barriers were not added when first implemented. There is no known issue with the existing callers, but the barriers are added given this is the expected semantics in Xen. The issue was introduced by XSA-295. Backport: 4.8+ Fixes: 86b0bc958373 ("xen/arm: cmpxchg: Provide a new helper that can timeo= ut") Signed-off-by: Julien Grall Reviewed-by: Bertrand Marquis Reviewed-by: Stefano Stabellini --- xen/include/asm-arm/arm32/cmpxchg.h | 8 +++++++- xen/include/asm-arm/arm64/cmpxchg.h | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/xen/include/asm-arm/arm32/cmpxchg.h b/xen/include/asm-arm/arm3= 2/cmpxchg.h index 49ca2a0d7ab1..0770f272ee99 100644 --- a/xen/include/asm-arm/arm32/cmpxchg.h +++ b/xen/include/asm-arm/arm32/cmpxchg.h @@ -147,7 +147,13 @@ static always_inline bool __cmpxchg_mb_timeout(volatil= e void *ptr, int size, unsigned int max_try) { - return __int_cmpxchg(ptr, old, new, size, true, max_try); + bool ret; + + smp_mb(); + ret =3D __int_cmpxchg(ptr, old, new, size, true, max_try); + smp_mb(); + + return ret; } =20 #define cmpxchg(ptr,o,n) \ diff --git a/xen/include/asm-arm/arm64/cmpxchg.h b/xen/include/asm-arm/arm6= 4/cmpxchg.h index 5bc2e1f78674..fc5c60f0bd74 100644 --- a/xen/include/asm-arm/arm64/cmpxchg.h +++ b/xen/include/asm-arm/arm64/cmpxchg.h @@ -160,7 +160,13 @@ static always_inline bool __cmpxchg_mb_timeout(volatil= e void *ptr, int size, unsigned int max_try) { - return __int_cmpxchg(ptr, old, new, size, true, max_try); + bool ret; + + smp_mb(); + ret =3D __int_cmpxchg(ptr, old, new, size, true, max_try); + smp_mb(); + + return ret; } =20 #define cmpxchg(ptr, o, n) \ --=20 2.17.1