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.9 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 92CD8C43461 for ; Thu, 17 Sep 2020 06:23:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1A03C2137B for ; Thu, 17 Sep 2020 06:23:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="VYwPjvy4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A03C2137B 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 5563E6B0037; Thu, 17 Sep 2020 02:23:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 50668900002; Thu, 17 Sep 2020 02:23:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F67A6B005A; Thu, 17 Sep 2020 02:23:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0006.hostedemail.com [216.40.44.6]) by kanga.kvack.org (Postfix) with ESMTP id 2A3536B0037 for ; Thu, 17 Sep 2020 02:23:33 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DC8D612FE for ; Thu, 17 Sep 2020 06:23:32 +0000 (UTC) X-FDA: 77271561864.10.burn68_0006a2227120 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id AD24216A0DE for ; Thu, 17 Sep 2020 06:23:32 +0000 (UTC) X-HE-Tag: burn68_0006a2227120 X-Filterd-Recvd-Size: 6357 Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Sep 2020 06:23:31 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id t76so1214541oif.7 for ; Wed, 16 Sep 2020 23:23:31 -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=t5xSYs5WyUHGoVugyXIsV4oBDVq0zP8fjjYyhPxmS5A=; b=VYwPjvy48TS158UnDBYgLFV8dLYTcm9kR1KQGEhIw/AOhPMVqcFjtf4qMuMDH5vVx+ FPsUGl1T9D37jThKoIE1tgSPSJrgXvgVwjl3/lAkLs4w0OqP0vq1bkZMABCQ9059UFw9 5vfWDwoa5rpsgJhfXrlf42ZrGwPdGMXJsMq00= 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=t5xSYs5WyUHGoVugyXIsV4oBDVq0zP8fjjYyhPxmS5A=; b=hvN/5hQRJlfk35tbomXM/4MaX+ePkBzTqktO2fCwl416FwhaU7ZK09pk7cZ+pUwXOs +jk6ibrT5/ntX8cSvE45HmvLbXzzcVe085LsnZMA6wziJN4eJ434sfMXTaQLgwwmNbtr 6RF/P+GgE8rXyuPi3QyATJJDYVz89Ft+Hd35n6MhjeQ0YXmQRUil0k5rEzlsA0gXS0zD fpOWb9tzWhtgA4wocRbugzatRvgA4denyl1j/ijDL3A8uoiYhsM98m8Cme4d3JYX04ia 1dj64bqMknK9HLQSeKRgMNHxjC1qTh5Fl/8rHMNkayALclVH3zsqDat7s4AeO+Eui86H s9Nw== X-Gm-Message-State: AOAM530b+A+Dm3+hSdZthaELsvsLJe1q1btEwkpusnAz+NclcRCcl+zH QRpnPlDlmGa6a4Tlo4y3ZylNp4qjeOFOy6lj6EwK7A== X-Google-Smtp-Source: ABdhPJzB3ReC52Ku2iqgR54KZacCgPTbpQb6FYFGgv4R5udMulfkKOhc4e2KvAwA9Q2qQA7f0ioN8nPBsAA6wdCsyJs= X-Received: by 2002:aca:6083:: with SMTP id u125mr5461400oib.14.1600323810870; Wed, 16 Sep 2020 23:23:30 -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> <20200916140710.GA8409@ziepe.ca> <8db2474f-ecb7-0e17-5f5b-145708fe44d5@amd.com> In-Reply-To: From: Daniel Vetter Date: Thu, 17 Sep 2020 08:23:19 +0200 Message-ID: Subject: Re: [Linaro-mm-sig] Changing vma->vm_file in dma_buf_mmap() To: =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: Linux MM , Linux Kernel Mailing List , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Jason Gunthorpe , Andrew Morton , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: AD24216A0DE X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 5:31 PM Christian K=C3=B6nig wrote: > > Am 16.09.20 um 17:24 schrieb Daniel Vetter: > > On Wed, Sep 16, 2020 at 4:14 PM Christian K=C3=B6nig > > wrote: > >> Am 16.09.20 um 16:07 schrieb Jason Gunthorpe: > >>> On Wed, Sep 16, 2020 at 11:53:59AM +0200, Daniel Vetter wrote: > >>> > >>>> But within the driver, we generally need thousands of these, and tha= t > >>>> tends to bring fd exhaustion problems with it. That's why all the pr= ivate > >>>> buffer objects which aren't shared with other process or other drive= rs are > >>>> handles only valid for a specific fd instance of the drm chardev (ea= ch > >>>> open gets their own namespace), and only for ioctls done on that cha= rdev. > >>>> And for mmap we assign fake (but unique across all open fd on it) of= fsets > >>>> within the overall chardev. Hence all the pgoff mangling and re-mang= ling. > >>> Are they still unique struct files? Just without a fdno? > >> Yes, exactly. > > Not entirely, since dma-buf happened after drm chardev, so for that > > historical reason the underlying struct file is shared, since it's the > > drm chardev. But since that's per-device we don't have a problem in > > practice with different vm_ops, since those are also per-device. But > > yeah we could fish out some entirely hidden per-object struct file if > > that's required for some mm internal reasons. > > Hui? Ok that is just the handling in i915, isn't it? > > As far as I know we create an unique struct file for each DMA-buf. Yes dma-buf, but that gets forwarded to the original drm chardev which originally exported the buffer. It's only there where the forwarding chain stops. The other thing is that iirc we have a singleton anon_inode behind all the dma-buf, so they'd share all the same address_space and so would all alias for unmap_mapping_range (I think at least). -Daniel > > Regards, > Christian. > > > > -Daniel > > > >>>> Hence why we'd like to be able to forward aliasing mappings and adju= st the > >>>> file and pgoff, while hopefully everything keeps working. I thought = this > >>>> would work, but Christian noticed it doesn't really. > >>> It seems reasonable to me that the dma buf should be the owner of the > >>> VMA, otherwise like you say, there is a big mess attaching the custom > >>> vma ops and what not to the proper dma buf. > >>> > >>> I don't see anything obviously against this in mmap_region() - why di= d > >>> Chritian notice it doesn't really work? > >> To clarify I think this might work. > >> > >> I just had the same "Is that legal?", "What about security?", etc.. > >> questions you raised as well. > >> > >> It seems like a source of trouble so I thought better ask somebody mor= e > >> familiar with that. > >> > >> Christian. > >> > >>> Jason > >> _______________________________________________ > >> dri-devel mailing list > >> dri-devel@lists.freedesktop.org > >> https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > > > --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch