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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 4B474C4332D for ; Sat, 21 Mar 2020 15:18:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D692220780 for ; Sat, 21 Mar 2020 15:18:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D692220780 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 60F976B0003; Sat, 21 Mar 2020 11:18:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C01B6B0005; Sat, 21 Mar 2020 11:18:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AE5F6B0007; Sat, 21 Mar 2020 11:18:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id 31BC56B0003 for ; Sat, 21 Mar 2020 11:18:30 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 0B5082C0D for ; Sat, 21 Mar 2020 15:18:30 +0000 (UTC) X-FDA: 76619725980.06.force69_845dbc8b57c48 X-HE-Tag: force69_845dbc8b57c48 X-Filterd-Recvd-Size: 2330 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Sat, 21 Mar 2020 15:18:29 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 264F468BEB; Sat, 21 Mar 2020 16:18:26 +0100 (CET) Date: Sat, 21 Mar 2020 16:18:25 +0100 From: Christoph Hellwig To: Jason Gunthorpe Cc: Christoph Hellwig , Dan Williams , Bharata B Rao , Christian =?iso-8859-1?Q?K=F6nig?= , Ben Skeggs , Jerome Glisse , kvm-ppc@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-mm@kvack.org Subject: Re: [PATCH 4/4] mm: check the device private page owner in hmm_range_fault Message-ID: <20200321151825.GA7692@lst.de> References: <20200316193216.920734-1-hch@lst.de> <20200316193216.920734-5-hch@lst.de> <20200320134109.GA30230@ziepe.ca> <20200321082236.GB28613@lst.de> <20200321123804.GV20941@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200321123804.GV20941@ziepe.ca> User-Agent: Mutt/1.5.17 (2007-11-01) 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: On Sat, Mar 21, 2020 at 09:38:04AM -0300, Jason Gunthorpe wrote: > > I don't think there is any specific protection. Let me see if we > > can throw in a get_dev_pagemap here > > The page tables are RCU protected right? could we do something like > > if (is_device_private_entry()) { > rcu_read_lock() > if (READ_ONCE(*ptep) != pte) > return -EBUSY; > hmm_is_device_private_entry() > rcu_read_unlock() > } > > ? Are they everywhere? I'd really love to hear from people that really know this ara.. > > Then pgmap needs a synchronize_rcu before the struct page's are > destroyed (possibly gup_fast already requires this?) > > I've got some other patches trying to close some of these styles of > bugs, but > > > note that current mainline doesn't even use it for this path.. > > Don't follow? If you look at mainline (or any other tree), we only do a get_dev_pagemap for devmap ptes. But device private pages are encoded as non-present swap ptes.