On 10 August 2012 03:11, Steven <wangwangk...@gmail.com> wrote: > The function definition has a return address type tb_page_addr_t. > tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) > > I am wondering is this address the guest physical address or the host > virtual address.
In linux-user mode the returned address is the guest virtual address. In system mode it is a ram_addr_t. (the comment above the implementation says "the returned address is not exactly the physical address: it is the offset relative to phys_ram_base" but this is out of date I think). A ram_addr_t is neither a host address nor a guest physical address but it's closely related to a guest physaddr (you can think of it as if all the RAM in the system was put into a straight line and then the ram_addr_t is an index into that). > If it it is the guest physical address, why does Qemu waste guest > physical space to store these address for tb? Thanks. I'm not sure what you're asking here. This function returns a physical address because we store TCG translated code blocks in a hash table indexed by guest physaddr. Given the information "the CPU is trying to execute code from this physaddr" we need to be able to find out whether we already have a code block translated for that. (there is also a fast code path so we can avoid doing a complete lookup from physaddr most of the time.) -- PMM