qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] hw/i386/cxl: ensure maxram is greater than ram size for calculat


From: Ani Sinha
Subject: [PATCH] hw/i386/cxl: ensure maxram is greater than ram size for calculating cxl range
Date: Wed, 11 Oct 2023 16:23:35 +0530

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 <anisinha@redhat.com>
---
 hw/i386/pc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f72e2c3b35..948c58171c 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -820,10 +820,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 {
-- 
2.42.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]