hw/cxl: Fix guest-triggerable QEMU exit on reserved interleave ways
PATCH 1/1 hw/cxl: Fix guest-triggerable QEMU exit on reserved interleave ways
A buggy or malicious guest can program a committed HDM decoder with a reserved Interleave Ways encoding (e.g. 0x5-0x7, 0xb-0xf). Two call sites pass &error_fatal to cxl_interleave_ways_dec(), which calls exit(1) on the reserved encoding before the subsequent decoded_iw == 0 guards can run:
- cxl-host.c update_non_interleaved(): called at commit time from hdm_decoder_commit() via cfmws_update_non_interleaved(), so a guest writing COMMIT with a reserved IW terminates QEMU immediately. This is the primary trigger on the current tree.
- cxl_type3.c cxl_type3_dpa(): called on memory access while iterating past committed decoders to accumulate dpa_base. Once the commit-time exit is removed, the decoder stays committed with the reserved encoding, so a later guest access outside that decoder's range would otherwise hit this second &error_fatal; both are fixed here.
Pass NULL instead of &error_fatal at both sites so that the reserved encoding returns zero and the existing guards handle it gracefully.
This can be reproduced by writing the HDM Decoder 0 Control register with a reserved IW encoding and the COMMIT bit set (e.g. IW=0x5, COMMIT=1).
--- hw/cxl/cxl-host.c | 2 +- hw/mem/cxl_type3.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/cxl/cxl-host.c +1 -1
@@ -442,7 +442,7 @@ static int update_non_interleaved(Object *obj, void *opaque) } } - interleave_ways_dec =cxl_interleave_ways_dec (iw, &error_fatal); + interleave_ways_dec =cxl_interleave_ways_dec (iw,NULL );if (interleave_ways_dec ==0 ) {return 0 ; }
hw/mem/cxl_type3.c +1 -1
@@ -1197,7 +1197,7 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa) }if (((uint64_t )host_addr < decoder_base) || (hpa_offset >= decoder_size)) { -int decoded_iw =cxl_interleave_ways_dec (iw, &error_fatal); +int decoded_iw =cxl_interleave_ways_dec (iw,NULL );if (decoded_iw ==0 ) {return false;
Signature · 1 line
2.43.0