[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/39] seqlock: use atomic writes for the sequence
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 13/39] seqlock: use atomic writes for the sequence |
Date: |
Fri, 7 Oct 2016 18:57:37 +0200 |
There is a data race if the sequence is written concurrently to the
read. In C11 this has undefined behavior. Use atomic_set; the
read side is already using atomic_read.
Reported-by: Alex Bennée <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Alex Bennée <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/qemu/seqlock.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/qemu/seqlock.h b/include/qemu/seqlock.h
index 2e2be4c..8dee11d 100644
--- a/include/qemu/seqlock.h
+++ b/include/qemu/seqlock.h
@@ -31,7 +31,7 @@ static inline void seqlock_init(QemuSeqLock *sl)
/* Lock out other writers and update the count. */
static inline void seqlock_write_begin(QemuSeqLock *sl)
{
- ++sl->sequence;
+ atomic_set(&sl->sequence, sl->sequence + 1);
/* Write sequence before updating other fields. */
smp_wmb();
@@ -42,7 +42,7 @@ static inline void seqlock_write_end(QemuSeqLock *sl)
/* Write other fields before finalizing sequence. */
smp_wmb();
- ++sl->sequence;
+ atomic_set(&sl->sequence, sl->sequence + 1);
}
static inline unsigned seqlock_read_begin(QemuSeqLock *sl)
--
2.7.4
- [Qemu-devel] [PULL 03/39] hw/misc/edu: support MSI interrupt, (continued)
- [Qemu-devel] [PULL 03/39] hw/misc/edu: support MSI interrupt, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 04/39] intc: add an interface to gather statistics/informations on interrupt controllers, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 05/39] intc/i8259: implement InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 06/39] intc/slavio_intctl: implement InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 07/39] intc/lm32_pic: implement InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 08/39] intc: make HMP 'info irq' and 'info pic' commands use InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 09/39] intc: make HMP 'info irq' and 'info pic' commands available on all targets, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 10/39] atomic.h: fix __SANITIZE_THREAD__ build, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 11/39] atomic.h: comment on use of atomic_read/set, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 12/39] tcg/optimize: move default return out of if statement, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 13/39] seqlock: use atomic writes for the sequence,
Paolo Bonzini <=
- [Qemu-devel] [PULL 14/39] qom/object: update class cache atomically, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 15/39] qom/cpu: atomically clear the tb_jmp_cache, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 16/39] cpu: atomically modify cpu->exit_request, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 17/39] util/qht: atomically set b->hashes, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 18/39] linux-user/syscall: extend lock around cpu-list, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 19/39] qga/command: use QEMU atomic primitives, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 20/39] .travis.yml: add gcc sanitizer build, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 22/39] char: use a fixed idx for child muxed chr, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 21/39] i8259: give ISA device when registering ISA ioports, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 23/39] char: update read handler in all cases, Paolo Bonzini, 2016/10/07