s390/lib: fix memcmp and strstr
authorChristian Borntraeger <borntraeger@de.ibm.com>
Thu, 4 Aug 2016 08:24:30 +0000 (10:24 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 8 Aug 2016 13:41:31 +0000 (15:41 +0200)
commite2efc424549eb66d227dfe6d073d1789a24bc698
tree1c95439c4a7f1696fbcaf1a753ccb68e62137b47
parent134a24cd895c5d138d639a0741ad27e389cd4562
s390/lib: fix memcmp and strstr

if two string compare equal the clcle instruction will update the
string addresses to point _after_ the string. This might already
be on a different page, so we should not use these pointer to
calculate the difference as in that case the calculation of the
difference can cause oopses.

The return value of memcmp does not need the difference, we
can just reuse the condition code and return for CC=1 (All bytes
compared, first operand low) -1 and for CC=2 (All bytes compared,
first operand high) +1
strstr also does not need the diff.
While fixing this, make the common function clcle "correct on its
own" by using l1 instead of l2 for the first length. strstr will
call this with l2 for both strings.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Fixes: db7f5eef3dc0 ("s390/lib: use basic blocks for inline assemblies")
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/lib/string.c