xen/arm: cmpxchg: Add missing memory barriers in __cmpxchg_mb_timeout()

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: 86b0bc9583 ("xen/arm: cmpxchg: Provide a new helper that can timeout")
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
(cherry picked from commit d501ef90ae)
This commit is contained in:
Julien Grall authored and Stefano Stabellini committed 2020-09-14 17:20:52 -07:00
1 parent 174be04403
commit 28855ebcdb
2 files changed
+14 -2

No files matched your search

+7 -1
View File
@@ -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) \
+7 -1
View File
@@ -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) \
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.