Skip to content

Commit 4152d14

Browse files
committed
Merge branch 'rwonce/rework' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux
Pull READ/WRITE_ONCE rework from Will Deacon: "This the READ_ONCE rework I've been working on for a while, which bumps the minimum GCC version and improves code-gen on arm64 when stack protector is enabled" [ Side note: I'm _really_ tempted to raise the minimum gcc version to 4.9, so that we can just say that we require _Generic() support. That would allow us to more cleanly handle a lot of the cases where we depend on very complex macros with 'sizeof' or __builtin_choose_expr() with __builtin_types_compatible_p() etc. This branch has a workaround for sparse not handling _Generic(), either, but that was already fixed in the sparse development branch, so it's really just gcc-4.9 that we'd require. - Linus ] * 'rwonce/rework' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux: compiler_types.h: Use unoptimized __unqual_scalar_typeof for sparse compiler_types.h: Optimize __unqual_scalar_typeof compilation time compiler.h: Enforce that READ_ONCE_NOCHECK() access size is sizeof(long) compiler-types.h: Include naked type in __pick_integer_type() match READ_ONCE: Fix comment describing 2x32-bit atomicity gcov: Remove old GCC 3.4 support arm64: barrier: Use '__unqual_scalar_typeof' for acquire/release macros locking/barriers: Use '__unqual_scalar_typeof' for load-acquire macros READ_ONCE: Drop pointer qualifiers when reading from scalar types READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses READ_ONCE: Simplify implementations of {READ,WRITE}_ONCE() arm64: csum: Disable KASAN for do_csum() fault_inject: Don't rely on "return value" from WRITE_ONCE() net: tls: Avoid assigning 'const' pointer to non-const pointer netfilter: Avoid assigning 'const' pointer to non-const pointer compiler/gcc: Raise minimum GCC version for kernel builds to 4.8
2 parents 78c24f7 + b398ace commit 4152d14

File tree

18 files changed

+161
-719
lines changed

18 files changed

+161
-719
lines changed

Documentation/process/changes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ you probably needn't concern yourself with pcmciautils.
2929
====================== =============== ========================================
3030
Program Minimal version Command to check the version
3131
====================== =============== ========================================
32-
GNU C 4.6 gcc --version
32+
GNU C 4.8 gcc --version
3333
GNU make 3.81 make --version
3434
binutils 2.23 ld -v
3535
flex 2.5.35 flex --version

arch/arm/crypto/Kconfig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ config CRYPTO_SHA1_ARM_NEON
3030

3131
config CRYPTO_SHA1_ARM_CE
3232
tristate "SHA1 digest algorithm (ARM v8 Crypto Extensions)"
33-
depends on KERNEL_MODE_NEON && (CC_IS_CLANG || GCC_VERSION >= 40800)
33+
depends on KERNEL_MODE_NEON
3434
select CRYPTO_SHA1_ARM
3535
select CRYPTO_HASH
3636
help
@@ -39,7 +39,7 @@ config CRYPTO_SHA1_ARM_CE
3939

4040
config CRYPTO_SHA2_ARM_CE
4141
tristate "SHA-224/256 digest algorithm (ARM v8 Crypto Extensions)"
42-
depends on KERNEL_MODE_NEON && (CC_IS_CLANG || GCC_VERSION >= 40800)
42+
depends on KERNEL_MODE_NEON
4343
select CRYPTO_SHA256_ARM
4444
select CRYPTO_HASH
4545
help
@@ -96,7 +96,7 @@ config CRYPTO_AES_ARM_BS
9696

9797
config CRYPTO_AES_ARM_CE
9898
tristate "Accelerated AES using ARMv8 Crypto Extensions"
99-
depends on KERNEL_MODE_NEON && (CC_IS_CLANG || GCC_VERSION >= 40800)
99+
depends on KERNEL_MODE_NEON
100100
select CRYPTO_SKCIPHER
101101
select CRYPTO_LIB_AES
102102
select CRYPTO_SIMD
@@ -106,7 +106,7 @@ config CRYPTO_AES_ARM_CE
106106

107107
config CRYPTO_GHASH_ARM_CE
108108
tristate "PMULL-accelerated GHASH using NEON/ARMv8 Crypto Extensions"
109-
depends on KERNEL_MODE_NEON && (CC_IS_CLANG || GCC_VERSION >= 40800)
109+
depends on KERNEL_MODE_NEON
110110
select CRYPTO_HASH
111111
select CRYPTO_CRYPTD
112112
select CRYPTO_GF128MUL
@@ -118,13 +118,13 @@ config CRYPTO_GHASH_ARM_CE
118118

119119
config CRYPTO_CRCT10DIF_ARM_CE
120120
tristate "CRCT10DIF digest algorithm using PMULL instructions"
121-
depends on KERNEL_MODE_NEON && (CC_IS_CLANG || GCC_VERSION >= 40800)
121+
depends on KERNEL_MODE_NEON
122122
depends on CRC_T10DIF
123123
select CRYPTO_HASH
124124

125125
config CRYPTO_CRC32_ARM_CE
126126
tristate "CRC32(C) digest algorithm using CRC and/or PMULL instructions"
127-
depends on KERNEL_MODE_NEON && (CC_IS_CLANG || GCC_VERSION >= 40800)
127+
depends on KERNEL_MODE_NEON
128128
depends on CRC32
129129
select CRYPTO_HASH
130130

arch/arm64/include/asm/barrier.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ static inline unsigned long array_index_mask_nospec(unsigned long idx,
7676
#define __smp_store_release(p, v) \
7777
do { \
7878
typeof(p) __p = (p); \
79-
union { typeof(*p) __val; char __c[1]; } __u = \
80-
{ .__val = (__force typeof(*p)) (v) }; \
79+
union { __unqual_scalar_typeof(*p) __val; char __c[1]; } __u = \
80+
{ .__val = (__force __unqual_scalar_typeof(*p)) (v) }; \
8181
compiletime_assert_atomic_type(*p); \
8282
kasan_check_write(__p, sizeof(*p)); \
8383
switch (sizeof(*p)) { \
@@ -110,7 +110,7 @@ do { \
110110

111111
#define __smp_load_acquire(p) \
112112
({ \
113-
union { typeof(*p) __val; char __c[1]; } __u; \
113+
union { __unqual_scalar_typeof(*p) __val; char __c[1]; } __u; \
114114
typeof(p) __p = (p); \
115115
compiletime_assert_atomic_type(*p); \
116116
kasan_check_read(__p, sizeof(*p)); \
@@ -136,33 +136,33 @@ do { \
136136
: "Q" (*__p) : "memory"); \
137137
break; \
138138
} \
139-
__u.__val; \
139+
(typeof(*p))__u.__val; \
140140
})
141141

142142
#define smp_cond_load_relaxed(ptr, cond_expr) \
143143
({ \
144144
typeof(ptr) __PTR = (ptr); \
145-
typeof(*ptr) VAL; \
145+
__unqual_scalar_typeof(*ptr) VAL; \
146146
for (;;) { \
147147
VAL = READ_ONCE(*__PTR); \
148148
if (cond_expr) \
149149
break; \
150150
__cmpwait_relaxed(__PTR, VAL); \
151151
} \
152-
VAL; \
152+
(typeof(*ptr))VAL; \
153153
})
154154

155155
#define smp_cond_load_acquire(ptr, cond_expr) \
156156
({ \
157157
typeof(ptr) __PTR = (ptr); \
158-
typeof(*ptr) VAL; \
158+
__unqual_scalar_typeof(*ptr) VAL; \
159159
for (;;) { \
160160
VAL = smp_load_acquire(__PTR); \
161161
if (cond_expr) \
162162
break; \
163163
__cmpwait_relaxed(__PTR, VAL); \
164164
} \
165-
VAL; \
165+
(typeof(*ptr))VAL; \
166166
})
167167

168168
#include <asm-generic/barrier.h>

arch/arm64/lib/csum.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ static u64 accumulate(u64 sum, u64 data)
1414
return tmp + (tmp >> 64);
1515
}
1616

17-
unsigned int do_csum(const unsigned char *buff, int len)
17+
/*
18+
* We over-read the buffer and this makes KASAN unhappy. Instead, disable
19+
* instrumentation and call kasan explicitly.
20+
*/
21+
unsigned int __no_sanitize_address do_csum(const unsigned char *buff, int len)
1822
{
1923
unsigned int offset, shift, sum;
2024
const u64 *ptr;
@@ -42,7 +46,7 @@ unsigned int do_csum(const unsigned char *buff, int len)
4246
* odd/even alignment, and means we can ignore it until the very end.
4347
*/
4448
shift = offset * 8;
45-
data = READ_ONCE_NOCHECK(*ptr++);
49+
data = *ptr++;
4650
#ifdef __LITTLE_ENDIAN
4751
data = (data >> shift) << shift;
4852
#else
@@ -58,10 +62,10 @@ unsigned int do_csum(const unsigned char *buff, int len)
5862
while (unlikely(len > 64)) {
5963
__uint128_t tmp1, tmp2, tmp3, tmp4;
6064

61-
tmp1 = READ_ONCE_NOCHECK(*(__uint128_t *)ptr);
62-
tmp2 = READ_ONCE_NOCHECK(*(__uint128_t *)(ptr + 2));
63-
tmp3 = READ_ONCE_NOCHECK(*(__uint128_t *)(ptr + 4));
64-
tmp4 = READ_ONCE_NOCHECK(*(__uint128_t *)(ptr + 6));
65+
tmp1 = *(__uint128_t *)ptr;
66+
tmp2 = *(__uint128_t *)(ptr + 2);
67+
tmp3 = *(__uint128_t *)(ptr + 4);
68+
tmp4 = *(__uint128_t *)(ptr + 6);
6569

6670
len -= 64;
6771
ptr += 8;
@@ -85,7 +89,7 @@ unsigned int do_csum(const unsigned char *buff, int len)
8589
__uint128_t tmp;
8690

8791
sum64 = accumulate(sum64, data);
88-
tmp = READ_ONCE_NOCHECK(*(__uint128_t *)ptr);
92+
tmp = *(__uint128_t *)ptr;
8993

9094
len -= 16;
9195
ptr += 2;
@@ -100,7 +104,7 @@ unsigned int do_csum(const unsigned char *buff, int len)
100104
}
101105
if (len > 0) {
102106
sum64 = accumulate(sum64, data);
103-
data = READ_ONCE_NOCHECK(*ptr);
107+
data = *ptr;
104108
len -= 8;
105109
}
106110
/*

crypto/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ config CRYPTO_AEGIS128
316316
config CRYPTO_AEGIS128_SIMD
317317
bool "Support SIMD acceleration for AEGIS-128"
318318
depends on CRYPTO_AEGIS128 && ((ARM || ARM64) && KERNEL_MODE_NEON)
319-
depends on !ARM || CC_IS_CLANG || GCC_VERSION >= 40800
320319
default y
321320

322321
config CRYPTO_AEGIS128_AESNI_SSE2

drivers/xen/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void xen_get_runstate_snapshot_cpu_delta(
6464
do {
6565
state_time = get64(&state->state_entry_time);
6666
rmb(); /* Hypervisor might update data. */
67-
*res = READ_ONCE(*state);
67+
*res = __READ_ONCE(*state);
6868
rmb(); /* Hypervisor might update data. */
6969
} while (get64(&state->state_entry_time) != state_time ||
7070
(state_time & XEN_RUNSTATE_UPDATE));

include/asm-generic/barrier.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ do { \
128128
#ifndef __smp_load_acquire
129129
#define __smp_load_acquire(p) \
130130
({ \
131-
typeof(*p) ___p1 = READ_ONCE(*p); \
131+
__unqual_scalar_typeof(*p) ___p1 = READ_ONCE(*p); \
132132
compiletime_assert_atomic_type(*p); \
133133
__smp_mb(); \
134-
___p1; \
134+
(typeof(*p))___p1; \
135135
})
136136
#endif
137137

@@ -183,10 +183,10 @@ do { \
183183
#ifndef smp_load_acquire
184184
#define smp_load_acquire(p) \
185185
({ \
186-
typeof(*p) ___p1 = READ_ONCE(*p); \
186+
__unqual_scalar_typeof(*p) ___p1 = READ_ONCE(*p); \
187187
compiletime_assert_atomic_type(*p); \
188188
barrier(); \
189-
___p1; \
189+
(typeof(*p))___p1; \
190190
})
191191
#endif
192192

@@ -229,14 +229,14 @@ do { \
229229
#ifndef smp_cond_load_relaxed
230230
#define smp_cond_load_relaxed(ptr, cond_expr) ({ \
231231
typeof(ptr) __PTR = (ptr); \
232-
typeof(*ptr) VAL; \
232+
__unqual_scalar_typeof(*ptr) VAL; \
233233
for (;;) { \
234234
VAL = READ_ONCE(*__PTR); \
235235
if (cond_expr) \
236236
break; \
237237
cpu_relax(); \
238238
} \
239-
VAL; \
239+
(typeof(*ptr))VAL; \
240240
})
241241
#endif
242242

@@ -250,10 +250,10 @@ do { \
250250
*/
251251
#ifndef smp_cond_load_acquire
252252
#define smp_cond_load_acquire(ptr, cond_expr) ({ \
253-
typeof(*ptr) _val; \
253+
__unqual_scalar_typeof(*ptr) _val; \
254254
_val = smp_cond_load_relaxed(ptr, cond_expr); \
255255
smp_acquire__after_ctrl_dep(); \
256-
_val; \
256+
(typeof(*ptr))_val; \
257257
})
258258
#endif
259259

include/linux/compiler-gcc.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
+ __GNUC_MINOR__ * 100 \
1111
+ __GNUC_PATCHLEVEL__)
1212

13-
#if GCC_VERSION < 40600
13+
/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */
14+
#if GCC_VERSION < 40800
1415
# error Sorry, your compiler is too old - please upgrade it.
1516
#endif
1617

@@ -126,9 +127,7 @@
126127
#if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP) && !defined(__CHECKER__)
127128
#define __HAVE_BUILTIN_BSWAP32__
128129
#define __HAVE_BUILTIN_BSWAP64__
129-
#if GCC_VERSION >= 40800
130130
#define __HAVE_BUILTIN_BSWAP16__
131-
#endif
132131
#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */
133132

134133
#if GCC_VERSION >= 70000

0 commit comments

Comments
 (0)