@@ -3,6 +3,7 @@
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/device.h>
#include <linux/delay.h>
+#include <linux/acpi.h>
#include <linux/pci.h>
#include <linux/pci-doe.h>
#include <cxlpci.h>
@@ -592,6 +593,7 @@ void read_cdat_data(struct cxl_port *port)
struct device *dev = &port->dev;
struct device *uport = port->uport;
size_t cdat_length;
+ acpi_status status;
int rc;
cdat_doe = find_cdat_doe(uport);
@@ -620,5 +622,14 @@ void read_cdat_data(struct cxl_port *port)
port->cdat.length = 0;
dev_err(dev, "CDAT data read error\n");
}
+
+ status = acpi_ut_verify_cdat_checksum(port->cdat.table, port->cdat.length);
+ if (status != AE_OK) {
+ /* Don't leave table data allocated on error */
+ devm_kfree(dev, port->cdat.table);
+ port->cdat.table = NULL;
+ port->cdat.length = 0;
+ dev_err(dev, "CDAT data checksum error\n");
+ }
}
EXPORT_SYMBOL_NS_GPL(read_cdat_data, CXL);
A CDAT table is available from a CXL device. The table is read by the driver and cached in software. With the CXL subsystem needing to parse the CDAT table, the checksum should be verified. Add checksum verification after the CDAT table is read from device. Signed-off-by: Dave Jiang <dave.jiang@intel.com> --- drivers/cxl/core/pci.c | 11 +++++++++++ 1 file changed, 11 insertions(+)