Commit 3cea45c6ef459b776123a4855eba6dafd506f3ce

Authored by Mike Frysinger
Committed by Linus Torvalds
1 parent c46dd6b48d

sh: convert to asm-generic ptrace.h

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Sergei Shtylyov <sshtylyov@mvista.com>
Cc: Dongdong Deng <dongdong.deng@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 4 additions and 2 deletions Inline Diff

arch/sh/include/asm/ptrace.h
1 #ifndef __ASM_SH_PTRACE_H 1 #ifndef __ASM_SH_PTRACE_H
2 #define __ASM_SH_PTRACE_H 2 #define __ASM_SH_PTRACE_H
3 3
4 /* 4 /*
5 * Copyright (C) 1999, 2000 Niibe Yutaka 5 * Copyright (C) 1999, 2000 Niibe Yutaka
6 */ 6 */
7 7
8 #define PTRACE_GETREGS 12 /* General registers */ 8 #define PTRACE_GETREGS 12 /* General registers */
9 #define PTRACE_SETREGS 13 9 #define PTRACE_SETREGS 13
10 10
11 #define PTRACE_GETFPREGS 14 /* FPU registers */ 11 #define PTRACE_GETFPREGS 14 /* FPU registers */
12 #define PTRACE_SETFPREGS 15 12 #define PTRACE_SETFPREGS 15
13 13
14 #define PTRACE_GETFDPIC 31 /* get the ELF fdpic loadmap address */ 14 #define PTRACE_GETFDPIC 31 /* get the ELF fdpic loadmap address */
15 15
16 #define PTRACE_GETFDPIC_EXEC 0 /* [addr] request the executable loadmap */ 16 #define PTRACE_GETFDPIC_EXEC 0 /* [addr] request the executable loadmap */
17 #define PTRACE_GETFDPIC_INTERP 1 /* [addr] request the interpreter loadmap */ 17 #define PTRACE_GETFDPIC_INTERP 1 /* [addr] request the interpreter loadmap */
18 18
19 #define PTRACE_GETDSPREGS 55 /* DSP registers */ 19 #define PTRACE_GETDSPREGS 55 /* DSP registers */
20 #define PTRACE_SETDSPREGS 56 20 #define PTRACE_SETDSPREGS 56
21 21
22 #define PT_TEXT_END_ADDR 240 22 #define PT_TEXT_END_ADDR 240
23 #define PT_TEXT_ADDR 244 /* &(struct user)->start_code */ 23 #define PT_TEXT_ADDR 244 /* &(struct user)->start_code */
24 #define PT_DATA_ADDR 248 /* &(struct user)->start_data */ 24 #define PT_DATA_ADDR 248 /* &(struct user)->start_data */
25 #define PT_TEXT_LEN 252 25 #define PT_TEXT_LEN 252
26 26
27 #if defined(__SH5__) || defined(CONFIG_CPU_SH5) 27 #if defined(__SH5__) || defined(CONFIG_CPU_SH5)
28 #include "ptrace_64.h" 28 #include "ptrace_64.h"
29 #else 29 #else
30 #include "ptrace_32.h" 30 #include "ptrace_32.h"
31 #endif 31 #endif
32 32
33 #ifdef __KERNEL__ 33 #ifdef __KERNEL__
34 34
35 #include <linux/stringify.h> 35 #include <linux/stringify.h>
36 #include <linux/stddef.h> 36 #include <linux/stddef.h>
37 #include <linux/thread_info.h> 37 #include <linux/thread_info.h>
38 #include <asm/addrspace.h> 38 #include <asm/addrspace.h>
39 #include <asm/page.h> 39 #include <asm/page.h>
40 #include <asm/system.h> 40 #include <asm/system.h>
41 41
42 #define user_mode(regs) (((regs)->sr & 0x40000000)==0) 42 #define user_mode(regs) (((regs)->sr & 0x40000000)==0)
43 #define user_stack_pointer(_regs) ((unsigned long)(_regs)->regs[15])
44 #define kernel_stack_pointer(_regs) ((unsigned long)(_regs)->regs[15]) 43 #define kernel_stack_pointer(_regs) ((unsigned long)(_regs)->regs[15])
45 #define instruction_pointer(regs) ((unsigned long)(regs)->pc) 44 #define GET_USP(regs) ((regs)->regs[15])
46 45
47 extern void show_regs(struct pt_regs *); 46 extern void show_regs(struct pt_regs *);
48 47
49 #define arch_has_single_step() (1) 48 #define arch_has_single_step() (1)
50 49
51 /* 50 /*
52 * kprobe-based event tracer support 51 * kprobe-based event tracer support
53 */ 52 */
54 struct pt_regs_offset { 53 struct pt_regs_offset {
55 const char *name; 54 const char *name;
56 int offset; 55 int offset;
57 }; 56 };
58 57
59 #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)} 58 #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
60 #define REGS_OFFSET_NAME(num) \ 59 #define REGS_OFFSET_NAME(num) \
61 {.name = __stringify(r##num), .offset = offsetof(struct pt_regs, regs[num])} 60 {.name = __stringify(r##num), .offset = offsetof(struct pt_regs, regs[num])}
62 #define TREGS_OFFSET_NAME(num) \ 61 #define TREGS_OFFSET_NAME(num) \
63 {.name = __stringify(tr##num), .offset = offsetof(struct pt_regs, tregs[num])} 62 {.name = __stringify(tr##num), .offset = offsetof(struct pt_regs, tregs[num])}
64 #define REG_OFFSET_END {.name = NULL, .offset = 0} 63 #define REG_OFFSET_END {.name = NULL, .offset = 0}
65 64
66 /* Query offset/name of register from its name/offset */ 65 /* Query offset/name of register from its name/offset */
67 extern int regs_query_register_offset(const char *name); 66 extern int regs_query_register_offset(const char *name);
68 extern const char *regs_query_register_name(unsigned int offset); 67 extern const char *regs_query_register_name(unsigned int offset);
69 68
70 extern const struct pt_regs_offset regoffset_table[]; 69 extern const struct pt_regs_offset regoffset_table[];
71 70
72 /** 71 /**
73 * regs_get_register() - get register value from its offset 72 * regs_get_register() - get register value from its offset
74 * @regs: pt_regs from which register value is gotten. 73 * @regs: pt_regs from which register value is gotten.
75 * @offset: offset number of the register. 74 * @offset: offset number of the register.
76 * 75 *
77 * regs_get_register returns the value of a register. The @offset is the 76 * regs_get_register returns the value of a register. The @offset is the
78 * offset of the register in struct pt_regs address which specified by @regs. 77 * offset of the register in struct pt_regs address which specified by @regs.
79 * If @offset is bigger than MAX_REG_OFFSET, this returns 0. 78 * If @offset is bigger than MAX_REG_OFFSET, this returns 0.
80 */ 79 */
81 static inline unsigned long regs_get_register(struct pt_regs *regs, 80 static inline unsigned long regs_get_register(struct pt_regs *regs,
82 unsigned int offset) 81 unsigned int offset)
83 { 82 {
84 if (unlikely(offset > MAX_REG_OFFSET)) 83 if (unlikely(offset > MAX_REG_OFFSET))
85 return 0; 84 return 0;
86 return *(unsigned long *)((unsigned long)regs + offset); 85 return *(unsigned long *)((unsigned long)regs + offset);
87 } 86 }
88 87
89 /** 88 /**
90 * regs_within_kernel_stack() - check the address in the stack 89 * regs_within_kernel_stack() - check the address in the stack
91 * @regs: pt_regs which contains kernel stack pointer. 90 * @regs: pt_regs which contains kernel stack pointer.
92 * @addr: address which is checked. 91 * @addr: address which is checked.
93 * 92 *
94 * regs_within_kernel_stack() checks @addr is within the kernel stack page(s). 93 * regs_within_kernel_stack() checks @addr is within the kernel stack page(s).
95 * If @addr is within the kernel stack, it returns true. If not, returns false. 94 * If @addr is within the kernel stack, it returns true. If not, returns false.
96 */ 95 */
97 static inline int regs_within_kernel_stack(struct pt_regs *regs, 96 static inline int regs_within_kernel_stack(struct pt_regs *regs,
98 unsigned long addr) 97 unsigned long addr)
99 { 98 {
100 return ((addr & ~(THREAD_SIZE - 1)) == 99 return ((addr & ~(THREAD_SIZE - 1)) ==
101 (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1))); 100 (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
102 } 101 }
103 102
104 /** 103 /**
105 * regs_get_kernel_stack_nth() - get Nth entry of the stack 104 * regs_get_kernel_stack_nth() - get Nth entry of the stack
106 * @regs: pt_regs which contains kernel stack pointer. 105 * @regs: pt_regs which contains kernel stack pointer.
107 * @n: stack entry number. 106 * @n: stack entry number.
108 * 107 *
109 * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which 108 * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
110 * is specified by @regs. If the @n th entry is NOT in the kernel stack, 109 * is specified by @regs. If the @n th entry is NOT in the kernel stack,
111 * this returns 0. 110 * this returns 0.
112 */ 111 */
113 static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, 112 static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
114 unsigned int n) 113 unsigned int n)
115 { 114 {
116 unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs); 115 unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs);
117 addr += n; 116 addr += n;
118 if (regs_within_kernel_stack(regs, (unsigned long)addr)) 117 if (regs_within_kernel_stack(regs, (unsigned long)addr))
119 return *addr; 118 return *addr;
120 else 119 else
121 return 0; 120 return 0;
122 } 121 }
123 122
124 struct perf_event; 123 struct perf_event;
125 struct perf_sample_data; 124 struct perf_sample_data;
126 125
127 extern void ptrace_triggered(struct perf_event *bp, int nmi, 126 extern void ptrace_triggered(struct perf_event *bp, int nmi,
128 struct perf_sample_data *data, struct pt_regs *regs); 127 struct perf_sample_data *data, struct pt_regs *regs);
129 128
130 #define task_pt_regs(task) \ 129 #define task_pt_regs(task) \
131 ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1) 130 ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1)
132 131
133 static inline unsigned long profile_pc(struct pt_regs *regs) 132 static inline unsigned long profile_pc(struct pt_regs *regs)
134 { 133 {
135 unsigned long pc = instruction_pointer(regs); 134 unsigned long pc = instruction_pointer(regs);
136 135
137 if (virt_addr_uncached(pc)) 136 if (virt_addr_uncached(pc))
138 return CAC_ADDR(pc); 137 return CAC_ADDR(pc);
139 138
140 return pc; 139 return pc;
141 } 140 }
141 #define profile_pc profile_pc
142
143 #include <asm-generic/ptrace.h>
142 #endif /* __KERNEL__ */ 144 #endif /* __KERNEL__ */
143 145
144 #endif /* __ASM_SH_PTRACE_H */ 146 #endif /* __ASM_SH_PTRACE_H */