Skip to contentSkip to conversation

hw/cxl, hw/machine, hw/i386: Misc minor fixes / cleanup

PATCH In review Jonathan Cameron via 3 participants 6 messages Jul 1, 2022 – Jul 19, 2022

lore
Share & tools
lore
#0 lore raw

cover hw/cxl, hw/machine, hw/i386: Misc minor fixes / cleanup

Three more or less less unrelated fixes for recently added CXL code.

Jonathan Cameron (3):
hw/machine: Clear out left over CXL related pointer from move of state
handling to machines.
hw/i386/pc: Always place CXL Memory Regions after device_memory hw/cxl: Fix size of constant in interleave granularity function.

 hw/i386/pc.c                   | 6 ++----
 include/hw/boards.h            | 1 -
 include/hw/cxl/cxl_component.h | 2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/3 hw/machine: Clear out left over CXL related pointer from move of state handling to machines.

This got left behind in the move of the CXL setup code from core files to the machines that support it.

---
 include/hw/boards.h | 1 -
 1 file changed, 1 deletion(-)
include/hw/boards.h +0 -1
index d94edcef28..7b416c9787 100644
@@ -360,7 +360,6 @@ struct MachineState {
     CpuTopology smp;
     struct NVDIMMState *nvdimms_state;
     struct NumaState *numa_state;
-    CXLFixedMemoryWindowOptionsList *cfmws_list;
 };
 
 #define DEFINE_MACHINE(namestr, machine_initfn) \
Signature · 1 line
2.32.0
#2 lore raw

PATCH 2/3 hw/i386/pc: Always place CXL Memory Regions after device_memory

In reply to Jonathan Cameron via

Previously broken_reserved_end was taken into account, but Igor Mammedov identified that this could lead to a clash between potential RAM being mapped in the region and CXL usage. Hence always add the size of the device_memory memory region. This only affects the case where the broken_reserved_end flag was set.

Fixes 6e4e3ae936e6 ("hw/cxl/component: Implement host bridge MMIO (8.2.5, table 142)")
---
 hw/i386/pc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
hw/i386/pc.c +2 -4
index 774cb2bf07..8d68295fda 100644
@@ -922,10 +922,8 @@ void pc_memory_init(PCMachineState *pcms,
         hwaddr cxl_size = MiB;
 
         if (pcmc->has_reserved_memory && machine->device_memory->base) {
-            cxl_base = machine->device_memory->base;
-            if (!pcmc->broken_reserved_end) {
-                cxl_base += memory_region_size(&machine->device_memory->mr);
-            }
+            cxl_base = machine->device_memory->base
+                + memory_region_size(&machine->device_memory->mr);
         } else if (pcms->sgx_epc.size != 0) {
             cxl_base = sgx_epc_above_4g_end(&pcms->sgx_epc);
         } else {
Signature · 1 line
2.32.0
#3 lore raw

PATCH 3/3 hw/cxl: Fix size of constant in interleave granularity function.

In reply to Jonathan Cameron via

Whilst the interleave granularity is always small enough that this isn't a real problem (much less than 4GiB) let's change the constant to ULL to fix the coverity warning.

Fixes 829de299d1 ("hw/cxl/component: Add utils for interleave parameter encoding/decoding")
Fixes Coverity CID 1488868
---
 include/hw/cxl/cxl_component.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/cxl/cxl_component.h +1 -1
index 70b5018156..94ec2f07d7 100644
@@ -215,7 +215,7 @@ uint8_t cxl_interleave_granularity_enc(uint64_t gran, Error **errp);
 
 static inline hwaddr cxl_decode_ig(int ig)
 {
-    return 1 << (ig + 8);
+    return 1ULL << (ig + 8);
 }
 
 CXLComponentState *cxl_get_hb_cstate(PCIHostState *hb);
Signature · 1 line
2.32.0
Acked-by on the v1 series
#4 lore raw
In reply to Jonathan Cameron via
Quoted 8 lines · On Fri, 1 Jul 2022 14:22:57 +0100 Jonathan Cameron via <[email protected]>…

Three more or less less unrelated fixes for recently added CXL code.

Jonathan Cameron (3):
hw/machine: Clear out left over CXL related pointer from move of state
handling to machines.
hw/i386/pc: Always place CXL Memory Regions after device_memory hw/cxl: Fix size of constant in interleave granularity function.

Quoted 5 lines
 hw/i386/pc.c                   | 6 ++----
 include/hw/boards.h            | 1 -
 include/hw/cxl/cxl_component.h | 2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)

For whole series:

#5 lore raw
In reply to Jonathan Cameron via
Quoted 8 lines · Jonathan Cameron

Three more or less less unrelated fixes for recently added CXL code.

Jonathan Cameron (3):
hw/machine: Clear out left over CXL related pointer from move of state
handling to machines.
hw/i386/pc: Always place CXL Memory Regions after device_memory hw/cxl: Fix size of constant in interleave granularity function.

Hi -- did this patch series get lost somewhere? I was going through old Coverity issues, and noticed the fix in patch 3 is still not upstream.

thanks
-- PMM