title: what is "num_regions" returned by the ioctl (VFIO_DEVICE_GET_REGION_INFO) in vfio
body: <p>I am trying to understand how vfio works on pci.
  I have read <a href="https://www.kernel.org/doc/Documentation/vfio.txt" rel="nofollow">https://www.kernel.org/doc/Documentation/vfio.txt</a>, and I am writting a test based on it.
  At some point,my code looks like this:</p>
  
  <pre><code>/* Get pci device information (number of regions and interrupts...) */
  ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_INFO, &amp;device_info);
  if (ret) {
          printf("  %s cannot get device info, "
                          "error %i (%s)\n", pci_addr, errno, strerror(errno));
          close(vfio_dev_fd);
          return -1;
  }
  printf ("found %d regions in the device\n", device_info.num_regions);
  </code></pre>
  
  <p>What I do not understand is that the last printf shows 9 (nine) regions!
  Looking at the config space of my PCI device I can see:</p>
  
  <pre><code>cat /sys/bus/pci/devices/0000\:06\:00.0/config | hd
  00000000  e4 14 81 16 00 04 10 00  10 00 00 02 10 00 00 00  |................|
  00000010  04 00 de f3 00 00 00 00  04 00 df f3 00 00 00 00  |................|
  00000020  00 00 00 00 00 00 00 00  00 00 00 00 28 10 6e 02  |............(.n.|
  00000030  00 00 00 00 48 00 00 00  00 00 00 00 0a 01 00 00  |....H...........|
  00000040
  </code></pre>
  
  <p>I am new to PCI, but my interpretation of this is that there are only two BARSs on this board (0 and 2). And I though that max number of regions (BARs?) was 6 on PCI.</p>
  
  <p>There is nevertheless a little indication that I am misunderstanding something: the kernel doc mentioned above states:</p>
  
  <blockquote>
    <p>For PCI devices, config space is a region</p>
  </blockquote>
  
  <p>So that could lead to 3 regions for the board I am looking at... Still it says 9...
  What is a PCI region for pci_vfio? how are they numbered and accessed?...</p>
  
  <p>Thanks.</p>