[PATCH] hw/sparc64/niagara: use int64_t for vdisk size to avoid truncation

Dmitry Pimenov posted 1 patch 1 day, 1 hour ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260710222350.9185-1-sun4qemu@gmail.com
Maintainers: Artyom Tarasenko <atar4qemu@gmail.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
hw/sparc64/niagara.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] hw/sparc64/niagara: use int64_t for vdisk size to avoid truncation
Posted by Dmitry Pimenov 1 day, 1 hour ago
blk_getlength() returns int64_t, but niagara_init() stored it in an int,
truncating the if=pflash virtual-ramdisk size for images >= 2 GiB. A ~4 GiB
image truncated to 0/negative, failed the `size > 0` check, and exit(1)'d
before the CPU ran, ending with:

  qemu-system-sparc64: could not load ram disk

AI-used-for: code (bug fix)
Signed-off-by: Dmitry Pimenov <sun4qemu@gmail.com>
---
 hw/sparc64/niagara.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
index 1211ecb82d..ad5e5945a8 100644
--- a/hw/sparc64/niagara.c
+++ b/hw/sparc64/niagara.c
@@ -137,7 +137,7 @@ static void niagara_init(MachineState *machine)
        outside of the partition RAM */
     if (dinfo) {
         BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
-        int size = blk_getlength(blk);
+        int64_t size = blk_getlength(blk);
         if (size > 0) {
             memory_region_init_ram(&s->vdisk_ram, NULL, "sun4v_vdisk.ram", size,
                                    &error_fatal);
--
2.43.0