提交 04988d6f 编写于 作者: T Thiemo Seufer 提交者: Ralf Baechle

Protect noat assembly with .set push/pop and make it somewhat readable.

Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
Signed-off-by: NThiemo Seufer <ths@networkno.de>
上级 9556ac2f
......@@ -71,14 +71,15 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *
static inline unsigned short int csum_fold(unsigned int sum)
{
__asm__(
".set\tnoat\t\t\t# csum_fold\n\t"
"sll\t$1,%0,16\n\t"
"addu\t%0,$1\n\t"
"sltu\t$1,%0,$1\n\t"
"srl\t%0,%0,16\n\t"
"addu\t%0,$1\n\t"
"xori\t%0,0xffff\n\t"
".set\tat"
" .set push # csum_fold\n"
" .set noat \n"
" sll $1, %0, 16 \n"
" addu %0, $1 \n"
" sltu $1, %0, $1 \n"
" srl %0, %0, 16 \n"
" addu %0, $1 \n"
" xori %0, 0xffff \n"
" .set pop"
: "=r" (sum)
: "0" (sum));
......@@ -128,29 +129,30 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr,
unsigned int sum)
{
__asm__(
".set\tnoat\t\t\t# csum_tcpudp_nofold\n\t"
" .set push # csum_tcpudp_nofold\n"
" .set noat \n"
#ifdef CONFIG_32BIT
"addu\t%0, %2\n\t"
"sltu\t$1, %0, %2\n\t"
"addu\t%0, $1\n\t"
" addu %0, %2 \n"
" sltu $1, %0, %2 \n"
" addu %0, $1 \n"
"addu\t%0, %3\n\t"
"sltu\t$1, %0, %3\n\t"
"addu\t%0, $1\n\t"
" addu %0, %3 \n"
" sltu $1, %0, %3 \n"
" addu %0, $1 \n"
"addu\t%0, %4\n\t"
"sltu\t$1, %0, %4\n\t"
"addu\t%0, $1\n\t"
" addu %0, %4 \n"
" sltu $1, %0, %4 \n"
" addu %0, $1 \n"
#endif
#ifdef CONFIG_64BIT
"daddu\t%0, %2\n\t"
"daddu\t%0, %3\n\t"
"daddu\t%0, %4\n\t"
"dsll32\t$1, %0, 0\n\t"
"daddu\t%0, $1\n\t"
"dsrl32\t%0, %0, 0\n\t"
" daddu %0, %2 \n"
" daddu %0, %3 \n"
" daddu %0, %4 \n"
" dsll32 $1, %0, 0 \n"
" daddu %0, $1 \n"
" dsrl32 %0, %0, 0 \n"
#endif
".set\tat"
" .set pop"
: "=r" (sum)
: "0" (daddr), "r"(saddr),
#ifdef __MIPSEL__
......@@ -193,57 +195,57 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
unsigned int sum)
{
__asm__(
".set\tpush\t\t\t# csum_ipv6_magic\n\t"
".set\tnoreorder\n\t"
".set\tnoat\n\t"
"addu\t%0, %5\t\t\t# proto (long in network byte order)\n\t"
"sltu\t$1, %0, %5\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %6\t\t\t# csum\n\t"
"sltu\t$1, %0, %6\n\t"
"lw\t%1, 0(%2)\t\t\t# four words source address\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
"sltu\t$1, %0, %1\n\t"
"lw\t%1, 4(%2)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
"sltu\t$1, %0, %1\n\t"
"lw\t%1, 8(%2)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
"sltu\t$1, %0, %1\n\t"
"lw\t%1, 12(%2)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
"sltu\t$1, %0, %1\n\t"
"lw\t%1, 0(%3)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
"sltu\t$1, %0, %1\n\t"
"lw\t%1, 4(%3)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
"sltu\t$1, %0, %1\n\t"
"lw\t%1, 8(%3)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
"sltu\t$1, %0, %1\n\t"
"lw\t%1, 12(%3)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
"sltu\t$1, %0, %1\n\t"
"addu\t%0, $1\t\t\t# Add final carry\n\t"
".set\tpop"
" .set push # csum_ipv6_magic\n"
" .set noreorder \n"
" .set noat \n"
" addu %0, %5 # proto (long in network byte order)\n"
" sltu $1, %0, %5 \n"
" addu %0, $1 \n"
" addu %0, %6 # csum\n"
" sltu $1, %0, %6 \n"
" lw %1, 0(%2) # four words source address\n"
" addu %0, $1 \n"
" addu %0, %1 \n"
" sltu $1, %0, %1 \n"
" lw %1, 4(%2) \n"
" addu %0, $1 \n"
" addu %0, %1 \n"
" sltu $1, %0, %1 \n"
" lw %1, 8(%2) \n"
" addu %0, $1 \n"
" addu %0, %1 \n"
" sltu $1, %0, %1 \n"
" lw %1, 12(%2) \n"
" addu %0, $1 \n"
" addu %0, %1 \n"
" sltu $1, %0, %1 \n"
" lw %1, 0(%3) \n"
" addu %0, $1 \n"
" addu %0, %1 \n"
" sltu $1, %0, %1 \n"
" lw %1, 4(%3) \n"
" addu %0, $1 \n"
" addu %0, %1 \n"
" sltu $1, %0, %1 \n"
" lw %1, 8(%3) \n"
" addu %0, $1 \n"
" addu %0, %1 \n"
" sltu $1, %0, %1 \n"
" lw %1, 12(%3) \n"
" addu %0, $1 \n"
" addu %0, %1 \n"
" sltu $1, %0, %1 \n"
" addu %0, $1 # Add final carry\n"
" .set pop"
: "=r" (sum), "=r" (proto)
: "r" (saddr), "r" (daddr),
"0" (htonl(len)), "1" (htonl(proto)), "r" (sum));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册