From patchwork Wed Dec 11 12:07:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 11284823 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 E4EF0139A for ; Wed, 11 Dec 2019 12:31:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A89F820836 for ; Wed, 11 Dec 2019 12:31:27 +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="U+50Fffw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A89F820836 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 018A36B31ED; Wed, 11 Dec 2019 07:31:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EDA0C6B31EE; Wed, 11 Dec 2019 07:31:20 -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 DA2766B31EF; Wed, 11 Dec 2019 07:31:20 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id C46A96B31ED for ; Wed, 11 Dec 2019 07:31:20 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 6B401181AEF1D for ; Wed, 11 Dec 2019 12:31:20 +0000 (UTC) X-FDA: 76252795920.16.feast06_45d356aa26e01 X-Spam-Summary: 2,0,0,1ab8e2288b051cbb,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:69:152:355:379:800:960:965:966:968:973:988:989:1183:1260:1261:1277:1313:1314:1345:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:1801:2194:2196:2198:2199:2200:2201:2393:2559:2562:2731:2903:3138:3139:3140:3141:3142:3353:3865:3867:3871:3872:4250:4385:4390:4395:4605:5007:6119:6261:6653:6742:8634:9592:10004:10400:11026:11473:11657:11658:11914:12043:12048:12296:12297:12438:12517:12519:13161:13229:14181:14394:14659:14721:21080:21451:21627:21990:30003:30054:30055,0,RBL:198.137.202.133:@infradead.org:.lbl8.mailshell.net-6 2.8.0.10 X-HE-Tag: feast06_45d356aa26e01 X-Filterd-Recvd-Size: 5316 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Dec 2019 12:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=6kZNNxSi21G4pXOCtXTpl9gJxQNMiVTuEix3Ulh9cmE=; b=U+50FffwCXOOmCFvs0ul2LtaFV hZXEbR8JwFIHgJxOtnzEuLJhbTgu/iLzJyBkFwz+/L9ig1+9iG+tN/50OiRVoeGNimDy0Cbj4xuY7 bO2Vs8F0SOAtThWosCnNtDOez0aUiE4CX6pieCiH/ItSRf9VEM1GdopsL384J5Q2+a8ZpAjzZ/fQd 5of6hD4fwuTT1mD9s0EvEfKwaFrLhS8jHCzJSRmSjHqz3WIFHPescBDqQ0xwffllkhZgBb71wGqaC YDcVwIo2S+eiZH/q4Md3azal/pDEv9YXSI6Gg9Gnj5Hp8/s7qQxFFodqMxsGDL45vFOVDS8xqRJT8 ipsqcG0w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1if191-0001Pb-LA; 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 EC9E8306BF0; Wed, 11 Dec 2019 13:29:43 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 4770520137CB9; Wed, 11 Dec 2019 13:31:02 +0100 (CET) Message-Id: <20191211122956.342306385@infradead.org> User-Agent: quilt/0.65 Date: Wed, 11 Dec 2019 13:07:25 +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 12/17] m68k/tlb: Fix __p*_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: Just like regular pages, page directories need to observe the following order: 1) unhook 2) TLB invalidate 3) free to ensure it is safe against concurrent accesses. The Motorola MMU has funny PMD stuff, so use a custom table freeer. Signed-off-by: Peter Zijlstra (Intel) --- arch/m68k/Kconfig | 1 + arch/m68k/include/asm/mcf_pgalloc.h | 11 +++++------ arch/m68k/include/asm/motorola_pgalloc.h | 22 ++++++++++------------ 3 files changed, 16 insertions(+), 18 deletions(-) --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -31,6 +31,7 @@ config M68K select OLD_SIGSUSPEND3 select OLD_SIGACTION select MMU_GATHER_NO_RANGE if MMU + select MMU_GATHER_TABLE_FREE if MMU_MOTOROLA config CPU_BIG_ENDIAN def_bool y --- a/arch/m68k/include/asm/mcf_pgalloc.h +++ b/arch/m68k/include/asm/mcf_pgalloc.h @@ -38,12 +38,11 @@ extern inline pmd_t *pmd_alloc_kernel(pg #define pmd_pgtable(pmd) pmd_page(pmd) -static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page, - unsigned long address) -{ - pgtable_pte_page_dtor(page); - __free_page(page); -} +#define __pte_free_tlb(tlb, pte, address) \ +do { \ + pgtable_pte_page_dtor(pte); \ + tlb_remove_page((tlb), (pte)); \ +} while (0) #define __pmd_free_tlb(tlb, pmd, address) do { } while (0) --- a/arch/m68k/include/asm/motorola_pgalloc.h +++ b/arch/m68k/include/asm/motorola_pgalloc.h @@ -57,15 +57,13 @@ static inline void pte_free(struct mm_st __free_page(page); } -static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page, - unsigned long address) -{ - pgtable_pte_page_dtor(page); - cache_page(kmap(page)); - kunmap(page); - __free_page(page); -} - +#define __pte_free_tlb(tlb, pte, address) \ +do { \ + pgtable_pte_page_dtor(pte); \ + cache_page(kmap(pte)); \ + kunmap(pte); \ + tlb_remove_page((tlb), (pte)); \ +} while (0) static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) { @@ -77,12 +75,12 @@ static inline int pmd_free(struct mm_str return free_pointer_table(pmd); } -static inline int __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, - unsigned long address) +static inline void __tlb_remove_table(void *table) { - return free_pointer_table(pmd); + free_pointer_table(table); } +#define __pmd_free_tlb(tlb, pmd, address) tlb_remove_table((tlb), (pmd)) static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) {