Skip to contentSkip to conversation

Next patches

GIT PULL Applied Peter Xu 3 participants 15 messages Sep 18 – Sep 19

Subsystems (2)
lore
Share & tools
lore

Peter Xu

author
#0 lore raw

The following changes since commit f8296b816fabd370307cd22b0270b610fc0fa279:

Merge tag 'pull-loongarch-20260917' of https://github.com/bibo-mao/qemu into staging (2026-09-16 18:24:08 -1000)

are available in the Git repository at:

https://gitlab.com/peterx/qemu.git tags/next-pull-request

for you to fetch changes up to 666dd3c9b10a70eea4aae3c09b0f945175a7cb8e:

system/ram-discard-manager: fix offset_within_address_space in replay_by_populated_state() (2026-09-18 07:36:52 -0400)

----------------------------------------------------------------
Mem api pull

- Peter's patchset to drop some dead code for 32bit hosts
- Phil/Bin's patch to enhance error message for mem allocations
- Cam's fix to virtio-mem crash in multi-source work

----------------------------------------------------------------

Cam Miller (1):
system/ram-discard-manager: fix offset_within_address_space in
replay_by_populated_state()

Peter Xu (9):
system: Define ram_addr_t to be always uint64_t hw/vexpress.c: Remove forced cast to u64
arm/mps: Remove 32bit define for MPS3_DDR_SIZE
xen-mapcache: Remove 32bit support
bsd-user: Remove 32bit host support in thunk_convert|print()
linux-user: Remove 32bit host support in thunk_convert|print() arm/aspeed: Drop ASPEED_RAM_SIZE
hw/arm/raspi4b: Drop board_rev for 32bit hosts
machine: Remove 32bit limitation on ram size

Philippe Mathieu-Daudé (1):
system/physmem: Improve guest memory allocation failure error message

 include/hw/arm/aspeed.h           |  7 -----
 include/system/ram_addr.h         | 16 +++++------
 bsd-user/thunk.c                  | 47 ++-----------------------------
 hw/arm/aspeed_ast2600_anacapa.c   |  2 +-
 hw/arm/aspeed_ast2600_bletchley.c |  2 +-
 hw/arm/aspeed_ast2600_catalina.c  |  2 +-
 hw/arm/aspeed_ast2600_fby35.c     |  2 +-
 hw/arm/aspeed_ast2600_fuji.c      |  2 +-
 hw/arm/aspeed_ast2600_gb200nvl.c  |  2 +-
 hw/arm/aspeed_ast2600_sanmiguel.c |  2 +-
 hw/arm/mps2-tz.c                  |  9 ------
 hw/arm/mps3r.c                    |  8 ------
 hw/arm/raspi4b.c                  |  4 ---
 hw/arm/vexpress.c                 | 13 ++-------
 hw/core/machine.c                 |  8 ------
 hw/xen/xen-mapcache.c             | 12 ++------
 linux-user/thunk.c                | 47 ++-----------------------------
 system/physmem.c                  |  4 ++-
 system/ram-discard-manager.c      | 29 ++++++++++---------
 19 files changed, 43 insertions(+), 175 deletions(-)
Signature · 1 line
2.55.0
author
#1 lore raw

[PULL 04/11] xen-mapcache: Remove 32bit support

QEMU has switched to 64bit-only hosts for all system emulations.

---
 hw/xen/xen-mapcache.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
hw/xen/xen-mapcache.c +2 -10
index 85cf0cf359..e30c07c2ee 100644
@@ -26,11 +26,7 @@
 #include <xenevtchn.h>
 #include <xengnttab.h>
 
