• Austin Clements's avatar
    runtime: check alignment of 8-byte atomic loads and stores on 386 · 7a71726b
    Austin Clements authored
    Currently, if we do an atomic{load,store}64 of an unaligned address on
    386, we'll simply get a non-atomic load/store.  This has been the
    source of myriad bugs, so add alignment checks to these two
    operations.  These checks parallel the equivalent checks in
    sync/atomic.
    
    The alignment check is not necessary in cas64 because it uses a locked
    instruction.  The CPU will either execute this atomically or raise an
    alignment fault (#AC)---depending on the alignment check flag---either
    of which is fine.
    
    This also fixes the two places in the runtime that trip the new
    checks.  One is in the runtime self-test and shouldn't have caused
    real problems.  The other is in tickspersecond and could, in
    principle, have caused a misread of the ticks per second during
    initialization.
    
    Change-Id: If1796667012a6154f64f5e71d043c7f5fb3dd050
    Reviewed-on: https://go-review.googlesource.com/3521Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    7a71726b
asm_386.s 45.6 KB