Re: [PATCH] ARM: perf: modify kuser rmb() call to compile forThumb-2

From: Jamie Iles
Date: Wed Mar 03 2010 - 06:55:35 EST


On Wed, Mar 03, 2010 at 11:47:58AM +0000, Will Deacon wrote:
> The Thumb-2 instruction set does not provide an encoding
> for sub pc, r0, #95 as present in the rmb() definition used
> by perf. This results in compilation failure when using a
> compiler targetting an instruction set other than ARM.
>
> This patch redefines rmb() for ARM by casting the address
> of the kuser helper to a function pointer, therefore getting
> the compiler to take care of making the call.
>
> Patch taken against tip/master.
>
> Signed-off-by: Will Deacon <will.deacon@xxxxxxx>
> Cc: Russell King - ARM Linux <linux@xxxxxxxxxxxxxxxx>
> Cc: Jamie Iles <jamie.iles@xxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxx>
> ---
> tools/perf/perf.h | 4 +---
> 1 files changed, 1 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index 75f941b..6fb379b 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -65,9 +65,7 @@
> * Use the __kuser_memory_barrier helper in the CPU helper page. See
> * arch/arm/kernel/entry-armv.S in the kernel source for details.
> */
> -#define rmb() asm volatile("mov r0, #0xffff0fff; mov lr, pc;" \
> - "sub pc, r0, #95" ::: "r0", "lr", "cc", \
> - "memory")
> +#define rmb() ((void(*)(void))0xffff0fa0)()
This will take care of doing the CPU barrier but don't we still need a
compiler memory barrier? I guess you could do:

#define rmb() ({ \
((void(*)(void))0xffff0fa0)(); \
asm volatile("" ::: "memory"); \
})

Jamie
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/