]> asedeno.scripts.mit.edu Git - linux.git/commit
powerpc/lib: Fix the feature fixup tests to actually work
authorMichael Ellerman <mpe@ellerman.id.au>
Mon, 16 Apr 2018 14:39:03 +0000 (00:39 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 11 May 2018 13:29:02 +0000 (23:29 +1000)
commitcad0e39023b43d94d5e38dfd55c103e15bdd093d
tree227ae4c7a6634b729d0b12b707594a9dfed86af4
parent32810d91325ec76b8ef4df463f8a0e9baf353322
powerpc/lib: Fix the feature fixup tests to actually work

The code patching code has always been a bit confused about whether
it's best to use void *, unsigned int *, char *, etc. to point to
instructions. In fact in the feature fixups tests we use both unsigned
int[] and u8[] in different places.

Unfortunately the tests that use unsigned int[] calculate the size of
the code blocks using subtraction of those unsigned int pointers, and
then pass the result to memcmp(). This means we're only comparing 1/4
of the bytes we need to, because we need to multiply by
sizeof(unsigned int) to get the number of *bytes*.

The result is that the tests do all the patching and then only compare
some of the resulting code, so patching bugs that only effect that
last 3/4 of the code could slip through undetected. It turns out that
hasn't been happening, although one test had a bad expected case (see
previous commit).

Fix it for now by multiplying the size by 4 in the affected functions.

Fixes: 362e7701fd18 ("powerpc: Add self-tests of the feature fixup code")
Epic-brown-paper-bag-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/lib/feature-fixups.c