[vfio-users] trouble mapping the pci config space on vfio-pci

Christophe Milard christophe.milard at linaro.org
Fri Oct 30 16:28:22 UTC 2015


Thanks for your quick answer, Alex.
I did not miss  vfio_region_info.flags: I am actually using its contents to
get the different regions offset.
I was not sure the mmap flag would apply to the configuration region
though, as the documentation comment suggested (at least as I understood
it), it would be mappable.
But it looks from the code I quoted that the configuration region will
never be mappable... right?
In which case the documentation comments is somehow missleading, I feel.

On 30 October 2015 at 13:55, Alex Williamson <alex.williamson at redhat.com>
wrote:

> On Fri, 2015-10-30 at 12:36 +0100, Christophe Milard wrote:
> > Hi
> >
> > www.kernel.org/doc/Documentation/vfio.txt says:
> >
> > """
> > for (i = 0; i < device_info.num_regions; i++) {
> > struct vfio_region_info reg = { .argsz = sizeof(reg) };
> >
> > reg.index = i;
> >
> > ioctl(device, VFIO_DEVICE_GET_REGION_INFO, &reg);
> >
> > /* Setup mappings... read/write offsets, mmaps
> > * For PCI devices, config space is a region */
> > }
> > """
> >
> > stating that the pci config space could be mapped using mmap, as any
> other
> > regions.
> > But, (after failing doing that and) looking
> > in linux/drivers/vfio/pci/vfio_pci.c, I can see:
> > """
> >
> > static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
> > {
> > ...        if (index >= VFIO_PCI_ROM_REGION_INDEX)
> >                 return -EINVAL;
> > """
> >
> > As VFIO_PCI_ROM_REGION_INDEX is defined as:
> >
> > """
> > enum {
> >         VFIO_PCI_BAR0_REGION_INDEX,
> >         VFIO_PCI_BAR1_REGION_INDEX,
> >         VFIO_PCI_BAR2_REGION_INDEX,
> >         VFIO_PCI_BAR3_REGION_INDEX,
> >         VFIO_PCI_BAR4_REGION_INDEX,
> >         VFIO_PCI_BAR5_REGION_INDEX,
> >         VFIO_PCI_ROM_REGION_INDEX,
> >         VFIO_PCI_CONFIG_REGION_INDEX,
> > ...
> > """
> >
> > The if statment excludes the possibility to map the pci configuration
> > region as any normal (BAR) region...
> >
> > DId I miss something? How am I supposed to perform the configuration
> space
> > mapping then?
>
> Hi Christophe,
>
> You're missing vfio_region_info.flags, which indicates whether the
> region supports read, write, or mmap.  The config space region does not
> set the mmap flag.  PCI config space itself may not be mmap capable and
> also the virtualization done to config space prevents it being mmap'd.
> This is generally not an issue since PCI config space should never be a
> performance path for a device.  Thanks,
>
> Alex
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/vfio-users/attachments/20151030/67a8ad10/attachment.htm>


More information about the vfio-users mailing list