linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vdpa: Consider device id larger than 31
@ 2021-11-25 18:09 Parav Pandit
  2021-11-26  2:48 ` Jason Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Parav Pandit @ 2021-11-25 18:09 UTC (permalink / raw)
  To: virtualization, mst, jasowang
  Cc: edumazet, kbuild-all, lkp, linux-kernel, kbuild, elic,
	Parav Pandit, Dan Carpenter

virtio device id value can be more than 31. Hence, use BIT_ULL in
assignment.

Fixes: 33b347503f01 ("vdpa: Define vdpa mgmt device, ops and a netlink interface")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Parav Pandit <parav@nvidia.com>
---
 drivers/vdpa/vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 7332a74a4b00..e91c71aeeddf 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -404,7 +404,7 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m
 		goto msg_err;
 
 	while (mdev->id_table[i].device) {
-		supported_classes |= BIT(mdev->id_table[i].device);
+		supported_classes |= BIT_ULL(mdev->id_table[i].device);
 		i++;
 	}
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] vdpa: Consider device id larger than 31
  2021-11-25 18:09 [PATCH] vdpa: Consider device id larger than 31 Parav Pandit
@ 2021-11-26  2:48 ` Jason Wang
  2021-11-28  7:14   ` Eli Cohen
  0 siblings, 1 reply; 6+ messages in thread
From: Jason Wang @ 2021-11-26  2:48 UTC (permalink / raw)
  To: Parav Pandit
  Cc: virtualization, mst, Eric Dumazet, kbuild-all, kernel test robot,
	linux-kernel, kbuild, Eli Cohen, Dan Carpenter

On Fri, Nov 26, 2021 at 2:09 AM Parav Pandit <parav@nvidia.com> wrote:
>
> virtio device id value can be more than 31. Hence, use BIT_ULL in
> assignment.
>
> Fixes: 33b347503f01 ("vdpa: Define vdpa mgmt device, ops and a netlink interface")
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Parav Pandit <parav@nvidia.com>

Acked-by: Jason Wang <jasowang@redhat.com>

> ---
>  drivers/vdpa/vdpa.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index 7332a74a4b00..e91c71aeeddf 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -404,7 +404,7 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m
>                 goto msg_err;
>
>         while (mdev->id_table[i].device) {
> -               supported_classes |= BIT(mdev->id_table[i].device);
> +               supported_classes |= BIT_ULL(mdev->id_table[i].device);
>                 i++;
>         }
>
> --
> 2.26.2
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vdpa: Consider device id larger than 31
  2021-11-26  2:48 ` Jason Wang
@ 2021-11-28  7:14   ` Eli Cohen
  2021-11-28  7:45     ` Michael S. Tsirkin
  2021-11-29  6:58     ` Dan Carpenter
  0 siblings, 2 replies; 6+ messages in thread
From: Eli Cohen @ 2021-11-28  7:14 UTC (permalink / raw)
  To: Jason Wang
  Cc: Parav Pandit, virtualization, mst, Eric Dumazet, kbuild-all,
	kernel test robot, linux-kernel, kbuild, Dan Carpenter

On Fri, Nov 26, 2021 at 10:48:12AM +0800, Jason Wang wrote:
> On Fri, Nov 26, 2021 at 2:09 AM Parav Pandit <parav@nvidia.com> wrote:
> >
> > virtio device id value can be more than 31. Hence, use BIT_ULL in
> > assignment.
> >
> > Fixes: 33b347503f01 ("vdpa: Define vdpa mgmt device, ops and a netlink interface")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Parav Pandit <parav@nvidia.com>
> 
> Acked-by: Jason Wang <jasowang@redhat.com>
> 
> > ---
> >  drivers/vdpa/vdpa.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > index 7332a74a4b00..e91c71aeeddf 100644
> > --- a/drivers/vdpa/vdpa.c
> > +++ b/drivers/vdpa/vdpa.c
> > @@ -404,7 +404,7 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m
> >                 goto msg_err;
> >
> >         while (mdev->id_table[i].device) {
> > -               supported_classes |= BIT(mdev->id_table[i].device);
> > +               supported_classes |= BIT_ULL(mdev->id_table[i].device);
> >                 i++;
> >         }
> >

type of mdev->id_table[i].device is __u32 so in theory you're limited
to device ID's up to 63.
Maybe add assert here?

> > --
> > 2.26.2
> >
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vdpa: Consider device id larger than 31
  2021-11-28  7:14   ` Eli Cohen
@ 2021-11-28  7:45     ` Michael S. Tsirkin
  2021-11-29  6:58     ` Dan Carpenter
  1 sibling, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2021-11-28  7:45 UTC (permalink / raw)
  To: Eli Cohen
  Cc: Jason Wang, Parav Pandit, virtualization, Eric Dumazet,
	kbuild-all, kernel test robot, linux-kernel, kbuild,
	Dan Carpenter

On Sun, Nov 28, 2021 at 09:14:35AM +0200, Eli Cohen wrote:
> On Fri, Nov 26, 2021 at 10:48:12AM +0800, Jason Wang wrote:
> > On Fri, Nov 26, 2021 at 2:09 AM Parav Pandit <parav@nvidia.com> wrote:
> > >
> > > virtio device id value can be more than 31. Hence, use BIT_ULL in
> > > assignment.
> > >
> > > Fixes: 33b347503f01 ("vdpa: Define vdpa mgmt device, ops and a netlink interface")
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > Signed-off-by: Parav Pandit <parav@nvidia.com>
> > 
> > Acked-by: Jason Wang <jasowang@redhat.com>
> > 
> > > ---
> > >  drivers/vdpa/vdpa.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > > index 7332a74a4b00..e91c71aeeddf 100644
> > > --- a/drivers/vdpa/vdpa.c
> > > +++ b/drivers/vdpa/vdpa.c
> > > @@ -404,7 +404,7 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m
> > >                 goto msg_err;
> > >
> > >         while (mdev->id_table[i].device) {
> > > -               supported_classes |= BIT(mdev->id_table[i].device);
> > > +               supported_classes |= BIT_ULL(mdev->id_table[i].device);
> > >                 i++;
> > >         }
> > >
> 
> type of mdev->id_table[i].device is __u32 so in theory you're limited
> to device ID's up to 63.
> Maybe add assert here?

I think 1 << 63 is illegal though.

> > > --
> > > 2.26.2
> > >
> > 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vdpa: Consider device id larger than 31
  2021-11-28  7:14   ` Eli Cohen
  2021-11-28  7:45     ` Michael S. Tsirkin
@ 2021-11-29  6:58     ` Dan Carpenter
  2021-11-29  7:22       ` Parav Pandit
  1 sibling, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2021-11-29  6:58 UTC (permalink / raw)
  To: Eli Cohen
  Cc: Jason Wang, Parav Pandit, virtualization, mst, Eric Dumazet,
	kbuild-all, kernel test robot, linux-kernel, kbuild

On Sun, Nov 28, 2021 at 09:14:35AM +0200, Eli Cohen wrote:
> On Fri, Nov 26, 2021 at 10:48:12AM +0800, Jason Wang wrote:
> > On Fri, Nov 26, 2021 at 2:09 AM Parav Pandit <parav@nvidia.com> wrote:
> > >
> > > virtio device id value can be more than 31. Hence, use BIT_ULL in
> > > assignment.
> > >
> > > Fixes: 33b347503f01 ("vdpa: Define vdpa mgmt device, ops and a netlink interface")
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > Signed-off-by: Parav Pandit <parav@nvidia.com>
> > 
> > Acked-by: Jason Wang <jasowang@redhat.com>
> > 
> > > ---
> > >  drivers/vdpa/vdpa.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> > > index 7332a74a4b00..e91c71aeeddf 100644
> > > --- a/drivers/vdpa/vdpa.c
> > > +++ b/drivers/vdpa/vdpa.c
> > > @@ -404,7 +404,7 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m
> > >                 goto msg_err;
> > >
> > >         while (mdev->id_table[i].device) {
> > > -               supported_classes |= BIT(mdev->id_table[i].device);
> > > +               supported_classes |= BIT_ULL(mdev->id_table[i].device);
> > >                 i++;
> > >         }
> > >
> 
> type of mdev->id_table[i].device is __u32 so in theory you're limited
> to device ID's up to 63.

A u32 can fit numbers up to 4 million?  These .device numbers are
normally hardcoded defines listed in usr/include/linux/virtio_ids.h

But sometimes they're not like in vp_modern_probe() which does:

	mdev->id.device = pci_dev->device - 0x1040;

I don't know if an assert is really worth it, considering how almost all
of them are hardcoded.  Also if we do want an assert maybe there is a
better place to put it?

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] vdpa: Consider device id larger than 31
  2021-11-29  6:58     ` Dan Carpenter
@ 2021-11-29  7:22       ` Parav Pandit
  0 siblings, 0 replies; 6+ messages in thread
From: Parav Pandit @ 2021-11-29  7:22 UTC (permalink / raw)
  To: Dan Carpenter, Eli Cohen
  Cc: Jason Wang, virtualization, mst, Eric Dumazet, kbuild-all,
	kernel test robot, linux-kernel, kbuild



> From: Dan Carpenter <dan.carpenter@oracle.com>
> Sent: Monday, November 29, 2021 12:29 PM
> 
> On Sun, Nov 28, 2021 at 09:14:35AM +0200, Eli Cohen wrote:
> > On Fri, Nov 26, 2021 at 10:48:12AM +0800, Jason Wang wrote:
> > > On Fri, Nov 26, 2021 at 2:09 AM Parav Pandit <parav@nvidia.com> wrote:
> > > >
> > > > virtio device id value can be more than 31. Hence, use BIT_ULL in
> > > > assignment.
> > > >
> > > > Fixes: 33b347503f01 ("vdpa: Define vdpa mgmt device, ops and a
> > > > netlink interface")
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > > Signed-off-by: Parav Pandit <parav@nvidia.com>
> > >
> > > Acked-by: Jason Wang <jasowang@redhat.com>
> > >
> > > > ---
> > > >  drivers/vdpa/vdpa.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index
> > > > 7332a74a4b00..e91c71aeeddf 100644
> > > > --- a/drivers/vdpa/vdpa.c
> > > > +++ b/drivers/vdpa/vdpa.c
> > > > @@ -404,7 +404,7 @@ static int vdpa_mgmtdev_fill(const struct
> vdpa_mgmt_dev *mdev, struct sk_buff *m
> > > >                 goto msg_err;
> > > >
> > > >         while (mdev->id_table[i].device) {
> > > > -               supported_classes |= BIT(mdev->id_table[i].device);
> > > > +               supported_classes |=
> > > > + BIT_ULL(mdev->id_table[i].device);
> > > >                 i++;
> > > >         }
> > > >
> >
> > type of mdev->id_table[i].device is __u32 so in theory you're limited
> > to device ID's up to 63.
> 
> A u32 can fit numbers up to 4 million?  These .device numbers are normally
> hardcoded defines listed in usr/include/linux/virtio_ids.h
> 
> But sometimes they're not like in vp_modern_probe() which does:
> 
> 	mdev->id.device = pci_dev->device - 0x1040;
> 
> I don't know if an assert is really worth it, considering how almost all of them
> are hardcoded.  Also if we do want an assert maybe there is a better place to
> put it?
I am changing above fix to report device id only upto 63.
Others higher values (which are not part of the current spec) will be ignored.
There is no need for assert for any undefined value anyway.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-29  7:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 18:09 [PATCH] vdpa: Consider device id larger than 31 Parav Pandit
2021-11-26  2:48 ` Jason Wang
2021-11-28  7:14   ` Eli Cohen
2021-11-28  7:45     ` Michael S. Tsirkin
2021-11-29  6:58     ` Dan Carpenter
2021-11-29  7:22       ` Parav Pandit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).