Skip to content

Commit 2c979c4

Browse files
m-browmpe
authored andcommitted
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 <[email protected]> Reviewed-by: Cyril Bur <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent f312793 commit 2c979c4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

arch/powerpc/lib/sstep.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,24 @@ static nokprobe_inline void do_bpermd(struct pt_regs *regs, unsigned long v1,
657657
regs->gpr[ra] = perm;
658658
}
659659
#endif /* CONFIG_PPC64 */
660+
/*
661+
* The size parameter adjusts the equivalent prty instruction.
662+
* prtyw = 32, prtyd = 64
663+
*/
664+
static nokprobe_inline void do_prty(struct pt_regs *regs, unsigned long v,
665+
int size, int ra)
666+
{
667+
unsigned long long res = v ^ (v >> 8);
668+
669+
res ^= res >> 16;
670+
if (size == 32) { /* prtyw */
671+
regs->gpr[ra] = res & 0x0000000100000001;
672+
return;
673+
}
674+
675+
res ^= res >> 32;
676+
regs->gpr[ra] = res & 1; /*prtyd */
677+
}
660678

661679
static nokprobe_inline int trap_compare(long v1, long v2)
662680
{
@@ -1262,6 +1280,14 @@ int analyse_instr(struct instruction_op *op, struct pt_regs *regs,
12621280
case 124: /* nor */
12631281
regs->gpr[ra] = ~(regs->gpr[rd] | regs->gpr[rb]);
12641282
goto logical_done;
1283+
1284+
case 154: /* prtyw */
1285+
do_prty(regs, regs->gpr[rd], 32, ra);
1286+
goto logical_done;
1287+
1288+
case 186: /* prtyd */
1289+
do_prty(regs, regs->gpr[rd], 64, ra);
1290+
goto logical_done;
12651291
#ifdef CONFIG_PPC64
12661292
case 252: /* bpermd */
12671293
do_bpermd(regs, regs->gpr[rd], regs->gpr[rb], ra);

0 commit comments

Comments
 (0)