On Mon, 2011-03-21 at 15:58 -0400, Nicolas Pitre wrote:
On Mon, 21 Mar 2011, Tixy wrote:
From: Jon Medhurst tixy@yxit.co.uk
On Thumb-2 kernels there may still be some kernel code using the ARM instruction set, so kprobes will need to support this. This patch fixes the ARM emulation code to built and work correctly when built as Thumb.
Signed-off-by: Jon Medhurst tixy@yxit.co.uk
[...]
@@ -108,8 +116,22 @@ static void __init find_str_pc_offset(void) int addr, scratch, ret; __asm__ ( +#ifdef CONFIG_THUMB2_KERNEL
/* Switch to ARM mode */
"adr %[scr], 1f \n\t"
"bx %[scr] \n\t"
A .align would be required here.
OK. I had assumed that the assembler would automatically align ARM instructions but I doesn't say that it the docs.
".arm \n\t"
"1: \n\t"
+#endif "sub %[ret], pc, #4 \n\t" "str pc, %[addr] \n\t" +#ifdef CONFIG_THUMB2_KERNEL
/* Switch back to Thumb mode */
"adr %[scr], 2f + 1 \n\t"
"bx %[scr] \n\t"
".thumb \n\t"
"2: \n\t"
Here you could simply use something like:
sub pc, pc, #3
Only on ARMv7, on ARMv6T2 it doesn't change state.
+#endif "ldr %[scr], %[addr] \n\t" "sub %[ret], %[scr], %[ret] \n\t" : [ret] "=r" (ret), [scr] "=r" (scratch), [addr] "+m" (addr));
Isn't the direct storage of pc architecturally defined with Thumb2 capable processors? If so this whole code could be omitted in that case.
Again, only on ARMv7, not ARMv6T2.
Does Linux support ARMv6T2? arch/arm/Kconfig has
config THUMB2_KERNEL depends on CPU_V7 && !CPU_V6 && !CPU_V6K && EXPERIMENTAL
so if there isn't any other CPU_V6x config option then THUMB2_KERNEL implies ARMv7.