All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vhost: Fix warnings and bad type handling
@ 2009-11-17 15:42 Alan Cox
  2009-11-22  9:36 ` Michael S. Tsirkin
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Alan Cox @ 2009-11-17 15:42 UTC (permalink / raw)
  To: mst, linux-kernel

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/vhost/vhost.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 97233d5..46b20f7 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -334,7 +334,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
 			r = -EINVAL;
 			break;
 		}
-		r = init_used(vq, (struct vring_used __user *)a.used_user_addr);
+		/* For 32bit we will ignore the top 32bits of the user
+		   data */
+		r = init_used(vq, (struct vring_used __user *)(unsigned long)
+						a.used_user_addr);
 		if (r)
 			break;
 		vq->log_used = !!(a.flags & (0x1 << VHOST_VRING_F_LOG));


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

* Re: [PATCH] vhost: Fix warnings and bad type handling
  2009-11-17 15:42 [PATCH] vhost: Fix warnings and bad type handling Alan Cox
@ 2009-11-22  9:36 ` Michael S. Tsirkin
  2009-11-22 10:28 ` Michael S. Tsirkin
  2009-11-22 10:28 ` Michael S. Tsirkin
  2 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2009-11-22  9:36 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

On Tue, Nov 17, 2009 at 03:42:15PM +0000, Alan Cox wrote:
> Signed-off-by: Alan Cox <alan@linux.intel.com>

Thanks!
Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
> 
>  drivers/vhost/vhost.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 97233d5..46b20f7 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -334,7 +334,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
>  			r = -EINVAL;
>  			break;
>  		}
> -		r = init_used(vq, (struct vring_used __user *)a.used_user_addr);
> +		/* For 32bit we will ignore the top 32bits of the user
> +		   data */

I am not sure this comment is helpful here: we actually verify that the
top 32 bits are set to 0, a couple of lines above this:

                if ((u64)(unsigned long)a.desc_user_addr != a.desc_user_addr ||
                    (u64)(unsigned long)a.used_user_addr != a.used_user_addr ||
                    (u64)(unsigned long)a.avail_user_addr != a.avail_user_addr) {
                        r = -EFAULT;
                        break;
                }


> +		r = init_used(vq, (struct vring_used __user *)(unsigned long)
> +						a.used_user_addr);
>  		if (r)
>  			break;
>  		vq->log_used = !!(a.flags & (0x1 << VHOST_VRING_F_LOG));

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

* Re: [PATCH] vhost: Fix warnings and bad type handling
  2009-11-17 15:42 [PATCH] vhost: Fix warnings and bad type handling Alan Cox
  2009-11-22  9:36 ` Michael S. Tsirkin
  2009-11-22 10:28 ` Michael S. Tsirkin
@ 2009-11-22 10:28 ` Michael S. Tsirkin
  2009-11-23  2:01   ` Rusty Russell
  2009-11-23  2:01   ` Rusty Russell
  2 siblings, 2 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2009-11-22 10:28 UTC (permalink / raw)
  To: Alan Cox, Rusty Russell, virtualization, kvm, linux-kernel


From: Alan Cox <alan@linux.intel.com>
Subject: [PATCH] vhost: fix warnings on 32 bit systems

Fix compiler warning about discarding top 32 bit
of data on 32 bit systems, and document that
dicarded bits must be 0.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

So I think the below slightly tweaked version of
Alan's patch is a bit better. OK?

 drivers/vhost/vhost.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 97233d5..e7b4dea 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -322,6 +322,8 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
 			r = -EOPNOTSUPP;
 			break;
 		}
+		/* For 32bit, verify that the top 32bits of the user
+		   data are set to zero. */
 		if ((u64)(unsigned long)a.desc_user_addr != a.desc_user_addr ||
 		    (u64)(unsigned long)a.used_user_addr != a.used_user_addr ||
 		    (u64)(unsigned long)a.avail_user_addr != a.avail_user_addr) {
@@ -334,7 +336,8 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
 			r = -EINVAL;
 			break;
 		}
-		r = init_used(vq, (struct vring_used __user *)a.used_user_addr);
+		r = init_used(vq, (struct vring_used __user *)(unsigned long)
+			      a.used_user_addr);
 		if (r)
 			break;
 		vq->log_used = !!(a.flags & (0x1 << VHOST_VRING_F_LOG));
-- 
1.6.5.2.143.g8cc62


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

* Re: [PATCH] vhost: Fix warnings and bad type handling
  2009-11-17 15:42 [PATCH] vhost: Fix warnings and bad type handling Alan Cox
  2009-11-22  9:36 ` Michael S. Tsirkin
