public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] ARM: kprobes: Fix jprobe registration on Thumb kernels
@ 2011-08-27 11:12 Tixy
  2011-08-29 10:07 ` Thumb symbol lookup. Was " Tixy
  0 siblings, 1 reply; 2+ messages in thread
From: Tixy @ 2011-08-27 11:12 UTC (permalink / raw)
  To: linux-arm-kernel

From: Jon Medhurst <tixy@yxit.co.uk>

When jprobes are registered, the generic kprobes code verifies that the
address given for the probe's handler corresponds to a symbol in the
kernel. For thumb kernels, this address has bit zero set to indicate its
thumb-ness and so is rejected as being offset by one byte from the
symbol address.

Fortunately, on some architectures, the jprobes handler is specified
using a struct rather than a plain function pointer; so a mechanism is
provided for arch code to define a translation function called
arch_deref_entry_point(). We can use this on Thumb kernels to remove bit
zero of the handler address and fix our problem.

Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
---
 arch/arm/kernel/kprobes.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/kernel/kprobes.c b/arch/arm/kernel/kprobes.c
index 129c116..9c88bcd 100644
--- a/arch/arm/kernel/kprobes.c
+++ b/arch/arm/kernel/kprobes.c
@@ -497,6 +497,14 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
 	regs->ARM_lr = (unsigned long)&kretprobe_trampoline;
 }
 
+#ifdef CONFIG_THUMB2_KERNEL
+unsigned long arch_deref_entry_point(void *entry)
+{
+	/* Remove any thumb flag from the function pointer. */
+	return (unsigned long)entry & ~1lu;
+}
+#endif
+
 int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
 {
 	struct jprobe *jp = container_of(p, struct jprobe, kp);
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-29 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-27 11:12 [PATCH] ARM: kprobes: Fix jprobe registration on Thumb kernels Tixy
2011-08-29 10:07 ` Thumb symbol lookup. Was " Tixy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox