[PATCH 3/5] powerpc/lib/sstep: Add bpermd instruction emulation

Matt Brown matthew.brown.dev at gmail.com
Fri Jul 14 14:19:34 AEST 2017


On Thu, Jul 13, 2017 at 5:28 PM, Segher Boessenkool
<segher at kernel.crashing.org> wrote:
> On Thu, Jul 13, 2017 at 01:25:46PM +1000, Matt Brown wrote:
>> +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);
>
> That doesn't work I think, the bit numbers ("idx") are big-endian?

Why would it be big-endian? Wouldn't it be in the same endian form as the arch?
>
>> +     }
>> +     regs->gpr[ra] = 0 | perm;
>
> And that is just silly :-)
>

Yep that is silly.

Thanks,
Matt

>> +}
>
>
> Segher


More information about the Linuxppc-dev mailing list