Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4821744iob; Mon, 9 May 2022 02:24:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF2btCGLS6XKRjj1fgT+18dhxszuX9WIuC/Q0JGtr+O6+O7A2nnFAUsByP4ivv7azwdipU X-Received: by 2002:a17:90a:5515:b0:1dc:c1f1:59bd with SMTP id b21-20020a17090a551500b001dcc1f159bdmr21870767pji.81.1652088250572; Mon, 09 May 2022 02:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652088250; cv=none; d=google.com; s=arc-20160816; b=GmSkhPk9F/Rqt2zYdUrny8zMAK+HLIZbGZhVRiJ1oFolbBvq/wWqhuZn8SzBpfF6Le zFmhtzuSE0gUMCmSma3RJUto5MxExqTHy8fOtisIlR1WNPtGrJMD7NFKGx6ELMZbS+xD vrvKY6vTY3uHZi72F5Yzersqkg8Yhm5wutw+uBVdWac+xPG1Nl729St0a6RnJK9rpnLW GM0YJAQB7fGSWIN0tRsgy3jBjXCS0MjNLS+pFrwI31nZPIYnysSKrYOewnSfzHlBhcDg ero8D/icQpT9obXQDmp3rpxaEhkSP0nKXvOQ/OPY7EtpzNyrE7/nMJI4EdJxvG1WLA62 fOXA== 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=Y9ADhkSO4ZjPTZCZRSH0kD6cxgUgbSflVzbUODZ/Xlg=; b=AOJACjvqcilAprA8bo0tCIJ1ZRZynJpGwRSUYPsT7XCTGeJQ89bYz7ZtSH6wqS0pxG Vocwwi4a7YTTqdZwbvuUgyEWA+8WF0nyXMzXZ8JAQP8PH0VUVIKTsxQsZKQE8vCkANaE PDw3JaOwZXcP6rtrVy5vJqfUrdQmYtfXGOzZPbXJmOHiIYiOQ74Uv5UbfyW700OP/POv P05w5yG7w2UQ7WfYjb5V5WhTot5exNVrZi1fu63dphdAIj+EFgw/t8GYd+5wPFQ6odfA 0NWnPnd0MJMYzJvWXNupI6ItSaxuxgeumKhsvjbrTMH1DlsFm4EYESLNYPQFNEkVc1Qy DpdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NYZWIxr7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 3-20020aa79103000000b0050ad22888dasi12429662pfh.158.2022.05.09.02.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 02:24:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NYZWIxr7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD1AD20CA60; Mon, 9 May 2022 02:14:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446477AbiEGNS1 (ORCPT + 99 others); Sat, 7 May 2022 09:18:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357403AbiEGNSY (ORCPT ); Sat, 7 May 2022 09:18:24 -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 6906A4666F; Sat, 7 May 2022 06:14:37 -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 2B00BB80833; Sat, 7 May 2022 13:14:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE553C385A9; Sat, 7 May 2022 13:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651929274; bh=9uTgmNAvlTbzN50Cu5IwNYqzF7atwTKQUljfe2kjZUc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NYZWIxr7bdtZV5TCcT29L1SoUFnfl0Drt2zM3YTpcRSmzMXOH2zT2baV4RKv/+juu BeDMU08ud7wEyHs+PdV76d+h0FPoWNnkiKsYboYXuD0asYcJpn1MYIybfLSkxaveRD uQQFXFWzr9gQFnG/xPzoBv9obxrCScP/SadNv3PCPo2G03s6CjQbtW7kU30vam9nvR Gf9YIXbw31u1k0y0AlA3If+Fygh/BycEfiWjNZ4jYfFCmNDyTDxL258IRkv/OGg8DJ x/as86QX/Y3tXnRDq/97ZySrx3YSbvxuVWbYl92I7gnkngH5rRb0u87EFe1JeEtcqb h3B3YManvPOXw== Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-2f7d7e3b5bfso105856877b3.5; Sat, 07 May 2022 06:14:34 -0700 (PDT) X-Gm-Message-State: AOAM5324RKs/khNVpfgto0nIU6Tw7t5R03GZYazMMiGH6m4oKC3eUQGE 4aM8eXq+3QcHFlQ8KhlBeB5lY/Q4ExXiQrTN8lU= X-Received: by 2002:a81:1697:0:b0:2fa:32f9:78c8 with SMTP id 145-20020a811697000000b002fa32f978c8mr6670913yww.135.1651929273816; Sat, 07 May 2022 06:14:33 -0700 (PDT) MIME-Version: 1.0 References: <20220505195342.GA509942@bhelgaas> <22bec167-241f-2cbe-829f-a3f65e40e71@linux-m68k.org> <105ccec439f709846e82b69cb854ac825d7a6a49.camel@linux.ibm.com> <7dfa7578-039-e132-c573-ad89bd3215@linux-m68k.org> In-Reply-To: <7dfa7578-039-e132-c573-ad89bd3215@linux-m68k.org> From: Arnd Bergmann Date: Sat, 7 May 2022 15:14:16 +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: Finn Thain Cc: Niklas Schnelle , Bjorn Helgaas , 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=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Sat, May 7, 2022 at 2:01 AM Finn Thain wrote: > On Fri, 6 May 2022, Niklas Schnelle wrote: > > On Fri, 2022-05-06 at 19:12 +1000, Finn Thain wrote: > > > On Thu, 5 May 2022, Bjorn Helgaas wrote: > > > > > > > > I mooted a s390 inb() implementation like "return ~0" because that's > > > > what happens on most arches when there's no device to respond to the > > > > inb(). > > > > > > > > The HAS_IOPORT dependencies are fairly ugly IMHO, and they clutter > > > > drivers that use I/O ports in some cases but not others. But maybe > > > > it's the most practical way. > > > > > > > > > > Do you mean, "the most practical way to avoid a compiler warning on > > > s390"? What about "#pragma GCC diagnostic ignored"? > > > > This actually happens with clang. > > That suggests a clang bug to me. If you believe GCC should behave like > clang, then I guess the pragma above really is the one you want. If you > somehow feel that the kernel should cater to gcc and clang even where they > disagree then you would have to use "#pragma clang diagnostic ignored". I don't see how you can blame the compiler for this. On architectures with a zero PCI_IOBASE, an inb(0x2f8) literally becomes var = *(u8*)((NULL + 0x2f8); If you run a driver that does this, the kernel gets a page fault for the NULL page and reports an Oops. clang tells you 'warning: performing pointer arithmetic on a null pointer has undefined behavior', which is not exactly spot on, but close enough to warn you that you probably shouldn't do this. gcc doesn't warn here, but it does warn about an array out-of-bounds access when you pass such a pointer into memcpy or another string function. > > Apart from that, I think this would also fall under the same argument as > > the original patch Linus unpulled. We would just paint over someting > > that we know at compile time won't work: > > > > https://lore.kernel.org/lkml/CAHk-=wg80je=K7madF4e7WrRNp37e3qh6y10Svhdc7O8SZ_-8g@mail.gmail.com/ > > > > I wasn't advocating adding any warnings. > > If you know at compile time that a driver won't work, the usual solution > is scripts/config -d CONFIG_SOME_UNDESIRED_DRIVER. Why is that no > longer appropriate for drivers that use IO ports? This was never an option, we rely on 'make allmodconfig' to build without warnings on all architectures for finding regressions. Any driver that depends on architecture specific interfaces must not get selected on architectures that don't have those interfaces. Arnd