diff mbox series

[2/3] arm: kprobe: make patch_lock a raw_spinlock_t

Message ID 20181207102749.15205-3-bigeasy@linutronix.de (mailing list archive)
State New, archived
Headers show
Series arm: covert a few spinlock_t locks to raw_spinlock_t | expand

Commit Message

Sebastian Andrzej Siewior Dec. 7, 2018, 10:27 a.m. UTC
From: Yang Shi <yang.shi@linaro.org>

When running kprobe on -rt kernel, the below bug is caught:

|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:931
|in_atomic(): 1, irqs_disabled(): 128, pid: 14, name: migration/0
|Preemption disabled at:[<802f2b98>] cpu_stopper_thread+0xc0/0x140
|CPU: 0 PID: 14 Comm: migration/0 Tainted: G O 4.8.3-rt2 #1
|Hardware name: Freescale LS1021A
|[<8025a43c>] (___might_sleep)
|[<80b5b324>] (rt_spin_lock)
|[<80b5c31c>] (__patch_text_real)
|[<80b5c3ac>] (patch_text_stop_machine)
|[<802f2920>] (multi_cpu_stop)

Since patch_text_stop_machine() is called in stop_machine() which
disables IRQ, sleepable lock should be not used in this atomic context,
 so replace patch_lock to raw lock.

Signed-off-by: Yang Shi <yang.shi@linaro.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/arm/kernel/patch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Sebastian Andrzej Siewior Feb. 13, 2019, 8:46 a.m. UTC | #1
On 2018-12-07 11:27:48 [+0100], To linux-arm-kernel@lists.infradead.org wrote:
> From: Yang Shi <yang.shi@linaro.org>
> 
> When running kprobe on -rt kernel, the below bug is caught:
> 
> |BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:931
> |in_atomic(): 1, irqs_disabled(): 128, pid: 14, name: migration/0
> |Preemption disabled at:[<802f2b98>] cpu_stopper_thread+0xc0/0x140
> |CPU: 0 PID: 14 Comm: migration/0 Tainted: G O 4.8.3-rt2 #1
> |Hardware name: Freescale LS1021A
> |[<8025a43c>] (___might_sleep)
> |[<80b5b324>] (rt_spin_lock)
> |[<80b5c31c>] (__patch_text_real)
> |[<80b5c3ac>] (patch_text_stop_machine)
> |[<802f2920>] (multi_cpu_stop)
> 
> Since patch_text_stop_machine() is called in stop_machine() which
> disables IRQ, sleepable lock should be not used in this atomic context,
>  so replace patch_lock to raw lock.
> 
> Signed-off-by: Yang Shi <yang.shi@linaro.org>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
ping

Sebastian
diff mbox series

Patch

diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
index a50dc00d79a27..d0a05a3bdb965 100644
--- a/arch/arm/kernel/patch.c
+++ b/arch/arm/kernel/patch.c
@@ -16,7 +16,7 @@  struct patch {
 	unsigned int insn;
 };
 
-static DEFINE_SPINLOCK(patch_lock);
+static DEFINE_RAW_SPINLOCK(patch_lock);
 
 static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
 	__acquires(&patch_lock)
@@ -33,7 +33,7 @@  static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
 		return addr;
 
 	if (flags)
-		spin_lock_irqsave(&patch_lock, *flags);
+		raw_spin_lock_irqsave(&patch_lock, *flags);
 	else
 		__acquire(&patch_lock);
 
@@ -48,7 +48,7 @@  static void __kprobes patch_unmap(int fixmap, unsigned long *flags)
 	clear_fixmap(fixmap);
 
 	if (flags)
-		spin_unlock_irqrestore(&patch_lock, *flags);
+		raw_spin_unlock_irqrestore(&patch_lock, *flags);
 	else
 		__release(&patch_lock);
 }