DRAM region is dynamically set and the last valid physical address region with LoongArch Virt Machine. To record the last valid physical address, field ram_end is added in structure LoongArchVirtMachineState. In future end address of DRAM cannot exceed base addres of PCIE 64-bit MMIO region.
Signed-off-by: Bibo Mao <[email protected]> --- hw/loongarch/virt.c | 2 ++ include/hw/loongarch/virt.h | 1 + 2 files changed, 3 insertions(+) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index c1760423ee..8740a3cf4b 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -850,8 +850,10 @@ static void virt_init(MachineState *machine) exit(EXIT_FAILURE); } machine_memory_devices_init(machine, base, device_mem_size); + base += device_mem_size; } + lvms->ram_end = base; /* load the BIOS image. */ virt_firmware_init(lvms); diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h index 76fa57cd07..224a66d3cc 100644 --- a/include/hw/loongarch/virt.h +++ b/include/hw/loongarch/virt.h @@ -90,6 +90,7 @@ struct LoongArchVirtMachineState { uint64_t misc_feature; uint64_t misc_status; DeviceState *dintc; + hwaddr ram_end; }; #define TYPE_LOONGARCH_VIRT_MACHINE MACHINE_TYPE_NAME("virt") -- 2.39.3
