Re: [PATCH 1/1] tty: serial: handle HAS_IOPORT dependencies
From: Arnd Bergmann
Date: Fri Oct 04 2024 - 02:54:22 EST
On Wed, Oct 2, 2024, at 22:59, Maciej W. Rozycki wrote:
> On Wed, 2 Oct 2024, Arnd Bergmann wrote:
>> Part of the problem that Niklas is trying to solve with the
>> CONFIG_HAS_IOPORT annotations is to prevent an invalid inb()/outb()
>> from turning into a NULL pointer dereference as it currently does
>> on architectures that have no way to support PIO but get the
>> default implementation from asm-generic/io.h.
>
> It can be worse than that. Part of my confusion with the defxx driver
> trying to do port I/O with my POWER9 system came from the mapping actually
> resulting in non-NULL invalid pointers, dereferencing which caused a flood
> of obscure messages produced to the system console by the system firmware:
>
> LPC[000]: Got SYNC no-response error. Error address reg: 0xd0010014
> IPMI: dropping non severe PEL event
> LPC[000]: Got SYNC no-response error. Error address reg: 0xd0010014
> IPMI: dropping non severe PEL event
> LPC[000]: Got SYNC no-response error. Error address reg: 0xd0010014
> IPMI: dropping non severe PEL event
> LPC[000]: Got SYNC no-response error. Error address reg: 0xd0010014
> IPMI: dropping non severe PEL event
> [...]
>
> from which it was all but obvious that they were caused by an attempt to
> use PCI port I/O with a system lacking support for it.
Ah, that's too bad. I think this is a result of the patch that
Michael did to shut up the NULL pointer warning we get, see
be140f1732b5 ("powerpc/64: Set _IO_BASE to POISON_POINTER_DELTA
not 0 for CONFIG_PCI=n"). I really wish we could have finished
Niklas' series earlier to avoid this.
>> I think that anyone using hardware that relies on port I/O on
>> non-x86 is at this point going to have a reasonable understanding
>> of the system, so I'm not too worried here. ;-)
>
> Well, virtually all non-x86 systems continue supporting PCI/e port I/O
> via a suitably decoded CPU-side MMIO window, so I think coming across one
> that doesn't can still be a nasty surprise even in 2024. For instance
> I've been happily using a PC parallel port PCIe option card, one of the
> very few interfaces if not the only one remaining that have not ever seen
> an MMIO variant, with my RISC-V hardware, newer than said POWER9 system.
>
> So far it's been the s390 and a couple of POWER system implementations
> that have support for PCI/e port I/O removed. Have I missed anything?
I meant PCIe cards with I/O space here, not host bridges. I know you
have a lot of them, but what I've heard from Arm platform maintainers
is that they tend to struggle finding any PCIe cards to test their
hsot bridge drivers on, and I expect that a lot of them are actually
broken because they have never been tested and just copied the
implementation badly from some other driver.
I think the only new PCIe devices you can find today that still use
I/O space are ones with compatibility registers for IBM PC style
hardware (vga, uart, parport), but most users would never have used
one of those and instead use the native register interface of their
GPU (on non-x86), USB-serial and no parport. Other devices that
needed I/O space never worked on PCIe anyway because of the lack
of ISA style DMA.
There are also a lot of Arm systems that have no I/O space support at
all, such as the Apple M2 I'm using at the moment.
Arnd