Skip to contentSkip to conversation

Emulation of unaligned LDXC1/SDXC1 instructions

PATCH In review Aurelien Jarno 2 participants 3 messages Apr 21, 2016 MIPS

lore
Share & tools
lore
#0 lore raw

Hi all,

Debian recently got access to Cavium III machines which have an FPU, before we were using Cavium II machines with the kernel FPU emulation.

It appears some code (at least openjdk and lcms2, probably more) use the LDXC1 and SDXC1 instructions with word aligned addresses instead of double-word aligned addresses as required by the specification. This causes a SIGILL. The kernel emulation is more relaxed and allow word aligned addresses.

First of all I am surprised to get a SIGILL in that case instead of a SIGBUS, and secondly I think the behavior with and without FPU should be consistent. The kernel currently emulates unaligned LDC1 and SDC1 instructions even with an FPU, so I wonder if the kernel should also emulate unaligned LDXC1 and SDXC1 instructions.

Any opinion?

Thanks,
Aurelien

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                 http://www.aurel32.net
#1 lore raw

PATCH 1/1 MIPS: Allow emulation for unaligned [LS]DXC1 instructions

If an address error exception occurs for a LDXC1 or SDXC1 instruction, within the cop1x opcode space, allow it to be passed through to the FPU emulator rather than resulting in a SIGILL. This causes LDXC1 & SDXC1 to be handled in a manner consistent with the more common LDC1 & SDC1 instructions.

Cc Aurelien Jarno <[email protected]>

---
Hi Aurelien,

Thanks for tracking that down. Does this simple patch fix your problem?

Thanks,
Paul

---
 arch/mips/kernel/unaligned.c | 1 +
 1 file changed, 1 insertion(+)
arch/mips/kernel/unaligned.c +1 -0
index 5c62065..28b3af7 100644
@@ -1191,6 +1191,7 @@ static void emulate_load_store_insn(struct pt_regs *regs,
 	case ldc1_op:
 	case swc1_op:
 	case sdc1_op:
+	case cop1x_op:
 		die_if_kernel("Unaligned FP access in kernel code", regs);
 		BUG_ON(!used_math());
 
Signature · 1 line
2.8.0
author Tested-by on v1 1/1
#2 lore raw

Re: [PATCH] MIPS: Allow emulation for unaligned [LS]DXC1 instructions

Quoted 6 lines · Paul Burton

If an address error exception occurs for a LDXC1 or SDXC1 instruction, within the cop1x opcode space, allow it to be passed through to the FPU emulator rather than resulting in a SIGILL. This causes LDXC1 & SDXC1 to be handled in a manner consistent with the more common LDC1 & SDC1 instructions.

Quoted 7 lines
Cc Aurelien Jarno <[email protected]>

---
Hi Aurelien,

Thanks for tracking that down. Does this simple patch fix your problem?

Thanks for the quick patch. I confirm this fixes the issue, so you can add a:

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                 http://www.aurel32.net