On 02/09/2018 02:45 AM, Paolo Bonzini wrote: > There is a race between TCG and accesses to the dirty log: > > vCPU thread reader thread > ----------------------- ----------------------- > TLB check -> slow path > notdirty_mem_write > write to RAM > set dirty flag > clear dirty flag > TLB check -> fast path > read memory > write to RAM > > Fortunately, in order to fix it, no change is required to the > vCPU thread. However, the reader thread must delay the read after > the vCPU thread has finished the write. This can be approximated > conservatively by run_on_cpu, which waits for the end of the current > translation block. > > A similar technique is used by KVM, which has to do a synchronous TLB > flush after doing a test-and-clear of the dirty-page flags. > > Reported-by: Dr. David Alan Gilbert <dgilb...@redhat.com> > Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> > --- > exec.c | 31 +++++++++++++++++++++++++++++++ > include/exec/memory.h | 12 ++++++++++++ > memory.c | 10 +++++++++- > migration/ram.c | 1 + > 4 files changed, 53 insertions(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.hender...@linaro.org> r~