Skip to content

Commit b28e050

Browse files
committed
virtio_ring: document alignment requirements
Host needs to know vring element alignment requirements: simply doing alignof on structures doesn't work reliably: on some platforms gcc has alignof(uint32_t) == 2. Add macros for alignment as specified in virtio 1.0 cs01, export them to userspace as well. Acked-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent b7392d2 commit b28e050

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/uapi/linux/virtio_ring.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ struct vring {
101101
struct vring_used *used;
102102
};
103103

104+
/* Alignment requirements for vring elements.
105+
* When using pre-virtio 1.0 layout, these fall out naturally.
106+
*/
107+
#define VRING_AVAIL_ALIGN_SIZE 2
108+
#define VRING_USED_ALIGN_SIZE 4
109+
#define VRING_DESC_ALIGN_SIZE 16
110+
104111
/* The standard layout for the ring is a continuous chunk of memory which looks
105112
* like this. We assume num is a power of 2.
106113
*

0 commit comments

Comments
 (0)