Re: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

2021-03-01 Thread Jason Gunthorpe
On Mon, Mar 01, 2021 at 05:48:00PM -0700, Dave Jiang wrote: > > On 3/1/2021 5:29 PM, Jason Gunthorpe wrote: > > On Mon, Mar 01, 2021 at 05:23:47PM -0700, Dave Jiang wrote: > > > So after looking at the code in vfio_pci_intrs.c, I agree that the > > > set_irqs > > > code between VFIO_PCI and this

Re: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

2021-03-01 Thread Dave Jiang
On 3/1/2021 5:29 PM, Jason Gunthorpe wrote: On Mon, Mar 01, 2021 at 05:23:47PM -0700, Dave Jiang wrote: So after looking at the code in vfio_pci_intrs.c, I agree that the set_irqs code between VFIO_PCI and this driver can be made in common. Given that Alex doesn't want a vfio_pci device

Re: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

2021-03-01 Thread Jason Gunthorpe
On Mon, Mar 01, 2021 at 05:23:47PM -0700, Dave Jiang wrote: > > So after looking at the code in vfio_pci_intrs.c, I agree that the set_irqs > code between VFIO_PCI and this driver can be made in common. Given that Alex > doesn't want a vfio_pci device embedded in the driver, idxd isn't a

Re: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

2021-03-01 Thread Dave Jiang
On 2/10/2021 4:59 PM, Jason Gunthorpe wrote: On Fri, Feb 05, 2021 at 01:53:24PM -0700, Dave Jiang wrote: <-- cut for brevity --> +static int vdcm_idxd_set_msix_trigger(struct vdcm_idxd *vidxd, + unsigned int index, unsigned int start, +

RE: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

2021-02-18 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, February 17, 2021 5:33 AM > > On Tue, Feb 16, 2021 at 12:04:55PM -0700, Dave Jiang wrote: > > > > > + return remap_pfn_range(vma, vma->vm_start, pgoff, req_size, > pg_prot); > > > Nothing validated req_size - did you copy this from the Intel RDMA

Re: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

2021-02-16 Thread Jason Gunthorpe
On Tue, Feb 16, 2021 at 12:04:55PM -0700, Dave Jiang wrote: > > > + return remap_pfn_range(vma, vma->vm_start, pgoff, req_size, pg_prot); > > Nothing validated req_size - did you copy this from the Intel RDMA > > driver? It had a huge security bug just like this. > Thanks. Will add. Some of the

Re: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

2021-02-16 Thread Jason Gunthorpe
On Tue, Feb 16, 2021 at 12:39:56PM -0800, Dan Williams wrote: > > >> +/* > > >> + * Check and see if the guest wants to map to the limited or > > >> unlimited portal. > > >> + * The driver will allow mapping to unlimited portal only if the > > >> the wq is a > > >> + * dedicated

Re: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

2021-02-16 Thread Dan Williams
On Tue, Feb 16, 2021 at 11:05 AM Dave Jiang wrote: > > > On 2/10/2021 4:59 PM, Jason Gunthorpe wrote: > > On Fri, Feb 05, 2021 at 01:53:24PM -0700, Dave Jiang wrote: > > > >> +static int check_vma(struct idxd_wq *wq, struct vm_area_struct *vma) > >> { > >> -/* FIXME: Fill in later */ > >> +

Re: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

2021-02-16 Thread Dave Jiang
On 2/10/2021 4:59 PM, Jason Gunthorpe wrote: On Fri, Feb 05, 2021 at 01:53:24PM -0700, Dave Jiang wrote: +static int check_vma(struct idxd_wq *wq, struct vm_area_struct *vma) { - /* FIXME: Fill in later */ + if (vma->vm_end < vma->vm_start) + return -EINVAL;

Re: [PATCH v5 05/14] vfio/mdev: idxd: add basic mdev registration and helper functions

2021-02-10 Thread Jason Gunthorpe
On Fri, Feb 05, 2021 at 01:53:24PM -0700, Dave Jiang wrote: > +static int check_vma(struct idxd_wq *wq, struct vm_area_struct *vma) > { > - /* FIXME: Fill in later */ > + if (vma->vm_end < vma->vm_start) > + return -EINVAL; These checks are redundant > -static int