Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1208181iob; Wed, 4 May 2022 17:30:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC0R298lw5UcIbd8gjt/30ORU5ceJE2SH8Ms6xTE5A7n0H3GjutvujMKWlHmObtu8nciHC X-Received: by 2002:a17:906:3e05:b0:6f3:a14a:fd3f with SMTP id k5-20020a1709063e0500b006f3a14afd3fmr22092584eji.640.1651710625493; Wed, 04 May 2022 17:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651710625; cv=none; d=google.com; s=arc-20160816; b=R78D1NVfQPfM17Noum4fYaMrqie26uDkgIFnagDHuOuAf4IfyaAz9xXzOafCgRJhVv WJlLzG1a9q0O9WsOneHJDkCat3Gyntn0ftxsw1cjVC4wjXs8vwZrehhJWS2d5RD0PVYM yjA0znOd3VZIboSeAZPiCHFf7F7bvtVdYjDbI3uSkNCZCHroUCbadn3XC4m3PXZ7j0CX Oz4WlnZHI6ZIQA7DqtEou3kKRyFNvbDAwUzaOrbGr8jtqSybuEIvJU6oVpfK2SWTyj7K 82Td2j5m9NL0vdwqTYyaPeM3h2m6l+iIoNmZDkOJj3gWVSCSBJ67tLt6fOQ7MYP6fkKk QOMQ== 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=qnHLNTTj0qbWKUA576qFTiqmPnSGu4b5UIjBEb2fMYw=; b=vj8OHUeuFiSzLNw3aKoQDqzrBzP1BAIZNJdvPVtDPn524Wivy1cnRFpqSSQyHQXcmL mqRT+wbnHG3RFFqOItUCSkXe1wsi5Im7FdWJenoqBGgfWnmJtLAC0yM+PiFBDbsiT4Ha SVp04tJbii1XHealpFDUJWFbWxr0oZezHskOivMiqAugKJnhP55lRWn9CDGejJtrcv0L Jysvuv1NIM584u4KX/JeZu9ioZSUO7cwCmPQBzpP0POaflj8+yvPUxN8jM3IPzDomNOC BT2c3qxxSLJL66wIxSD6cU1iB0zS7cgHCoWCi4DOpNu+iJWQYWULTEI+1bakFFjhSnYU 0HvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=psHr6IyS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a170906501000b006f4a3a09585si417909ejj.782.2022.05.04.17.30.02; Wed, 04 May 2022 17:30:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=psHr6IyS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378601AbiEDVf2 (ORCPT + 99 others); Wed, 4 May 2022 17:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347126AbiEDVf0 (ORCPT ); Wed, 4 May 2022 17:35:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BFB84838E; Wed, 4 May 2022 14:31:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CAD48B829E8; Wed, 4 May 2022 21:31:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80D62C385BF; Wed, 4 May 2022 21:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651699906; bh=zFvzT8pCm+1ful8W/hZ4LOb35c/AZPHiTAR5f5uq/tc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=psHr6IyS0tCkPqNjtn0h6gBlwY40lOhbh/uw16bstSHWVYnmtHqEoZ532Dc9rtOal DUtXfgn3DdLZgWPENyY+MDgzz08W+auqjcYPklLCUJDhHdzEXeeuxWe7LpvbPQY9kJ FOxNi34XKyPTNO9nguLWvf12if7tv0axSjj5zB31OByn/knBsjbgNK9SEZoOb9mk2H 8Mi5Plsbv3ClcTw6udErx8u6A9v1Ng1bHEjpGoMpucB2QcZFN6TMAvSYQ6IMdui25o P6nUGl1dzSr93wmpQQ9rPDjMiV7wf6pGhiZS8ljqSo0VQ8Lm9E+/x0iZSoSI081EGu qotf+DUD3i/vA== Received: by mail-wr1-f51.google.com with SMTP id k2so3657498wrd.5; Wed, 04 May 2022 14:31:46 -0700 (PDT) X-Gm-Message-State: AOAM530m3z7+Lq1wthZl3Ou4DDusfe+YzKGwkK3E99iNDWFIQi4smzAh db83aG6SCEY16rFZw+Bo71+iWvSUabbsMWpWX3Y= X-Received: by 2002:adf:e106:0:b0:20a:b31b:213d with SMTP id t6-20020adfe106000000b0020ab31b213dmr17558428wrz.219.1651699904306; Wed, 04 May 2022 14:31:44 -0700 (PDT) MIME-Version: 1.0 References: <20220429135108.2781579-2-schnelle@linux.ibm.com> <20220504210840.GA469916@bhelgaas> In-Reply-To: <20220504210840.GA469916@bhelgaas> From: Arnd Bergmann Date: Wed, 4 May 2022 23:31:28 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC v2 01/39] Kconfig: introduce HAS_IOPORT option and select it as necessary To: Bjorn Helgaas Cc: Niklas Schnelle , Arnd Bergmann , Greg Kroah-Hartman , Linux Kernel Mailing List , linux-arch , linux-pci , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Michal Simek , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , "David S. Miller" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "open list:ALPHA PORT" , "moderated list:ARM PORT" , "open list:IA64 (Itanium) PLATFORM" , "open list:M68K ARCHITECTURE" , "open list:MIPS" , "open list:PARISC ARCHITECTURE" , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , "open list:RISC-V ARCHITECTURE" , "open list:SUPERH" , "open list:SPARC + UltraSPARC (sparc/sparc64)" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 4, 2022 at 11:08 PM Bjorn Helgaas wrote: > > On Fri, Apr 29, 2022 at 03:49:59PM +0200, Niklas Schnelle wrote: > > We introduce a new HAS_IOPORT Kconfig option to indicate support for > > I/O Port access. In a future patch HAS_IOPORT=n will disable compilation > > of the I/O accessor functions inb()/outb() and friends on architectures > > which can not meaningfully support legacy I/O spaces such as s390 or > > where such support is optional. > > So you plan to drop inb()/outb() on architectures where I/O port space > is optional? So even platforms that have I/O port space may not be > able to use it? > > This feels like a lot of work where the main benefit is to keep > Kconfig from offering drivers that aren't of interest on s390. > > Granted, there may be issues where inb()/outb() does the wrong thing > such as dereferencing null pointers when I/O port space isn't > implemented. I think that's a defect in inb()/outb() and could be > fixed there. The current implementation in asm-generic/io.h implements inb()/outb() using readb()/writeb() with a fixed architecture specific offset. There are three possible things that can happen here: a) there is a host bridge driver that maps its I/O ports to this window, and everything works b) the address range is reserved and accessible but no host bridge driver has mapped its registers there, so an access causes a page fault c) the architecture does not define an offset, and accessing low I/O ports ends up as a NULL pointer dereference The main goal is to avoid c), which is what happens on s390, but can also happen elsewhere. Catching b) would be nice as well, but is much harder to do from generic code as you'd need an architecture specific inline asm statement to insert a ex_table fixup, or a runtime conditional on each access. Arnd