[patch 48/59] SPARC32: Fix over-optimization by GCC near ip_fast_csum.

Chris Wright
2007-02-03T02:47:53Z

[-- Attachment #1: sparc32-fix-over-optimization-by-gcc-near-ip_fast_csum.patch --]
[-- Type: text/plain, Size: 973 bytes --]

-stable review patch. If anyone has any objections, please let us know.
------------------

From: Bob Breuer <breuerr@mc.net>

In some cases such as:
iph->check = 0;
iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
GCC may optimize out the previous store.

Observed as a failure of NFS over udp (bad checksums on ip fragments)
when compiled with GCC 3.4.2.

Signed-off-by: Bob Breuer <breuerr@mc.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
include/asm-sparc/checksum.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.19.2.orig/include/asm-sparc/checksum.h
+++ linux-2.6.19.2/include/asm-sparc/checksum.h
@@ -159,7 +159,7 @@ static inline unsigned short ip_fast_csu
"xnor\t%%g0, %0, %0"
: "=r" (sum), "=&r" (iph)
: "r" (ihl), "1" (iph)
- : "g2", "g3", "g4", "cc");
+ : "g2", "g3", "g4", "cc", "memory");
return sum;
}

--