Skip to content

Commit 17e8de7

Browse files
Tom Mustaozbenh
authored andcommitted
powerpc: Unaligned stores and stmw are broken in emulation code
The stmw instruction was incorrectly decoded as an update form instruction and thus the RA register was being clobbered. Also, the utility routine to write memory to unaligned addresses breaks the operation into smaller aligned accesses but was incorrectly incrementing the address by only one; it needs to increment the address by the size of the smaller aligned chunk. Signed-off-by: Tom Musta <tmusta@us.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
1 parent f748eda commit 17e8de7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎arch/powerpc/lib/sstep.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ static unsigned long __kprobes dform_ea(unsigned int instr, struct pt_regs *regs
100100
ea = (signed short) instr; /* sign-extend */
101101
if (ra) {
102102
ea += regs->gpr[ra];
103-
if (instr & 0x04000000) /* update forms */
104-
regs->gpr[ra] = ea;
103+
if (instr & 0x04000000) { /* update forms */
104+
if ((instr>>26) != 47) /* stmw is not an update form */
105+
regs->gpr[ra] = ea;
106+
}
105107
}
106108

107109
return truncate_if_32bit(regs->msr, ea);
@@ -279,7 +281,7 @@ static int __kprobes write_mem_unaligned(unsigned long val, unsigned long ea,
279281
err = write_mem_aligned(val >> (nb - c) * 8, ea, c);
280282
if (err)
281283
return err;
282-
++ea;
284+
ea += c;
283285
}
284286
return 0;
285287
}

0 commit comments

Comments
 (0)