aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sparc64
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-12-10 05:42:03 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-10 05:42:03 -0500
commitf0882589666440d573f657cb3a1d5f66f3caa157 (patch)
treeb2c7d133a0c6140950e928e592cf1f3cf867d4d2 /include/asm-sparc64
parent2f149228bb30ea08bfde740178f832d5c9081005 (diff)
[SPARC64]: Fix several kprobes bugs.
- relbranch_fixup(), for non-branches, would end up setting regs->tnpc incorrectly, in fact it would set it equal to regs->tpc which would cause that instruction to execute twice Also, if this is not a PC-relative branch, we should just leave regs->tnpc as-is. This covers cases like 'jmpl' which branch to absolute values. - To be absolutely %100 safe, we need to flush the instruction cache for all assignments to kprobe->ainsn.insn[], including cases like add_aggr_kprobe() - prev_kprobe's status field needs to be 'unsigned long' to match the type of the value it is saving - jprobes were totally broken: = jprobe_return() can run in the stack frame of the jprobe handler, or in an even deeper stack frame, thus we'll be in the wrong register window than the one from the original probe state. So unwind using 'restore' instructions, if necessary, right before we do the jprobe_return() breakpoint trap. = There is no reason to save/restore the register window saved at %sp at jprobe trigger time. Those registers cannot be modified by the jprobe handler. Also, this code was saving and restoring "sizeof (struct sparc_stackf)" bytes. Depending upon the caller, this could clobber unrelated stack frame pieces if there is only a basic 128-byte register window stored on the stack, without the argument save area. So just saving and restoring struct pt_regs is sufficient. = Kill the "jprobe_saved_esp", totally unused. Also, delete "jprobe_saved_regs_location", with the stack frame unwind now done explicitly by jprobe_return(), this check is superfluous. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/asm-sparc64')
-rw-r--r--include/asm-sparc64/kprobes.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/include/asm-sparc64/kprobes.h b/include/asm-sparc64/kprobes.h
index c9f5c34d318c..becc38fa06c5 100644
--- a/include/asm-sparc64/kprobes.h
+++ b/include/asm-sparc64/kprobes.h
@@ -13,7 +13,11 @@ typedef u32 kprobe_opcode_t;
13#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry 13#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry
14#define arch_remove_kprobe(p) do {} while (0) 14#define arch_remove_kprobe(p) do {} while (0)
15#define ARCH_INACTIVE_KPROBE_COUNT 0 15#define ARCH_INACTIVE_KPROBE_COUNT 0
16#define flush_insn_slot(p) do { } while (0) 16
17#define flush_insn_slot(p) \
18do { flushi(&(p)->ainsn.insn[0]); \
19 flushi(&(p)->ainsn.insn[1]); \
20} while (0)
17 21
18/* Architecture specific copy of original instruction*/ 22/* Architecture specific copy of original instruction*/
19struct arch_specific_insn { 23struct arch_specific_insn {
@@ -23,7 +27,7 @@ struct arch_specific_insn {
23 27
24struct prev_kprobe { 28struct prev_kprobe {
25 struct kprobe *kp; 29 struct kprobe *kp;
26 unsigned int status; 30 unsigned long status;
27 unsigned long orig_tnpc; 31 unsigned long orig_tnpc;
28 unsigned long orig_tstate_pil; 32 unsigned long orig_tstate_pil;
29}; 33};
@@ -33,10 +37,7 @@ struct kprobe_ctlblk {
33 unsigned long kprobe_status; 37 unsigned long kprobe_status;
34 unsigned long kprobe_orig_tnpc; 38 unsigned long kprobe_orig_tnpc;
35 unsigned long kprobe_orig_tstate_pil; 39 unsigned long kprobe_orig_tstate_pil;
36 long *jprobe_saved_esp;
37 struct pt_regs jprobe_saved_regs; 40 struct pt_regs jprobe_saved_regs;
38 struct pt_regs *jprobe_saved_regs_location;
39 struct sparc_stackf jprobe_saved_stack;
40 struct prev_kprobe prev_kprobe; 41 struct prev_kprobe prev_kprobe;
41}; 42};
42 43