On Mon, 20 Jun 2016 16:23:07 -0600 Eric Blake <ebl...@redhat.com> wrote:
> On 06/20/2016 04:04 PM, Alex Williamson wrote: > > The kernel currently exposes the SR-IOV capability as read-only > > through vfio-pci. This is sufficient to protect the host kernel, but > > has the potential to confuse guests without further virtualization. > > In particular, OVMF tries to size the VF BARs and comes up with absurd > > results, ending with an assert. There's not much point in adding > > virtualization to a read-only capability, so we simply hide it for > > now. If the kernel ever enables SR-IOV virtualization, we should > > easily be able to test it through VF BAR sizing or explicit flags. > > > > Testing whether we should parse extended capabilities is also pulled > > into the function to keep these assumptions in one place. > > > > Signed-off-by: Alex Williamson <alex.william...@redhat.com> > > --- > > > + * Extended capabilities are chained with each pointing to the next, > > so we > > + * can drop anything other than the head of the chain simply by > > modifying > > + * the previous next pointer. For the head of the chain, we can > > modify the > > + * capability ID to something that cannot match a valid capability. ID > > + * 0 is reserved for this since absence of capabilities is indicated by > > + * 0 for the ID, version, AND next pointer. However, > > pcie_add_capability() > > + * uses ID 0 as reserved for list management and will incorrectly > > match and > > + * assert if we attempt to pre-load the head of the chain with with > > this > > + * ID. Use ID 0xFFFF temporarily since it is also seems to be > > reserved in > > + * part for identifying abscense of capabilities in a root complex > > register > > s/abscense/absence/ > Thanks, updated: diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 36d5e00..2418b93 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1796,7 +1796,7 @@ static int vfio_add_ext_cap(VFIOPCIDevice *vdev) * uses ID 0 as reserved for list management and will incorrectly match and * assert if we attempt to pre-load the head of the chain with with this * ID. Use ID 0xFFFF temporarily since it is also seems to be reserved in - * part for identifying abscense of capabilities in a root complex register + * part for identifying absence of capabilities in a root complex register * block. If the ID still exists after adding capabilities, switch back to * zero. We'll mark this entire first dword as emulated for this purpose. */