Commit 04988d6f authored by Thiemo Seufer's avatar Thiemo Seufer Committed by Ralf Baechle

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

Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
Signed-off-by: default avatarThiemo Seufer <ths@networkno.de>
parent 9556ac2f
...@@ -71,14 +71,15 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char * ...@@ -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) static inline unsigned short int csum_fold(unsigned int sum)
{ {
__asm__( __asm__(
".set\tnoat\t\t\t# csum_fold\n\t" " .set push # csum_fold\n"
"sll\t$1,%0,16\n\t" " .set noat \n"
"addu\t%0,$1\n\t" " sll $1, %0, 16 \n"
"sltu\t$1,%0,$1\n\t" " addu %0, $1 \n"
"srl\t%0,%0,16\n\t" " sltu $1, %0, $1 \n"
"addu\t%0,$1\n\t" " srl %0, %0, 16 \n"
"xori\t%0,0xffff\n\t" " addu %0, $1 \n"
".set\tat" " xori %0, 0xffff \n"
" .set pop"
: "=r" (sum) : "=r" (sum)
: "0" (sum)); : "0" (sum));
...@@ -128,29 +129,30 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr, ...@@ -128,29 +129,30 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr,
unsigned int sum) unsigned int sum)
{ {
__asm__( __asm__(
".set\tnoat\t\t\t# csum_tcpudp_nofold\n\t" " .set push # csum_tcpudp_nofold\n"
" .set noat \n"
#ifdef CONFIG_32BIT #ifdef CONFIG_32BIT
"addu\t%0, %2\n\t" " addu %0, %2 \n"
"sltu\t$1, %0, %2\n\t" " sltu $1, %0, %2 \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %3\n\t" " addu %0, %3 \n"
"sltu\t$1, %0, %3\n\t" " sltu $1, %0, %3 \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %4\n\t" " addu %0, %4 \n"
"sltu\t$1, %0, %4\n\t" " sltu $1, %0, %4 \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
#endif #endif
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
"daddu\t%0, %2\n\t" " daddu %0, %2 \n"
"daddu\t%0, %3\n\t" " daddu %0, %3 \n"
"daddu\t%0, %4\n\t" " daddu %0, %4 \n"
"dsll32\t$1, %0, 0\n\t" " dsll32 $1, %0, 0 \n"
"daddu\t%0, $1\n\t" " daddu %0, $1 \n"
"dsrl32\t%0, %0, 0\n\t" " dsrl32 %0, %0, 0 \n"
#endif #endif
".set\tat" " .set pop"
: "=r" (sum) : "=r" (sum)
: "0" (daddr), "r"(saddr), : "0" (daddr), "r"(saddr),
#ifdef __MIPSEL__ #ifdef __MIPSEL__
...@@ -193,57 +195,57 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, ...@@ -193,57 +195,57 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
unsigned int sum) unsigned int sum)
{ {
__asm__( __asm__(
".set\tpush\t\t\t# csum_ipv6_magic\n\t" " .set push # csum_ipv6_magic\n"
".set\tnoreorder\n\t" " .set noreorder \n"
".set\tnoat\n\t" " .set noat \n"
"addu\t%0, %5\t\t\t# proto (long in network byte order)\n\t" " addu %0, %5 # proto (long in network byte order)\n"
"sltu\t$1, %0, %5\n\t" " sltu $1, %0, %5 \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %6\t\t\t# csum\n\t" " addu %0, %6 # csum\n"
"sltu\t$1, %0, %6\n\t" " sltu $1, %0, %6 \n"
"lw\t%1, 0(%2)\t\t\t# four words source address\n\t" " lw %1, 0(%2) # four words source address\n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %1\n\t" " addu %0, %1 \n"
"sltu\t$1, %0, %1\n\t" " sltu $1, %0, %1 \n"
"lw\t%1, 4(%2)\n\t" " lw %1, 4(%2) \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %1\n\t" " addu %0, %1 \n"
"sltu\t$1, %0, %1\n\t" " sltu $1, %0, %1 \n"
"lw\t%1, 8(%2)\n\t" " lw %1, 8(%2) \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %1\n\t" " addu %0, %1 \n"
"sltu\t$1, %0, %1\n\t" " sltu $1, %0, %1 \n"
"lw\t%1, 12(%2)\n\t" " lw %1, 12(%2) \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %1\n\t" " addu %0, %1 \n"
"sltu\t$1, %0, %1\n\t" " sltu $1, %0, %1 \n"
"lw\t%1, 0(%3)\n\t" " lw %1, 0(%3) \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %1\n\t" " addu %0, %1 \n"
"sltu\t$1, %0, %1\n\t" " sltu $1, %0, %1 \n"
"lw\t%1, 4(%3)\n\t" " lw %1, 4(%3) \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %1\n\t" " addu %0, %1 \n"
"sltu\t$1, %0, %1\n\t" " sltu $1, %0, %1 \n"
"lw\t%1, 8(%3)\n\t" " lw %1, 8(%3) \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %1\n\t" " addu %0, %1 \n"
"sltu\t$1, %0, %1\n\t" " sltu $1, %0, %1 \n"
"lw\t%1, 12(%3)\n\t" " lw %1, 12(%3) \n"
"addu\t%0, $1\n\t" " addu %0, $1 \n"
"addu\t%0, %1\n\t" " addu %0, %1 \n"
"sltu\t$1, %0, %1\n\t" " sltu $1, %0, %1 \n"
"addu\t%0, $1\t\t\t# Add final carry\n\t" " addu %0, $1 # Add final carry\n"
".set\tpop" " .set pop"
: "=r" (sum), "=r" (proto) : "=r" (sum), "=r" (proto)
: "r" (saddr), "r" (daddr), : "r" (saddr), "r" (daddr),
"0" (htonl(len)), "1" (htonl(proto)), "r" (sum)); "0" (htonl(len)), "1" (htonl(proto)), "r" (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