From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BFC5C76186 for ; Wed, 24 Jul 2019 20:01:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0025321738 for ; Wed, 24 Jul 2019 20:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998483; bh=8hB8GEYwwsBCWI9E/TaVGO1DZZahcDjnJqvJxAcZX8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rICldLc2gHSupD+EZiXNmj3xNwVGx40GSMKuV50NulvVTKxiU+84rdpSvpYLy+R4A lixiV7BYpxI6Um0mHVSkE5GOTMoCvwnOszPRrPA9OhS8eve9OZDswTgnKv7ZV7mpSx G/d4Zv4QtCHRgv6cG+buc6T8LFXA/Wqp1gobJlKk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405404AbfGXUBW (ORCPT ); Wed, 24 Jul 2019 16:01:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:50000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405386AbfGXUBS (ORCPT ); Wed, 24 Jul 2019 16:01:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8223422ADC; Wed, 24 Jul 2019 20:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998478; bh=8hB8GEYwwsBCWI9E/TaVGO1DZZahcDjnJqvJxAcZX8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ef/xdnOETZK0rDfRw+Lvb/cqI+hnue1Axo+frqMu4haWZi1mwFI+PabInvv92Q06r 3cJmq9SZTyNjWw1nd57lpVsuajK/vojBf+FWRHmr/RCFg12tr+pagd1NK7Sp34bsf5 KSpAjP4TVIGQteurjcTG90Hl8cUA9zIIGDe9LOp4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Aneesh Kumar K.V" , Dan Williams , Andrew Morton , Linus Torvalds Subject: [PATCH 5.1 340/371] mm/nvdimm: add is_ioremap_addr and use that to check ioremap address Date: Wed, 24 Jul 2019 21:21:32 +0200 Message-Id: <20190724191749.276584347@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aneesh Kumar K.V commit 9bd3bb6703d8c0a5fb8aec8e3287bd55b7341dcd upstream. 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 Link: http://lkml.kernel.org/r/20190701134038.14165-1-aneesh.kumar@linux.ibm.com Signed-off-by: Aneesh Kumar K.V Fixes: b5beae5e224f ("powerpc/pseries: Add driver for PAPR SCM regions") Cc: Dan Williams Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/include/asm/pgtable.h | 14 ++++++++++++++ include/linux/mm.h | 5 +++++ kernel/iomem.c | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -137,6 +137,20 @@ static inline void pte_frag_set(mm_conte } #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 */ --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -590,6 +590,11 @@ static inline bool is_vmalloc_addr(const 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 --- 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);