Commit afbc1e99 authored by Heiko Carstens's avatar Heiko Carstens

[S390] Fix TCP/UDP pseudo header checksum computation.

git commit f994aae1 changed the
function declaration of csum_tcpudp_nofold. Argument types were
changed from unsigned long to __be32 (unsigned int). Therefore we
lost the implicit type conversion that zeroed the upper half of the
registers that are used to pass parameters. Since the inline assembly
relied on this we ended up adding random values and wrong checksums
were created.
Showed only up on machines with more than 4GB since gcc produced code
where the registers that are used to pass 'saddr' and 'daddr' previously
contained addresses before calling this function.
Fix this by using 32 bit arithmetics and convert code to C, since gcc
produces better code than these hand-optimized versions.

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
parent 04439694
...@@ -121,50 +121,21 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, ...@@ -121,50 +121,21 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, unsigned short proto, unsigned short len, unsigned short proto,
__wsum sum) __wsum sum)
{ {
#ifndef __s390x__ __u32 csum = (__force __u32)sum;
asm volatile(
" alr %0,%1\n" /* sum += saddr */ csum += (__force __u32)saddr;
" brc 12,0f\n" if (csum < (__force __u32)saddr)
" ahi %0,1\n" /* add carry */ csum++;
"0:"
: "+&d" (sum) : "d" (saddr) : "cc"); csum += (__force __u32)daddr;
asm volatile( if (csum < (__force __u32)daddr)
" alr %0,%1\n" /* sum += daddr */ csum++;
" brc 12,1f\n"
" ahi %0,1\n" /* add carry */ csum += len + proto;
"1:" if (csum < len + proto)
: "+&d" (sum) : "d" (daddr) : "cc"); csum++;
asm volatile(
" alr %0,%1\n" /* sum += len + proto */ return (__force __wsum)csum;
" brc 12,2f\n"
" ahi %0,1\n" /* add carry */
"2:"
: "+&d" (sum)
: "d" (len + proto)
: "cc");
#else /* __s390x__ */
asm volatile(
" lgfr %0,%0\n"
" algr %0,%1\n" /* sum += saddr */
" brc 12,0f\n"
" aghi %0,1\n" /* add carry */
"0: algr %0,%2\n" /* sum += daddr */
" brc 12,1f\n"
" aghi %0,1\n" /* add carry */
"1: algfr %0,%3\n" /* sum += len + proto */
" brc 12,2f\n"
" aghi %0,1\n" /* add carry */
"2: srlg 0,%0,32\n"
" alr %0,0\n" /* fold to 32 bits */
" brc 12,3f\n"
" ahi %0,1\n" /* add carry */
"3: llgfr %0,%0"
: "+&d" (sum)
: "d" (saddr), "d" (daddr),
"d" (len + proto)
: "cc", "0");
#endif /* __s390x__ */
return sum;
} }
/* /*
......
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