Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17e8de7e authored by Tom Musta's avatar Tom Musta Committed by Benjamin Herrenschmidt
Browse files

powerpc: Unaligned stores and stmw are broken in emulation code



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: default avatarTom Musta <tmusta@us.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent f748edaf
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -100,9 +100,11 @@ 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 */
		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;
}