From: Christian Borntraeger <borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
To: virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: kvm-devel
<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
Christian Ehrhardt
<ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Subject: [PATCH] virtio_ring: make structure defines packed
Date: Fri, 8 Feb 2008 14:01:21 +0100 [thread overview]
Message-ID: <200802081401.21194.borntraeger@de.ibm.com> (raw)
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/
next reply other threads:[~2008-02-08 13:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-08 13:01 Christian Borntraeger [this message]
2008-02-09 8:56 ` [PATCH] virtio_ring: make structure defines packed 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200802081401.21194.borntraeger@de.ibm.com \
--to=borntraeger-ta70fqpds9bqt0dzr+alfa@public.gmane.org \
--cc=ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox