diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-01-04 17:43:01 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-01-04 17:43:01 +0000 |
commit | 1376847f9f003a5a1c7f62a1425352d397348ba7 (patch) | |
tree | b9da81c212eff102cc9abae6c852868da84319ff /cpu-exec.c | |
parent | 17348a7f5ed81bfd58cacdf911a75c558aa0fc8f (diff) | |
download | hqemu-1376847f9f003a5a1c7f62a1425352d397348ba7.zip hqemu-1376847f9f003a5a1c7f62a1425352d397348ba7.tar.gz |
support for new TLB handling
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@513 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'cpu-exec.c')
-rw-r--r-- | cpu-exec.c | 49 |
1 files changed, 47 insertions, 2 deletions
@@ -262,7 +262,42 @@ int cpu_exec(CPUState *env1) tb = tb_find(&ptb, (unsigned long)pc, (unsigned long)cs_base, flags); if (!tb) { + TranslationBlock **ptb1; + unsigned int h; + target_ulong phys_pc, phys_page1, phys_page2, virt_page2; + + spin_lock(&tb_lock); + + tb_invalidated_flag = 0; + + /* find translated block using physical mappings */ + phys_pc = get_phys_addr_code(env, (unsigned long)pc); + phys_page1 = phys_pc & TARGET_PAGE_MASK; + phys_page2 = -1; + h = tb_phys_hash_func(phys_pc); + ptb1 = &tb_phys_hash[h]; + for(;;) { + tb = *ptb1; + if (!tb) + goto not_found; + if (tb->pc == (unsigned long)pc && + tb->page_addr[0] == phys_page1 && + tb->cs_base == (unsigned long)cs_base && + tb->flags == flags) { + /* check next page if needed */ + virt_page2 = ((unsigned long)pc + tb->size - 1) & TARGET_PAGE_MASK; + if (((unsigned long)pc & TARGET_PAGE_MASK) != virt_page2) { + phys_page2 = get_phys_addr_code(env, virt_page2); + if (tb->page_addr[1] == phys_page2) + goto found; + } else { + goto found; + } + } + ptb1 = &tb->phys_hash_next; + } + not_found: /* if no translated code available, then translate it now */ tb = tb_alloc((unsigned long)pc); if (!tb) { @@ -278,8 +313,18 @@ int cpu_exec(CPUState *env1) tb->tc_ptr = tc_ptr; tb->cs_base = (unsigned long)cs_base; tb->flags = flags; - tb_invalidated_flag = 0; cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size); + code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1)); + + /* check next page if needed */ + virt_page2 = ((unsigned long)pc + tb->size - 1) & TARGET_PAGE_MASK; + phys_page2 = -1; + if (((unsigned long)pc & TARGET_PAGE_MASK) != virt_page2) { + phys_page2 = get_phys_addr_code(env, virt_page2); + } + tb_link_phys(tb, phys_pc, phys_page2); + + found: if (tb_invalidated_flag) { /* as some TB could have been invalidated because of memory exceptions while generating the code, we @@ -289,10 +334,10 @@ int cpu_exec(CPUState *env1) ptb = &(*ptb)->hash_next; T0 = 0; } + /* we add the TB in the virtual pc hash table */ *ptb = tb; tb->hash_next = NULL; tb_link(tb); - code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1)); spin_unlock(&tb_lock); } #ifdef DEBUG_EXEC |