Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp399772pxy; Wed, 21 Apr 2021 05:54:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOvk5CIGU8vl6fPVAx4IBBqQqzbG2M3x5/WGk7MgQKDzYBKevwdiEh3wlbOfVdOeVk/LSC X-Received: by 2002:a17:906:b1d4:: with SMTP id bv20mr32959911ejb.46.1619009650232; Wed, 21 Apr 2021 05:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619009650; cv=none; d=google.com; s=arc-20160816; b=j0Cvoej5jBqG89w/QXlMZXvZS8qo/liU+UG+B0jmRxJ1Pp57ezv84ioookOPFKnYwx tr/nqgyBGuFpJXb73MznP0UFifV7elOxoKAFsfp9BFA2St3F4xjeJfqNKBFP5yH9shso yoM1pdmLrCBiVZwruREG7IvJZx11SHWl0de/LG8aCytYXnwB8VsjTUSFQ/4503vws0db TqmIbazaV2IZoPawC2VQ4R/t0Bj3LG3l33z6jmsUDvXuV4ThLaqWmkZG4+AdaPT7DJYm zjl55EcXENVP46WUCAZys/Nn55V5tYynN+G7x01ecJk23vPxvmjUpX29XUC05Bshc+LO NIbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=dCqWWqhIN7oNszeyxj4yRAyoaya2D8r/6aYLJUxL/d8=; b=o4i4KfUQ/mzUP6IKuJzCl9oJAnKE5bX+EgUAj1dR4Tfjt7psDZVqarqlkzkACQXwTM n10ZHlZ4O/seWywPnmntckNZRQPJB1c7e9Go9ARK9La5vbdGFi6LBooT8dPul8s81BG1 VR60hkCmDSNM3qioOy9Edh5NAh2CBG49R2WW4yoA5MR+4Q+lisqU/hKnkuGy4sP8vlz0 heXW+7AyUlnDl+cMCP9om4dXFgIZq74BcbsIkI0RNFilDGibwXG9Dn0nbcLiLvYSLEEn Fy8C/EkDoGzHEoUP4xQ9+yOBuW+4NqXB1VBxFTeYitPQwT72YC6J8CHMldIYHch9XsQK I6tg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w12si2086993edr.113.2021.04.21.05.53.47; Wed, 21 Apr 2021 05:54:10 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235254AbhDULZZ convert rfc822-to-8bit (ORCPT + 99 others); Wed, 21 Apr 2021 07:25:25 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:36068 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235070AbhDULZY (ORCPT ); Wed, 21 Apr 2021 07:25:24 -0400 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-145-Cn1hkKd9P9uw5RfL9DWEDg-1; Wed, 21 Apr 2021 12:24:48 +0100 X-MC-Unique: Cn1hkKd9P9uw5RfL9DWEDg-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Apr 2021 12:24:47 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.015; Wed, 21 Apr 2021 12:24:47 +0100 From: David Laight To: 'Niklas Schnelle' , Arnd Bergmann , Vineet Gupta , "David S. Miller" CC: Nathan Chancellor , Nick Desaulniers , "clang-built-linux@googlegroups.com" , "linux-arch@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-s390@vger.kernel.org" , "linux-snps-arc@lists.infradead.org" , "sparclinux@vger.kernel.org" Subject: RE: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE Thread-Topic: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE Thread-Index: AQHXNqAK6EZxeEzVYUmXQlgF5xc7+Kq+079Q Date: Wed, 21 Apr 2021 11:24:47 +0000 Message-ID: References: <20210421111759.2059976-1-schnelle@linux.ibm.com> <20210421111759.2059976-4-schnelle@linux.ibm.com> In-Reply-To: <20210421111759.2059976-4-schnelle@linux.ibm.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Niklas Schnelle > Sent: 21 April 2021 12:18 > > When PCI_IOBASE is not defined, it is set to 0 such that it is ignored > in calls to the readX/writeX primitives. This triggers clang's > -Wnull-pointer-arithmetic warning and will result in illegal accesses on > platforms that do not support I/O ports if drivers do still attempt to > access them. > > Make things explicit and silence the warning by letting inb() and > friends fail with WARN_ONCE() and a 0xff... return in case PCI_IOBASE is > not defined. ... > > diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h > index c6af40ce03be..aabb0a8186ee 100644 > --- a/include/asm-generic/io.h > +++ b/include/asm-generic/io.h ... > @@ -458,12 +454,17 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer, > #define _inb _inb > static inline u8 _inb(unsigned long addr) > { > +#ifdef PCI_IOBASE > u8 val; > > __io_pbr(); > val = __raw_readb(PCI_IOBASE + addr); > __io_par(val); > return val; > +#else > + WARN_ONCE(1, "No I/O port support\n"); > + return ~0; > +#endif > } > #endif I suspect that this might be better not inlined when PCI_IOBASE is undefined. Otherwise you get quite a lot of bloat from all the WARN_ONCE() calls. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)