]> git.itanic.dy.fi Git - linux-stable/commit
cxl/region: Fix region setup/teardown for RCDs
authorDan Williams <dan.j.williams@intel.com>
Mon, 3 Apr 2023 21:44:41 +0000 (14:44 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 4 Apr 2023 22:34:34 +0000 (15:34 -0700)
commit030f880342b875c7d714d06d3ca4058ae9f13fee
treeeac15b70e3c7a86b9fbb6388e0d37ed47d0c071b
parentd35b495ddf92c964eedf2ac86fdbf88dc3e5cbc9
cxl/region: Fix region setup/teardown for RCDs

RCDs (CXL memory devices that link train without VH capability and show
up as root complex integrated endpoints), hide the presence of the link
between the endpoint and the host-bridge. The CXL region setup/teardown
paths assume that a link hop is present and go looking for at least one
'struct cxl_port' instance between the CXL root port-object and an
endpoint port-object leading to crashes of the form:

    BUG: kernel NULL pointer dereference, address: 0000000000000008
    [..]
    RIP: 0010:cxl_region_setup_targets+0x3e9/0xae0 [cxl_core]
    [..]
    Call Trace:
     <TASK>
     cxl_region_attach+0x46c/0x7a0 [cxl_core]
     cxl_create_region+0x20b/0x270 [cxl_core]
     cxl_mock_mem_probe+0x641/0x800 [cxl_mock_mem]
     platform_probe+0x5b/0xb0

Detect RCDs explicitly and skip walking the non-existent port hierarchy
between root and endpoint in that case.

While this has been a problem since:

commit 0a19bfc8de93 ("cxl/port: Add RCD endpoint port enumeration")

...it becomes a more reliable crash scenario with the new autodiscovery
implementation.

Fixes: a32320b71f08 ("cxl/region: Add region autodiscovery")
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/168002858268.50647.728091521032131326.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/region.c