From a624f772e194e3dac47adbb62edf9a006457890e Mon Sep 17 00:00:00 2001 From: James Yang Date: Mon, 24 Jun 2013 18:31:44 -0500 Subject: Fix string emulation for 32-bit process on ppc64 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 Change-Id: Ib2eb9aa3a712f25124680d0f164c3a392e5401a7 Reviewed-on: http://git.am.freescale.net:8181/3052 Tested-by: Review Code-CDREVIEW Reviewed-by: Fleming Andrew-AFLEMING 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: -- cgit v0.10.2