net: starfire: fix ioaddr sign-extension causing ioremap() failure
Subsystems (3)
PATCH 1/1 net: starfire: fix ioaddr sign-extension causing ioremap() failure
ioaddr is declared as a signed long, but is assigned the result of pci_resource_start(), which returns an unsigned resource_size_t. On configurations where the BAR address has its high bit set, the value sign-extends when passed to ioremap(), producing a bogus 64-bit address and causing device probe to fail:
ioremap: invalid physical address fffffffffe480000 starfire 0000:08:04.0: cannot Remap 0x80000 @ 0xfe480000, aborting
Change ioaddr to unsigned long so pci_resource_start()'s value is preserved correctly.
--- drivers/net/ethernet/adaptec/starfire.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/adaptec/starfire.c +1 -1
@@ -634,7 +634,7 @@ static int starfire_init_one(struct pci_dev *pdev,int i, irq, chip_idx = ent->driver_data;struct net_device *dev;u8 addr[ETH_ALEN ]; -long ioaddr; +unsigned long ioaddr;void __iomem *base;int drv_flags, io_size;int boguscnt;
Signature · 1 line
2.55.0
Simon Horman
reviewerQuoted 9 lines · Ivy Lopez
ioaddr is declared as a signed long, but is assigned the result of
pci_resource_start(), which returns an unsignedresource_size_t. On configurations where the BAR address has its high bit set, the value sign-extends when passed toioremap(), producing a bogus 64-bit address and causing device probe to fail:ioremap: invalid physical address
fffffffffe480000starfire 0000:08:04.0: cannot Remap0x80000@0xfe480000, aborting
Quoted 7 lines
Change ioaddr to unsigned long so pci_resource_start()'s value is preserved correctly.
Signed-off-by Ivy Lopez <[email protected]>
I guess this is a minor tooling mishap, but one Signed-off-by is enough.
Quoted 9 lines
--- drivers/net/ethernet/adaptec/starfire.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/adaptec/starfire.c +0
-0
drivers/net/ethernet/adaptec/starfire.c static int starfire_init_one(struct pci_dev *pdev, · line 640
Quoted 8 lines
drivers/net/ethernet/adaptec/starfire.c +1
-1@@ -634,7 +634,7 @@ static int starfire_init_one(struct pci_dev *pdev,int i, irq, chip_idx = ent->driver_data;struct net_device *dev;u8 addr[ETH_ALEN ]; -long ioaddr; +unsigned long ioaddr;void __iomem *base;int drv_flags, io_size;int boguscnt;
I'm wondering if you considered using resource_size_t (and %pa[p]). Given that is the both type returned by pci_resource_start() and the type of the phys_addr parameter to ioremap().
PATCH v2 1/1 net: starfire: fix ioaddr sign-extension causing ioremap() failure
ioaddr is declared as a signed long, but is assigned the result of pci_resource_start(), which returns an unsigned resource_size_t. On configurations where the BAR address has its high bit set, the value sign-extends when passed to ioremap(), producing a bogus 64-bit address and causing device probe to fail:
ioremap: invalid physical address fffffffffe480000 starfire 0000:08:04.0: cannot Remap 0x80000 @ 0xfe480000, aborting
Change ioaddr to resource_size_t, matching both the return type of pci_resource_start() and the type ioremap() expects for its physical address argument, rather than unsigned long, which is not guaranteed to be wide enough on all configurations. Switch the associated error print to %pa accordingly.
---
v2: use resource_size_t instead of unsigned long, and switch the
error print to %pa, per Simon Horman's review.
--- drivers/net/ethernet/adaptec/starfire.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/adaptec/starfire.c +3 -3
@@ -634,7 +634,7 @@ static int starfire_init_one(struct pci_dev *pdev,int i, irq, chip_idx = ent->driver_data;struct net_device *dev;u8 addr[ETH_ALEN ]; -unsigned long ioaddr; +resource_size_t ioaddr;void __iomem *base;int drv_flags, io_size;int boguscnt;
@@ -664,8 +664,8 @@ static int starfire_init_one(struct pci_dev *pdev, base =ioremap (ioaddr, io_size);if (!base) { -dev_err (d,"cannot remap %#x @ %#lx, aborting\n" , - io_size, ioaddr); +dev_err (d,"cannot remap %#x @ %pa, aborting\n" , + io_size, &ioaddr); goto err_out_free_res; }
Signature · 1 line
2.55.0
Simon Horman
reviewerQuoted 15 lines · Ivy Lopez
ioaddr is declared as a signed long, but is assigned the result of
pci_resource_start(), which returns an unsignedresource_size_t. On configurations where the BAR address has its high bit set, the value sign-extends when passed toioremap(), producing a bogus 64-bit address and causing device probe to fail:ioremap: invalid physical address
fffffffffe480000starfire 0000:08:04.0: cannot Remap0x80000@0xfe480000, abortingChange ioaddr to
resource_size_t, matching both the return type ofpci_resource_start()and the typeioremap()expects for its physical address argument, rather than unsigned long, which is not guaranteed to be wide enough on all configurations. Switch the associated error print to %pa accordingly.
Quoted 5 lines
---
v2: useresource_size_tinstead of unsigned long, and switch the
error print to %pa, per Simon Horman's review.
In general this change looks good to me.
But unfortunately it does not apply against net-next.
Please rebase.
Signature · 3 lines
pw-bot: changes-requested ...
PATCH v3 1/1 net: starfire: fix ioaddr sign-extension causing ioremap() failure
ioaddr is declared as a signed long, but is assigned the result of pci_resource_start(), which returns an unsigned resource_size_t. On configurations where the BAR address has its high bit set, the value sign-extends when passed to ioremap(), producing a bogus 64-bit address and causing device probe to fail:
ioremap: invalid physical address fffffffffe480000 starfire 0000:08:04.0: cannot Remap 0x80000 @ 0xfe480000, aborting
Change ioaddr to resource_size_t, matching both the return type of pci_resource_start() and the type ioremap() expects for its physical address argument, rather than unsigned long, which is not guaranteed to be wide enough on all configurations. Switch the associated error print to %pa accordingly.
---
---
v2: use resource_size_t instead of unsigned long, and switch the
error print to %pa, per Simon Horman's review.
v3: rebase against net-next, no content changes, per Simon Horman.
--- drivers/net/ethernet/adaptec/starfire.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/adaptec/starfire.c +3 -3
@@ -634,7 +634,7 @@ static int starfire_init_one(struct pci_dev *pdev,int i, irq, chip_idx = ent->driver_data;struct net_device *dev;u8 addr[ETH_ALEN ]; -long ioaddr; +resource_size_t ioaddr;void __iomem *base;int drv_flags, io_size;int boguscnt;
@@ -664,8 +664,8 @@ static int starfire_init_one(struct pci_dev *pdev, base =ioremap (ioaddr, io_size);if (!base) { -dev_err (d,"cannot remap %#x @ %#lx, aborting\n" , - io_size, ioaddr); +dev_err (d,"cannot remap %#x @ %pa, aborting\n" , + io_size, &ioaddr); goto err_out_free_res; }
Signature · 1 line
2.55.0
Quoted 6 lines · Ivy Lopez
ioaddr is declared as a signed long, but is assigned the result of
pci_resource_start(), which returns an unsignedresource_size_t. On configurations where the BAR address has its high bit set, the value sign-extends when passed toioremap(), producing a bogus 64-bit address and causing device probe to fail:
Quoted 8 lines
ioremap: invalid physical address
fffffffffe480000starfire 0000:08:04.0: cannot Remap0x80000@0xfe480000, abortingChange ioaddr to
resource_size_t, matching both the return type ofpci_resource_start()and the typeioremap()expects for its physical address argument, rather than unsigned long, which is not guaranteed to be wide enough on all configurations. Switch the associated error print to %pa accordingly.
Sorry for not noticing this earlier, but probably this should have a Fixes tag. No need to repost just for this but I think it should be:
Quoted 3 lines
Quoted 5 lines
---
---
v2: useresource_size_tinstead of unsigned long, and switch the
error print to %pa, per Simon Horman's review.
v3: rebase against net-next, no content changes, per Simon Horman.
...
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 8 Sep 2026 18:28:29 -0600 you wrote:
ioaddr is declared as a signed long, but is assigned the result of
pci_resource_start(), which returns an unsignedresource_size_t. On configurations where the BAR address has its high bit set, the value sign-extends when passed toioremap(), producing a bogus 64-bit address and causing device probe to fail:ioremap: invalid physical address
fffffffffe480000starfire 0000:08:04.0: cannot Remap0x80000@0xfe480000, aborting[...]
Here is the summary with links:
- [net-next,v3] net: starfire: fix ioaddr sign-extension causing ioremap() failure
https://git.kernel.org/netdev/net-next/c/f5f0fcfcb30c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html