[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aac9ac52de09ff7162fc7caa6e817258d9dd313d.camel@linux.ibm.com>
Date: Wed, 21 Apr 2021 13:50:25 +0200
From: Niklas Schnelle <schnelle@...ux.ibm.com>
To: David Laight <David.Laight@...LAB.COM>,
Arnd Bergmann <arnd@...db.de>,
Vineet Gupta <vgupta@...opsys.com>,
"David S. Miller" <davem@...emloft.net>
Cc: Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
"clang-built-linux@...glegroups.com"
<clang-built-linux@...glegroups.com>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
"linux-snps-arc@...ts.infradead.org"
<linux-snps-arc@...ts.infradead.org>,
"sparclinux@...r.kernel.org" <sparclinux@...r.kernel.org>
Subject: Re: [PATCH v3 3/3] asm-generic/io.h: Silence
-Wnull-pointer-arithmetic warning on PCI_IOBASE
On Wed, 2021-04-21 at 11:24 +0000, David Laight wrote:
> 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
Hmm, I was wondering if we should rather have a large ifdef block of
all these functions stubbed to WARN_ONCE rather than in each function.
As I understand it this would be necessary if we want the inline gone.
They would still be static though so we still get a copy per
compilation unit that uses it or am I misunderstanding?
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
>
Powered by blists - more mailing lists