qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: qemu-devel@nongnu.org
Cc: aik@ozlabs.ru
Subject: [Qemu-devel] [PATCH 4/5] virtio-balloon: fixed endianness bug in the config space
Date: Thu,  7 Apr 2011 13:02:04 +1000	[thread overview]
Message-ID: <1302145325-4634-5-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1302145325-4634-1-git-send-email-david@gibson.dropbear.id.au>

From: Alexey Kardashevskiy <aik@ozlabs.ru>

The specification for the virtio balloon device requres that the values
in the config space be encoded little-endian.  This differs from most
virtio things, where guest-native endian is the norm.

Currently, the qemu virtio-balloon code correctly makes the conversion
on get_config(), but doesn't on set_config for the 'actual' field.  The
kernel driver, on the other hand, correctly converts when setting the
actual field, but does not convert when reading the config space.  The
upshot is that virtio-balloon will only work correctly if both host and
guest are LE, making all the conversions nops.

This patch corrects the qemu side, correctly doing host-native <-> LE
conversions when accessing the config space.  This won't break any setups
that aren't already broken, and fixes the case of BE host, LE guest.
Fixing the BE guest case will require kernel fixes as well.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/virtio-balloon.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index 8adddea..257baf8 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -191,7 +191,7 @@ static void virtio_balloon_set_config(VirtIODevice *vdev,
     VirtIOBalloon *dev = to_virtio_balloon(vdev);
     struct virtio_balloon_config config;
     memcpy(&config, config_data, 8);
-    dev->actual = config.actual;
+    dev->actual = le32_to_cpu(config.actual);
 }
 
 static uint32_t virtio_balloon_get_features(VirtIODevice *vdev, uint32_t f)
-- 
1.7.1

  parent reply	other threads:[~2011-04-07  3:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-07  3:02 [Qemu-devel] Assorted trivial bugfixes David Gibson
2011-04-07  3:02 ` [Qemu-devel] [PATCH 1/5] ppce500_mpc8544ds: Fix compile with --enable-debug and --disable-kvm David Gibson
2011-04-07  8:42   ` Alexander Graf
2011-04-07  8:52     ` Alexey Kardashevskiy
2011-04-07  9:06       ` Alexander Graf
2011-04-07  3:02 ` [Qemu-devel] [PATCH 2/5] spapr_llan: Fix warning when compiled with -dDEBUG David Gibson
2011-04-07  3:02 ` [Qemu-devel] [PATCH 3/5] virtio-9p: fixed LE-to-host conversion bug when QEMU is called from guest David Gibson
2011-04-07  3:02 ` David Gibson [this message]
2011-04-07  3:02 ` [Qemu-devel] [PATCH 5/5] virtio-serial: Fix endianness bug in the config space David Gibson
2011-04-07  8:57 ` [Qemu-devel] Assorted trivial bugfixes Stefan Hajnoczi
2011-04-08  3:46   ` David Gibson
2011-04-08  9:29     ` Stefan Hajnoczi

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=1302145325-4634-5-git-send-email-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=aik@ozlabs.ru \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).