Re: [PATCH v5 07/16] ARM: Remove use of struct kprobe from generic probes code
On 02/03/14 09:57, Jon Medhurst (Tixy) wrote: On Thu, 2014-01-23 at 15:05 -0500, David Long wrote: From: "David A. Long" Change the generic ARM probes code to pass in the opcode and architecture-specific structure separately instead of using struct kprobe, so we do not pollute code being used only for uprobes or other non-kprobes instruction interpretation. Signed-off-by: David A. Long --- One minor nit-pick... [...] diff --git a/arch/arm/kernel/kprobes-thumb.c b/arch/arm/kernel/kprobes-thumb.c index c7ee290..cea707a 100644 --- a/arch/arm/kernel/kprobes-thumb.c +++ b/arch/arm/kernel/kprobes-thumb.c [...] @@ -593,7 +590,7 @@ t16_emulate_pop_pc(struct kprobe *p, struct pt_regs *regs) bx_write_pc(pc, regs); } -static enum kprobe_insn __kprobes +enum kprobe_insn __kprobes t16_decode_pop(kprobe_opcode_t insn, struct arch_specific_insn *asi, struct decode_header *d) { The above removal of 'static' appears to be an unneeded accidental change? Yes, that got lost during editing. The change has been made. -dl -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v5 07/16] ARM: Remove use of struct kprobe from generic probes code
On Thu, 2014-01-23 at 15:05 -0500, David Long wrote: > From: "David A. Long" > > Change the generic ARM probes code to pass in the opcode and > architecture-specific > structure separately instead of using struct kprobe, so we do not pollute > code being used only for uprobes or other non-kprobes instruction > interpretation. > > Signed-off-by: David A. Long > --- One minor nit-pick... [...] > diff --git a/arch/arm/kernel/kprobes-thumb.c b/arch/arm/kernel/kprobes-thumb.c > index c7ee290..cea707a 100644 > --- a/arch/arm/kernel/kprobes-thumb.c > +++ b/arch/arm/kernel/kprobes-thumb.c [...] > @@ -593,7 +590,7 @@ t16_emulate_pop_pc(struct kprobe *p, struct pt_regs *regs) > bx_write_pc(pc, regs); > } > > -static enum kprobe_insn __kprobes > +enum kprobe_insn __kprobes > t16_decode_pop(kprobe_opcode_t insn, struct arch_specific_insn *asi, > struct decode_header *d) > { The above removal of 'static' appears to be an unneeded accidental change? -- Tixy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v5 07/16] ARM: Remove use of struct kprobe from generic probes code
On Thu, 2014-01-23 at 15:05 -0500, David Long wrote: From: David A. Long dave.l...@linaro.org Change the generic ARM probes code to pass in the opcode and architecture-specific structure separately instead of using struct kprobe, so we do not pollute code being used only for uprobes or other non-kprobes instruction interpretation. Signed-off-by: David A. Long dave.l...@linaro.org --- One minor nit-pick... [...] diff --git a/arch/arm/kernel/kprobes-thumb.c b/arch/arm/kernel/kprobes-thumb.c index c7ee290..cea707a 100644 --- a/arch/arm/kernel/kprobes-thumb.c +++ b/arch/arm/kernel/kprobes-thumb.c [...] @@ -593,7 +590,7 @@ t16_emulate_pop_pc(struct kprobe *p, struct pt_regs *regs) bx_write_pc(pc, regs); } -static enum kprobe_insn __kprobes +enum kprobe_insn __kprobes t16_decode_pop(kprobe_opcode_t insn, struct arch_specific_insn *asi, struct decode_header *d) { The above removal of 'static' appears to be an unneeded accidental change? -- Tixy -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v5 07/16] ARM: Remove use of struct kprobe from generic probes code
On 02/03/14 09:57, Jon Medhurst (Tixy) wrote: On Thu, 2014-01-23 at 15:05 -0500, David Long wrote: From: David A. Long dave.l...@linaro.org Change the generic ARM probes code to pass in the opcode and architecture-specific structure separately instead of using struct kprobe, so we do not pollute code being used only for uprobes or other non-kprobes instruction interpretation. Signed-off-by: David A. Long dave.l...@linaro.org --- One minor nit-pick... [...] diff --git a/arch/arm/kernel/kprobes-thumb.c b/arch/arm/kernel/kprobes-thumb.c index c7ee290..cea707a 100644 --- a/arch/arm/kernel/kprobes-thumb.c +++ b/arch/arm/kernel/kprobes-thumb.c [...] @@ -593,7 +590,7 @@ t16_emulate_pop_pc(struct kprobe *p, struct pt_regs *regs) bx_write_pc(pc, regs); } -static enum kprobe_insn __kprobes +enum kprobe_insn __kprobes t16_decode_pop(kprobe_opcode_t insn, struct arch_specific_insn *asi, struct decode_header *d) { The above removal of 'static' appears to be an unneeded accidental change? Yes, that got lost during editing. The change has been made. -dl -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5 07/16] ARM: Remove use of struct kprobe from generic probes code
From: "David A. Long" Change the generic ARM probes code to pass in the opcode and architecture-specific structure separately instead of using struct kprobe, so we do not pollute code being used only for uprobes or other non-kprobes instruction interpretation. Signed-off-by: David A. Long --- arch/arm/include/asm/probes.h| 9 +- arch/arm/kernel/kprobes-arm.c| 61 +++--- arch/arm/kernel/kprobes-common.c | 40 + arch/arm/kernel/kprobes-thumb.c | 177 +++ arch/arm/kernel/kprobes.c| 2 +- arch/arm/kernel/probes-arm.c | 33 arch/arm/kernel/probes-arm.h | 15 ++-- arch/arm/kernel/probes-thumb.c | 15 ++-- arch/arm/kernel/probes.c | 14 ++-- arch/arm/kernel/probes.h | 8 +- 10 files changed, 202 insertions(+), 172 deletions(-) diff --git a/arch/arm/include/asm/probes.h b/arch/arm/include/asm/probes.h index 737a9b3..4d014c4 100644 --- a/arch/arm/include/asm/probes.h +++ b/arch/arm/include/asm/probes.h @@ -21,9 +21,14 @@ struct kprobe; -typedef void (kprobe_insn_handler_t)(struct kprobe *, struct pt_regs *); +struct arch_specific_insn; +typedef void (kprobe_insn_handler_t)(kprobe_opcode_t, +struct arch_specific_insn *, +struct pt_regs *); typedef unsigned long (kprobe_check_cc)(unsigned long); -typedef void (kprobe_insn_singlestep_t)(struct kprobe *, struct pt_regs *); +typedef void (kprobe_insn_singlestep_t)(kprobe_opcode_t, + struct arch_specific_insn *, + struct pt_regs *); typedef void (kprobe_insn_fn_t)(void); /* Architecture specific copy of original instruction. */ diff --git a/arch/arm/kernel/kprobes-arm.c b/arch/arm/kernel/kprobes-arm.c index 72ee2a9..d62bbdf 100644 --- a/arch/arm/kernel/kprobes-arm.c +++ b/arch/arm/kernel/kprobes-arm.c @@ -72,12 +72,11 @@ "movpc, "reg" \n\t" #endif - static void __kprobes -emulate_ldrdstrd(struct kprobe *p, struct pt_regs *regs) +emulate_ldrdstrd(kprobe_opcode_t insn, + struct arch_specific_insn *asi, struct pt_regs *regs) { - kprobe_opcode_t insn = p->opcode; - unsigned long pc = (unsigned long)p->addr + 8; + unsigned long pc = regs->ARM_pc + 4; int rt = (insn >> 12) & 0xf; int rn = (insn >> 16) & 0xf; int rm = insn & 0xf; @@ -92,7 +91,7 @@ emulate_ldrdstrd(struct kprobe *p, struct pt_regs *regs) BLX("%[fn]") : "=r" (rtv), "=r" (rt2v), "=r" (rnv) : "0" (rtv), "1" (rt2v), "2" (rnv), "r" (rmv), - [fn] "r" (p->ainsn.insn_fn) + [fn] "r" (asi->insn_fn) : "lr", "memory", "cc" ); @@ -103,10 +102,10 @@ emulate_ldrdstrd(struct kprobe *p, struct pt_regs *regs) } static void __kprobes -emulate_ldr(struct kprobe *p, struct pt_regs *regs) +emulate_ldr(kprobe_opcode_t insn, + struct arch_specific_insn *asi, struct pt_regs *regs) { - kprobe_opcode_t insn = p->opcode; - unsigned long pc = (unsigned long)p->addr + 8; + unsigned long pc = regs->ARM_pc + 4; int rt = (insn >> 12) & 0xf; int rn = (insn >> 16) & 0xf; int rm = insn & 0xf; @@ -119,7 +118,7 @@ emulate_ldr(struct kprobe *p, struct pt_regs *regs) __asm__ __volatile__ ( BLX("%[fn]") : "=r" (rtv), "=r" (rnv) - : "1" (rnv), "r" (rmv), [fn] "r" (p->ainsn.insn_fn) + : "1" (rnv), "r" (rmv), [fn] "r" (asi->insn_fn) : "lr", "memory", "cc" ); @@ -133,11 +132,11 @@ emulate_ldr(struct kprobe *p, struct pt_regs *regs) } static void __kprobes -emulate_str(struct kprobe *p, struct pt_regs *regs) +emulate_str(kprobe_opcode_t insn, + struct arch_specific_insn *asi, struct pt_regs *regs) { - kprobe_opcode_t insn = p->opcode; - unsigned long rtpc = (unsigned long)p->addr + str_pc_offset; - unsigned long rnpc = (unsigned long)p->addr + 8; + unsigned long rtpc = regs->ARM_pc - 4 + str_pc_offset; + unsigned long rnpc = regs->ARM_pc + 4; int rt = (insn >> 12) & 0xf; int rn = (insn >> 16) & 0xf; int rm = insn & 0xf; @@ -151,7 +150,7 @@ emulate_str(struct kprobe *p, struct pt_regs *regs) __asm__ __volatile__ ( BLX("%[fn]") : "=r" (rnv) - : "r" (rtv), "0" (rnv), "r" (rmv), [fn] "r" (p->ainsn.insn_fn) + : "r" (rtv), "0" (rnv), "r" (rmv), [fn] "r" (asi->insn_fn) : "lr", "memory", "cc" ); @@ -160,10 +159,10 @@ emulate_str(struct kprobe *p, struct pt_regs *regs) } static void __kprobes -emulate_rd12rn16rm0rs8_rwflags(struct kprobe *p, struct pt_regs *regs) +emulate_rd12rn16rm0rs8_rwflags(kprobe_opcode_t insn, + struct arch_specific_insn *asi, struct pt_regs *regs) { -
[PATCH v5 07/16] ARM: Remove use of struct kprobe from generic probes code
From: David A. Long dave.l...@linaro.org Change the generic ARM probes code to pass in the opcode and architecture-specific structure separately instead of using struct kprobe, so we do not pollute code being used only for uprobes or other non-kprobes instruction interpretation. Signed-off-by: David A. Long dave.l...@linaro.org --- arch/arm/include/asm/probes.h| 9 +- arch/arm/kernel/kprobes-arm.c| 61 +++--- arch/arm/kernel/kprobes-common.c | 40 + arch/arm/kernel/kprobes-thumb.c | 177 +++ arch/arm/kernel/kprobes.c| 2 +- arch/arm/kernel/probes-arm.c | 33 arch/arm/kernel/probes-arm.h | 15 ++-- arch/arm/kernel/probes-thumb.c | 15 ++-- arch/arm/kernel/probes.c | 14 ++-- arch/arm/kernel/probes.h | 8 +- 10 files changed, 202 insertions(+), 172 deletions(-) diff --git a/arch/arm/include/asm/probes.h b/arch/arm/include/asm/probes.h index 737a9b3..4d014c4 100644 --- a/arch/arm/include/asm/probes.h +++ b/arch/arm/include/asm/probes.h @@ -21,9 +21,14 @@ struct kprobe; -typedef void (kprobe_insn_handler_t)(struct kprobe *, struct pt_regs *); +struct arch_specific_insn; +typedef void (kprobe_insn_handler_t)(kprobe_opcode_t, +struct arch_specific_insn *, +struct pt_regs *); typedef unsigned long (kprobe_check_cc)(unsigned long); -typedef void (kprobe_insn_singlestep_t)(struct kprobe *, struct pt_regs *); +typedef void (kprobe_insn_singlestep_t)(kprobe_opcode_t, + struct arch_specific_insn *, + struct pt_regs *); typedef void (kprobe_insn_fn_t)(void); /* Architecture specific copy of original instruction. */ diff --git a/arch/arm/kernel/kprobes-arm.c b/arch/arm/kernel/kprobes-arm.c index 72ee2a9..d62bbdf 100644 --- a/arch/arm/kernel/kprobes-arm.c +++ b/arch/arm/kernel/kprobes-arm.c @@ -72,12 +72,11 @@ movpc, reg \n\t #endif - static void __kprobes -emulate_ldrdstrd(struct kprobe *p, struct pt_regs *regs) +emulate_ldrdstrd(kprobe_opcode_t insn, + struct arch_specific_insn *asi, struct pt_regs *regs) { - kprobe_opcode_t insn = p-opcode; - unsigned long pc = (unsigned long)p-addr + 8; + unsigned long pc = regs-ARM_pc + 4; int rt = (insn 12) 0xf; int rn = (insn 16) 0xf; int rm = insn 0xf; @@ -92,7 +91,7 @@ emulate_ldrdstrd(struct kprobe *p, struct pt_regs *regs) BLX(%[fn]) : =r (rtv), =r (rt2v), =r (rnv) : 0 (rtv), 1 (rt2v), 2 (rnv), r (rmv), - [fn] r (p-ainsn.insn_fn) + [fn] r (asi-insn_fn) : lr, memory, cc ); @@ -103,10 +102,10 @@ emulate_ldrdstrd(struct kprobe *p, struct pt_regs *regs) } static void __kprobes -emulate_ldr(struct kprobe *p, struct pt_regs *regs) +emulate_ldr(kprobe_opcode_t insn, + struct arch_specific_insn *asi, struct pt_regs *regs) { - kprobe_opcode_t insn = p-opcode; - unsigned long pc = (unsigned long)p-addr + 8; + unsigned long pc = regs-ARM_pc + 4; int rt = (insn 12) 0xf; int rn = (insn 16) 0xf; int rm = insn 0xf; @@ -119,7 +118,7 @@ emulate_ldr(struct kprobe *p, struct pt_regs *regs) __asm__ __volatile__ ( BLX(%[fn]) : =r (rtv), =r (rnv) - : 1 (rnv), r (rmv), [fn] r (p-ainsn.insn_fn) + : 1 (rnv), r (rmv), [fn] r (asi-insn_fn) : lr, memory, cc ); @@ -133,11 +132,11 @@ emulate_ldr(struct kprobe *p, struct pt_regs *regs) } static void __kprobes -emulate_str(struct kprobe *p, struct pt_regs *regs) +emulate_str(kprobe_opcode_t insn, + struct arch_specific_insn *asi, struct pt_regs *regs) { - kprobe_opcode_t insn = p-opcode; - unsigned long rtpc = (unsigned long)p-addr + str_pc_offset; - unsigned long rnpc = (unsigned long)p-addr + 8; + unsigned long rtpc = regs-ARM_pc - 4 + str_pc_offset; + unsigned long rnpc = regs-ARM_pc + 4; int rt = (insn 12) 0xf; int rn = (insn 16) 0xf; int rm = insn 0xf; @@ -151,7 +150,7 @@ emulate_str(struct kprobe *p, struct pt_regs *regs) __asm__ __volatile__ ( BLX(%[fn]) : =r (rnv) - : r (rtv), 0 (rnv), r (rmv), [fn] r (p-ainsn.insn_fn) + : r (rtv), 0 (rnv), r (rmv), [fn] r (asi-insn_fn) : lr, memory, cc ); @@ -160,10 +159,10 @@ emulate_str(struct kprobe *p, struct pt_regs *regs) } static void __kprobes -emulate_rd12rn16rm0rs8_rwflags(struct kprobe *p, struct pt_regs *regs) +emulate_rd12rn16rm0rs8_rwflags(kprobe_opcode_t insn, + struct arch_specific_insn *asi, struct pt_regs *regs) { - kprobe_opcode_t insn = p-opcode; - unsigned long pc = (unsigned long)p-addr + 8; +