Skip to contentSkip to conversation

staging: gpib: Fix i386 build issue

PATCH Superseded Dave Penkler 5 participants 12 messages Dec 4, 2024 – Dec 11, 2024 Staging

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 staging: gpib: Fix i386 build issue

These drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Disable these drivers if X68_PAE is enabled

Fixes e9dc69956d4d ("staging: gpib: Add Computer Boards GPIB driver")
Fixes e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")
Fixes bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes 0cd5b05551e0 ("staging: gpib: Add TNT4882 chip based GPIB driver")
---
 drivers/staging/gpib/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/gpib/Kconfig +4 -0
index 95308d15a555..6cf05586ca10 100644
@@ -50,6 +50,7 @@ config GPIB_CEC_PCI
 	tristate "CEC PCI board"
 	depends on PCI
 	depends on HAS_IOPORT
+	depends on !X86_PAE
 	select GPIB_COMMON
 	select GPIB_NEC7210
 	help
@@ -62,6 +63,7 @@ config GPIB_CEC_PCI
 config GPIB_NI_PCI_ISA
 	tristate "NI PCI/ISA compatible boards"
 	depends on ISA_BUS || PCI || PCMCIA
+	depends on !X86_PAE
 	select GPIB_COMMON
 	select GPIB_NEC7210
 	help
@@ -85,6 +87,7 @@ config GPIB_CB7210
        tristate "Measurement Computing compatible boards"
 	depends on HAS_IOPORT
 	depends on ISA_BUS || PCI || PCMCIA
+	depends on !X86_PAE
        select GPIB_COMMON
 	select GPIB_NEC7210
        help
@@ -174,6 +177,7 @@ config GPIB_INES
        tristate "INES"
 	depends on PCI || ISA_BUS || PCMCIA
 	depends on HAS_IOPORT
+	depends on !X86_PAE
        select GPIB_COMMON
        select GPIB_NEC7210
        help
Signature · 1 line
2.47.1
#1 lore raw

From: Dave Penkler

Quoted 8 lines

Sent: 04 December 2024 16:21

These drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Disable these drivers if X68_PAE is enabled

You missed the obvious typo :-)

There is also a proposal to just remove PAE support. Mostly because it is likely to have bit-rotted and isn't really needed now 64bit code is common.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#2 lore raw

Hi David,

Quoted 12 lines · David Laight

From: Dave Penkler

Quoted 8 lines

Sent: 04 December 2024 16:21

These drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Disable these drivers if X68_PAE is enabled

You missed the obvious typo :-)

FWIW, I fail to see that typo as well, so I am not sure if it is really that obvious.

Quoted 4 lines

There is also a proposal to just remove PAE support. Mostly because it is likely to have bit-rotted and isn't really needed now 64bit code is common.

Presumably that removal would not be 6.13 material, though, and I hope that there _some_ fix will make it into 6.13.

Thanks,
Guenter

#3 lore raw
In reply to Dave Penkler

Hi Dave,

Quoted 7 lines · Dave Penkler

These drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Disable these drivers if X68_PAE is enabled

Quoted 7 lines
Fixes e9dc69956d4d ("staging: gpib: Add Computer Boards GPIB driver")
Fixes e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")
Fixes bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes 0cd5b05551e0 ("staging: gpib: Add TNT4882 chip based GPIB driver")

Thanks for your patch!

drivers/staging/gpib/Kconfig config GPIB_CEC_PCI · line 53

Quoted 7 lines
drivers/staging/gpib/Kconfig +1 -0
@@ -50,6 +50,7 @@ config GPIB_CEC_PCI
        tristate "CEC PCI board"
        depends on PCI
        depends on HAS_IOPORT
+       depends on !X86_PAE

!CONFIG_PHYS_ADDR_T_64BIT, to match the definition of phys_addr_t?

Or is this only showing up on x86?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#4 lore raw

On Mon, Dec 09, 2024 at 05:01:19PM +0100, Geert Uytterhoeven wrote:
Hi Geert,

Quoted 30 lines

Hi Dave,

Quoted 7 lines · On Wed, Dec 4, 2024 at 5:21???PM Dave Penkler <[email protected]> wrote:

These drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Disable these drivers if X68_PAE is enabled

