xen/arm: cmpxchg: Add missing memory barriers in __cmpxchg_mb_timeout()
PATCH 1/1 xen/arm: cmpxchg: Add missing memory barriers in __cmpxchg_mb_timeout()
From: Julien Grall <[email protected]>
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+
--- xen/include/asm-arm/arm32/cmpxchg.h | 8 +++++++- xen/include/asm-arm/arm64/cmpxchg.h | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-)
xen/include/asm-arm/arm32/cmpxchg.h +7 -1
@@ -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) \
xen/include/asm-arm/arm64/cmpxchg.h +7 -1
@@ -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) \
Signature · 1 line
2.17.1
Quoted 6 lines · Julien Grall
From: Julien Grall <[email protected]>
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.
Quoted 8 lines
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 <[email protected]>
Quoted 46 lines
--- xen/include/asm-arm/arm32/cmpxchg.h | 8 +++++++- xen/include/asm-arm/arm64/cmpxchg.h | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-)xen/include/asm-arm/arm32/cmpxchg.h +7
-1@@ -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) \xen/include/asm-arm/arm64/cmpxchg.h +7
-1@@ -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) \Signature · 1 line
2.17.1
Quoted 10 lines · Julien Grall
From: Julien Grall <[email protected]>
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.
Quoted 8 lines
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 <[email protected]>
Quoted 47 lines
---
xen/include/asm-arm/arm32/cmpxchg.h| 8 +++++++-xen/include/asm-arm/arm64/cmpxchg.h| 8 +++++++-2 files changed, 14 insertions(+), 2 deletions(-)xen/include/asm-arm/arm32/cmpxchg.h +7
-1@@ -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) \xen/include/asm-arm/arm64/cmpxchg.h +7
-1@@ -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) \Signature · 1 line
2.17.1