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 AF969C433E2 for ; Wed, 16 Sep 2020 12:42:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7394222264 for ; Wed, 16 Sep 2020 12:42:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="Lu3BjPbR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7394222264 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 BF2A66B0037; Wed, 16 Sep 2020 08:42:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B7BC16B0055; Wed, 16 Sep 2020 08:42:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A43966B005A; Wed, 16 Sep 2020 08:42:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0140.hostedemail.com [216.40.44.140]) by kanga.kvack.org (Postfix) with ESMTP id 8ACE46B0037 for ; Wed, 16 Sep 2020 08:42:04 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 45EBB8249980 for ; Wed, 16 Sep 2020 12:42:04 +0000 (UTC) X-FDA: 77268886968.28.party59_02115622711a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id F3A1E6C04 for ; Wed, 16 Sep 2020 12:42:03 +0000 (UTC) X-HE-Tag: party59_02115622711a X-Filterd-Recvd-Size: 4763 Received: from mail-oi1-f195.google.com (mail-oi1-f195.google.com [209.85.167.195]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Sep 2020 12:42:03 +0000 (UTC) Received: by mail-oi1-f195.google.com with SMTP id a3so7951973oib.4 for ; Wed, 16 Sep 2020 05:42:02 -0700 (PDT) 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:content-transfer-encoding; bh=czd653EAQqRd9y6KWSclqvh0oWs0wM7+eL3iGSU/nsI=; b=Lu3BjPbRiC/AX011FfwezqvylAv3ZKt1PhgO2s9ivkaAdFT+L+aU0tlTbH9aGB3QdD ZRH99A3CPlO3UqmOgNoRm+sYa3H4f9liy9wkSbTEbzeH6grEkhQUdoV/KEkl0b+7g6Fl aZYv0CeL8ooRR1NM3VZWi8l0zPzoTUe7oUQL4= 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:content-transfer-encoding; bh=czd653EAQqRd9y6KWSclqvh0oWs0wM7+eL3iGSU/nsI=; b=qh656eeC19rs6u2O85mLE/u1zQSsyavz2COVcgl7iQ2Zid+p0PXZY9EXTBEC5bPiyV 1wBcBdIpcq5CTC6WMqZNsXPTiGQtEVWkUbP3aTvr2nViUNqu3mXPnsyyPrvxBL8CbxEQ l4IdzR8DRivp7qK02BfEaF+Gpt7PyFPctYmwfWQ91iLQODL3GCWHIDWPhc+ZwFN1YZBj 8bBVo0CmE9psrh1Tc8EH5JHyMAr8+VJKxGqIDd2FAVfHlFu5CFcvlWdy8v3Bh84OGL0x KYEMA7VG4VWNRGld+5QXCS7rRS8O8Qss7Y2pfVk4scSzucOtoYU4VcoUqzC0MKDsfU8k iBMA== X-Gm-Message-State: AOAM530ugVocJD88SLKJ/gN54o5gWcA4yMjlmi0w5Y+PJrbTGDRz+bZV EBc4SepLoSXAWdi9AK8buLnU2zAn1Mu101GXwNoJ4w== X-Google-Smtp-Source: ABdhPJwB+2iScSnSRjswx0wBN3crEjmROMPJs/KcyWAFLMOIPP9Nlf6b8MzVFM61WOlkTuWWi8Wacl+i3PJJq3k7BoM= X-Received: by 2002:aca:6083:: with SMTP id u125mr3033440oib.14.1600260122457; Wed, 16 Sep 2020 05:42:02 -0700 (PDT) MIME-Version: 1.0 References: <20200914132920.59183-1-christian.koenig@amd.com> <40cd26ae-b855-4627-5a13-4dcea5d622f6@gmail.com> <20200914140632.GD1221970@ziepe.ca> <9302e4e0-0ff0-8b00-ada1-85feefb49e88@gmail.com> <20200916095359.GD438822@phenom.ffwll.local> In-Reply-To: From: Daniel Vetter Date: Wed, 16 Sep 2020 14:41:51 +0200 Message-ID: Subject: Re: Changing vma->vm_file in dma_buf_mmap() To: =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: Jason Gunthorpe , Andrew Morton , Sumit Semwal , "open list:DMA BUFFER SHARING FRAMEWORK" , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Linux Kernel Mailing List , Linux MM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: F3A1E6C04 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 Wed, Sep 16, 2020 at 1:45 PM Christian K=C3=B6nig wrote: > > [SNIP] > > But Jason pointed me to the right piece of code. See this comment in in m= map_region(): > > /* ->mmap() can change vma->vm_file, but must guarantee that > * vma_link() below can deny write-access if VM_DENYWRITE is set > * and map writably if VM_SHARED is set. This usually means the > * new file must not have been exposed to user-space, yet. > */ > vma->vm_file =3D get_file(file); > error =3D call_mmap(file, vma); > > > So changing vma->vm_file is allowed at least under certain circumstances. > > Only the "file must not have been exposed to user-space, yet" part still = needs double checking. Currently working on that. > > > Ok, I think we can guarantee for all DMA-bufs what is required here. > > While searching the code I've found that at least vgem_prime_mmap() and i= 915_gem_dmabuf_mmap() are doing the same thing of modifying vma->vm_file. > > So I'm leaning towards that this works as expected and we should just doc= ument this properly. > > Daniel and Jason what do you think? Well I can claim I started this, so I started out with naively assuming that it Just Works :-) I think we already have vgem/i915 prime testcases in igt which try to excercise this mmap forwarding, including provoking pte shoot-downs. So I think best would be if you could also add a variant for amdgpu, to make sure this really works and keeps working. Plus ofc the documentation patch so that core mm folks can officially ack this as legit. -Daniel --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch