Re: [PATCH v4 0/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
From: Arnd Bergmann <arnd@arndb.de>
Date: 2021-05-04 07:43:27
Also in:
linux-s390, lkml, sparclinux
From: Arnd Bergmann <arnd@arndb.de>
Date: 2021-05-04 07:43:27
Also in:
linux-s390, lkml, sparclinux
On Tue, May 4, 2021 at 9:40 AM Niklas Schnelle [off-list ref] wrote:
On Mon, 2021-05-03 at 18:07 +0200, Arnd Bergmann wrote:quoted
- for the risc-v patch, I would suggest explaining that this fixes an existing runtime bug, not just a compiler error: | This is already broken, as accessing a fixed I/O port number of | an ISA device on NOMMU RISC-V would turn into a NULL pointer | dereference. Feel free to either copy this, or use your own explanation.I mixed the above in with the current commit message: Without MMU support PCI_IOBASE is left undefined because PCI_IO_END is VMEMMAP_START. Nevertheless the in*()/out*() helper macros are left defined with uses of PCI_IOBASE. At the moment this only compiles because asm-generic/io.h defines PCI_IOBASE as 0 if it is undefined and so at macro expansion PCI_IOBASE is defined. This leads to compilation errors when asm-generic/io.h is changed to leave PCI_IOBASE undefined. More importantly it is currently broken at runtime, as accessing a fixed I/O port number of an ISA device on NOMMU RISC-V would turn into a NULL pointer dereference. Instead only define the in*()/out*() helper macros with MMU support and fall back to the asm-generic/io.h helper stubs otherwise.
Looks good, thanks. Maybe split into two or three paragraphs for readability.
Arnd