[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] mem: Fix mem region size when is UINT64_MAX
|
From: |
Peter Maydell |
|
Subject: |
Re: [RFC] mem: Fix mem region size when is UINT64_MAX |
|
Date: |
Tue, 24 Oct 2023 11:28:37 +0100 |
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
- [RFC] mem: Fix mem region size when is UINT64_MAX, Antonio Caggiano, 2023/10/24
- Re: [RFC] mem: Fix mem region size when is UINT64_MAX,
Peter Maydell <=
- Re: [RFC] mem: Fix mem region size when is UINT64_MAX, Antonio Caggiano, 2023/10/24
- Re: [RFC] mem: Fix mem region size when is UINT64_MAX, Peter Maydell, 2023/10/24
- Re: [RFC] mem: Fix mem region size when is UINT64_MAX, Antonio Caggiano, 2023/10/24
- Re: [RFC] mem: Fix mem region size when is UINT64_MAX, Peter Maydell, 2023/10/24
- Re: [RFC] mem: Fix mem region size when is UINT64_MAX, Antonio Caggiano, 2023/10/24
- Re: [RFC] mem: Fix mem region size when is UINT64_MAX, Peter Maydell, 2023/10/24