Thread (18 messages) flat view 18 messages, 5 authors, 2017-07-14

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

From: Segher Boessenkool <hidden>
Date: 2017-07-14 16:17:07

On Fri, Jul 14, 2017 at 02:19:34PM +1000, Matt Brown wrote:
quoted
quoted
+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?
Because that is what the ISA says.  Bit ordering is always BE.  If any
instruction behaves differently in LE mode that is explicitly described.

Please somehow test that the emulation works correctly, and describe
how you tested it, to give people the warm fuzzies.


Segher
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help