On Thu, Jul 13, 2017 at 01:25:46PM +1000, Matt Brown wrote: > This adds emulation for the bpermd instruction. > > Signed-off-by: Matt Brown <matthew.brown....@gmail.com> > --- > arch/powerpc/lib/sstep.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c > index cf69987..603654d 100644 > --- a/arch/powerpc/lib/sstep.c > +++ b/arch/powerpc/lib/sstep.c > @@ -637,6 +637,21 @@ static nokprobe_inline void do_popcnt(struct pt_regs > *regs, unsigned long v1, > regs->gpr[ra] = out_val; > } > > +static nokprobe_inline void do_bpermd(struct pt_regs *regs, unsigned long v1, > + unsigned long v2, int ra) > +{ > + unsigned int idx, i; > + unsigned char perm; > + > + perm = 0x0; > + for (i = 0; i < 8; i++) { > + idx = (v1 >> (i * 8)) & 0xff; > + if (idx < 64) > + perm |= (v2 & (1 << idx)) >> (idx - i); > + } > + regs->gpr[ra] = 0 | perm;
Huh? What's the point of doing an or with 0? The compiler will eliminate it, but it just confuses the reader. Gabriel > +} > + > static nokprobe_inline int trap_compare(long v1, long v2) > { > int ret = 0; > @@ -1274,6 +1289,14 @@ int analyse_instr(struct instruction_op *op, struct > pt_regs *regs, > goto logical_done; > #endif > > +#ifdef __powerpc64__ > + case 2396736: /* bpermd */ > + val = regs->gpr[rd]; > + val2 = regs->gpr[rb]; > + do_bpermd(regs, val, val2, ra); > + goto logical_done; > +#endif > + > /* > * Shift instructions > */ > -- > 2.9.3