From: Ani Sinha Date: Wed, 11 Oct 2023 10:53:35 +0000 (+0530) Subject: hw/i386/cxl: ensure maxram is greater than ram size for calculating cxl range X-Git-Tag: v8.2.0-rc0~53^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4076bc86a3afd626338f2e3d018f6b884a972143;p=thirdparty%2Fqemu.git hw/i386/cxl: ensure maxram is greater than ram size for calculating cxl range pc_get_device_memory_range() finds the device memory size by calculating the difference between maxram and ram sizes. This calculation makes sense only when maxram is greater than the ram size. Make sure we check for that before calling pc_get_device_memory_range(). Signed-off-by: Ani Sinha Message-Id: <20231011105335.42296-1-anisinha@redhat.com> Acked-by: Jonathan Cameron Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 6293f57a0c7..dbaefa76176 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -781,10 +781,12 @@ static void pc_get_device_memory_range(PCMachineState *pcms, static uint64_t pc_get_cxl_range_start(PCMachineState *pcms) { PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); + MachineState *ms = MACHINE(pcms); hwaddr cxl_base; ram_addr_t size; - if (pcmc->has_reserved_memory) { + if (pcmc->has_reserved_memory && + (ms->ram_size < ms->maxram_size)) { pc_get_device_memory_range(pcms, &cxl_base, &size); cxl_base += size; } else {