Message ID | 20200120140749.69549-4-aneesh.kumar@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Validating namespace size and start address attributes. | expand |
On Mon, Jan 20, 2020 at 6:08 AM Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> wrote: > > Namespace start address and size should be multiple of subsection size to avoid > handling complex partial subsection addition and removal of memory. Even though > subsection size is arch independent (2M), architectures do impose further > restrictions w.r.t namespace size/start addr based on direct-mapping page size. > > This patch adds an arch callback for supporting arch specific restrictions w.r.t > namespace size. This is different from arch_namespace_map_size() in that this > validates against SUBSECTION_SIZE. Ideally, kernel should use the same restrictions > during namespace initialization too. But that prevents an existing unaligned > namespace initialization to fail. The kernel now allows such namespace initialization > so that an existing installation is not broken. I think we only need memremap_compat_align() to default to the subsection size with the option for Power to override it to 16MiB.
diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c index 95cb5538bc6e..32b4ba57cc95 100644 --- a/arch/arm64/mm/flush.c +++ b/arch/arm64/mm/flush.c @@ -97,4 +97,11 @@ unsigned long arch_namespace_map_size(void) return PAGE_SIZE; } EXPORT_SYMBOL_GPL(arch_namespace_map_size); + +unsigned long arch_namespace_align_size(void) +{ + return (1UL << SUBSECTION_SHIFT); +} +EXPORT_SYMBOL_GPL(arch_namespace_align_size); + #endif diff --git a/arch/powerpc/lib/pmem.c b/arch/powerpc/lib/pmem.c index 63dca24e4a18..cdf4248c536c 100644 --- a/arch/powerpc/lib/pmem.c +++ b/arch/powerpc/lib/pmem.c @@ -35,6 +35,17 @@ unsigned long arch_namespace_map_size(void) } EXPORT_SYMBOL_GPL(arch_namespace_map_size); +unsigned long arch_namespace_align_size(void) +{ + unsigned long sub_section_size = (1UL << SUBSECTION_SHIFT); + + if (radix_enabled()) + return sub_section_size; + return max(sub_section_size, (1UL << mmu_psize_defs[mmu_linear_psize].shift)); + +} +EXPORT_SYMBOL_GPL(arch_namespace_align_size); + /* * CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE symbols */ diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index d78b5082f376..1dea3e822e1a 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -316,6 +316,12 @@ unsigned long arch_namespace_map_size(void) } EXPORT_SYMBOL_GPL(arch_namespace_map_size); +unsigned long arch_namespace_align_size(void) +{ + return (1UL << SUBSECTION_SHIFT); +} +EXPORT_SYMBOL_GPL(arch_namespace_align_size); + static void __cpa_flush_all(void *arg) { diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h index a3476dbd2656..0f366706b0aa 100644 --- a/include/linux/libnvdimm.h +++ b/include/linux/libnvdimm.h @@ -285,4 +285,5 @@ static inline void arch_invalidate_pmem(void *addr, size_t size) #endif unsigned long arch_namespace_map_size(void); +unsigned long arch_namespace_align_size(void); #endif /* __LIBNVDIMM_H__ */
Namespace start address and size should be multiple of subsection size to avoid handling complex partial subsection addition and removal of memory. Even though subsection size is arch independent (2M), architectures do impose further restrictions w.r.t namespace size/start addr based on direct-mapping page size. This patch adds an arch callback for supporting arch specific restrictions w.r.t namespace size. This is different from arch_namespace_map_size() in that this validates against SUBSECTION_SIZE. Ideally, kernel should use the same restrictions during namespace initialization too. But that prevents an existing unaligned namespace initialization to fail. The kernel now allows such namespace initialization so that an existing installation is not broken. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> --- arch/arm64/mm/flush.c | 7 +++++++ arch/powerpc/lib/pmem.c | 11 +++++++++++ arch/x86/mm/pageattr.c | 6 ++++++ include/linux/libnvdimm.h | 1 + 4 files changed, 25 insertions(+)