[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH v2 06/15] xen: port Linux <asm-generic/rwonce.h> to Xen
From: Ash Wilding <ash.j.wilding@xxxxxxxxx> - Drop kasan related helpers. - Drop READ_ONCE() and WRITE_ONCE(); the __* versions are fine for now as the only callers in Xen are the arm32 atomics helpers which are always accessing an atomic_t's counter member, which is an int. This means we can swap the arm32 atomics helpers over to using the __* versions like the arm64 code does, removing a dependency on <linux/compiler_types.h> for __native_word(). - Relax __unqual_scalar_typeof() in __READ_ONCE() to just typeof(). Similarly to above, the only callers in Xen are the arm32/arm64 atomics helpers, which are always accessing an atomic_t's counter member as a regular (int *) which doesn't need unqual'ing. This means we can remove the other dependency on <linux/compiler_types.h>. Please see previous patch in the series for expanded rationale on why not having to port <linux/compiler_types.h> to Xen makes life easier. Signed-off-by: Ash Wilding <ash.j.wilding@xxxxxxxxx> --- xen/include/xen/rwonce.h | 79 +++------------------------------------- 1 file changed, 5 insertions(+), 74 deletions(-) diff --git a/xen/include/xen/rwonce.h b/xen/include/xen/rwonce.h index 6b47392d1c..d001e7e41e 100644 --- a/xen/include/xen/rwonce.h +++ b/xen/include/xen/rwonce.h @@ -1,90 +1,21 @@ -/* SPDX-License-Identifier: GPL-2.0 */ /* - * Prevent the compiler from merging or refetching reads or writes. The - * compiler is also forbidden from reordering successive instances of - * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some - * particular ordering. One way to make the compiler aware of ordering is to - * put the two invocations of READ_ONCE or WRITE_ONCE in different C - * statements. + * Taken from Linux 5.10-rc2 (last commit 3cea11cd5) * - * These two macros will also work on aggregate data types like structs or - * unions. - * - * Their two major use cases are: (1) Mediating communication between - * process-level code and irq/NMI handlers, all running on the same CPU, - * and (2) Ensuring that the compiler does not fold, spindle, or otherwise - * mutilate accesses that either do not require ordering or that interact - * with an explicit memory barrier or atomic instruction that provides the - * required ordering. + * SPDX-License-Identifier: GPL-2.0 */ + #ifndef __ASM_GENERIC_RWONCE_H #define __ASM_GENERIC_RWONCE_H #ifndef __ASSEMBLY__ -#include <linux/compiler_types.h> -#include <linux/kasan-checks.h> -#include <linux/kcsan-checks.h> - -/* - * Yes, this permits 64-bit accesses on 32-bit architectures. These will - * actually be atomic in some cases (namely Armv7 + LPAE), but for others we - * rely on the access being split into 2x32-bit accesses for a 32-bit quantity - * (e.g. a virtual address) and a strong prevailing wind. - */ -#define compiletime_assert_rwonce_type(t) \ - compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ - "Unsupported access size for {READ,WRITE}_ONCE().") - -/* - * Use __READ_ONCE() instead of READ_ONCE() if you do not require any - * atomicity. Note that this may result in tears! - */ -#ifndef __READ_ONCE -#define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) -#endif - -#define READ_ONCE(x) \ -({ \ - compiletime_assert_rwonce_type(x); \ - __READ_ONCE(x); \ -}) +#define __READ_ONCE(x) (*(const volatile typeof(x) *)&(x)) #define __WRITE_ONCE(x, val) \ do { \ *(volatile typeof(x) *)&(x) = (val); \ } while (0) -#define WRITE_ONCE(x, val) \ -do { \ - compiletime_assert_rwonce_type(x); \ - __WRITE_ONCE(x, val); \ -} while (0) - -static __no_sanitize_or_inline -unsigned long __read_once_word_nocheck(const void *addr) -{ - return __READ_ONCE(*(unsigned long *)addr); -} - -/* - * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a - * word from memory atomically but without telling KASAN/KCSAN. This is - * usually used by unwinding code when walking the stack of a running process. - */ -#define READ_ONCE_NOCHECK(x) \ -({ \ - compiletime_assert(sizeof(x) == sizeof(unsigned long), \ - "Unsupported access size for READ_ONCE_NOCHECK()."); \ - (typeof(x))__read_once_word_nocheck(&(x)); \ -}) - -static __no_kasan_or_inline -unsigned long read_word_at_a_time(const void *addr) -{ - kasan_check_read(addr, 1); - return *(unsigned long *)addr; -} #endif /* __ASSEMBLY__ */ -#endif /* __ASM_GENERIC_RWONCE_H */ \ No newline at end of file +#endif /* __ASM_GENERIC_RWONCE_H */ -- 2.24.3 (Apple Git-128)
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |