Patchwork Fix string emulation for 32-bit process on ppc64

login
register
mail settings
Submitter James Yang
Date June 25, 2013, 4:41 p.m.
Message ID <alpine.LRH.2.00.1306251133460.1506@ra8135-ec1.am.freescale.net>
Download mbox | patch
Permalink /patch/254424/
State Accepted
Commit 80aa0fb4940bf8ee52bcb574d74459a7aea45621
Headers show

Comments

James Yang - June 25, 2013, 4:41 p.m.
String instruction emulation would erroneously result in a segfault if
the upper bits of the EA are set and is so high that it fails access
check.  Truncate the EA to 32 bits if the process is 32-bit.

Signed-off-by: James Yang <James.Yang@freescale.com>
---
 arch/powerpc/kernel/traps.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Patch

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index dce1bea..c72e7e9 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -840,6 +840,10 @@  static int emulate_string_inst(struct pt_regs *regs, u32 instword)
 		u8 val;
 		u32 shift = 8 * (3 - (pos & 0x3));
 
+		/* if process is 32-bit, clear upper 32 bits of EA */
+		if ((regs->msr & MSR_64BIT) == 0)
+			EA &= 0xFFFFFFFF;
+
 		switch ((instword & PPC_INST_STRING_MASK)) {
 			case PPC_INST_LSWX:
 			case PPC_INST_LSWI: