linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/nvdimm: Add is_ioremap_addr and use that to check ioremap address
@ 2019-07-01 13:40 Aneesh Kumar K.V
  2019-07-01 23:51 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Aneesh Kumar K.V @ 2019-07-01 13:40 UTC (permalink / raw)
  To: dan.j.williams, akpm
  Cc: linux-nvdimm, linux-mm, linuxppc-dev, Aneesh Kumar K.V

Architectures like powerpc use different address range to map ioremap
and vmalloc range. The memunmap() check used by the nvdimm layer was
wrongly using is_vmalloc_addr() to check for ioremap range which fails for
ppc64. This result in ppc64 not freeing the ioremap mapping. The side effect
of this is an unbind failure during module unload with papr_scm nvdimm driver

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 arch/powerpc/include/asm/pgtable.h | 14 ++++++++++++++
 include/linux/mm.h                 |  5 +++++
 kernel/iomem.c                     |  2 +-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index 3f53be60fb01..64145751b2fd 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -140,6 +140,20 @@ static inline void pte_frag_set(mm_context_t *ctx, void *p)
 }
 #endif
 
+#ifdef CONFIG_PPC64
+#define is_ioremap_addr is_ioremap_addr
+static inline bool is_ioremap_addr(const void *x)
+{
+#ifdef CONFIG_MMU
+	unsigned long addr = (unsigned long)x;
+
+	return addr >= IOREMAP_BASE && addr < IOREMAP_END;
+#else
+	return false;
+#endif
+}
+#endif /* CONFIG_PPC64 */
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_POWERPC_PGTABLE_H */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 973ebf71f7b6..65b2eb6c9f0a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -633,6 +633,11 @@ static inline bool is_vmalloc_addr(const void *x)
 	return false;
 #endif
 }
+
+#ifndef is_ioremap_addr
+#define is_ioremap_addr(x) is_vmalloc_addr(x)
+#endif
+
 #ifdef CONFIG_MMU
 extern int is_vmalloc_or_module_addr(const void *x);
 #else
diff --git a/kernel/iomem.c b/kernel/iomem.c
index 93c264444510..62c92e43aa0d 100644
--- a/kernel/iomem.c
+++ b/kernel/iomem.c
@@ -121,7 +121,7 @@ EXPORT_SYMBOL(memremap);
 
 void memunmap(void *addr)
 {
-	if (is_vmalloc_addr(addr))
+	if (is_ioremap_addr(addr))
 		iounmap((void __iomem *) addr);
 }
 EXPORT_SYMBOL(memunmap);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/nvdimm: Add is_ioremap_addr and use that to check ioremap address
  2019-07-01 13:40 [PATCH] mm/nvdimm: Add is_ioremap_addr and use that to check ioremap address Aneesh Kumar K.V
@ 2019-07-01 23:51 ` Andrew Morton
  2019-07-02  3:33   ` Aneesh Kumar K.V
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2019-07-01 23:51 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: dan.j.williams, linux-nvdimm, linux-mm, linuxppc-dev

On Mon,  1 Jul 2019 19:10:38 +0530 "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> wrote:

> Architectures like powerpc use different address range to map ioremap
> and vmalloc range. The memunmap() check used by the nvdimm layer was
> wrongly using is_vmalloc_addr() to check for ioremap range which fails for
> ppc64. This result in ppc64 not freeing the ioremap mapping. The side effect
> of this is an unbind failure during module unload with papr_scm nvdimm driver

The patch applies to 5.1.  Does it need a Fixes: and a Cc:stable?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/nvdimm: Add is_ioremap_addr and use that to check ioremap address
  2019-07-01 23:51 ` Andrew Morton
@ 2019-07-02  3:33   ` Aneesh Kumar K.V
  2019-07-04 14:23     ` Michael Ellerman
  0 siblings, 1 reply; 4+ messages in thread
From: Aneesh Kumar K.V @ 2019-07-02  3:33 UTC (permalink / raw)
  To: Andrew Morton; +Cc: dan.j.williams, linux-nvdimm, linux-mm, linuxppc-dev

Andrew Morton <akpm@linux-foundation.org> writes:

> On Mon,  1 Jul 2019 19:10:38 +0530 "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> wrote:
>
>> Architectures like powerpc use different address range to map ioremap
>> and vmalloc range. The memunmap() check used by the nvdimm layer was
>> wrongly using is_vmalloc_addr() to check for ioremap range which fails for
>> ppc64. This result in ppc64 not freeing the ioremap mapping. The side effect
>> of this is an unbind failure during module unload with papr_scm nvdimm driver
>
> The patch applies to 5.1.  Does it need a Fixes: and a Cc:stable?

Actually, we want it to be backported to an older kernel possibly one
that added papr-scm driver, b5beae5e224f ("powerpc/pseries: Add driver
for PAPR SCM regions"). But that doesn't apply easily. It does apply
without conflicts to 5.0

-aneesh


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/nvdimm: Add is_ioremap_addr and use that to check ioremap address
  2019-07-02  3:33   ` Aneesh Kumar K.V
@ 2019-07-04 14:23     ` Michael Ellerman
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2019-07-04 14:23 UTC (permalink / raw)
  To: Aneesh Kumar K.V, Andrew Morton
  Cc: linux-mm, dan.j.williams, linuxppc-dev, linux-nvdimm

"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
> Andrew Morton <akpm@linux-foundation.org> writes:
>
>> On Mon,  1 Jul 2019 19:10:38 +0530 "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> wrote:
>>
>>> Architectures like powerpc use different address range to map ioremap
>>> and vmalloc range. The memunmap() check used by the nvdimm layer was
>>> wrongly using is_vmalloc_addr() to check for ioremap range which fails for
>>> ppc64. This result in ppc64 not freeing the ioremap mapping. The side effect
>>> of this is an unbind failure during module unload with papr_scm nvdimm driver
>>
>> The patch applies to 5.1.  Does it need a Fixes: and a Cc:stable?
>
> Actually, we want it to be backported to an older kernel possibly one
> that added papr-scm driver, b5beae5e224f ("powerpc/pseries: Add driver
> for PAPR SCM regions"). But that doesn't apply easily. It does apply
> without conflicts to 5.0

Don't worry about where it applies or doesn't, just tag it with the
correct Fixes: and stable versions and then if it doesn't backport
cleanly then we deal with that later.

cheers


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-04 14:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-01 13:40 [PATCH] mm/nvdimm: Add is_ioremap_addr and use that to check ioremap address Aneesh Kumar K.V
2019-07-01 23:51 ` Andrew Morton
2019-07-02  3:33   ` Aneesh Kumar K.V
2019-07-04 14:23     ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).