exec.c: Fix breakpoint invalidation race
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 6 Dec 2016 18:07:09 +0000 (18:07 +0000)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 6 Dec 2016 20:21:46 +0000 (20:21 +0000)
commita9353fe897ca2687e5b3385ed39e3db3927a90e0
treecdcbdc899172840177ee1330e69d5a101c07eb6d
parentd750c3a966d6409356739e97fa4d4a6446754e1e
exec.c: Fix breakpoint invalidation race

A bug (1647683) was reported showing a crash when removing
breakpoints.  The reproducer was bisected to 3359baad when tb_flush
was finally made thread safe.  While in MTTCG the locking in
breakpoint_invalidate would have prevented any problems, but
currently tb_lock() is a NOP for system emulation.

The race is between a tb_flush from the gdbstub and the
tb_invalidate_phys_addr() in breakpoint_invalidate().

Ideally we'd have actual locking here; for the moment the
simple fix is to do a full tb_flush() for a bp invalidate,
since that is thread-safe even if no lock is taken.

Reported-by: Julian Brown <julian@codesourcery.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1481047629-7763-1-git-send-email-peter.maydell@linaro.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
exec.c