Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5655620pxu; Thu, 22 Oct 2020 07:56:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7WMQOZDxVp+35LCSHY1ughJ1VZWjGgLZTtGSeVK1wXXK7npZzrLdHIiehUsIMiPoojOHa X-Received: by 2002:a17:906:1643:: with SMTP id n3mr2571845ejd.459.1603378607064; Thu, 22 Oct 2020 07:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603378607; cv=none; d=google.com; s=arc-20160816; b=l7uniEH2GdAQp9jChF4Iqf3EfJdV3QvfApt3QrmAQsoMdpEFncZzsYKUJ2lPciTTDE /XOUUQRqAsFGbiDPidYAA2Zb10NkVOGCOjUfkWDXaKqZSKKusJx7N6uDkQ+rR7n9BZgH jAbqF/k94FBUp59N3GpDQUTGxKykRtm1UneCrq6DQ2ex8l2iOjjULZ9he4hCg9kQW7mB pp3DCCLpuJwUVNzYaPpJbD0blZI7wfxSTHJCI1TL16eJG9y6nAgzou72lIS5ckTVruKJ sW+0heHMQ9gmYiiukPbETHmKWM7s6n1aK5OBIyG4uCnNAzAQ1lsWhFpHQAfPHmmNJASp o+qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2r/6zOf2kRDD4tSmvaZuCPU8DwfuIowf0YjaeLwP4Nk=; b=LMfe0Lc0hzVEkIQGN9rjt663jiiID1jo/BXuOXWf46R+wVRstCF+rVcsaetF/0DwTh 9Pv/Bz2FXtd/4kTj5kOP6Ey0g5wEeW8UQK/Ph+1Tvv/QIqSId99vuM9APIoVLNr0QT4t /FYc7bC7w7HMUuF+dC/oyi6NdrI0r42SD1DsMFUBVkcxoFxDfmjMGQXC4znqNMQUxGL2 nZx/jiQtZIKuYBGnQpMhprXGVkfsiovnzjxSZfQDkB/P5RTen+Gax3koveO7/PSXsBBU HOiKiP58f9/DE1TjRODD+YfSncKGPTzWZE9RTwmDG1qyzd0qo7yrrTZI3RwLXqUSLJvQ poVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=et6ZBeQF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t17si971238eje.331.2020.10.22.07.56.24; Thu, 22 Oct 2020 07:56:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=et6ZBeQF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504737AbgJVHA4 (ORCPT + 99 others); Thu, 22 Oct 2020 03:00:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504736AbgJVHA4 (ORCPT ); Thu, 22 Oct 2020 03:00:56 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 214FEC0613D2 for ; Thu, 22 Oct 2020 00:00:56 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id u127so688859oib.6 for ; Thu, 22 Oct 2020 00:00:56 -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; bh=2r/6zOf2kRDD4tSmvaZuCPU8DwfuIowf0YjaeLwP4Nk=; b=et6ZBeQFHerVGVhgtgtRrYMM/XKZjx8P9HBSzQAYN1qwBLnRqWCR1692Hd2N6mG2QH DRodjxUs0g/udks4HbxzEysdS3iPEQ/WX4sYQzu415V2h1QQT1XnQSq/3dWFguLdKkzI zrJA18zci4a+rkwc8KCUbQtvVEViy3ghNPANM= 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=2r/6zOf2kRDD4tSmvaZuCPU8DwfuIowf0YjaeLwP4Nk=; b=hY4vEgpYVKkWeudUmZKcJo6NH7IqNgR1Jfsdar8iCTjJ7gXUPapme9czeXa/khkJe0 D66SZISY2v/MjLYed1XW07m1rPd60HK8PK2Ds6xuQYq0F7fA9DccwcElq+RDS2413HOI BBtQ18iqLOcASzmlcB4wxRJhIo+REWwnZaZWJygDBsXAv8WugRYf8PloUPcr3bqevAXO M0IMVtTCQfIlmyWaUbh9x/p05gJ3XWWYDCga8huJvd7tn6aT/jkD8WglTykPDif1sOys 92TTM/PpdGSX0EdhQZ1RCiwXeJzNaqRV7MZpDhQwKiYvtzUoPNJuAcX3Ln2EQTJD4Px9 Cv/w== X-Gm-Message-State: AOAM531Y3YJ8Un6X/pz0EN9Ys66pCSkz9gDFCZzDn+ThDKz4LOf/ICLl WYYQlRlD3UTdL+nMuDwQU+cvRv3FoUiViYzkACWTWg== X-Received: by 2002:aca:cc01:: with SMTP id c1mr631463oig.128.1603350055185; Thu, 22 Oct 2020 00:00:55 -0700 (PDT) MIME-Version: 1.0 References: <20201021085655.1192025-1-daniel.vetter@ffwll.ch> <20201021085655.1192025-13-daniel.vetter@ffwll.ch> <20201021125030.GK36674@ziepe.ca> <20201021151352.GL36674@ziepe.ca> <20201021163702.GM36674@ziepe.ca> <20201021232022.GN36674@ziepe.ca> In-Reply-To: <20201021232022.GN36674@ziepe.ca> From: Daniel Vetter Date: Thu, 22 Oct 2020 09:00:44 +0200 Message-ID: Subject: Re: [PATCH v3 12/16] PCI: Obey iomem restrictions for procfs mmap To: Jason Gunthorpe Cc: DRI Development , LKML , KVM list , Linux MM , Linux ARM , linux-samsung-soc , "open list:DMA BUFFER SHARING FRAMEWORK" , linux-s390 , Daniel Vetter , Kees Cook , Dan Williams , Andrew Morton , John Hubbard , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jan Kara , Bjorn Helgaas , Linux PCI , Daniel Vetter Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 22, 2020 at 1:20 AM Jason Gunthorpe wrote: > > On Wed, Oct 21, 2020 at 09:24:08PM +0200, Daniel Vetter wrote: > > On Wed, Oct 21, 2020 at 6:37 PM Jason Gunthorpe wrote: > > > > > > On Wed, Oct 21, 2020 at 05:54:54PM +0200, Daniel Vetter wrote: > > > > > > > The trouble is that io_remap_pfn adjust vma->pgoff, so we'd need to > > > > split that. So ideally ->mmap would never set up any ptes. > > > > > > /dev/mem makes pgoff == pfn so it doesn't get changed by remap. > > > > > > pgoff doesn't get touched for MAP_SHARED either, so there are other > > > users that could work like this - eg anyone mmaping IO memory is > > > probably OK. > > > > I was more generally thinking for io_remap_pfn_users because of the > > mkwrite use-case we might have in fbdev emulation in drm. > > You have a use case for MAP_PRIVATE and io_remap_pfn_range()?? Uh no :-) But for ioremaps and keep track of which pages userspace has touched. Problem is that there's many displays where you need to explicitly upload the data, and in drm we have ioctl calls for that. fbdev mmap assumes this just magically happens. So you need to keep track of write faults, launch a delayed worker which first re-protects all ptes and then uploads the dirty pages. And ideally we wouldn't have to implement this everywhere just for fbdev, but could wrap it around an existing mmap implementation by just intercepting mkwrite. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch