On 06/03/2017 11:28, Alex Bennée wrote: >> This can be called from gdbstub, so you need to put the lock/unlock >> around helper_wrpsr's call to cpu_put_psr instead. Also please add a >> comment /* Called with BQL held. */ around cpu_put_psr. > > OK will do. I have to say its hard to see the gdbstub being under the > BQL. Is this a feature of the packet handling being done in the main IO > thread?
Yes. It's probably nigh time to have stronger debug facilities for locks, including changing our lock policy comments to optional assertions. I'm even thinking of doing something like C++'s std::unique_lock, for example // Takes a lock and unlocks it when the scope is left. // c++: std::lock_guard<std::mutex> sl(some_lock); QEMU_SCOPED_MUTEX(QemuMutex, some_lock) sl; // The lock is also unlocked correctly when the scope is left. // c++: std::unique_lock<std::mutex> sl(some_lock); QEMU_SCOPED_MUTEX(QemuMutex, some_lock) sl; ... for (;;) { qemu_scoped_mutex_unlock(&sl); if (foo) { break; } ... qemu_scoped_mutex_lock(&sl); } // The lock is taken later. // c++: std::unique_lock<std::mutex> sl(some_lock, std::defer_lock); QEMU_SCOPED_MUTEX_DEFER(QemuMutex, some_lock) sl; ... if (x) { qemu_scoped_mutex_lock(&sl); } Paolo