From: "Michael S. Tsirkin" <mst@redhat.com>
To: Greg Kurz <gkurz@linux.vnet.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
virtualization@lists.linux-foundation.org
Subject: Re: [Qemu-devel] [PATCH] virtio-pci: fix host notifiers on bi-endian architectures
Date: Wed, 11 Mar 2015 21:06:05 +0100 [thread overview]
Message-ID: <20150311210322-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <20150311180212.8119.14734.stgit@bahia.local>
On Wed, Mar 11, 2015 at 07:04:38PM +0100, Greg Kurz wrote:
> vhost is seriously broken with ppc64le guests, even in the supposedly
> supported case where the host is ppc64le and we don't need cross-endian
> support.
>
> The TX virtqueue fails to be handled by vhost and falls back to QEMU.
> Despite this unexpected scenario where RX is vhost and TX is QEMU, the
> guest runs well with reduced upload performances... until you reboot,
> migrate, managed save or in fact any operation that causes vhost_net
> to be re-started. Network connectivity is then permanantly lost for
> the guest.
>
> TX falling back to QEMU is the result of a failed MMIO store emulation
> in KVM. Debugging shows that:
>
> kvmppc_emulate_mmio()
> |
> +-> kvmppc_handle_store()
> |
> +-> kvm_io_bus_write()
> |
> +-> __kvm_io_bus_write() returns -EOPNOTSUPP
>
> This happens because no matching device was found:
>
> __kvm_io_bus_write()
> |
> +->kvm_iodevice_write()
> |
> +->ioeventfd_write()
> |
> +->ioeventfd_in_range() returns false for all registered vrings
>
> Extra debugging shows that the TX vring number (16-bit) is supposed to
> be 0x0100 but QEMU passes 0x0001 to KVM... This happens *again* because
> QEMU still assumes powerpc is big endian (TARGET_WORDS_BIGENDIAN) by
> default.
>
> This patch adds an extra swap in virtio_pci_set_host_notifier_internal()
> to negate the one that is done in adjust_endianness(). Since this is not
> a hot path and we want to keep virtio-pci.o in common-obj, we don't care
> whether the guest is bi-endian or not.
>
> Reported-by: Cédric Le Goater <clg@fr.ibm.com>
> Suggested-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
I am confused.
The value that notifications use is always LE.
Can't we avoid multiple swaps?
They make my head spin.
> ---
>
> I guess it is also a fix for virtio-1 but I didn't check.
>
> hw/virtio/virtio-pci.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index e7baf7b..62b04c9 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -133,6 +133,11 @@ static int virtio_pci_load_queue(DeviceState *d, int n, QEMUFile *f)
> return 0;
> }
>
> +static uint16_t cpu_to_host_notifier16(VirtIODevice *vdev, uint16_t val)
> +{
> + return virtio_is_big_endian(vdev) ? val : bswap16(val);
> +}
> +
> static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy,
> int n, bool assign, bool set_handler)
> {
> @@ -150,10 +155,12 @@ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy,
> }
> virtio_queue_set_host_notifier_fd_handler(vq, true, set_handler);
> memory_region_add_eventfd(&proxy->bar, VIRTIO_PCI_QUEUE_NOTIFY, 2,
> - true, n, notifier);
> + true, cpu_to_host_notifier16(vdev, n),
> + notifier);
> } else {
> memory_region_del_eventfd(&proxy->bar, VIRTIO_PCI_QUEUE_NOTIFY, 2,
> - true, n, notifier);
> + true, cpu_to_host_notifier16(vdev, n),
> + notifier);
> virtio_queue_set_host_notifier_fd_handler(vq, false, false);
> event_notifier_cleanup(notifier);
> }
next prev parent reply other threads:[~2015-03-11 20:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-11 18:04 [Qemu-devel] [PATCH] virtio-pci: fix host notifiers on bi-endian architectures Greg Kurz
2015-03-11 20:06 ` Michael S. Tsirkin [this message]
2015-03-11 22:03 ` Greg Kurz
2015-03-11 22:18 ` [Qemu-devel] [Qemu-ppc] " Benjamin Herrenschmidt
2015-03-11 22:52 ` Greg Kurz
2015-03-12 7:10 ` Michael S. Tsirkin
2015-03-12 7:08 ` [Qemu-devel] " Michael S. Tsirkin
2015-03-12 16:25 ` Paolo Bonzini
2015-03-13 8:03 ` Greg Kurz
2015-03-13 8:11 ` [Qemu-devel] [PATCH 1/2] memory: make adjust_endianness() generic Greg Kurz
2015-03-13 8:11 ` [Qemu-devel] [PATCH 2/2] memory: fix the eventfd data endianness according to the host Greg Kurz
2015-03-13 11:06 ` Paolo Bonzini
2015-03-13 11:32 ` Greg Kurz
2015-03-13 14:52 ` Paolo Bonzini
2015-03-13 15:24 ` Michael S. Tsirkin
2015-03-13 14:23 ` Michael S. Tsirkin
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=20150311210322-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=clg@fr.ibm.com \
--cc=gkurz@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=virtualization@lists.linux-foundation.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).