qemu中执行块的时间
time of executing block in qemu
我想问一个关于在QEMU中执行翻译块时获取时间信息的问题
事实上我正在使用这个功能
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
但我不确定它 returns 在来宾处理器中执行翻译块的时间。
所以有人可以给我一些提示吗?
谢谢
非 KVM,soft-mmu qemu!!!:
qemu_clock_get_ns(QEMUClockType 类型) 表示指定的 qemu 参考时钟经过的纳秒。有几个参考时钟:
实时、虚拟、主机等。QEMU_CLOCK_VIRTUAL 是由 qemu 主循环显式驱动的计数器:该时钟的一个滴答是模拟的时间量(纳秒)。
详情:
QEMU 假设:
1 guest instruction counter tick = 1 emulated nano second << icount_time_shift
icount_time_shift由“-icount”命令行选项指定,默认为3。
所有 qemu 计时器都实现为截止时间(以 QEMU_CLOCK_VIRTUAL 为单位),并且 qemu 执行从一个截止时间到另一个截止时间的转换块。从 ns 到 icount 的直接对话提供了确定性的 tb 生成:QEMU 主循环根据翻译时执行的指令数量推进时钟 block/chain(参见 cpu_exec.c,这里是抽象伪代码):
cpu_exec(CPUState env):
# jump here if any synchronous exception occurs: page fault, protection and etc
if(setjmp(env) == exeption)
;#fall through
for(;;):
# if exception/interrupt is pending then handle it here
take_exception_or_interrupt();
while(no_interrupts()) {
# get num instructions that left till next deadline
icount_extra = get_icount_limit();
# find/generate tb accordnace to icount_extra
# Also every instruction that access to IO is the last instruction at block.
# if access to IO cause interrupt we handle it on next iteration
tb = find_tb(env, icount_extra);
# execute tb or tb chain
execute(env, tb);
# increment QEMU_CLOCK_VIRTUAL accordance to guest instructions was executed
# (syncronise with iothread)
update_clock(tb.executed_instr);
# we will take all interrupts at next iteration
QEMU_CLOCK_VIRTUAL 提供的时间间隔用于客户机的所有型号 timers/counters:例如,如果您将主板系统计数器频率设置为 62 MHz,则 qemu 每 16 次对该计数器进行一次递增QEMU_CLOCK_VIRTUAL.
的增量
然后您可以使用 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) 在您的来宾模型上获得模拟的纳秒间隔。
我想问一个关于在QEMU中执行翻译块时获取时间信息的问题
事实上我正在使用这个功能
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
但我不确定它 returns 在来宾处理器中执行翻译块的时间。
所以有人可以给我一些提示吗?
谢谢
非 KVM,soft-mmu qemu!!!:
qemu_clock_get_ns(QEMUClockType 类型) 表示指定的 qemu 参考时钟经过的纳秒。有几个参考时钟: 实时、虚拟、主机等。QEMU_CLOCK_VIRTUAL 是由 qemu 主循环显式驱动的计数器:该时钟的一个滴答是模拟的时间量(纳秒)。
详情: QEMU 假设:
1 guest instruction counter tick = 1 emulated nano second << icount_time_shift
icount_time_shift由“-icount”命令行选项指定,默认为3。
所有 qemu 计时器都实现为截止时间(以 QEMU_CLOCK_VIRTUAL 为单位),并且 qemu 执行从一个截止时间到另一个截止时间的转换块。从 ns 到 icount 的直接对话提供了确定性的 tb 生成:QEMU 主循环根据翻译时执行的指令数量推进时钟 block/chain(参见 cpu_exec.c,这里是抽象伪代码):
cpu_exec(CPUState env):
# jump here if any synchronous exception occurs: page fault, protection and etc
if(setjmp(env) == exeption)
;#fall through
for(;;):
# if exception/interrupt is pending then handle it here
take_exception_or_interrupt();
while(no_interrupts()) {
# get num instructions that left till next deadline
icount_extra = get_icount_limit();
# find/generate tb accordnace to icount_extra
# Also every instruction that access to IO is the last instruction at block.
# if access to IO cause interrupt we handle it on next iteration
tb = find_tb(env, icount_extra);
# execute tb or tb chain
execute(env, tb);
# increment QEMU_CLOCK_VIRTUAL accordance to guest instructions was executed
# (syncronise with iothread)
update_clock(tb.executed_instr);
# we will take all interrupts at next iteration
QEMU_CLOCK_VIRTUAL 提供的时间间隔用于客户机的所有型号 timers/counters:例如,如果您将主板系统计数器频率设置为 62 MHz,则 qemu 每 16 次对该计数器进行一次递增QEMU_CLOCK_VIRTUAL.
的增量然后您可以使用 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) 在您的来宾模型上获得模拟的纳秒间隔。