Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5369266pxu; Wed, 21 Oct 2020 23:41:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwFpyWn3D6/2hFeL+5tSHII6/ulraa2RZsidSxdH6UbW5RXTYtcHn40GuhNsNYMdK2j2zE X-Received: by 2002:a17:906:5e4f:: with SMTP id b15mr897875eju.353.1603348897378; Wed, 21 Oct 2020 23:41:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603348897; cv=none; d=google.com; s=arc-20160816; b=WDy5K8ypQeP7Z/JPpP86J9y/avq7dUiXuQct/Y1sHv1p646SmhoresPTGaA18lMm2D UdMcZ4pl7bAFF0fs4VWUFyyW5bNP+Xap5XCQGXXJgOvRcvHmqaiblQkjtkns7L0xrVMd SswxiEJ8TknMmdgz9Yky6BYI+sPwJ/vS6YYvpSccS0zVCtG9pZ1tBoLreBPFvFq9p7hp 4SsRgS+Fc/fkcmZaQc2b2bC5D2wW7voDkqGMo5KeSjZmL3YNUKvPEDXlDFu/+QrNX0RW 2fdDvXnrzM5AsuebXFHbMBw2NlkmnEhawV5eQ1eXfZ7vb4d+Jdqpr6vhv6tmkqZf/c9O l73w== 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=sYM9cUyMSOj9mKCWCe707+J8b20m45BOShUil5OYiuY=; b=tyet+ZTwy+d/orB/KkmdGf9yx5kUcFbfoB7c3Xv2XdpxULirHmXuMOU2q+mh0DUFAG E8WVvZq3DFPgHxs++m0JkgSLsqHESvqIcqx+JsGlLrcFNI5q0FRd0RDEq4Tep7yx4tAQ vh1f/ouNdH7FzJZ51DZPApDRO7KuVB+hhF6eC7jaB09GkXr+f2QC83E9FZIJHy7PjLpd G+GvuXsgeHK/vTPw4FoD+qU65m2biuxnftrH5t5hn31mcmK1jsha+995YOep8KAsgNPq kNkCREkULIZaGI3YJWO5rMOZdeUK569lXVFQVywj6ZElh6UlaXOV0i8LHJZotDdWYd3F dmew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=UcRTFA71; 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 do2si384108ejc.215.2020.10.21.23.41.15; Wed, 21 Oct 2020 23:41:37 -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=UcRTFA71; 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 S2504910AbgJUTYU (ORCPT + 99 others); Wed, 21 Oct 2020 15:24:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441922AbgJUTYU (ORCPT ); Wed, 21 Oct 2020 15:24:20 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30912C0613D5 for ; Wed, 21 Oct 2020 12:24:20 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id n11so2914219ota.2 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=EuTyhWoyMwXOnz9K0lJxTszDTGMAWBY6T4+G9XYCowDmhYU2FSUUhX4RWFcfWg5old l8V8GcSuUjNbw9mYJF2OE6NmglxNlDDLp7TvncjzebefweX4oFqHWgce1/4paKszQg9o Huah8kSf7Ma3m5Klm13TtAvaqXrC3ExcyYPIcu1xKOviIUPLHsgGDlLHRMCk27sxRXwh Jk3bZVtIkwCAXJ3cVBNK1KuZppYjNkD/j8zM1agXBUKi+QbutuKSaC3HB84FMuVQefya c40aLiFgRiWKg0vww61ByfG1PC2EVYSddRR7f8AXallypeVcWemc8OHIWdqWbPm2dxKz 54Bg== X-Gm-Message-State: AOAM531iQkhrmeZS3qnFPIvCZjDcouJeVnDJXOXISN8wci2H0GNCw1BR ne0DhOmGOmUUm4PG9bNl1GoLrERPzEb9ofCGwiIeuQ== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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