diff options
| author | Robert Norton | 2017-09-25 12:28:26 +0100 |
|---|---|---|
| committer | Robert Norton | 2017-09-25 12:28:26 +0100 |
| commit | 8ca00a2729ed477183afeeb1ad20b5a0fc23dc82 (patch) | |
| tree | b9d842087716817741a119d52e23cb41ecf058b9 | |
| parent | 963d4fef5b9c75939b744f1a2e09779859c7c643 (diff) | |
x86: always perform write for cmpxchg by writing back original value if comparison fails. This is specified in manual and also helps RMEM with locked writes.
| -rw-r--r-- | x86/x64.sail | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/x86/x64.sail b/x86/x64.sail index 2f6f07ed..dfa92fd3 100644 --- a/x86/x64.sail +++ b/x86/x64.sail @@ -628,8 +628,12 @@ function clause execute (CMPXCHG (locked, sz,r,n)) = write_binop (locked, sz, Cmp, val_acc, val_dst, src); if val_acc == val_dst then wEA(locked, dst) := EA (false, src) - else + else { wEA(false, acc) := val_dst; + (* write back the original value in dst so that we always + perform locked write after locked read *) + wEA(locked, dst) := val_dst; + } } (* ========================================================================== |
