vfio/pci: Avoid mapping BARs for devices with non-mappable BARs
Subsystems (3)
PATCH 1/1 vfio/pci: Avoid mapping BARs for devices with non-mappable BARs
vfio_pci_core_map_bars() calls pci_iomap() to set up BAR resources, but not all devices support having their BARs mapped by the CPU. The non_mappable_bars flag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_range for size 281474976714752 failed: Address range restricted to 0x2110bab00000 - 0x21903ab00000
Use pdev->non_mappable_bars to skip pci_iomap() for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose in vfio_pci_probe_mmaps().
--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/vfio/pci/vfio_pci_core.c +3 -0
@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +if (!pci_resource_len (pdev, i))continue ;
Signature · 1 line
2.43.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000
Quoted 7 lines
Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 26 lines · Farhan Ali
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0
drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) · line 559
Quoted 6 lines
drivers/vfio/pci/vfio_pci_core.c +3
-0@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +
This would work for the ISM case at least, but I wonder: should we check vdev->bar_mmap_supported[bar] instead?
My question boils down to: do we still want messages for some of the cases where we set vdev->bar_mmap_supported[bar] = false in vfio_pci_probe_mmaps()?
Or should the messages only print when we probed, thought the bar could be mmap'd (vdev->bar_mmap_supported[bar] == true), and now hit a failure?
Thanks,
Matt
Quoted 3 lines
drivers/vfio/pci/vfio_pci_core.c +0
-0if (!pci_resource_len (pdev, i))continue ;
Quoted 36 lines · Matthew Rosato
Quoted 26 lines · Farhan Ali
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) · line 559
Quoted 6 lines
drivers/vfio/pci/vfio_pci_core.c +3
-0@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +This would work for the ISM case at least, but I wonder: should we check vdev->bar_mmap_supported[bar] instead?
Quoted 3 lines
My question boils down to: do we still want messages for some of the cases where we set vdev->bar_mmap_supported[bar] = false in
vfio_pci_probe_mmaps()?
AFAIU vfio_pci_probe_mmaps() is only called in vfio_pci_core_finish_enable(). Since vfio_pci_core_map_bars() is called in vfio_pci_core_enable(), and before vfio_pci_core_finish_enable(), bar_mmap_supported would be false here for all devices. So I don't think it would work here, unless I missed something?
Thanks
Farhan
Quoted 10 lines
Or should the messages only print when we probed, thought the bar could be mmap'd (vdev->bar_mmap_supported[bar] == true), and now hit a failure?
Thanks,
MattQuoted 3 lines
drivers/vfio/pci/vfio_pci_core.c +0
-0if (!pci_resource_len (pdev, i))continue ;
Alex Williamson
maintainerQuoted 41 lines · On Wed, 29 Jul 2026 13:28:46 -0700 Farhan Ali <[email protected]> wrote:
Quoted 36 lines · Matthew Rosato
Quoted 26 lines · Farhan Ali
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) · line 559
Quoted 6 lines
drivers/vfio/pci/vfio_pci_core.c +3
-0@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +This would work for the ISM case at least, but I wonder: should we check vdev->bar_mmap_supported[bar] instead?
Quoted 3 lines
My question boils down to: do we still want messages for some of the cases where we set vdev->bar_mmap_supported[bar] = false in
vfio_pci_probe_mmaps()?
Quoted 5 lines
AFAIU
vfio_pci_probe_mmaps()is only called invfio_pci_core_finish_enable(). Sincevfio_pci_core_map_bars()is called invfio_pci_core_enable(), and beforevfio_pci_core_finish_enable(),bar_mmap_supportedwould be false here for all devices. So I don't think it would work here, unless I missed something?
Also IO Port and sub-page MMIO BARs are things that do exist. Thanks,
Alex
Quoted 43 lines · Alex Williamson
Quoted 40 lines · On Wed, 29 Jul 2026 13:28:46 -0700 Farhan Ali <[email protected]> wrote:
Quoted 39 lines · Matthew Rosato
Quoted 26 lines · Farhan Ali
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) · line 559
Quoted 6 lines
drivers/vfio/pci/vfio_pci_core.c +3
-0@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +This would work for the ISM case at least, but I wonder: should we check vdev->bar_mmap_supported[bar] instead?
My question boils down to: do we still want messages for some of the cases where we set vdev->bar_mmap_supported[bar] = false in
vfio_pci_probe_mmaps()?
Quoted 8 lines
Quoted 5 lines
AFAIU
vfio_pci_probe_mmaps()is only called invfio_pci_core_finish_enable(). Sincevfio_pci_core_map_bars()is called invfio_pci_core_enable(), and beforevfio_pci_core_finish_enable(),bar_mmap_supportedwould be false here for all devices. So I don't think it would work here, unless I missed something?Also IO Port and sub-page MMIO BARs are things that do exist. Thanks,
Alex
Just to clarify, are you suggesting we expand this check to also avoid mapping IO port and sub-page MMIO BARs?
Thanks
Farhan
Alex Williamson
maintainerQuoted 49 lines · On Wed, 29 Jul 2026 14:32:45 -0700 Farhan Ali <[email protected]> wrote:
Quoted 48 lines · Alex Williamson
Quoted 45 lines · On Wed, 29 Jul 2026 13:28:46 -0700 Farhan Ali <[email protected]> wrote:
Quoted 36 lines · Matthew Rosato
Quoted 26 lines · Farhan Ali
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) · line 559
Quoted 6 lines
drivers/vfio/pci/vfio_pci_core.c +3
-0@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +This would work for the ISM case at least, but I wonder: should we check vdev->bar_mmap_supported[bar] instead?
Quoted 3 lines
My question boils down to: do we still want messages for some of the cases where we set vdev->bar_mmap_supported[bar] = false in
vfio_pci_probe_mmaps()?AFAIU
vfio_pci_probe_mmaps()is only called invfio_pci_core_finish_enable(). Sincevfio_pci_core_map_bars()is called invfio_pci_core_enable(), and beforevfio_pci_core_finish_enable(),bar_mmap_supportedwould be false here for all devices. So I don't think it would work here, unless I missed something?
Quoted 4 lines
Quoted 1 line
Also IO Port and sub-page MMIO BARs are things that do exist. Thanks,
Just to clarify, are you suggesting we expand this check to also avoid mapping IO port and sub-page MMIO BARs?
Sorry, no, I'm not. I think we're conflating that the barmap is related to mmap access. The barmap itself is holding the iomap of the BAR, used for read/write. The only real relation to the mmap is that we request the resource via this path as well.
Therefore not only is the ordering of setting up bar_mmap_supported wrong, it's flagging entirely the wrong thing here and keying on it would entirely break IO port and sub-page MMIO BAR access. Thanks,
Alex
Quoted 60 lines · Alex Williamson
Quoted 44 lines · On Wed, 29 Jul 2026 14:32:45 -0700 Farhan Ali <[email protected]> wrote:
Quoted 43 lines · Alex Williamson
Quoted 40 lines · On Wed, 29 Jul 2026 13:28:46 -0700 Farhan Ali <[email protected]> wrote:
Quoted 39 lines · Matthew Rosato
Quoted 26 lines · Farhan Ali
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) · line 559
Quoted 6 lines
drivers/vfio/pci/vfio_pci_core.c +3
-0@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +This would work for the ISM case at least, but I wonder: should we check vdev->bar_mmap_supported[bar] instead?
My question boils down to: do we still want messages for some of the cases where we set vdev->bar_mmap_supported[bar] = false in
vfio_pci_probe_mmaps()?Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
AFAIU
vfio_pci_probe_mmaps()is only called invfio_pci_core_finish_enable(). Sincevfio_pci_core_map_bars()is called invfio_pci_core_enable(), and beforevfio_pci_core_finish_enable(),bar_mmap_supportedwould be false here for all devices. So I don't think it would work here, unless I missed something?Also IO Port and sub-page MMIO BARs are things that do exist. Thanks,
Just to clarify, are you suggesting we expand this check to also avoid mapping IO port and sub-page MMIO BARs?
Sorry, no, I'm not. I think we're conflating that the barmap is related to mmap access. The barmap itself is holding the iomap of the BAR, used for read/write. The only real relation to the mmap is that we request the resource via this path as well.
Quoted 5 lines
Therefore not only is the ordering of setting up
bar_mmap_supportedwrong, it's flagging entirely the wrong thing here and keying on it would entirely break IO port and sub-page MMIO BAR access. Thanks,Alex
Hi Alex,
I wanted some guidance on how we should proceed with this patch? The warning messages are a regression on s390 for ISM devices, so we would like to fix it.
Thanks
Farhan
Alex Williamson
maintainerQuoted 65 lines · On Mon, 3 Aug 2026 09:39:19 -0700 Farhan Ali <[email protected]> wrote:
Quoted 64 lines · Alex Williamson
Quoted 44 lines · On Wed, 29 Jul 2026 14:32:45 -0700 Farhan Ali <[email protected]> wrote:
Quoted 43 lines · Alex Williamson
Quoted 40 lines · On Wed, 29 Jul 2026 13:28:46 -0700 Farhan Ali <[email protected]> wrote:
Quoted 39 lines · Matthew Rosato
Quoted 26 lines · Farhan Ali
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) · line 559
Quoted 6 lines
drivers/vfio/pci/vfio_pci_core.c +3
-0@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +This would work for the ISM case at least, but I wonder: should we check vdev->bar_mmap_supported[bar] instead?
My question boils down to: do we still want messages for some of the cases where we set vdev->bar_mmap_supported[bar] = false in
vfio_pci_probe_mmaps()?Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
AFAIU
vfio_pci_probe_mmaps()is only called invfio_pci_core_finish_enable(). Sincevfio_pci_core_map_bars()is called invfio_pci_core_enable(), and beforevfio_pci_core_finish_enable(),bar_mmap_supportedwould be false here for all devices. So I don't think it would work here, unless I missed something?Also IO Port and sub-page MMIO BARs are things that do exist. Thanks,
Just to clarify, are you suggesting we expand this check to also avoid mapping IO port and sub-page MMIO BARs?
Sorry, no, I'm not. I think we're conflating that the barmap is related to mmap access. The barmap itself is holding the iomap of the BAR, used for read/write. The only real relation to the mmap is that we request the resource via this path as well.
Therefore not only is the ordering of setting up
bar_mmap_supportedwrong, it's flagging entirely the wrong thing here and keying on it would entirely break IO port and sub-page MMIO BAR access. Thanks,
Quoted 7 lines
Quoted 1 line
Alex
Hi Alex,
I wanted some guidance on how we should proceed with this patch? The warning messages are a regression on s390 for ISM devices, so we would like to fix it.
I think the original proposal is probably the correct one. The non_mmapable_bars flag doesn't restrict its application to specific BAR types or access, at least not beyond "can't be mapped to CPU or peers."
If we can't map the BAR to the CPU, then we don't need to request the region or perform the pci_iomap(), which is what I understand explodes here. Therefore we really only need to establish the errno in the barmap here.
The bar_mmap_supported flag describes something else, whether the BAR can be mapped into the user address space. My intention was only to point out that there are BARs that cannot be mapped to the user address space because either they're not MMIO or we can't safely map the full page, therefore bar_mmap_supported is an invalid test for whether we should request the region or iomap the BAR.
Is there still a gap with the original proposal that I'm missing? Thanks,
Alex
Quoted 74 lines · Alex Williamson
Quoted 65 lines · On Mon, 3 Aug 2026 09:39:19 -0700 Farhan Ali <[email protected]> wrote:
Quoted 64 lines · Alex Williamson
Quoted 44 lines · On Wed, 29 Jul 2026 14:32:45 -0700 Farhan Ali <[email protected]> wrote:
Quoted 43 lines · Alex Williamson
Quoted 40 lines · On Wed, 29 Jul 2026 13:28:46 -0700 Farhan Ali <[email protected]> wrote:
Quoted 39 lines · Matthew Rosato
Quoted 26 lines · Farhan Ali
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) · line 559
Quoted 6 lines
drivers/vfio/pci/vfio_pci_core.c +3
-0@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +This would work for the ISM case at least, but I wonder: should we check vdev->bar_mmap_supported[bar] instead?
My question boils down to: do we still want messages for some of the cases where we set vdev->bar_mmap_supported[bar] = false in
vfio_pci_probe_mmaps()?Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
AFAIU
vfio_pci_probe_mmaps()is only called invfio_pci_core_finish_enable(). Sincevfio_pci_core_map_bars()is called invfio_pci_core_enable(), and beforevfio_pci_core_finish_enable(),bar_mmap_supportedwould be false here for all devices. So I don't think it would work here, unless I missed something?Also IO Port and sub-page MMIO BARs are things that do exist. Thanks,
Just to clarify, are you suggesting we expand this check to also avoid mapping IO port and sub-page MMIO BARs?
Sorry, no, I'm not. I think we're conflating that the barmap is related to mmap access. The barmap itself is holding the iomap of the BAR, used for read/write. The only real relation to the mmap is that we request the resource via this path as well.
Therefore not only is the ordering of setting up
bar_mmap_supportedwrong, it's flagging entirely the wrong thing here and keying on it would entirely break IO port and sub-page MMIO BAR access. Thanks,Quoted 6 lines
Quoted 1 line
Alex
Hi Alex,
I wanted some guidance on how we should proceed with this patch? The warning messages are a regression on s390 for ISM devices, so we would like to fix it.
Quoted 8 lines
I think the original proposal is probably the correct one. The
non_mmapable_barsflag doesn't restrict its application to specific BAR types or access, at least not beyond "can't be mapped to CPU or peers."If we can't map the BAR to the CPU, then we don't need to request the region or perform the
pci_iomap(), which is what I understand explodes here. Therefore we really only need to establish the errno in the barmap here.
Yes, its the call to pci_iomap() that leads to the warning.
Quoted 9 lines
The
bar_mmap_supportedflag describes something else, whether the BAR can be mapped into the user address space. My intention was only to point out that there are BARs that cannot be mapped to the user address space because either they're not MMIO or we can't safely map the full page, thereforebar_mmap_supportedis an invalid test for whether we should request the region or iomap the BAR.Is there still a gap with the original proposal that I'm missing?
AFAICT this fix should be sufficient. I think Matt's question was to see if there were other cases for which bar_mmap_supported were set to false, that we need to consider here. But I will let him clarify to see if he has any concerns.
Thanks
Farhan
Matthew Rosato
Reviewed-byQuoted 8 lines
Quoted 8 lines
The
bar_mmap_supportedflag describes something else, whether the BAR can be mapped into the user address space. My intention was only to point out that there are BARs that cannot be mapped to the user address space because either they're not MMIO or we can't safely map the full page, thereforebar_mmap_supportedis an invalid test for whether we should request the region or iomap the BAR.
Quoted 6 lines
Quoted 1 line
Is there still a gap with the original proposal that I'm missing?
AFAICT this fix should be sufficient. I think Matt's question was to see if there were other cases for which
bar_mmap_supportedwere set to false, that we need to consider here. But I will let him clarify to see if he has any concerns.
^ Yes exactly that. To be clear: I am happy from the s390 side with the fix as it is proposed.
My questions were basically trying to generate the conversation that was just had in an effort to avoid another fix later.
So, with the context provided (thanks!):
Quoted 15 lines · Matthew Rosato
Quoted 7 lines
Quoted 7 lines
The
bar_mmap_supportedflag describes something else, whether the BAR can be mapped into the user address space. My intention was only to point out that there are BARs that cannot be mapped to the user address space because either they're not MMIO or we can't safely map the full page, thereforebar_mmap_supportedis an invalid test for whether we should request the region or iomap the BAR.Quoted 5 lines
Quoted 1 line
Is there still a gap with the original proposal that I'm missing?
AFAICT this fix should be sufficient. I think Matt's question was to see if there were other cases for which
bar_mmap_supportedwere set to false, that we need to consider here. But I will let him clarify to see if he has any concerns.^ Yes exactly that. To be clear: I am happy from the s390 side with the fix as it is proposed.
Quoted 6 lines
My questions were basically trying to generate the conversation that was just had in an effort to avoid another fix later.
So, with the context provided (thanks!):
Reviewed-by Matthew Rosato <[email protected]>
Hi Alex,
Polite ping on this patch. Please let me know if there are any other concerns with this patch or if we could consider this for inclusion to fix the regression on s390.
Thanks
Farhan
Quoted 26 lines · Farhan Ali
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0
drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) · line 562
Quoted 9 lines
drivers/vfio/pci/vfio_pci_core.c +3
-0@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +if (!pci_resource_len (pdev, i))continue ;
While I was following the discussion I forgot to reply. This looks good to me. Thank you for taking care of this.
Feel free to add:
Quoted 26 lines · On Wed, 29 Jul 2026 11:11:16 -0700 Farhan Ali <[email protected]> wrote:
vfio_pci_core_map_bars()callspci_iomap()to set up BAR resources, but not all devices support having their BARs mapped by the CPU. Thenon_mappable_barsflag indicates that a PCI device's BARs cannot be accessed by the CPU. The ISM device on s390 is one such device. The BAR size for an ISM device is 256 TiB, and attempting to map the BAR will lead to warnings:
vmalloc_node_rangefor size 281474976714752 failed: Address range restricted to0x2110bab00000-0x21903ab00000Use
pdev->non_mappable_barsto skippci_iomap()for such devices. This flag is set by the PCI core at enumeration time and already serves the same purpose invfio_pci_probe_mmaps().Fixes 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Farhan Ali <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0
drivers/vfio/pci/vfio_pci_core.c static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) · line 562
Quoted 9 lines
drivers/vfio/pci/vfio_pci_core.c +3
-0@@ -554,6 +554,9 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) vdev->barmap[bar] =IOMEM_ERR_PTR (-ENODEV ); +if (pdev->non_mappable_bars) +continue ; +if (!pci_resource_len (pdev, i))continue ;
Applied to vfio next branch for v7.3. Thanks,
Alex