blob: d91c31870ac897f1185b7e24bb83302f70f457df [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* arch/sparc64/kernel/kprobes.c
2 *
3 * Copyright (C) 2004 David S. Miller <davem@davemloft.net>
4 */
5
6#include <linux/config.h>
7#include <linux/kernel.h>
8#include <linux/kprobes.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <asm/kdebug.h>
10#include <asm/signal.h>
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -070011#include <asm/cacheflush.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
13/* We do not have hardware single-stepping on sparc64.
14 * So we implement software single-stepping with breakpoint
15 * traps. The top-level scheme is similar to that used
16 * in the x86 kprobes implementation.
17 *
18 * In the kprobe->ainsn.insn[] array we store the original
19 * instruction at index zero and a break instruction at
20 * index one.
21 *
22 * When we hit a kprobe we:
23 * - Run the pre-handler
24 * - Remember "regs->tnpc" and interrupt level stored in
25 * "regs->tstate" so we can restore them later
26 * - Disable PIL interrupts
27 * - Set regs->tpc to point to kprobe->ainsn.insn[0]
28 * - Set regs->tnpc to point to kprobe->ainsn.insn[1]
29 * - Mark that we are actively in a kprobe
30 *
31 * At this point we wait for the second breakpoint at
32 * kprobe->ainsn.insn[1] to hit. When it does we:
33 * - Run the post-handler
34 * - Set regs->tpc to "remembered" regs->tnpc stored above,
35 * restore the PIL interrupt level in "regs->tstate" as well
36 * - Make any adjustments necessary to regs->tnpc in order
37 * to handle relative branches correctly. See below.
38 * - Mark that we are no longer actively in a kprobe.
39 */
40
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080041DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
42DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
43
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -070044int __kprobes arch_prepare_kprobe(struct kprobe *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -070045{
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 p->ainsn.insn[0] = *p->addr;
47 p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2;
Rusty Lynch7e1048b2005-06-23 00:09:25 -070048 p->opcode = *p->addr;
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -080049 return 0;
Rusty Lynch7e1048b2005-06-23 00:09:25 -070050}
51
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -070052void __kprobes arch_arm_kprobe(struct kprobe *p)
Rusty Lynch7e1048b2005-06-23 00:09:25 -070053{
54 *p->addr = BREAKPOINT_INSTRUCTION;
55 flushi(p->addr);
56}
57
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -070058void __kprobes arch_disarm_kprobe(struct kprobe *p)
Rusty Lynch7e1048b2005-06-23 00:09:25 -070059{
60 *p->addr = p->opcode;
61 flushi(p->addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062}
63
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080064static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070065{
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080066 kcb->prev_kprobe.kp = kprobe_running();
67 kcb->prev_kprobe.status = kcb->kprobe_status;
68 kcb->prev_kprobe.orig_tnpc = kcb->kprobe_orig_tnpc;
69 kcb->prev_kprobe.orig_tstate_pil = kcb->kprobe_orig_tstate_pil;
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070070}
71
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080072static inline void restore_previous_kprobe(struct kprobe_ctlblk *kcb)
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070073{
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080074 __get_cpu_var(current_kprobe) = kcb->prev_kprobe.kp;
75 kcb->kprobe_status = kcb->prev_kprobe.status;
76 kcb->kprobe_orig_tnpc = kcb->prev_kprobe.orig_tnpc;
77 kcb->kprobe_orig_tstate_pil = kcb->prev_kprobe.orig_tstate_pil;
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070078}
79
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080080static inline void set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
81 struct kprobe_ctlblk *kcb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082{
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080083 __get_cpu_var(current_kprobe) = p;
84 kcb->kprobe_orig_tnpc = regs->tnpc;
85 kcb->kprobe_orig_tstate_pil = (regs->tstate & TSTATE_PIL);
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070086}
87
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080088static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs,
89 struct kprobe_ctlblk *kcb)
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070090{
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 regs->tstate |= TSTATE_PIL;
92
93 /*single step inline, if it a breakpoint instruction*/
94 if (p->opcode == BREAKPOINT_INSTRUCTION) {
95 regs->tpc = (unsigned long) p->addr;
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080096 regs->tnpc = kcb->kprobe_orig_tnpc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 } else {
98 regs->tpc = (unsigned long) &p->ainsn.insn[0];
99 regs->tnpc = (unsigned long) &p->ainsn.insn[1];
100 }
101}
102
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700103static int __kprobes kprobe_handler(struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104{
105 struct kprobe *p;
106 void *addr = (void *) regs->tpc;
107 int ret = 0;
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800108 struct kprobe_ctlblk *kcb;
109
110 /*
111 * We don't want to be preempted for the entire
112 * duration of kprobe processing
113 */
114 preempt_disable();
115 kcb = get_kprobe_ctlblk();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 if (kprobe_running()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 p = get_kprobe(addr);
119 if (p) {
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800120 if (kcb->kprobe_status == KPROBE_HIT_SS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 regs->tstate = ((regs->tstate & ~TSTATE_PIL) |
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800122 kcb->kprobe_orig_tstate_pil);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 goto no_kprobe;
124 }
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700125 /* We have reentered the kprobe_handler(), since
126 * another probe was hit while within the handler.
127 * We here save the original kprobes variables and
128 * just single step on the instruction of the new probe
129 * without calling any user handlers.
130 */
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800131 save_previous_kprobe(kcb);
132 set_current_kprobe(p, regs, kcb);
Keshavamurthy Anil Sbf8d5c52005-12-12 00:37:34 -0800133 kprobes_inc_nmissed_count(p);
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800134 kcb->kprobe_status = KPROBE_REENTER;
135 prepare_singlestep(p, regs, kcb);
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700136 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 } else {
Keshavamurthy Anil Seb3a7292006-01-11 12:17:42 -0800138 if (*(u32 *)addr != BREAKPOINT_INSTRUCTION) {
139 /* The breakpoint instruction was removed by
140 * another cpu right after we hit, no further
141 * handling of this interrupt is appropriate
142 */
143 ret = 1;
144 goto no_kprobe;
145 }
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800146 p = __get_cpu_var(current_kprobe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 if (p->break_handler && p->break_handler(p, regs))
148 goto ss_probe;
149 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 goto no_kprobe;
151 }
152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 p = get_kprobe(addr);
154 if (!p) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 if (*(u32 *)addr != BREAKPOINT_INSTRUCTION) {
156 /*
157 * The breakpoint instruction was removed right
158 * after we hit it. Another cpu has removed
159 * either a probepoint or a debugger breakpoint
160 * at this address. In either case, no further
161 * handling of this interrupt is appropriate.
162 */
163 ret = 1;
164 }
165 /* Not one of ours: let kernel handle it */
166 goto no_kprobe;
167 }
168
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800169 set_current_kprobe(p, regs, kcb);
170 kcb->kprobe_status = KPROBE_HIT_ACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 if (p->pre_handler && p->pre_handler(p, regs))
172 return 1;
173
174ss_probe:
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800175 prepare_singlestep(p, regs, kcb);
176 kcb->kprobe_status = KPROBE_HIT_SS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 return 1;
178
179no_kprobe:
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800180 preempt_enable_no_resched();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 return ret;
182}
183
184/* If INSN is a relative control transfer instruction,
185 * return the corrected branch destination value.
186 *
187 * The original INSN location was REAL_PC, it actually
188 * executed at PC and produced destination address NPC.
189 */
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700190static unsigned long __kprobes relbranch_fixup(u32 insn, unsigned long real_pc,
191 unsigned long pc,
192 unsigned long npc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193{
194 /* Branch not taken, no mods necessary. */
195 if (npc == pc + 0x4UL)
196 return real_pc + 0x4UL;
197
198 /* The three cases are call, branch w/prediction,
199 * and traditional branch.
200 */
201 if ((insn & 0xc0000000) == 0x40000000 ||
202 (insn & 0xc1c00000) == 0x00400000 ||
203 (insn & 0xc1c00000) == 0x00800000) {
204 /* The instruction did all the work for us
205 * already, just apply the offset to the correct
206 * instruction location.
207 */
208 return (real_pc + (npc - pc));
209 }
210
211 return real_pc + 0x4UL;
212}
213
214/* If INSN is an instruction which writes it's PC location
215 * into a destination register, fix that up.
216 */
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700217static void __kprobes retpc_fixup(struct pt_regs *regs, u32 insn,
218 unsigned long real_pc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219{
220 unsigned long *slot = NULL;
221
222 /* Simplest cast is call, which always uses %o7 */
223 if ((insn & 0xc0000000) == 0x40000000) {
224 slot = &regs->u_regs[UREG_I7];
225 }
226
227 /* Jmpl encodes the register inside of the opcode */
228 if ((insn & 0xc1f80000) == 0x81c00000) {
229 unsigned long rd = ((insn >> 25) & 0x1f);
230
231 if (rd <= 15) {
232 slot = &regs->u_regs[rd];
233 } else {
234 /* Hard case, it goes onto the stack. */
235 flushw_all();
236
237 rd -= 16;
238 slot = (unsigned long *)
239 (regs->u_regs[UREG_FP] + STACK_BIAS);
240 slot += rd;
241 }
242 }
243 if (slot != NULL)
244 *slot = real_pc;
245}
246
247/*
248 * Called after single-stepping. p->addr is the address of the
249 * instruction whose first byte has been replaced by the breakpoint
250 * instruction. To avoid the SMP problems that can occur when we
251 * temporarily put back the original opcode to single-step, we
252 * single-stepped a copy of the instruction. The address of this
253 * copy is p->ainsn.insn.
254 *
255 * This function prepares to return from the post-single-step
256 * breakpoint trap.
257 */
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800258static void __kprobes resume_execution(struct kprobe *p,
259 struct pt_regs *regs, struct kprobe_ctlblk *kcb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260{
261 u32 insn = p->ainsn.insn[0];
262
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800263 regs->tpc = kcb->kprobe_orig_tnpc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 regs->tnpc = relbranch_fixup(insn,
265 (unsigned long) p->addr,
266 (unsigned long) &p->ainsn.insn[0],
267 regs->tnpc);
268 retpc_fixup(regs, insn, (unsigned long) p->addr);
269
270 regs->tstate = ((regs->tstate & ~TSTATE_PIL) |
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800271 kcb->kprobe_orig_tstate_pil);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272}
273
274static inline int post_kprobe_handler(struct pt_regs *regs)
275{
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800276 struct kprobe *cur = kprobe_running();
277 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
278
279 if (!cur)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 return 0;
281
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800282 if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
283 kcb->kprobe_status = KPROBE_HIT_SSDONE;
284 cur->post_handler(cur, regs, 0);
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700285 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800287 resume_execution(cur, regs, kcb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700289 /*Restore back the original saved kprobes variables and continue. */
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800290 if (kcb->kprobe_status == KPROBE_REENTER) {
291 restore_previous_kprobe(kcb);
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700292 goto out;
293 }
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800294 reset_current_kprobe();
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700295out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 preempt_enable_no_resched();
297
298 return 1;
299}
300
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
302{
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800303 struct kprobe *cur = kprobe_running();
304 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
305
306 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 return 1;
308
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800309 if (kcb->kprobe_status & KPROBE_HIT_SS) {
310 resume_execution(cur, regs, kcb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800312 reset_current_kprobe();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 preempt_enable_no_resched();
314 }
315 return 0;
316}
317
318/*
319 * Wrapper routine to for handling exceptions.
320 */
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700321int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
322 unsigned long val, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323{
324 struct die_args *args = (struct die_args *)data;
Ananth N Mavinakayanahalli66ff2d02005-11-07 01:00:07 -0800325 int ret = NOTIFY_DONE;
326
bibo,mao2326c772006-03-26 01:38:21 -0800327 if (args->regs && user_mode(args->regs))
328 return ret;
329
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 switch (val) {
331 case DIE_DEBUG:
332 if (kprobe_handler(args->regs))
Ananth N Mavinakayanahalli66ff2d02005-11-07 01:00:07 -0800333 ret = NOTIFY_STOP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 break;
335 case DIE_DEBUG_2:
336 if (post_kprobe_handler(args->regs))
Ananth N Mavinakayanahalli66ff2d02005-11-07 01:00:07 -0800337 ret = NOTIFY_STOP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 break;
339 case DIE_GPF:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 case DIE_PAGE_FAULT:
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800341 /* kprobe_running() needs smp_processor_id() */
342 preempt_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 if (kprobe_running() &&
344 kprobe_fault_handler(args->regs, args->trapnr))
Ananth N Mavinakayanahalli66ff2d02005-11-07 01:00:07 -0800345 ret = NOTIFY_STOP;
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800346 preempt_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 break;
348 default:
349 break;
350 }
Ananth N Mavinakayanahalli66ff2d02005-11-07 01:00:07 -0800351 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352}
353
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700354asmlinkage void __kprobes kprobe_trap(unsigned long trap_level,
355 struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356{
357 BUG_ON(trap_level != 0x170 && trap_level != 0x171);
358
359 if (user_mode(regs)) {
360 local_irq_enable();
361 bad_trap(regs, trap_level);
362 return;
363 }
364
365 /* trap_level == 0x170 --> ta 0x70
366 * trap_level == 0x171 --> ta 0x71
367 */
368 if (notify_die((trap_level == 0x170) ? DIE_DEBUG : DIE_DEBUG_2,
369 (trap_level == 0x170) ? "debug" : "debug_2",
370 regs, 0, trap_level, SIGTRAP) != NOTIFY_STOP)
371 bad_trap(regs, trap_level);
372}
373
374/* Jprobes support. */
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700375int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376{
377 struct jprobe *jp = container_of(p, struct jprobe, kp);
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800378 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800380 kcb->jprobe_saved_regs_location = regs;
381 memcpy(&(kcb->jprobe_saved_regs), regs, sizeof(*regs));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382
383 /* Save a whole stack frame, this gets arguments
384 * pushed onto the stack after using up all the
385 * arg registers.
386 */
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800387 memcpy(&(kcb->jprobe_saved_stack),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 (char *) (regs->u_regs[UREG_FP] + STACK_BIAS),
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800389 sizeof(kcb->jprobe_saved_stack));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390
391 regs->tpc = (unsigned long) jp->entry;
392 regs->tnpc = ((unsigned long) jp->entry) + 0x4UL;
393 regs->tstate |= TSTATE_PIL;
394
395 return 1;
396}
397
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700398void __kprobes jprobe_return(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 __asm__ __volatile__(
401 ".globl jprobe_return_trap_instruction\n"
402"jprobe_return_trap_instruction:\n\t"
403 "ta 0x70");
404}
405
406extern void jprobe_return_trap_instruction(void);
407
408extern void __show_regs(struct pt_regs * regs);
409
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700410int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411{
412 u32 *addr = (u32 *) regs->tpc;
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800413 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
415 if (addr == (u32 *) jprobe_return_trap_instruction) {
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800416 if (kcb->jprobe_saved_regs_location != regs) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 printk("JPROBE: Current regs (%p) does not match "
418 "saved regs (%p).\n",
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800419 regs, kcb->jprobe_saved_regs_location);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 printk("JPROBE: Saved registers\n");
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800421 __show_regs(kcb->jprobe_saved_regs_location);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 printk("JPROBE: Current registers\n");
423 __show_regs(regs);
424 BUG();
425 }
426 /* Restore old register state. Do pt_regs
427 * first so that UREG_FP is the original one for
428 * the stack frame restore.
429 */
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800430 memcpy(regs, &(kcb->jprobe_saved_regs), sizeof(*regs));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
432 memcpy((char *) (regs->u_regs[UREG_FP] + STACK_BIAS),
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800433 &(kcb->jprobe_saved_stack),
434 sizeof(kcb->jprobe_saved_stack));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800436 preempt_enable_no_resched();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 return 1;
438 }
439 return 0;
440}
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700441
Rusty Lynch67729262005-07-05 18:54:50 -0700442/* architecture specific initialization */
443int arch_init_kprobes(void)
444{
445 return 0;
446}