qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC] mem: Fix mem region size when is UINT64_MAX
@ 2023-10-24  9:43 Antonio Caggiano
  2023-10-24 10:28 ` Peter Maydell
  0 siblings, 1 reply; 8+ messages in thread
From: Antonio Caggiano @ 2023-10-24  9:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Antonio Caggiano

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();
-    }
     mr->name = g_strdup(name);
     mr->owner = owner;
     mr->dev = (DeviceState *) object_dynamic_cast(mr->owner, TYPE_DEVICE);
-- 
2.42.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-24 14:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-24  9:43 [RFC] mem: Fix mem region size when is UINT64_MAX Antonio Caggiano
2023-10-24 10:28 ` Peter Maydell
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

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).