aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/kernel/kprobes.c
diff options
context:
space:
mode:
authorAnil S Keshavamurthy <anil.s.keshavamurthy@intel.com>2005-06-23 03:09:34 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-23 12:45:24 -0400
commit708de8f11c2901cc49fd7725baf4a0fbd7264e73 (patch)
treea78c45c153c6414908104547292c177bcf309908 /arch/ia64/kernel/kprobes.c
parent1674eafcbd3e3c68556cf19fbf4a2c30f7add729 (diff)
[PATCH] Kprobes IA64: safe register kprobe
The current kprobes does not yet handle register kprobes on some of the following kind of instruction which needs to be emulated in a special way. 1) mov r1=ip 2) chk -- Speculation check instruction This patch attempts to fail register_kprobes() when user tries to insert kprobes on the above kind of instruction. Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/ia64/kernel/kprobes.c')
-rw-r--r--arch/ia64/kernel/kprobes.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 51bc08bd0466..027d656664d2 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -121,6 +121,48 @@ static void update_kprobe_inst_flag(uint template, uint slot, uint major_opcode
121 121
122/* 122/*
123 * In this function we check to see if the instruction 123 * In this function we check to see if the instruction
124 * on which we are inserting kprobe is supported.
125 * Returns 0 if supported
126 * Returns -EINVAL if unsupported
127 */
128static int unsupported_inst(uint template, uint slot, uint major_opcode,
129 unsigned long kprobe_inst, struct kprobe *p)
130{
131 unsigned long addr = (unsigned long)p->addr;
132
133 if (bundle_encoding[template][slot] == I) {
134 switch (major_opcode) {
135 case 0x0: //I_UNIT_MISC_OPCODE:
136 /*
137 * Check for Integer speculation instruction
138 * - Bit 33-35 to be equal to 0x1
139 */
140 if (((kprobe_inst >> 33) & 0x7) == 1) {
141 printk(KERN_WARNING
142 "Kprobes on speculation inst at <0x%lx> not supported\n",
143 addr);
144 return -EINVAL;
145 }
146
147 /*
148 * IP relative mov instruction
149 * - Bit 27-35 to be equal to 0x30
150 */
151 if (((kprobe_inst >> 27) & 0x1FF) == 0x30) {
152 printk(KERN_WARNING
153 "Kprobes on \"mov r1=ip\" at <0x%lx> not supported\n",
154 addr);
155 return -EINVAL;
156
157 }
158 }
159 }
160 return 0;
161}
162
163
164/*
165 * In this function we check to see if the instruction
124 * (qp) cmpx.crel.ctype p1,p2=r2,r3 166 * (qp) cmpx.crel.ctype p1,p2=r2,r3
125 * on which we are inserting kprobe is cmp instruction 167 * on which we are inserting kprobe is cmp instruction
126 * with ctype as unc. 168 * with ctype as unc.
@@ -254,6 +296,9 @@ int arch_prepare_kprobe(struct kprobe *p)
254 /* Get kprobe_inst and major_opcode from the bundle */ 296 /* Get kprobe_inst and major_opcode from the bundle */
255 get_kprobe_inst(bundle, slot, &kprobe_inst, &major_opcode); 297 get_kprobe_inst(bundle, slot, &kprobe_inst, &major_opcode);
256 298
299 if (unsupported_inst(template, slot, major_opcode, kprobe_inst, p))
300 return -EINVAL;
301
257 prepare_break_inst(template, slot, major_opcode, kprobe_inst, p); 302 prepare_break_inst(template, slot, major_opcode, kprobe_inst, p);
258 303
259 return 0; 304 return 0;