Quoted 7 lines
Fixes e9dc69956d4d ("staging: gpib: Add Computer Boards GPIB driver")
Fixes e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")
Fixes bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes 0cd5b05551e0 ("staging: gpib: Add TNT4882 chip based GPIB driver")

Thanks for your patch!

drivers/staging/gpib/Kconfig config GPIB_CEC_PCI · line 53

Quoted 7 lines
drivers/staging/gpib/Kconfig +1 -0
@@ -50,6 +50,7 @@ config GPIB_CEC_PCI
        tristate "CEC PCI board"
        depends on PCI
        depends on HAS_IOPORT
+       depends on !X86_PAE

!CONFIG_PHYS_ADDR_T_64BIT, to match the definition of phys_addr_t?

Quoted 2 lines

Or is this only showing up on x86?

I think so. See this message from Guenter
https://lore.kernel.org/all/[email protected]/

cheers,
-Dave

#5 lore raw
In reply to Geert Uytterhoeven
Quoted 20 lines · Geert Uytterhoeven

Hi Dave,

Quoted 7 lines · Dave Penkler

These drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Disable these drivers if X68_PAE is enabled

Quoted 7 lines
Fixes e9dc69956d4d ("staging: gpib: Add Computer Boards GPIB driver")
Fixes e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")
Fixes bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes 0cd5b05551e0 ("staging: gpib: Add TNT4882 chip based GPIB driver")

Thanks for your patch!

Quoted 10 lines

drivers/staging/gpib/Kconfig config GPIB_CEC_PCI · line 53

Quoted 7 lines
drivers/staging/gpib/Kconfig +1 -0
@@ -50,6 +50,7 @@ config GPIB_CEC_PCI
         tristate "CEC PCI board"
         depends on PCI
         depends on HAS_IOPORT
+       depends on !X86_PAE

!CONFIG_PHYS_ADDR_T_64BIT, to match the definition of phys_addr_t?

That would be wrong. It would disable the code for all 64-bit builds.

The underlying problem is that the code uses a pointer to store the physical address. That doesn't work if sizeof(pointer) < sizeof(physical address), which affects systems with X86_PAE enabled. I have not seen the problem anywhere else.

Guenter

#6 lore raw

Hi Günter,

Quoted 29 lines · Guenter Roeck
Quoted 18 lines · Geert Uytterhoeven
Quoted 7 lines · Dave Penkler

These drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Disable these drivers if X68_PAE is enabled

Quoted 7 lines
Fixes e9dc69956d4d ("staging: gpib: Add Computer Boards GPIB driver")
Fixes e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")
Fixes bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes 0cd5b05551e0 ("staging: gpib: Add TNT4882 chip based GPIB driver")

Thanks for your patch!

Quoted 9 lines

drivers/staging/gpib/Kconfig config GPIB_CEC_PCI · line 53

Quoted 7 lines
drivers/staging/gpib/Kconfig +1 -0
@@ -50,6 +50,7 @@ config GPIB_CEC_PCI
         tristate "CEC PCI board"
         depends on PCI
         depends on HAS_IOPORT
+       depends on !X86_PAE

!CONFIG_PHYS_ADDR_T_64BIT, to match the definition of phys_addr_t?

Quoted 1 line

That would be wrong. It would disable the code for all 64-bit builds.

Oops...

    depends on 64BIT || !PHYS_ADDR_T_64BIT

Assuming the driver actually works on 64-bit? Perhaps people keep an old i386 to control their GPIB gear?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#7 lore raw
Quoted 32 lines · Geert Uytterhoeven

Hi Günter,

Quoted 29 lines · Guenter Roeck
Quoted 27 lines · Geert Uytterhoeven
Quoted 7 lines · Dave Penkler

These drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Disable these drivers if X68_PAE is enabled

Quoted 7 lines
Fixes e9dc69956d4d ("staging: gpib: Add Computer Boards GPIB driver")
Fixes e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")
Fixes bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes 0cd5b05551e0 ("staging: gpib: Add TNT4882 chip based GPIB driver")

Thanks for your patch!

drivers/staging/gpib/Kconfig config GPIB_CEC_PCI · line 53

