Skip to contentSkip to conversation

sparc32: fix gcc over-optimizatoin near ip_fast_csum

PATCH In review Bob Breuer 2 participants 2 messages Jan 14, 2007 – Jan 16, 2007

lore
Share & tools
lore

Bob Breuer

author
#0 lore raw

PATCH 1/1 sparc32: fix gcc over-optimizatoin near ip_fast_csum

Fix over-optimization by GCC near ip_fast_csum.

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.

---

include/asm-sparc/checksum.h +1 -1
index 267e631..34518ea 100644
@@ -151,7 +151,7 @@ static inline __sum16 ip_fast_csum(const
 			     "xnor\t%%g0, %0, %0"
 			     : "=r" (sum), "=&r" (iph)
 			     : "r" (ihl), "1" (iph)
-			     : "g2", "g3", "g4", "cc");
+			     : "g2", "g3", "g4", "cc", "memory");
 	return sum;
 }
 
#1 lore raw

From: Bob Breuer <[email protected]>
Date: Sun, 14 Jan 2007 14:32:57 -0600

Quoted 11 lines

Fix over-optimization by GCC near ip_fast_csum.

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.

Thanks for finding this bug, patch applied.

This issue may be why I made ip_fast_csum() non-inlined on sparc64 :-)