cxl/test: Enforce PMD alignment for volatile mock regions
PATCH v4 1/1 cxl/test: Enforce PMD alignment for volatile mock regions
cxl_test allocates synthetic CFMWS HPA windows from a gen_pool with SZ_256M alignment. On arm64 with CONFIG_ARM64_64K_PAGES=y and CONFIG_PGTABLE_LEVELS=3, PMD_SIZE is 512M, so every CXL region carved from a volatile window inherits a non-PMD-aligned start, and cxl_dax_region_probe() -> alloc_dax_region() fails:
"""
cxl_dax_region dax_region1: probe with driver cxl_dax_region failed
with error -12
"""
Enforce that every volatile mock CFMWS is PMD-aligned in both start and size
---
Changelog:
v3->v4:
- Replace compile-time BUILD_BUG_ON() with runtime IS_ALIGNED(mock_auto_region_size, PMD_SIZE) check incxl_test_init().
v2->v3:
- Correct hunk headers
- Add base commit SHA
v1->v2:
- Reframe from "fix start alignment" to "enforce PMD invariant for volatile CFMWS"
- Bump cfmws5.window_size to max(SZ_256M, PMD_SIZE)
- Gate populate_cedt() alignment on ACPI_CEDT_CFMWS_RESTRICT_VOLATILE so PMEM windows stay at SZ_256M
- Add BUILD_BUG_ON for MOCK_AUTO_REGION_SIZE_DEFAULT v.s. PMD_SIZE in cxl_test_init()
Best regards,
Richard Cheng.
--- tools/testing/cxl/test/cxl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/testing/cxl/test/cxl.c +11 -2
@@ -318,7 +318,7 @@ static struct { .restrictions = ACPI_CEDT_CFMWS_RESTRICT_HOSTONLYMEM | ACPI_CEDT_CFMWS_RESTRICT_VOLATILE, .qtg_id = FAKE_QTG_ID, - .window_size = SZ_256M, + .window_size = SZ_256M > PMD_SIZE ? SZ_256M : PMD_SIZE, }, .target = { 3 }, },
@@ -495,9 +495,12 @@ static int populate_cedt(void)for (i = cfmws_start; i <= cfmws_end; i++) {struct acpi_cedt_cfmws *window = mock_cfmws[i]; +int align =SZ_256M ;cfmws_elc_update (window, i); - res =alloc_mock_res (window->window_size,SZ_256M ); +if (window->restrictions &ACPI_CEDT_CFMWS_RESTRICT_VOLATILE ) + align =max_t (int,SZ_256M ,PMD_SIZE ); + res =alloc_mock_res (window->window_size, align);if (!res)return -ENOMEM ; window->base_hpa = res->range.start;
@@ -1826,6 +1829,12 @@ static __init int cxl_test_init(void)int rc, i;struct range mappable; +if (!IS_ALIGNED (mock_auto_region_size,PMD_SIZE )) { +pr_err_once ("mock_auto_region_size %d must be PMD-aligned\n" , + mock_auto_region_size); +return -EINVAL ; + } +cxl_acpi_test ();cxl_core_test ();cxl_mem_test ();
base-commit: 507bd4b66c85d5b65696150cc16d31ac0b2ab151
Signature · 1 line
2.43.0
Quoted 6 lines · Richard Cheng
cxl_testallocates synthetic CFMWS HPA windows from agen_poolwithSZ_256Malignment. On arm64 withCONFIG_ARM64_64K_PAGES=yandCONFIG_PGTABLE_LEVELS=3,PMD_SIZEis 512M, so every CXL region carved from a volatile window inherits a non-PMD-aligned start, andcxl_dax_region_probe()->alloc_dax_region()fails:
Quoted 8 lines
"""
cxl_dax_regiondax_region1: probe with drivercxl_dax_regionfailed
with error -12
"""Enforce that every volatile mock CFMWS is PMD-aligned in both start and size
checkpatch is emitting this complaint, that I believe is a false positive, and I'm happy to ignore versus add ugly code to appease.
WARNING: Comparisons should place the constant on the right side of the test #36: FILE: tools/testing/cxl/test/cxl.c:321:
+ .window_size = SZ_256M > PMD_SIZE ? SZ_256M : PMD_SIZE,
Quoted 75 lines
Reviewed-by Dave Jiang <[email protected]>Acked-by Kai-Heng Feng <[email protected]>Signed-off-by Richard Cheng <[email protected]>---
Changelog:
v3->v4:
- Replace compile-timeBUILD_BUG_ON()with runtimeIS_ALIGNED(mock_auto_region_size, PMD_SIZE)check incxl_test_init().
v2->v3:
- Correct hunk headers
- Add base commit SHA
v1->v2:
- Reframe from "fix start alignment" to "enforce PMD invariant for volatile CFMWS"
- Bump cfmws5.window_size tomax(SZ_256M, PMD_SIZE)
- Gatepopulate_cedt()alignment onACPI_CEDT_CFMWS_RESTRICT_VOLATILEso PMEM windows stay atSZ_256M
- AddBUILD_BUG_ONforMOCK_AUTO_REGION_SIZE_DEFAULTv.s.PMD_SIZEincxl_test_init()Best regards,
Richard Cheng.--- tools/testing/cxl/test/cxl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)tools/testing/cxl/test/cxl.c +11
-2@@ -318,7 +318,7 @@ static struct { .restrictions = ACPI_CEDT_CFMWS_RESTRICT_HOSTONLYMEM | ACPI_CEDT_CFMWS_RESTRICT_VOLATILE, .qtg_id = FAKE_QTG_ID, - .window_size = SZ_256M, + .window_size = SZ_256M > PMD_SIZE ? SZ_256M : PMD_SIZE, }, .target = { 3 }, },@@ -495,9 +495,12 @@ static int populate_cedt(void)for (i = cfmws_start; i <= cfmws_end; i++) {struct acpi_cedt_cfmws *window = mock_cfmws[i]; +int align =SZ_256M ;cfmws_elc_update (window, i); - res =alloc_mock_res (window->window_size,SZ_256M ); +if (window->restrictions &ACPI_CEDT_CFMWS_RESTRICT_VOLATILE ) + align =max_t (int,SZ_256M ,PMD_SIZE ); + res =alloc_mock_res (window->window_size, align);if (!res)return -ENOMEM ; window->base_hpa = res->range.start;@@ -1826,6 +1829,12 @@ static __init int cxl_test_init(void)int rc, i;struct range mappable; +if (!IS_ALIGNED (mock_auto_region_size,PMD_SIZE )) { +pr_err_once ("mock_auto_region_size %d must be PMD-aligned\n" , + mock_auto_region_size); +return -EINVAL ; + } +cxl_acpi_test ();cxl_core_test ();cxl_mem_test ();base-commit:
507bd4b66c85d5b65696150cc16d31ac0b2ab151Signature · 1 line
2.43.0
Quoted 24 lines · Alison Schofield
Quoted 6 lines · Richard Cheng
cxl_testallocates synthetic CFMWS HPA windows from agen_poolwithSZ_256Malignment. On arm64 withCONFIG_ARM64_64K_PAGES=yandCONFIG_PGTABLE_LEVELS=3,PMD_SIZEis 512M, so every CXL region carved from a volatile window inherits a non-PMD-aligned start, andcxl_dax_region_probe()->alloc_dax_region()fails:Quoted 8 lines
"""
cxl_dax_regiondax_region1: probe with drivercxl_dax_regionfailed
with error -12
"""Enforce that every volatile mock CFMWS is PMD-aligned in both start and size
checkpatch is emitting this complaint, that I believe is a false positive, and I'm happy to ignore versus add ugly code to appease.
WARNING: Comparisons should place the constant on the right side of the test #36: FILE:
tools/testing/cxl/test/cxl.c:321:tools/testing/cxl/test/cxl.c +1
-0+ .window_size = SZ_256M > PMD_SIZE ? SZ_256M : PMD_SIZE,
Quoted 3 lines
Reviewed-by Alison Schofield <[email protected]>
Hello Alison,
Thanks for your kindness,
I ran into issue when running checkpatch script, that's why I tried to edit the line in v2, should have decleared that more clearly.
Thanks.
--Richard
Quoted 75 lines
Quoted 75 lines
Reviewed-by Dave Jiang <[email protected]>Acked-by Kai-Heng Feng <[email protected]>Signed-off-by Richard Cheng <[email protected]>---
Changelog:
v3->v4:
- Replace compile-timeBUILD_BUG_ON()with runtimeIS_ALIGNED(mock_auto_region_size, PMD_SIZE)check incxl_test_init().
v2->v3:
- Correct hunk headers
- Add base commit SHA
v1->v2:
- Reframe from "fix start alignment" to "enforce PMD invariant for volatile CFMWS"
- Bump cfmws5.window_size tomax(SZ_256M, PMD_SIZE)
- Gatepopulate_cedt()alignment onACPI_CEDT_CFMWS_RESTRICT_VOLATILEso PMEM windows stay atSZ_256M
- AddBUILD_BUG_ONforMOCK_AUTO_REGION_SIZE_DEFAULTv.s.PMD_SIZEincxl_test_init()Best regards,
Richard Cheng.--- tools/testing/cxl/test/cxl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)tools/testing/cxl/test/cxl.c +11
-2@@ -318,7 +318,7 @@ static struct { .restrictions = ACPI_CEDT_CFMWS_RESTRICT_HOSTONLYMEM | ACPI_CEDT_CFMWS_RESTRICT_VOLATILE, .qtg_id = FAKE_QTG_ID, - .window_size = SZ_256M, + .window_size = SZ_256M > PMD_SIZE ? SZ_256M : PMD_SIZE, }, .target = { 3 }, },@@ -495,9 +495,12 @@ static int populate_cedt(void)for (i = cfmws_start; i <= cfmws_end; i++) {struct acpi_cedt_cfmws *window = mock_cfmws[i]; +int align =SZ_256M ;cfmws_elc_update (window, i); - res =alloc_mock_res (window->window_size,SZ_256M ); +if (window->restrictions &ACPI_CEDT_CFMWS_RESTRICT_VOLATILE ) + align =max_t (int,SZ_256M ,PMD_SIZE ); + res =alloc_mock_res (window->window_size, align);if (!res)return -ENOMEM ; window->base_hpa = res->range.start;@@ -1826,6 +1829,12 @@ static __init int cxl_test_init(void)int rc, i;struct range mappable; +if (!IS_ALIGNED (mock_auto_region_size,PMD_SIZE )) { +pr_err_once ("mock_auto_region_size %d must be PMD-aligned\n" , + mock_auto_region_size); +return -EINVAL ; + } +cxl_acpi_test ();cxl_core_test ();cxl_mem_test ();base-commit:
507bd4b66c85d5b65696150cc16d31ac0b2ab151Signature · 1 line
2.43.0
Quoted 11 lines · Richard Cheng
cxl_testallocates synthetic CFMWS HPA windows from agen_poolwithSZ_256Malignment. On arm64 withCONFIG_ARM64_64K_PAGES=yandCONFIG_PGTABLE_LEVELS=3,PMD_SIZEis 512M, so every CXL region carved from a volatile window inherits a non-PMD-aligned start, andcxl_dax_region_probe()->alloc_dax_region()fails:"""
cxl_dax_regiondax_region1: probe with drivercxl_dax_regionfailed
with error -12
"""
Quoted 6 lines
Enforce that every volatile mock CFMWS is PMD-aligned in both start and size
Reviewed-by Dave Jiang <[email protected]>Acked-by Kai-Heng Feng <[email protected]>Signed-off-by Richard Cheng <[email protected]>
Applied to cxl/next8850852b25f7884d9804f8de5591edb3881bd674
Quoted 69 lines
---
Changelog:
v3->v4:
- Replace compile-timeBUILD_BUG_ON()with runtimeIS_ALIGNED(mock_auto_region_size, PMD_SIZE)check incxl_test_init().
v2->v3:
- Correct hunk headers
- Add base commit SHA
v1->v2:
- Reframe from "fix start alignment" to "enforce PMD invariant for volatile CFMWS"
- Bump cfmws5.window_size tomax(SZ_256M, PMD_SIZE)
- Gatepopulate_cedt()alignment onACPI_CEDT_CFMWS_RESTRICT_VOLATILEso PMEM windows stay atSZ_256M
- AddBUILD_BUG_ONforMOCK_AUTO_REGION_SIZE_DEFAULTv.s.PMD_SIZEincxl_test_init()Best regards,
Richard Cheng.--- tools/testing/cxl/test/cxl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)tools/testing/cxl/test/cxl.c +11
-2@@ -318,7 +318,7 @@ static struct { .restrictions = ACPI_CEDT_CFMWS_RESTRICT_HOSTONLYMEM | ACPI_CEDT_CFMWS_RESTRICT_VOLATILE, .qtg_id = FAKE_QTG_ID, - .window_size = SZ_256M, + .window_size = SZ_256M > PMD_SIZE ? SZ_256M : PMD_SIZE, }, .target = { 3 }, },@@ -495,9 +495,12 @@ static int populate_cedt(void)for (i = cfmws_start; i <= cfmws_end; i++) {struct acpi_cedt_cfmws *window = mock_cfmws[i]; +int align =SZ_256M ;cfmws_elc_update (window, i); - res =alloc_mock_res (window->window_size,SZ_256M ); +if (window->restrictions &ACPI_CEDT_CFMWS_RESTRICT_VOLATILE ) + align =max_t (int,SZ_256M ,PMD_SIZE ); + res =alloc_mock_res (window->window_size, align);if (!res)return -ENOMEM ; window->base_hpa = res->range.start;@@ -1826,6 +1829,12 @@ static __init int cxl_test_init(void)int rc, i;struct range mappable; +if (!IS_ALIGNED (mock_auto_region_size,PMD_SIZE )) { +pr_err_once ("mock_auto_region_size %d must be PMD-aligned\n" , + mock_auto_region_size); +return -EINVAL ; + } +cxl_acpi_test ();cxl_core_test ();cxl_mem_test ();base-commit:
507bd4b66c85d5b65696150cc16d31ac0b2ab151