-#if HOST_LONG_BITS == 32
-#  define MCACHE_MAX_SIZE     (1UL<<31) /* 2GB Cap */
-#else
-#  define MCACHE_MAX_SIZE     (1UL<<35) /* 32GB Cap */
-#endif
+#define MCACHE_MAX_SIZE     (1UL << 35) /* 32GB Cap */
 
 /* This is the size of the virtual address space reserve to QEMU that will not
  * be use by MapCache.
@@ -151,11 +147,7 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque)
         exit(EXIT_FAILURE);
     }
 
-    if (HOST_LONG_BITS == 32) {
-        bucket_shift = 16;
-    } else {
-        bucket_shift = 20;
-    }
+    bucket_shift = 20;
 
     if (geteuid() == 0) {
         rlimit_as.rlim_cur = RLIM_INFINITY;
Signature · 1 line
2.55.0
#2 lore raw

Re: [PULL 04/11] xen-mapcache: Remove 32bit support

Quoted 33 lines · Peter Xu

QEMU has switched to 64bit-only hosts for all system emulations.

---
  hw/xen/xen-mapcache.c | 12 ++----------
  1 file changed, 2 insertions(+), 10 deletions(-)
hw/xen/xen-mapcache.c +1 -5
index 85cf0cf359..e30c07c2ee 100644
@@ -26,11 +26,7 @@
  #include <xenevtchn.h>
  #include <xengnttab.h>
 
-#if HOST_LONG_BITS == 32
-#  define MCACHE_MAX_SIZE     (1UL<<31) /* 2GB Cap */
-#else
-#  define MCACHE_MAX_SIZE     (1UL<<35) /* 32GB Cap */
-#endif
+#define MCACHE_MAX_SIZE     (1UL << 35) /* 32GB Cap */
 
  /* This is the size of the virtual address space reserve to QEMU that will not
   * be use by MapCache.
@@ -151,11 +147,7 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque)
          exit(EXIT_FAILURE);
      }

hw/xen/xen-mapcache.c void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque) · line 153

Quoted 10 lines
hw/xen/xen-mapcache.c +1 -5
 
-    if (HOST_LONG_BITS == 32) {
-        bucket_shift = 16;
-    } else {
-        bucket_shift = 20;
-    }
+    bucket_shift = 20;
 
      if (geteuid() == 0) {
          rlimit_as.rlim_cur = RLIM_INFINITY;

Using a local variable here to store a constant is a bit weird and its only use is to be stored as MapCache.bucket_shift and MapCache.bucket_size which are effectively constant. Not sure why this isn't just a couple of #defines at the top and used everywhere bucket_shift and bucket_size is needed. Perhaps that is further cleanup to be done separately...

Ross

author
#3 lore raw

Re: [PULL 04/11] xen-mapcache: Remove 32bit support

Quoted 38 lines · Ross Lagerwall
Quoted 37 lines · Peter Xu

QEMU has switched to 64bit-only hosts for all system emulations.

---
  hw/xen/xen-mapcache.c | 12 ++----------
  1 file changed, 2 insertions(+), 10 deletions(-)
hw/xen/xen-mapcache.c +2 -10
index 85cf0cf359..e30c07c2ee 100644
@@ -26,11 +26,7 @@
  #include <xenevtchn.h>
  #include <xengnttab.h>
-#if HOST_LONG_BITS == 32
-#  define MCACHE_MAX_SIZE     (1UL<<31) /* 2GB Cap */
-#else
-#  define MCACHE_MAX_SIZE     (1UL<<35) /* 32GB Cap */
-#endif
+#define MCACHE_MAX_SIZE     (1UL << 35) /* 32GB Cap */
  /* This is the size of the virtual address space reserve to QEMU that will not
   * be use by MapCache.
@@ -151,11 +147,7 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque)
          exit(EXIT_FAILURE);
      }
-    if (HOST_LONG_BITS == 32) {
-        bucket_shift = 16;
-    } else {
-        bucket_shift = 20;
-    }
+    bucket_shift = 20;
Quoted 8 lines

hw/xen/xen-mapcache.c void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque) · line 153

Quoted 2 lines
hw/xen/xen-mapcache.c +0 -0
      if (geteuid() == 0) {
          rlimit_as.rlim_cur = RLIM_INFINITY;

Using a local variable here to store a constant is a bit weird and its only use is to be stored as MapCache.bucket_shift and MapCache.bucket_size which are effectively constant. Not sure why this isn't just a couple of #defines at the top and used everywhere bucket_shift and bucket_size is needed. Perhaps that is further cleanup to be done separately...

True..

It's my bad not noticing that relevant people were not properly copied when sending the patches; I thought each patch will have its own set of CC from get_maintainers.pl, but it didn't actually work and I didn't notice. I only notice it when I was just to send a pull, hence added Cc: explicitly at least in the pull sent, feeling that these changes are mostly cosmotic and safe.

It'll be great if this can be done separately, makes me easier. If there's any strong feeling on any of the changes, please speak and then I'll redo the work.

Thanks,

Signature · 1 line
Peter Xu
author
#4 lore raw

[PULL 02/11] hw/vexpress.c: Remove forced cast to u64

In reply to Peter Xu

Now since ram_addr_t has switched to u64, remove the forced cast as not needed.

---
 hw/arm/vexpress.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
hw/arm/vexpress.c +3 -10
index 914cda66d2..a4328ec74b 100644
@@ -362,16 +362,9 @@ static void a15_daughterboard_init(VexpressMachineState *vms,
     MachineState *machine = MACHINE(vms);
     MemoryRegion *sysmem = get_system_memory();
 
-    {
-        /* We have to use a separate 64 bit variable here to avoid the gcc
-         * "comparison is always false due to limited range of data type"
-         * warning if we are on a host where ram_addr_t is 32 bits.
-         */
-        uint64_t rsz = ram_size;
-        if (rsz > (30ULL * 1024 * 1024 * 1024)) {
-            error_report("vexpress-a15: cannot model more than 30GB RAM");
-            exit(1);
-        }
+    if (ram_size > (30ULL * 1024 * 1024 * 1024)) {
+        error_report("vexpress-a15: cannot model more than 30GB RAM");
+        exit(1);
     }
 
     /* RAM is from 0x80000000 upwards; there is no low-memory alias for it. */
