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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 6BE5AC00A89 for ; Mon, 2 Nov 2020 15:53:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AD672225B for ; Mon, 2 Nov 2020 15:53:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="hqSP56nc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbgKBPw7 (ORCPT ); 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-Google-Smtp-Source: ABdhPJywaNhw5aFpN/pYIk6/MJ/bkf/gh0tZ3udL0VlE8QqDUlZAs/BeSFGHSpJn56VGOhuQYMqcFg== 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 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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 0716AC388F2 for ; Mon, 2 Nov 2020 15:53:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 838BA22258 for ; Mon, 2 Nov 2020 15:53:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="hqSP56nc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 838BA22258 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BA7F66B0071; Mon, 2 Nov 2020 10:52:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B2FA16B0074; Mon, 2 Nov 2020 10:52:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F5766B0075; Mon, 2 Nov 2020 10:52:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 68E596B0071 for ; Mon, 2 Nov 2020 10:52:59 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0D9D9180AD801 for ; Mon, 2 Nov 2020 15:52:59 +0000 (UTC) X-FDA: 77439921678.04.uncle66_4605f8c272b1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id E1FC1800224C for ; Mon, 2 Nov 2020 15:52:58 +0000 (UTC) X-HE-Tag: uncle66_4605f8c272b1 X-Filterd-Recvd-Size: 5594 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Mon, 2 Nov 2020 15:52:58 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id w5so6292156qvn.12 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=TWm3PVjXxjcB4SCDoC+3PWM9BXrYA25tfJE7Ky6LgXnP93u88f9Tag4IwjdcgEXtaC R1gk964Ab/4+ag0SdnvUE6Z4S8Z2HwRy6FhA2YGMdvCC99tj0BSN9jsdrYp8bmb4voiw dJ3OfTvqqIPjvgodc3VN5NdYJa7kToM+cpuvpjCdL017qWjOIfewKRHZ4Zr6YvgWl//Q IIp70dezGweGSjJfTvTCGD4wwEVN5eKR/Gzl2LlPvdkeD/bppC2geJMo1Cx1pUX/B9o+ 6mPB3kWMe+MKxY9m2dPMUjslY74WFLLeXZaP0tx0rA0Ifg/KuoT8st63ZOgUjyxGh4zF BqxQ== X-Gm-Message-State: AOAM532gbPEcM8kFZe6BUfBRcM6VPMDhLpHEJjDF348kJ5BgGFbZD2u0 3CdW9ZgkgHEoN9XDb5i8oFCWxA== X-Google-Smtp-Source: ABdhPJywaNhw5aFpN/pYIk6/MJ/bkf/gh0tZ3udL0VlE8QqDUlZAs/BeSFGHSpJn56VGOhuQYMqcFg== 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: 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 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 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=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 76A57C388F2 for ; Mon, 2 Nov 2020 15:54:35 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1332822258 for ; Mon, 2 Nov 2020 15:54:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Y5nFjWaS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="hqSP56nc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1332822258 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nNHXtYhlRJQESOATlu9ywqMHv0uAhiEPIMlYFxBDd5M=; b=Y5nFjWaSb/4hNUL/CfsjoAFsD 95jUjxO+PRc4PqV6FrrRSkgwzo7HQzjyJ/3Xfd/ekyNBBer+YUWfo1GwLiYy82ncVkrTht+eJiAtd g32WduSpvXnZhD0IuhN3MmRiVFG6WYmxclDfApnctIOlsnsXOX7VQI3SRZ2Y9U/L3A9Lf1cE16csJ 1CaPi0aVA42YTvIuyDvUGRmFgte4Sv3wSzJ3ZKzVXG9AG9KelGDKAZQJ8tScC8nfHAyVRSdKHF8L4 FMwJ0aDS2lOdiIgxhuQNQ4VP/IV1PSsSkC3XE5GGOIqEMbizZperOwA6TVVmeyXjnaNKxcANJxleE trqEFaNgQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZc8k-0004jB-Jf; Mon, 02 Nov 2020 15:53:02 +0000 Received: from mail-qv1-xf43.google.com ([2607:f8b0:4864:20::f43]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZc8h-0004hu-GZ for linux-arm-kernel@lists.infradead.org; Mon, 02 Nov 2020 15:53:00 +0000 Received: by mail-qv1-xf43.google.com with SMTP id ed14so2743361qvb.4 for ; Mon, 02 Nov 2020 07:52:59 -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=GaJStQV30niwntf6qaGgegdLQ9mZsjg993ZihkvkyGKYbMqB7GVPE9PTmBOJzIpVsz b3Sc9UDffh859NlProgeXBUNMM2ygCb7jweGV1tk/B3xjPHuG5zCSBZ7RyXTiLtd1/34 Vxov6Mlu5+zGFTENB1uMxYDeR3I4ua+iYNZwlCv/YgX/UDsr4BdukoOs4Ilh7Ln4JV1l EkzkwTIagAeiwAsZhyfdbcdddkjwhKt7MhfQOU4afKGPvTQOy3hpKzMYPw4iy0D1eDZg kGnMH1q4xOgnGnLtAQ0R+5MV0papO2pt5jopzauaaL7z8Q4QuG4rcuCV2iyS0z556EOB vXtA== X-Gm-Message-State: AOAM532/hJ9FcBeKYNer52ga/bJLfbCZZ+5YtYHqCn0FdSUW3vzTuuFc hdiutCld8uaHJMkO/NtEMBxhuA== X-Google-Smtp-Source: ABdhPJywaNhw5aFpN/pYIk6/MJ/bkf/gh0tZ3udL0VlE8QqDUlZAs/BeSFGHSpJn56VGOhuQYMqcFg== 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 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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201102_105259_916935_B7E37851 X-CRM114-Status: GOOD ( 24.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc , Jan Kara , Kees Cook , KVM list , John Hubbard , LKML , DRI Development , Christoph Hellwig , Linux MM , J??r??me Glisse , Daniel Vetter , Dan Williams , Andrew Morton , Linux ARM , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 AD485C388F2 for ; Tue, 3 Nov 2020 08:16:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C5F8206DF for ; Tue, 3 Nov 2020 08:16:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="hqSP56nc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C5F8206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 69EB96EC2C; Tue, 3 Nov 2020 08:14:36 +0000 (UTC) Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by gabe.freedesktop.org (Postfix) with ESMTPS id AF04D6E105 for ; Mon, 2 Nov 2020 15:52:58 +0000 (UTC) Received: by mail-qv1-xf44.google.com with SMTP id bl9so6296615qvb.10 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=rVyUcXprgnR2YvFbSjYPgeiqQJg8/tetkL1bEUXETOj2LW5QBhs8otq/W22zGQ/45M 6+EKf0Azf1uZpUxQJYyLpIhB0Z97bLdPBQvBqv3HOoQAFnRPonIWDWyj/V3TWhf0tfA1 hBMxWx43bWD1+m3M4ke/0JkW2Jy/TdqpxRgIYXralA6qhbWSKoKo8FS8H+zmabtfyt/P jiqqebuLgdF3MyPtNZdeJtIrf/4iEphfDMgX4MpjhzhOf9jRrgY8MVBG2ca9EI6Fxa3R lA/FsmvPYA6J1yZAxVYj5BXaxTTTyQzz19cbZGn4YmGfQt5dkmshK7un5egrhIlh32Ke tC5w== X-Gm-Message-State: AOAM533gsDc1XJr9v+jLSSx70+fJQHTJ66ar8FBVxkr3myPQIzN1DJ9N Fuc9NO8fzA9zS8wllyH6YGevZA== X-Google-Smtp-Source: ABdhPJywaNhw5aFpN/pYIk6/MJ/bkf/gh0tZ3udL0VlE8QqDUlZAs/BeSFGHSpJn56VGOhuQYMqcFg== 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 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-Disposition: inline In-Reply-To: X-Mailman-Approved-At: Tue, 03 Nov 2020 08:14:25 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc , Jan Kara , Kees Cook , KVM list , John Hubbard , LKML , DRI Development , Christoph Hellwig , Linux MM , J??r??me Glisse , Daniel Vetter , Dan Williams , Andrew Morton , Linux ARM , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel