qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC] mem: Fix mem region size when is UINT64_MAX


From: Antonio Caggiano
Subject: [RFC] mem: Fix mem region size when is UINT64_MAX
Date: Tue, 24 Oct 2023 11:43:51 +0200

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]