@ 2009-11-22 10:28 ` Michael S. Tsirkin
  2009-11-22 10:28 ` Michael S. Tsirkin
  2 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2009-11-22 10:28 UTC (permalink / raw)
  To: Alan Cox, Rusty Russell, virtualization, kvm, linux-kernel


From: Alan Cox <alan@linux.intel.com>
Subject: [PATCH] vhost: fix warnings on 32 bit systems

Fix compiler warning about discarding top 32 bit
of data on 32 bit systems, and document that
dicarded bits must be 0.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

So I think the below slightly tweaked version of
Alan's patch is a bit better. OK?

 drivers/vhost/vhost.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 97233d5..e7b4dea 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -322,6 +322,8 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
 			r = -EOPNOTSUPP;
 			break;
 		}
+		/* For 32bit, verify that the top 32bits of the user
+		   data are set to zero. */
 		if ((u64)(unsigned long)a.desc_user_addr != a.desc_user_addr ||
 		    (u64)(unsigned long)a.used_user_addr != a.used_user_addr ||
 		    (u64)(unsigned long)a.avail_user_addr != a.avail_user_addr) {
@@ -334,7 +336,8 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
 			r = -EINVAL;
 			break;
 		}
-		r = init_used(vq, (struct vring_used __user *)a.used_user_addr);
+		r = init_used(vq, (struct vring_used __user *)(unsigned long)
+			      a.used_user_addr);
 		if (r)
 			break;
 		vq->log_used = !!(a.flags & (0x1 << VHOST_VRING_F_LOG));
-- 
1.6.5.2.143.g8cc62

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

* Re: [PATCH] vhost: Fix warnings and bad type handling
  2009-11-22 10:28 ` Michael S. Tsirkin
  2009-11-23  2:01   ` Rusty Russell
@ 2009-11-23  2:01   ` Rusty Russell
  1 sibling, 0 replies; 6+ messages in thread
From: Rusty Russell @ 2009-11-23  2:01 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Alan Cox, virtualization, kvm, linux-kernel

On Sun, 22 Nov 2009 08:58:01 pm Michael S. Tsirkin wrote:
> 
> From: Alan Cox <alan@linux.intel.com>
> Subject: [PATCH] vhost: fix warnings on 32 bit systems
> 
> Fix compiler warning about discarding top 32 bit
> of data on 32 bit systems, and document that
> dicarded bits must be 0.
> 
> Signed-off-by: Alan Cox <alan@linux.intel.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> So I think the below slightly tweaked version of
> Alan's patch is a bit better. OK?

Thanks, applied.

Rusty.

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

* Re: [PATCH] vhost: Fix warnings and bad type handling
  2009-11-22 10:28 ` Michael S. Tsirkin
@ 2009-11-23  2:01   ` Rusty Russell
  2009-11-23  2:01   ` Rusty Russell
  1 sibling, 0 replies; 6+ messages in thread
From: Rusty Russell @ 2009-11-23  2:01 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: virtualization, linux-kernel, kvm, Alan Cox

On Sun, 22 Nov 2009 08:58:01 pm Michael S. Tsirkin wrote:
> 
> From: Alan Cox <alan@linux.intel.com>
> Subject: [PATCH] vhost: fix warnings on 32 bit systems
> 
> Fix compiler warning about discarding top 32 bit
> of data on 32 bit systems, and document that
> dicarded bits must be 0.
> 
> Signed-off-by: Alan Cox <alan@linux.intel.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> So I think the below slightly tweaked version of
> Alan's patch is a bit better. OK?

Thanks, applied.

Rusty.

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

end of thread, other threads:[~2009-11-23  2:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-17 15:42 [PATCH] vhost: Fix warnings and bad type handling Alan Cox
2009-11-22  9:36 ` Michael S. Tsirkin
2009-11-22 10:28 ` Michael S. Tsirkin
2009-11-22 10:28 ` Michael S. Tsirkin
2009-11-23  2:01   ` Rusty Russell
2009-11-23  2:01   ` Rusty Russell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.