<html><body>
<p><font size="2" face="Courier New">To: linuxppc-dev@lists.ozlabs.org</font><br>
<font size="2" face="Courier New">Subject: [PATCH] powerpc: Unaligned stores and stmw are broken in PowerISA emulation code</font><br>
<font size="2" face="Courier New">From: Tom Musta <tmusta@us.ibm.com></font><br>
<br>
<font size="2" face="Courier New">The stmw instruction was incorrectly decoded as an update form instruction and thus the RA</font><br>
<font size="2" face="Courier New">register was being clobbered.</font><br>
<br>
<font size="2" face="Courier New">Also, the utility routine to write memory to unaligned addresses breaks the operation into </font><br>
<font size="2" face="Courier New">smaller aligned accesses but was incorrectly incrementing the address by only one; it needs </font><br>
<font size="2" face="Courier New">to increment the address by the size of the smaller aligned chunk.</font><br>
<br>
<font size="2" face="Courier New">Signed-off-by: Tom Musta <tmusta@us.ibm.com></font><br>
<br>
<font size="2" face="Courier New">---</font><br>
<font size="2" face="Courier New">arch/powerpc/lib/sstep.c | 9 ++++++---</font><br>
<font size="2" face="Courier New">1 files changed, 6 insertions(+), 3 deletions(-)</font><br>
<br>
<font size="2" face="Courier New">diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c</font><br>
<font size="2" face="Courier New">index 9a52349..d220b88 100644</font><br>
<font size="2" face="Courier New">--- a/arch/powerpc/lib/sstep.c</font><br>
<font size="2" face="Courier New">+++ b/arch/powerpc/lib/sstep.c</font><br>
<font size="2" face="Courier New">@@ -100,8 +100,10 @@ static unsigned long __kprobes dform_ea(unsigned int instr, struct pt_regs *regs</font><br>
<font size="2" face="Courier New"> ea = (signed short) instr; /* sign-extend */</font><br>
<font size="2" face="Courier New"> if (ra) {</font><br>
<font size="2" face="Courier New"> ea += regs->gpr[ra];</font><br>
<font size="2" face="Courier New">- if (instr & 0x04000000) /* update forms */</font><br>
<font size="2" face="Courier New">- regs->gpr[ra] = ea;</font><br>
<font size="2" face="Courier New">+ if (instr & 0x04000000) { /* update forms */</font><br>
<font size="2" face="Courier New">+ if ((instr>>26) != 47) /* stmw is not an update form */</font><br>
<font size="2" face="Courier New">+ regs->gpr[ra] = ea;</font><br>
<font size="2" face="Courier New">+ }</font><br>
<font size="2" face="Courier New"> }</font><br>
<font size="2" face="Courier New"> </font><br>
<font size="2" face="Courier New"> return truncate_if_32bit(regs->msr, ea);</font><br>
<font size="2" face="Courier New">@@ -279,7 +281,7 @@ static int __kprobes write_mem_unaligned(unsigned long val, unsigned long ea,</font><br>
<font size="2" face="Courier New"> err = write_mem_aligned(val >> (nb - c) * 8, ea, c);</font><br>
<font size="2" face="Courier New"> if (err)</font><br>
<font size="2" face="Courier New"> return err;</font><br>
<font size="2" face="Courier New">- ++ea;</font><br>
<font size="2" face="Courier New">+ ea += c;</font><br>
<font size="2" face="Courier New"> }</font><br>
<font size="2" face="Courier New"> return 0;</font><br>
<font size="2" face="Courier New"> }</font><br>
<br>
<font size="2" face="sans-serif">Tom Musta (tmusta@us.ibm.com)<br>
Senior Software Engineer<br>
Blue Gene Kernel Development<br>
IBM Rochester<br>
(507) 253-4119 (T/L 553-4119)<br>
</font></body></html>