Commit 17cabcb4 authored by Anton Blanchard's avatar Anton Blanchard Committed by Ben Hutchings

powerpc: Fix bad inline asm constraint in create_zero_mask()

commit b4c11211 upstream.

In create_zero_mask() we have:

	addi	%1,%2,-1
	andc	%1,%1,%2
	popcntd	%0,%1

using the "r" constraint for %2. r0 is a valid register in the "r" set,
but addi X,r0,X turns it into an li:

	li	r7,-1
	andc	r7,r7,r0
	popcntd	r4,r7

Fix this by using the "b" constraint, for which r0 is not a valid
register.

This was found with a kernel build using gcc trunk, narrowed down to
when -frename-registers was enabled at -O2. It is just luck however
that we aren't seeing this on older toolchains.

Thanks to Segher for working with me to find this issue.

Fixes: d0cebfa6 ("powerpc: word-at-a-time optimization for 64-bit Little Endian")
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
[bwh: Backported to 3.16: same issue exists with a different variable in
 find_zero()]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent dfc39542
...@@ -62,7 +62,7 @@ static inline unsigned long find_zero(unsigned long mask) ...@@ -62,7 +62,7 @@ static inline unsigned long find_zero(unsigned long mask)
"andc %1,%1,%2\n\t" "andc %1,%1,%2\n\t"
"popcntd %0,%1" "popcntd %0,%1"
: "=r" (leading_zero_bits), "=&r" (trailing_zero_bit_mask) : "=r" (leading_zero_bits), "=&r" (trailing_zero_bit_mask)
: "r" (mask)); : "b" (mask));
return leading_zero_bits >> 3; return leading_zero_bits >> 3;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment