Skip to contentSkip to conversation

vhost: Fix compile time error

PATCH In review Guenter Roeck 2 participants 3 messages Sep 14, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: Fix compile time error

Building vhost on 32-bit targets results in the following error.

drivers/vhost/vhost.c: In function 'translate_desc':
include/linux/compiler.h:549:38: error:
call to '__compiletime_assert_1879' declared with attribute error:
BUILD_BUG_ON failed: sizeof(_s) > sizeof(long)

Fixes a89db445fbd7 ("vhost: block speculation of translated descriptors")
Cc Michael S. Tsirkin <[email protected]>
Cc Jason Wang <[email protected]>
---
 drivers/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +1 -1
index acabf20b069e..102a0c877007 100644
@@ -2074,7 +2074,7 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len,
 		_iov->iov_base = (void __user *)
 			((unsigned long)node->userspace_addr +
 			 array_index_nospec((unsigned long)(addr - node->start),
-					    node->size));
+					    (unsigned long)node->size));
 		s += size;
 		addr += size;
 		++ret;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 23 lines · Guenter Roeck

Building vhost on 32-bit targets results in the following error.

drivers/vhost/vhost.c: In function 'translate_desc':
include/linux/compiler.h:549:38: error:
call to '__compiletime_assert_1879' declared with attribute error:
BUILD_BUG_ON failed: sizeof(_s) > sizeof(long)

Fixes a89db445fbd7 ("vhost: block speculation of translated descriptors")
Cc Michael S. Tsirkin <[email protected]>
Cc Jason Wang <[email protected]>
---
 drivers/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +0 -0
index acabf20b069e..102a0c877007 100644

drivers/vhost/vhost.c static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len, · line 2077

Quoted 5 lines
drivers/vhost/vhost.c +1 -1
@@ -2074,7 +2074,7 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len,
 		_iov->iov_base = (void __user *)
 			((unsigned long)node->userspace_addr +
 			 array_index_nospec((unsigned long)(addr - node->start),
-					    node->size));
+					    (unsigned long)node->size));

Unfortunately this does not fix the case where size is actually 64 bit, e.g. a single node with VA 0, size 2^32 is how
you cover the whole virtual address space.

this is not how qemu uses it, but it's valid.

I think it's best to just revert the patch for now.

Quoted 5 lines
drivers/vhost/vhost.c +0 -0
 		s += size;
 		addr += size;
 		++ret;
Signature · 1 line
2.7.4
#2 lore raw
In reply to Guenter Roeck
Quoted 23 lines · Guenter Roeck

Building vhost on 32-bit targets results in the following error.

drivers/vhost/vhost.c: In function 'translate_desc':
include/linux/compiler.h:549:38: error:
call to '__compiletime_assert_1879' declared with attribute error:
BUILD_BUG_ON failed: sizeof(_s) > sizeof(long)

Fixes a89db445fbd7 ("vhost: block speculation of translated descriptors")
Cc Michael S. Tsirkin <[email protected]>
Cc Jason Wang <[email protected]>
---
 drivers/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +0 -0
index acabf20b069e..102a0c877007 100644

drivers/vhost/vhost.c static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len, · line 2077

Quoted 5 lines
drivers/vhost/vhost.c +1 -1
@@ -2074,7 +2074,7 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len,
 		_iov->iov_base = (void __user *)
 			((unsigned long)node->userspace_addr +
 			 array_index_nospec((unsigned long)(addr - node->start),
-					    node->size));
+					    (unsigned long)node->size));

Unfortunately this does not fix the case where size is actually 64 bit, e.g. a single node with VA 0, size 2^32 is how
you cover the whole virtual address space.

this is not how qemu uses it, but it's valid.

I think it's best to just revert the patch for now.

Quoted 5 lines
drivers/vhost/vhost.c +0 -0
 		s += size;
 		addr += size;
 		++ret;
Signature · 1 line
2.7.4