Per CXL 4.0 Table 8-331, the Discovery operation "returns a list of all Media Operations that the device supports, with the exception of the Discovery operation (Class=0, Subclass=0)."
Filter out Discovery entries when building the output list and adjust total_supported_operations accordingly. Signed-off-by: Davidlohr Bueso <[email protected]> --- hw/cxl/cxl-mailbox-utils.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 71a012121c87..90540f59dedd 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -2593,7 +2593,10 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in, } QEMU_PACKED *media_op_in_disc_pl = (void *)payload_in; struct media_op_discovery_out_pl *media_out_pl = (struct media_op_discovery_out_pl *)payload_out; - int total = ARRAY_SIZE(media_op_matrix); + /* + * Per Table 8-331, the returned list excludes Discovery (entry 0). + */ + int total = ARRAY_SIZE(media_op_matrix) - 1; int num_ops, start_index, i; int count = 0; @@ -2619,10 +2622,12 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in, num_ops = MIN(num_ops, total - start_index); for (i = 0; i < num_ops; i++) { + int idx = start_index + i + 1; /* +1 skips Discovery at entry 0 */ + media_out_pl->entry[count].media_op_class = - media_op_matrix[start_index + i].media_op_class; + media_op_matrix[idx].media_op_class; media_out_pl->entry[count].media_op_subclass = - media_op_matrix[start_index + i].media_op_subclass; + media_op_matrix[idx].media_op_subclass; count++; } -- 2.39.5
