@@ -1912,6 +1912,7 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
struct nd_label_ent *label_ent;
struct nd_namespace_pmem *nspm;
struct nd_mapping *nd_mapping;
+ unsigned long map_align_size;
resource_size_t size = 0;
struct resource *res;
struct device *dev;
@@ -2010,6 +2011,20 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
}
+ map_align_size = arch_validate_namespace_size(nd_region->ndr_mappings, size);
+ if (map_align_size) {
+ dev_err(&nd_region->dev, "%llu is not %ldK aligned\n", size,
+ map_align_size/ SZ_1K);
+ /*
+ * Disable this region completely. A wrongly sized namespace
+ * size implies the start address of other namespace would also
+ * be wrong and we would find confusing crashes w.r.t
+ * direct-map address.
+ */
+ rc = -EINVAL;
+ goto err;
+ }
+
if (!nspm->alt_name || !nspm->uuid) {
rc = -ENOMEM;
goto err;
During namespace initialization, if kernel finds the namespace size not aligned as per arch-specific restriction, disable the region completely. Even though kernel validates the namespace size while creating the namespace nvdimm core still needs to make sure namespaces with wrong size are not initialized. This can happen when users move SCM across different architectures and with architectures like ppc64 when we use different MMU translation modes. ppc64 allow booting systems with different translation mode based on kernel parameter and the two translation mode (hash and radix) have different direct-map page size restrictions. Marking the region disabled enables the user to either re-init the namespace using the dimm interface or boot back to the right kernel supporting the alignment. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> --- drivers/nvdimm/namespace_devs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)