summaryrefslogtreecommitdiff
path: root/cpu-exec.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-11-19 22:12:02 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-11-19 22:12:02 +0000
commit36bdbe5479cebb5765779a430d14daddddcab871 (patch)
tree092cd5144d8eac0007b39b3ff7fea281818e3533 /cpu-exec.c
parent8004340674c4b014e18357acfbcaa24d10ec9c22 (diff)
downloadqemu-36bdbe5479cebb5765779a430d14daddddcab871.tar.gz
fixed TB linking in case of code invalidation (fixes random segfaults)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@469 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'cpu-exec.c')
-rw-r--r--cpu-exec.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/cpu-exec.c b/cpu-exec.c
index 1f08934cb7..5bbace345f 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -21,6 +21,8 @@
#include "exec.h"
#include "disas.h"
+int tb_invalidated_flag;
+
//#define DEBUG_EXEC
//#define DEBUG_SIGNAL
@@ -273,8 +275,17 @@ int cpu_exec(CPUState *env1)
tb->tc_ptr = tc_ptr;
tb->cs_base = (unsigned long)cs_base;
tb->flags = flags;
- /* XXX: an MMU exception can occur here */
+ tb_invalidated_flag = 0;
cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size);
+ if (tb_invalidated_flag) {
+ /* as some TB could have been invalidated because
+ of memory exceptions while generating the code, we
+ must recompute the hash index here */
+ ptb = &tb_hash[tb_hash_func((unsigned long)pc)];
+ while (*ptb != NULL)
+ ptb = &(*ptb)->hash_next;
+ T0 = 0;
+ }
*ptb = tb;
tb->hash_next = NULL;
tb_link(tb);