Hi, all I am looking for when TB unchaining is needed. Currently, I can only see there are three spots (take i386-softmmu as an example):
1. cpu_interrupt: When virtual devices raise interrupts, eventually apic_local_deliver (apic.c) will call cpu_interrupt. cpu_interrupt will set up env->interrupt_request, then call cpu_unlink_tb to unlink env's TBs. Here I have a question. I though cpu_interrupt is only used in system mode to deliever virtual devices' interrupt. But it seems process mode also has cpu_interrupt. I have ran some small programs in process mode under GDB, but I never see cpu_interrupt is called. Do I have to run something bigger to see when cpu_interrupt is called in process mode? Or cpu_interrupt in process mode is only used in some rare cases? 2. cpu_exit: QEMU will register a host SIGALRM handler, host_alarm_handler (qemu-timer.c), when initialize the enviroment in system mode. Then when host OS delivers SIGALRM to QEMU, host_alarm_handler calls qemu_notify_event -> cpu_exit. cpu_exit raise env->exit_request , then call cpu_unlink_tb to unlink env's TBs. There are other places where cpu_exit is called, like - cpu_signal: I think this is used when IOTHREAD is enabled. - DMA_init: I guess cpu_exit is called when DMA is done so that control is gave back to QEMU from the code cache. - gdb_do_syscall: Don't know when it get called. - vm_stop -> cpu_stop_current: Don't know when it get called. 3. tb_phys_invalidate: QEMU will invalidate TBs related to a guest page which is done by tb_invalidate_phys_page_range (exec.c), then tb_invalidate_phys_page_range calls tb_phys_invalidate to invalidate a TB and unlink links to the TB. Please correct me if I am wrong or something miss. Thanks! Regards, chenwj -- Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667