Home | History | Annotate | Download | only in qemu

Lines Matching defs:tb

56 /* make various TB consistency checks */
64 /* TB consistency checks only implemented for usermode emulation. */
680 TranslationBlock *tb;
684 for(tb = tb_phys_hash[i]; tb != NULL; tb = tb->phys_hash_next) {
685 if (!(address + TARGET_PAGE_SIZE <= tb->pc ||
686 address >= tb->pc + tb->size)) {
689 address, (long)tb->pc, tb->size);
698 TranslationBlock *tb;
702 for(tb = tb_phys_hash[i]; tb != NULL; tb = tb->phys_hash_next) {
703 flags1 = page_get_flags(tb->pc);
704 flags2 = page_get_flags(tb->pc + tb->size - 1);
707 (long)tb->pc, tb->size, flags1, flags2);
715 /* invalidate one TB */
716 static inline void tb_remove(TranslationBlock **ptb, TranslationBlock *tb,
722 if (tb1 == tb) {
730 static inline void tb_page_remove(TranslationBlock **ptb, TranslationBlock *tb)
739 if (tb1 == tb) {
747 static inline void tb_jmp_remove(TranslationBlock *tb, int n)
752 ptb = &tb->jmp_next[n];
755 /* find tb(n) in circular list */
760 if (n1 == n && tb1 == tb)
768 /* now we can suppress tb(n) from the list */
769 *ptb = tb->jmp_next[n];
771 tb->jmp_next[n] = NULL;
775 /* reset the jump entry 'n' of a TB so that it is not chained to
776 another TB */
777 static inline void tb_reset_jump(TranslationBlock *tb, int n)
779 tb_set_jmp_target(tb, n, (unsigned long)(tb->tc_ptr + tb->tb_next_offset[n]));
782 void tb_phys_invalidate(TranslationBlock *tb, target_ulong page_addr)
790 /* remove the TB from the hash list */
791 phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
793 tb_remove(&tb_phys_hash[h], tb,
796 /* remove the TB from the page list */
797 if (tb->page_addr[0] != page_addr) {
798 p = page_find(tb->page_addr[0] >> TARGET_PAGE_BITS);
799 tb_page_remove(&p->first_tb, tb);
802 if (tb->page_addr[1] != -1 && tb->page_addr[1] != page_addr) {
803 p = page_find(tb->page_addr[1] >> TARGET_PAGE_BITS);
804 tb_page_remove(&p->first_tb, tb);
810 /* remove the TB from the hash list */
811 h = tb_jmp_cache_hash_func(tb->pc);
813 if (env->tb_jmp_cache[h] == tb)
817 /* suppress this TB from the two jump lists */
818 tb_jmp_remove(tb, 0);
819 tb_jmp_remove(tb, 1);
821 /* suppress any remaining jumps to this TB */
822 tb1 = tb->jmp_first;
833 tb->jmp_first = (TranslationBlock *)((long)tb | 2); /* fail safe */
836 if (tb->tpc2gpc != NULL) {
837 qemu_free(tb->tpc2gpc);
838 tb->tpc2gpc = NULL;
839 tb->tpc2gpc_pairs = 0;
876 TranslationBlock *tb;
880 tb = p->first_tb;
881 while (tb != NULL) {
882 n = (long)tb & 3;
883 tb = (TranslationBlock *)((long)tb & ~3);
884 /* NOTE: this is subtle as a TB may span two physical pages */
888 tb_start = tb->pc & ~TARGET_PAGE_MASK;
889 tb_end = tb_start + tb->size;
894 tb_end = ((tb->pc + tb->size) & ~TARGET_PAGE_MASK);
897 tb = tb->page_next[n];
905 TranslationBlock *tb;
911 tb = tb_alloc(pc);
912 if (!tb) {
916 tb = tb_alloc(pc);
917 /* Don't forget to invalidate previous TB info. */
921 tb->tc_ptr = tc_ptr;
922 tb->cs_base = cs_base;
923 tb->flags = flags;
924 tb->cflags = cflags;
926 tb->bb_rec = NULL;
927 tb->prev_time = 0;
929 cpu_gen_code(env, tb, &code_gen_size);
933 virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
938 tb_link_phys(tb, phys_pc, phys_page2);
939 return tb;
946 TB if code is modified inside this TB. */
950 TranslationBlock *tb, *tb_next, *saved_tb;
976 tb = p->first_tb;
977 while (tb != NULL) {
978 n = (long)tb & 3;
979 tb = (TranslationBlock *)((long)tb & ~3);
980 tb_next = tb->page_next[n];
981 /* NOTE: this is subtle as a TB may span two physical pages */
985 tb_start = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
986 tb_end = tb_start + tb->size;
988 tb_start = tb->page_addr[1];
989 tb_end = tb_start + ((tb->pc + tb->size) & ~TARGET_PAGE_MASK);
1001 if (current_tb == tb &&
1003 /* If we are modifying the current TB, we must stop
1022 tb_phys_invalidate(tb, -1);
1029 tb = tb_next;
1083 TranslationBlock *tb;
1099 tb = p->first_tb;
1101 if (tb && pc != 0) {
1105 while (tb != NULL) {
1106 n = (long)tb & 3;
1107 tb = (TranslationBlock *)((long)tb & ~3);
1109 if (current_tb == tb &&
1111 /* If we are modifying the current TB, we must stop
1123 tb_phys_invalidate(tb, addr);
1124 tb = tb->page_next[n];
1140 /* add the tb in the target page and protect it if necessary */
1141 static inline void tb_alloc_page(TranslationBlock *tb,
1147 tb->page_addr[n] = page_addr;
1149 tb->page_next[n] = p->first_tb;
1151 p->first_tb = (TranslationBlock *)((long)tb | n);
1185 protected. So we handle the case where only the first TB is
1199 TranslationBlock *tb;
1204 tb = &tbs[nb_tbs++];
1205 tb->pc = pc;
1206 tb->cflags = 0;
1208 tb->tpc2gpc = NULL;
1209 tb->tpc2gpc_pairs = 0;
1211 return tb;
1214 void tb_free(TranslationBlock *tb)
1216 /* In practice this is mostly used for single use temporary TB
1217 Ignore the hard cases and just back up if this TB happens to
1219 if (nb_tbs > 0 && tb == &tbs[nb_tbs - 1]) {
1220 code_gen_ptr = tb->tc_ptr;
1225 /* add a new TB and link it to the physical page tables. phys_page2 is
1226 (-1) to indicate that only one page contains the TB. */
1227 void tb_link_phys(TranslationBlock *tb,
1233 /* Grab the mmap lock to stop another thread invalidating this TB
1239 tb->phys_hash_next = *ptb;
1240 *ptb = tb;
1243 tb_alloc_page(tb, 0, phys_pc & TARGET_PAGE_MASK);
1245 tb_alloc_page(tb, 1, phys_page2);
1247 tb->page_addr[1] = -1;
1249 tb->jmp_first = (TranslationBlock *)((long)tb | 2);
1250 tb->jmp_next[0] = NULL;
1251 tb->jmp_next[1] = NULL;
1254 if (tb->tb_next_offset[0] != 0xffff)
1255 tb_reset_jump(tb, 0);
1256 if (tb->tb_next_offset[1] != 0xffff)
1257 tb_reset_jump(tb, 1);
1265 /* find the TB 'tb' such that tb[0].tc_ptr <= tc_ptr <
1266 tb[1].tc_ptr. Return NULL if not found */
1271 TranslationBlock *tb;
1283 tb = &tbs[m];
1284 v = (unsigned long)tb->tc_ptr;
1286 return tb;
1296 static void tb_reset_jump_recursive(TranslationBlock *tb);
1298 static inline void tb_reset_jump_recursive2(TranslationBlock *tb, int n)
1303 tb1 = tb->jmp_next[n];
1313 /* we are now sure now that tb jumps to tb1 */
1316 /* remove tb from the jmp_first list */
1322 if (n1 == n && tb1 == tb)
1326 *ptb = tb->jmp_next[n];
1327 tb->jmp_next[n] = NULL;
1329 /* suppress the jump to next tb in generated code */
1330 tb_reset_jump(tb, n);
1332 /* suppress jumps in the tb on which we could have jumped */
1337 static void tb_reset_jump_recursive(TranslationBlock *tb)
1339 tb_reset_jump_recursive2(tb, 0);
1340 tb_reset_jump_recursive2(tb, 1);
1562 /* FIXME: TB unchaining isn't SMP safe. For now just ignore the
1566 TranslationBlock *tb;
1570 tb = env->current_tb;
1572 all the potentially executing TB */
1573 if (tb) {
1575 tb_reset_jump_recursive(tb);
1625 "show generated host assembly code for each compiled TB" },
1627 "show target assembly code for each compiled TB" },
1629 "show micro ops for each compiled TB" },
1639 "show trace before each executed TB (lots of logs)" },
1775 /* Discard jump cache entries for any tb which might potentially
1795 /* must reset current TB so that interrupts cannot modify the
1840 /* must reset current TB so that interrupts cannot modify the
2941 TranslationBlock *tb;
2947 /* We re-entered the check after replacing the TB. Now raise
2960 tb = tb_find_pc(env->mem_io_pc);
2961 if (!tb) {
2962 cpu_abort(env, "check_watchpoint: could not find TB for "
2965 cpu_restore_state(tb, env, env->mem_io_pc);
2966 tb_phys_invalidate(tb, -1);
3836 must be at the end of the TB */
3839 TranslationBlock *tb;
3844 tb = tb_find_pc((unsigned long)retaddr);
3845 if (!tb) {
3846 cpu_abort(env, "cpu_io_recompile: could not find TB for pc=%p",
3849 n = env->icount_decr.u16.low + tb->icount;
3850 cpu_restore_state(tb, env, (unsigned long)retaddr);
3854 /* Generate a new TB ending on the I/O insn. */
3857 they were already the first instruction in the TB. If this is not
3858 the first instruction in a TB then re-execute the preceding
3876 cpu_abort(env, "TB too big during recompile");
3879 pc = tb->pc;
3880 cs_base = tb->cs_base;
3881 flags = tb->flags;
3882 tb_phys_invalidate(tb, -1);
3886 /* TODO: If env->pc != tb->pc (i.e. the faulting instruction was not
3887 the first in the TB) then we end up generating a whole new TB and
3890 second new TB. */
3900 TranslationBlock *tb;
3908 tb = &tbs[i];
3909 target_code_size += tb->size;
3910 if (tb->size > max_target_code_size)
3911 max_target_code_size = tb->size;
3912 if (tb->page_addr[1] != -1)
3914 if (tb->tb_next_offset[0] != 0xffff) {
3916 if (tb->tb_next_offset[1] != 0xffff) {
3925 cpu_fprintf(f, "TB count %d/%d\n",
3927 cpu_fprintf(f, "TB avg target size %d max=%d bytes\n",
3930 cpu_fprintf(f, "TB avg host size %td bytes (expansion ratio: %0.1f)\n",
3933 cpu_fprintf(f, "cross page TB count %d (%d%%)\n",
3942 cpu_fprintf(f, "TB flush count %d\n", tb_flush_count);
3943 cpu_fprintf(f, "TB invalidate count %d\n", tb_phys_invalidate_count);