qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Is the return address of get_page_addr_code guest physi


From: Peter Maydell
Subject: Re: [Qemu-devel] Is the return address of get_page_addr_code guest physical address?
Date: Sat, 11 Aug 2012 03:06:23 +0100

On 10 August 2012 19:53, Steven <address@hidden> wrote:
> On Fri, Aug 10, 2012 at 11:47 AM, Peter Maydell
> <address@hidden> wrote:
>> On 10 August 2012 03:11, Steven <address@hidden> 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
>
> My question is related to system mode.
> Is the RAM you mean the guest physical address, which is a continuous
> sequence of numbers beginning from 0 to the max of allocated RAM of
> the guest?
>
>> ram_addr_t is an index into that).
>
> If the returned value of get_page_addr_code is the index to that
> straight line, I am wondering if it is the guest physical address.

No, it is definitely not the guest physical address. Consider
the case where there are two aliases of the same RAM in
guest physical memory -- two physical addresses might
map to a single ram_addr_t. Consider the case where there
is a 'hole' in memory -- ram_addr_t and physical address are
not identical there either.

> So if I want to get the guest physical address (GPA) of a
> tb_page_addr_t, can I do
>   tb_page_addr_t = returned value from get_page_addr_code  + phys_ram_base
> Is this translation correct?

This is wrong on several counts: (a) there's no such thing
as phys_ram_base any more (it was removed several years
ago) and (b) there is no single unique guest physical
address corresponding to a tb_page_addr_t, so what
you are trying to do is not well defined.

What are you trying to do anyway and why do you want
to call get_page_addr_code() ?

-- PMM



reply via email to

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