qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: pbonzini@redhat.com, kraxel@redhat.com,
	Laszlo Ersek <lersek@redhat.com>,
	qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH v4 1/2] arch_init: align MR size to target page size
Date: Mon, 19 Aug 2013 20:51:23 +0300	[thread overview]
Message-ID: <20130819175123.GC7737@redhat.com> (raw)
In-Reply-To: <CAFEAcA_SVG_XeT5VnkUm1t8BaaUPGqxS0Feps8vH7TUEvMsqYg@mail.gmail.com>

On Mon, Aug 19, 2013 at 06:45:10PM +0100, Peter Maydell wrote:
> On 19 August 2013 18:37, Laszlo Ersek <lersek@redhat.com> wrote:
> > ((3) memory_region_size() is slightly different from
> > int128_get64(mr->size); it has a special case for int128_2_64() -- and I
> > don't understand that.
> 
> The special case is because valid memory region sizes range
> from 0 to 2^64, *inclusive*. [2^64-sized regions tend to be
> containers representing address spaces like PCI or the system
> memory space.] Inside memory.c we store the size
> in an int128 in the way you'd expect. However some of the
> memory region APIs take or return the size of the region
> as a uint64_t, with the convention that UINT64_MAX means
> "actually 2^64" (with a size of really 2^64 - 1 not being
> valid). So the special case here is doing the conversion
> from an int128 representation of the size to the uint64_t
> representation. You can see the same thing going the other
> way in memory_region_init(), where we take the size as a
> uint64_t and convert it to an int128 with
> 
>     mr->size = int128_make64(size);
>     if (size == UINT64_MAX) {
>         mr->size = int128_2_64();
>     }
> 
> (Note that int128_get64() of an int128 which == 2^64 or
> more will assert, so int128_get64(mr->size) is a bit of a
> code smell; it happens to be OK here because we know that a
> RAM-backed MR will never be a 2^64-sized region.)
> 
> -- PMM

Note code smell is in the original code -
this patch uses the API.
We could add memory_region_get_target_pages
as that will fit in uint64_t.
But other migration code shifts it right back by target page size,
so I don't think it's worth it.

  reply	other threads:[~2013-08-19 17:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19 14:26 [Qemu-devel] [PATCH v4 0/2] future proof rom loading for cross versiom migration Michael S. Tsirkin
2013-08-19 14:26 ` [Qemu-devel] [PATCH v4 1/2] arch_init: align MR size to target page size Michael S. Tsirkin
2013-08-19 17:37   ` Laszlo Ersek
2013-08-19 17:45     ` Peter Maydell
2013-08-19 17:51       ` Michael S. Tsirkin [this message]
2013-08-19 17:48     ` Michael S. Tsirkin
2013-08-19 18:04       ` Laszlo Ersek
2013-08-19 14:26 ` [Qemu-devel] [PATCH v4 2/2] loader: store FW CFG ROM files in RAM Michael S. Tsirkin
2013-08-19 17:28   ` Paolo Bonzini
2013-08-19 17:40     ` Michael S. Tsirkin
2013-08-19 17:50       ` Paolo Bonzini
2013-08-19 18:05   ` Laszlo Ersek
2013-08-19 16:35 ` [Qemu-devel] [PATCH v4 0/2] future proof rom loading for cross versiom migration Peter Maydell

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=20130819175123.GC7737@redhat.com \
    --to=mst@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lersek@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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).