[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211015145921.0abf7cb0.alex.williamson@redhat.com>
Date: Fri, 15 Oct 2021 14:59:21 -0600
From: Alex Williamson <alex.williamson@...hat.com>
To: Jason Gunthorpe <jgg@...dia.com>
Cc: Yishai Hadas <yishaih@...dia.com>, bhelgaas@...gle.com,
saeedm@...dia.com, linux-pci@...r.kernel.org, kvm@...r.kernel.org,
netdev@...r.kernel.org, kuba@...nel.org, leonro@...dia.com,
kwankhede@...dia.com, mgurtovoy@...dia.com, maorg@...dia.com
Subject: Re: [PATCH V1 mlx5-next 11/13] vfio/mlx5: Implement vfio_pci driver
for mlx5 devices
On Fri, 15 Oct 2021 17:16:54 -0300
Jason Gunthorpe <jgg@...dia.com> wrote:
> On Fri, Oct 15, 2021 at 02:12:01PM -0600, Alex Williamson wrote:
> > On Fri, 15 Oct 2021 16:59:37 -0300
> > Jason Gunthorpe <jgg@...dia.com> wrote:
> >
> > > On Fri, Oct 15, 2021 at 01:48:20PM -0600, Alex Williamson wrote:
> > > > > +static int mlx5vf_pci_set_device_state(struct mlx5vf_pci_core_device *mvdev,
> > > > > + u32 state)
> > > > > +{
> > > > > + struct mlx5vf_pci_migration_info *vmig = &mvdev->vmig;
> > > > > + u32 old_state = vmig->vfio_dev_state;
> > > > > + int ret = 0;
> > > > > +
> > > > > + if (vfio_is_state_invalid(state) || vfio_is_state_invalid(old_state))
> > > > > + return -EINVAL;
> > > >
> > > > if (!VFIO_DEVICE_STATE_VALID(old_state) || !VFIO_DEVICE_STATE_VALID(state))
> > >
> > > AFAICT this macro doesn't do what is needed, eg
> > >
> > > VFIO_DEVICE_STATE_VALID(0xF000) == true
> > >
> > > What Yishai implemented is at least functionally correct - states this
> > > driver does not support are rejected.
> >
> >
> > if (!VFIO_DEVICE_STATE_VALID(old_state) || !VFIO_DEVICE_STATE_VALID(state)) || (state & ~VFIO_DEVICE_STATE_MASK))
> >
> > old_state is controlled by the driver and can never have random bits
> > set, user state should be sanitized to prevent setting undefined bits.
>
> In that instance let's just write
>
> old_state != VFIO_DEVICE_STATE_ERROR
>
> ?
Not quite, the user can't set either of the other invalid states
either.
>
> I'm happy to see some device specific mask selecting the bits it
> supports.
There are currently no optional bits within the mask, but the
RESUME|RUNNING state is rather TBD. I figured we'd use flags in the
region info to advertise additional feature bits when it comes to that.
Thanks,
Alex
Powered by blists - more mailing lists