__volatile__ for asms in unaligned.c
I just discovered that my compiler is scheduling the code in the asm blocks in unaligned.c *before* the 'goto sigbus'. My gcc is 3.1.1 with some almost certainly unrelated local mods.
Anyway, is there a reason these aren't marked as volatile? The gcc docs have the scary comment "You can prevent an asm' instruction from being deleted, MOVED SIGNIFICANTLY, or combined, by writing the keyword volatile' after the`asm'."
Here's an example, for the lw_op case in the mips64 kernel:
---------
case lw_op: if (verify_area(VERIFY_READ, addr, 4)) goto sigbus; __asm__( "1:\tlwl\t%0, (%2)\n" "2:\tlwr\t%0, 3(%2)\n\t"
---------
Compiled with normal mips64 build flags (for SB1) was turned into:
---------
### verify_area
ld $2,2400($28)
daddu $3,$5,4
or $3,$5,$3
and $2,$2,$3
li $4,-14 # 0xfffffffffffffff2
movz $4,$0,$2
...
### the asm code
1: lwl $9, ($5)
2: lwr $9, 3($5)
li $3, 0
3: .section .fixup,"ax"
4: li $3, -14
j 3b...
### finally, the verify_area result check
beq $4,$0,$L1131---------
Kip
Quoted 4 lines · Kip Walker
Anyway, is there a reason these aren't marked as volatile? The gcc docs have the scary comment "You can prevent an
asm' instruction from being deleted, MOVED SIGNIFICANTLY, or combined, by writing the keywordvolatile' after the`asm'."
It's a valid code movement by gcc's no longer really new basic block reordering thing. I admit I'm pretty surprised this wasn't found before.
So I just added the volatiles.
Ralf