qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: "Sinha, Ani" <Ani.Sinha@tellabs.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] target_phys_addr_t vs ram_addr_t
Date: Sat, 3 Sep 2011 14:14:11 +0100	[thread overview]
Message-ID: <CAFEAcA8CseSNYfqog6o+83ZNc-5RHV5Z2=sgkGgrg6a1zP6PDQ@mail.gmail.com> (raw)
In-Reply-To: <CAAu8pHv0HNb71-OQAWwebPNmHyHnMgFq16e-qRNQH_oo5ohZVQ@mail.gmail.com>

On 3 September 2011 12:26, Blue Swirl <blauwirbel@gmail.com> wrote:
> On Fri, Sep 2, 2011 at 6:08 AM, Sinha, Ani <Ani.Sinha@tellabs.com> wrote:
>> First off, what is the difference between target_phys_addr_t and
>> ram_addr_t? I believe the former is a virtual address within the guest but
>> what is the later? The comment says "address in ram (different from
>> physical address)" but is this the virtual address or the physical
>> address? Is this for guest or for host?
>
> target_phys_addr_t is used for guest physical addresses. For example,
> i386 guest with PAE would need 36 bits which makes this 64 bit type
> (regardless of host address sizes). Devices should usually only use
> this type.
>
> ram_addr_t (uintptr_t) is linked to the size of host virtual address
> space. Because of how RAM is implemented, we can't give 64 bit guests
> more than 4 GB of RAM on a 32 bit host, so in that case it would be 32
> bits. On a 64 bit host this can be 64 bits. It can be considered as a
> subset of target_phys_addr_t. Normally devices need it only if there
> are RAM areas, like frame buffers.

To add to this and point out some particular wrinkles:
Even if on the guest machine RAM doesn't start at physical address
0, the first bit of RAM will generally be at a zero ram_addr_t.
If the guest machine has some RAM that is mapped at two physical
addresses, then both those target_phys_addr_t values will map to
the same ram_addr_t. This is why you can't just cast a ram_addr_t
to a target_phys_addr_t or vice-versa. (This kind of situation
doesn't happen on the PC but does on some of the embedded boards
qemu models.)

I think of ram_addr_t as being "offset into a big lump of host
memory which we have parcelled out to use as guest RAM".

-- PMM

  reply	other threads:[~2011-09-03 13:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-02  6:08 [Qemu-devel] target_phys_addr_t vs ram_addr_t Sinha, Ani
2011-09-03 11:26 ` Blue Swirl
2011-09-03 13:14   ` Peter Maydell [this message]
2011-09-07 19:25     ` Sinha, Ani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFEAcA8CseSNYfqog6o+83ZNc-5RHV5Z2=sgkGgrg6a1zP6PDQ@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=Ani.Sinha@tellabs.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).