Signature · 1 line
2.55.0
author
#5 lore raw

[PULL 07/11] arm/aspeed: Drop ASPEED_RAM_SIZE

In reply to Peter Xu

QEMU has switched to 64bit-only hosts for all system/user emulations. It's not needed anymore.

Cc "Cédric Le Goater" <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Steven Lee <[email protected]>
Cc Troy Lee <[email protected]>
Cc Jamin Lin <[email protected]>
Cc Kane Chen <[email protected]>
Cc Andrew Jeffery <[email protected]>
Cc Joel Stanley <[email protected]>
[peterx: fix aspeed_ast2600_sanmiguel.c, recently added in b6bcec6c2]
---
 include/hw/arm/aspeed.h           | 7 -------
 hw/arm/aspeed_ast2600_anacapa.c   | 2 +-
 hw/arm/aspeed_ast2600_bletchley.c | 2 +-
 hw/arm/aspeed_ast2600_catalina.c  | 2 +-
 hw/arm/aspeed_ast2600_fby35.c     | 2 +-
 hw/arm/aspeed_ast2600_fuji.c      | 2 +-
 hw/arm/aspeed_ast2600_gb200nvl.c  | 2 +-
 hw/arm/aspeed_ast2600_sanmiguel.c | 2 +-
 8 files changed, 7 insertions(+), 14 deletions(-)
