Skip to contentSkip to conversation

um: Turn HAS_IOPORT_MAP off

PATCH In review Tiwei Bie 3 participants 8 messages Jun 28, 2025 – Jul 2, 2025

Subsystems (2)
lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

PATCH 1/1 um: Turn HAS_IOPORT_MAP off

Since we don't have port I/O support, we should turn HAS_IOPORT_MAP off as well. It will fix clang warnings like below:

./include/asm-generic/io.h:1175:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
1175 | return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
| ~~~~~~~~~~ ^

---
Strictly speaking, the -Wnull-pointer-arithmetic warnings reported by lkp has been fixed by commit b8c9c3b822fe ("um: stop using PCI port I/O"). But it introduced new -Wnull-pointer-arithmetic warnings, and this patch fixes the newly introduced warnings.

 arch/um/Kconfig | 3 +++
 1 file changed, 3 insertions(+)
arch/um/Kconfig +3 -0
index f08e8a7fac93..76aa954520b1 100644
@@ -54,6 +54,9 @@ config UML_IOMEM_EMULATION
 	select INDIRECT_IOMEM
 	select GENERIC_PCI_IOMAP
 
+config NO_IOPORT_MAP
+	def_bool y
+
 config ISA
 	bool
 
Signature · 1 line
2.34.1
#1 lore raw

CC arnd

Quoted 34 lines · Tiwei Bie

Since we don't have port I/O support, we should turn HAS_IOPORT_MAP off as well. It will fix clang warnings like below:

./include/asm-generic/io.h:1175:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
1175 | return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
| ~~~~~~~~~~ ^

---
Strictly speaking, the -Wnull-pointer-arithmetic warnings reported by lkp has been fixed by commit b8c9c3b822fe ("um: stop using PCI port I/O"). But it introduced new -Wnull-pointer-arithmetic warnings, and this patch fixes the newly introduced warnings.

 arch/um/Kconfig | 3 +++
 1 file changed, 3 insertions(+)
arch/um/Kconfig +3 -0
index f08e8a7fac93..76aa954520b1 100644
@@ -54,6 +54,9 @@ config UML_IOMEM_EMULATION
        select INDIRECT_IOMEM
        select GENERIC_PCI_IOMAP
 
+config NO_IOPORT_MAP
+       def_bool y
+
 config ISA
        bool
 
#2 lore raw
Quoted 15 lines · Geert Uytterhoeven

CC arnd

Quoted 12 lines · Tiwei Bie

Since we don't have port I/O support, we should turn HAS_IOPORT_MAP off as well. It will fix clang warnings like below:

./include/asm-generic/io.h:1175:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
1175 | return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
| ~~~~~~~~~~ ^

---

I think this one would be a more generic solution, does that work for you?

lib/Kconfig +1 -1
@@ -381,7 +381,7 @@ config HAS_IOPORT
 config HAS_IOPORT_MAP
        bool
        depends on HAS_IOMEM && !NO_IOPORT_MAP
-       default y
+       default HAS_IOPORT
 
 source "kernel/dma/Kconfig"
 

It seems silly to turn off HAS_IOPORT_MAP on platforms that don't have HAS_IOPORT to start with.

Arnd

author
#3 lore raw
Quoted 2 lines · Arnd Bergmann
Quoted 1 line · Geert Uytterhoeven

CC arnd

Thanks for CCing Arnd. I missed that.

Quoted 9 lines
Quoted 9 lines · Tiwei Bie
Quoted 7 lines

Since we don't have port I/O support, we should turn HAS_IOPORT_MAP off as well. It will fix clang warnings like below:

./include/asm-generic/io.h:1175:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
1175 | return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
| ~~~~~~~~~~ ^

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

---

I think this one would be a more generic solution,

+1

Quoted 1 line

does that work for you?

Yeah, that works for me. :)

Quoted 12 lines
lib/Kconfig +1 -1
@@ -381,7 +381,7 @@ config HAS_IOPORT
 config HAS_IOPORT_MAP
        bool
        depends on HAS_IOMEM && !NO_IOPORT_MAP
-       default y
+       default HAS_IOPORT
 
 source "kernel/dma/Kconfig"
 
Quoted 2 lines

It seems silly to turn off HAS_IOPORT_MAP on platforms that don't have HAS_IOPORT to start with.

I'm not entirely clear on the meaning of HAS_IOPORT though. It looks HAS_IOPORT was introduced to support disabling compilation of the I/O accessor functions inb()/outb() and friends [1]. And looking at the code, xtensa supports IOPORT_MAP [2][3], but doesn't select HAS_IOPORT (which is also stated in the commit log in [1]).

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fcbfe8121a45152a3cfbe1c28c96a3b611b7347d
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/xtensa/include/asm/io.h?h=v6.16-rc4#n25
[3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/xtensa/Kconfig?h=v6.16-rc4#n81

Regards,
Tiwei

#4 lore raw
Quoted 11 lines · Tiwei Bie
Quoted 10 lines · Arnd Bergmann

On Tue, Jul 1, 2025, at 10:26, Geert Uytterhoeven wrote:

lib/Kconfig +1 -1
@@ -381,7 +381,7 @@ config HAS_IOPORT
 config HAS_IOPORT_MAP
        bool
        depends on HAS_IOMEM && !NO_IOPORT_MAP
-       default y
+       default HAS_IOPORT
 
Quoted 8 lines
Quoted 4 lines
lib/Kconfig +0 -0
 source "kernel/dma/Kconfig"
 

It seems silly to turn off HAS_IOPORT_MAP on platforms that don't have HAS_IOPORT to start with.

I'm not entirely clear on the meaning of HAS_IOPORT though. It looks HAS_IOPORT was introduced to support disabling compilation of the I/O accessor functions inb()/outb() and friends [1].

Correct

Quoted 3 lines

And looking at the
code, xtensa supports IOPORT_MAP [2][3], but doesn't select HAS_IOPORT (which is also stated in the commit log in [1]).

xtensa selects NO_IOPORT_MAP, which means that HAS_IOPORT_MAP gets disabled here:

arch/xtensa/Kconfig:config NO_IOPORT_MAP
arch/xtensa/Kconfig- def_bool n

The NO_IOPORT_MAP symbol is a bit confusing, but I think it works as intended, at least on xtensa. There are probably still some platforms that started selecting NO_IOPORT_MAP because they have no actual I/O port implementation, but that still need to be updated to not select HAS_IOPORT.

With my patch above, we should probably stop selecting NO_IOPORT_MAP on platforms that don't also set HAS_IOPORT, and keep the HAS_IOPORT_MAP/NO_IOPORT_MAP logic around only for the few cases that cannot abstract inb()/outb() through ioread8()/iowrite8(), i.e. Arm RiscPC, m68k q40, etc.

Arnd

author
#5 lore raw
Quoted 27 lines · Arnd Bergmann
Quoted 11 lines · Tiwei Bie
Quoted 10 lines · Arnd Bergmann

On Tue, Jul 1, 2025, at 10:26, Geert Uytterhoeven wrote:

lib/Kconfig +1 -1
@@ -381,7 +381,7 @@ config HAS_IOPORT
 config HAS_IOPORT_MAP
        bool
        depends on HAS_IOMEM && !NO_IOPORT_MAP
-       default y
+       default HAS_IOPORT
 
Quoted 8 lines
Quoted 4 lines
lib/Kconfig +0 -0
 source "kernel/dma/Kconfig"
 

It seems silly to turn off HAS_IOPORT_MAP on platforms that don't have HAS_IOPORT to start with.

I'm not entirely clear on the meaning of HAS_IOPORT though. It looks HAS_IOPORT was introduced to support disabling compilation of the I/O accessor functions inb()/outb() and friends [1].

Correct

Quoted 3 lines

And looking at the
code, xtensa supports IOPORT_MAP [2][3], but doesn't select HAS_IOPORT (which is also stated in the commit log in [1]).

Quoted 5 lines

xtensa selects NO_IOPORT_MAP, which means that HAS_IOPORT_MAP gets disabled here:

arch/xtensa/Kconfig:config NO_IOPORT_MAP
arch/xtensa/Kconfig- def_bool n

The value of NO_IOPORT_MAP on xtensa is inverted compared to that on most other platforms that explicitly defines NO_IOPORT_MAP.

When NO_IOPORT_MAP is explicitly defined, it is typically set to 'y', which disables HAS_IOPORT_MAP [1]. However, on xtensa, NO_IOPORT_MAP is set to 'n' [2], thereby enabling HAS_IOPORT_MAP.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/Kconfig?h=v6.16-rc4#n468
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/xtensa/Kconfig?h=v6.16-rc4#n82

Regards,
Tiwei

#6 lore raw
Quoted 10 lines · Tiwei Bie
Quoted 6 lines · Arnd Bergmann

On Tue, Jul 1, 2025, at 14:22, Tiwei Bie wrote:
xtensa selects NO_IOPORT_MAP, which means that HAS_IOPORT_MAP gets disabled here:

arch/xtensa/Kconfig:config NO_IOPORT_MAP
arch/xtensa/Kconfig- def_bool n

The value of NO_IOPORT_MAP on xtensa is inverted compared to that on most other platforms that explicitly defines NO_IOPORT_MAP.

Ah of course, sorry for misunderstanding. Apparently this only existed because it was selected by a long gone platform:

-config XTENSA_PLATFORM_S6105

-       bool "S6105"
-       select HAVE_IDE
-       select SERIAL_CONSOLE
-       select NO_IOPORT_MAP

Before commits

d38efc1f150f ("xtensa: adopt generic io routines") d046f77ec4a4 ("xtensa: set NO_IOPORT to 'n' by default")

it was always-on, and I think the idea at the time was to make it behave more like the generic PCI code, while it was originally copied from sparc, which does things quite differently.

It is rather clear that the I/O port implementation on xtensa never actually worked, and some of the comments on its PCI code suggest that it was never really used either.

Arnd

author
#7 lore raw
Quoted 15 lines · Arnd Bergmann
Quoted 10 lines · Tiwei Bie
Quoted 6 lines · Arnd Bergmann

On Tue, Jul 1, 2025, at 14:22, Tiwei Bie wrote:
xtensa selects NO_IOPORT_MAP, which means that HAS_IOPORT_MAP gets disabled here:

arch/xtensa/Kconfig:config NO_IOPORT_MAP
arch/xtensa/Kconfig- def_bool n

The value of NO_IOPORT_MAP on xtensa is inverted compared to that on most other platforms that explicitly defines NO_IOPORT_MAP.

Ah of course, sorry for misunderstanding. Apparently this only existed because it was selected by a long gone platform:

Review

Quoted 5 lines
(quoted diff) +0 -5
-config XTENSA_PLATFORM_S6105
-       bool "S6105"
-       select HAVE_IDE
-       select SERIAL_CONSOLE
-       select NO_IOPORT_MAP

Cool, that makes sense!

Quoted 11 lines

Before commits

d38efc1f150f ("xtensa: adopt generic io routines") d046f77ec4a4 ("xtensa: set NO_IOPORT to 'n' by default")

it was always-on, and I think the idea at the time was to make it behave more like the generic PCI code, while it was originally copied from sparc, which does things quite differently.

Quoted 4 lines

It is rather clear that the I/O port implementation on xtensa never actually worked, and some of the comments on its PCI code suggest that it was never really used either.

Thanks for the details. I'm not really familiar with xtensa; my understanding comes merely from reading the code. Please feel free to proceed with your patch. I also think it is a more generic solution. :)

Regards,
Tiwei