Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3398326pxx; Mon, 2 Nov 2020 07:54:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxphNr7HJyG+uXk1gHLdEE+EHA25WOKPnxM4CmjJ+DsD5KTtxQ2f2jeLPpJhfGj8Q/t6URd X-Received: by 2002:a50:8acf:: with SMTP id k15mr17270635edk.351.1604332491340; Mon, 02 Nov 2020 07:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604332491; cv=none; d=google.com; s=arc-20160816; b=rOoAGnDaU/f5Zank6H5l0pyCL1kJFRisrtkfH4+8AgcIhEJk6QhgmamL/xXyM4ERmF PU9xRXuxD3nRNU0XaV4eU90nfDn/Z6ODDpGACOWNV0MCY9/n4Oka+WyKFUmO2gh8d3Hv 3U8Jo7kbaP0Dr5luPWQaO+itTr6be82hg+J2zMrpKSnSEhD+hEKubf0KR6zqEwlGTAE8 znhZma7Sd/hTRMKiSd1jrAzld+4dXkpSAcB2ReDvReBpAKSVPW/6FqLvrjnLMoHV+NKc W54izj7zYZ2bpTx4F0+L63xlP64vSFqLd4sY6Nk/fsyKnU1Pq/LbathVE4jWdGhjF6Dl hmcQ== 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=f4bAkyYQ5JW+w3wAB0B3Wuqs9gDAq+dCKVKb1szgdTE=; b=u6mSXszvzSYLq1A9Dhq2cHqENEC25F/dxcvLIvCqXpNE3XJE7xEJGCPm6ZtheKnawA Mp2k+Dei8F1TY+0cniF/2K+3qirEC81AMl1IWuYCWFVRnVIzVmG+jblS2ynd/HGRskv+ r07fl5pmZZzAzUyFP5SyMCNdS3E5GsFFt0Ud4Brx+sxxdK3F6KqiqtqD7E2ABfwCn4La AzwuJhozUdilZENTyMbgGH514/DHX1164rJmClQ2H01jNJtwL7dkvFNzelk5RgjpeRSW kvUHxYmWuJ6vrh5sYgeYpJkeMAri091CwdIzieBf/JiiSXqASuY21vXpL3NV89z3NTgw nHJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=hqSP56nc; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s17si5877089edr.437.2020.11.02.07.54.27; Mon, 02 Nov 2020 07:54:51 -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=@ziepe.ca header.s=google header.b=hqSP56nc; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbgKBPw7 (ORCPT + 99 others); Mon, 2 Nov 2020 10:52:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbgKBPw6 (ORCPT ); Mon, 2 Nov 2020 10:52:58 -0500 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FB48C0617A6 for ; Mon, 2 Nov 2020 07:52:58 -0800 (PST) Received: by mail-qv1-xf41.google.com with SMTP id da2so4108797qvb.0 for ; Mon, 02 Nov 2020 07:52:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=f4bAkyYQ5JW+w3wAB0B3Wuqs9gDAq+dCKVKb1szgdTE=; b=hqSP56ncN1Xesc0LR+LCBrLcoSGV6TopG9RG3GGTAjXZawK07x4FedOxx8+KwVozhh yTaXjjMacA7HSrB+GRFpwykUXEgHjYuiJRUfTBK6bxwzQkDVZZxpNeA6oR5zy06hcsRr +OWzKfZs32d+rXtNU6sG16vNSbBVRNjen0md3oJEh5m3qEuLJBFDAZd22drwYUhFMUM8 jihAo1Zpdxicjpm3k0zP51jRIixb81HpWfJ8CKClqtFak5XKxto5Xo7s7pUz3s+srShN 1BUfFqWebwl5tOah1zDSpMj6M1bL9GXyO8wQDz9s59OVdbT9CJgBaBWOD1bIDFUY/B+7 N2fQ== 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=f4bAkyYQ5JW+w3wAB0B3Wuqs9gDAq+dCKVKb1szgdTE=; b=ZZUZm8rtLE0wQIFqt+i51Z5pQs21MAk6DBftlG+t7nl/1dbmLSTUSDbfFP4j3guky6 lCgRJcvWMB0Wd2OoUqXCOp5LlebV1rzKO31xCt8eyTVrmcF/luuMPujtZkPBynNrznSV L4aMm5Tva3lje2nCPKjmbKsZjgI1NQjEaVVnFr9Dh97XJnENNsjqGkgaVwDbPNPWERHN w7xuh8n04TOHUT6Wf99VeGRgmGRRz2XZl4cHxysU2AmdPExesIvo4h7P/ql/yl5CtV+s vaa1X5MbDFHjfpxZp+hjOXZuXGKqYlFKuDSP1F/BbFkRbdzvIhh2Os05oaj11EvgTVEq jcQw== X-Gm-Message-State: AOAM530ID0vSLexLr9wC3c7n27vRTT5sREiM5b4BdmNEwnLSvg4qGEHI u6C7OGFhJM/ckmUI/QSfQ3HZaA== X-Received: by 2002:a0c:a261:: with SMTP id f88mr23351432qva.56.1604332377746; Mon, 02 Nov 2020 07:52:57 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id v92sm8169357qte.33.2020.11.02.07.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 07:52:56 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kZc8e-00F975-6s; Mon, 02 Nov 2020 11:52:56 -0400 Date: Mon, 2 Nov 2020 11:52:56 -0400 From: Jason Gunthorpe To: Daniel Vetter Cc: Christoph Hellwig , DRI Development , LKML , KVM list , Linux MM , Linux ARM , linux-samsung-soc , "open list:DMA BUFFER SHARING FRAMEWORK" , Daniel Vetter , Kees Cook , Dan Williams , Andrew Morton , John Hubbard , J??r??me Glisse , Jan Kara Subject: Re: [PATCH v5 08/15] mm: Add unsafe_follow_pfn Message-ID: <20201102155256.GG36674@ziepe.ca> References: <20201030100815.2269-1-daniel.vetter@ffwll.ch> <20201030100815.2269-9-daniel.vetter@ffwll.ch> <20201102072931.GA16419@infradead.org> <20201102130115.GC36674@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 02, 2020 at 02:23:58PM +0100, Daniel Vetter wrote: > On Mon, Nov 2, 2020 at 2:01 PM Jason Gunthorpe wrote: > > > > On Mon, Nov 02, 2020 at 01:56:10PM +0100, Daniel Vetter wrote: > > > On Mon, Nov 2, 2020 at 8:29 AM Christoph Hellwig wrote: > > > > > > > > On Fri, Oct 30, 2020 at 11:08:08AM +0100, Daniel Vetter wrote: > > > > > Also mark up follow_pfn as EXPORT_SYMBOL_GPL. The only safe way to use > > > > > that by drivers/modules is together with an mmu_notifier, and that's > > > > > all _GPL stuff. > > > > > > > > I also think it also needs to be renamed to explicitly break any existing > > > > users out of tree or int the submission queue. > > > > > > Ok I looked at the mmu notifier locking again and noticed that > > > mm->subscriptions has its own spinlock. Since there usually shouldn't > > > be a huge pile of these I think it's feasible to check for the mmu > > > notifier in follow_pfn. And that would stuff this gap for good. I'll > > > throw that on top as a final patch and see what people think. > > > > Probably the simplest is to just check mm_has_notifiers() when in > > lockdep or something very simple like that > > lockdep feels wrong, was locking more at CONFIG_DEBUG_VM. And since > generally you only have 1 mmu notifier (especially for kvm) I think we > can also pay the 2nd cacheline miss and actually check the right mmu > notifier is registered. Need to hold the lock to check that and there are two ways to register notifiers these days, so it feels to expensive to me. CH's 'export symbol only for kvm' really does seem the most robust way to handle this though. Jason