Commit 820843af authored by Yang Shi's avatar Yang Shi Committed by Stefan Bader

ARM: 8839/1: kprobe: make patch_lock a raw_spinlock_t

BugLink: https://bugs.launchpad.net/bugs/1828420

[ Upstream commit 143c2a89 ]

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: default avatarYang Shi <yang.shi@linaro.org>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 7974d754
...@@ -15,7 +15,7 @@ struct patch { ...@@ -15,7 +15,7 @@ struct patch {
unsigned int insn; 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) static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
__acquires(&patch_lock) __acquires(&patch_lock)
...@@ -32,7 +32,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags) ...@@ -32,7 +32,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
return addr; return addr;
if (flags) if (flags)
spin_lock_irqsave(&patch_lock, *flags); raw_spin_lock_irqsave(&patch_lock, *flags);
else else
__acquire(&patch_lock); __acquire(&patch_lock);
...@@ -47,7 +47,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned long *flags) ...@@ -47,7 +47,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned long *flags)
clear_fixmap(fixmap); clear_fixmap(fixmap);
if (flags) if (flags)
spin_unlock_irqrestore(&patch_lock, *flags); raw_spin_unlock_irqrestore(&patch_lock, *flags);
else else
__release(&patch_lock); __release(&patch_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment