aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2014-04-29 15:25:17 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-05-19 20:54:06 -0400
commit21f585073d6347651f2262da187606fa1c4ee16d (patch)
tree5ec5947a36e0a7e7fe458d13523d4036cc748ff1
parent04c32a516806ec74b62048baf4cddcbb840927db (diff)
powerpc: Fix smp_processor_id() in preemptible splat in set_breakpoint
Currently, on 8641D, which doesn't set CONFIG_HAVE_HW_BREAKPOINT we get the following splat: BUG: using smp_processor_id() in preemptible [00000000] code: login/1382 caller is set_breakpoint+0x1c/0xa0 CPU: 0 PID: 1382 Comm: login Not tainted 3.15.0-rc3-00041-g2aafe1a4d451 #1 Call Trace: [decd5d80] [c0008dc4] show_stack+0x50/0x158 (unreliable) [decd5dc0] [c03c6fa0] dump_stack+0x7c/0xdc [decd5de0] [c01f8818] check_preemption_disabled+0xf4/0x104 [decd5e00] [c00086b8] set_breakpoint+0x1c/0xa0 [decd5e10] [c00d4530] flush_old_exec+0x2bc/0x588 [decd5e40] [c011c468] load_elf_binary+0x2ac/0x1164 [decd5ec0] [c00d35f8] search_binary_handler+0xc4/0x1f8 [decd5ef0] [c00d4ee8] do_execve+0x3d8/0x4b8 [decd5f40] [c001185c] ret_from_syscall+0x0/0x38 --- Exception: c01 at 0xfeee554 LR = 0xfeee7d4 The call path in this case is: flush_thread --> set_debug_reg_defaults --> set_breakpoint --> __get_cpu_var Since preemption is enabled in the cleanup of flush thread, and there is no need to disable it, introduce the distinction between set_breakpoint and __set_breakpoint, leaving only the flush_thread instance as the current user of set_breakpoint. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--arch/powerpc/include/asm/debug.h1
-rw-r--r--arch/powerpc/include/asm/hw_breakpoint.h2
-rw-r--r--arch/powerpc/kernel/hw_breakpoint.c8
-rw-r--r--arch/powerpc/kernel/process.c11
-rw-r--r--arch/powerpc/kernel/signal.c2
-rw-r--r--arch/powerpc/xmon/xmon.c2
6 files changed, 17 insertions, 9 deletions
diff --git a/arch/powerpc/include/asm/debug.h b/arch/powerpc/include/asm/debug.h
index 1d7f966d3b18..a954e4975049 100644
--- a/arch/powerpc/include/asm/debug.h
+++ b/arch/powerpc/include/asm/debug.h
@@ -47,6 +47,7 @@ static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }
47#endif 47#endif
48 48
49void set_breakpoint(struct arch_hw_breakpoint *brk); 49void set_breakpoint(struct arch_hw_breakpoint *brk);
50void __set_breakpoint(struct arch_hw_breakpoint *brk);
50#ifdef CONFIG_PPC_ADV_DEBUG_REGS 51#ifdef CONFIG_PPC_ADV_DEBUG_REGS
51extern void do_send_trap(struct pt_regs *regs, unsigned long address, 52extern void do_send_trap(struct pt_regs *regs, unsigned long address,
52 unsigned long error_code, int signal_code, int brkpt); 53 unsigned long error_code, int signal_code, int brkpt);
diff --git a/arch/powerpc/include/asm/hw_breakpoint.h b/arch/powerpc/include/asm/hw_breakpoint.h
index eb0f4ac75c4c..ac6432d9be46 100644
--- a/arch/powerpc/include/asm/hw_breakpoint.h
+++ b/arch/powerpc/include/asm/hw_breakpoint.h
@@ -79,7 +79,7 @@ static inline void hw_breakpoint_disable(void)
79 brk.address = 0; 79 brk.address = 0;
80 brk.type = 0; 80 brk.type = 0;
81 brk.len = 0; 81 brk.len = 0;
82 set_breakpoint(&brk); 82 __set_breakpoint(&brk);
83} 83}
84extern void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs); 84extern void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs);
85 85
diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index b0a1792279bb..0bb5918faaaf 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -72,7 +72,7 @@ int arch_install_hw_breakpoint(struct perf_event *bp)
72 * If so, DABR will be populated in single_step_dabr_instruction(). 72 * If so, DABR will be populated in single_step_dabr_instruction().
73 */ 73 */
74 if (current->thread.last_hit_ubp != bp) 74 if (current->thread.last_hit_ubp != bp)
75 set_breakpoint(info); 75 __set_breakpoint(info);
76 76
77 return 0; 77 return 0;
78} 78}
@@ -198,7 +198,7 @@ void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs)
198 198
199 info = counter_arch_bp(tsk->thread.last_hit_ubp); 199 info = counter_arch_bp(tsk->thread.last_hit_ubp);
200 regs->msr &= ~MSR_SE; 200 regs->msr &= ~MSR_SE;
201 set_breakpoint(info); 201 __set_breakpoint(info);
202 tsk->thread.last_hit_ubp = NULL; 202 tsk->thread.last_hit_ubp = NULL;
203} 203}
204 204
@@ -284,7 +284,7 @@ int __kprobes hw_breakpoint_handler(struct die_args *args)
284 if (!(info->type & HW_BRK_TYPE_EXTRANEOUS_IRQ)) 284 if (!(info->type & HW_BRK_TYPE_EXTRANEOUS_IRQ))
285 perf_bp_event(bp, regs); 285 perf_bp_event(bp, regs);
286 286
287 set_breakpoint(info); 287 __set_breakpoint(info);
288out: 288out:
289 rcu_read_unlock(); 289 rcu_read_unlock();
290 return rc; 290 return rc;
@@ -316,7 +316,7 @@ int __kprobes single_step_dabr_instruction(struct die_args *args)
316 if (!(info->type & HW_BRK_TYPE_EXTRANEOUS_IRQ)) 316 if (!(info->type & HW_BRK_TYPE_EXTRANEOUS_IRQ))
317 perf_bp_event(bp, regs); 317 perf_bp_event(bp, regs);
318 318
319 set_breakpoint(info); 319 __set_breakpoint(info);
320 current->thread.last_hit_ubp = NULL; 320 current->thread.last_hit_ubp = NULL;
321 321
322 /* 322 /*
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index f895a5062287..8a1edbe26b8f 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -496,7 +496,7 @@ static inline int set_dawr(struct arch_hw_breakpoint *brk)
496 return 0; 496 return 0;
497} 497}
498 498
499void set_breakpoint(struct arch_hw_breakpoint *brk) 499void __set_breakpoint(struct arch_hw_breakpoint *brk)
500{ 500{
501 __get_cpu_var(current_brk) = *brk; 501 __get_cpu_var(current_brk) = *brk;
502 502
@@ -506,6 +506,13 @@ void set_breakpoint(struct arch_hw_breakpoint *brk)
506 set_dabr(brk); 506 set_dabr(brk);
507} 507}
508 508
509void set_breakpoint(struct arch_hw_breakpoint *brk)
510{
511 preempt_disable();
512 __set_breakpoint(brk);
513 preempt_enable();
514}
515
509#ifdef CONFIG_PPC64 516#ifdef CONFIG_PPC64
510DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array); 517DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array);
511#endif 518#endif
@@ -835,7 +842,7 @@ struct task_struct *__switch_to(struct task_struct *prev,
835 */ 842 */
836#ifndef CONFIG_HAVE_HW_BREAKPOINT 843#ifndef CONFIG_HAVE_HW_BREAKPOINT
837 if (unlikely(!hw_brk_match(&__get_cpu_var(current_brk), &new->thread.hw_brk))) 844 if (unlikely(!hw_brk_match(&__get_cpu_var(current_brk), &new->thread.hw_brk)))
838 set_breakpoint(&new->thread.hw_brk); 845 __set_breakpoint(&new->thread.hw_brk);
839#endif /* CONFIG_HAVE_HW_BREAKPOINT */ 846#endif /* CONFIG_HAVE_HW_BREAKPOINT */
840#endif 847#endif
841 848
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index 8fc4177ed65a..1c794cef2883 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -134,7 +134,7 @@ static int do_signal(struct pt_regs *regs)
134 */ 134 */
135 if (current->thread.hw_brk.address && 135 if (current->thread.hw_brk.address &&
136 current->thread.hw_brk.type) 136 current->thread.hw_brk.type)
137 set_breakpoint(&current->thread.hw_brk); 137 __set_breakpoint(&current->thread.hw_brk);
138#endif 138#endif
139 /* Re-enable the breakpoints for the signal stack */ 139 /* Re-enable the breakpoints for the signal stack */
140 thread_change_pc(current, regs); 140 thread_change_pc(current, regs);
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 08504e75b2c7..d3759b7a5535 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -759,7 +759,7 @@ static void insert_cpu_bpts(void)
759 brk.address = dabr.address; 759 brk.address = dabr.address;
760 brk.type = (dabr.enabled & HW_BRK_TYPE_DABR) | HW_BRK_TYPE_PRIV_ALL; 760 brk.type = (dabr.enabled & HW_BRK_TYPE_DABR) | HW_BRK_TYPE_PRIV_ALL;
761 brk.len = 8; 761 brk.len = 8;
762 set_breakpoint(&brk); 762 __set_breakpoint(&brk);
763 } 763 }
764 if (iabr && cpu_has_feature(CPU_FTR_IABR)) 764 if (iabr && cpu_has_feature(CPU_FTR_IABR))
765 mtspr(SPRN_IABR, iabr->address 765 mtspr(SPRN_IABR, iabr->address