include/hw/arm/aspeed.h +0 -7
index 54f0d7643d..989d39528e 100644
@@ -26,13 +26,6 @@ DECLARE_OBJ_CHECKERS(AspeedMachineState, AspeedMachineClass,
 #define ASPEED_MAC2_ON   (1 << 2)
 #define ASPEED_MAC3_ON   (1 << 3)
 
-/* On 32-bit hosts, lower RAM to 1G because of the 2047 MB limit */
-#if HOST_LONG_BITS == 32
-#define ASPEED_RAM_SIZE(sz) MIN((sz), 1 * GiB)
-#else
-#define ASPEED_RAM_SIZE(sz) (sz)
-#endif
-
 struct AspeedMachineState {
     MachineState parent_obj;
 
hw/arm/aspeed_ast2600_anacapa.c +1 -1
index 697be58b0e..25578db589 100644
@@ -17,7 +17,7 @@
 
 #define ANACAPA_BMC_HW_STRAP1 0x00002002
 #define ANACAPA_BMC_HW_STRAP2 0x00000000
-#define ANACAPA_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB)
+#define ANACAPA_BMC_RAM_SIZE (2 * GiB)
 
 /*
  * "Anacapa HPM (MB)" FRU data. Generated with frugen.
hw/arm/aspeed_ast2600_bletchley.c +1 -1
index 2822f6bdf5..6fa606c047 100644
@@ -17,7 +17,7 @@
 /* Bletchley hardware value */
 #define BLETCHLEY_BMC_HW_STRAP1 0x00002000
 #define BLETCHLEY_BMC_HW_STRAP2 0x00000801
-#define BLETCHLEY_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB)
+#define BLETCHLEY_BMC_RAM_SIZE (2 * GiB)
 
 static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
 {
hw/arm/aspeed_ast2600_catalina.c +1 -1
index ad2953dfea..4f2b396f6f 100644
@@ -19,7 +19,7 @@
 /* Catalina hardware value */
 #define CATALINA_BMC_HW_STRAP1 0x00002002
 #define CATALINA_BMC_HW_STRAP2 0x00000800
-#define CATALINA_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB)
+#define CATALINA_BMC_RAM_SIZE (2 * GiB)
 
 #define TYPE_TMP421 "tmp421"
 #define TYPE_DS1338 "ds1338"
hw/arm/aspeed_ast2600_fby35.c +1 -1
index 65d98fafec..28c9c143d8 100644
@@ -16,7 +16,7 @@
 
 #define TYPE_LM75 TYPE_TMP105
 #define TYPE_TMP421 "tmp421"
-#define FBY35_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB)
+#define FBY35_BMC_RAM_SIZE (2 * GiB)
 
 static const uint8_t fby35_nic_fruid[] = {
     0x01, 0x00, 0x00, 0x01, 0x0f, 0x20, 0x00, 0xcf, 0x01, 0x0e, 0x19, 0xd7,
hw/arm/aspeed_ast2600_fuji.c +1 -1
index dae0239387..08d809b2fd 100644
@@ -19,7 +19,7 @@
 /* Fuji hardware value */
 #define FUJI_BMC_HW_STRAP1    0x00000000
 #define FUJI_BMC_HW_STRAP2    0x00000000
-#define FUJI_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB)
+#define FUJI_BMC_RAM_SIZE (2 * GiB)
 
 static void get_pca9548_channels(I2CBus *bus, uint8_t mux_addr,
                                  I2CBus **channels)
hw/arm/aspeed_ast2600_gb200nvl.c +1 -1
index 311feb8202..c9c0b6cb6e 100644
@@ -15,7 +15,7 @@
 /* GB200NVL hardware value */
 #define GB200NVL_BMC_HW_STRAP1 0x000000C0
 #define GB200NVL_BMC_HW_STRAP2 0x00000003
-#define GB200NVL_BMC_RAM_SIZE ASPEED_RAM_SIZE(1 * GiB)
+#define GB200NVL_BMC_RAM_SIZE (1 * GiB)
 
 static const uint8_t gb200nvl_bmc_fruid[] = {
     0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, 0x19, 0x1f,
hw/arm/aspeed_ast2600_sanmiguel.c +1 -1
index 599ef1701f..345a9c9416 100644
@@ -18,7 +18,7 @@
 /* SanMiguel hardware values */
 #define SANMIGUEL_BMC_HW_STRAP1 0x00002002
 #define SANMIGUEL_BMC_HW_STRAP2 0x00000000
-#define SANMIGUEL_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB)
+#define SANMIGUEL_BMC_RAM_SIZE (2 * GiB)
 
 #define TYPE_DS1338 "ds1338"
 
Signature · 1 line
2.55.0
author
#6 lore raw

[PULL 01/11] system: Define ram_addr_t to be always uint64_t

In reply to Peter Xu

QEMU's 32bit host support was deprecated since 10.0 and removed in 11.0 (commit 372ec46b9f), at least system emulation part (cf634dfcd8fc revived tools). Now it's safe to move ram_addr_t completely over to uint64_t.

It should be almost the same as uintptr_t as before for !Xen, except that on some systems (like MacOS) uintptr_t and uint64_t can be typed slightly differently, causing unnecessary compiler warnings when use them in a mixture way.

Hopefully, this change also makes it clear that ram_addr_t is never used as a host pointer in any form, but only an internal QEMU integer based address space for allocating ramblocks.

[1] https://lore.kernel.org/r/[email protected]

---
 include/system/ram_addr.h | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
include/system/ram_addr.h +7 -9
index 129f6b8757..044c0b52cc 100644
@@ -14,16 +14,14 @@
 #ifndef RAM_ADDR_H
 #define RAM_ADDR_H
 
-/* address in the RAM (different from a physical address) */
-#if defined(CONFIG_XEN_BACKEND)
+/*
+ * QEMU's internal RAM address space for ramblock allocations (different
+ * from guest physical address).
+ */
 typedef uint64_t ram_addr_t;
-#  define RAM_ADDR_MAX UINT64_MAX
-#  define RAM_ADDR_FMT "%" PRIx64
-#else
-typedef uintptr_t ram_addr_t;
-#  define RAM_ADDR_MAX UINTPTR_MAX
-#  define RAM_ADDR_FMT "%" PRIxPTR
-#endif
+
+#define RAM_ADDR_MAX UINT64_MAX
+#define RAM_ADDR_FMT "%" PRIx64
 
 #define DIRTY_MEMORY_VGA       0
 #define DIRTY_MEMORY_CODE      1
Signature · 1 line
2.55.0
author
#7 lore raw

[PULL 03/11] arm/mps: Remove 32bit define for MPS3_DDR_SIZE

In reply to Peter Xu

QEMU has switched to 64bit-only hosts for all system emulations.

---
 hw/arm/mps2-tz.c | 9 ---------
 hw/arm/mps3r.c   | 8 --------
 2 files changed, 17 deletions(-)
hw/arm/mps2-tz.c +0 -9
index 4e6744eddf..7f41a74df1 100644
@@ -190,16 +190,7 @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE)
 
 /* Slow 32Khz S32KCLK frequency in Hz */
 #define S32KCLK_FRQ (32 * 1000)
-
-/*
- * The MPS3 DDR is 2GiB, but on a 32-bit host QEMU doesn't permit
- * emulation of that much guest RAM, so artificially make it smaller.
- */
-#if HOST_LONG_BITS == 32
-#define MPS3_DDR_SIZE (1 * GiB)
-#else
 #define MPS3_DDR_SIZE (2 * GiB)
-#endif
 
 /* For cpu{0,1}_mpu_{ns,s}, means "leave at SSE's default value" */
 #define MPU_REGION_DEFAULT UINT32_MAX
hw/arm/mps3r.c +0 -8
index eedb877e4b..4bd5d83d56 100644
@@ -58,15 +58,7 @@ typedef struct RAMInfo {
     int flags;
 } RAMInfo;
 
-/*
- * The MPS3 DDR is 3GiB, but on a 32-bit host QEMU doesn't permit
- * emulation of that much guest RAM, so artificially make it smaller.
- */
-#if HOST_LONG_BITS == 32
-#define MPS3_DDR_SIZE (1 * GiB)
-#else
 #define MPS3_DDR_SIZE (3 * GiB)
-#endif
 
 /*
  * Flag values:
Signature · 1 line
2.55.0
author
#8 lore raw

[PULL 08/11] hw/arm/raspi4b: Drop board_rev for 32bit hosts

In reply to Peter Xu

QEMU has switched to 64bit-only hosts for all system/user emulations.

---
 hw/arm/raspi4b.c | 4 ----
 1 file changed, 4 deletions(-)
hw/arm/raspi4b.c +0 -4
index 7d3eed9630..566d64572d 100644
@@ -110,11 +110,7 @@ static void raspi4b_machine_class_init(ObjectClass *oc, const void *data)
     MachineClass *mc = MACHINE_CLASS(oc);
     RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc);
 
-#if HOST_LONG_BITS == 32
-    rmc->board_rev = 0xa03111; /* Revision 1.1, 1 Gb RAM */
-#else
     rmc->board_rev = 0xb03115; /* Revision 1.5, 2 Gb RAM */
-#endif
     raspi_machine_class_common_init(mc, rmc->board_rev);
     mc->auto_create_sdcard = true;
     mc->init = raspi4b_machine_init;
Signature · 1 line
2.55.0
author
#9 lore raw

[PULL 06/11] linux-user: Remove 32bit host support in thunk_convert|print()

In reply to Peter Xu

QEMU has switched to 64bit-only hosts for all system/user emulations.

---
 linux-user/thunk.c | 47 +++-------------------------------------------
 1 file changed, 3 insertions(+), 44 deletions(-)
linux-user/thunk.c +3 -44
index 3cd19e79c6..892ff3d154 100644
@@ -145,13 +145,7 @@ const argtype *thunk_convert(void *dst, const void *src,
     case TYPE_ULONGLONG:
         *(uint64_t *)dst = tswap64(*(uint64_t *)src);
         break;
-#if HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 32
-    case TYPE_LONG:
-    case TYPE_ULONG:
-    case TYPE_PTRVOID:
-        *(uint32_t *)dst = tswap32(*(uint32_t *)src);
-        break;
-#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 32
+#if TARGET_ABI_BITS == 32
     case TYPE_LONG:
     case TYPE_ULONG:
     case TYPE_PTRVOID:
@@ -166,27 +160,12 @@ const argtype *thunk_convert(void *dst, const void *src,
             *(uint32_t *)dst = tswap32(*(uint64_t *)src & 0xffffffff);
         }
         break;
-#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
+#elif TARGET_ABI_BITS == 64
     case TYPE_LONG:
     case TYPE_ULONG:
     case TYPE_PTRVOID:
         *(uint64_t *)dst = tswap64(*(uint64_t *)src);
         break;
-#elif HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 64
-    case TYPE_LONG:
-    case TYPE_ULONG:
-    case TYPE_PTRVOID:
-        if (to_host) {
-            *(uint32_t *)dst = tswap64(*(uint64_t *)src);
-        } else {
-            if (type == TYPE_LONG) {
-                /* sign extension */
-                *(uint64_t *)dst = tswap64(*(int32_t *)src);
-            } else {
-                *(uint64_t *)dst = tswap64(*(uint32_t *)src);
-            }
-        }
-        break;
 #else
 #warning unsupported conversion
 #endif
@@ -294,17 +273,7 @@ const argtype *thunk_print(void *arg, const argtype *type_ptr)
     case TYPE_ULONGLONG:
         qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg));
         break;
-#if HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 32
-    case TYPE_PTRVOID:
-        qemu_log("0x%" PRIx32, tswap32(*(uint32_t *)arg));
-        break;
-    case TYPE_LONG:
-        qemu_log("%" PRId32, tswap32(*(uint32_t *)arg));
-        break;
-    case TYPE_ULONG:
-        qemu_log("%" PRIu32, tswap32(*(uint32_t *)arg));
-        break;
-#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 32
+#if TARGET_ABI_BITS == 32
     case TYPE_PTRVOID:
         qemu_log("0x%" PRIx32, tswap32(*(uint64_t *)arg & 0xffffffff));
         break;
@@ -314,16 +283,6 @@ const argtype *thunk_print(void *arg, const argtype *type_ptr)
     case TYPE_ULONG:
         qemu_log("%" PRIu32, tswap32(*(uint64_t *)arg & 0xffffffff));
         break;
-#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
-    case TYPE_PTRVOID:
-        qemu_log("0x%" PRIx64, tswap64(*(uint64_t *)arg));
-        break;
-    case TYPE_LONG:
-        qemu_log("%" PRId64, tswap64(*(uint64_t *)arg));
-        break;
-    case TYPE_ULONG:
-        qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg));
-        break;
 #else
     case TYPE_PTRVOID:
         qemu_log("0x%" PRIx64, tswap64(*(uint64_t *)arg));
Signature · 1 line
2.55.0
author
#10 lore raw

[PULL 05/11] bsd-user: Remove 32bit host support in thunk_convert|print()

In reply to Peter Xu

QEMU has switched to 64bit-only hosts for all system/user emulations.

---
 bsd-user/thunk.c | 47 +++--------------------------------------------
 1 file changed, 3 insertions(+), 44 deletions(-)
bsd-user/thunk.c +3 -44
index 3c89ae3ab8..6703286609 100644
@@ -134,13 +134,7 @@ const argtype *thunk_convert(void *dst, const void *src,
     case TYPE_ULONGLONG:
         *(uint64_t *)dst = tswap64(*(uint64_t *)src);
         break;
-#if HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 32
-    case TYPE_LONG:
-    case TYPE_ULONG:
-    case TYPE_PTRVOID:
-        *(uint32_t *)dst = tswap32(*(uint32_t *)src);
-        break;
-#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 32
+#if TARGET_ABI_BITS == 32
     case TYPE_LONG:
     case TYPE_ULONG:
     case TYPE_PTRVOID:
@@ -155,27 +149,12 @@ const argtype *thunk_convert(void *dst, const void *src,
             *(uint32_t *)dst = tswap32(*(uint64_t *)src & 0xffffffff);
         }
         break;
-#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
+#elif TARGET_ABI_BITS == 64
     case TYPE_LONG:
     case TYPE_ULONG:
     case TYPE_PTRVOID:
         *(uint64_t *)dst = tswap64(*(uint64_t *)src);
         break;
-#elif HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 64
-    case TYPE_LONG:
-    case TYPE_ULONG:
-    case TYPE_PTRVOID:
-        if (to_host) {
-            *(uint32_t *)dst = tswap64(*(uint64_t *)src);
-        } else {
-            if (type == TYPE_LONG) {
-                /* sign extension */
-                *(uint64_t *)dst = tswap64(*(int32_t *)src);
-            } else {
-                *(uint64_t *)dst = tswap64(*(uint32_t *)src);
-            }
-        }
-        break;
 #else
 #warning unsupported conversion
 #endif
@@ -283,17 +262,7 @@ const argtype *thunk_print(void *arg, const argtype *type_ptr)
     case TYPE_ULONGLONG:
         qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg));
         break;
