arm64: alternatives: ensure secondary CPUs execute ISB after patching
authorWill Deacon <will.deacon@arm.com>
Tue, 4 Aug 2015 17:52:09 +0000 (18:52 +0100)
committerWill Deacon <will.deacon@arm.com>
Tue, 4 Aug 2015 17:52:09 +0000 (18:52 +0100)
In order to guarantee that the patched instruction stream is visible to
a CPU, that CPU must execute an isb instruction after any related cache
maintenance has completed.

The instruction patching routines in kernel/insn.c get this right for
things like jump labels and ftrace, but the alternatives patching omits
it entirely leaving secondary cores in a potential limbo between the old
and the new code.

This patch adds an isb following the secondary polling loop in the
altenatives patching.

Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/kernel/alternative.c

index fa1d575ab2c2f5b59cbc616093b95dffe3cea9af..ab9db0e9818c0caa52aa040b7c01aa83183d774e 100644 (file)
@@ -132,6 +132,7 @@ static int __apply_alternatives_multi_stop(void *unused)
        if (smp_processor_id()) {
                while (!READ_ONCE(patched))
                        cpu_relax();
+               isb();
        } else {
                BUG_ON(patched);
                __apply_alternatives(&region);