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.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 3A23CC43460 for ; Thu, 8 Apr 2021 11:41:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D593861151 for ; Thu, 8 Apr 2021 11:41:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D593861151 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 48A0D6B0078; Thu, 8 Apr 2021 07:41:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43A946B007E; Thu, 8 Apr 2021 07:41:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B3986B0080; Thu, 8 Apr 2021 07:41:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 0E9C86B0078 for ; Thu, 8 Apr 2021 07:41:05 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B56E01830BB1D for ; Thu, 8 Apr 2021 11:41:04 +0000 (UTC) X-FDA: 78009008448.35.647353B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 68E3EC0007C6 for ; Thu, 8 Apr 2021 11:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617882063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s9XSwEEi1zJXTpbPUBOMu9HhV0dFlRjs6EwHYbE6+e4=; b=BCqGMbJOfrjxEXjDu0AmwJDqVN1hDW8OvOjjCRNYXhMvLGE1yEFFfOo1BfJNp8NQdCY9uv Fd5Lz11RVCjX3uZZkkrOtfjOPIKnAFGuJ0UFudoxphsoYzKlXQZll4PWvYXfWi8b98WRHQ LikfUekwF6sExdN/PxLALQuUr73igqg= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-256-C22vKiUBMTOt42EW7MjdqQ-1; Thu, 08 Apr 2021 07:41:02 -0400 X-MC-Unique: C22vKiUBMTOt42EW7MjdqQ-1 Received: by mail-ej1-f70.google.com with SMTP id o11so712514ejx.23 for ; Thu, 08 Apr 2021 04:41:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=s9XSwEEi1zJXTpbPUBOMu9HhV0dFlRjs6EwHYbE6+e4=; b=D0v+MKuwfij/4SqCAXxTYhkBGLamYEkdr1WZFSlT053ebmF+3sTgVt1s4iGQ31XNif +PMtcFKGDqe8FsmHDDpdFAiYrjTDhtUC2g8K+5Bta1DydZfOVLgnmbvJe9U30fRZ9i7x As4yvmFUIR5xnMDQihY/vev+1XZOYxTM41LqR2mIhs1D8YQzZbCe55I0xKq5U+XckHbg AiC7qnEPkmaBlzGYsfwzJXz57c4ocuYsXB1GP0FPnokI5ac47Yi/ua4OiOCcAYhSCZ5N lmCmbNdOz5VgD+BmuxVyNTA652NMrJjR+BUm7E0i3yaXhL1z0nG2PaG+0BD48RmBZkJR Tv6Q== X-Gm-Message-State: AOAM530ztnfem/sTK8VKqDSy12uI8RipBkpJccpdZBKEyfJ8n9oRR0nn nS3ogVNNVMU1TO7DDsec2uQ98XZ7/Ezf52Qxju0r6V6kK0ewWOeUJr3OJFqcZMDYPjRYLIe4D7Z bb7geX6jJ8o4= X-Received: by 2002:aa7:cf90:: with SMTP id z16mr10682032edx.273.1617882060792; Thu, 08 Apr 2021 04:41:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUNwVjPU6LZkoTiJz3z03af3SU7UKs6cSUJv0KPBteAvMvZy2H6osTmzxUIJoPNr0/d/3eYQ== X-Received: by 2002:aa7:cf90:: with SMTP id z16mr10682002edx.273.1617882060615; Thu, 08 Apr 2021 04:41:00 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id t1sm4680038eds.53.2021.04.08.04.40.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Apr 2021 04:41:00 -0700 (PDT) To: 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> From: Paolo Bonzini Subject: Re: [PATCH 3/3] mm: unexport follow_pfn Message-ID: <5f956a46-da38-e72a-edaa-3b746a275f1e@redhat.com> Date: Thu, 8 Apr 2021 13:40:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 68E3EC0007C6 X-Stat-Signature: uhe73xwbtwbyhpc4xhiyzgckb6w6m5d9 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617882065-701306 Content-Transfer-Encoding: quoted-printable 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 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 >=20 > 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=20 follow_pfn and update it from the MMU notifiers. 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 >=20 > Thanks for your r-b tags, I'll add them. > -Daniel >=20 >> >> Jason >=20