Skip to contentSkip to conversation

ARM: asm: __und_usr_thumb need byteswap instructions in BE case

PATCH New Victor Kamensky 3 participants 4 messages Jan 13, 2014 – Jan 21, 2014 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: asm: __und_usr_thumb need byteswap instructions in BE case

__und_usr_thumb function deals with thumb2 opcodes. In case of BE image, it needs to byteswap half word thumb2 encoded instructions before further processing them.

Without this fix BE image user-land thread executing first VFP instruction encoded in thumb2 fails with SIGILL, because kernel does not recognize instruction and does not enable VFP.

---
 arch/arm/kernel/entry-armv.S | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/kernel/entry-armv.S +2 -0
index b3fb8c9..1879e8d 100644
@@ -451,9 +451,11 @@ __und_usr_thumb:
 	.arch	armv6t2
 #endif
 2:	ldrht	r5, [r4]
+ARM_BE8(rev16	r5, r5)				@ little endian instruction
 	cmp	r5, #0xe800			@ 32bit instruction if xx != 0
 	blo	__und_usr_fault_16		@ 16bit undefined instruction
 3:	ldrht	r0, [r2]
+ARM_BE8(rev16	r0, r0)				@ little endian instruction
 	add	r2, r2, #2			@ r2 is PC + 2, make it PC + 4
 	str	r2, [sp, #S_PC]			@ it's a 2x16bit instr, update
 	orr	r0, r0, r5, lsl #16
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/1 ARM: asm: __und_usr_thumb need byteswap instructions in BE case

Quoted 10 lines · Victor Kamensky

__und_usr_thumb function deals with thumb2 opcodes. In case of BE image, it needs to byteswap half word thumb2 encoded instructions before further processing them.

Without this fix BE image user-land thread executing first VFP instruction encoded in thumb2 fails with SIGILL, because kernel does not recognize instruction and does not enable VFP.

Good spot. This looks like the correct fix to me.

Quoted 28 lines
---
 arch/arm/kernel/entry-armv.S | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/kernel/entry-armv.S +2 -0
index b3fb8c9..1879e8d 100644
@@ -451,9 +451,11 @@ __und_usr_thumb:
 	.arch	armv6t2
 #endif
 2:	ldrht	r5, [r4]
+ARM_BE8(rev16	r5, r5)				@ little endian instruction
 	cmp	r5, #0xe800			@ 32bit instruction if xx != 0
 	blo	__und_usr_fault_16		@ 16bit undefined instruction
 3:	ldrht	r0, [r2]
+ARM_BE8(rev16	r0, r0)				@ little endian instruction
 	add	r2, r2, #2			@ r2 is PC + 2, make it PC + 4
 	str	r2, [sp, #S_PC]			@ it's a 2x16bit instr, update
 	orr	r0, r0, r5, lsl #16
Signature · 7 lines
1.8.1.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw

PATCH 1/1 ARM: asm: __und_usr_thumb need byteswap instructions in BE case

Quoted 9 lines · Dave Martin
Quoted 8 lines · Victor Kamensky

__und_usr_thumb function deals with thumb2 opcodes. In case of BE image, it needs to byteswap half word thumb2 encoded instructions before further processing them.

Without this fix BE image user-land thread executing first VFP instruction encoded in thumb2 fails with SIGILL, because kernel does not recognize instruction and does not enable VFP.

Quoted 6 lines
Quoted 2 lines

Good spot. This looks like the correct fix to me.

Can you please send this to the patch tracker? Feel free to add

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#3 lore raw

PATCH 1/1 ARM: asm: __und_usr_thumb need byteswap instructions in BE case

Quoted 12 lines · Stephen Boyd
Quoted 11 lines · Dave Martin
Quoted 10 lines · Victor Kamensky

__und_usr_thumb function deals with thumb2 opcodes. In case of BE image, it needs to byteswap half word thumb2 encoded instructions before further processing them.

Without this fix BE image user-land thread executing first VFP instruction encoded in thumb2 fails with SIGILL, because kernel does not recognize instruction and does not enable VFP.

Quoted 8 lines
Quoted 4 lines

Good spot. This looks like the correct fix to me.

Can you please send this to the patch tracker? Feel free to add

Thanks. It is done on both counts. Patch is submitted as [1].

Thanks,
Victor

[1] http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=7946/1

Quoted 4 lines

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation