From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B3C7C433DF for ; Thu, 30 Jul 2020 19:44:37 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 18F0A2173E for ; Thu, 30 Jul 2020 19:44:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="Qf656IJK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18F0A2173E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1ETW-0003Zn-Mi; Thu, 30 Jul 2020 19:44:22 +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 1k1ETV-0003Zi-59 for xen-devel@lists.xenproject.org; Thu, 30 Jul 2020 19:44:21 +0000 X-Inumbo-ID: 0f994682-d29d-11ea-ab18-12813bfff9fa Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0f994682-d29d-11ea-ab18-12813bfff9fa; Thu, 30 Jul 2020 19:44:20 +0000 (UTC) Received: from localhost (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A01782072A; Thu, 30 Jul 2020 19:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596138259; bh=ue3sDqBzxkRw8CCsEptpU2EkFEZDRufHMYpjO1K8rGI=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=Qf656IJK+gwP3pvxj/fiIL9ZZcDybfp7toHjxMSHIVgpi07NHS9ApNobijP/GPglS BE8BPXiRO43m7M6NLsX0TOtnRJOlW90xTcANKw+OA8oCVpi4zretVF5+BUtLZLC1DM sbr0PKdHK0VdAcD7UrfnwEhEwsR3T7AHvme/Tdzc= Date: Thu, 30 Jul 2020 12:44:19 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: Julien Grall Subject: Re: [PATCH] xen/arm: cmpxchg: Add missing memory barriers in __cmpxchg_mb_timeout() In-Reply-To: <20200730170721.23393-1-julien@xen.org> Message-ID: References: <20200730170721.23393-1-julien@xen.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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: xen-devel@lists.xenproject.org, Julien Grall , Stefano Stabellini , Volodymyr Babchuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Thu, 30 Jul 2020, Julien Grall wrote: > 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 timeout") > Signed-off-by: Julien Grall 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/arm32/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(volatile void *ptr, > int size, > unsigned int max_try) > { > - return __int_cmpxchg(ptr, old, new, size, true, max_try); > + bool ret; > + > + smp_mb(); > + ret = __int_cmpxchg(ptr, old, new, size, true, max_try); > + smp_mb(); > + > + return ret; > } > > #define cmpxchg(ptr,o,n) \ > diff --git a/xen/include/asm-arm/arm64/cmpxchg.h b/xen/include/asm-arm/arm64/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(volatile void *ptr, > int size, > unsigned int max_try) > { > - return __int_cmpxchg(ptr, old, new, size, true, max_try); > + bool ret; > + > + smp_mb(); > + ret = __int_cmpxchg(ptr, old, new, size, true, max_try); > + smp_mb(); > + > + return ret; > } > > #define cmpxchg(ptr, o, n) \ > -- > 2.17.1 >