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 09DBBC5DF9D for ; Wed, 21 Oct 2020 19:24:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2D7262416E for ; Wed, 21 Oct 2020 19:24:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="UcRTFA71" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D7262416E 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 6C3F06B0062; Wed, 21 Oct 2020 15:24:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69AA56B0068; Wed, 21 Oct 2020 15:24:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B2CC6B006C; Wed, 21 Oct 2020 15:24:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 2D9A06B0062 for ; Wed, 21 Oct 2020 15:24:22 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BA828180AD811 for ; Wed, 21 Oct 2020 19:24:21 +0000 (UTC) X-FDA: 77396908722.10.swim46_4416df02724a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 8ABAE16A4B0 for ; Wed, 21 Oct 2020 19:24:21 +0000 (UTC) X-HE-Tag: swim46_4416df02724a X-Filterd-Recvd-Size: 4825 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Wed, 21 Oct 2020 19:24:20 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id e20so2877832otj.11 for ; Wed, 21 Oct 2020 12:24:20 -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=sYM9cUyMSOj9mKCWCe707+J8b20m45BOShUil5OYiuY=; b=UcRTFA71oa+ZohVvqr5nTk2VrlQIDJZuL8YbFFB6slZWA8umJ/bN/qbSbMlqTB7z0q bIxgy64Kmi9zqOgOlY5HP3Sd823hLvIZ4IY3eeEDdvu0znOIz4Dey+GMkJlQfrWVVWss 6QNEH9JVNXJd4SlM1j+HDRzTJLUTR8870k28s= 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=sYM9cUyMSOj9mKCWCe707+J8b20m45BOShUil5OYiuY=; b=M7XQWoX7dtc8NG4jlrV5jY6v8qFW95YYl0rO63NHo9wBGx32kuZNr8wD59tiBsj+N4 86pAgzb+Ck7z5vSshU1gfbWC+JureuD9oc+vLcAz7ZdShLx/ZlVxJTLdAzGDBpeoaVt4 fXGDU/5Y7+lJAkE/TCQxLvPIU02SmYTuc5qa/Iy1aKp8qGhW+Tzhpm7qfs6ykbd6rKlc XuxFQf0JC+KArCHc43yGjy7ezGHqG7W9bmSvrAqG5Ddf1eN5CCpZsAbEWcfeMASHLYvb x3H6CbSQmrWjQPHiPNghs0XRWA3RinwbGHy1hADMTjzSwKpeNHi+J6oR3F4Q/qMLUnVl Z6xg== X-Gm-Message-State: AOAM530jdJRqH3/WZoYQtUTGvNQa3fRuDvFSJPDxSCM2ayCjIXFPlHPF QAwR/BWygb/SzisJMZg2nyY2MnXkHgG93pHDBwGfbQ== X-Google-Smtp-Source: ABdhPJwJGiQE46eBJclvgjHXJJ+j87WJ+7cjHqpCSH7v0fZi8HkcRkC+gln/SdoBFVWEgA88/UYBf7mOSQSqgr0L7bk= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr3877970otr.281.1603308259478; Wed, 21 Oct 2020 12:24:19 -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> In-Reply-To: <20201021163702.GM36674@ziepe.ca> From: Daniel Vetter Date: Wed, 21 Oct 2020 21:24:08 +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" 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, 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. > > I guess one option would be if remap_pfn_range would steal the > > vma->vm_ops pointer for itself, then it could set up the correct > > ->install_ptes hook. But there's tons of callers for that, so not sure > > that's a bright idea. > > The caller has to check that the mapping is still live, and I think > hold a lock across the remap? Auto-defering it doesn't seem feasible. Right auto-defering reopens the race, so making this work automatically is a bit much. I guess just splitting this into a setup/install part and then doing the install of all the ptes at first fault should be good enough. We don't really need a new install_pages for that, just an io_remap_pfn_range that's split in two parts. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch