From: Marek Bykowski <marekx.bykow...@intel.com>

__install_bp_hardening_cb() is called with the spinlock taken to allow each
CPU to take its turn when allocating slots. With the RT patches applied,
the spinlock becomes a mutex, and we get warnings about sleeping in
the cpu stop callback executing in the atomic context from the migration
thread. Changing to a raw spinlock resolves it.

BUG: scheduling while atomic: migration/<cpu_no>/84/0x00000002
Modules linked in:
[<ffffff800819af6c>] cpu_stopper_thread+0x9c/0x128
CPU: <cpu_no> PID: 76 Comm: migration/8 Tainted: G        W         4.19.19-rt3 
#1
Hardware name: AXM56xx Victoria (DT)
Call trace:
 dump_backtrace+0x0/0x168
 show_stack+0x24/0x30
 dump_stack+0x9c/0xd4
 __schedule_bug+0x74/0xc0
 __schedule+0x500/0x558
 schedule+0x44/0xf0
 rt_spin_lock_slowlock_locked+0x100/0x298
 rt_spin_lock_slowlock+0x68/0x98
 rt_spin_lock+0x60/0x70
 enable_smccc_arch_workaround_1+0x154/0x270
 __enable_cpu_capability+0x24/0x38
 multi_cpu_stop+0x100/0x148
 cpu_stopper_thread+0xa4/0x128
 smpboot_thread_fn+0x1f8/0x2c0
 kthread+0x104/0x130
 ret_from_fork+0x10/0x1c

Signed-off-by: James Morse <james.mo...@arm.com>
Signed-off-by: Will Deacon <will.dea...@arm.com>
Signed-off-by: Marek Bykowski <marekx.bykow...@intel.com>
Signed-off-by: John Jacques <john.jacq...@intel.com>
---
 arch/arm64/kernel/cpu_errata.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index d191ce8..589f0b3 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -114,10 +114,10 @@ static void install_bp_hardening_cb(bp_hardening_cb_t fn,
                                    const char *hyp_vecs_start,
                                    const char *hyp_vecs_end)
 {
-       static DEFINE_SPINLOCK(bp_lock);
+       static DEFINE_RAW_SPINLOCK(bp_lock);
        int cpu, slot = -1;
 
-       spin_lock(&bp_lock);
+       raw_spin_lock(&bp_lock);
        for_each_possible_cpu(cpu) {
                if (per_cpu(bp_hardening_data.fn, cpu) == fn) {
                        slot = per_cpu(bp_hardening_data.hyp_vectors_slot, cpu);
@@ -133,7 +133,7 @@ static void install_bp_hardening_cb(bp_hardening_cb_t fn,
 
        __this_cpu_write(bp_hardening_data.hyp_vectors_slot, slot);
        __this_cpu_write(bp_hardening_data.fn, fn);
-       spin_unlock(&bp_lock);
+       raw_spin_unlock(&bp_lock);
 }
 #else
 #define __smccc_workaround_1_smc_start         NULL
-- 
2.7.4

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9506): 
https://lists.yoctoproject.org/g/linux-yocto/message/9506
Mute This Topic: https://lists.yoctoproject.org/mt/81082044/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to