bql: check that the BQL is not dropped within marked sections
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 6 Nov 2024 07:59:07 +0000 (08:59 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 10 Dec 2024 17:49:25 +0000 (18:49 +0100)
commit37fb26601dd156369ebb84096c2ecfbe89f0a83b
treefd230a0b955edccb1b6dea0d87d4a2ff739b4954
parent281305d3e08ac7330dfe7cf7b3978c119a888bad
bql: check that the BQL is not dropped within marked sections

The Big QEMU Lock (BQL) is used to provide interior mutability to Rust
code.  While BqlCell performs indivisible accesses, an equivalent of
RefCell will allow the borrower to hold to the interior content for a
long time.  If the BQL is dropped, another thread could come and mutate
the data from C code (Rust code would panic on borrow_mut() instead).
In order to prevent this, add a new BQL primitive that can mark
BQL-atomic sections and aborts if the BQL is dropped within them.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/qemu/main-loop.h
stubs/iothread-lock.c
system/cpus.c