Quoted 7 lines
drivers/staging/gpib/Kconfig +1 -0
@@ -50,6 +50,7 @@ config GPIB_CEC_PCI
          tristate "CEC PCI board"
          depends on PCI
          depends on HAS_IOPORT
+       depends on !X86_PAE

!CONFIG_PHYS_ADDR_T_64BIT, to match the definition of phys_addr_t?

Quoted 6 lines
Quoted 1 line

That would be wrong. It would disable the code for all 64-bit builds.

Oops...

     depends on 64BIT || !PHYS_ADDR_T_64BIT

Yes, that should work.

Quoted 1 line

Assuming the driver actually works on 64-bit?

No idea.

Quoted 2 lines

Perhaps people keep an old i386 to control their GPIB gear?

The code does not depend on x86, so presumably it could be any kind of CPU as long as it supports PCI.

Guenter

#8 lore raw
In reply to Guenter Roeck

Hi Günter,

Quoted 4 lines · Guenter Roeck

The underlying problem is that the code uses a pointer to store the physical address. That doesn't work if sizeof(pointer) < sizeof(physical address), which affects systems with X86_PAE enabled. I have not seen the problem anywhere else.

I could reproduce the build issue on ARM, with CONFIG_ARM_LPAE=y, which is not enabled by allmodconfig.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer
#9 lore raw
Quoted 10 lines · Geert Uytterhoeven

Hi Günter,

Quoted 4 lines · Guenter Roeck

The underlying problem is that the code uses a pointer to store the physical address. That doesn't work if sizeof(pointer) < sizeof(physical address), which affects systems with X86_PAE enabled. I have not seen the problem anywhere else.

I could reproduce the build issue on ARM, with CONFIG_ARM_LPAE=y, which is not enabled by allmodconfig.

So does that mean this patch is incorrect?

confused,

greg k-h

#10 lore raw

Hi Greg,

Quoted 11 lines · Greg KH
Quoted 8 lines · Geert Uytterhoeven
Quoted 4 lines · Guenter Roeck

The underlying problem is that the code uses a pointer to store the physical address. That doesn't work if sizeof(pointer) < sizeof(physical address), which affects systems with X86_PAE enabled. I have not seen the problem anywhere else.

I could reproduce the build issue on ARM, with CONFIG_ARM_LPAE=y, which is not enabled by allmodconfig.

So does that mean this patch is incorrect?

Purely from an arch-agnostic LPAE PoV, it should be:

    depends on 64BIT || !PHYS_ADDR_T_64BIT

However, that assumes the driver actually works on 64-bit or non-x86. Perhaps people keep an old i386 to control their GPIB gear?

The drivers do not use ioremap(), but just cast the PCI resource addresses to void * pointers. No idea if that works on x86_64. It will probably crash spectacularly on non-x86...

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#11 lore raw
Quoted 12 lines · Geert Uytterhoeven

Hi Greg,

Quoted 9 lines · Greg KH
Quoted 8 lines · Geert Uytterhoeven
Quoted 4 lines · Guenter Roeck

The underlying problem is that the code uses a pointer to store the physical address. That doesn't work if sizeof(pointer) < sizeof(physical address), which affects systems with X86_PAE enabled. I have not seen the problem anywhere else.

I could reproduce the build issue on ARM, with CONFIG_ARM_LPAE=y, which is not enabled by allmodconfig.

I think it may actually also affect mips (CPU_MIPS32_R5_XPA) and arc (ARC_HAS_PAE40).

Quoted 7 lines
Quoted 2 lines

So does that mean this patch is incorrect?

Purely from an arch-agnostic LPAE PoV, it should be:

     depends on 64BIT || !PHYS_ADDR_T_64BIT

Dave, would you mind submitting another version of your patch with the above dependencies ?

Quoted 5 lines

However, that assumes the driver actually works on 64-bit or non-x86. Perhaps people keep an old i386 to control their GPIB gear?

The drivers do not use ioremap(), but just cast the PCI resource addresses to void * pointers. No idea if that works on x86_64.

I did wonder about that as well, but unfortunately it isn't easy to change, and would most definitely require testing on real hardware.

Quoted 2 lines

It will probably crash spectacularly on non-x86...

I'd guess so. However, that isn't something we can address here. All we can make sure is that the code compiles.

Thanks,
Guenter