Skip to content

Commit 89963d5

Browse files
zhijianli88davejiang
authored andcommitted
cxl/acpi: Verify CHBS length for CXL2.0
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>
1 parent cdafa67 commit 89963d5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/cxl/acpi.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#include "cxlpci.h"
1212
#include "cxl.h"
1313

14-
#define CXL_RCRB_SIZE SZ_8K
15-
1614
struct cxl_cxims_data {
1715
int nr_maps;
1816
u64 xormaps[] __counted_by(nr_maps);
@@ -479,7 +477,11 @@ static int cxl_get_chbs_iter(union acpi_subtable_headers *header, void *arg,
479477
chbs = (struct acpi_cedt_chbs *) header;
480478

481479
if (chbs->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11 &&
482-
chbs->length != CXL_RCRB_SIZE)
480+
chbs->length != ACPI_CEDT_CHBS_LENGTH_CXL11)
481+
return 0;
482+
483+
if (chbs->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL20 &&
484+
chbs->length != ACPI_CEDT_CHBS_LENGTH_CXL20)
483485
return 0;
484486

485487
if (!chbs->base)

0 commit comments

Comments
 (0)