summaryrefslogtreecommitdiff
path: root/arch/powerpc/lib
diff options
context:
space:
mode:
authorMatt Brown <matthew.brown.dev@gmail.com>2017-07-31 10:58:25 +1000
committerMichael Ellerman <mpe@ellerman.id.au>2017-08-10 22:30:28 +1000
commit2c979c489fee0e6b418133a9d0b938f02f47232a (patch)
treedda38ecfa3f46106ae9529de0d0994d21ac74440 /arch/powerpc/lib
parentf312793dda98df93a113fd4cdeeeb8fc10c6db76 (diff)
powerpc/lib/sstep: Add prty instruction emulation
This adds emulation for the prtyw and prtyd instructions. Tested for logical correctness against the prtyw and prtyd instructions on ppc64le. Signed-off-by: Matt Brown <matthew.brown.dev@gmail.com> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/lib')
-rw-r--r--arch/powerpc/lib/sstep.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 09dc05446717..a2ded89db73e 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -657,6 +657,24 @@ static nokprobe_inline void do_bpermd(struct pt_regs *regs, unsigned long v1,
regs->gpr[ra] = perm;
}
#endif /* CONFIG_PPC64 */
+/*
+ * The size parameter adjusts the equivalent prty instruction.
+ * prtyw = 32, prtyd = 64
+ */
+static nokprobe_inline void do_prty(struct pt_regs *regs, unsigned long v,
+ int size, int ra)
+{
+ unsigned long long res = v ^ (v >> 8);
+
+ res ^= res >> 16;
+ if (size == 32) { /* prtyw */
+ regs->gpr[ra] = res & 0x0000000100000001;
+ return;
+ }
+
+ res ^= res >> 32;
+ regs->gpr[ra] = res & 1; /*prtyd */
+}
static nokprobe_inline int trap_compare(long v1, long v2)
{
@@ -1262,6 +1280,14 @@ int analyse_instr(struct instruction_op *op, struct pt_regs *regs,
case 124: /* nor */
regs->gpr[ra] = ~(regs->gpr[rd] | regs->gpr[rb]);
goto logical_done;
+
+ case 154: /* prtyw */
+ do_prty(regs, regs->gpr[rd], 32, ra);
+ goto logical_done;
+
+ case 186: /* prtyd */
+ do_prty(regs, regs->gpr[rd], 64, ra);
+ goto logical_done;
#ifdef CONFIG_PPC64
case 252: /* bpermd */
do_bpermd(regs, regs->gpr[rd], regs->gpr[rb], ra);