[PATCH] powerpc: Unaligned stores and stmw are broken in PowerISA emulation code

Tom Musta tmusta at us.ibm.com
Fri Aug 23 00:25:28 EST 2013


To: linuxppc-dev at lists.ozlabs.org
Subject: [PATCH] powerpc: Unaligned stores and stmw are broken in PowerISA
emulation code
From: Tom Musta <tmusta at us.ibm.com>

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 at us.ibm.com>

---
arch/powerpc/lib/sstep.c |    9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 9a52349..d220b88 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -100,8 +100,10 @@ static unsigned long __kprobes dform_ea(unsigned int
instr, struct pt_regs *regs
 	ea = (signed short) instr;		/* sign-extend */
 	if (ra) {
 		ea += regs->gpr[ra];
-		if (instr & 0x04000000)		/* update forms */
-			regs->gpr[ra] = ea;
+		if (instr & 0x04000000) {		/* update forms */
+			if ((instr>>26) != 47) 		/* stmw is not an update
form */
+				regs->gpr[ra] = ea;
+		}
 	}

 	return truncate_if_32bit(regs->msr, ea);
@@ -279,7 +281,7 @@ static int __kprobes write_mem_unaligned(unsigned long
val, unsigned long ea,
 		err = write_mem_aligned(val >> (nb - c) * 8, ea, c);
 		if (err)
 			return err;
-		++ea;
+		ea += c;
 	}
 	return 0;
 }

Tom Musta (tmusta at us.ibm.com)
Senior Software Engineer
Blue Gene Kernel Development
IBM Rochester
(507) 253-4119   (T/L 553-4119)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20130822/5f49d8ae/attachment.html>


More information about the Linuxppc-dev mailing list