Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1129441pxb; Sat, 16 Jan 2021 20:44:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxY4IHXPuASPeV1hnl9aYljAB2OEPKm7OosTMX4rCQtKpyot1dXTFXM1xise7yxjFofM08j X-Received: by 2002:a50:d484:: with SMTP id s4mr15129898edi.13.1610858679374; Sat, 16 Jan 2021 20:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610858679; cv=none; d=google.com; s=arc-20160816; b=rNch1X+IId8zxkjONxQ1LoAmSBtnJElRsYlAbRwGCCmQBfH5BkaHrpXfGPz4tIzIGG uccZdErQBTmx5FPWRKDeVVwfCVuEMr+OoZGfqrbrVP8o//Y+sp08pgKQ+lb9yTvv+Bcd cHkr/FTQ+XWsmAjavVZveG3u/YgQC/o+BNDKNRyfIEE61w0ygHaXThWbWQtaBc4/MF1C cCggrXArVtS8W6shfxLga+w+gd1c28nZg0rp/O62a2yQyQ4dt2/qq01XJV+DQIWcG9vT pE+wVGCf6JSs9gqhAyFcm0TdTeCIkLYqgqUCXdgR6izGAD0dAlp65WoOcX3gU8rvFl4e fohw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=B1u3O83tTrsiNvPrp3hP0q70ExIGdl4r796ZiGkVvug=; b=K++R6WLYrT7yqWkzdQq046hOOVUK04TT52H9fpIBgE9F5z4B+4MFtZg2Jclaiv3lGP ockPDUcMDHBxd8FZVgJDvdDh5sjv/z+A0dMG2S2C05SmSD4HCtSn3gzbJukiVvi/hLJW JL81djfqIIntyQGsZcA6uJwNpJzkT16j+6Tx2gWkvvSQzWGFTCWgKgIZWy9QnVmhIEaB nZNNURiRhtwHVzJKVgvzn+saTZdmTGsl0tmt/qM73pvvVTP72UZmJOCsmcp2/kOyDTcR Re7b2dB/JfQbsm7sHI/yqBCZhFVhDWoWeOreLKdXAd4p224zH1MGzig3gS0pnTjzoAE3 08fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=N1aT2fBk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v8si5958852ejb.630.2021.01.16.20.44.16; Sat, 16 Jan 2021 20:44:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=N1aT2fBk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727629AbhAQEm0 (ORCPT + 99 others); Sat, 16 Jan 2021 23:42:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbhAQEmK (ORCPT ); Sat, 16 Jan 2021 23:42:10 -0500 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CD2AC061574 for ; Sat, 16 Jan 2021 20:41:30 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id e22so26380131iom.5 for ; Sat, 16 Jan 2021 20:41:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=B1u3O83tTrsiNvPrp3hP0q70ExIGdl4r796ZiGkVvug=; b=N1aT2fBkHInlcB+SZ3y3jFU0B3PlXy6oQ9UoC2DV3e03WGOj7kquOGyhUCZfwmUThV xWBXH42AWotId0uCXKh9KXFy5i9GGKv1JznVVFqEiG6mh83/qbPvFlxRIbrWI2qH92E4 2R8i+dDmCkDFRQUeC0C7eArExk7aWwcROV1/a4cWml3fwCdLHZr/w+jcLL0ZdXazxJ7j O/MdslR1uPPl2rQcbKtEqnq0GSiujKsPS7nbbJkpR0HLzazeto7sWAWJmqT30oaK2yXA cHJLEmL8juw/8Bf+enLx/6pausdfE3zFhPX/IZ49Xu8ZEphPLfyLAAQr9+xHIikMTWS7 RO6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=B1u3O83tTrsiNvPrp3hP0q70ExIGdl4r796ZiGkVvug=; b=NXen13oruk3cOTwuDfSsteKmATtv3VAiDxB1fFsHWswd0ffMb+5WPP971k8kETDNNp yiz0mfee6Tr71UtwoT6526By2epgb/5Y/2BYv8MXE8H6T21FvqgrXdysunZocjcdgujg V7lARUoUYtTsZ/PAPbe+J1odPaIimRQKEY+C2CXRJYCvsqgM517Vb80Fqbt+ymqtao3j EyfyCezilyx6rcyOCsMc7R70GGaIp80YPRCG4idm/dSEZARQEb0ar8cIOUHGOWSdOToV RHX+Q/t1Dc8X5vksbfUbba0E0GGTQj7CauNIiFYtCdYD0pdtdMHq0grYA9d9WwhgZLgr 3WDw== X-Gm-Message-State: AOAM530euN+DwpatDzz/MCjgo1kmnrFYfOQI8RrIPQWCkzjTRJlkPeHb G/zXGG1G7nSNnoDa6NNevbhqNg== X-Received: by 2002:a92:d4c4:: with SMTP id o4mr17061597ilm.15.1610858489666; Sat, 16 Jan 2021 20:41:29 -0800 (PST) Received: from google.com ([2620:15c:183:200:7d62:41db:b863:bc92]) by smtp.gmail.com with ESMTPSA id g13sm7969402iln.12.2021.01.16.20.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jan 2021 20:41:28 -0800 (PST) Date: Sat, 16 Jan 2021 21:41:25 -0700 From: Yu Zhao To: Will Deacon Cc: Nadav Amit , Laurent Dufour , Peter Zijlstra , Vinayak Menon , Linus Torvalds , Andy Lutomirski , Peter Xu , Andrea Arcangeli , linux-mm , lkml , Pavel Emelyanov , Mike Kravetz , Mike Rapoport , stable , Minchan Kim , surenb@google.com Subject: Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect Message-ID: References: <20210105153727.GK3040@hirez.programming.kicks-ass.net> <0201238b-e716-2a3c-e9ea-d5294ff77525@linux.vnet.ibm.com> <2C7AE23B-ACA3-4D55-A907-AF781C5608F0@gmail.com> <20210112214337.GA10434@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210112214337.GA10434@willie-the-truck> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 12, 2021 at 09:43:38PM +0000, Will Deacon wrote: > On Tue, Jan 12, 2021 at 12:38:34PM -0800, Nadav Amit wrote: > > > On Jan 12, 2021, at 11:56 AM, Yu Zhao wrote: > > > On Tue, Jan 12, 2021 at 11:15:43AM -0800, Nadav Amit wrote: > > >> I will send an RFC soon for per-table deferred TLB flushes tracking. > > >> The basic idea is to save a generation in the page-struct that tracks > > >> when deferred PTE change took place, and track whenever a TLB flush > > >> completed. In addition, other users - such as mprotect - would use > > >> the tlb_gather interface. > > >> > > >> Unfortunately, due to limited space in page-struct this would only > > >> be possible for 64-bit (and my implementation is only for x86-64). > > > > > > I don't want to discourage you but I don't think this would end up > > > well. PPC doesn't necessarily follow one-page-struct-per-table rule, > > > and I've run into problems with this before while trying to do > > > something similar. > > > > Discourage, discourage. Better now than later. > > > > It will be relatively easy to extend the scheme to be per-VMA instead of > > per-table for architectures that prefer it this way. It does require > > TLB-generation tracking though, which Andy only implemented for x86, so I > > will focus on x86-64 right now. > > Can you remind me of what we're missing on arm64 in this area, please? I'm > happy to help get this up and running once you have something I can build > on. I noticed arm/arm64 don't support ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH. Would it be something worth pursuing? Arm has been using mm_cpumask, so it might not be too difficult I guess?