]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: check alignment of 8-byte atomic loads and stores on 386
authorAustin Clements <austin@google.com>
Thu, 29 Jan 2015 16:54:45 +0000 (11:54 -0500)
committerAustin Clements <austin@google.com>
Thu, 29 Jan 2015 17:34:40 +0000 (17:34 +0000)
commit7a71726b1f0b54b9241730e4bf7a5073676f17fa
treec9f9c463bdbf18a82456170ca1adf9739552e418
parent83c10b204d619d18100716c9588404200acdf6e0
runtime: check alignment of 8-byte atomic loads and stores on 386

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/3521
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/asm_386.s
src/runtime/runtime.go
src/runtime/runtime1.go