aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-05-17 22:26:53 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-05-18 00:35:23 -0400
commitf0218b3e9974f06014b61be8987159f4a20e011e (patch)
tree29a593c4d71ab18cb0c450a34e79bf6bea66877e /arch/sh
parent1eaa4787a774c4896518c81f24e8bccaa2244924 (diff)
parent9d192e118a094087494997ea1c8a2faf39af38c5 (diff)
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip into trace/tip/tracing/core-6
Conflicts: include/trace/ftrace.h kernel/trace/trace_kprobe.c Acked-by: Masami Hiramatsu <mhiramat@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'arch/sh')
-rw-r--r--arch/sh/Kconfig1
-rw-r--r--arch/sh/include/asm/hw_breakpoint.h10
-rw-r--r--arch/sh/kernel/hw_breakpoint.c34
-rw-r--r--arch/sh/kernel/ptrace_32.c2
4 files changed, 16 insertions, 31 deletions
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 8d90564c2bcf..e6d8ab5cfa9d 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -44,6 +44,7 @@ config SUPERH32
44 select HAVE_FUNCTION_GRAPH_TRACER 44 select HAVE_FUNCTION_GRAPH_TRACER
45 select HAVE_ARCH_KGDB 45 select HAVE_ARCH_KGDB
46 select HAVE_HW_BREAKPOINT 46 select HAVE_HW_BREAKPOINT
47 select HAVE_MIXED_BREAKPOINTS_REGS
47 select PERF_EVENTS if HAVE_HW_BREAKPOINT 48 select PERF_EVENTS if HAVE_HW_BREAKPOINT
48 select ARCH_HIBERNATION_POSSIBLE if MMU 49 select ARCH_HIBERNATION_POSSIBLE if MMU
49 50
diff --git a/arch/sh/include/asm/hw_breakpoint.h b/arch/sh/include/asm/hw_breakpoint.h
index 965dd780d51b..e14cad96798f 100644
--- a/arch/sh/include/asm/hw_breakpoint.h
+++ b/arch/sh/include/asm/hw_breakpoint.h
@@ -46,10 +46,14 @@ struct pmu;
46/* Maximum number of UBC channels */ 46/* Maximum number of UBC channels */
47#define HBP_NUM 2 47#define HBP_NUM 2
48 48
49static inline int hw_breakpoint_slots(int type)
50{
51 return HBP_NUM;
52}
53
49/* arch/sh/kernel/hw_breakpoint.c */ 54/* arch/sh/kernel/hw_breakpoint.c */
50extern int arch_check_va_in_userspace(unsigned long va, u16 hbp_len); 55extern int arch_check_bp_in_kernelspace(struct perf_event *bp);
51extern int arch_validate_hwbkpt_settings(struct perf_event *bp, 56extern int arch_validate_hwbkpt_settings(struct perf_event *bp);
52 struct task_struct *tsk);
53extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused, 57extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
54 unsigned long val, void *data); 58 unsigned long val, void *data);
55 59
diff --git a/arch/sh/kernel/hw_breakpoint.c b/arch/sh/kernel/hw_breakpoint.c
index 675eea7785d9..1f2cf6229862 100644
--- a/arch/sh/kernel/hw_breakpoint.c
+++ b/arch/sh/kernel/hw_breakpoint.c
@@ -120,25 +120,16 @@ static int get_hbp_len(u16 hbp_len)
120} 120}
121 121
122/* 122/*
123 * Check for virtual address in user space.
124 */
125int arch_check_va_in_userspace(unsigned long va, u16 hbp_len)
126{
127 unsigned int len;
128
129 len = get_hbp_len(hbp_len);
130
131 return (va <= TASK_SIZE - len);
132}
133
134/*
135 * Check for virtual address in kernel space. 123 * Check for virtual address in kernel space.
136 */ 124 */
137static int arch_check_va_in_kernelspace(unsigned long va, u8 hbp_len) 125int arch_check_bp_in_kernelspace(struct perf_event *bp)
138{ 126{
139 unsigned int len; 127 unsigned int len;
128 unsigned long va;
129 struct arch_hw_breakpoint *info = counter_arch_bp(bp);
140 130
141 len = get_hbp_len(hbp_len); 131 va = info->address;
132 len = get_hbp_len(info->len);
142 133
143 return (va >= TASK_SIZE) && ((va + len - 1) >= TASK_SIZE); 134 return (va >= TASK_SIZE) && ((va + len - 1) >= TASK_SIZE);
144} 135}
@@ -226,8 +217,7 @@ static int arch_build_bp_info(struct perf_event *bp)
226/* 217/*
227 * Validate the arch-specific HW Breakpoint register settings 218 * Validate the arch-specific HW Breakpoint register settings
228 */ 219 */
229int arch_validate_hwbkpt_settings(struct perf_event *bp, 220int arch_validate_hwbkpt_settings(struct perf_event *bp)
230 struct task_struct *tsk)
231{ 221{
232 struct arch_hw_breakpoint *info = counter_arch_bp(bp); 222 struct arch_hw_breakpoint *info = counter_arch_bp(bp);
233 unsigned int align; 223 unsigned int align;
@@ -270,15 +260,6 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp,
270 if (info->address & align) 260 if (info->address & align)
271 return -EINVAL; 261 return -EINVAL;
272 262
273 /* Check that the virtual address is in the proper range */
274 if (tsk) {
275 if (!arch_check_va_in_userspace(info->address, info->len))
276 return -EFAULT;
277 } else {
278 if (!arch_check_va_in_kernelspace(info->address, info->len))
279 return -EFAULT;
280 }
281
282 return 0; 263 return 0;
283} 264}
284 265
@@ -363,8 +344,7 @@ static int __kprobes hw_breakpoint_handler(struct die_args *args)
363 perf_bp_event(bp, args->regs); 344 perf_bp_event(bp, args->regs);
364 345
365 /* Deliver the signal to userspace */ 346 /* Deliver the signal to userspace */
366 if (arch_check_va_in_userspace(bp->attr.bp_addr, 347 if (!arch_check_bp_in_kernelspace(bp)) {
367 bp->attr.bp_len)) {
368 siginfo_t info; 348 siginfo_t info;
369 349
370 info.si_signo = args->signr; 350 info.si_signo = args->signr;
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c
index 7759a9a93211..d4104ce9fe53 100644
--- a/arch/sh/kernel/ptrace_32.c
+++ b/arch/sh/kernel/ptrace_32.c
@@ -85,7 +85,7 @@ static int set_single_step(struct task_struct *tsk, unsigned long addr)
85 85
86 bp = thread->ptrace_bps[0]; 86 bp = thread->ptrace_bps[0];
87 if (!bp) { 87 if (!bp) {
88 hw_breakpoint_init(&attr); 88 ptrace_breakpoint_init(&attr);
89 89
90 attr.bp_addr = addr; 90 attr.bp_addr = addr;
91 attr.bp_len = HW_BREAKPOINT_LEN_2; 91 attr.bp_len = HW_BREAKPOINT_LEN_2;