linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Tom Musta <tmusta@us.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] powerpc: Unaligned stores and stmw are broken in PowerISA emulation code
Date: Thu, 22 Aug 2013 09:25:28 -0500	[thread overview]
Message-ID: <OF355BAB01.27F99E7D-ON86257BCF.004EC768-86257BCF.004F3C8F@us.ibm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1632 bytes --]


To: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] powerpc: Unaligned stores and stmw are broken in PowerISA
emulation code
From: Tom Musta <tmusta@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@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@us.ibm.com)
Senior Software Engineer
Blue Gene Kernel Development
IBM Rochester
(507) 253-4119   (T/L 553-4119)

[-- Attachment #2: Type: text/html, Size: 3578 bytes --]

                 reply	other threads:[~2013-08-22 14:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OF355BAB01.27F99E7D-ON86257BCF.004EC768-86257BCF.004F3C8F@us.ibm.com \
    --to=tmusta@us.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).