]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/lib/sstep: Fix count leading zeros instructions
authorSandipan Das <sandipan@linux.vnet.ibm.com>
Tue, 10 Oct 2017 06:45:30 +0000 (12:15 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 10 Oct 2017 09:16:32 +0000 (20:16 +1100)
commitcba48abfb17c182d6dcd8452b7d84a3741e920d8
treedc96af57600fdc47d874e933103265e4dff79233
parent50345a59b2d5d78aa742f6bf3c5a31b9ad56637b
powerpc/lib/sstep: Fix count leading zeros instructions

According to the GCC documentation, the behaviour of __builtin_clz()
and __builtin_clzl() is undefined if the value of the input argument
is zero. Without handling this special case, these builtins have been
used for emulating the following instructions:
  * Count Leading Zeros Word (cntlzw[.])
  * Count Leading Zeros Doubleword (cntlzd[.])

This fixes the emulated behaviour of these instructions by adding an
additional check for this special case.

Fixes: 161c9d1ebdd25 ("powerpc: Change analyse_instr so it doesn't modify *regs")
Signed-off-by: Sandipan Das <sandipan@linux.vnet.ibm.com>
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/lib/sstep.c