qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

seqlock: fix seqlock_write_unlock_impl function

The seqlock write unlock function was incorrectly calling
seqlock_write_begin() instead of seqlock_write_end(), and was releasing
the lock before incrementing the sequence. This could lead to a race
condition and a corrupted sequence number becoming odd even though the
lock is not held.

Signed-off-by: Luc Michel <luc.michel@greensocs.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200129144948.2161551-1-luc.michel@greensocs.com>
Fixes: 988fcafc73 ("seqlock: add QemuLockable support", 2018-08-23)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Luc Michel and committed by
Paolo Bonzini
e261b368 4903602e

+2 -2
+2 -2
include/qemu/seqlock.h
··· 55 55 #define seqlock_write_lock(sl, lock) \ 56 56 seqlock_write_lock_impl(sl, QEMU_MAKE_LOCKABLE(lock)) 57 57 58 - /* Lock out other writers and update the count. */ 58 + /* Update the count and release the lock. */ 59 59 static inline void seqlock_write_unlock_impl(QemuSeqLock *sl, QemuLockable *lock) 60 60 { 61 + seqlock_write_end(sl); 61 62 qemu_lockable_unlock(lock); 62 - seqlock_write_begin(sl); 63 63 } 64 64 #define seqlock_write_unlock(sl, lock) \ 65 65 seqlock_write_unlock_impl(sl, QEMU_MAKE_LOCKABLE(lock))