linux/drivers/cxl/core
Robert Richter 623c075133 cxl/mbox: Fix Payload Length check for Get Log command
Commit 2aeaf663b8 introduced strict checking for variable length
payload size validation. The payload length of received data must
match the size of the requested data by the caller except for the case
where the min_out value is set.

The Get Log command does not have a header with a length field set.
The Log size is determined by the Get Supported Logs command (CXL 3.0,
8.2.9.5.1). However, the actual size can be smaller and the number of
valid bytes in the payload output must be determined reading the
Payload Length field (CXL 3.0, Table 8-36, Note 2).

Two issues arise: The command can successfully complete with a payload
length of zero. And, the valid payload length must then also be
consumed by the caller.

Change cxl_xfer_log() to pass the number of payload bytes back to the
caller to determine the number of log entries. Implement the payload
handling as a special case where mbox_cmd->size_out is consulted when
cxl_internal_send_cmd() returns -EIO. A WARN_ONCE() is added to check
that -EIO is only returned in case of an unexpected output size.

Logs can be bigger than the maximum payload length and multiple Get
Log commands can be issued. If the received payload size is smaller
than the maximum payload size we can assume all valid bytes have been
fetched. Stop sending further Get Log commands then.

On that occasion, change debug messages to also report the opcodes of
supported commands.

The variable payload commands GET_LSA and SET_LSA are not affected by
this strict check: SET_LSA cannot be broken because SET_LSA does not
return an output payload, and GET_LSA never expects short reads.

Fixes: 2aeaf663b8 ("cxl/mbox: Add variable output size validation for internal commands")
Signed-off-by: Robert Richter <rrichter@amd.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20230119094934.86067-1-rrichter@amd.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2023-01-27 13:58:11 -08:00
..
core.h cxl/mem: Move devm_cxl_add_endpoint() from cxl_core to cxl_mem 2022-12-05 10:32:26 -08:00
hdm.c cxl: update names for interleave ways conversion macros 2022-12-05 18:17:16 -08:00
Makefile cxl/pci: Move tracepoint definitions to drivers/cxl/core/ 2023-01-04 17:11:11 -08:00
mbox.c cxl/mbox: Fix Payload Length check for Get Log command 2023-01-27 13:58:11 -08:00
memdev.c cxl/pci: Add (hopeful) error handling support 2022-12-03 13:40:17 -08:00
pci.c cxl/pci: Move tracepoint definitions to drivers/cxl/core/ 2023-01-04 17:11:11 -08:00
pmem.c Merge branch 'for-6.2/cxl-security' into for-6.2/cxl 2022-12-05 12:30:38 -08:00
port.c cxl: fix spelling mistakes 2023-01-26 15:57:42 -08:00
region.c cxl: fix spelling mistakes 2023-01-26 15:57:42 -08:00
regs.c cxl/regs: Fix sparse warning 2022-12-05 12:33:20 -08:00
suspend.c PM: CXL: Disable suspend 2022-04-22 16:09:42 -07:00
trace.c cxl/pci: Move tracepoint definitions to drivers/cxl/core/ 2023-01-04 17:11:11 -08:00
trace.h cxl/pci: Move tracepoint definitions to drivers/cxl/core/ 2023-01-04 17:11:11 -08:00