ARM: perf: modify kuser rmb() call to compile for Thumb-2
PATCH 1/1 ARM: perf: modify kuser rmb() call to compile for Thumb-2
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.
--- tools/perf/perf.h | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
tools/perf/perf.h +1 -3
@@ -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)()#define cpu_relax () asm volatile("":::"memory")#endif
Signature · 1 line
1.6.3.3
Quoted 24 lines · Will Deacon
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 <[email protected]>Cc Russell King - ARM Linux <[email protected]>Cc Jamie Iles <[email protected]>Cc Ingo Molnar <[email protected]>--- tools/perf/perf.h | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)tools/perf/perf.h +0
-0
tools/perf/perf.h line 68
Quoted 7 lines
tools/perf/perf.h +1
-3@@ -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
[tip:perf/pebs] perf, ARM: Modify kuser rmb() call to compile for Thumb-2
In reply to Will DeaconCommit-ID: da7196e1f986c846ffa8b2ec385223fad38e8518 Gitweb: http://git.kernel.org/tip/da7196e1f986c846ffa8b2ec385223fad38e8518 Author: Will Deacon <[email protected]> AuthorDate: Wed, 3 Mar 2010 11:47:58 +0000 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 4 Mar 2010 12:13:28 +0100
perf, ARM: Modify kuser rmb() call to compile for Thumb-2
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.
LKML-Reference: <[email protected]>
--- tools/perf/perf.h | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
tools/perf/perf.h +1 -3
@@ -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)()#define cpu_relax () asm volatile("":::"memory")#endif