Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cxl_test: Limit location for fake CFMWS to mappable range

Some architectures (e.g. arm64) only support memory hotplug operations on
a restricted set of physical addresses. This applies even when we are
faking some CXL fixed memory windows for the purposes of cxl_test.
That range can be queried with mhp_get_pluggable_range(true). Use the
minimum of that the top of that range and iomem_resource.end to establish
the 64GiB region used by cxl_test.

From thread #2 which was related to the issue in #1.

[ dj: Add CONFIG_MEMORY_HOTPLUG config check, from Alison ]

Link: https://lore.kernel.org/linux-cxl/20250522145622.00002633@huawei.com/ #2
Reported-by: Itaru Kitayama <itaru.kitayama@linux.dev>
Closes: https://github.com/pmem/ndctl/issues/278 #1
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Itaru Kitayama <itaru.kitayama@fujitsu.com <mailto:itaru.kitayama@fujitsu.com>
Tested-by: Marc Herbert <marc.herbert@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://patch.msgid.link/20250527153451.82858-1-Jonathan.Cameron@huawei.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

authored by

Jonathan Cameron and committed by
Dave Jiang
60da1f68 38b502e0

+7 -1
+1
tools/testing/cxl/config_check.c
··· 14 14 BUILD_BUG_ON(!IS_ENABLED(CONFIG_CXL_REGION_INVALIDATION_TEST)); 15 15 BUILD_BUG_ON(!IS_ENABLED(CONFIG_NVDIMM_SECURITY_TEST)); 16 16 BUILD_BUG_ON(!IS_ENABLED(CONFIG_DEBUG_FS)); 17 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_MEMORY_HOTPLUG)); 17 18 }
+6 -1
tools/testing/cxl/test/cxl.c
··· 2 2 // Copyright(c) 2021 Intel Corporation. All rights reserved. 3 3 4 4 #include <linux/platform_device.h> 5 + #include <linux/memory_hotplug.h> 5 6 #include <linux/genalloc.h> 6 7 #include <linux/module.h> 7 8 #include <linux/mutex.h> ··· 1329 1328 static __init int cxl_test_init(void) 1330 1329 { 1331 1330 int rc, i; 1331 + struct range mappable; 1332 1332 1333 1333 cxl_acpi_test(); 1334 1334 cxl_core_test(); ··· 1344 1342 rc = -ENOMEM; 1345 1343 goto err_gen_pool_create; 1346 1344 } 1345 + mappable = mhp_get_pluggable_range(true); 1347 1346 1348 - rc = gen_pool_add(cxl_mock_pool, iomem_resource.end + 1 - SZ_64G, 1347 + rc = gen_pool_add(cxl_mock_pool, 1348 + min(iomem_resource.end + 1 - SZ_64G, 1349 + mappable.end + 1 - SZ_64G), 1349 1350 SZ_64G, NUMA_NO_NODE); 1350 1351 if (rc) 1351 1352 goto err_gen_pool_add;