Home | History | Annotate | Download | only in qemu

Lines Matching refs:tb

54 /* make various TB consistency checks */
62 /* TB consistency checks only implemented for usermode emulation. */
670 TranslationBlock *tb;
674 for(tb = tb_phys_hash[i]; tb != NULL; tb = tb->phys_hash_next) {
675 if (!(address + TARGET_PAGE_SIZE <= tb->pc ||
676 address >= tb->pc + tb->size)) {
679 address, (long)tb->pc, tb->size);
688 TranslationBlock *tb;
692 for(tb = tb_phys_hash[i]; tb != NULL; tb = tb->phys_hash_next) {
693 flags1 = page_get_flags(tb->pc);
694 flags2 = page_get_flags(tb->pc + tb->size - 1);
697 (long)tb->pc, tb->size, flags1, flags2);
705 /* invalidate one TB */
706 static inline void tb_remove(TranslationBlock **ptb, TranslationBlock *tb,
712 if (tb1 == tb) {
720 static inline void tb_page_remove(TranslationBlock **ptb, TranslationBlock *tb)
729 if (tb1 == tb) {
737 static inline void tb_jmp_remove(TranslationBlock *tb, int n)
742 ptb = &tb->jmp_next[n];
745 /* find tb(n) in circular list */
750 if (n1 == n && tb1 == tb)
758 /* now we can suppress tb(n) from the list */
759 *ptb = tb->jmp_next[n];
761 tb->jmp_next[n] = NULL;
765 /* reset the jump entry 'n' of a TB so that it is not chained to
766 another TB */
767 static inline void tb_reset_jump(TranslationBlock *tb, int n)
769 tb_set_jmp_target(tb, n, (unsigned long)(tb->tc_ptr + tb->tb_next_offset[n]));
772 void tb_phys_invalidate(TranslationBlock *tb, target_ulong page_addr)
780 /* remove the TB from the hash list */
781 phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
783 tb_remove(&tb_phys_hash[h], tb,
786 /* remove the TB from the page list */
787 if (tb->page_addr[0] != page_addr) {
788 p = page_find(tb->page_addr[0] >> TARGET_PAGE_BITS);
789 tb_page_remove(&p->first_tb, tb);
792 if (tb->page_addr[1] != -1 && tb->page_addr[1] != page_addr) {
793 p = page_find(tb->page_addr[1] >> TARGET_PAGE_BITS);
794 tb_page_remove(&p->first_tb, tb);
800 /* remove the TB from the hash list */
801 h = tb_jmp_cache_hash_func(tb->pc);
803 if (env->tb_jmp_cache[h] == tb)
807 /* suppress this TB from the two jump lists */
808 tb_jmp_remove(tb, 0);
809 tb_jmp_remove(tb, 1);
811 /* suppress any remaining jumps to this TB */
812 tb1 = tb->jmp_first;
823 tb->jmp_first = (TranslationBlock *)((long)tb | 2); /* fail safe */
826 if (tb->tpc2gpc != NULL) {
827 qemu_free(tb->tpc2gpc);
828 tb->tpc2gpc = NULL;
829 tb->tpc2gpc_pairs = 0;
866 TranslationBlock *tb;
870 tb = p->first_tb;
871 while (tb != NULL) {
872 n = (long)tb & 3;
873 tb = (TranslationBlock *)((long)tb & ~3);
874 /* NOTE: this is subtle as a TB may span two physical pages */
878 tb_start = tb->pc & ~TARGET_PAGE_MASK;
879 tb_end = tb_start + tb->size;
884 tb_end = ((tb->pc + tb->size) & ~TARGET_PAGE_MASK);
887 tb = tb->page_next[n];
895 TranslationBlock *tb;
901 tb = tb_alloc(pc);
902 if (!tb) {
906 tb = tb_alloc(pc);
907 /* Don't forget to invalidate previous TB info. */
911 tb->tc_ptr = tc_ptr;
912 tb->cs_base = cs_base;
913 tb->flags = flags;
914 tb->cflags = cflags;
916 tb->bb_rec = NULL;
917 tb->prev_time = 0;
919 cpu_gen_code(env, tb, &code_gen_size);
923 virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
928 tb_link_phys(tb, phys_pc, phys_page2);
929 return tb;
936 TB if code is modified inside this TB. */
940 TranslationBlock *tb, *tb_next, *saved_tb;
966 tb = p->first_tb;
967 while (tb != NULL) {
968 n = (long)tb & 3;
969 tb = (TranslationBlock *)((long)tb & ~3);
970 tb_next = tb->page_next[n];
971 /* NOTE: this is subtle as a TB may span two physical pages */
975 tb_start = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
976 tb_end = tb_start + tb->size;
978 tb_start = tb->page_addr[1];
979 tb_end = tb_start + ((tb->pc + tb->size) & ~TARGET_PAGE_MASK);
991 if (current_tb == tb &&
993 /* If we are modifying the current TB, we must stop
1013 tb_phys_invalidate(tb, -1);
1020 tb = tb_next;
1074 TranslationBlock *tb;
1090 tb = p->first_tb;
1092 if (tb && pc != 0) {
1096 while (tb != NULL) {
1097 n = (long)tb & 3;
1098 tb = (TranslationBlock *)((long)tb & ~3);
1100 if (current_tb == tb &&
1102 /* If we are modifying the current TB, we must stop
1114 tb_phys_invalidate(tb, addr);
1115 tb = tb->page_next[n];
1131 /* add the tb in the target page and protect it if necessary */
1132 static inline void tb_alloc_page(TranslationBlock *tb,
1138 tb->page_addr[n] = page_addr;
1140 tb->page_next[n] = p->first_tb;
1142 p->first_tb = (TranslationBlock *)((long)tb | n);
1176 protected. So we handle the case where only the first TB is
1190 TranslationBlock *tb;
1195 tb = &tbs[nb_tbs++];
1196 tb->pc = pc;
1197 tb->cflags = 0;
1199 tb->tpc2gpc = NULL;
1200 tb->tpc2gpc_pairs = 0;
1202 return tb;
1205 void tb_free(TranslationBlock *tb)
1207 /* In practice this is mostly used for single use temporary TB
1208 Ignore the hard cases and just back up if this TB happens to
1210 if (nb_tbs > 0 && tb == &tbs[nb_tbs - 1]) {
1211 code_gen_ptr = tb->tc_ptr;
1216 /* add a new TB and link it to the physical page tables. phys_page2 is
1217 (-1) to indicate that only one page contains the TB. */
1218 void tb_link_phys(TranslationBlock *tb,
1224 /* Grab the mmap lock to stop another thread invalidating this TB
1230 tb->phys_hash_next = *ptb;
1231 *ptb = tb;
1234 tb_alloc_page(tb, 0, phys_pc & TARGET_PAGE_MASK);
1236 tb_alloc_page(tb, 1, phys_page2);
1238 tb->page_addr[1] = -1;
1240 tb->jmp_first = (TranslationBlock *)((long)tb | 2);
1241 tb->jmp_next[0] = NULL;
1242 tb->jmp_next[1] = NULL;
1245 if (tb->tb_next_offset[0] != 0xffff)
1246 tb_reset_jump(tb, 0);
1247 if (tb->tb_next_offset[1] != 0xffff)
1248 tb_reset_jump(tb, 1);
1256 /* find the TB 'tb' such that tb[0].tc_ptr <= tc_ptr <
1257 tb[1].tc_ptr. Return NULL if not found */
1262 TranslationBlock *tb;
1274 tb = &tbs[m];
1275 v = (unsigned long)tb->tc_ptr;
1277 return tb;
1287 static void tb_reset_jump_recursive(TranslationBlock *tb);
1289 static inline void tb_reset_jump_recursive2(TranslationBlock *tb, int n)
1294 tb1 = tb->jmp_next[n];
1304 /* we are now sure now that tb jumps to tb1 */
1307 /* remove tb from the jmp_first list */
1313 if (n1 == n && tb1 == tb)
1317 *ptb = tb->jmp_next[n];
1318 tb->jmp_next[n] = NULL;
1320 /* suppress the jump to next tb in generated code */
1321 tb_reset_jump(tb, n);
1323 /* suppress jumps in the tb on which we could have jumped */
1328 static void tb_reset_jump_recursive(TranslationBlock *tb)
1330 tb_reset_jump_recursive2(tb, 0);
1331 tb_reset_jump_recursive2(tb, 1);
1553 /* FIXME: TB unchaining isn't SMP safe. For now just ignore the
1557 TranslationBlock *tb;
1560 tb = env->current_tb;
1562 all the potentially executing TB */
1563 if (tb && !testandset(&interrupt_lock)) {
1565 tb_reset_jump_recursive(tb);
1615 "show generated host assembly code for each compiled TB" },
1617 "show target assembly code for each compiled TB" },
1619 "show micro ops for each compiled TB" },
1629 "show trace before each executed TB (lots of logs)" },
1757 /* Discard jump cache entries for any tb which might potentially
1777 /* must reset current TB so that interrupts cannot modify the
1822 /* must reset current TB so that interrupts cannot modify the
2717 TranslationBlock *tb;
2723 /* We re-entered the check after replacing the TB. Now raise
2736 tb = tb_find_pc(env->mem_io_pc);
2737 if (!tb) {
2738 cpu_abort(env, "check_watchpoint: could not find TB for "
2741 cpu_restore_state(tb, env, env->mem_io_pc, NULL);
2742 tb_phys_invalidate(tb, -1);
3617 must be at the end of the TB */
3620 TranslationBlock *tb;
3625 tb = tb_find_pc((unsigned long)retaddr);
3626 if (!tb) {
3627 cpu_abort(env, "cpu_io_recompile: could not find TB for pc=%p",
3630 n = env->icount_decr.u16.low + tb->icount;
3631 cpu_restore_state(tb, env, (unsigned long)retaddr, NULL);
3635 /* Generate a new TB ending on the I/O insn. */
3638 they were already the first instruction in the TB. If this is not
3639 the first instruction in a TB then re-execute the preceding
3657 cpu_abort(env, "TB too big during recompile");
3660 pc = tb->pc;
3661 cs_base = tb->cs_base;
3662 flags = tb->flags;
3663 tb_phys_invalidate(tb, -1);
3667 /* TODO: If env->pc != tb->pc (i.e. the faulting instruction was not
3668 the first in the TB) then we end up generating a whole new TB and
3671 second new TB. */
3680 TranslationBlock *tb;
3688 tb = &tbs[i];
3689 target_code_size += tb->size;
3690 if (tb->size > max_target_code_size)
3691 max_target_code_size = tb->size;
3692 if (tb->page_addr[1] != -1)
3694 if (tb->tb_next_offset[0] != 0xffff) {
3696 if (tb->tb_next_offset[1] != 0xffff) {
3705 cpu_fprintf(f, "TB count %d/%d\n",
3707 cpu_fprintf(f, "TB avg target size %d max=%d bytes\n",
3710 cpu_fprintf(f, "TB avg host size %d bytes (expansion ratio: %0.1f)\n",
3713 cpu_fprintf(f, "cross page TB count %d (%d%%)\n",
3722 cpu_fprintf(f, "TB flush count %d\n", tb_flush_count);
3723 cpu_fprintf(f, "TB invalidate count %d\n", tb_phys_invalidate_count);