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@amazon.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
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) \
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) \