-#if HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 32
-    case TYPE_PTRVOID:
-        qemu_log("0x%" PRIx32, tswap32(*(uint32_t *)arg));
-        break;
-    case TYPE_LONG:
-        qemu_log("%" PRId32, tswap32(*(uint32_t *)arg));
-        break;
-    case TYPE_ULONG:
-        qemu_log("%" PRIu32, tswap32(*(uint32_t *)arg));
-        break;
-#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 32
+#if TARGET_ABI_BITS == 32
     case TYPE_PTRVOID:
         qemu_log("0x%" PRIx32, tswap32(*(uint64_t *)arg & 0xffffffff));
         break;
@@ -303,16 +272,6 @@ const argtype *thunk_print(void *arg, const argtype *type_ptr)
     case TYPE_ULONG:
         qemu_log("%" PRIu32, tswap32(*(uint64_t *)arg & 0xffffffff));
         break;
-#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
-    case TYPE_PTRVOID:
-        qemu_log("0x%" PRIx64, tswap64(*(uint64_t *)arg));
-        break;
-    case TYPE_LONG:
-        qemu_log("%" PRId64, tswap64(*(uint64_t *)arg));
-        break;
-    case TYPE_ULONG:
-        qemu_log("%" PRIu64, tswap64(*(uint64_t *)arg));
-        break;
 #else
     case TYPE_PTRVOID:
         qemu_log("0x%" PRIx64, tswap64(*(uint64_t *)arg));
