[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/arm: cmpxchg: Add missing memory barriers in __cmpxchg_mb_timeout()


  • To: Julien Grall <julien@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Fri, 31 Jul 2020 12:50:34 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A9MF/oavr0y5/X8dO6kF96zbmF0lsxqm7Y8/nZ2i0X8=; b=cPXZcoam9aSWw/JOFi3ZqThr+aDwllKeroTbJ761xFSM/tZ+VsqK43c7UxH3+j16cTPRaV1AHrGQiWACpAxrlTxg25Ha0EL5CCdJSCidUiACAazWOAXy8iiTx5oba+0evTANMbyEqlAcbY6VZ5XUupG1bI2OIeF9urIeRfnUs1CiDxyikWukWAWFQlUVgZmOf2FIeJJzd0LivFaEFtZ3lV891J+fP6PDBmggAo8XujxA69HLoH65ahWHGaxy2Fw36t98bkj0LRV3EVzAXL8x0VsizITJMikE5BLOKeuqH3F3oQcspB/Mcp+xOnsiEUqsYhaJroQaeUnBdcA4WDR0bw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ImZboK/CfedxKZgBDzLijCuH6rPwmYg1/gbjOV6TKUjqxpsZ1U69U5BP8U7MT7rKPZIzZTMQOJKPa6eP8BWMiyEm4sHbRLnuFxQW2TLUL6/mhRKPs7rBdiI3KjF3sgPRE6qBhnc0CrgXgjHfI/Uzbf6Vq5bB/Woi9Bw4tIhWhHD6EC16JV32QEWCUkmJvOgQodrNhRG+jC3GffQuqBcyw9YnAYU12lXquMfFyFiNpgZJUxRTEyg6fB29GS6DFP6zjBufxxzaiJ2JjauCxuunjCTxEphA1cMdapJL4iM9fvkWPYb0px3D1gJMIJ64gz0gqrOeL/rgfpCHNk4lMmLpmA==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, nd <nd@xxxxxxx>
  • Delivery-date: Fri, 31 Jul 2020 12:50:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHWZpQy56S+RNuVHkeeRq+c5Nj1s6khpTQA
  • Thread-topic: [PATCH] xen/arm: cmpxchg: Add missing memory barriers in __cmpxchg_mb_timeout()


> On 30 Jul 2020, at 19:07, Julien Grall <julien@xxxxxxx> wrote:
> 
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> 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 <jgrall@xxxxxxxxxx>
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

> ---
> 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
> 
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.