* __volatile__ for asms in unaligned.c
@ 2003-02-20 22:43 Kip Walker
2003-02-21 1:09 ` Ralf Baechle
0 siblings, 1 reply; 2+ messages in thread
From: Kip Walker @ 2003-02-20 22:43 UTC (permalink / raw)
To: Ralf Baechle, linux-mips
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: __volatile__ for asms in unaligned.c
2003-02-20 22:43 __volatile__ for asms in unaligned.c Kip Walker
@ 2003-02-21 1:09 ` Ralf Baechle
0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2003-02-21 1:09 UTC (permalink / raw)
To: Kip Walker; +Cc: linux-mips
On Thu, Feb 20, 2003 at 02:43:58PM -0800, Kip Walker wrote:
> 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'."
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-02-21 1:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-20 22:43 __volatile__ for asms in unaligned.c Kip Walker
2003-02-21 1:09 ` Ralf Baechle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox