vhost: Fix warnings and bad type handling
Subsystems (3)
PATCH 1/1 vhost: Fix warnings and bad type handling
---
drivers/vhost/vhost.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/vhost/vhost.c +4 -1
@@ -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 ));
Quoted 1 line · Alan Cox
Signed-off-by Alan Cox <[email protected]>
Thanks!
Quoted 11 lines
---
drivers/vhost/vhost.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)drivers/vhost/vhost.c +0
-0
drivers/vhost/vhost.c static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp) · line 338
Quoted 6 lines
drivers/vhost/vhost.c +2
-1@@ -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;
}Quoted 5 lines
drivers/vhost/vhost.c +2
-0+ 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 ));
Michael S. Tsirkin
maintainerFrom: Alan Cox <[email protected]>
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.
---
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(-)
drivers/vhost/vhost.c +4 -1
@@ -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 ));
Signature · 1 line
1.6.5.2.143.g8cc62
Rusty Russell
AppliedQuoted 8 lines · Michael S. Tsirkin
From: Alan Cox <[email protected]>
Subject: [PATCH] vhost: fix warnings on 32 bit systemsFix compiler warning about discarding top 32 bit of data on 32 bit systems, and document that dicarded bits must be 0.
Quoted 6 lines
Signed-off-by Alan Cox <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>---
So I think the below slightly tweaked version of Alan's patch is a bit better. OK?
Thanks, applied.
Rusty.
Rusty Russell
AppliedQuoted 8 lines · Michael S. Tsirkin
From: Alan Cox <[email protected]>
Subject: [PATCH] vhost: fix warnings on 32 bit systemsFix compiler warning about discarding top 32 bit of data on 32 bit systems, and document that dicarded bits must be 0.
Quoted 6 lines
Signed-off-by Alan Cox <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>---
So I think the below slightly tweaked version of Alan's patch is a bit better. OK?
Thanks, applied.
Rusty.
Michael S. Tsirkin
maintainerFrom: Alan Cox <[email protected]>
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.
---
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(-)
drivers/vhost/vhost.c +4 -1
@@ -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 ));
Signature · 1 line
1.6.5.2.143.g8cc62