Received: from [140.186.70.92] (port=40245 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7fUd-00029Y-L5 for qemu-devel@nongnu.org; Wed, 06 Apr 2011 23:02:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7fUc-0008C0-4c for qemu-devel@nongnu.org; Wed, 06 Apr 2011 23:02:47 -0400 Received: from ozlabs.org ([203.10.76.45]:45371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q7fUb-0008B9-Lw for qemu-devel@nongnu.org; Wed, 06 Apr 2011 23:02:46 -0400 From: David Gibson Date: Thu, 7 Apr 2011 13:02:04 +1000 Message-Id: <1302145325-4634-5-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1302145325-4634-1-git-send-email-david@gibson.dropbear.id.au> References: <1302145325-4634-1-git-send-email-david@gibson.dropbear.id.au> Subject: [Qemu-devel] [PATCH 4/5] virtio-balloon: fixed endianness bug in the config space List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aik@ozlabs.ru From: Alexey Kardashevskiy 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 Signed-off-by: David Gibson --- 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