qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] QEMU TB lookup


From: 陳韋任
Subject: Re: [Qemu-devel] QEMU TB lookup
Date: Thu, 22 Sep 2011 09:30:21 +0800
User-agent: Mutt/1.5.21 (2010-09-15)

> I am studying QEMU, I would like to know that Is QEMU TB lookup based on
> guest system virtual address or physical address ?

  QEMU lookups TB in two steps:

tb_find_fast (exec.c):

  It'll try to use guest virtual address (pc) to index tb_jmp_cache.
    
    tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];

Then it'll check if there is a hit or not. Also check the finded TB
is valid or not.

    if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||
                 tb->flags != flags)) {
        tb = tb_find_slow(env, pc, cs_base, flags);
    }

tb_find_slow (exec.c):

  If tb_find_fast fail to find a TB by using guest virtual address (pc),
then it comes to tb_find_slow. tb_find_slow use pc's corresponding
guest physical address to index tb_phys_hash.

    /* find translated block using physical mappings */
    phys_pc = get_page_addr_code(env, pc);
    phys_page1 = phys_pc & TARGET_PAGE_MASK;
    h = tb_phys_hash_func(phys_pc);
    ptb1 = &tb_phys_hash[h];

Then it'll check if there is a hit or not. Also check the finded TB
is valid or not. If tb_phys_hash hit and the finded TB is valid, then
it goes to lable found:

 found:
    /* we add the TB in the virtual pc hash table */
    env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;

Otherwise, it goes to lable not_found:

 not_found:
   /* if no translated code available, then translate it now */
    tb = tb_gen_code(env, pc, cs_base, flags, 0);


Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667



reply via email to

[Prev in Thread] Current Thread [Next in Thread]