All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] hw/arm/raspi4b: fix guest RAM capped at ~1 GiB regardless of machine size
@ 2026-07-26 14:41 Marcelo Manzo
  2026-07-26 14:41 ` [PATCH 1/2] hw/arm/raspi4b: fix guest never seeing more than ~1 GiB of RAM Marcelo Manzo
  2026-07-26 14:41 ` [PATCH 2/2] tests/functional/aarch64: add raspi4b full-RAM regression test Marcelo Manzo
  0 siblings, 2 replies; 3+ messages in thread
From: Marcelo Manzo @ 2026-07-26 14:41 UTC (permalink / raw)
  To: qemu-devel, qemu-arm
  Cc: Peter Maydell, Philippe Mathieu-Daudé, Marcelo Manzo

While working on unrelated raspi4b issues, I noticed the guest never
seemed to have as much RAM as I'd given it and tracked it down to
hw/arm/raspi4b.c's raspi4_modify_dtb(): it 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
where it's allowed to place 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 -- the second node was never added, and the
guest never saw more than ~1 GiB of RAM regardless of the machine's
nominal size. board_ram_size(info->board_id), computed one line above
in the same function, is the value that was actually needed.

Patch 1 fixes it (one line); patch 2 adds a regression test.

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

    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.

I also looked into extending this to raspi4b's real 4 GiB and 8 GiB
hardware variants (real boards exist in 1/2/4/8 GiB configurations),
since board_ram_size()'s encoding already supports arbitrary sizes and
this same bug meant the necessary split-memory-node path had never
actually been exercised at any size, ever. 2 GiB now works cleanly
with this fix (tested above); 4 GiB hits a real kernel panic
(`kernel BUG at arch/arm64/mm/mmu.c:192!` in early page-table setup,
addresses landing in the BCM2711 peripheral region around 0xfc000000)
that looks like it needs the "high peripheral alias" real BCM2711
firmware sets up for boards with enough RAM to otherwise collide with
that region -- out of scope for this series, so I'm leaving 4/8 GiB
support for later and keeping this fix minimal.

checkpatch.pl is clean (0 errors, 0 warnings) on both patches, and the
series builds standalone from a clean worktree
(--target-list=aarch64-softmmu). All 6 tests in
tests/functional/aarch64/test_raspi4.py pass, including the 5
pre-existing ones (no regression) and the new one added here.

Marcelo Manzo (2):
  hw/arm/raspi4b: fix guest never seeing more than ~1 GiB of RAM
  tests/functional/aarch64: add raspi4b full-RAM regression test

 hw/arm/raspi4b.c                        | 14 ++++++-
 tests/functional/aarch64/test_raspi4.py | 51 +++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 1 deletion(-)

-- 
2.47.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-26 14:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-26 14:41 [PATCH 0/2] hw/arm/raspi4b: fix guest RAM capped at ~1 GiB regardless of machine size Marcelo Manzo
2026-07-26 14:41 ` [PATCH 1/2] hw/arm/raspi4b: fix guest never seeing more than ~1 GiB of RAM Marcelo Manzo
2026-07-26 14:41 ` [PATCH 2/2] tests/functional/aarch64: add raspi4b full-RAM regression test Marcelo Manzo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.