Commit 198688ed authored by Tiezhu Yang's avatar Tiezhu Yang Committed by Thomas Bogendoerfer

MIPS: Fix inline asm input/output type mismatch in checksum.h used with Clang

Fix the following build error when make M=samples/bpf used with Clang:

  CLANG-bpf  samples/bpf/sockex2_kern.o
In file included from samples/bpf/sockex2_kern.c:7:
In file included from ./include/uapi/linux/if_tunnel.h:7:
In file included from ./include/linux/ip.h:16:
In file included from ./include/linux/skbuff.h:28:
In file included from ./include/net/checksum.h:22:
./arch/mips/include/asm/checksum.h:161:9: error: unsupported inline asm: input with type 'unsigned long' matching output with type '__wsum' (aka 'unsigned int')
        : "0" ((__force unsigned long)daddr),
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

This is a known issue on MIPS [1], the changed code can be compiled
successfully by both GCC and Clang.

[1] https://lore.kernel.org/linux-mips/CAG_fn=W0JHf8QyUX==+rQMp8PoULHrsQCa9Htffws31ga8k-iw@mail.gmail.com/Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
parent e6a52b8f
...@@ -130,6 +130,8 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, ...@@ -130,6 +130,8 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
__u32 len, __u8 proto, __u32 len, __u8 proto,
__wsum sum) __wsum sum)
{ {
unsigned long tmp = (__force unsigned long)sum;
__asm__( __asm__(
" .set push # csum_tcpudp_nofold\n" " .set push # csum_tcpudp_nofold\n"
" .set noat \n" " .set noat \n"
...@@ -157,7 +159,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, ...@@ -157,7 +159,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
" addu %0, $1 \n" " addu %0, $1 \n"
#endif #endif
" .set pop" " .set pop"
: "=r" (sum) : "=r" (tmp)
: "0" ((__force unsigned long)daddr), : "0" ((__force unsigned long)daddr),
"r" ((__force unsigned long)saddr), "r" ((__force unsigned long)saddr),
#ifdef __MIPSEL__ #ifdef __MIPSEL__
...@@ -167,7 +169,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, ...@@ -167,7 +169,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
#endif #endif
"r" ((__force unsigned long)sum)); "r" ((__force unsigned long)sum));
return sum; return (__force __wsum)tmp;
} }
#define csum_tcpudp_nofold csum_tcpudp_nofold #define csum_tcpudp_nofold csum_tcpudp_nofold
......
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