From patchwork Wed Dec 11 12:07:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 11284849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C092C138D for ; Wed, 11 Dec 2019 12:32:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E11C2173E for ; Wed, 11 Dec 2019 12:32:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="eyYSAOGb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E11C2173E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CBA1E6B31FA; Wed, 11 Dec 2019 07:31:33 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C6A7C6B31FB; Wed, 11 Dec 2019 07:31:33 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B31C46B31FC; Wed, 11 Dec 2019 07:31:33 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0076.hostedemail.com [216.40.44.76]) by kanga.kvack.org (Postfix) with ESMTP id 99C596B31FA for ; Wed, 11 Dec 2019 07:31:33 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 573E3180AD817 for ; Wed, 11 Dec 2019 12:31:33 +0000 (UTC) X-FDA: 76252796466.22.toys64_47bff1bcb2c62 X-Spam-Summary: 2,0,0,a4c2597226bd9e69,d41d8cd98f00b204,peterz@infradead.org,:will@kernel.org:aneesh.kumar@linux.ibm.com:akpm@linux-foundation.org:npiggin@gmail.com:peterz@infradead.org:linux-arch@vger.kernel.org::linux-kernel@vger.kernel.org:ysato@users.sourceforge.jp:dalias@libc.org:davem@davemloft.net:deller@gmx.de:geert@linux-m68k.org:paulburton@kernel.org:tony.luck@intel.com:rth@twiddle.net:nickhu@andestech.com:paul.walmsley@sifive.com,RULES_HIT:41:152:355:379:800:960:965:966:968:973:988:989:1183:1260:1261:1277:1313:1314:1345:1431:1437:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2731:2903:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3871:3872:3874:4250:4385:4390:4395:4605:5007:6119:6261:6653:6742:8634:10004:10400:11026:11473:11657:11658:11914:12043:12048:12296:12297:12438:12517:12519:14096:14097:14181:14394:14659:14721:21080:21451:21627:30003:30054:30055,0,RBL:205.233.59.134:@infradead.org:.lbl8.mailshell.net-6 2.8.55.1 X-HE-Tag: toys64_47bff1bcb2c62 X-Filterd-Recvd-Size: 4889 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Dec 2019 12:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FvghZFBaoqrMAEVkDDRcPbYOLQl3+Nssq3SxvKZJaQI=; b=eyYSAOGbwuKI+/tsaYEU5bznHd rczIvlRuyztabhFl3bCt9VDUhDf4mBhA+lY7x9tqz4PAb0skfrtoPhJTPMeiZ4XeRU53ia0VekyOO uAo2tqtKGg8GYJfmFe9iPytIgsf5uDNGXLsqdXk4pgOgeu+PaWVbZ6XrF9+bIxUA40EqldwR/L/Gb /qnN85DQU/nWxRFmoXeIpZ6vSzYHsewDDJIpLLokkREYuXmaxAYWyPBx5cLIRYgv3yoAJz/+6TlUL YYV/irr9dWhr4QniMt6SZQNJfFTAIx7bAWgrQ6qJF3PGPEbAwbt1uGi0X0Axl/q0HTGQr3Kh7KjY5 mAIfyp/A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1if191-0003sl-9d; Wed, 11 Dec 2019 12:31:07 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E6C463066B3; Wed, 11 Dec 2019 13:29:43 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 3B16F20137CB2; Wed, 11 Dec 2019 13:31:02 +0100 (CET) Message-Id: <20191211122956.169764611@infradead.org> User-Agent: quilt/0.65 Date: Wed, 11 Dec 2019 13:07:22 +0100 From: Peter Zijlstra To: Will Deacon , "Aneesh Kumar K.V" , Andrew Morton , Nick Piggin , Peter Zijlstra Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yoshinori Sato , Rich Felker , "David S. Miller" , Helge Deller , Geert Uytterhoeven , Paul Burton , Tony Luck , Richard Henderson , Nick Hu , Paul Walmsley Subject: [PATCH 09/17] sh/tlb: Fix __pmd_free_tlb() References: <20191211120713.360281197@infradead.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: SH violates the freeing order for it's PMD page directories. It's __pmd_free_tlb() does not ensure there is a TLB invalidation between itself and the eventualy freeing of the page. Further complicating the situation is that SH uses non page based allocation for it's PMDs. Use the shiny new HAVE_TABLE_FREE option to enable a custom page table freeer. (SuperH uses IPI based TLB invalidation and therefore doesn't need HAVE_RCU_TABLE_FREE for its HAVE_FAST_GUP). Signed-off-by: Peter Zijlstra (Intel) --- arch/sh/Kconfig | 1 + arch/sh/include/asm/pgalloc.h | 3 ++- arch/sh/mm/pgtable.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -15,6 +15,7 @@ config SUPERH select HAVE_PERF_EVENTS select HAVE_DEBUG_BUGVERBOSE select HAVE_FAST_GUP if MMU + select MMU_GATHER_TABLE_FREE if X2TLB select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A) select ARCH_HAS_GCOV_PROFILE_ALL --- a/arch/sh/include/asm/pgalloc.h +++ b/arch/sh/include/asm/pgalloc.h @@ -12,7 +12,8 @@ extern void pgd_free(struct mm_struct *m extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd); extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address); extern void pmd_free(struct mm_struct *mm, pmd_t *pmd); -#define __pmd_free_tlb(tlb, pmdp, addr) pmd_free((tlb)->mm, (pmdp)) +extern void __tlb_remove_table(void *table); +#define __pmd_free_tlb(tlb, pmdp, addr) tlb_remove_table((tlb), (pmdp)) #endif static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, --- a/arch/sh/mm/pgtable.c +++ b/arch/sh/mm/pgtable.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #define PGALLOC_GFP GFP_KERNEL | __GFP_ZERO @@ -55,4 +56,9 @@ void pmd_free(struct mm_struct *mm, pmd_ { kmem_cache_free(pmd_cachep, pmd); } + +void __tlb_remove_table(void *table) +{ + pmd_free(NULL, table); +} #endif /* PAGETABLE_LEVELS > 2 */