linux-stable/drivers/cxl/core
Alison Schofield 3e88562092 cxl: Restore XOR'd position bits during address translation
[ Upstream commit 3b2fedcd75 ]

When a device reports a DPA in events like poison, general_media,
and dram, the driver translates that DPA back to an HPA. Presently,
the CXL driver translation only considers the Modulo position and
will report the wrong HPA for XOR configured root decoders.

Add a helper function that restores the XOR'd bits during DPA->HPA
address translation. Plumb a root decoder callback to the new helper
when XOR interleave arithmetic is in use. For Modulo arithmetic, just
let the callback be NULL - as in no extra work required.

Upon completion of a DPA->HPA translation a couple of checks are
performed on the result. One simply confirms that the calculated
HPA is within the address range of the region. That test is useful
for both Modulo and XOR interleave arithmetic decodes.

A second check confirms that the HPA is within an expected chunk
based on the endpoints position in the region and the region
granularity. An XOR decode disrupts the Modulo pattern making the
chunk check useless.

To align the checks with the proper decode, pull the region range
check inline and use the helper to do the chunk check for Modulo
decodes only.

A cxl-test unit test is posted for upstream review here:
https://lore.kernel.org/20240624210644.495563-1-alison.schofield@intel.com/

Fixes: 28a3ae4ff6 ("cxl/trace: Add an HPA to cxl_poison trace events")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Tested-by: Diego Garcia Rodriguez <diego.garcia.rodriguez@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Link: https://patch.msgid.link/1a1ac880d9f889bd6384e657e810431b9a0a72e5.1719980933.git.alison.schofield@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-09-18 19:25:14 +02:00
..
cdat.c cxl: Consolidate dport access_coordinate ->hb_coord and ->sw_coord into ->coord 2024-04-08 08:25:21 -07:00
core.h cxl/region: Move cxl_trace_hpa() work to the region driver 2024-04-30 12:24:42 -07:00
hdm.c cxl/region: check interleave capability 2024-06-25 14:45:27 -07:00
Makefile cxl: Add callback to parse the DSMAS subtables from CDAT 2023-12-22 14:33:10 -08:00
mbox.c Merge remote-tracking branch 'cxl/for-6.10/dpa-to-hpa' into cxl-for-next 2024-04-30 13:45:43 -07:00
memdev.c cxl/region: Move cxl_dpa_to_region() work to the region driver 2024-04-30 12:24:42 -07:00
pci.c cxl: Add post-reset warning if reset results in loss of previously committed HDM decoders 2024-05-08 13:25:46 -05:00
pmem.c cxl/mem: Fix no cxl_nvd during pmem region auto-assembling 2024-06-18 16:56:50 -07:00
pmu.c cxl/pmu: Ensure put_device on pmu devices 2023-12-14 21:54:45 -08:00
port.c cxl: Fix cxl_endpoint_get_perf_coordinate() support for RCH 2024-04-29 09:03:26 -07:00
region.c cxl: Restore XOR'd position bits during address translation 2024-09-18 19:25:14 +02:00
regs.c pci-v6.10-changes 2024-05-21 10:09:28 -07:00
suspend.c
trace.c cxl/region: Move cxl_trace_hpa() work to the region driver 2024-04-30 12:24:42 -07:00
trace.h tracing/treewide: Remove second parameter of __assign_str() 2024-05-22 20:14:47 -04:00