[PATCH 3/4] ARM: kprobes: Make ARM instruction emulation work on Thumb-2 kernels

Nicolas Pitre nicolas.pitre at linaro.org
Mon Mar 21 19:58:44 UTC 2011


On Mon, 21 Mar 2011, Tixy wrote:

> From: Jon Medhurst <tixy at 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 at 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.

> +		".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

> +#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.


Nicolas



More information about the linaro-kernel mailing list