Skip to contentSkip to conversation

virtio: fix vring_align() on 64-bit win32 platforms

PATCH Superseded Andrew Baumann 2 participants 3 messages Mar 24, 2017

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 virtio: fix vring_align() on 64-bit win32 platforms

long is 32-bits on win32, which caused the top half of the address to be truncated; this patch changes it to use the QEMU_ALIGN_UP macro which does not suffer the same problem

---
 include/hw/virtio/virtio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/virtio/virtio.h +1 -1
index 15efcf2..7b6edba 100644
@@ -34,7 +34,7 @@ struct VirtQueue;
 static inline hwaddr vring_align(hwaddr addr,
                                              unsigned long align)
 {
-    return (addr + align - 1) & ~(align - 1);
+    return QEMU_ALIGN_UP(addr, align);
 }
 
 typedef struct VirtQueue VirtQueue;
Signature · 1 line
2.8.3
Reviewed-by on v2 1/1
#1 lore raw

On 03/24/2017 04:21 PM, Andrew Baumann wrote:

So is 'win32' really a 64-bit platform, or should the subject be '64-bit windows'?

Quoted 9 lines

long is 32-bits on win32, which caused the top half of the address to be truncated; this patch changes it to use the QEMU_ALIGN_UP macro which does not suffer the same problem

---
 include/hw/virtio/virtio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
Quoted 5 lines

From: Eric Blake [mailto:[email protected]]
Sent: Friday, 24 March 2017 15:20

So is 'win32' really a 64-bit platform, or should the subject be '64-bit windows'?

Sigh. Yes, ok, it's a little silly if you put it like that. I guess I was thinking of the _WIN32 ifdef and the files named *win32.

I'll send you a v3...

Andrew