public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio_ring: make structure defines packed
@ 2008-02-08 13:01 Christian Borntraeger
  2008-02-09  8:56 ` Arnd Bergmann
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Christian Borntraeger @ 2008-02-08 13:01 UTC (permalink / raw)
  To: virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: kvm-devel, Christian Ehrhardt

Currently the virtio_ring structure are not declared packed, but they 
describe an hardware like interface. We should not allow compilers to make 
alignments and optimizations that can be different between the guest and 
host compiler.

I propose to declare all structures that are in shared memory as packed.

Does anybody see a problem with packed?

Signed-off-by: Christian Borntraeger <borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
---
 include/linux/virtio_ring.h |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Index: kvm/include/linux/virtio_ring.h
===================================================================
--- kvm.orig/include/linux/virtio_ring.h
+++ kvm/include/linux/virtio_ring.h
@@ -35,14 +35,14 @@ struct vring_desc
 	__u16 flags;
 	/* We chain unused descriptors via this, too */
 	__u16 next;
-};
+} __attribute__ ((packed));
 
 struct vring_avail
 {
 	__u16 flags;
 	__u16 idx;
 	__u16 ring[];
-};
+} __attribute__ ((packed));
 
 /* u32 is used here for ids for padding reasons. */
 struct vring_used_elem
@@ -51,14 +51,15 @@ struct vring_used_elem
 	__u32 id;
 	/* Total length of the descriptor chain which was used (written to) */
 	__u32 len;
-};
+} __attribute__ ((packed));
 
 struct vring_used
 {
 	__u16 flags;
 	__u16 idx;
+	__u32 padding;
 	struct vring_used_elem ring[];
-};
+} __attribute__ ((packed));
 
 struct vring {
 	unsigned int num;

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

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

end of thread, other threads:[~2008-02-11 12:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-08 13:01 [PATCH] virtio_ring: make structure defines packed Christian Borntraeger
2008-02-09  8:56 ` Arnd Bergmann
2008-02-10  0:51 ` Anthony Liguori
2008-02-10  2:18   ` Arnd Bergmann
2008-02-10  6:32 ` ron minnich
2008-02-11 12:55   ` Christian Borntraeger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox