Skip to contentSkip to conversation

ARM: PJ4: make coprocessor access sequences buildable in Thumb2 mode

PATCH Superseded Ard Biesheuvel 2 participants 3 messages Dec 22, 2015 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ARM: PJ4: make coprocessor access sequences buildable in Thumb2 mode

The PJ4 inline asm sequence to write to cp15 cannot be built in Thumb-2 mode, due to the way it performs arithmetic on the program counter, so it is built in ARM mode instead. However, building C files in ARM mode under CONFIG_THUMB2_KERNEL is problematic, since the instrumentation performed by subsystems like ftrace does not expect having to deal with interworking branches.

Since the sequence in question is simply a poor man's ISB instruction, let's use a straight 'isb' instead when building in Thumb2 mode. Thumb2 implies V7, so 'isb' should always be supported in that case.

---
 arch/arm/kernel/Makefile  | 1 -
 arch/arm/kernel/pj4-cp0.c | 4 ++++
 2 files changed, 4 insertions(+), 1 deletion(-)
arch/arm/kernel/Makefile +0 -1
index af9e59bf3831..3c789496297f 100644
@@ -73,7 +73,6 @@ obj-$(CONFIG_IWMMXT)		+= iwmmxt.o
 obj-$(CONFIG_PERF_EVENTS)	+= perf_regs.o perf_callchain.o
 obj-$(CONFIG_HW_PERF_EVENTS)	+= perf_event_xscale.o perf_event_v6.o \
 				   perf_event_v7.o
-CFLAGS_pj4-cp0.o		:= -marm
 AFLAGS_iwmmxt.o			:= -Wa,-mcpu=iwmmxt
 obj-$(CONFIG_ARM_CPU_TOPOLOGY)  += topology.o
 obj-$(CONFIG_VDSO)		+= vdso.o
arch/arm/kernel/pj4-cp0.c +4 -0
index 8153e36b2491..7c9248b74d3f 100644
@@ -66,9 +66,13 @@ static void __init pj4_cp_access_write(u32 value)
 
 	__asm__ __volatile__ (
 		"mcr	p15, 0, %1, c1, c0, 2\n\t"
+#ifdef CONFIG_THUMB2_KERNEL
+		"isb\n\t"
+#else
 		"mrc	p15, 0, %0, c1, c0, 2\n\t"
 		"mov	%0, %0\n\t"
 		"sub	pc, pc, #4\n\t"
+#endif
 		: "=r" (temp) : "r" (value));
 }
 
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 1/1 ARM: PJ4: make coprocessor access sequences buildable in Thumb2 mode

Quoted 10 lines · Ard Biesheuvel

The PJ4 inline asm sequence to write to cp15 cannot be built in Thumb-2 mode, due to the way it performs arithmetic on the program counter, so it is built in ARM mode instead. However, building C files in ARM mode under CONFIG_THUMB2_KERNEL is problematic, since the instrumentation performed by subsystems like ftrace does not expect having to deal with interworking branches.

Since the sequence in question is simply a poor man's ISB instruction, let's use a straight 'isb' instead when building in Thumb2 mode. Thumb2 implies V7, so 'isb' should always be supported in that case.

I think, given how close Christmas is, and I suspect that the merge window will be opening shortly afterwards, it'll be better to drop the change and sort it out in the new year, rather than trying to rush this in, especially as we're already at the 3rd iteration of this supposedly simple change. It obviously isn't quite as simple as it looks.

Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#2 lore raw

PATCH v2 1/1 ARM: PJ4: make coprocessor access sequences buildable in Thumb2 mode

Quoted 12 lines · Russell King - ARM Linux
Quoted 10 lines · Ard Biesheuvel

The PJ4 inline asm sequence to write to cp15 cannot be built in Thumb-2 mode, due to the way it performs arithmetic on the program counter, so it is built in ARM mode instead. However, building C files in ARM mode under CONFIG_THUMB2_KERNEL is problematic, since the instrumentation performed by subsystems like ftrace does not expect having to deal with interworking branches.

Since the sequence in question is simply a poor man's ISB instruction, let's use a straight 'isb' instead when building in Thumb2 mode. Thumb2 implies V7, so 'isb' should always be supported in that case.

Quoted 7 lines

I think, given how close Christmas is, and I suspect that the merge window will be opening shortly afterwards, it'll be better to drop the change and sort it out in the new year, rather than trying to rush this in, especially as we're already at the 3rd iteration of this supposedly simple change. It obviously isn't quite as simple as it looks.

I agree. Please apply it whenever you feel it is appropriate to do so.

Apologies for the trouble