Skip to content

Commit cc7059b

Browse files
James Yangozbenh
authored andcommitted
powerpc/math-emu: Fix load/store indexed emulation
Load/store indexed instructions where the index register RA=R0, such as "lfdx f1,0,r3", are not illegal. Load/store indexed with update instructions where the index register RA=R0, such as "lfdux f1,0,r3", are invalid, and, to be consistent with existing math-emu behavior for other invalid instruction forms, will signal as illegal. Signed-off-by: James Yang <James.Yang@freescale.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
1 parent 5f20be4 commit cc7059b

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

‎arch/powerpc/math-emu/math.c‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -380,21 +380,16 @@ do_mathemu(struct pt_regs *regs)
380380
case XE:
381381
idx = (insn >> 16) & 0x1f;
382382
op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
383-
if (!idx) {
384-
if (((insn >> 1) & 0x3ff) == STFIWX)
385-
op1 = (void *)(regs->gpr[(insn >> 11) & 0x1f]);
386-
else
387-
goto illegal;
388-
} else {
389-
op1 = (void *)(regs->gpr[idx] + regs->gpr[(insn >> 11) & 0x1f]);
390-
}
391-
383+
op1 = (void *)((idx ? regs->gpr[idx] : 0)
384+
+ regs->gpr[(insn >> 11) & 0x1f]);
392385
break;
393386

394387
case XEU:
395388
idx = (insn >> 16) & 0x1f;
389+
if (!idx)
390+
goto illegal;
396391
op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
397-
op1 = (void *)((idx ? regs->gpr[idx] : 0)
392+
op1 = (void *)(regs->gpr[idx]
398393
+ regs->gpr[(insn >> 11) & 0x1f]);
399394
break;
400395

0 commit comments

Comments
 (0)