Re: [PATCH v2] powerpc/kprobes: Fix kprobe Oops happens in booke
On 2021/8/11 13:31, Christophe Leroy wrote: Le 11/08/2021 à 04:53, Pu Lehui a écrit : Ping, serious problem here. All booke ppc will trigger Oops when perform kprobes related operations. As far as I can see it is in the fixes branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/log/?h=fixes Thanks. On 2021/8/9 10:36, Pu Lehui wrote: When using kprobe on powerpc booke series processor, Oops happens as show bellow: / # echo "p:myprobe do_nanosleep" > /sys/kernel/debug/tracing/kprobe_events / # echo 1 > /sys/kernel/debug/tracing/events/kprobes/myprobe/enable / # sleep 1 [ 50.076730] Oops: Exception in kernel mode, sig: 5 [#1] [ 50.077017] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500 [ 50.077221] Modules linked in: [ 50.077462] CPU: 0 PID: 77 Comm: sleep Not tainted 5.14.0-rc4-00022-g251a1524293d #21 [ 50.077887] NIP: c0b9c4e0 LR: c00ebecc CTR: [ 50.078067] REGS: c3883de0 TRAP: 0700 Not tainted (5.14.0-rc4-00022-g251a1524293d) [ 50.078349] MSR: 00029000 CR: 24000228 XER: 2000 [ 50.078675] [ 50.078675] GPR00: c00ebdf0 c3883e90 c313e300 c3883ea0 0001 c3883ecc 0001 [ 50.078675] GPR08: c100598c c00ea250 0004 24000222 102490c2 bff4180c 101e60d4 [ 50.078675] GPR16: 102454ac 0040 1024 10241100 102410f8 1024 0050 [ 50.078675] GPR24: 0002 c3883ea0 0001 c350 3b9b8d50 [ 50.080151] NIP [c0b9c4e0] do_nanosleep+0x0/0x190 [ 50.080352] LR [c00ebecc] hrtimer_nanosleep+0x14c/0x1e0 [ 50.080638] Call Trace: [ 50.080801] [c3883e90] [c00ebdf0] hrtimer_nanosleep+0x70/0x1e0 (unreliable) [ 50.081110] [c3883f00] [c00ec004] sys_nanosleep_time32+0xa4/0x110 [ 50.081336] [c3883f40] [c001509c] ret_from_syscall+0x0/0x28 [ 50.081541] --- interrupt: c00 at 0x100a4d08 [ 50.081749] NIP: 100a4d08 LR: 101b5234 CTR: 0003 [ 50.081931] REGS: c3883f50 TRAP: 0c00 Not tainted (5.14.0-rc4-00022-g251a1524293d) [ 50.082183] MSR: 0002f902 CR: 24000222 XER: [ 50.082457] [ 50.082457] GPR00: 00a2 bf980040 1024b4d0 bf980084 bf980084 6400 00555345 fefefeff [ 50.082457] GPR08: 7f7f7f7f 101e 0069 0003 28000422 102490c2 bff4180c 101e60d4 [ 50.082457] GPR16: 102454ac 0040 1024 10241100 102410f8 1024 0050 [ 50.082457] GPR24: 0002 bf9803f4 1024 100039e0 102444e8 [ 50.083789] NIP [100a4d08] 0x100a4d08 [ 50.083917] LR [101b5234] 0x101b5234 [ 50.084042] --- interrupt: c00 [ 50.084238] Instruction dump: [ 50.084483] 4bfffc40 6000 6000 6000 9421fff0 39400402 914200c0 38210010 [ 50.084841] 4bfffc20 <7fe8> 7c0802a6 7c892378 93c10048 [ 50.085487] ---[ end trace f6fffe98e2fa8f3e ]--- [ 50.085678] Trace/breakpoint trap There is no real mode for booke arch and the MMU translation is always on. The corresponding MSR_IS/MSR_DS bit in booke is used to switch the address space, but not for real mode judgment. Fixes: 21f8b2fa3ca5 ("powerpc/kprobes: Ignore traps that happened in real mode") Signed-off-by: Pu Lehui --- v1->v2: - use IS_ENABLED(CONFIG_BOOKE) as suggested by Michael Ellerman and Christophe Leroy - update Oops log to make problem clear arch/powerpc/kernel/kprobes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index cbc28d1a2e1b..7a7cd6bda53e 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c @@ -292,7 +292,8 @@ int kprobe_handler(struct pt_regs *regs) if (user_mode(regs)) return 0; - if (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR)) + if (!IS_ENABLED(CONFIG_BOOKE) && + (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR))) return 0; /* .
Re: [PATCH v2] powerpc/kprobes: Fix kprobe Oops happens in booke
Ping, serious problem here. All booke ppc will trigger Oops when perform kprobes related operations. On 2021/8/9 10:36, Pu Lehui wrote: When using kprobe on powerpc booke series processor, Oops happens as show bellow: / # echo "p:myprobe do_nanosleep" > /sys/kernel/debug/tracing/kprobe_events / # echo 1 > /sys/kernel/debug/tracing/events/kprobes/myprobe/enable / # sleep 1 [ 50.076730] Oops: Exception in kernel mode, sig: 5 [#1] [ 50.077017] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500 [ 50.077221] Modules linked in: [ 50.077462] CPU: 0 PID: 77 Comm: sleep Not tainted 5.14.0-rc4-00022-g251a1524293d #21 [ 50.077887] NIP: c0b9c4e0 LR: c00ebecc CTR: [ 50.078067] REGS: c3883de0 TRAP: 0700 Not tainted (5.14.0-rc4-00022-g251a1524293d) [ 50.078349] MSR: 00029000 CR: 24000228 XER: 2000 [ 50.078675] [ 50.078675] GPR00: c00ebdf0 c3883e90 c313e300 c3883ea0 0001 c3883ecc 0001 [ 50.078675] GPR08: c100598c c00ea250 0004 24000222 102490c2 bff4180c 101e60d4 [ 50.078675] GPR16: 102454ac 0040 1024 10241100 102410f8 1024 0050 [ 50.078675] GPR24: 0002 c3883ea0 0001 c350 3b9b8d50 [ 50.080151] NIP [c0b9c4e0] do_nanosleep+0x0/0x190 [ 50.080352] LR [c00ebecc] hrtimer_nanosleep+0x14c/0x1e0 [ 50.080638] Call Trace: [ 50.080801] [c3883e90] [c00ebdf0] hrtimer_nanosleep+0x70/0x1e0 (unreliable) [ 50.081110] [c3883f00] [c00ec004] sys_nanosleep_time32+0xa4/0x110 [ 50.081336] [c3883f40] [c001509c] ret_from_syscall+0x0/0x28 [ 50.081541] --- interrupt: c00 at 0x100a4d08 [ 50.081749] NIP: 100a4d08 LR: 101b5234 CTR: 0003 [ 50.081931] REGS: c3883f50 TRAP: 0c00 Not tainted (5.14.0-rc4-00022-g251a1524293d) [ 50.082183] MSR: 0002f902 CR: 24000222 XER: [ 50.082457] [ 50.082457] GPR00: 00a2 bf980040 1024b4d0 bf980084 bf980084 6400 00555345 fefefeff [ 50.082457] GPR08: 7f7f7f7f 101e 0069 0003 28000422 102490c2 bff4180c 101e60d4 [ 50.082457] GPR16: 102454ac 0040 1024 10241100 102410f8 1024 0050 [ 50.082457] GPR24: 0002 bf9803f4 1024 100039e0 102444e8 [ 50.083789] NIP [100a4d08] 0x100a4d08 [ 50.083917] LR [101b5234] 0x101b5234 [ 50.084042] --- interrupt: c00 [ 50.084238] Instruction dump: [ 50.084483] 4bfffc40 6000 6000 6000 9421fff0 39400402 914200c0 38210010 [ 50.084841] 4bfffc20 <7fe8> 7c0802a6 7c892378 93c10048 [ 50.085487] ---[ end trace f6fffe98e2fa8f3e ]--- [ 50.085678] Trace/breakpoint trap There is no real mode for booke arch and the MMU translation is always on. The corresponding MSR_IS/MSR_DS bit in booke is used to switch the address space, but not for real mode judgment. Fixes: 21f8b2fa3ca5 ("powerpc/kprobes: Ignore traps that happened in real mode") Signed-off-by: Pu Lehui --- v1->v2: - use IS_ENABLED(CONFIG_BOOKE) as suggested by Michael Ellerman and Christophe Leroy - update Oops log to make problem clear arch/powerpc/kernel/kprobes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index cbc28d1a2e1b..7a7cd6bda53e 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c @@ -292,7 +292,8 @@ int kprobe_handler(struct pt_regs *regs) if (user_mode(regs)) return 0; - if (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR)) + if (!IS_ENABLED(CONFIG_BOOKE) && + (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR))) return 0; /*
[PATCH v2] powerpc/kprobes: Fix kprobe Oops happens in booke
When using kprobe on powerpc booke series processor, Oops happens as show bellow: / # echo "p:myprobe do_nanosleep" > /sys/kernel/debug/tracing/kprobe_events / # echo 1 > /sys/kernel/debug/tracing/events/kprobes/myprobe/enable / # sleep 1 [ 50.076730] Oops: Exception in kernel mode, sig: 5 [#1] [ 50.077017] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500 [ 50.077221] Modules linked in: [ 50.077462] CPU: 0 PID: 77 Comm: sleep Not tainted 5.14.0-rc4-00022-g251a1524293d #21 [ 50.077887] NIP: c0b9c4e0 LR: c00ebecc CTR: [ 50.078067] REGS: c3883de0 TRAP: 0700 Not tainted (5.14.0-rc4-00022-g251a1524293d) [ 50.078349] MSR: 00029000 CR: 24000228 XER: 2000 [ 50.078675] [ 50.078675] GPR00: c00ebdf0 c3883e90 c313e300 c3883ea0 0001 c3883ecc 0001 [ 50.078675] GPR08: c100598c c00ea250 0004 24000222 102490c2 bff4180c 101e60d4 [ 50.078675] GPR16: 102454ac 0040 1024 10241100 102410f8 1024 0050 [ 50.078675] GPR24: 0002 c3883ea0 0001 c350 3b9b8d50 [ 50.080151] NIP [c0b9c4e0] do_nanosleep+0x0/0x190 [ 50.080352] LR [c00ebecc] hrtimer_nanosleep+0x14c/0x1e0 [ 50.080638] Call Trace: [ 50.080801] [c3883e90] [c00ebdf0] hrtimer_nanosleep+0x70/0x1e0 (unreliable) [ 50.081110] [c3883f00] [c00ec004] sys_nanosleep_time32+0xa4/0x110 [ 50.081336] [c3883f40] [c001509c] ret_from_syscall+0x0/0x28 [ 50.081541] --- interrupt: c00 at 0x100a4d08 [ 50.081749] NIP: 100a4d08 LR: 101b5234 CTR: 0003 [ 50.081931] REGS: c3883f50 TRAP: 0c00 Not tainted (5.14.0-rc4-00022-g251a1524293d) [ 50.082183] MSR: 0002f902 CR: 24000222 XER: [ 50.082457] [ 50.082457] GPR00: 00a2 bf980040 1024b4d0 bf980084 bf980084 6400 00555345 fefefeff [ 50.082457] GPR08: 7f7f7f7f 101e 0069 0003 28000422 102490c2 bff4180c 101e60d4 [ 50.082457] GPR16: 102454ac 0040 1024 10241100 102410f8 1024 0050 [ 50.082457] GPR24: 0002 bf9803f4 1024 100039e0 102444e8 [ 50.083789] NIP [100a4d08] 0x100a4d08 [ 50.083917] LR [101b5234] 0x101b5234 [ 50.084042] --- interrupt: c00 [ 50.084238] Instruction dump: [ 50.084483] 4bfffc40 6000 6000 6000 9421fff0 39400402 914200c0 38210010 [ 50.084841] 4bfffc20 <7fe8> 7c0802a6 7c892378 93c10048 [ 50.085487] ---[ end trace f6fffe98e2fa8f3e ]--- [ 50.085678] Trace/breakpoint trap There is no real mode for booke arch and the MMU translation is always on. The corresponding MSR_IS/MSR_DS bit in booke is used to switch the address space, but not for real mode judgment. Fixes: 21f8b2fa3ca5 ("powerpc/kprobes: Ignore traps that happened in real mode") Signed-off-by: Pu Lehui --- v1->v2: - use IS_ENABLED(CONFIG_BOOKE) as suggested by Michael Ellerman and Christophe Leroy - update Oops log to make problem clear arch/powerpc/kernel/kprobes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index cbc28d1a2e1b..7a7cd6bda53e 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c @@ -292,7 +292,8 @@ int kprobe_handler(struct pt_regs *regs) if (user_mode(regs)) return 0; - if (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR)) + if (!IS_ENABLED(CONFIG_BOOKE) && + (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR))) return 0; /* -- 2.17.1
Re: [PATCH] powerpc/kprobes: Fix kprobe Oops happens in booke
On 2021/8/5 17:51, Christophe Leroy wrote: Le 04/08/2021 à 16:37, Pu Lehui a écrit : When using kprobe on powerpc booke series processor, Oops happens as show bellow: [ 35.861352] Oops: Exception in kernel mode, sig: 5 [#1] [ 35.861676] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500 [ 35.861905] Modules linked in: [ 35.862144] CPU: 0 PID: 76 Comm: sh Not tainted 5.14.0-rc3-00060-g7e96bf476270 #18 [ 35.862610] NIP: c0b96470 LR: c00107b4 CTR: c0161c80 [ 35.862805] REGS: c387fe70 TRAP: 0700 Not tainted (5.14.0-rc3-00060-g7e96bf476270) [ 35.863198] MSR: 00029002 CR: 24022824 XER: 2000 [ 35.863577] [ 35.863577] GPR00: c0015218 c387ff20 c313e300 c387ff50 0004 4002 4000 0a1a2cce [ 35.863577] GPR08: 0004 59764000 24022422 102490c2 [ 35.863577] GPR16: 0040 1024 1024 1024 1024 1022 [ 35.863577] GPR24: 1024 bfc655e8 0800 c387ff50 [ 35.865367] NIP [c0b96470] schedule+0x0/0x130 [ 35.865606] LR [c00107b4] interrupt_exit_user_prepare_main+0xf4/0x100 [ 35.865974] Call Trace: [ 35.866142] [c387ff20] [c0053224] irq_exit+0x114/0x120 (unreliable) [ 35.866472] [c387ff40] [c0015218] interrupt_return+0x14/0x13c [ 35.866728] --- interrupt: 900 at 0x100af3dc [ 35.866963] NIP: 100af3dc LR: 100de020 CTR: [ 35.867177] REGS: c387ff50 TRAP: 0900 Not tainted (5.14.0-rc3-00060-g7e96bf476270) [ 35.867488] MSR: 0002f902 CR: 20022422 XER: 2000 [ 35.867808] [ 35.867808] GPR00: c001509c bfc65570 1024b4d0 100de020 20022422 bfc655a8 100af3dc [ 35.867808] GPR08: 0002f902 72656773 102490c2 [ 35.867808] GPR16: 0040 1024 1024 1024 1024 1022 [ 35.867808] GPR24: 1024 bfc655e8 10245910 0001 [ 35.869406] NIP [100af3dc] 0x100af3dc [ 35.869578] LR [100de020] 0x100de020 [ 35.869751] --- interrupt: 900 [ 35.870001] Instruction dump: [ 35.870283] 40c20010 815e0518 714a0100 41e2fd04 3920 913e00c0 3b1e0450 4bfffd80 [ 35.870666] 0fe0 92a10024 4bfff1a9 6000 <7fe8> 7c0802a6 93e1001c 7c5f1378 [ 35.871339] ---[ end trace 23ff848139efa9b9 ]--- There is no real mode for booke arch and the MMU translation is always on. The corresponding MSR_IS/MSR_DS bit in booke is used to switch the address space, but not for real mode judgment. Can you explain more the link between that explanation and the Oops itself ? In fact, the same Oops appears when any probed function is hit, like do_nanosleep / # echo "p:myprobe do_nanosleep" > /sys/kernel/debug/tracing/kprobe_events / # echo 1 > /sys/kernel/debug/tracing/events/kprobes/myprobe/enable / # sleep 1 [ 50.076730] Oops: Exception in kernel mode, sig: 5 [#1] [ 50.077017] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500 [ 50.077221] Modules linked in: [ 50.077462] CPU: 0 PID: 77 Comm: sleep Not tainted 5.14.0-rc4-00022-g251a1524293d #21 [ 50.077887] NIP: c0b9c4e0 LR: c00ebecc CTR: [ 50.078067] REGS: c3883de0 TRAP: 0700 Not tainted (5.14.0-rc4-00022-g251a1524293d) [ 50.078349] MSR: 00029000 CR: 24000228 XER: 2000 [ 50.078675] [ 50.078675] GPR00: c00ebdf0 c3883e90 c313e300 c3883ea0 0001 c3883ecc 0001 [ 50.078675] GPR08: c100598c c00ea250 0004 24000222 102490c2 bff4180c 101e60d4 [ 50.078675] GPR16: 102454ac 0040 1024 10241100 102410f8 1024 0050 [ 50.078675] GPR24: 0002 c3883ea0 0001 c350 3b9b8d50 [ 50.080151] NIP [c0b9c4e0] do_nanosleep+0x0/0x190 [ 50.080352] LR [c00ebecc] hrtimer_nanosleep+0x14c/0x1e0 [ 50.080638] Call Trace: [ 50.080801] [c3883e90] [c00ebdf0] hrtimer_nanosleep+0x70/0x1e0 (unreliable) [ 50.081110] [c3883f00] [c00ec004] sys_nanosleep_time32+0xa4/0x110 [ 50.081336] [c3883f40] [c001509c] ret_from_syscall+0x0/0x28 [ 50.081541] --- interrupt: c00 at 0x100a4d08 [ 50.081749] NIP: 100a4d08 LR: 101b5234 CTR: 0003 [ 50.081931] REGS: c3883f50 TRAP: 0c00 Not tainted (5.14.0-rc4-00022-g251a1524293d) [ 50.082183] MSR: 0002f902 CR: 24000222 XER: [ 50.082457] [ 50.082457] GPR00: 00a2 bf980040 1024b4d0 bf980084 bf980084 6400 00555345 fefefeff [ 50.082457] GPR08: 7f7f7f7f 101e 0069 0003 28000422 102490c2 bff4180c 101e60d4 [ 50.082457] GPR16: 102454ac 0040 1024 10241100 102410f8 1024 0050 [ 50.082457] GPR24: 0002 bf9803f4 1024 100039e0 102444e8 [ 50.083789] NIP [100a4d08] 0x100a4d08 [ 50.083917] LR [101b5234] 0x101b5234 [ 50.084042] --- interrupt: c00 [ 50.084238] Instruction dump: [ 50.084483] 4bfffc40 6000 6000 6000 9421fff0 39400402 914200c0 38210010 [ 50.084841] 4bfffc20 00
Re: [PATCH] powerpc/kprobes: Fix kprobe Oops happens in booke
On 2021/8/5 14:13, Michael Ellerman wrote: Pu Lehui writes: When using kprobe on powerpc booke series processor, Oops happens as show bellow: [ 35.861352] Oops: Exception in kernel mode, sig: 5 [#1] [ 35.861676] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500 [ 35.861905] Modules linked in: [ 35.862144] CPU: 0 PID: 76 Comm: sh Not tainted 5.14.0-rc3-00060-g7e96bf476270 #18 [ 35.862610] NIP: c0b96470 LR: c00107b4 CTR: c0161c80 [ 35.862805] REGS: c387fe70 TRAP: 0700 Not tainted (5.14.0-rc3-00060-g7e96bf476270) [ 35.863198] MSR: 00029002 CR: 24022824 XER: 2000 [ 35.863577] [ 35.863577] GPR00: c0015218 c387ff20 c313e300 c387ff50 0004 4002 4000 0a1a2cce [ 35.863577] GPR08: 0004 59764000 24022422 102490c2 [ 35.863577] GPR16: 0040 1024 1024 1024 1024 1022 [ 35.863577] GPR24: 1024 bfc655e8 0800 c387ff50 [ 35.865367] NIP [c0b96470] schedule+0x0/0x130 [ 35.865606] LR [c00107b4] interrupt_exit_user_prepare_main+0xf4/0x100 [ 35.865974] Call Trace: [ 35.866142] [c387ff20] [c0053224] irq_exit+0x114/0x120 (unreliable) [ 35.866472] [c387ff40] [c0015218] interrupt_return+0x14/0x13c [ 35.866728] --- interrupt: 900 at 0x100af3dc [ 35.866963] NIP: 100af3dc LR: 100de020 CTR: [ 35.867177] REGS: c387ff50 TRAP: 0900 Not tainted (5.14.0-rc3-00060-g7e96bf476270) [ 35.867488] MSR: 0002f902 CR: 20022422 XER: 2000 [ 35.867808] [ 35.867808] GPR00: c001509c bfc65570 1024b4d0 100de020 20022422 bfc655a8 100af3dc [ 35.867808] GPR08: 0002f902 72656773 102490c2 [ 35.867808] GPR16: 0040 1024 1024 1024 1024 1022 [ 35.867808] GPR24: 1024 bfc655e8 10245910 0001 [ 35.869406] NIP [100af3dc] 0x100af3dc [ 35.869578] LR [100de020] 0x100de020 [ 35.869751] --- interrupt: 900 [ 35.870001] Instruction dump: [ 35.870283] 40c20010 815e0518 714a0100 41e2fd04 3920 913e00c0 3b1e0450 4bfffd80 [ 35.870666] 0fe0 92a10024 4bfff1a9 6000 <7fe8> 7c0802a6 93e1001c 7c5f1378 [ 35.871339] ---[ end trace 23ff848139efa9b9 ]--- There is no real mode for booke arch and the MMU translation is always on. The corresponding MSR_IS/MSR_DS bit in booke is used to switch the address space, but not for real mode judgment. Fixes: 21f8b2fa3ca5 ("powerpc/kprobes: Ignore traps that happened in real mode") Signed-off-by: Pu Lehui --- arch/powerpc/include/asm/ptrace.h | 6 ++ arch/powerpc/kernel/kprobes.c | 5 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h index 3e5d470a6155..4aec1a97024b 100644 --- a/arch/powerpc/include/asm/ptrace.h +++ b/arch/powerpc/include/asm/ptrace.h @@ -187,6 +187,12 @@ static inline unsigned long frame_pointer(struct pt_regs *regs) #define user_mode(regs) (((regs)->msr & MSR_PR) != 0) #endif +#ifdef CONFIG_BOOKE +#define real_mode(regs)0 +#else +#define real_mode(regs)(!((regs)->msr & MSR_IR) || !((regs)->msr & MSR_DR)) +#endif I'm not sure about this helper. Arguably it should only return true if both MSR_IR and MSR_DR are clear. diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index cbc28d1a2e1b..fac9a5974718 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c @@ -289,10 +289,7 @@ int kprobe_handler(struct pt_regs *regs) unsigned int *addr = (unsigned int *)regs->nip; struct kprobe_ctlblk *kcb; - if (user_mode(regs)) - return 0; - - if (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR)) + if (user_mode(regs) || real_mode(regs)) return 0; I think just adding an IS_ENABLED(CONFIG_BOOKE) here might be better. cheers . Thanks for your suggestion, I will fix it in v2. Best regards Lehui
[PATCH] powerpc/kprobes: Fix kprobe Oops happens in booke
When using kprobe on powerpc booke series processor, Oops happens as show bellow: [ 35.861352] Oops: Exception in kernel mode, sig: 5 [#1] [ 35.861676] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500 [ 35.861905] Modules linked in: [ 35.862144] CPU: 0 PID: 76 Comm: sh Not tainted 5.14.0-rc3-00060-g7e96bf476270 #18 [ 35.862610] NIP: c0b96470 LR: c00107b4 CTR: c0161c80 [ 35.862805] REGS: c387fe70 TRAP: 0700 Not tainted (5.14.0-rc3-00060-g7e96bf476270) [ 35.863198] MSR: 00029002 CR: 24022824 XER: 2000 [ 35.863577] [ 35.863577] GPR00: c0015218 c387ff20 c313e300 c387ff50 0004 4002 4000 0a1a2cce [ 35.863577] GPR08: 0004 59764000 24022422 102490c2 [ 35.863577] GPR16: 0040 1024 1024 1024 1024 1022 [ 35.863577] GPR24: 1024 bfc655e8 0800 c387ff50 [ 35.865367] NIP [c0b96470] schedule+0x0/0x130 [ 35.865606] LR [c00107b4] interrupt_exit_user_prepare_main+0xf4/0x100 [ 35.865974] Call Trace: [ 35.866142] [c387ff20] [c0053224] irq_exit+0x114/0x120 (unreliable) [ 35.866472] [c387ff40] [c0015218] interrupt_return+0x14/0x13c [ 35.866728] --- interrupt: 900 at 0x100af3dc [ 35.866963] NIP: 100af3dc LR: 100de020 CTR: [ 35.867177] REGS: c387ff50 TRAP: 0900 Not tainted (5.14.0-rc3-00060-g7e96bf476270) [ 35.867488] MSR: 0002f902 CR: 20022422 XER: 2000 [ 35.867808] [ 35.867808] GPR00: c001509c bfc65570 1024b4d0 100de020 20022422 bfc655a8 100af3dc [ 35.867808] GPR08: 0002f902 72656773 102490c2 [ 35.867808] GPR16: 0040 1024 1024 1024 1024 1022 [ 35.867808] GPR24: 1024 bfc655e8 10245910 0001 [ 35.869406] NIP [100af3dc] 0x100af3dc [ 35.869578] LR [100de020] 0x100de020 [ 35.869751] --- interrupt: 900 [ 35.870001] Instruction dump: [ 35.870283] 40c20010 815e0518 714a0100 41e2fd04 3920 913e00c0 3b1e0450 4bfffd80 [ 35.870666] 0fe0 92a10024 4bfff1a9 6000 <7fe8> 7c0802a6 93e1001c 7c5f1378 [ 35.871339] ---[ end trace 23ff848139efa9b9 ]--- There is no real mode for booke arch and the MMU translation is always on. The corresponding MSR_IS/MSR_DS bit in booke is used to switch the address space, but not for real mode judgment. Fixes: 21f8b2fa3ca5 ("powerpc/kprobes: Ignore traps that happened in real mode") Signed-off-by: Pu Lehui --- arch/powerpc/include/asm/ptrace.h | 6 ++ arch/powerpc/kernel/kprobes.c | 5 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h index 3e5d470a6155..4aec1a97024b 100644 --- a/arch/powerpc/include/asm/ptrace.h +++ b/arch/powerpc/include/asm/ptrace.h @@ -187,6 +187,12 @@ static inline unsigned long frame_pointer(struct pt_regs *regs) #define user_mode(regs) (((regs)->msr & MSR_PR) != 0) #endif +#ifdef CONFIG_BOOKE +#define real_mode(regs)0 +#else +#define real_mode(regs)(!((regs)->msr & MSR_IR) || !((regs)->msr & MSR_DR)) +#endif + #define force_successful_syscall_return() \ do { \ set_thread_flag(TIF_NOERROR); \ diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index cbc28d1a2e1b..fac9a5974718 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c @@ -289,10 +289,7 @@ int kprobe_handler(struct pt_regs *regs) unsigned int *addr = (unsigned int *)regs->nip; struct kprobe_ctlblk *kcb; - if (user_mode(regs)) - return 0; - - if (!(regs->msr & MSR_IR) || !(regs->msr & MSR_DR)) + if (user_mode(regs) || real_mode(regs)) return 0; /* -- 2.17.1
[PATCH -next] powerpc/xmon: Make symbol 'spu_inst_dump' static
Fix sparse warning: arch/powerpc/xmon/xmon.c:4216:1: warning: symbol 'spu_inst_dump' was not declared. Should it be static? This symbol is not used outside of xmon.c, so make it static. Signed-off-by: Pu Lehui --- arch/powerpc/xmon/xmon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index bf7d69625a2e..d4ae2a25781f 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -4212,8 +4212,7 @@ static void dump_spu_fields(struct spu *spu) DUMP_FIELD(spu, "0x%p", pdata); } -int -spu_inst_dump(unsigned long adr, long count, int praddr) +static int spu_inst_dump(unsigned long adr, long count, int praddr) { return generic_inst_dump(adr, count, praddr, print_insn_spu); } -- 2.17.1
[PATCH -next] powerpc/fadump: make symbol 'rtas_fadump_set_regval' static
Fix sparse warnings: arch/powerpc/platforms/pseries/rtas-fadump.c:250:6: warning: symbol 'rtas_fadump_set_regval' was not declared. Should it be static? Signed-off-by: Pu Lehui --- arch/powerpc/platforms/pseries/rtas-fadump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/rtas-fadump.c b/arch/powerpc/platforms/pseries/rtas-fadump.c index 81343908ed33..f8f73b47b107 100644 --- a/arch/powerpc/platforms/pseries/rtas-fadump.c +++ b/arch/powerpc/platforms/pseries/rtas-fadump.c @@ -247,7 +247,7 @@ static inline int rtas_fadump_gpr_index(u64 id) return i; } -void rtas_fadump_set_regval(struct pt_regs *regs, u64 reg_id, u64 reg_val) +static void rtas_fadump_set_regval(struct pt_regs *regs, u64 reg_id, u64 reg_val) { int i; -- 2.17.1