Skip to contentSkip to conversation

ARM: perf: modify kuser rmb() call to compile for Thumb-2

PATCH In review Will Deacon 2 participants 3 messages Mar 3, 2010 – Mar 4, 2010 perf events

lore
Share & tools
lore
#0 lore raw

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.

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 +1 -3
index 75f941b..6fb379b 100644
@@ -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
#1 lore raw
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.

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
index 75f941b..6fb379b 100644

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

#2 lore raw

[tip:perf/pebs] perf, ARM: Modify kuser rmb() call to compile for Thumb-2

In reply to Will Deacon
Commit-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.

Cc Russell King - ARM Linux <[email protected]>
Cc Jamie Iles <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/perf.h |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
tools/perf/perf.h +1 -3
index 75f941b..6fb379b 100644
@@ -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