Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'arm64/for-next/read-once'

Need the arm64 READ_ONCE() rework, otherwise clang context analysis can't see through it.

Signed-off-by: Peter Zijlstra <peterz@infradead.org>

+19 -5
+19 -5
arch/arm64/include/asm/rwonce.h
··· 20 20 ARM64_HAS_LDAPR) 21 21 22 22 /* 23 + * Replace this with typeof_unqual() when minimum compiler versions are 24 + * increased to GCC 14 and Clang 19. For the time being, we need this 25 + * workaround, which relies on function return values dropping qualifiers. 26 + */ 27 + #define __rwonce_typeof_unqual(x) typeof(({ \ 28 + __diag_push() \ 29 + __diag_ignore_all("-Wignored-qualifiers", "") \ 30 + ((typeof(x)(*)(void))0)(); \ 31 + __diag_pop() })) 32 + 33 + /* 23 34 * When building with LTO, there is an increased risk of the compiler 24 35 * converting an address dependency headed by a READ_ONCE() invocation 25 36 * into a control dependency and consequently allowing for harmful ··· 42 31 */ 43 32 #define __READ_ONCE(x) \ 44 33 ({ \ 45 - typeof(&(x)) __x = &(x); \ 46 - int atomic = 1; \ 47 - union { __unqual_scalar_typeof(*__x) __val; char __c[1]; } __u; \ 34 + auto __x = &(x); \ 35 + auto __ret = (__rwonce_typeof_unqual(*__x) *)__x; \ 36 + /* Hides alias reassignment from Clang's -Wthread-safety. */ \ 37 + auto __retp = &__ret; \ 38 + union { typeof(*__ret) __val; char __c[1]; } __u; \ 39 + *__retp = &__u.__val; \ 48 40 switch (sizeof(x)) { \ 49 41 case 1: \ 50 42 asm volatile(__LOAD_RCPC(b, %w0, %1) \ ··· 70 56 : "Q" (*__x) : "memory"); \ 71 57 break; \ 72 58 default: \ 73 - atomic = 0; \ 59 + __u.__val = *(volatile typeof(*__x) *)__x; \ 74 60 } \ 75 - atomic ? (typeof(*__x))__u.__val : (*(volatile typeof(*__x) *)__x);\ 61 + *__ret; \ 76 62 }) 77 63 78 64 #endif /* !BUILD_VDSO */