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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 C3F8FC43462 for ; Thu, 8 Apr 2021 11:44:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 67E9A61157 for ; Thu, 8 Apr 2021 11:44:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67E9A61157 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 E99676B0080; Thu, 8 Apr 2021 07:44:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E6FCD6B0081; Thu, 8 Apr 2021 07:44:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D10936B0082; Thu, 8 Apr 2021 07:44:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id B47926B0080 for ; Thu, 8 Apr 2021 07:44:10 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 62C6F180AE7F3 for ; Thu, 8 Apr 2021 11:44:10 +0000 (UTC) X-FDA: 78009016260.17.1D320BF Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by imf06.hostedemail.com (Postfix) with ESMTP id 47343C0007CE for ; Thu, 8 Apr 2021 11:44:11 +0000 (UTC) Received: by mail-wr1-f43.google.com with SMTP id x7so1777952wrw.10 for ; Thu, 08 Apr 2021 04:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=+bIMHjM8IkWGQ9w2UhAWL6nad3z/nsAAXwfEZIX9lWc=; b=HzLW9PAKd4D2FBBBl8PCr0y3Kw+mUxzAfMkhunUFy5g084vTc3tR3FgCZULEQo0aRJ 70RJkyKfjoUXms2whB0E+fWJOI2bfvz4DeQho9AoZyPY+Fi8PJLOMkNvY/vNEMPUQWqq eGGIn6Fb7N4Gn6wTADCQI6woEj7GonRXHLLvE= 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 :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=+bIMHjM8IkWGQ9w2UhAWL6nad3z/nsAAXwfEZIX9lWc=; b=kEwIkTCidYCTNN/G04nWXsi1DVqk9pRMnD1RQRh9nS4dgXZ7BM0M0ec2Fc53lyyILr BiDjGhwanmS9M4vefzEn+cEGoZzQHPAhkluyjRpB36B8oUKbWTWzGjd6A+gwHA0uFrwJ qcaIrXBnBiCl99vFOK9Yf4DcbwgxA1BZ8xwpo1XEwX7/FwVbwSzyA535MIeOL1S6qUpq muU7Bd7SYTR8iwykMkSWYlRNJX1oL/K7YYn+luH7idE5CGuUBQM+fQN9GIJEFw+/wQDE 4b89XNGINyGl3GBk1z+ocCVFe9MnRQZhcqnvv44cKA2b1hzQHbBBA33VBGHi74RFJndY Rn+g== X-Gm-Message-State: AOAM531Uz/SGMbblSg10SobXtjRdbDqQcXUSw0UX96wSZCqnT9VzLvGX mRv9UFkFQGH/ZuYbR/FfExglGg== X-Google-Smtp-Source: ABdhPJx7T3RCQlE5ua8yXfZvWLP1S80e0mDHoUGS7ErWGxP0VUT/3ngstw02CFjw7tqjgD8X14d31A== X-Received: by 2002:adf:e743:: with SMTP id c3mr7764889wrn.408.1617882248844; Thu, 08 Apr 2021 04:44:08 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id f7sm11692950wmq.11.2021.04.08.04.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 04:44:08 -0700 (PDT) Date: Thu, 8 Apr 2021 13:44:06 +0200 From: Daniel Vetter To: Paolo Bonzini Cc: Jason Gunthorpe , DRI Development , LKML , kvm@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-media@vger.kernel.org, 3pvd@google.com, Jann Horn , Cornelia Huck , Peter Xu , Alex Williamson , Daniel Vetter Subject: Re: [PATCH 3/3] mm: unexport follow_pfn Message-ID: Mail-Followup-To: Paolo Bonzini , Jason Gunthorpe , DRI Development , LKML , kvm@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-media@vger.kernel.org, 3pvd@google.com, Jann Horn , Cornelia Huck , Peter Xu , Alex Williamson , Daniel Vetter References: <20210316153303.3216674-1-daniel.vetter@ffwll.ch> <20210316153303.3216674-4-daniel.vetter@ffwll.ch> <20210329133101.GA1168973@nvidia.com> <5f956a46-da38-e72a-edaa-3b746a275f1e@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5f956a46-da38-e72a-edaa-3b746a275f1e@redhat.com> X-Operating-System: Linux phenom 5.7.0-1-amd64 X-Rspamd-Queue-Id: 47343C0007CE X-Stat-Signature: bx4usg5p5gaxbwo6794s94e8jr4tnsox X-Rspamd-Server: rspam02 Received-SPF: none (ffwll.ch>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=mail-wr1-f43.google.com; client-ip=209.85.221.43 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617882251-940679 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 Thu, Apr 08, 2021 at 01:40:59PM +0200, Paolo Bonzini wrote: > On 08/04/21 12:05, Daniel Vetter wrote: > > On Mon, Mar 29, 2021 at 10:31:01AM -0300, Jason Gunthorpe wrote: > > > On Tue, Mar 16, 2021 at 04:33:03PM +0100, Daniel Vetter wrote: > > > > Both kvm (in bd2fae8da794 ("KVM: do not assume PTE is writable after > > > > follow_pfn")) and vfio (in 07956b6269d3 ("vfio/type1: Use > > > > follow_pte()")) have lost their callsites of follow_pfn(). All the > > > > other ones have been switched over to unsafe_follow_pfn because they > > > > cannot be fixed without breaking userspace api. > > > > > > > > Argueably the vfio code is still racy, but that's kinda a bigger > > > > > > vfio and kvm > > > > Hm I thought kvm is non-racy due to the mmu notifier catch races? > > No, but the plan is indeed to have some struct for each page that uses > follow_pfn and update it from the MMU notifiers. Thanks for clarifying, I've fixed the commit message to mention both vfio and kvm as Jason suggested. I didn't know that the follow_pte usage in kvm still has some gaps wrt what's invalidated with mmu notifiers. Thanks, Daniel > > Paolo > > > > > > > > picture. But since it does leak the pte beyond where it drops the pt > > > > lock, without anything else like an mmu notifier guaranteeing > > > > coherence, the problem is at least clearly visible in the vfio code. > > > > So good enough with me. > > > > > > > > I've decided to keep the explanation that after dropping the pt lock > > > > you must have an mmu notifier if you keep using the pte somehow by > > > > adjusting it and moving it into the kerneldoc for the new follow_pte() > > > > function. > > > > > > > > Cc: 3pvd@google.com > > > > Cc: Jann Horn > > > > Cc: Paolo Bonzini > > > > Cc: Jason Gunthorpe > > > > Cc: Cornelia Huck > > > > Cc: Peter Xu > > > > Cc: Alex Williamson > > > > Cc: linux-mm@kvack.org > > > > Cc: linux-arm-kernel@lists.infradead.org > > > > Cc: linux-samsung-soc@vger.kernel.org > > > > Cc: linux-media@vger.kernel.org > > > > Cc: kvm@vger.kernel.org > > > > Signed-off-by: Daniel Vetter > > > > --- > > > > include/linux/mm.h | 2 -- > > > > mm/memory.c | 26 +++++--------------------- > > > > mm/nommu.c | 13 +------------ > > > > 3 files changed, 6 insertions(+), 35 deletions(-) > > > > > > Reviewed-by: Jason Gunthorpe > > > > Thanks for your r-b tags, I'll add them. > > -Daniel > > > > > > > > Jason > > > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch