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

arm64: alternatives: Remove READ_ONCE() usage during patch operation

In preparation for patching the internals of READ_ONCE() itself, replace
its usage on the alternatives patching patch with a volatile variable
instead.

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>

+4 -3
+4 -3
arch/arm64/kernel/alternative.c
··· 21 21 #define ALT_ORIG_PTR(a) __ALT_PTR(a, orig_offset) 22 22 #define ALT_REPL_PTR(a) __ALT_PTR(a, alt_offset) 23 23 24 - static int all_alternatives_applied; 24 + /* Volatile, as we may be patching the guts of READ_ONCE() */ 25 + static volatile int all_alternatives_applied; 25 26 26 27 static DECLARE_BITMAP(applied_alternatives, ARM64_NCAPS); 27 28 ··· 206 205 207 206 /* We always have a CPU 0 at this point (__init) */ 208 207 if (smp_processor_id()) { 209 - while (!READ_ONCE(all_alternatives_applied)) 208 + while (!all_alternatives_applied) 210 209 cpu_relax(); 211 210 isb(); 212 211 } else { ··· 218 217 BUG_ON(all_alternatives_applied); 219 218 __apply_alternatives(&region, false, remaining_capabilities); 220 219 /* Barriers provided by the cache flushing */ 221 - WRITE_ONCE(all_alternatives_applied, 1); 220 + all_alternatives_applied = 1; 222 221 } 223 222 224 223 return 0;