VFIO fixes for v4.18

- Make vfio-pci IGD extensions optional via Kconfig (Alex Williamson)
 
  - Remove unused and soon to be removed map_atomic callback from mbochs
    sample driver, add unmap callback to avoid dmabuf leaks (Gerd Hoffmann)
 
  - Fix usage of get_user_pages_longterm() (Jason Gunthorpe)
 
  - Fix sample mbochs driver vm_operations_struct.fault return type
    (Souptick Joarder)
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.14 (GNU/Linux)
 
 iQIcBAABAgAGBQJbP5NzAAoJECObm247sIsibX8QAJnJ+p88yIhozwmzIyZdy/rN
 zHNo+jSKlyGYmm1GWg77h+UfmVzLPI1eQZUsVt1L582J1M1/cpjiiPLPq/HGMQlw
 kG+9sMxqcux92En5D6nJF8wF/DXSWLxRSv0YTgjLTzhx6d473VYHKBZA/VJa0wBD
 /lj7Mdhbs5FrAwIfZCTyodRvkE21rE63pcS4KnNayjiIIlbiBKV8n+RZ0ayl8Qqp
 oycEMOLo2yF5New2/AK/RAWeCFfiyAgXaFjAor1jD3kiA/PUNs+HpUnbUqjWyj36
 ogI81gZqe1XVrEKaAcESalpldQP3lggxC1QmwhSdOzAjKNRA4qMnvuRr3XyFxXM5
 PsBdqmdmavRTX23rTAViAhlrwwukWaICAU8p2UxVobS3IEEzaG+DHhxOmeeoYF1v
 5fjlf0D1jOaKnYmdEhsLKDEbJ5NCj2qjkkQNA3/MHoyjdmz1ZuonK9oap/OBrPkK
 IB1gSuKUNwsCNyN18c6RBnWagprAEbMR6i35SVEf0VIgM6UI2Ld4aUTDczqObU/L
 T1vgkbp8DkAX8O7TZ29eMm/ieyUZ01pgYuxjnK1MYLR1byuOwI1WpYjQfo1JPtmJ
 TJH5YbGUqznJUZXrkB6CuUCXX3MkG2KU9CZVJU0MwGYuRUvJz5Tk4+ODbpoqDHby
 v1cQJdVywzi8BkacW1DZ
 =shTo
 -----END PGP SIGNATURE-----

Merge tag 'vfio-v4.18-rc4' of git://github.com/awilliam/linux-vfio

Pull VFIO fixes from Alex Williamson:

 - Make vfio-pci IGD extensions optional via Kconfig (Alex Williamson)

 - Remove unused and soon to be removed map_atomic callback from mbochs
   sample driver, add unmap callback to avoid dmabuf leaks (Gerd
   Hoffmann)

 - Fix usage of get_user_pages_longterm() (Jason Gunthorpe)

 - Fix sample mbochs driver vm_operations_struct.fault return type
   (Souptick Joarder)

* tag 'vfio-v4.18-rc4' of git://github.com/awilliam/linux-vfio:
  sample/vfio-mdev: Change return type to vm_fault_t
  vfio: Use get_user_pages_longterm correctly
  sample/mdev/mbochs: add mbochs_kunmap_dmabuf
  sample/mdev/mbochs: remove mbochs_kmap_atomic_dmabuf
  vfio/pci: Make IGD support a configurable option
This commit is contained in:
Linus Torvalds 2018-07-06 12:23:53 -07:00
commit 1bb155702d
3 changed files with 26 additions and 23 deletions

View File

@ -28,5 +28,13 @@ config VFIO_PCI_INTX
def_bool y if !S390
config VFIO_PCI_IGD
depends on VFIO_PCI
def_bool y if X86
bool "VFIO PCI extensions for Intel graphics (GVT-d)"
depends on VFIO_PCI && X86
default y
help
Support for Intel IGD specific extensions to enable direct
assignment to virtual machines. This includes exposing an IGD
specific firmware table and read-only copies of the host bridge
and LPC bridge config space.
To enable Intel IGD assignment through vfio-pci, say Y.

View File

@ -343,18 +343,16 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,
struct page *page[1];
struct vm_area_struct *vma;
struct vm_area_struct *vmas[1];
unsigned int flags = 0;
int ret;
if (prot & IOMMU_WRITE)
flags |= FOLL_WRITE;
down_read(&mm->mmap_sem);
if (mm == current->mm) {
ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE),
page, vmas);
ret = get_user_pages_longterm(vaddr, 1, flags, page, vmas);
} else {
unsigned int flags = 0;
if (prot & IOMMU_WRITE)
flags |= FOLL_WRITE;
down_read(&mm->mmap_sem);
ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page,
vmas, NULL);
/*
@ -368,8 +366,8 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,
ret = -EOPNOTSUPP;
put_page(page[0]);
}
up_read(&mm->mmap_sem);
}
up_read(&mm->mmap_sem);
if (ret == 1) {
*pfn = page_to_pfn(page[0]);

View File

@ -657,7 +657,7 @@ static void mbochs_put_pages(struct mdev_state *mdev_state)
dev_dbg(dev, "%s: %d pages released\n", __func__, count);
}
static int mbochs_region_vm_fault(struct vm_fault *vmf)
static vm_fault_t mbochs_region_vm_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct mdev_state *mdev_state = vma->vm_private_data;
@ -695,7 +695,7 @@ static int mbochs_mmap(struct mdev_device *mdev, struct vm_area_struct *vma)
return 0;
}
static int mbochs_dmabuf_vm_fault(struct vm_fault *vmf)
static vm_fault_t mbochs_dmabuf_vm_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct mbochs_dmabuf *dmabuf = vma->vm_private_data;
@ -803,15 +803,6 @@ static void mbochs_release_dmabuf(struct dma_buf *buf)
mutex_unlock(&mdev_state->ops_lock);
}
static void *mbochs_kmap_atomic_dmabuf(struct dma_buf *buf,
unsigned long page_num)
{
struct mbochs_dmabuf *dmabuf = buf->priv;
struct page *page = dmabuf->pages[page_num];
return kmap_atomic(page);
}
static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num)
{
struct mbochs_dmabuf *dmabuf = buf->priv;
@ -820,12 +811,18 @@ static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num)
return kmap(page);
}
static void mbochs_kunmap_dmabuf(struct dma_buf *buf, unsigned long page_num,
void *vaddr)
{
kunmap(vaddr);
}
static struct dma_buf_ops mbochs_dmabuf_ops = {
.map_dma_buf = mbochs_map_dmabuf,
.unmap_dma_buf = mbochs_unmap_dmabuf,
.release = mbochs_release_dmabuf,
.map_atomic = mbochs_kmap_atomic_dmabuf,
.map = mbochs_kmap_dmabuf,
.unmap = mbochs_kunmap_dmabuf,
.mmap = mbochs_mmap_dmabuf,
};