linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v2 PATCH] arm64: convert patch_lock to raw lock
@ 2015-10-06 21:12 Yang Shi
  2015-10-07  9:28 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Shi @ 2015-10-06 21:12 UTC (permalink / raw)
  To: rostedt, catalin.marinas, will.deacon
  Cc: linux-kernel, linux-rt-users, linux-arm-kernel, linaro-kernel,
	yang.shi

When running kprobe test on arm64 rt kernel, it reports the below warning:

root@qemu7:~# modprobe kprobe_example
BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917
in_atomic(): 0, irqs_disabled(): 128, pid: 484, name: modprobe
CPU: 0 PID: 484 Comm: modprobe Not tainted 4.1.6-rt5 #2
Hardware name: linux,dummy-virt (DT)
Call trace:
[<ffffffc0000891b8>] dump_backtrace+0x0/0x128
[<ffffffc000089300>] show_stack+0x20/0x30
[<ffffffc00061dae8>] dump_stack+0x1c/0x28
[<ffffffc0000bbad0>] ___might_sleep+0x120/0x198
[<ffffffc0006223e8>] rt_spin_lock+0x28/0x40
[<ffffffc000622b30>] __aarch64_insn_write+0x28/0x78
[<ffffffc000622e48>] aarch64_insn_patch_text_nosync+0x18/0x48
[<ffffffc000622ee8>] aarch64_insn_patch_text_cb+0x70/0xa0
[<ffffffc000622f40>] aarch64_insn_patch_text_sync+0x28/0x48
[<ffffffc0006236e0>] arch_arm_kprobe+0x38/0x48
[<ffffffc00010e6f4>] arm_kprobe+0x34/0x50
[<ffffffc000110374>] register_kprobe+0x4cc/0x5b8
[<ffffffbffc002038>] kprobe_init+0x38/0x7c [kprobe_example]
[<ffffffc000084240>] do_one_initcall+0x90/0x1b0
[<ffffffc00061c498>] do_init_module+0x6c/0x1cc
[<ffffffc0000fd0c0>] load_module+0x17f8/0x1db0
[<ffffffc0000fd8cc>] SyS_finit_module+0xb4/0xc8

Convert patch_lock to raw lock to avoid this issue.

Although the problem is found on rt kernel, the fix should be applicable to
mainline kernel too.

Signed-off-by: Yang Shi <yang.shi@linaro.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
---
v1 -> v2:
 Add Steven's Acked-by
 Fix subject (remove unnecessary "make")
 Fix a typo error in commit log

 arch/arm64/kernel/insn.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c
index f341866..c08b9ad 100644
--- a/arch/arm64/kernel/insn.c
+++ b/arch/arm64/kernel/insn.c
@@ -85,7 +85,7 @@ bool aarch64_insn_is_branch_imm(u32 insn)
 		aarch64_insn_is_bcond(insn));
 }
 
-static DEFINE_SPINLOCK(patch_lock);
+static DEFINE_RAW_SPINLOCK(patch_lock);
 
 static void __kprobes *patch_map(void *addr, int fixmap)
 {
@@ -131,13 +131,13 @@ static int __kprobes __aarch64_insn_write(void *addr, u32 insn)
 	unsigned long flags = 0;
 	int ret;
 
-	spin_lock_irqsave(&patch_lock, flags);
+	raw_spin_lock_irqsave(&patch_lock, flags);
 	waddr = patch_map(addr, FIX_TEXT_POKE0);
 
 	ret = probe_kernel_write(waddr, &insn, AARCH64_INSN_SIZE);
 
 	patch_unmap(FIX_TEXT_POKE0);
-	spin_unlock_irqrestore(&patch_lock, flags);
+	raw_spin_unlock_irqrestore(&patch_lock, flags);
 
 	return ret;
 }
-- 
2.0.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [v2 PATCH] arm64: convert patch_lock to raw lock
  2015-10-06 21:12 [v2 PATCH] arm64: convert patch_lock to raw lock Yang Shi
@ 2015-10-07  9:28 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2015-10-07  9:28 UTC (permalink / raw)
  To: Yang Shi
  Cc: rostedt, catalin.marinas, linux-kernel, linux-rt-users,
	linux-arm-kernel, linaro-kernel

On Tue, Oct 06, 2015 at 02:12:31PM -0700, Yang Shi wrote:
> When running kprobe test on arm64 rt kernel, it reports the below warning:
> 
> root@qemu7:~# modprobe kprobe_example
> BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917
> in_atomic(): 0, irqs_disabled(): 128, pid: 484, name: modprobe
> CPU: 0 PID: 484 Comm: modprobe Not tainted 4.1.6-rt5 #2
> Hardware name: linux,dummy-virt (DT)
> Call trace:
> [<ffffffc0000891b8>] dump_backtrace+0x0/0x128
> [<ffffffc000089300>] show_stack+0x20/0x30
> [<ffffffc00061dae8>] dump_stack+0x1c/0x28
> [<ffffffc0000bbad0>] ___might_sleep+0x120/0x198
> [<ffffffc0006223e8>] rt_spin_lock+0x28/0x40
> [<ffffffc000622b30>] __aarch64_insn_write+0x28/0x78
> [<ffffffc000622e48>] aarch64_insn_patch_text_nosync+0x18/0x48
> [<ffffffc000622ee8>] aarch64_insn_patch_text_cb+0x70/0xa0
> [<ffffffc000622f40>] aarch64_insn_patch_text_sync+0x28/0x48
> [<ffffffc0006236e0>] arch_arm_kprobe+0x38/0x48
> [<ffffffc00010e6f4>] arm_kprobe+0x34/0x50
> [<ffffffc000110374>] register_kprobe+0x4cc/0x5b8
> [<ffffffbffc002038>] kprobe_init+0x38/0x7c [kprobe_example]
> [<ffffffc000084240>] do_one_initcall+0x90/0x1b0
> [<ffffffc00061c498>] do_init_module+0x6c/0x1cc
> [<ffffffc0000fd0c0>] load_module+0x17f8/0x1db0
> [<ffffffc0000fd8cc>] SyS_finit_module+0xb4/0xc8
> 
> Convert patch_lock to raw lock to avoid this issue.
> 
> Although the problem is found on rt kernel, the fix should be applicable to
> mainline kernel too.
> 
> Signed-off-by: Yang Shi <yang.shi@linaro.org>
> Acked-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> v1 -> v2:
>  Add Steven's Acked-by
>  Fix subject (remove unnecessary "make")
>  Fix a typo error in commit log

I already queued with this Steve's Ack, so we'll just have to live with
the typos.

Will

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-07  9:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-06 21:12 [v2 PATCH] arm64: convert patch_lock to raw lock Yang Shi
2015-10-07  9:28 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).