Skip to contentSkip to conversation

cxl/acpi: Fail decoder add if CXIMS for HBIG is missing

PATCH In review [email protected] 3 participants 3 messages Dec 5, 2022 CXL

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 cxl/acpi: Fail decoder add if CXIMS for HBIG is missing

From: Alison Schofield <[email protected]>

The BIOS provided CXIMS (CXL XOR Interleave Math Structure) is required for calculating a targets position in an interleave list during region creation. The CXL driver expects to discover a CXIMS that matches the HBIG (Host Bridge Interleave Granularity) and stores the xormaps found in that CXIMS for retrieval during region creation.

If there is no CXIMS for an HBIG, no maps are stored. That leads to a NULL pointer dereference at xormap retrieval during region creation.

Add a check during ACPI probe for the case of no matching CXIMS. Emit an error message and fail to add the decoder.

Fixes f9db85bfec0d ("cxl/acpi: Support CXL XOR Interleave Math (CXIMS)")

---

Not sure the Commit-ID in Fixes tag will persist. (from cxl/pending)

 drivers/cxl/acpi.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/cxl/acpi.c +5 -0
index 657ef250d848..420e322c85a1 100644
@@ -282,6 +282,11 @@ static int cxl_parse_cfmws(union acpi_subtable_headers *header, void *arg,
 						   cxl_parse_cxims, &cxims_ctx);
 			if (rc < 0)
 				goto err_xormap;
+			if (!cxlrd->platform_data) {
+				dev_err(dev, "No CXIMS for HBIG %u\n", ig);
+				rc = -EINVAL;
+				goto err_xormap;
+			}
 		}
 	}
 	rc = cxl_decoder_add(cxld, target_map);

base-commit: d72a5b810410c076d4dd63fe542a5a4d6c145cfa

Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On 12/4/2022 5:29 PM, [email protected] wrote:

From: Alison Schofield <[email protected]>

The BIOS provided CXIMS (CXL XOR Interleave Math Structure) is required for calculating a targets position in an interleave list during region creation. The CXL driver expects to discover a CXIMS that matches the HBIG (Host Bridge Interleave Granularity) and stores the xormaps found in that CXIMS for retrieval during region creation.

If there is no CXIMS for an HBIG, no maps are stored. That leads to a NULL pointer dereference at xormap retrieval during region creation.

Quoted 6 lines

Add a check during ACPI probe for the case of no matching CXIMS. Emit an error message and fail to add the decoder.

Fixes f9db85bfec0d ("cxl/acpi: Support CXL XOR Interleave Math (CXIMS)")
Quoted 25 lines

---

Not sure the Commit-ID in Fixes tag will persist. (from cxl/pending)

  drivers/cxl/acpi.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/cxl/acpi.c +5 -0
index 657ef250d848..420e322c85a1 100644
@@ -282,6 +282,11 @@ static int cxl_parse_cfmws(union acpi_subtable_headers *header, void *arg,
  						   cxl_parse_cxims, &cxims_ctx);
  			if (rc < 0)
  				goto err_xormap;
+			if (!cxlrd->platform_data) {
+				dev_err(dev, "No CXIMS for HBIG %u\n", ig);
+				rc = -EINVAL;
+				goto err_xormap;
+			}
  		}
  	}
  	rc = cxl_decoder_add(cxld, target_map);

base-commit: d72a5b810410c076d4dd63fe542a5a4d6c145cfa

#2 lore raw
In reply to [email protected]
Quoted 14 lines · alison.schofield@ wrote:

From: Alison Schofield <[email protected]>

The BIOS provided CXIMS (CXL XOR Interleave Math Structure) is required for calculating a targets position in an interleave list during region creation. The CXL driver expects to discover a CXIMS that matches the HBIG (Host Bridge Interleave Granularity) and stores the xormaps found in that CXIMS for retrieval during region creation.

If there is no CXIMS for an HBIG, no maps are stored. That leads to a NULL pointer dereference at xormap retrieval during region creation.

Add a check during ACPI probe for the case of no matching CXIMS. Emit an error message and fail to add the decoder.

Quoted 6 lines
Fixes f9db85bfec0d ("cxl/acpi: Support CXL XOR Interleave Math (CXIMS)")

---

Not sure the Commit-ID in Fixes tag will persist. (from cxl/pending)

Looks good to me, and yes that commit-id is stable even with the recent rebase to fixup some authorship in the for-6.2/cxl-rch branch.