Linux-NVDIMM Archive on lore.kernel.org
 help / color / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: dan.j.williams@intel.com, vishal.l.verma@intel.com, jmoyer@redhat.com
Cc: linux-nvdimm@lists.01.org,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Subject: [PATCH v4 3/6] libnvdimm/namespace: Add arch dependent callback for namespace create time validation
Date: Mon, 20 Jan 2020 19:37:46 +0530
Message-ID: <20200120140749.69549-4-aneesh.kumar@linux.ibm.com> (raw)
In-Reply-To: <20200120140749.69549-1-aneesh.kumar@linux.ibm.com>

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(+)

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__ */
-- 
2.24.1
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

  parent reply index

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20 14:07 [PATCH v4 0/6] Validating namespace size and start address attributes Aneesh Kumar K.V
2020-01-20 14:07 ` [PATCH v4 1/6] libnvdimm/namespace: Make namespace size validation arch dependent Aneesh Kumar K.V
2020-01-24  5:57   ` Dan Williams
2020-01-24  7:34     ` Aneesh Kumar K.V
2020-01-24 16:45       ` Dan Williams
2020-01-24 17:07         ` Aneesh Kumar K.V
2020-01-24 18:25           ` Dan Williams
2020-01-26 11:41             ` Aneesh Kumar K.V
2020-01-24 17:08         ` Aneesh Kumar K.V
2020-01-20 14:07 ` [PATCH v4 2/6] libnvdimm/namespace: Validate namespace start addr and size Aneesh Kumar K.V
2020-01-25  1:55   ` Dan Williams
2020-01-20 14:07 ` Aneesh Kumar K.V [this message]
2020-01-25  1:59   ` [PATCH v4 3/6] libnvdimm/namespace: Add arch dependent callback for namespace create time validation Dan Williams
2020-01-20 14:07 ` [PATCH v4 4/6] libnvdimm/namespace: Validate namespace size when creating a new namespace Aneesh Kumar K.V
2020-01-25  2:22   ` Dan Williams
2020-01-20 14:07 ` [PATCH v4 5/6] libnvdimm/namespace: Align DPA based on arch restrictions Aneesh Kumar K.V
2020-01-20 14:07 ` [PATCH v4 6/6] libnvdimm/namespace: Expose arch specific supported size align value Aneesh Kumar K.V

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200120140749.69549-4-aneesh.kumar@linux.ibm.com \
    --to=aneesh.kumar@linux.ibm.com \
    --cc=dan.j.williams@intel.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-NVDIMM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nvdimm/0 linux-nvdimm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nvdimm linux-nvdimm/ https://lore.kernel.org/linux-nvdimm \
		linux-nvdimm@lists.01.org
	public-inbox-index linux-nvdimm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.01.lists.linux-nvdimm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git