:p
atchew
Login
The following changes since commit 30e8a06b64aa58a3990ba39cb5d09531e7d265e0: Merge tag 'net-pull-request' of https://github.com/jasowang/qemu into staging (2026-06-29 17:41:42 +0200) are available in the Git repository at: https://gitlab.com/peterx/qemu.git tags/next-pull-request for you to fetch changes up to 60f2281450c4b4e9a16922fd69c66486a8207abb: migration: clean up postcopy blocktime presentation (2026-07-17 12:33:42 -0400) ---------------------------------------------------------------- Migration pull for rc1 - Bin's cleanup on migration blocktime (partly) - Yujun's fix on print format ---------------------------------------------------------------- Bin Guo (2): migration: fix ineffective overflow assert in postcopy blocktime migration: clean up postcopy blocktime presentation yujun (1): migration: Fix invalid %ud format and trace arg typo migration/migration-hmp-cmds.c | 2 +- migration/postcopy-ram.c | 14 ++++++-------- migration/trace-events | 6 +++--- 3 files changed, 10 insertions(+), 12 deletions(-) -- 2.54.0
From: yujun <yujun@kylinos.cn> Standard printf has no %ud conversion; glibc treats it as %u followed by a literal 'd', so postcopy userfaultfd error messages printed event values like "5d" instead of "5". The same typo existed in two postcopy discard trace format strings. Also rename the misspelled ram_save_iterate_big_wait() trace argument milliconds to milliseconds. Fixes: 00fa4fc85b ("postcopy: Allow registering of fd handler") Signed-off-by: yujun <yujun@kylinos.cn> Reviewed-by: Fabiano Rosas <farosas@suse.de> Link: https://lore.kernel.org/r/20260630031324.43453-1-yujun@kylinos.cn Signed-off-by: Peter Xu <peterx@redhat.com> --- migration/postcopy-ram.c | 4 ++-- migration/trace-events | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index XXXXXXX..XXXXXXX 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -XXX,XX +XXX,XX @@ static void *postcopy_ram_fault_thread(void *opaque) } } if (msg.event != UFFD_EVENT_PAGEFAULT) { - error_report("%s: Read unexpected event %ud from userfaultfd", + error_report("%s: Read unexpected event %u from userfaultfd", __func__, msg.event); continue; /* It's not a page fault, shouldn't happen */ } @@ -XXX,XX +XXX,XX @@ retry: } } if (msg.event != UFFD_EVENT_PAGEFAULT) { - error_report("%s: Read unexpected event %ud " + error_report("%s: Read unexpected event %u " "from userfaultfd (shared)", __func__, msg.event); continue; /* It's not a page fault, shouldn't happen */ diff --git a/migration/trace-events b/migration/trace-events index XXXXXXX..XXXXXXX 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -XXX,XX +XXX,XX @@ loadvm_postcopy_handle_run(void) "" loadvm_postcopy_handle_resume(void) "" loadvm_postcopy_ram_handle_discard(void) "" loadvm_postcopy_ram_handle_discard_end(void) "" -loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len) "%s: %ud" +loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len) "%s: %u" loadvm_process_command(const char *s, uint16_t len) "com=%s len=%d" loadvm_process_command_ping(uint32_t val) "0x%x" loadvm_approve_switchover(unsigned int switchover_ack_pending_num) "Switchover ack pending num=%u" postcopy_ram_listen_thread_exit(void) "" postcopy_ram_listen_thread_start(void) "" qemu_savevm_send_postcopy_advise(void) "" -qemu_savevm_send_postcopy_ram_discard(const char *id, uint16_t len) "%s: %ud" +qemu_savevm_send_postcopy_ram_discard(const char *id, uint16_t len) "%s: %u" savevm_command_send(uint16_t command, uint16_t len) "com=0x%x len=%d" savevm_section_start(const char *id, unsigned int section_id) "%s, section_id %u" savevm_section_end(const char *id, unsigned int section_id, int ret) "%s, section_id %u -> %d" @@ -XXX,XX +XXX,XX @@ colo_flush_ram_cache_begin(uint64_t dirty_pages) "dirty_pages %" PRIu64 colo_flush_ram_cache_end(void) "" save_xbzrle_page_skipping(void) "" save_xbzrle_page_overflow(void) "" -ram_save_iterate_big_wait(uint64_t milliconds, int iterations) "big wait: %" PRIu64 " milliseconds, %d iterations" +ram_save_iterate_big_wait(uint64_t milliseconds, int iterations) "big wait: %" PRIu64 " milliseconds, %d iterations" ram_load_start(void) "" ram_load_complete(int ret, uint64_t seq_iter) "exit_code %d seq iteration %" PRIu64 ram_write_tracking_ramblock_start(const char *block_id, size_t page_size, void *addr, size_t length) "%s: page_size: %zu addr: %p length: %zu" -- 2.54.0
From: Bin Guo <guobin@linux.alibaba.com> vcpu_faults_current[] is uint8_t. The overflow assert was checked after the post-increment, so 255 would wrap to 0 and the assert would pass silently. Move the check before the increment and use < 255. Signed-off-by: Bin Guo <guobin@linux.alibaba.com> Link: https://lore.kernel.org/r/20260716101952.65329-2-guobin@linux.alibaba.com Signed-off-by: Peter Xu <peterx@redhat.com> --- migration/postcopy-ram.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index XXXXXXX..XXXXXXX 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -XXX,XX +XXX,XX @@ void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid, /* * Account how many concurrent faults on this vCPU we trapped. See * comments above vcpu_faults_current[] on why it can be more than one. + * + * vcpu_faults_current[] is uint8_t, so assert before incrementing to + * catch overflow before it wraps. */ + assert(dc->vcpu_faults_current[cpu] < 255); if (dc->vcpu_faults_current[cpu]++ == 0) { dc->smp_cpus_down++; /* @@ -XXX,XX +XXX,XX @@ void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid, */ dc->last_begin = current; } - - /* Making sure it won't overflow - it really should never! */ - assert(dc->vcpu_faults_current[cpu] <= 255); } else { /* * For non-vCPU thread faults, we don't care about tid or cpu index -- 2.54.0
From: Bin Guo <guobin@linux.alibaba.com> Small cleanups for the postcopy blocktime fine-grained tracking feature: * Remove a redundant memset() on latency_buckets after g_new0(). * Use singular "Latency" in the HMP label for postcopy non-vCPU latency, consistent with other single-value labels. Signed-off-by: Bin Guo <guobin@linux.alibaba.com> Link: https://lore.kernel.org/r/20260716101952.65329-4-guobin@linux.alibaba.com Signed-off-by: Peter Xu <peterx@redhat.com> --- migration/migration-hmp-cmds.c | 2 +- migration/postcopy-ram.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index XXXXXXX..XXXXXXX 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -XXX,XX +XXX,XX @@ static void migration_dump_blocktime(Monitor *mon, MigrationInfo *info) } if (info->has_postcopy_non_vcpu_latency) { - monitor_printf(mon, "Postcopy non-vCPU Latencies (ns): %" PRIu64 "\n", + monitor_printf(mon, "Postcopy non-vCPU Latency (ns): %" PRIu64 "\n", info->postcopy_non_vcpu_latency); } diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index XXXXXXX..XXXXXXX 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -XXX,XX +XXX,XX @@ static struct PostcopyBlocktimeContext *blocktime_context_new(void) unsigned int smp_cpus = ms->smp.cpus; PostcopyBlocktimeContext *ctx = g_new0(PostcopyBlocktimeContext, 1); - /* Initialize all counters to be zeros */ - memset(ctx->latency_buckets, 0, sizeof(ctx->latency_buckets)); - ctx->vcpu_blocktime_total = g_new0(uint64_t, smp_cpus); ctx->vcpu_faults_count = g_new0(uint64_t, smp_cpus); ctx->vcpu_faults_current = g_new0(uint8_t, smp_cpus); -- 2.54.0
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(-) -- 2.55.0
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/d7b2fbf6-f9fa-4b39-8f40-95b7d5d0d8fb@oss.qualcomm.com Suggested-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Link: https://lore.kernel.org/r/20260818172012.3052821-2-peterx@redhat.com Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Peter Xu <peterx@redhat.com> Cc: "Philippe Mathieu-Daudé" <philmd@mailo.com> Signed-off-by: Peter Xu <peterx@redhat.com> --- include/system/ram_addr.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/include/system/ram_addr.h b/include/system/ram_addr.h index XXXXXXX..XXXXXXX 100644 --- a/include/system/ram_addr.h +++ b/include/system/ram_addr.h @@ -XXX,XX +XXX,XX @@ #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 -- 2.55.0
Now since ram_addr_t has switched to u64, remove the forced cast as not needed. Suggested-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260818172012.3052821-3-peterx@redhat.com Cc: Peter Maydell <peter.maydell@linaro.org> Cc: qemu-arm@nongnu.org Signed-off-by: Peter Xu <peterx@redhat.com> --- hw/arm/vexpress.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -XXX,XX +XXX,XX @@ 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. */ -- 2.55.0
QEMU has switched to 64bit-only hosts for all system emulations. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260818172012.3052821-4-peterx@redhat.com Cc: Peter Maydell <peter.maydell@linaro.org> Cc: qemu-arm@nongnu.org Signed-off-by: Peter Xu <peterx@redhat.com> --- hw/arm/mps2-tz.c | 9 --------- hw/arm/mps3r.c | 8 -------- 2 files changed, 17 deletions(-) diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/mps2-tz.c +++ b/hw/arm/mps2-tz.c @@ -XXX,XX +XXX,XX @@ 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 diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/mps3r.c +++ b/hw/arm/mps3r.c @@ -XXX,XX +XXX,XX @@ 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: -- 2.55.0
QEMU has switched to 64bit-only hosts for all system emulations. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Link: https://lore.kernel.org/r/20260818172012.3052821-5-peterx@redhat.com Cc: Stefano Stabellini <sstabellini@kernel.org> Cc: Anthony PERARD <anthony@xenproject.org> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com> Cc: xen-devel@lists.xenproject.org Signed-off-by: Peter Xu <peterx@redhat.com> --- hw/xen/xen-mapcache.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index XXXXXXX..XXXXXXX 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -XXX,XX +XXX,XX @@ #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. @@ -XXX,XX +XXX,XX @@ 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; -- 2.55.0
QEMU has switched to 64bit-only hosts for all system/user emulations. Reviewed-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Link: https://lore.kernel.org/r/20260818172012.3052821-6-peterx@redhat.com Cc: Warner Losh <imp@bsdimp.com> Cc: Kyle Evans <kevans@freebsd.org> Signed-off-by: Peter Xu <peterx@redhat.com> --- bsd-user/thunk.c | 47 +++-------------------------------------------- 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/bsd-user/thunk.c b/bsd-user/thunk.c index XXXXXXX..XXXXXXX 100644 --- a/bsd-user/thunk.c +++ b/bsd-user/thunk.c @@ -XXX,XX +XXX,XX @@ 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: @@ -XXX,XX +XXX,XX @@ 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 @@ -XXX,XX +XXX,XX @@ 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; @@ -XXX,XX +XXX,XX @@ 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)); -- 2.55.0
QEMU has switched to 64bit-only hosts for all system/user emulations. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Link: https://lore.kernel.org/r/20260818172012.3052821-7-peterx@redhat.com Cc: Laurent Vivier <laurent@vivier.eu> Cc: Helge Deller <deller@gmx.de> Cc: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Signed-off-by: Peter Xu <peterx@redhat.com> --- linux-user/thunk.c | 47 +++------------------------------------------- 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/linux-user/thunk.c b/linux-user/thunk.c index XXXXXXX..XXXXXXX 100644 --- a/linux-user/thunk.c +++ b/linux-user/thunk.c @@ -XXX,XX +XXX,XX @@ 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: @@ -XXX,XX +XXX,XX @@ 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 @@ -XXX,XX +XXX,XX @@ 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; @@ -XXX,XX +XXX,XX @@ 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)); -- 2.55.0
QEMU has switched to 64bit-only hosts for all system/user emulations. It's not needed anymore. Reviewed-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260818172012.3052821-8-peterx@redhat.com Cc: "Cédric Le Goater" <clg@kaod.org> Cc: Peter Maydell <peter.maydell@linaro.org> Cc: Steven Lee <steven_lee@aspeedtech.com> Cc: Troy Lee <leetroy@gmail.com> Cc: Jamin Lin <jamin_lin@aspeedtech.com> Cc: Kane Chen <kane_chen@aspeedtech.com> Cc: Andrew Jeffery <andrew@codeconstruct.com.au> Cc: Joel Stanley <joel@jms.id.au> Cc: qemu-arm@nongnu.org [peterx: fix aspeed_ast2600_sanmiguel.c, recently added in b6bcec6c2] Signed-off-by: Peter Xu <peterx@redhat.com> --- 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(-) diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h index XXXXXXX..XXXXXXX 100644 --- a/include/hw/arm/aspeed.h +++ b/include/hw/arm/aspeed.h @@ -XXX,XX +XXX,XX @@ 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; diff --git a/hw/arm/aspeed_ast2600_anacapa.c b/hw/arm/aspeed_ast2600_anacapa.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/aspeed_ast2600_anacapa.c +++ b/hw/arm/aspeed_ast2600_anacapa.c @@ -XXX,XX +XXX,XX @@ #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. diff --git a/hw/arm/aspeed_ast2600_bletchley.c b/hw/arm/aspeed_ast2600_bletchley.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/aspeed_ast2600_bletchley.c +++ b/hw/arm/aspeed_ast2600_bletchley.c @@ -XXX,XX +XXX,XX @@ /* 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) { diff --git a/hw/arm/aspeed_ast2600_catalina.c b/hw/arm/aspeed_ast2600_catalina.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/aspeed_ast2600_catalina.c +++ b/hw/arm/aspeed_ast2600_catalina.c @@ -XXX,XX +XXX,XX @@ /* 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" diff --git a/hw/arm/aspeed_ast2600_fby35.c b/hw/arm/aspeed_ast2600_fby35.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/aspeed_ast2600_fby35.c +++ b/hw/arm/aspeed_ast2600_fby35.c @@ -XXX,XX +XXX,XX @@ #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, diff --git a/hw/arm/aspeed_ast2600_fuji.c b/hw/arm/aspeed_ast2600_fuji.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/aspeed_ast2600_fuji.c +++ b/hw/arm/aspeed_ast2600_fuji.c @@ -XXX,XX +XXX,XX @@ /* 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) diff --git a/hw/arm/aspeed_ast2600_gb200nvl.c b/hw/arm/aspeed_ast2600_gb200nvl.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/aspeed_ast2600_gb200nvl.c +++ b/hw/arm/aspeed_ast2600_gb200nvl.c @@ -XXX,XX +XXX,XX @@ /* 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, diff --git a/hw/arm/aspeed_ast2600_sanmiguel.c b/hw/arm/aspeed_ast2600_sanmiguel.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/aspeed_ast2600_sanmiguel.c +++ b/hw/arm/aspeed_ast2600_sanmiguel.c @@ -XXX,XX +XXX,XX @@ /* 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" -- 2.55.0
QEMU has switched to 64bit-only hosts for all system/user emulations. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260818172012.3052821-9-peterx@redhat.com Cc: Peter Maydell <peter.maydell@linaro.org> Cc: "Philippe Mathieu-Daudé" <philmd@mailo.com> Cc: qemu-arm@nongnu.org Signed-off-by: Peter Xu <peterx@redhat.com> --- hw/arm/raspi4b.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c index XXXXXXX..XXXXXXX 100644 --- a/hw/arm/raspi4b.c +++ b/hw/arm/raspi4b.c @@ -XXX,XX +XXX,XX @@ 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; -- 2.55.0
QEMU has switched to 64bit-only hosts for all system/user emulations. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Link: https://lore.kernel.org/r/20260818172012.3052821-10-peterx@redhat.com Cc: "Philippe Mathieu-Daudé" <philmd@mailo.com> Cc: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Peter Xu <peterx@redhat.com> --- hw/core/machine.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index XXXXXXX..XXXXXXX 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -XXX,XX +XXX,XX @@ 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); -- 2.55.0
From: Philippe Mathieu-Daudé <philmd@redhat.com> 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 Reported-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Bin Meng <bin.meng@processmission.com> Link: https://lore.kernel.org/r/20260822122710.3731595-2-bin.meng@processmission.com Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Peter Xu <peterx@redhat.com> Cc: "Philippe Mathieu-Daudé" <philmd@mailo.com> Signed-off-by: Peter Xu <peterx@redhat.com> --- system/physmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/physmem.c b/system/physmem.c index XXXXXXX..XXXXXXX 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -XXX,XX +XXX,XX @@ 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; -- 2.55.0
From: Cam Miller <cam@linux.ibm.com> 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 <qemu-stable@nongnu.org> Fixes: cc9c77f4ddf0 ("system/memory: implement RamDiscardManager multi-source aggregation") Reported-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Cam Miller <cam@linux.ibm.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Link: https://lore.kernel.org/r/20260914-vmem_fix-v1-1-f69ef04a07b0@linux.ibm.com Signed-off-by: Peter Xu <peterx@redhat.com> --- system/ram-discard-manager.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/system/ram-discard-manager.c b/system/ram-discard-manager.c index XXXXXXX..XXXXXXX 100644 --- a/system/ram-discard-manager.c +++ b/system/ram-discard-manager.c @@ -XXX,XX +XXX,XX @@ 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; } @@ -XXX,XX +XXX,XX @@ 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; -- 2.55.0