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=-2.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham 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 0FC4AC282CE for ; Fri, 5 Apr 2019 18:06:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEE9C21852 for ; Fri, 5 Apr 2019 18:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554487579; bh=HK3C+WQAVoOovk03K17EVGE894FDOVP/NrAJyP885xg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=M6YbBLzQNNRgUH6E9WuYVzLEz6D19F2zSZGa7wt6GDUdYyD8Y4SgqbIBhe+oqtyWX NyZubrzSi0Mo9kVyTY1JFB1A8jevBvcNn6Rr9LuCJtwjYNxF06d/I84kURnBjU9J6/ uhOQYX2wnhD75/kjmt05rUsyrmDbKi2Sb7niCTAo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731542AbfDESGT (ORCPT ); Fri, 5 Apr 2019 14:06:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:49536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728683AbfDESGS (ORCPT ); Fri, 5 Apr 2019 14:06:18 -0400 Received: from localhost (unknown [69.71.4.100]) (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 A41142146F; Fri, 5 Apr 2019 18:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554487577; bh=HK3C+WQAVoOovk03K17EVGE894FDOVP/NrAJyP885xg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F8nWszjI7awFxRSTBbXrulQydNuEc5JnEQp1XJjzA/ZMndxtdqXdMifMZYxHW+tut Ytcy308xnFaZu6IABLQ0xW8xG++uE7gZK1wlfeXNqPSssAPpDAYeTgl+mRaTUsoyCT 7CzcrvfuOEwjOfRcaYHzdN9mHfOrSORMx5RZULIw= Date: Fri, 5 Apr 2019 13:06:15 -0500 From: Bjorn Helgaas To: John Garry Cc: Guenter Roeck , wangkefeng.wang@huawei.com, lorenzo.pieralisi@arm.com, arnd@arndb.de, rafael@kernel.org, linux-pci@vger.kernel.org, will.deacon@arm.com, linux-kernel@vger.kernel.org, linuxarm@huawei.com, andy.shevchenko@gmail.com, catalin.marinas@arm.com, bp@suse.de, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 3/4] lib: logic_pio: Reject accesses to unregistered CPU MMIO regions Message-ID: <20190405180615.GB109021@google.com> References: <1554393602-152448-1-git-send-email-john.garry@huawei.com> <1554393602-152448-4-git-send-email-john.garry@huawei.com> <20190404164130.GA12203@roeck-us.net> <24cc8006-0f0d-6b20-a466-e4a32a0bb656@huawei.com> <20190404174336.GA10404@roeck-us.net> <20190404185815.GA26522@google.com> <2d0f583a-cabe-df4e-ad89-c1800d9b4804@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2d0f583a-cabe-df4e-ad89-c1800d9b4804@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Fri, Apr 05, 2019 at 09:10:27AM +0100, John Garry wrote: > On 04/04/2019 19:58, Bjorn Helgaas wrote: > > On Thu, Apr 04, 2019 at 10:43:36AM -0700, Guenter Roeck wrote: > > > On Thu, Apr 04, 2019 at 05:52:35PM +0100, John Garry wrote: > > > > > > Note that the f71805f driver does not call > > > > > > request_{muxed_}region(), as it should. > > > > > > > > > ... which is the real problem, one that is not solved by this > > > > > patch. This may result in parallel and descructive accesses if > > > > > there is another device on the LPC bus, and another driver > > > > > accessing that device. Personally I'd rather have > > > > > request_muxed_region() added to the f71805f driver. > > > > > > > > Right, we should and will still fix f71805f. If you recall, I did > > > > have the f71805f fix in the v1 series, but you committed that it > > > > was orthogonal, so I decided to take it out of this work for now. > > > > > > > > And even if we fix up f71805f and other known drivers which don't > > > > call request_muxed_region(), we still need to police against these > > > > rogue accesses, which is what this patch attempts to do. > > > > > > > Do we ? I am personally not convinced that LPC accesses _have_ to > > > occur through PCI on any given system. > > > > On current systems, I suspect ISA/LPC devices are typically connected > > via a PCI-to-ISA/LPC bridge. But AFAIK there's no actual requirement > > for that bridge, and there certainly *were* systems with ISA devices > > but no PCI at all. > > > > IMO, if you want to build ISA drivers on your arch, you need to make > > sure the inb() probing done by those drivers works like it does on > > x86. If there's no device there, the inb() should return 0xff with no > > fuss and no crash. > > Right, and this is what I am attempting to do here. > > So today a call to request_muxed_region() can still succeed even if no IO > space mapped. > > As such, even well-behaved drivers like f71882fg can still crash the system, > as noted in RFC patch 1/4 ("resource: Request IO port regions from children > of ioport_resource"). Maybe I'm missing something, but on x86, drivers like f71882fg do not crash the system because inb() *never* causes a crash. If you want to build that driver for ARM, I think you need to make sure that inb() on ARM also *never* causes a crash. I don't think changing f71882fg and all the similar drivers is the right answer. Bjorn 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=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable 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 817ECC282CE for ; Fri, 5 Apr 2019 18:06:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 51EFD2171F for ; Fri, 5 Apr 2019 18:06:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="g0OImttN"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="F8nWszjI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51EFD2171F 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+infradead-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=bombadil.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:References: 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: List-Owner; bh=NwCi9uziSBPvBZOGZwhC2EtZZrha5osI4JxACklSiXs=; b=g0OImttNieXACJ nNtCt7cF1PCm8knJMjqr94uV9Yk3I8dz4FW1MdFHJNKwyWhvl1dgOpXiqV2UWsKPgp7gPSgYof5P3 nSm/iz7PebLXu01TgkDYbGMUE3BAut3ID5LecepSzPXEcsn1y5tanaQlOkqyARJ/E9QOglEHdYIOB kYMdGCjvKo+P1C0urRSQ5D9K3duUsqxGaO+geMjhlNhhQ6agJXIfmBTYUMX8eRLcS23ClvcKGIF0h RJ8eziLjaO2rWIdgIivNEiwRvscy14zV+AhJ6QylcjULyd5FrsRPsxoB+OC/v9e30xTW1Ke4W8sZO staBiwODzcv8fRtUpfjQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hCTEM-0003om-DP; Fri, 05 Apr 2019 18:06:22 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hCTEJ-0003o6-SN for linux-arm-kernel@lists.infradead.org; Fri, 05 Apr 2019 18:06:21 +0000 Received: from localhost (unknown [69.71.4.100]) (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 A41142146F; Fri, 5 Apr 2019 18:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554487577; bh=HK3C+WQAVoOovk03K17EVGE894FDOVP/NrAJyP885xg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F8nWszjI7awFxRSTBbXrulQydNuEc5JnEQp1XJjzA/ZMndxtdqXdMifMZYxHW+tut Ytcy308xnFaZu6IABLQ0xW8xG++uE7gZK1wlfeXNqPSssAPpDAYeTgl+mRaTUsoyCT 7CzcrvfuOEwjOfRcaYHzdN9mHfOrSORMx5RZULIw= Date: Fri, 5 Apr 2019 13:06:15 -0500 From: Bjorn Helgaas To: John Garry Subject: Re: [PATCH v3 3/4] lib: logic_pio: Reject accesses to unregistered CPU MMIO regions Message-ID: <20190405180615.GB109021@google.com> References: <1554393602-152448-1-git-send-email-john.garry@huawei.com> <1554393602-152448-4-git-send-email-john.garry@huawei.com> <20190404164130.GA12203@roeck-us.net> <24cc8006-0f0d-6b20-a466-e4a32a0bb656@huawei.com> <20190404174336.GA10404@roeck-us.net> <20190404185815.GA26522@google.com> <2d0f583a-cabe-df4e-ad89-c1800d9b4804@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2d0f583a-cabe-df4e-ad89-c1800d9b4804@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190405_110619_954162_714980BF X-CRM114-Status: GOOD ( 21.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wangkefeng.wang@huawei.com, lorenzo.pieralisi@arm.com, arnd@arndb.de, rafael@kernel.org, linux-pci@vger.kernel.org, will.deacon@arm.com, linux-kernel@vger.kernel.org, linuxarm@huawei.com, andy.shevchenko@gmail.com, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, bp@suse.de, Guenter Roeck Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 05, 2019 at 09:10:27AM +0100, John Garry wrote: > On 04/04/2019 19:58, Bjorn Helgaas wrote: > > On Thu, Apr 04, 2019 at 10:43:36AM -0700, Guenter Roeck wrote: > > > On Thu, Apr 04, 2019 at 05:52:35PM +0100, John Garry wrote: > > > > > > Note that the f71805f driver does not call > > > > > > request_{muxed_}region(), as it should. > > > > > > > > > ... which is the real problem, one that is not solved by this > > > > > patch. This may result in parallel and descructive accesses if > > > > > there is another device on the LPC bus, and another driver > > > > > accessing that device. Personally I'd rather have > > > > > request_muxed_region() added to the f71805f driver. > > > > > > > > Right, we should and will still fix f71805f. If you recall, I did > > > > have the f71805f fix in the v1 series, but you committed that it > > > > was orthogonal, so I decided to take it out of this work for now. > > > > > > > > And even if we fix up f71805f and other known drivers which don't > > > > call request_muxed_region(), we still need to police against these > > > > rogue accesses, which is what this patch attempts to do. > > > > > > > Do we ? I am personally not convinced that LPC accesses _have_ to > > > occur through PCI on any given system. > > > > On current systems, I suspect ISA/LPC devices are typically connected > > via a PCI-to-ISA/LPC bridge. But AFAIK there's no actual requirement > > for that bridge, and there certainly *were* systems with ISA devices > > but no PCI at all. > > > > IMO, if you want to build ISA drivers on your arch, you need to make > > sure the inb() probing done by those drivers works like it does on > > x86. If there's no device there, the inb() should return 0xff with no > > fuss and no crash. > > Right, and this is what I am attempting to do here. > > So today a call to request_muxed_region() can still succeed even if no IO > space mapped. > > As such, even well-behaved drivers like f71882fg can still crash the system, > as noted in RFC patch 1/4 ("resource: Request IO port regions from children > of ioport_resource"). Maybe I'm missing something, but on x86, drivers like f71882fg do not crash the system because inb() *never* causes a crash. If you want to build that driver for ARM, I think you need to make sure that inb() on ARM also *never* causes a crash. I don't think changing f71882fg and all the similar drivers is the right answer. Bjorn _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel