linux-mips
[Top] [All Lists]

__volatile__ for asms in unaligned.c

To: "Ralf Baechle" <ralf@linux-mips.org>, linux-mips@linux-mips.org
Subject: __volatile__ for asms in unaligned.c
From: "Kip Walker" <kwalker@broadcom.com>
Date: Thu, 20 Feb 2003 14:43:58 -0800
Organization: Broadcom Corp. BPBU
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
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


<Prev in Thread] Current Thread [Next in Thread>