Commit c59b691626 for qemu.org

commit c59b6916269d8d813399bfc02c75207b0bef91c6
Author: Marcelo Manzo <marcelomanzo@gmail.com>
Date:   Tue Aug 11 10:35:38 2026 -0400

    hw/arm/raspi4b: fix guest never seeing more than ~1 GiB of RAM

    raspi4_modify_dtb() decides whether to add a second memory node above
    the 1 GiB peripheral hole by checking info->ram_size -- but that field
    is the boot loader's RAM budget for loading the kernel/initrd/dtb
    image, itself always capped to at most UPPER_RAM_BASE - vcram_size by
    raspi_base_machine_init(). Since that capped value can never exceed
    UPPER_RAM_BASE by construction, the condition was never true for any
    raspi4b configuration, and the second node was never added: the guest
    never saw more than ~1 GiB of its nominal RAM, regardless of the
    machine's actual size.

    board_ram_size(info->board_id), computed one line above in the same
    function, is the value that was actually needed -- the board's real
    total RAM, not the boot loader's own budget for where it's allowed to
    place the kernel image.

    Confirmed via direct measurement inside the guest ("free -h" /
    /proc/meminfo) on raspi4b's default 2 GiB configuration, before and
    after:

        before: MemTotal:  943524 kB (~921 MiB)
        after:  MemTotal: 1905824 kB (~1861 MiB)

    Also verified against two real, unmodified Raspberry Pi OS releases
    (Debian 11/Bullseye and Debian 13/Trixie): both now report ~1.8 GiB of
    usable RAM instead of ~900 MiB, with clean boots, working SSH, and no
    kernel errors on either.

    Signed-off-by: Marcelo Manzo <marcelomanzo@gmail.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
    Message-id: 20260811143539.7835-2-marcelomanzo@gmail.com
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c
index 06aeb8db01..e1595a875f 100644
--- a/hw/arm/raspi4b.c
+++ b/hw/arm/raspi4b.c
@@ -85,7 +85,7 @@ static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt)

     ram_size = board_ram_size(info->board_id);

-    if (info->ram_size > UPPER_RAM_BASE) {
+    if (ram_size > UPPER_RAM_BASE) {
         raspi_add_memory_node(fdt, UPPER_RAM_BASE, ram_size - UPPER_RAM_BASE);
     }
 }