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 15F6AC00A89 for ; Mon, 2 Nov 2020 16:42:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DA75222EC for ; Mon, 2 Nov 2020 16:42:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="DejrOT1E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726865AbgKBQmf (ORCPT ); Mon, 2 Nov 2020 11:42:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727334AbgKBQmd (ORCPT ); Mon, 2 Nov 2020 11:42:33 -0500 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3646C061A04 for ; Mon, 2 Nov 2020 08:42:32 -0800 (PST) Received: by mail-ot1-x341.google.com with SMTP id z16so8006730otq.6 for ; Mon, 02 Nov 2020 08:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LkcPNNpMLX6kEqUed20/jhdzhJZXy+qPlqOir1Z4UWg=; b=DejrOT1ET977KzMedOZFf/nvESeZd35VW615DHzfUVNv/jtr5S39tQRR1rkXRrNQsS 8e7QakA0NQZajazNYknFTyPn7wzCTD0MaLh6LD79vAKy5J2WjkyqZwU1hUMlTMpcVTcY aRcqJL/19jZSjJmXa+xeFfRoO2oW4s/0IBZV8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LkcPNNpMLX6kEqUed20/jhdzhJZXy+qPlqOir1Z4UWg=; b=LB50Iy3ALgfY0H/MP8IC1/ixodiAAo14lf8FkseEo+ePoIdljh0LXks/rPrd0BOSbs IGSu2bHVAJwGPe56IbYK6sS5vm70VS6tESXAxouQG5j3YFNcShCfBYVqKCDfdT5u0p3X ZiFFhuM1ouPRZtMPC7XkJhIGvi6CAUCbFNpon7WBDQnyNR2WHzChAiMQHDtXVI905jDM 3OOK4A+/wr3UJsqK1WL82hw/dbHVB1Ytfjeih4PTbn81urWlcyZdRi5/oL8wlFz1AhX2 9FB+U2I/NQl/e85AaJD0ZEaIE6fHwLubi+OIc8cdN/XC43yScP/aZcsl6EJqcfFmYfpa naAQ== X-Gm-Message-State: AOAM532Igk7YgYeUKGWwN4CmyRpZ9CxoIWAcoJDSSc+KAS4dVo2JrTce hqeudCssyVYAjoPbE5EY2JsNKokB/lWoza3tCMug0A== X-Google-Smtp-Source: ABdhPJw6fgeaE8WrMv6/yjTLi0nLsEgIsTJGq7lnieyfjRKsxeZQjFjVvPlXPA1vJ6n1s7o3wIRvF8cXTGM5e/OE7rM= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr13325941otr.281.1604335352341; Mon, 02 Nov 2020 08:42:32 -0800 (PST) MIME-Version: 1.0 References: <20201030100815.2269-1-daniel.vetter@ffwll.ch> <20201030100815.2269-9-daniel.vetter@ffwll.ch> <20201102072931.GA16419@infradead.org> <20201102130115.GC36674@ziepe.ca> <20201102155256.GG36674@ziepe.ca> In-Reply-To: <20201102155256.GG36674@ziepe.ca> From: Daniel Vetter Date: Mon, 2 Nov 2020 17:42:20 +0100 Message-ID: Subject: Re: [PATCH v5 08/15] mm: Add unsafe_follow_pfn To: Jason Gunthorpe 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 2, 2020 at 4:52 PM Jason Gunthorpe wrote: > > 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. Uh I mixed stuff up all along, struct mmu_notifier *subcription that all the mmu notifier users use has the ->mm pointer we want right there. That's good enough I think. Now I'm kinda lost in kvm code trying to wire it through, but it's looking ok-ish thus far :-) -Daniel > CH's 'export symbol only for kvm' really does seem the most robust way > to handle this though. > > Jason -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch 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 C3CCBC55178 for ; Mon, 2 Nov 2020 16:42:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F02BA223AB for ; Mon, 2 Nov 2020 16:42:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="DejrOT1E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F02BA223AB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7058C6B006C; Mon, 2 Nov 2020 11:42:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 68EBF6B0070; Mon, 2 Nov 2020 11:42:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 567376B006C; Mon, 2 Nov 2020 11:42:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0240.hostedemail.com [216.40.44.240]) by kanga.kvack.org (Postfix) with ESMTP id 26C0B6B006C for ; Mon, 2 Nov 2020 11:42:35 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A57633631 for ; Mon, 2 Nov 2020 16:42:34 +0000 (UTC) X-FDA: 77440046628.26.air29_3b008b4272b1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 80A6E1804B647 for ; Mon, 2 Nov 2020 16:42:34 +0000 (UTC) X-HE-Tag: air29_3b008b4272b1 X-Filterd-Recvd-Size: 5408 Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Mon, 2 Nov 2020 16:42:33 +0000 (UTC) Received: by mail-ot1-f66.google.com with SMTP id 32so13203622otm.3 for ; Mon, 02 Nov 2020 08:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LkcPNNpMLX6kEqUed20/jhdzhJZXy+qPlqOir1Z4UWg=; b=DejrOT1ET977KzMedOZFf/nvESeZd35VW615DHzfUVNv/jtr5S39tQRR1rkXRrNQsS 8e7QakA0NQZajazNYknFTyPn7wzCTD0MaLh6LD79vAKy5J2WjkyqZwU1hUMlTMpcVTcY aRcqJL/19jZSjJmXa+xeFfRoO2oW4s/0IBZV8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LkcPNNpMLX6kEqUed20/jhdzhJZXy+qPlqOir1Z4UWg=; b=OI+/Y65gq8fFYvPqVC87nQqQwR9viZMB/lWmWfl5feMGc8KjaImLElKPFZq5qjBAv1 VX+/tOY9StfUjApJLaYavsWWKvj95X8UkORUfnHoeY9E6G/MMHIMPBWobjHFcCi0HJYf /q5Hmvn9fPP8RhJc9m+eo6oYy01mYk6/20MKK5S09n8LffOakJGPGwhvgURuNJ9KMetr +sQVvEaH6YYAVZzu6Yv0Cv0PM/BcgF/EUMsphM3tLQHyP69KVtoGWEGDdzOmGF0/tRr0 v1rEj7kIHuAApbcc4EXTPL5R0cEGtH6Kol9KTst+QOH1rj921YkQj5fexLjd8eP1Kgc/ mgig== X-Gm-Message-State: AOAM533/BynZddMvXEziPeoZuNOsaV9BHiVWD67T4BZeSGSivoJpBfx7 bVldvZ+p/xFx/ty6Tm/79EZLuv8DViYg4N/U8GkQWw== X-Google-Smtp-Source: ABdhPJw6fgeaE8WrMv6/yjTLi0nLsEgIsTJGq7lnieyfjRKsxeZQjFjVvPlXPA1vJ6n1s7o3wIRvF8cXTGM5e/OE7rM= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr13325941otr.281.1604335352341; Mon, 02 Nov 2020 08:42:32 -0800 (PST) MIME-Version: 1.0 References: <20201030100815.2269-1-daniel.vetter@ffwll.ch> <20201030100815.2269-9-daniel.vetter@ffwll.ch> <20201102072931.GA16419@infradead.org> <20201102130115.GC36674@ziepe.ca> <20201102155256.GG36674@ziepe.ca> In-Reply-To: <20201102155256.GG36674@ziepe.ca> From: Daniel Vetter Date: Mon, 2 Nov 2020 17:42:20 +0100 Message-ID: Subject: Re: [PATCH v5 08/15] mm: Add unsafe_follow_pfn To: Jason Gunthorpe 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 Content-Type: text/plain; charset="UTF-8" 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 2, 2020 at 4:52 PM Jason Gunthorpe wrote: > > 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. Uh I mixed stuff up all along, struct mmu_notifier *subcription that all the mmu notifier users use has the ->mm pointer we want right there. That's good enough I think. Now I'm kinda lost in kvm code trying to wire it through, but it's looking ok-ish thus far :-) -Daniel > CH's 'export symbol only for kvm' really does seem the most robust way > to handle this though. > > Jason -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch 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 710C1C4742C for ; Mon, 2 Nov 2020 16:45:06 +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 025BB22268 for ; Mon, 2 Nov 2020 16:45:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="U0z1YwBg"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="DejrOT1E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 025BB22268 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch 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:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jG0joZndRg2JMc08f05Cg/p0WqWXWeB5wLXJbdWc14A=; b=U0z1YwBgt2UEWD7IQ6RA/Cct0 A3O3K6JTowYK56mq8Z83+6+8zrMNdfAagSV9EU12hl3w8ybXwRMet2mOXf0ZjQXchUar6pZzW0kKz 0j907Tr6vzF2pn2nOy9/DFRIyHergrAW/0b1KSksbnpSOAUThYeBCAjfQtSDQIBoFVRGeUO69DZYF vyiUIj1iS1oiUx6QWWFtzaUVthk42v8McT1bqahs7rZ1nzT4teJiUgTMRUgItCzZk71yu3x/chz4J l0AMZe5PqEf81IRZoq5tTTu7/neTEqSNfavieaN3sxiRI930ZwCKZIcb8FG7jQpgUz6v2VqAKW3ke 9mjseVdQw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZcvh-0005sX-AJ; Mon, 02 Nov 2020 16:43:37 +0000 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZcuh-0005Kb-0l for linux-arm-kernel@lists.infradead.org; Mon, 02 Nov 2020 16:42:43 +0000 Received: by mail-ot1-x344.google.com with SMTP id i18so8461194ots.0 for ; Mon, 02 Nov 2020 08:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LkcPNNpMLX6kEqUed20/jhdzhJZXy+qPlqOir1Z4UWg=; b=DejrOT1ET977KzMedOZFf/nvESeZd35VW615DHzfUVNv/jtr5S39tQRR1rkXRrNQsS 8e7QakA0NQZajazNYknFTyPn7wzCTD0MaLh6LD79vAKy5J2WjkyqZwU1hUMlTMpcVTcY aRcqJL/19jZSjJmXa+xeFfRoO2oW4s/0IBZV8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LkcPNNpMLX6kEqUed20/jhdzhJZXy+qPlqOir1Z4UWg=; b=oh6UumPZXvVAZaso7oC+mKwmmgkjeVHFpa4nQcJ1Rhwos8N77Zl7jnPJlsNH1BBcrj 5a20ooMYwFDAc0Yqyn63gJA5hYs7kdJO+jajzumIBN+h+9gO2y4LrrqH5mLuMzF74GT9 gnAVcoK5sR6kCXZn210jNq/RXq0tEJ2v55fkZbfktTTZ06uRXQJFq6B5rk9+VtgQbcF1 OtJ49i8spB14wm0fJ3lyOidlugFIsFTHeo4PGQ5X9Qh6TW4aXZhCHRSe7mm7VrsdKiGV zco5rPlSkBoEPmkDSpaeA6zB06qAFIDDzCrEB1PN16QoS4yoGvCD2SYLups6YouqTIew 38Dw== X-Gm-Message-State: AOAM531ysawkdZVQSA08XGZLVyQiF59vD2XX4JnxEiFGD5zcl4PxE0HJ 3mxoWbzZR+dNomS+126ELX3359ay3KsQegDVQ3mF+Q== X-Google-Smtp-Source: ABdhPJw6fgeaE8WrMv6/yjTLi0nLsEgIsTJGq7lnieyfjRKsxeZQjFjVvPlXPA1vJ6n1s7o3wIRvF8cXTGM5e/OE7rM= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr13325941otr.281.1604335352341; Mon, 02 Nov 2020 08:42:32 -0800 (PST) MIME-Version: 1.0 References: <20201030100815.2269-1-daniel.vetter@ffwll.ch> <20201030100815.2269-9-daniel.vetter@ffwll.ch> <20201102072931.GA16419@infradead.org> <20201102130115.GC36674@ziepe.ca> <20201102155256.GG36674@ziepe.ca> In-Reply-To: <20201102155256.GG36674@ziepe.ca> From: Daniel Vetter Date: Mon, 2 Nov 2020 17:42:20 +0100 Message-ID: Subject: Re: [PATCH v5 08/15] mm: Add unsafe_follow_pfn To: Jason Gunthorpe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201102_114236_629240_429C61EC X-CRM114-Status: GOOD ( 26.40 ) 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 2, 2020 at 4:52 PM Jason Gunthorpe wrote: > > 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. Uh I mixed stuff up all along, struct mmu_notifier *subcription that all the mmu notifier users use has the ->mm pointer we want right there. That's good enough I think. Now I'm kinda lost in kvm code trying to wire it through, but it's looking ok-ish thus far :-) -Daniel > CH's 'export symbol only for kvm' really does seem the most robust way > to handle this though. > > Jason -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ 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 8613FC4742C for ; Mon, 2 Nov 2020 16:42:35 +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 A582B222B9 for ; Mon, 2 Nov 2020 16:42:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="DejrOT1E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A582B222B9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch 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 BEECC6E47B; Mon, 2 Nov 2020 16:42:33 +0000 (UTC) Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by gabe.freedesktop.org (Postfix) with ESMTPS id F09FD6E47B for ; Mon, 2 Nov 2020 16:42:32 +0000 (UTC) Received: by mail-ot1-x342.google.com with SMTP id j14so2969702ots.1 for ; Mon, 02 Nov 2020 08:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LkcPNNpMLX6kEqUed20/jhdzhJZXy+qPlqOir1Z4UWg=; b=DejrOT1ET977KzMedOZFf/nvESeZd35VW615DHzfUVNv/jtr5S39tQRR1rkXRrNQsS 8e7QakA0NQZajazNYknFTyPn7wzCTD0MaLh6LD79vAKy5J2WjkyqZwU1hUMlTMpcVTcY aRcqJL/19jZSjJmXa+xeFfRoO2oW4s/0IBZV8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LkcPNNpMLX6kEqUed20/jhdzhJZXy+qPlqOir1Z4UWg=; b=DOdjvr/rIEQoOkk3QfKAZuhlIQPOf5DRLCqGwgEbr6pbJ8eBBueE8BT8c2M5738IEC TKzanrFFVhfVCXhlacODkKA7IElROs6OTVsphAYBb7Cm7Ux6hqmactaEoztDpJubdE5u 5j33IHF+h/74JW+ZW2dsYfQRfSsqiK/AJiHVTyFcfhIgln06++B0206fm+19D3r1uIrf coNRi26zC3jinDwGQyfFxjc3yMhlH3lO4c5PVKCuGFrqHGLvOlxFLydgVNXSPfyGdlw1 W4NZpidWjpk2vG8jgS27PYKaHeHPQN8mtOEOytDP2auQ5H8JI1Qw87ybOBspEYowdHnV wp7A== X-Gm-Message-State: AOAM530+UMn+24ee6cznP7cxedguY1TDbDx+i5moBWnhY+VVgmwHsc6c T3mwcV0vwQQL7vhQHuHABSM0zg7zwuSh5kj82DzVxg== X-Google-Smtp-Source: ABdhPJw6fgeaE8WrMv6/yjTLi0nLsEgIsTJGq7lnieyfjRKsxeZQjFjVvPlXPA1vJ6n1s7o3wIRvF8cXTGM5e/OE7rM= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr13325941otr.281.1604335352341; Mon, 02 Nov 2020 08:42:32 -0800 (PST) MIME-Version: 1.0 References: <20201030100815.2269-1-daniel.vetter@ffwll.ch> <20201030100815.2269-9-daniel.vetter@ffwll.ch> <20201102072931.GA16419@infradead.org> <20201102130115.GC36674@ziepe.ca> <20201102155256.GG36674@ziepe.ca> In-Reply-To: <20201102155256.GG36674@ziepe.ca> From: Daniel Vetter Date: Mon, 2 Nov 2020 17:42:20 +0100 Message-ID: Subject: Re: [PATCH v5 08/15] mm: Add unsafe_follow_pfn To: Jason Gunthorpe 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 2, 2020 at 4:52 PM Jason Gunthorpe wrote: > > 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. Uh I mixed stuff up all along, struct mmu_notifier *subcription that all the mmu notifier users use has the ->mm pointer we want right there. That's good enough I think. Now I'm kinda lost in kvm code trying to wire it through, but it's looking ok-ish thus far :-) -Daniel > CH's 'export symbol only for kvm' really does seem the most robust way > to handle this though. > > Jason -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel