From patchwork Tue Jan 14 10:01:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 11331773 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 218AB930 for ; Tue, 14 Jan 2020 10:02:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC8D32465B for ; Tue, 14 Jan 2020 10:02:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC8D32465B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B0AE38E000B; Tue, 14 Jan 2020 05:02:32 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AB83C8E000A; Tue, 14 Jan 2020 05:02:32 -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 959218E000B; Tue, 14 Jan 2020 05:02:32 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id 799668E0009 for ; Tue, 14 Jan 2020 05:02:32 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 36E19181AC9BF for ; Tue, 14 Jan 2020 10:02:32 +0000 (UTC) X-FDA: 76375800144.25.sleet72_16133d605e461 X-Spam-Summary: 2,0,0,df72114dcf419a29,d41d8cd98f00b204,aneesh.kumar@linux.ibm.com,:akpm@linux-foundation.org:peterz@infradead.org:will@kernel.org::linux-kernel@vger.kernel.org:linux-arch@vger.kernel.org:aneesh.kumar@linux.ibm.com,RULES_HIT:41:334:355:368:369:379:541:965:966:968:988:989:1042:1260:1261:1311:1314:1345:1437:1515:1535:1542:1711:1730:1747:1777:1792:1801:1981:2194:2196:2198:2199:2200:2201:2393:2559:2562:2731:2899:2904:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3871:3872:3874:4250:4385:4390:4395:4605:5007:6119:6261:8634:10004:11026:11473:11657:11658:11914:12043:12050:12296:12297:12438:12895:13153:13161:13228:13229:13894:14096:14394:14721:21080:21433:21451:21627:21772:21795:30051:30054:30089,0,RBL:148.163.156.1:@linux.ibm.com:.lbl8.mailshell.net-62.2.0.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: sleet72_16133d605e461 X-Filterd-Recvd-Size: 5724 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Jan 2020 10:02:31 +0000 (UTC) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00EA23Pg081517; Tue, 14 Jan 2020 05:02:07 -0500 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xfavytyd7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2020 05:02:06 -0500 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 00EA075d020269; Tue, 14 Jan 2020 10:01:56 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma02dal.us.ibm.com with ESMTP id 2xf74p13k0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2020 10:01:55 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00EA1sED50921896 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Jan 2020 10:01:54 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 935E5C6057; Tue, 14 Jan 2020 10:01:54 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A37FC605A; Tue, 14 Jan 2020 10:01:52 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.35.105]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 14 Jan 2020 10:01:51 +0000 (GMT) From: "Aneesh Kumar K.V" To: akpm@linux-foundation.org, peterz@infradead.org, will@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, "Aneesh Kumar K.V" Subject: [PATCH v3 0/9] Fixup page directory freeing Date: Tue, 14 Jan 2020 15:31:36 +0530 Message-Id: <20200114100145.365527-1-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-14_02:2020-01-13,2020-01-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 suspectscore=2 adultscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=487 bulkscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001140090 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: This is a repost of patch series from Peter with the arch specific changes except ppc64 dropped. ppc64 changes are added here because we are redoing the patch series on top of ppc64 changes. This makes it easy to backport these changes. Only the first 3 patches need to be backported to stable. The thing is, on anything SMP, freeing page directories should observe the exact same order as normal page freeing: 1) unhook page/directory 2) TLB invalidate 3) free page/directory Without this, any concurrent page-table walk could end up with a Use-after-Free. This is esp. trivial for anything that has software page-table walkers (HAVE_FAST_GUP / software TLB fill) or the hardware caches partial page-walks (ie. caches page directories). Even on UP this might give issues since mmu_gather is preemptible these days. An interrupt or preempted task accessing user pages might stumble into the free page if the hardware caches page directories. This patch series fixup ppc64 and add generic MMU_GATHER changes to support the conversion of other architectures. I haven't added patches w.r.t other architecture because they are yet to be acked. Aneesh Kumar K.V (1): powerpc/mmu_gather: Enable RCU_TABLE_FREE even for !SMP case Peter Zijlstra (8): mm/mmu_gather: Invalidate TLB correctly on batch allocation failure and flush asm-generic/tlb: Avoid potential double flush asm-gemeric/tlb: Remove stray function declarations asm-generic/tlb: Add missing CONFIG symbol asm-generic/tlb: Rename HAVE_RCU_TABLE_FREE asm-generic/tlb: Rename HAVE_MMU_GATHER_PAGE_SIZE asm-generic/tlb: Rename HAVE_MMU_GATHER_NO_GATHER asm-generic/tlb: Provide MMU_GATHER_TABLE_FREE arch/Kconfig | 13 +- arch/arm/Kconfig | 2 +- arch/arm/include/asm/tlb.h | 4 - arch/arm64/Kconfig | 2 +- arch/powerpc/Kconfig | 5 +- arch/powerpc/include/asm/book3s/32/pgalloc.h | 8 -- arch/powerpc/include/asm/book3s/64/pgalloc.h | 2 - arch/powerpc/include/asm/nohash/pgalloc.h | 8 -- arch/powerpc/include/asm/tlb.h | 11 ++ arch/powerpc/mm/book3s64/pgtable.c | 7 - arch/s390/Kconfig | 4 +- arch/sparc/Kconfig | 3 +- arch/sparc/include/asm/tlb_64.h | 9 ++ arch/x86/Kconfig | 2 +- arch/x86/include/asm/tlb.h | 4 +- include/asm-generic/tlb.h | 120 ++++++++++------- mm/gup.c | 2 +- mm/mmu_gather.c | 134 +++++++++++++------ 18 files changed, 207 insertions(+), 133 deletions(-)