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=-4.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 85182C4363C for ; Wed, 7 Oct 2020 18:43:22 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F323A2173E for ; Wed, 7 Oct 2020 18:43:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wdk8jM0h"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="fvTSDoaS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F323A2173E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID:Subject:To:From: Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References:List-Owner; bh=MFAuQl3XN/7xt+mFbj16KHp3sRsk+g/toYOif+tNpHc=; b=wdk8jM0hC/913dBKqVra1aPtA s12HJzfBD+Jju3bFGAjLeHU9UT5QtH+wCdm/KTGXNAz8LALBz2hPNJpGvGelTenRg6PlKK9uoC3VA vJpfOegZDxBCZ+m/wNvWnQsMVms1rHHNekR6n3zeMKSv9DtChRlBPsSr+5iQOpCyuOAdF6m4QNRSx XNvkPZl7gRFfQFuiOh3sIh8xmPP9lvPqDI1dWla/5B1KiGZ0DPwcjN1vmQ9BIasNHhYKLLQkUThYx 114fmEw/dKzUSJF8SwHubkDrJ8B2iH1bdn+8J98rnXFKEicJM5jjTQ96UJhsJ6cW54jqKrEzO+18z /3eQUknZQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQENf-0006pi-0j; Wed, 07 Oct 2020 18:41:39 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQENc-0006oF-9B for linux-arm-kernel@lists.infradead.org; Wed, 07 Oct 2020 18:41:37 +0000 Received: from localhost (170.sub-72-107-125.myvzw.com [72.107.125.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7E5DE2168B; Wed, 7 Oct 2020 18:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602096093; bh=jybj9lxB9HDSUiFTDfX0tbqIYHCI2WD8V2Srcj/Y2q0=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=fvTSDoaSFaR5f+GW+1VfPgc/eLGyZstXFPM0Pbbd72KBA+ecoTEtBddTdYZhtlYj3 bsFSSKkvJi72PjhGp9tmM7ZEtUUSjRP9PU6yME2u3FWvCct89TVsvj/po3TnsMWfeR J1+3vx2h0ip+tE/J1MK3LQud3yRzf+O7RxgCuZrk= Date: Wed, 7 Oct 2020 13:41:31 -0500 From: Bjorn Helgaas To: Daniel Vetter Subject: Re: [PATCH 10/13] PCI: revoke mappings like devmem Message-ID: <20201007184131.GA3259154@bjorn-Precision-5520> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201007164426.1812530-11-daniel.vetter@ffwll.ch> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201007_144136_487212_ACF6D089 X-CRM114-Status: GOOD ( 24.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-s390@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Jan Kara , Kees Cook , kvm@vger.kernel.org, Jason Gunthorpe , John Hubbard , LKML , DRI Development , linux-mm@kvack.org, =?iso-8859-1?B?Suly9G1l?= Glisse , linux-pci@vger.kernel.org, Bjorn Helgaas , Daniel Vetter , Dan Williams , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Capitalize subject, like other patches in this series and previous drivers/pci history. On Wed, Oct 07, 2020 at 06:44:23PM +0200, Daniel Vetter wrote: > Since 3234ac664a87 ("/dev/mem: Revoke mappings when a driver claims > the region") /dev/kmem zaps ptes when the kernel requests exclusive > acccess to an iomem region. And with CONFIG_IO_STRICT_DEVMEM, this is > the default for all driver uses. > > Except there's two more ways to access pci bars: sysfs and proc mmap > support. Let's plug that hole. s/pci/PCI/ in commit logs and comments. > For revoke_devmem() to work we need to link our vma into the same > address_space, with consistent vma->vm_pgoff. ->pgoff is already > adjusted, because that's how (io_)remap_pfn_range works, but for the > mapping we need to adjust vma->vm_file->f_mapping. Usually that's done > at ->open time, but that's a bit tricky here with all the entry points > and arch code. So instead create a fake file and adjust vma->vm_file. > > Note this only works for ARCH_GENERIC_PCI_MMAP_RESOURCE. But that > seems to be a subset of architectures support STRICT_DEVMEM, so we > should be good. > > The only difference in access checks left is that sysfs pci mmap does > not check for CAP_RAWIO. But I think that makes some sense compared to > /dev/mem and proc, where one file gives you access to everything and > no ownership applies. > --- a/drivers/char/mem.c > +++ b/drivers/char/mem.c > @@ -810,6 +810,7 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig) > } > > static struct inode *devmem_inode; > +static struct vfsmount *devmem_vfs_mount; > > #ifdef CONFIG_IO_STRICT_DEVMEM > void revoke_devmem(struct resource *res) > @@ -843,6 +844,20 @@ void revoke_devmem(struct resource *res) > > unmap_mapping_range(inode->i_mapping, res->start, resource_size(res), 1); > } > + > +struct file *devmem_getfile(void) > +{ > + struct file *file; > + > + file = alloc_file_pseudo(devmem_inode, devmem_vfs_mount, "devmem", > + O_RDWR, &kmem_fops); > + if (IS_ERR(file)) > + return NULL; > + > + file->f_mapping = devmem_indoe->i_mapping; "devmem_indoe"? Obviously not compiled, I guess? > --- a/include/linux/ioport.h > +++ b/include/linux/ioport.h > @@ -304,8 +304,10 @@ struct resource *request_free_mem_region(struct resource *base, > > #ifdef CONFIG_IO_STRICT_DEVMEM > void revoke_devmem(struct resource *res); > +struct file *devm_getfile(void); > #else > static inline void revoke_devmem(struct resource *res) { }; > +static inline struct file *devmem_getfile(void) { return NULL; }; I guess these names are supposed to match? > #endif > > #endif /* __ASSEMBLY__ */ > -- > 2.28.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel