Skip to content

Commit 80aa0fb

Browse files
James Yangozbenh
authored andcommitted
powerpc: Fix string instr. emulation for 32-bit processes 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 <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]>
1 parent e1b85c1 commit 80aa0fb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/powerpc/kernel/traps.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,10 @@ static int emulate_string_inst(struct pt_regs *regs, u32 instword)
866866
u8 val;
867867
u32 shift = 8 * (3 - (pos & 0x3));
868868

869+
/* if process is 32-bit, clear upper 32 bits of EA */
870+
if ((regs->msr & MSR_64BIT) == 0)
871+
EA &= 0xFFFFFFFF;
872+
869873
switch ((instword & PPC_INST_STRING_MASK)) {
870874
case PPC_INST_LSWX:
871875
case PPC_INST_LSWI:

0 commit comments

Comments
 (0)