On Thu, Nov 29, 2018 at 05:37:45PM +0000, Rob Bradford wrote:
If there is a QEMU FW CFG variable for memory available then always use it instead of CMOS. We cannot extract the values from E820 tables yet as that code assumes a working malloc.
Failed in testing.
Try a guest with 4G RAM, seabios falls back to cmos.
Try a guest with q35 and 7G RAM, seabios thinks it has 3G of low mem even though it actually has 2G only.
- // Prefer QEMU FW CFG entry over CMOS for initial RAM sizes
- if (qemu_cfg_enabled()) {
qemu_cfg_read_entry(&RamSize, 0x03, sizeof(RamSize));
if (RamSize > 0) {
e820_add(0, RamSize, E820_RAM);
dprintf(1, "RamSize: 0x%08x [fw_cfg]\n", RamSize);
}
- }
You are loosing the high bits here, RamSize is a 32bit variable.
Another problem is that you only get the total amout of memory here, not the mapping.
I think there is no way around scanning the e820 table (etc/e830 fw_cfg file) for the ram entry with the zero start address to figure the amout of ram you have below 4G.
cheers, Gerd