]> git.baikalelectronics.ru Git - kernel.git/commit
vfio/pci: Use kernel VPD access functions
authorAlex Williamson <alex.williamson@redhat.com>
Tue, 27 Oct 2015 20:53:05 +0000 (14:53 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 27 Oct 2015 20:53:05 +0000 (14:53 -0600)
commitad1f9f97cf2ce0b9a16907cead5a77116f83fa8c
treeca4997c28062babbe93bea6915580711539191dc
parentea2e1cd210e2021dd5b9f27206e25bc0d3ba6f06
vfio/pci: Use kernel VPD access functions

The PCI VPD capability operates on a set of window registers in PCI
config space.  Writing to the address register triggers either a read
or write, depending on the setting of the PCI_VPD_ADDR_F bit within
the address register.  The data register provides either the source
for writes or the target for reads.

This model is susceptible to being broken by concurrent access, for
which the kernel has adopted a set of access functions to serialize
these registers.  Additionally, commits like b84fe6712a22 ("PCI: Add
dev_flags bit to access VPD through function 0") and 98f38fad7cc2
("PCI: Add VPD function 0 quirk for Intel Ethernet devices") indicate
that VPD registers can be shared between functions on multifunction
devices creating dependencies between otherwise independent devices.

Fortunately it's quite easy to emulate the VPD registers, simply
storing copies of the address and data registers in memory and
triggering a VPD read or write on writes to the address register.
This allows vfio users to avoid seeing spurious register changes from
accesses on other devices and enables the use of shared quirks in the
host kernel.  We can theoretically still race with access through
sysfs, but the window of opportunity is much smaller.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Mark Rustad <mark.d.rustad@intel.com>
drivers/vfio/pci/vfio_pci_config.c