qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Antonio Caggiano <quic_acaggian@quicinc.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [RFC] mem: Fix mem region size when is UINT64_MAX
Date: Tue, 24 Oct 2023 11:28:37 +0100	[thread overview]
Message-ID: <CAFEAcA86trVBDe4zJr2Zv-EgWReY2M+yvU83Kc_8nGrjP4_tJg@mail.gmail.com> (raw)
In-Reply-To: <20231024094351.50464-1-quic_acaggian@quicinc.com>

On Tue, 24 Oct 2023 at 10:45, Antonio Caggiano
<quic_acaggian@quicinc.com> wrote:
>
> This looks like a bug. When the size is `UINT64_MAX`, it is reset to
> (Int128)`1 << 64` which actually is `UINT64_MAX + 1`.
>
> Then, an assert is triggered when the size is converted back to uin64_t
> by using the int128_get64() function, as the new value happens to be
> different than the previous one.
>
> Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com>
> ---
>  system/memory.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/system/memory.c b/system/memory.c
> index a800fbc9e5..d41fc6af88 100644
> --- a/system/memory.c
> +++ b/system/memory.c
> @@ -1193,9 +1193,6 @@ static void memory_region_do_init(MemoryRegion *mr,
>                                    uint64_t size)
>  {
>      mr->size = int128_make64(size);
> -    if (size == UINT64_MAX) {
> -        mr->size = int128_2_64();
> -    }

No, this is intentional. In these memory region creation APIs
that take a uint64_t size parameter, size == UINT64_MAX is a
special case that means "actually the full 64 bit address space"
(and there is no way to ask for an MR to have a size that is
truly UINT64_MAX bytes). When we create the MR, the size is
stored in the MemoryRegion struct as its true size, because
we have an Int128 field there.

What assertion (with backtrace) is being hit? The issue is
probably at that point, not here.

thanks
-- PMM


  reply	other threads:[~2023-10-24 10:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24  9:43 [RFC] mem: Fix mem region size when is UINT64_MAX Antonio Caggiano
2023-10-24 10:28 ` Peter Maydell [this message]
2023-10-24 10:49   ` Antonio Caggiano
2023-10-24 12:00     ` Peter Maydell
2023-10-24 12:31       ` Antonio Caggiano
2023-10-24 13:21         ` Peter Maydell
2023-10-24 13:38           ` Antonio Caggiano
2023-10-24 14:17             ` 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=CAFEAcA86trVBDe4zJr2Zv-EgWReY2M+yvU83Kc_8nGrjP4_tJg@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quic_acaggian@quicinc.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).