• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisióncc689485ee3e9dca05765326ee8fd619a6ec48f0 (tree)
Tiempo2017-10-25 05:53:42
AutorEmilio G. Cota <cota@braa...>
CommiterRichard Henderson

Log Message

translate-all: exit from tb_phys_invalidate if qht_remove fails

Two or more threads might race while invalidating the same TB. We currently
do not check for this at all despite taking tb_lock, which means we would
wrongly invalidate the same TB more than once. This bug has actually been
hit by users: I recently saw a report on IRC, although I have yet to see
the corresponding test case.

Fix this by using qht_remove as the synchronization point; if it fails,
that means the TB has already been invalidated, and therefore there
is nothing left to do in tb_phys_invalidate.

Note that this solution works now that we still have tb_lock, and will
continue working once we remove tb_lock.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Emilio G. Cota <cota@braap.org>
Message-Id: <1508445114-4717-1-git-send-email-cota@braap.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Cambiar Resumen

Diferencia incremental

--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -1079,7 +1079,9 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
10791079 phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
10801080 h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK,
10811081 tb->trace_vcpu_dstate);
1082- qht_remove(&tb_ctx.htable, tb, h);
1082+ if (!qht_remove(&tb_ctx.htable, tb, h)) {
1083+ return;
1084+ }
10831085
10841086 /* remove the TB from the page list */
10851087 if (tb->page_addr[0] != page_addr) {