[POWERPC] Fix handling of stfiwx math emulation
authorKumar Gala <galak@kernel.crashing.org>
Thu, 11 Oct 2007 22:07:34 +0000 (17:07 -0500)
committerKumar Gala <galak@kernel.crashing.org>
Tue, 16 Oct 2007 14:05:24 +0000 (09:05 -0500)
Its legal for the stfiwx instruction to have RA = 0 as part of its
effective address calculation.  This is illegal for all other XE
form instructions.

Add code to compute the proper effective address for stfiwx if
RA = 0 rather than treating it as illegal.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/math-emu/math.c

index 69058b2873de8d6dfd76cb9b46736cd289d2c701..381306bb1590ec62e198ebf16efbb024208c7273 100644 (file)
@@ -407,11 +407,16 @@ do_mathemu(struct pt_regs *regs)
 
        case XE:
                idx = (insn >> 16) & 0x1f;
-               if (!idx)
-                       goto illegal;
-
                op0 = (void *)&current->thread.fpr[(insn >> 21) & 0x1f];
-               op1 = (void *)(regs->gpr[idx] + regs->gpr[(insn >> 11) & 0x1f]);
+               if (!idx) {
+                       if (((insn >> 1) & 0x3ff) == STFIWX)
+                               op1 = (void *)(regs->gpr[(insn >> 11) & 0x1f]);
+                       else
+                               goto illegal;
+               } else {
+                       op1 = (void *)(regs->gpr[idx] + regs->gpr[(insn >> 11) & 0x1f]);
+               }
+
                break;
 
        case XEU: