hw/cxl: Add a performant (and correct) path for the non interleaved cases
v6 cover hw/cxl: Add a performant (and correct) path for the non interleaved cases
Hey everyone,
This is v6 of performant CXL type 3 regions set:
v5 -> v6:
- Use object_unparent() in the third commit when deleting alias regions.
- Thanks to Gregory for the suggestion and testing.
v4 -> v5:
- Fixed some minor patch style like missing trailing white space and such.
v3 -> v4:
- Tear down path changed, given that it is done differently than setup.
- Dropped Gregory's tested-by tag due to tear down changes.
v2 -> v3:
- Addressing Zhijian Li. Thanks for the feedback.
v1 -> v2:
- Mainly rebase.
==========================================================
The CXL address to device decoding logic is complex because of the need to correctly decode fine grained interleave. The current implementation prevents use with KVM where executed instructions may reside in that memory and gives very slow performance even in TCG.
In many real cases non interleaved memory configurations are useful and for those we can use a more conventional memory region alias allowing similar performance to other memory in the system.
Whether this fast path is applicable can be established once the full set of HDM decoders has been committed (in whatever order the guest decides to commit them). As such a check is performed on each commit / uncommit of HDM decoder to establish if the alias should be added or removed.
Performance numbers:
For a read/write test with 4K block size, 256M region size, and 1 thread with 100 iteration on TCG (it should do similar on KVM):
- Non-interleaved region (fast path): 25-30 seconds.
- Interleaved region (no fast path): Never finishes within 10 minutes.
Tested Topologies and Region Layouts
====================================
This series was validated across multiple CXL topology configurations, covering single-device, multi-device, multi-host-bridge, and switched fabrics. Region creation was exercised using the cxl userspace tool with both non-interleaved and interleaved setups.
Decoder and memdev identifiers were discovered using:
cxl list
cxl list -D
Decoder IDs (e.g. decoder0.0) and memdev names (mem0, mem1) are environment-specific. Commands below use placeholders such as <decoder_span_both> which should be replaced with IDs from cxl list -D.
---------------------------------------------------------------------
Region Layout Notation
----------------------
CFMW (CXL Fixed Memory Window) is shown as a linear address space containing regions:
CFMW: [ R0 | R1 | R2 ]
R0, R1, R2 are regions created by cxl create-region.
Non-interleaved region:
R0 (ways=1) -> entirely on one device (mem0 or mem1) Fast path: APPLICABLE
2-way interleaved region (g=256):
R1 (ways=2, g=256) striped across devices:
|mem0|mem1|mem0|mem1|mem0|mem1| ...
256 256 256 256 256 256 bytesFast path: NOT APPLICABLE
---------------------------------------------------------------------
1) One device, one host bridge, one fixed window
------------------------------------------------
QEMU:
-M q35,cxl=on,cxl-fmw.0.targets.0=cxl.0,cxl-fmw.0.size=4G -device pxb-cxl,id=cxl.0,bus=pcie.0,bus_nr=12 -device cxl-rp,id=rp0,bus=cxl.0,port=0,chassis=0,slot=2 -object memory-backend-ram,id=mem0,size=512M,share=on -device cxl-type3,id=dev0,bus=rp0,memdev=mem0
Topology:
Host
|
+-- CXL Host Bridge (cxl.0)
|
+-- Root Port (rp0)
|
+-- Type-3 (dev0, mem0)Regions created:
cxl create-region ... -w 1 ... mem0 (Fast path: YES)
cxl create-region ... -w 1 ... mem0 (Fast path: YES)
Layout:
CFMW: [ R0 | R1 ]
R0 -> mem0 (Fast path: YES)
R1 -> mem0 (Fast path: YES)
---------------------------------------------------------------------
2) One host bridge, two Type-3 devices (via two root ports)
------------------------------------------------------------
QEMU:
-M q35,cxl=on,cxl-fmw.0.targets.0=cxl.0,cxl-fmw.0.size=4G -device pxb-cxl,id=cxl.0,bus=pcie.0,bus_nr=12 -device cxl-rp,id=rp0,bus=cxl.0,port=0,chassis=0,slot=2 -device cxl-rp,id=rp1,bus=cxl.0,port=1,chassis=0,slot=3 -object memory-backend-ram,id=mem0,size=512M,share=on -object memory-backend-ram,id=mem1,size=512M,share=on -device cxl-type3,id=dev0,bus=rp0,memdev=mem0 -device cxl-type3,id=dev1,bus=rp1,memdev=mem1
Topology:
Host
|
+-- CXL Host Bridge (cxl.0)
|
+-- Root Port (rp0) -- Type-3 (dev0, mem0)
|
+-- Root Port (rp1) -- Type-3 (dev1, mem1)Region patterns exercised:
2.1 All non-interleaved:
R0 -> mem0 (Fast path: YES) R1 -> mem0 (Fast path: YES) R2 -> mem1 (Fast path: YES) R3 -> mem1 (Fast path: YES)
2.2 Interleaved + local:
R0 -> mem0/mem1 interleaved (Fast path: NO)
R1 -> mem0 (Fast path: YES)
2.3 Local + interleaved + local:
R0 -> mem0 (Fast path: YES) R1 -> mem0/mem1 interleaved (Fast path: NO) R2 -> mem1 (Fast path: YES)
---------------------------------------------------------------------
3) Two host bridges, one device per host bridge
------------------------------------------------
QEMU:
-M q35,cxl=on,
cxl-fmw.0.targets.0=cxl.0,cxl-fmw.0.size=4G,
cxl-fmw.1.targets.0=cxl.1,cxl-fmw.1.size=4G,
cxl-fmw.2.targets.0=cxl.0,cxl-fmw.2.size=4G-device pxb-cxl,id=cxl.0,bus=pcie.0,bus_nr=12 -device cxl-rp,id=rp0,bus=cxl.0,port=0,chassis=0,slot=2 -object memory-backend-ram,id=mem0,size=512M,share=on -device cxl-type3,id=dev0,bus=rp0,memdev=mem0 -device pxb-cxl,id=cxl.1,bus=pcie.0,bus_nr=13 -device cxl-rp,id=rp1,bus=cxl.1,port=0,chassis=1,slot=2 -object memory-backend-ram,id=mem1,size=512M,share=on -device cxl-type3,id=dev1,bus=rp1,memdev=mem1
Region patterns identical to section 2, and fast-path applicability is identical per region mapping (non-interleaved: YES, interleaved: NO).
---------------------------------------------------------------------
4) Switch topology
------------------
QEMU:
-M q35,cxl=on,cxl-fmw.0.targets.0=cxl.0,cxl-fmw.0.size=4G -device pxb-cxl,id=cxl.0,bus=pcie.0,bus_nr=12 -device cxl-rp,id=rp0,bus=cxl.0,port=0,chassis=0,slot=2 -device cxl-rp,id=rp1,bus=cxl.0,port=0,chassis=0,slot=3 -device cxl-upstream,id=us0,bus=rp0
-device cxl-downstream,id=ds0,bus=us0,port=0,chassis=0,slot=4 -object memory-backend-ram,id=mem0,size=512M,share=on -device cxl-type3,id=dev0,bus=ds0,memdev=mem0
Topology (detailed):
Host
|
+-- CXL Host Bridge (cxl.0)
|
+-- Root Port (rp0)
| |
| +-- CXL Switch (upstream us0)
| |
| +-- Downstream Port (ds0) -- Type-3 (mem0)
| |
| +-- Downstream Port (ds1) -- Type-3 (mem1) [optional]
+-- Root Port (rp1)
|
+-- More devices/switches.Fast-path interpretation in this topology:
If only mem0 exists:
All regions -> Fast path: YES
If mem0 and mem1 exist:
Non-interleaved regions -> Fast path: YES
Interleaved regions -> Fast path: NO---------------------------------------------------------------------
Summary
-------
Across all topologies, region creation, enablement, and HDM decoder commit/uncommit flows were exercised. The fast path is enabled only when all decoders describe a non-interleaved mapping and is removed when any interleave configuration is introduced.
Alireza Sanaee (3):
hw/cxl: Use HPA in cxl_cfmws_find_device() rather than offset in
window.
hw/cxl: Allow cxl_cfmws_find_device() to filter on whether interleaved
paths are accepted
hw/cxl: Add a performant (and correct) path for the non interleaved
cases
hw/cxl/cxl-component-utils.c | 6 + hw/cxl/cxl-host.c | 224 +++++++++++++++++++++++++++++++++-- hw/mem/cxl_type3.c | 4 + include/hw/cxl/cxl.h | 1 + include/hw/cxl/cxl_device.h | 4 + 5 files changed, 230 insertions(+), 9 deletions(-)
base-commit: 6593154e7d65f61d8f9dbeb98224731b7137c53e
Signature · 1 line
2.43.0
PATCH v6 1/3 hw/cxl: Use HPA in cxl_cfmws_find_device() rather than offset in window.
This function will shortly be used to help find if there is a route to a device, serving an HPA, under a particular fixed memory window. Rather than having that new use case subtract the base address in the caller, only to add it again in cxl_cfmws_find_device(), push the responsibility for calculating the HPA to the caller.
This also reduces the inconsistency in the meaning of the hwaddr addr parameter between this function and the calls made within it that access the HDM decoders that operating on HPA.
---
Change log:
v5-v6: No change.
hw/cxl/cxl-host.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
hw/cxl/cxl-host.c +2 -5
@@ -168,9 +168,6 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr)bool target_found;PCIDevice *rp, *d; -/* Address is relative to memory region. Convert to HPA */ - addr += fw->base; - rb_index = (addr /cxl_decode_ig (fw->enc_int_gran)) % fw->num_targets; hb =PCI_HOST_BRIDGE (fw->target_hbs[rb_index]->cxl_host_bridge);if (!hb || !hb->bus || !pci_bus_is_cxl (hb->bus)) {
@@ -254,7 +251,7 @@ static MemTxResult cxl_read_cfmws(void *opaque, hwaddr addr, uint64_t *data,CXLFixedWindow *fw = opaque;PCIDevice *d; - d =cxl_cfmws_find_device (fw, addr); + d =cxl_cfmws_find_device (fw, addr + fw->base);if (d ==NULL ) { *data =0 ;/* Reads to invalid address return poison */
@@ -271,7 +268,7 @@ static MemTxResult cxl_write_cfmws(void *opaque, hwaddr addr,CXLFixedWindow *fw = opaque;PCIDevice *d; - d =cxl_cfmws_find_device (fw, addr); + d =cxl_cfmws_find_device (fw, addr + fw->base);if (d ==NULL ) {/* Writes to invalid address are silent */ return MEMTX_OK ;
Signature · 1 line
2.43.0
Re: [PATCH v6 1/3] hw/cxl: Use HPA in cxl_cfmws_find_device() rather than offset in window.
Quoted 6 lines · Alireza Sanaee
This function will shortly be used to help find if there is a route to a device, serving an HPA, under a particular fixed memory window. Rather than having that new use case subtract the base address in the caller, only to add it again in
cxl_cfmws_find_device(), push the responsibility for calculating the HPA to the caller.
Quoted 6 lines
This also reduces the inconsistency in the meaning of the hwaddr addr parameter between this function and the calls made within it that access the HDM decoders that operating on HPA.
Reviewed-by Jonathan Cameron <[email protected]>Signed-off-by Alireza Sanaee <[email protected]>
PATCH v6 2/3 hw/cxl: Allow cxl_cfmws_find_device() to filter on whether interleaved paths are accepted
In reply to Alireza Sanaee via qemu developmentExtend cxl_cfmws_find_device() with a parameter that filters on whether the address lies in an interleaved range. For now all callers accept interleave configurations so no functional changes.
---
Change log:v5->v6: No change.
hw/cxl/cxl-host.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
hw/cxl/cxl-host.c +26 -7
@@ -104,7 +104,7 @@ void cxl_fmws_link_targets(Error **errp) }static bool cxl_hdm_find_target (uint32_t *cache_mem,hwaddr addr, -uint8_t *target) +uint8_t *target,bool *interleaved) {int hdm_inc =R_CXL_HDM_DECODER1_BASE_LO -R_CXL_HDM_DECODER0_BASE_LO ;unsigned int hdm_count;
@@ -138,6 +138,11 @@ static bool cxl_hdm_find_target(uint32_t *cache_mem, hwaddr addr, found = true; ig_enc =FIELD_EX32 (ctrl,CXL_HDM_DECODER0_CTRL ,IG ); iw_enc =FIELD_EX32 (ctrl,CXL_HDM_DECODER0_CTRL ,IW ); + +if (interleaved) { + *interleaved = iw_enc !=0 ; + } + target_idx = (addr /cxl_decode_ig (ig_enc)) % (1 << iw_enc);if (target_idx <4 ) {
@@ -157,7 +162,8 @@ static bool cxl_hdm_find_target(uint32_t *cache_mem, hwaddr addr,return found; } -static PCIDevice *cxl_cfmws_find_device (CXLFixedWindow *fw,hwaddr addr) +static PCIDevice *cxl_cfmws_find_device (CXLFixedWindow *fw,hwaddr addr, +bool allow_interleave) {CXLComponentState *hb_cstate, *usp_cstate;PCIHostState *hb;
@@ -165,9 +171,13 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr)int rb_index;uint32_t *cache_mem;uint8_t target; -bool target_found; +bool target_found, interleaved;PCIDevice *rp, *d; +if ((fw->num_targets >1 ) && !allow_interleave) { +return NULL ; + } + rb_index = (addr /cxl_decode_ig (fw->enc_int_gran)) % fw->num_targets; hb =PCI_HOST_BRIDGE (fw->target_hbs[rb_index]->cxl_host_bridge);if (!hb || !hb->bus || !pci_bus_is_cxl (hb->bus)) {
@@ -187,11 +197,16 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr) cache_mem = hb_cstate->crb.cache_mem_registers; - target_found =cxl_hdm_find_target (cache_mem, addr, &target); + target_found =cxl_hdm_find_target (cache_mem, addr, &target, + &interleaved);if (!target_found) {return NULL ; } +if (interleaved && !allow_interleave) { +return NULL ; + } + rp =pcie_find_port_by_pn (hb->bus, target);if (!rp) {return NULL ;
@@ -223,11 +238,15 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr) cache_mem = usp_cstate->crb.cache_mem_registers; - target_found =cxl_hdm_find_target (cache_mem, addr, &target); + target_found =cxl_hdm_find_target (cache_mem, addr, &target, &interleaved);if (!target_found) {return NULL ; } +if (interleaved && !allow_interleave) { +return NULL ; + } + d =pcie_find_port_by_pn (&PCI_BRIDGE (d)->sec_bus, target);if (!d) {return NULL ;
@@ -251,7 +270,7 @@ static MemTxResult cxl_read_cfmws(void *opaque, hwaddr addr, uint64_t *data,CXLFixedWindow *fw = opaque;PCIDevice *d; - d =cxl_cfmws_find_device (fw, addr + fw->base); + d =cxl_cfmws_find_device (fw, addr + fw->base, true);if (d ==NULL ) { *data =0 ;/* Reads to invalid address return poison */
@@ -268,7 +287,7 @@ static MemTxResult cxl_write_cfmws(void *opaque, hwaddr addr,CXLFixedWindow *fw = opaque;PCIDevice *d; - d =cxl_cfmws_find_device (fw, addr + fw->base); + d =cxl_cfmws_find_device (fw, addr + fw->base, true);if (d ==NULL ) {/* Writes to invalid address are silent */ return MEMTX_OK ;
Signature · 1 line
2.43.0
Re: [PATCH v6 2/3] hw/cxl: Allow cxl_cfmws_find_device() to filter on whether interleaved paths are accepted
Quoted 5 lines · Alireza Sanaee
Extend
cxl_cfmws_find_device()with a parameter that filters on whether the address lies in an interleaved range. For now all callers accept interleave configurations so no functional changes.Signed-off-by Alireza Sanaee <[email protected]>
PATCH v6 3/3 hw/cxl: Add a performant (and correct) path for the non interleaved cases
In reply to Alireza Sanaee via qemu developmentThe CXL address to device decoding logic is complex because of the need to correctly decode fine grained interleave. The current implementation prevents use with KVM where executed instructions may reside in that memory and gives very slow performance even in TCG.
In many real cases non interleaved memory configurations are useful and for those we can use a more conventional memory region alias allowing similar performance to other memory in the system.
Whether this fast path is applicable can be established once the full set of HDM decoders has been committed (in whatever order the guest decides to commit them). As such a check is performed on each commit/uncommit of HDM decoder to establish if the alias should be added or removed.
---
Thanks Gregory for the review and feedback on the previous versions.
Change log:
v5-v6: Use object_unparent() in the third commit when deleting alias regions.
hw/cxl/cxl-component-utils.c | 6 ++ hw/cxl/cxl-host.c | 190 +++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 4 + include/hw/cxl/cxl.h | 1 + include/hw/cxl/cxl_device.h | 4 + 5 files changed, 205 insertions(+)
hw/cxl/cxl-component-utils.c +6 -0
@@ -143,6 +143,12 @@ static void dumb_hdm_handler(CXLComponentState *cxl_cstate, hwaddr offset, value =FIELD_DP32 (value,CXL_HDM_DECODER0_CTRL ,COMMITTED ,0 ); }stl_le_p ((uint8_t *)cache_mem + offset, value); + +if (should_commit) { +cfmws_update_non_interleaved (true); + }else if (should_uncommit) { +cfmws_update_non_interleaved (false); + } } static void bi_handler(CXLComponentState *cxl_cstate, hwaddr offset,
hw/cxl/cxl-host.c +190 -0
196 lines not on this page · raw message
hw/mem/cxl_type3.c +4 -0
@@ -427,6 +427,8 @@ static void hdm_decoder_commit(CXLType3Dev *ct3d, int which) ctrl =FIELD_DP32 (ctrl,CXL_HDM_DECODER0_CTRL ,COMMITTED ,1 );stl_le_p (cache_mem +R_CXL_HDM_DECODER0_CTRL + which * hdm_inc, ctrl); + +cfmws_update_non_interleaved (true); }static void hdm_decoder_uncommit (CXLType3Dev *ct3d,int which)
@@ -442,6 +444,8 @@ static void hdm_decoder_uncommit(CXLType3Dev *ct3d, int which) ctrl =FIELD_DP32 (ctrl,CXL_HDM_DECODER0_CTRL ,COMMITTED ,0 );stl_le_p (cache_mem +R_CXL_HDM_DECODER0_CTRL + which * hdm_inc, ctrl); + +cfmws_update_non_interleaved (false); }static int ct3d_qmp_uncor_err_to_cxl (CxlUncorErrorType qmp_err)
include/hw/cxl/cxl.h +1 -0
@@ -71,4 +71,5 @@ CXLComponentState *cxl_usp_to_cstate(CXLUpstreamPort *usp);typedef struct CXLDownstreamPort CXLDownstreamPort ; DECLARE_INSTANCE_CHECKER(CXLDownstreamPort, CXL_DSP, TYPE_CXL_DSP) +bool cfmws_update_non_interleaved (bool commit);#endif
include/hw/cxl/cxl_device.h +4 -0
@@ -685,6 +685,8 @@ typedef struct CXLSetFeatureInfo {size_t data_size; } CXLSetFeatureInfo; +typedef struct CXLFixedWindow CXLFixedWindow ; +struct CXLSanitizeInfo ; typedef struct CXLAlertConfig {
@@ -712,6 +714,8 @@ struct CXLType3Dev {uint64_t sn;/* State */ +MemoryRegion direct_mr[CXL_HDM_DECODER_COUNT ]; +CXLFixedWindow *direct_mr_fw[CXL_HDM_DECODER_COUNT ];AddressSpace hostvmem_as;AddressSpace hostpmem_as;CXLComponentState cxl_cstate;
Signature · 1 line
2.43.0
(updated the recipient: s/[email protected]/[email protected])
Quoted 45 lines · Alireza Sanaee
The CXL address to device decoding logic is complex because of the need to correctly decode fine grained interleave. The current implementation prevents use with KVM where executed instructions may reside in that memory and gives very slow performance even in TCG.
In many real cases non interleaved memory configurations are useful and for those we can use a more conventional memory region alias allowing similar performance to other memory in the system.
Whether this fast path is applicable can be established once the full set of HDM decoders has been committed (in whatever order the guest decides to commit them). As such a check is performed on each commit/uncommit of HDM decoder to establish if the alias should be added or removed.
Co-developed-by Jonathan Cameron<[email protected]>Signed-off-by Jonathan Cameron<[email protected]>Signed-off-by Alireza Sanaee<[email protected]>---
Thanks Gregory for the review and feedback on the previous versions.Change log:
v5-v6: Useobject_unparent()in the third commit when deleting alias regions.hw/cxl/cxl-component-utils.c | 6 ++ hw/cxl/cxl-host.c | 190 +++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 4 + include/hw/cxl/cxl.h | 1 + include/hw/cxl/cxl_device.h | 4 + 5 files changed, 205 insertions(+)hw/cxl/cxl-component-utils.c +6
-0@@ -143,6 +143,12 @@ static void dumb_hdm_handler(CXLComponentState *cxl_cstate, hwaddr offset, value =FIELD_DP32 (value,CXL_HDM_DECODER0_CTRL ,COMMITTED ,0 ); }stl_le_p ((uint8_t *)cache_mem + offset, value); + +if (should_commit) { +cfmws_update_non_interleaved (true); + }else if (should_uncommit) { +cfmws_update_non_interleaved (false); + } }
[..snip...]
hw/cxl/cxl-component-utils.c
Quoted 11 lines
hw/cxl/cxl-component-utils.c +11
-0+ +bool cfmws_update_non_interleaved (bool commit) +{ +/* +* Walk endpoints to find both committed and uncommitted decoders, +* then check if they are not interleaved (but the path is fully set up). +*/ +object_child_foreach_recursive (object_get_root (), + update_non_interleaved, &commit); + +return false;
Since this function always returns false and its return value is never used, it can be defined as void. With that minor change, the patch looks good to me.
Quoted 2 lines
hw/cxl/cxl-component-utils.c +2
-0+} +
hw/cxl/cxl-host.c static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr, · line 399
Quoted 3 lines · Alireza Sanaee
hw/cxl/cxl-host.c +3
-0+/* +* Optimization: Looking for a fully committed path; if the type 3 HDM +* decoder is not commmitted, it cannot lie on such a path.
^^^ committed
... snip ...
hw/cxl/cxl-host.c static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr, · line 441
Quoted 8 lines
hw/cxl/cxl-host.c +8
-0+object_child_foreach_recursive (object_get_root (), + cxl_fmws_direct_passthrough, + &state); + } + } + dpa_base += decoder_size /cxl_interleave_ways_dec (iw, &error_fatal); + } +
Div-by-0 here for invalid values?
int cxl_interleave_ways_dec(uint8_t iw_enc, Error **errp)
{
switch (iw_enc) {
... snip ...
default:
error_setg(errp, "Encoded interleave ways: %d not supported", iw_enc);
return 0;
}
}Or does this abort before return?
Review
Quoted 2 lines
(quoted diff) +2
-0+ return false; +}
You're returning false as an 'int'
~Gregory
Quoted 18 lines · On Thu, 5 Mar 2026 16:13:24 -0500 Gregory Price <[email protected]> wrote:
hw/cxl/cxl-host.c static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr, · line 399
Quoted 3 lines · Alireza Sanaee
hw/cxl/cxl-host.c +3
-0+/* +* Optimization: Looking for a fully committed path; if the type 3 HDM +* decoder is not commmitted, it cannot lie on such a path. ^^^ committed
... snip ...
hw/cxl/cxl-host.c static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr, · line 441
Quoted 8 lines
hw/cxl/cxl-host.c +8
-0+object_child_foreach_recursive (object_get_root (), + cxl_fmws_direct_passthrough, + &state); + } + } + dpa_base += decoder_size /cxl_interleave_ways_dec (iw, &error_fatal); + } +Div-by-0 here for invalid values?
Quoted 7 lines
int
cxl_interleave_ways_dec(uint8_t iw_enc, Error **errp){ switch (iw_enc) { ... snip ... default: error_setg(errp, "Encoded interleave ways: %d not supported", iw_enc); return 0;
It will abort because error_fatal is passed in. I believe we've always sanity checked the value at write so
That's not particularly elegant so I think we should do a check on it being zero and just return 0 if it happens to be so.
We have similar checks in the other uses of cxl_interleave_ways_dec()
On the todo list for a long time has been adding more sanity checking to the HDM commit flows. As we are getting closer to this stuff actually being usable for virtualization as well as emulation / testing, that will need cleaning up.
Quoted 9 lines
} }Or does this abort before return?
Review
Quoted 2 lines
(quoted diff) +2
-0+ return false; +}You're returning false as an 'int'
Good spot. That should be return 0.
Quoted 2 lines
~Gregory