Skip to contentSkip to conversation

FRV: ip_fast_csum() requires a memory clobber on its inline asm

PATCH In review David Howells 2 participants 2 messages Jun 5, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 FRV: ip_fast_csum() requires a memory clobber on its inline asm

ip_fast_csum() requires a memory clobber on its inline asm as it accesses memory in a fashion that gcc can't predict.

The GCC manual says:

If your assembler instructions access memory in an unpredictable fashion, add `memory' to the list of clobbered registers. This will cause GCC to not keep memory values cached in registers across the assembler instruction and not optimize stores or loads to that memory.

The bug hasn't been noticed in FRV, but it has been seen in PA-RISC.

---

 include/asm-frv/checksum.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/asm-frv/checksum.h +1 -1
index 9b16898..269da09 100644
@@ -75,7 +75,7 @@ __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
 	    : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (inc), "=&r"(tmp)
 	    : "0" (sum), "1" (iph), "2" (ihl), "3" (4),
 	    "m"(*(volatile struct { int _[100]; } *)iph)
-	    : "icc0", "icc1"
+	    : "icc0", "icc1", "memory"
 	    );
 
 	return (__force __sum16)~sum;
#1 lore raw

include/asm-frv/checksum.h __sum16 ip_fast_csum(const void *iph, unsigned int ihl) · line 77

Quoted 3 lines · David Howells
include/asm-frv/checksum.h +0 -0
 	    : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (inc), "=&r"(tmp)
 	    : "0" (sum), "1" (iph), "2" (ihl), "3" (4),
 	    "m"(*(volatile struct { int _[100]; } *)iph)

Do you still need the input "m" constraint?

Quoted 5 lines
include/asm-frv/checksum.h +1 -1
-	    : "icc0", "icc1"
+	    : "icc0", "icc1", "memory"
 	    );
 
 	return (__force __sum16)~sum;
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."