blob: bbd5aa6818eab1d33d72e757e65808b50bb9362e [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
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -070064void __kprobes arch_remove_kprobe(struct kprobe *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065{
66}
67
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080068static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070069{
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080070 kcb->prev_kprobe.kp = kprobe_running();
71 kcb->prev_kprobe.status = kcb->kprobe_status;
72 kcb->prev_kprobe.orig_tnpc = kcb->kprobe_orig_tnpc;
73 kcb->prev_kprobe.orig_tstate_pil = kcb->kprobe_orig_tstate_pil;
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070074}
75
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080076static inline void restore_previous_kprobe(struct kprobe_ctlblk *kcb)
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070077{
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080078 __get_cpu_var(current_kprobe) = kcb->prev_kprobe.kp;
79 kcb->kprobe_status = kcb->prev_kprobe.status;
80 kcb->kprobe_orig_tnpc = kcb->prev_kprobe.orig_tnpc;
81 kcb->kprobe_orig_tstate_pil = kcb->prev_kprobe.orig_tstate_pil;
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070082}
83
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080084static inline void set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
85 struct kprobe_ctlblk *kcb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086{
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080087 __get_cpu_var(current_kprobe) = p;
88 kcb->kprobe_orig_tnpc = regs->tnpc;
89 kcb->kprobe_orig_tstate_pil = (regs->tstate & TSTATE_PIL);
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070090}
91
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -080092static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs,
93 struct kprobe_ctlblk *kcb)
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -070094{
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 regs->tstate |= TSTATE_PIL;
96
97 /*single step inline, if it a breakpoint instruction*/
98 if (p->opcode == BREAKPOINT_INSTRUCTION) {
99 regs->tpc = (unsigned long) p->addr;
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800100 regs->tnpc = kcb->kprobe_orig_tnpc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 } else {
102 regs->tpc = (unsigned long) &p->ainsn.insn[0];
103 regs->tnpc = (unsigned long) &p->ainsn.insn[1];
104 }
105}
106
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700107static int __kprobes kprobe_handler(struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108{
109 struct kprobe *p;
110 void *addr = (void *) regs->tpc;
111 int ret = 0;
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800112 struct kprobe_ctlblk *kcb;
113
114 /*
115 * We don't want to be preempted for the entire
116 * duration of kprobe processing
117 */
118 preempt_disable();
119 kcb = get_kprobe_ctlblk();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 if (kprobe_running()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 p = get_kprobe(addr);
123 if (p) {
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800124 if (kcb->kprobe_status == KPROBE_HIT_SS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 regs->tstate = ((regs->tstate & ~TSTATE_PIL) |
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800126 kcb->kprobe_orig_tstate_pil);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 goto no_kprobe;
128 }
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700129 /* We have reentered the kprobe_handler(), since
130 * another probe was hit while within the handler.
131 * We here save the original kprobes variables and
132 * just single step on the instruction of the new probe
133 * without calling any user handlers.
134 */
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800135 save_previous_kprobe(kcb);
136 set_current_kprobe(p, regs, kcb);
Keshavamurthy Anil Sbf8d5c52005-12-12 00:37:34 -0800137 kprobes_inc_nmissed_count(p);
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800138 kcb->kprobe_status = KPROBE_REENTER;
139 prepare_singlestep(p, regs, kcb);
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700140 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 } else {
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800142 p = __get_cpu_var(current_kprobe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 if (p->break_handler && p->break_handler(p, regs))
144 goto ss_probe;
145 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 goto no_kprobe;
147 }
148
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 p = get_kprobe(addr);
150 if (!p) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 if (*(u32 *)addr != BREAKPOINT_INSTRUCTION) {
152 /*
153 * The breakpoint instruction was removed right
154 * after we hit it. Another cpu has removed
155 * either a probepoint or a debugger breakpoint
156 * at this address. In either case, no further
157 * handling of this interrupt is appropriate.
158 */
159 ret = 1;
160 }
161 /* Not one of ours: let kernel handle it */
162 goto no_kprobe;
163 }
164
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800165 set_current_kprobe(p, regs, kcb);
166 kcb->kprobe_status = KPROBE_HIT_ACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 if (p->pre_handler && p->pre_handler(p, regs))
168 return 1;
169
170ss_probe:
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800171 prepare_singlestep(p, regs, kcb);
172 kcb->kprobe_status = KPROBE_HIT_SS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 return 1;
174
175no_kprobe:
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800176 preempt_enable_no_resched();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 return ret;
178}
179
180/* If INSN is a relative control transfer instruction,
181 * return the corrected branch destination value.
182 *
183 * The original INSN location was REAL_PC, it actually
184 * executed at PC and produced destination address NPC.
185 */
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700186static unsigned long __kprobes relbranch_fixup(u32 insn, unsigned long real_pc,
187 unsigned long pc,
188 unsigned long npc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189{
190 /* Branch not taken, no mods necessary. */
191 if (npc == pc + 0x4UL)
192 return real_pc + 0x4UL;
193
194 /* The three cases are call, branch w/prediction,
195 * and traditional branch.
196 */
197 if ((insn & 0xc0000000) == 0x40000000 ||
198 (insn & 0xc1c00000) == 0x00400000 ||
199 (insn & 0xc1c00000) == 0x00800000) {
200 /* The instruction did all the work for us
201 * already, just apply the offset to the correct
202 * instruction location.
203 */
204 return (real_pc + (npc - pc));
205 }
206
207 return real_pc + 0x4UL;
208}
209
210/* If INSN is an instruction which writes it's PC location
211 * into a destination register, fix that up.
212 */
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700213static void __kprobes retpc_fixup(struct pt_regs *regs, u32 insn,
214 unsigned long real_pc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215{
216 unsigned long *slot = NULL;
217
218 /* Simplest cast is call, which always uses %o7 */
219 if ((insn & 0xc0000000) == 0x40000000) {
220 slot = &regs->u_regs[UREG_I7];
221 }
222
223 /* Jmpl encodes the register inside of the opcode */
224 if ((insn & 0xc1f80000) == 0x81c00000) {
225 unsigned long rd = ((insn >> 25) & 0x1f);
226
227 if (rd <= 15) {
228 slot = &regs->u_regs[rd];
229 } else {
230 /* Hard case, it goes onto the stack. */
231 flushw_all();
232
233 rd -= 16;
234 slot = (unsigned long *)
235 (regs->u_regs[UREG_FP] + STACK_BIAS);
236 slot += rd;
237 }
238 }
239 if (slot != NULL)
240 *slot = real_pc;
241}
242
243/*
244 * Called after single-stepping. p->addr is the address of the
245 * instruction whose first byte has been replaced by the breakpoint
246 * instruction. To avoid the SMP problems that can occur when we
247 * temporarily put back the original opcode to single-step, we
248 * single-stepped a copy of the instruction. The address of this
249 * copy is p->ainsn.insn.
250 *
251 * This function prepares to return from the post-single-step
252 * breakpoint trap.
253 */
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800254static void __kprobes resume_execution(struct kprobe *p,
255 struct pt_regs *regs, struct kprobe_ctlblk *kcb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256{
257 u32 insn = p->ainsn.insn[0];
258
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800259 regs->tpc = kcb->kprobe_orig_tnpc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 regs->tnpc = relbranch_fixup(insn,
261 (unsigned long) p->addr,
262 (unsigned long) &p->ainsn.insn[0],
263 regs->tnpc);
264 retpc_fixup(regs, insn, (unsigned long) p->addr);
265
266 regs->tstate = ((regs->tstate & ~TSTATE_PIL) |
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800267 kcb->kprobe_orig_tstate_pil);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268}
269
270static inline int post_kprobe_handler(struct pt_regs *regs)
271{
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800272 struct kprobe *cur = kprobe_running();
273 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
274
275 if (!cur)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 return 0;
277
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800278 if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
279 kcb->kprobe_status = KPROBE_HIT_SSDONE;
280 cur->post_handler(cur, regs, 0);
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700281 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800283 resume_execution(cur, regs, kcb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700285 /*Restore back the original saved kprobes variables and continue. */
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800286 if (kcb->kprobe_status == KPROBE_REENTER) {
287 restore_previous_kprobe(kcb);
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700288 goto out;
289 }
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800290 reset_current_kprobe();
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700291out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 preempt_enable_no_resched();
293
294 return 1;
295}
296
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
298{
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800299 struct kprobe *cur = kprobe_running();
300 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
301
302 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 return 1;
304
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800305 if (kcb->kprobe_status & KPROBE_HIT_SS) {
306 resume_execution(cur, regs, kcb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800308 reset_current_kprobe();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 preempt_enable_no_resched();
310 }
311 return 0;
312}
313
314/*
315 * Wrapper routine to for handling exceptions.
316 */
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700317int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
318 unsigned long val, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319{
320 struct die_args *args = (struct die_args *)data;
Ananth N Mavinakayanahalli66ff2d02005-11-07 01:00:07 -0800321 int ret = NOTIFY_DONE;
322
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 switch (val) {
324 case DIE_DEBUG:
325 if (kprobe_handler(args->regs))
Ananth N Mavinakayanahalli66ff2d02005-11-07 01:00:07 -0800326 ret = NOTIFY_STOP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 break;
328 case DIE_DEBUG_2:
329 if (post_kprobe_handler(args->regs))
Ananth N Mavinakayanahalli66ff2d02005-11-07 01:00:07 -0800330 ret = NOTIFY_STOP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 break;
332 case DIE_GPF:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 case DIE_PAGE_FAULT:
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800334 /* kprobe_running() needs smp_processor_id() */
335 preempt_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 if (kprobe_running() &&
337 kprobe_fault_handler(args->regs, args->trapnr))
Ananth N Mavinakayanahalli66ff2d02005-11-07 01:00:07 -0800338 ret = NOTIFY_STOP;
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800339 preempt_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 break;
341 default:
342 break;
343 }
Ananth N Mavinakayanahalli66ff2d02005-11-07 01:00:07 -0800344 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345}
346
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700347asmlinkage void __kprobes kprobe_trap(unsigned long trap_level,
348 struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349{
350 BUG_ON(trap_level != 0x170 && trap_level != 0x171);
351
352 if (user_mode(regs)) {
353 local_irq_enable();
354 bad_trap(regs, trap_level);
355 return;
356 }
357
358 /* trap_level == 0x170 --> ta 0x70
359 * trap_level == 0x171 --> ta 0x71
360 */
361 if (notify_die((trap_level == 0x170) ? DIE_DEBUG : DIE_DEBUG_2,
362 (trap_level == 0x170) ? "debug" : "debug_2",
363 regs, 0, trap_level, SIGTRAP) != NOTIFY_STOP)
364 bad_trap(regs, trap_level);
365}
366
367/* Jprobes support. */
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700368int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369{
370 struct jprobe *jp = container_of(p, struct jprobe, kp);
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800371 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800373 kcb->jprobe_saved_regs_location = regs;
374 memcpy(&(kcb->jprobe_saved_regs), regs, sizeof(*regs));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375
376 /* Save a whole stack frame, this gets arguments
377 * pushed onto the stack after using up all the
378 * arg registers.
379 */
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800380 memcpy(&(kcb->jprobe_saved_stack),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 (char *) (regs->u_regs[UREG_FP] + STACK_BIAS),
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800382 sizeof(kcb->jprobe_saved_stack));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383
384 regs->tpc = (unsigned long) jp->entry;
385 regs->tnpc = ((unsigned long) jp->entry) + 0x4UL;
386 regs->tstate |= TSTATE_PIL;
387
388 return 1;
389}
390
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700391void __kprobes jprobe_return(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 __asm__ __volatile__(
394 ".globl jprobe_return_trap_instruction\n"
395"jprobe_return_trap_instruction:\n\t"
396 "ta 0x70");
397}
398
399extern void jprobe_return_trap_instruction(void);
400
401extern void __show_regs(struct pt_regs * regs);
402
Prasanna S Panchamukhi05e14cb2005-09-06 15:19:30 -0700403int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404{
405 u32 *addr = (u32 *) regs->tpc;
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800406 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407
408 if (addr == (u32 *) jprobe_return_trap_instruction) {
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800409 if (kcb->jprobe_saved_regs_location != regs) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 printk("JPROBE: Current regs (%p) does not match "
411 "saved regs (%p).\n",
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800412 regs, kcb->jprobe_saved_regs_location);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 printk("JPROBE: Saved registers\n");
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800414 __show_regs(kcb->jprobe_saved_regs_location);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 printk("JPROBE: Current registers\n");
416 __show_regs(regs);
417 BUG();
418 }
419 /* Restore old register state. Do pt_regs
420 * first so that UREG_FP is the original one for
421 * the stack frame restore.
422 */
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800423 memcpy(regs, &(kcb->jprobe_saved_regs), sizeof(*regs));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424
425 memcpy((char *) (regs->u_regs[UREG_FP] + STACK_BIAS),
Ananth N Mavinakayanahallif215d982005-11-07 01:00:11 -0800426 &(kcb->jprobe_saved_stack),
427 sizeof(kcb->jprobe_saved_stack));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800429 preempt_enable_no_resched();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 return 1;
431 }
432 return 0;
433}
Prasanna S Panchamukhie539c232005-06-23 00:09:39 -0700434
Rusty Lynch67729262005-07-05 18:54:50 -0700435/* architecture specific initialization */
436int arch_init_kprobes(void)
437{
438 return 0;
439}