* [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs
@ 2026-07-29 18:11 Farhan Ali
2026-07-29 18:23 ` sashiko-bot
2026-07-29 19:41 ` Matthew Rosato
0 siblings, 2 replies; 7+ messages in thread
From: Farhan Ali @ 2026-07-29 18:11 UTC (permalink / raw)
To: linux-kernel, linux-s390, kvm
Cc: alifm, mjrosato, borntraeger, alex, mattev, schnelle
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().
Fixes: 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")
Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
---
drivers/vfio/pci/vfio_pci_core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index 3f11a9624b9c..6a184588ff23 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -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;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs
2026-07-29 18:11 [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs Farhan Ali
@ 2026-07-29 18:23 ` sashiko-bot
2026-07-29 19:41 ` Matthew Rosato
1 sibling, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-07-29 18:23 UTC (permalink / raw)
To: Farhan Ali
Cc: Alexander Gordeev, kvm, Heiko Carstens, linux-s390, Vasily Gorbik
> 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().
>
> Fixes: 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")
> Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260729181116.1373-1-alifm@linux.ibm.com?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs
2026-07-29 18:11 [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs Farhan Ali
2026-07-29 18:23 ` sashiko-bot
@ 2026-07-29 19:41 ` Matthew Rosato
2026-07-29 20:28 ` Farhan Ali
1 sibling, 1 reply; 7+ messages in thread
From: Matthew Rosato @ 2026-07-29 19:41 UTC (permalink / raw)
To: Farhan Ali, linux-kernel, linux-s390, kvm
Cc: borntraeger, alex, mattev, schnelle
On 7/29/26 2:11 PM, Farhan Ali wrote:
> 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().
>
> Fixes: 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")
> Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> ---
> drivers/vfio/pci/vfio_pci_core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index 3f11a9624b9c..6a184588ff23 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
> @@ -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
> if (!pci_resource_len(pdev, i))
> continue;
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs
2026-07-29 19:41 ` Matthew Rosato
@ 2026-07-29 20:28 ` Farhan Ali
2026-07-29 20:36 ` Alex Williamson
0 siblings, 1 reply; 7+ messages in thread
From: Farhan Ali @ 2026-07-29 20:28 UTC (permalink / raw)
To: Matthew Rosato, linux-kernel, linux-s390, kvm
Cc: borntraeger, alex, mattev, schnelle
On 7/29/2026 12:41 PM, Matthew Rosato wrote:
> On 7/29/26 2:11 PM, Farhan Ali wrote:
>> 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().
>>
>> Fixes: 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")
>> Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
>> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
>> ---
>> drivers/vfio/pci/vfio_pci_core.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
>> index 3f11a9624b9c..6a184588ff23 100644
>> --- a/drivers/vfio/pci/vfio_pci_core.c
>> +++ b/drivers/vfio/pci/vfio_pci_core.c
>> @@ -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()?
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
>
> 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
>
>> if (!pci_resource_len(pdev, i))
>> continue;
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs
2026-07-29 20:28 ` Farhan Ali
@ 2026-07-29 20:36 ` Alex Williamson
2026-07-29 21:32 ` Farhan Ali
0 siblings, 1 reply; 7+ messages in thread
From: Alex Williamson @ 2026-07-29 20:36 UTC (permalink / raw)
To: Farhan Ali
Cc: Matthew Rosato, linux-kernel, linux-s390, kvm, borntraeger,
mattev, schnelle, alex
On Wed, 29 Jul 2026 13:28:46 -0700
Farhan Ali <alifm@linux.ibm.com> wrote:
> On 7/29/2026 12:41 PM, Matthew Rosato wrote:
> > On 7/29/26 2:11 PM, Farhan Ali wrote:
> >> 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().
> >>
> >> Fixes: 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")
> >> Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> >> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> >> ---
> >> drivers/vfio/pci/vfio_pci_core.c | 3 +++
> >> 1 file changed, 3 insertions(+)
> >>
> >> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> >> index 3f11a9624b9c..6a184588ff23 100644
> >> --- a/drivers/vfio/pci/vfio_pci_core.c
> >> +++ b/drivers/vfio/pci/vfio_pci_core.c
> >> @@ -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()?
>
> 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?
Also IO Port and sub-page MMIO BARs are things that do exist. Thanks,
Alex
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs
2026-07-29 20:36 ` Alex Williamson
@ 2026-07-29 21:32 ` Farhan Ali
2026-07-29 21:50 ` Alex Williamson
0 siblings, 1 reply; 7+ messages in thread
From: Farhan Ali @ 2026-07-29 21:32 UTC (permalink / raw)
To: Alex Williamson
Cc: Matthew Rosato, linux-kernel, linux-s390, kvm, borntraeger,
mattev, schnelle
On 7/29/2026 1:36 PM, Alex Williamson wrote:
> On Wed, 29 Jul 2026 13:28:46 -0700
> Farhan Ali <alifm@linux.ibm.com> wrote:
>
>> On 7/29/2026 12:41 PM, Matthew Rosato wrote:
>>> On 7/29/26 2:11 PM, Farhan Ali wrote:
>>>> 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().
>>>>
>>>> Fixes: 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")
>>>> Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
>>>> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
>>>> ---
>>>> drivers/vfio/pci/vfio_pci_core.c | 3 +++
>>>> 1 file changed, 3 insertions(+)
>>>>
>>>> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
>>>> index 3f11a9624b9c..6a184588ff23 100644
>>>> --- a/drivers/vfio/pci/vfio_pci_core.c
>>>> +++ b/drivers/vfio/pci/vfio_pci_core.c
>>>> @@ -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()?
>> 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?
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs
2026-07-29 21:32 ` Farhan Ali
@ 2026-07-29 21:50 ` Alex Williamson
0 siblings, 0 replies; 7+ messages in thread
From: Alex Williamson @ 2026-07-29 21:50 UTC (permalink / raw)
To: Farhan Ali
Cc: Matthew Rosato, linux-kernel, linux-s390, kvm, borntraeger,
mattev, schnelle, alex
On Wed, 29 Jul 2026 14:32:45 -0700
Farhan Ali <alifm@linux.ibm.com> wrote:
> On 7/29/2026 1:36 PM, Alex Williamson wrote:
> > On Wed, 29 Jul 2026 13:28:46 -0700
> > Farhan Ali <alifm@linux.ibm.com> wrote:
> >
> >> On 7/29/2026 12:41 PM, Matthew Rosato wrote:
> >>> On 7/29/26 2:11 PM, Farhan Ali wrote:
> >>>> 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().
> >>>>
> >>>> Fixes: 05f2a68b407a ("vfio/pci: Set up BAR resources and maps in vfio_pci_core_enable()")
> >>>> Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> >>>> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> >>>> ---
> >>>> drivers/vfio/pci/vfio_pci_core.c | 3 +++
> >>>> 1 file changed, 3 insertions(+)
> >>>>
> >>>> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> >>>> index 3f11a9624b9c..6a184588ff23 100644
> >>>> --- a/drivers/vfio/pci/vfio_pci_core.c
> >>>> +++ b/drivers/vfio/pci/vfio_pci_core.c
> >>>> @@ -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()?
> >> 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?
> > 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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-07-29 21:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29 18:11 [PATCH v1] vfio/pci: Avoid mapping BARs for devices with non-mappable BARs Farhan Ali
2026-07-29 18:23 ` sashiko-bot
2026-07-29 19:41 ` Matthew Rosato
2026-07-29 20:28 ` Farhan Ali
2026-07-29 20:36 ` Alex Williamson
2026-07-29 21:32 ` Farhan Ali
2026-07-29 21:50 ` Alex Williamson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox