From patchwork Wed Feb 25 04:20:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 443317 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E0F6A14008F for ; Wed, 25 Feb 2015 17:30:14 +1100 (AEDT) Received: from localhost ([::1]:53018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQVU4-0001i1-Lx for incoming@patchwork.ozlabs.org; Wed, 25 Feb 2015 01:30:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQVTl-00012H-Ka for qemu-devel@nongnu.org; Wed, 25 Feb 2015 01:29:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQVTh-0006xW-K0 for qemu-devel@nongnu.org; Wed, 25 Feb 2015 01:29:53 -0500 Received: from ozlabs.org ([103.22.144.67]:34584) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQVTh-0006vt-94 for qemu-devel@nongnu.org; Wed, 25 Feb 2015 01:29:49 -0500 Received: by ozlabs.org (Postfix, from userid 1011) id 18ABC14010F; Wed, 25 Feb 2015 17:29:43 +1100 (AEDT) From: Rusty Russell To: Cornelia Huck , virtualization@lists.linux-foundation.org, qemu-devel@nongnu.org, kvm@vger.kernel.org References: <1417101409-29482-1-git-send-email-cornelia.huck@de.ibm.com> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Wed, 25 Feb 2015 14:50:22 +1030 Message-ID: <877fv6mxkp.fsf@rustcorp.com.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 103.22.144.67 Cc: Cornelia Huck , thuth@linux.vnet.ibm.com, mst@redhat.com Subject: [Qemu-devel] Qemu and virtio 1.0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org OK, I am trying to experiment with virtio 1.0 support using the latest kernel and MST's qemu tree: https://git.kernel.org/cgit/virt/kvm/mst/qemu.git/?h=virtio-1.0 The first issue is that the device config endian was wrong (see attached patch). I'm now setting up a BE guest on my x86 laptop, and a BE and LE guest on a BE powerpc machine, to check that all combinations work correctly. If others test too, that would be appreciated! Cheers, Rusty. From 95ac91554ed602f856a2a5fcc25eaffcad1b1c8d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 24 Feb 2015 14:47:44 +1030 Subject: [PATCH] virtio_config_write*/virtio_config_read*: Don't endian swap for virtio 1.0. Signed-off-by: Rusty Russell diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 079944c..882a31b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -662,7 +662,12 @@ uint32_t virtio_config_readw(VirtIODevice *vdev, uint32_t addr) k->get_config(vdev, vdev->config); - val = lduw_p(vdev->config + addr); + /* Virtio 1.0 is always LE */ + if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + val = lduw_le_p(vdev->config + addr); + } else { + val = lduw_p(vdev->config + addr); + } return val; } @@ -677,7 +682,12 @@ uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t addr) k->get_config(vdev, vdev->config); - val = ldl_p(vdev->config + addr); + /* Virtio 1.0 is always LE */ + if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + val = ldl_le_p(vdev->config + addr); + } else { + val = ldl_p(vdev->config + addr); + } return val; } @@ -706,7 +716,12 @@ void virtio_config_writew(VirtIODevice *vdev, uint32_t addr, uint32_t data) return; } - stw_p(vdev->config + addr, val); + /* Virtio 1.0 is always LE */ + if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + stw_le_p(vdev->config + addr, val); + } else { + stw_p(vdev->config + addr, val); + } if (k->set_config) { k->set_config(vdev, vdev->config); @@ -722,7 +737,12 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data) return; } - stl_p(vdev->config + addr, val); + /* Virtio 1.0 is always LE */ + if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + stl_le_p(vdev->config + addr, val); + } else { + stl_p(vdev->config + addr, val); + } if (k->set_config) { k->set_config(vdev, vdev->config);