Signature · 1 line
2.55.0
author
#11 lore raw

[PULL 09/11] machine: Remove 32bit limitation on ram size

In reply to Peter Xu

QEMU has switched to 64bit-only hosts for all system/user emulations.

---
 hw/core/machine.c | 8 --------
 1 file changed, 8 deletions(-)
hw/core/machine.c +0 -8
index 8939ae1666..92f7be52a1 100644
@@ -1626,14 +1626,6 @@ void machine_run_board_init(MachineState *machine, const char *mem_path, Error *
        clock values from the log. */
     replay_checkpoint(CHECKPOINT_INIT);
 
-    if (!xen_enabled()) {
-        /* On 32-bit hosts, QEMU is limited by virtual address space */
-        if (machine->ram_size > (2047 << 20) && HOST_LONG_BITS == 32) {
-            error_setg(errp, "at most 2047 MB RAM can be simulated");
-            return;
-        }
-    }
-
     if (machine->memdev) {
         ram_addr_t backend_size = object_property_get_uint(OBJECT(machine->memdev),
                                                            "size",  &error_abort);
Signature · 1 line
2.55.0
author
#12 lore raw

[PULL 11/11] system/ram-discard-manager: fix offset_within_address_space in replay_by_populated_state()

In reply to Peter Xu

From: Cam Miller <[email protected]>

Fix bug inside replay_by_populated_state() that forgets to initialize MemoryRegionSection field offset_within_address_space. Follow the established pattern of calling memory_region_section_intersect_range() to accomplish this task.

Prior to commit cc9c77f4ddf0 ("system/memory: implement RamDiscardManager multi-source aggregation"), replay_by_populated_state() had called memory_region_section_intersect_range() in order to initialize interdependent fields offset_within_address_space, offset_within_region, and size together, as shown below.

    s->offset_within_address_space += start - s->offset_within_region;
    s->offset_within_region = start;
    s->size = int128_sub(end, int128_make64(start));

cc9c77f4ddf0 reimplements replay_by_populated_state() initializing the fields of the given MemoryRegionSection instance by hand instead of via memory_region_section_intersect_range(). In doing so, it leaves offset_within_address_space uninitialized for some reason, as you can see below.

    MemoryRegionSection subsection = {
        .mr = section->mr,
        .offset_within_region = offset,
        .size = int128_make64(MIN(granularity, end_offset - offset)),
    };

Consequently offset_within_address_space defaults to GPA 0x0, which is incorrect. For example, on s390x, base RAM begins at GPA 0x0 and it is problematic to report that a virtio-iommu MR section lives there instead.

cc9c77f4ddf0 deliberately calls memory_region_section_intersect_range() from other related code paths inside the same file, namely replay_source_by_state() and rdl_populate_cb()/rdl_discard_cb(). It is unclear why the new replay_by_populated_state() implementation does not conform to this same pattern.

The effects of the bug include qemu crashes on multiple architectures. The following assertion failure occurs when driving the guest_phys_blocks_append() code path, for guests with virtio-mem device that has some memory plugged.

    DBG: guest_phys_block_add_section: predecessor->target_end=280000000 target_start=0
    **
    ERROR:../system/memory_mapping.c:222:guest_phys_block_add_section: assertion failed: (predecessor->target_end <= target_start)
    Bail out! ERROR:../system/memory_mapping.c:222:guest_phys_block_add_section: assertion failed: (predecessor->target_end <= target_start)
    2026-09-11 16:03:57.405+0000: shutting down, reason=crashed

This crash can be triggered on x86 via the dump-guest-memory QMP command. The same crash can be triggered on s390x by restoring VM State that has been migrated to a local file. (I used libvirt to manage this migration restore operation, namely command virsh managedsave then virsh start.) Applying the fix resolved the crash on both platforms.

Cc qemu-stable <[email protected]>
Fixes cc9c77f4ddf0 ("system/memory: implement RamDiscardManager multi-source aggregation")
---
 system/ram-discard-manager.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
system/ram-discard-manager.c +15 -14
index 4e8816e5a2..e9a609e5cd 100644
@@ -238,14 +238,15 @@ static int replay_by_populated_state(const RamDiscardManager *rdm,
             }
         } else {
             if (in_run) {
-                MemoryRegionSection run_section = {
-                    .mr = section->mr,
-                    .offset_within_region = run_start,
-                    .size = int128_make64(offset - run_start),
-                };
-                ret = replay_fn(&run_section, user_opaque);
-                if (ret) {
-                    return ret;
+                MemoryRegionSection run_section = *section;
+
+                if (memory_region_section_intersect_range(&run_section,
+                                                          run_start,
+                                                          offset - run_start)) {
+                    ret = replay_fn(&run_section, user_opaque);
+                    if (ret) {
+                        return ret;
+                    }
                 }
                 in_run = false;
             }
@@ -257,12 +258,12 @@ static int replay_by_populated_state(const RamDiscardManager *rdm,
     }
 
     if (in_run) {
-        MemoryRegionSection run_section = {
-            .mr = section->mr,
-            .offset_within_region = run_start,
-            .size = int128_make64(end_offset - run_start),
-        };
-        ret = replay_fn(&run_section, user_opaque);
+        MemoryRegionSection run_section = *section;
+
+        if (memory_region_section_intersect_range(&run_section, run_start,
+                                                  end_offset - run_start)) {
+            ret = replay_fn(&run_section, user_opaque);
+        }
     }
 
     return ret;
Signature · 1 line
2.55.0
author
#13 lore raw

[PULL 10/11] system/physmem: Improve guest memory allocation failure error message

In reply to Peter Xu

From: Philippe Mathieu-Daudé <[email protected]>

When Linux refuses to overcommit a seriously wild allocation we get:

  $ qemu-system-i386 -m 40000000
  qemu-system-i386: cannot set up guest memory 'pc.ram':
  Cannot allocate memory

Slightly improve the error message, displaying the memory size requested (in case the user didn't expect unspecified memory size unit is in MiB):

  $ qemu-system-i386 -m 40000000
  qemu-system-i386: Cannot set up 38.1 TiB of guest memory 'pc.ram':
  Cannot allocate memory
---
 system/physmem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
system/physmem.c +3 -1
index a4a6a4710c..bd5f41cb02 100644
@@ -2171,8 +2171,10 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)
                                                   &new_block->mr->align,
                                                   shared, noreserve);
             if (!new_block->host) {
+                g_autofree char *size_s = size_to_str(new_block->max_length);
                 error_setg_errno(errp, errno,
-                                 "cannot set up guest memory '%s'",
+                                 "Cannot set up %s of guest memory '%s'",
+                                 size_s,
                                  memory_region_name(new_block->mr));
                 qemu_mutex_unlock_ramlist();
                 return;
Signature · 1 line
2.55.0
#14 lore raw
In reply to Peter Xu
Quoted 10 lines · Peter Xu

The following changes since commit f8296b816fabd370307cd22b0270b610fc0fa279:

   Merge tag 'pull-loongarch-20260917' ofhttps://github.com/bibo-mao/qemu into staging (2026-09-16 18:24:08 -1000)

are available in the Git repository at:

https://gitlab.com/peterx/qemu.git tags/next-pull-request

for you to fetch changes up to 666dd3c9b10a70eea4aae3c09b0f945175a7cb8e:

Quoted 8 lines
   system/ram-discard-manager: fix offset_within_address_space in replay_by_populated_state() (2026-09-18 07:36:52 -0400)

----------------------------------------------------------------
Mem api pull

- Peter's patchset to drop some dead code for 32bit hosts
- Phil/Bin's patch to enhance error message for mem allocations
- Cam's fix to virtio-mem crash in multi-source work

Applied, thanks.

r~