cxl/acpi: Verify CHBS length for CXL2.0
authorLi Zhijian <lizhijian@fujitsu.com>
Thu, 10 Apr 2025 01:05:45 +0000 (09:05 +0800)
committerDave Jiang <dave.jiang@intel.com>
Mon, 28 Apr 2025 15:48:30 +0000 (08:48 -0700)
Per CXL Spec r3.1 Table 9-21, both CXL1.1 and CXL2.0 have defined their
own length, verify it to avoid an invalid CHBS.

Additionally, this patch also removes the redundant macro CXL_RCRB_SIZE,
favoring the use of `ACPI_CEDT_CHBS_LENGTH_CXL11`, which offers clearer
semantic meaning.

[DJ: Code edited for readability suggested by djbw]

Reviewed-by: Gregory Price <gourry@gourry.net>
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Link: https://patch.msgid.link/20250410010545.99590-1-lizhijian@fujitsu.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/acpi.c

index cb14829bb9be4b479ff215f9fe813833774cbc54..4eac068a18035fefa51234d0b4a2118d360f3072 100644 (file)
@@ -11,8 +11,6 @@
 #include "cxlpci.h"
 #include "cxl.h"
 
-#define CXL_RCRB_SIZE  SZ_8K
-
 struct cxl_cxims_data {
        int nr_maps;
        u64 xormaps[] __counted_by(nr_maps);
@@ -479,7 +477,11 @@ static int cxl_get_chbs_iter(union acpi_subtable_headers *header, void *arg,
        chbs = (struct acpi_cedt_chbs *) header;
 
        if (chbs->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11 &&
-           chbs->length != CXL_RCRB_SIZE)
+           chbs->length != ACPI_CEDT_CHBS_LENGTH_CXL11)
+               return 0;
+
+       if (chbs->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL20 &&
+           chbs->length != ACPI_CEDT_CHBS_LENGTH_CXL20)
                return 0;
 
        if (!chbs->base)