linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mst@redhat.com (Michael S. Tsirkin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/3] virtio-mmio: handle BE guests on LE hosts
Date: Tue, 15 Oct 2013 09:38:31 +0300	[thread overview]
Message-ID: <20131015063831.GA19143@redhat.com> (raw)
In-Reply-To: <874n8jbfoa.fsf@rustcorp.com.au>

On Tue, Oct 15, 2013 at 09:53:17AM +1030, Rusty Russell wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> > On Mon, Oct 14, 2013 at 06:50:48PM +0200, Paolo Bonzini wrote:
> >> Il 14/10/2013 17:36, Marc Zyngier ha scritto:
> >> >> > 
> >> >> > Devices are fine in QEMU, it's only the "generic" parts (rings) that are
> >> >> > missing AFAICT.
> >> > So if I understand correctly how it works, target endianness is set at
> >> > compile time, and you have a BE specific QEMU?
> >> 
> >> Yes.  Though as Alex said, this will have to change for PPC
> >> little-endian support.
> >> 
> >> Paolo
> >
> > Or we'll just say that this platform requires virtio 1.0.
> 
> To come full circle, I have implemented virtio support for BE PPC in
> qemu :) And we'll be supporting pre-1.0 for the moment. I'm awaiting
> some ppc-specific hooks, but it could be merged without them.
> 
> It's icky: we don't really want to use the current endianness of the
> CPU, since in theory a BE kernel could be running an LE process.  So at
> the time of virtio device reset (the first thing the Linux drivers do)
> we read the endianness of the interrupt entry point, which is presumably
> the OS endianness.

Indeed, ick.
The next thing after reset is status write:

        /* We always start by resetting the device, in case a previous
         * driver messed it up.  This also tests that code path a
         * little. */
        dev->config->reset(dev);

        /* Acknowledge that we've seen the device. */
        add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE);

and mmio happens to use a 32 bit register for this:

	static void vm_set_status(struct virtio_device *vdev, u8 status)
	{
		struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);

		/* We should never be setting status to 0. */
		BUG_ON(status == 0);

		writel(status, vm_dev->base + VIRTIO_MMIO_STATUS);
	}

so if we only care about mmio, we can use the status write
to detect endian-ness: low byte set means LE, high byte set
means BE, which seems cleaner.

Hmm?

-- 
MST

  reply	other threads:[~2013-10-15  6:38 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-11 14:36 [PATCH 0/3] virtio-mmio: handle BE guests on LE hosts Marc Zyngier
2013-10-11 14:36 ` [PATCH 1/3] virtio: let the guest report its endianess if advertized by the host Marc Zyngier
2013-10-11 14:36 ` [PATCH 2/3] virtio: mmio: fix signature checking for BE guests Marc Zyngier
2013-10-14  8:46   ` Pawel Moll
2013-10-14  9:11     ` Rusty Russell
2013-11-05  3:36       ` Rusty Russell
2013-11-05 10:45         ` Pawel Moll
2013-11-07  0:36           ` Rusty Russell
2013-10-11 14:36 ` [PATCH 3/3] virtio: mmio: access configuration space as little-endian Marc Zyngier
2013-10-14  8:44   ` Pawel Moll
2013-10-12 18:28 ` [PATCH 0/3] virtio-mmio: handle BE guests on LE hosts Michael S. Tsirkin
2013-10-14  8:24   ` Marc Zyngier
2013-10-14  8:59     ` Michael S. Tsirkin
2013-10-14  9:04       ` Pawel Moll
2013-10-14 10:46         ` Michael S. Tsirkin
2013-10-14 10:50           ` Pawel Moll
2013-10-14 23:02             ` Rusty Russell
2013-10-14  9:13     ` Rusty Russell
2013-10-14  8:21 ` Rusty Russell
2013-10-14 12:36   ` Marc Zyngier
2013-10-14 12:51     ` Michael S. Tsirkin
2013-10-17  0:27     ` Rusty Russell
2013-10-14 13:03 ` Paolo Bonzini
2013-10-14 13:10   ` Alexander Graf
2013-10-14 13:13     ` Paolo Bonzini
2013-10-14 13:24     ` Marc Zyngier
2013-10-14 13:29       ` Paolo Bonzini
2013-10-14 13:39       ` Alexander Graf
2013-10-14 13:49         ` Marc Zyngier
2013-10-14 14:05           ` Michael S. Tsirkin
2013-10-14 14:13             ` Marc Zyngier
2013-10-14 14:16               ` Alexander Graf
2013-10-14 14:52                 ` Marc Zyngier
2013-10-14 14:56                   ` Paolo Bonzini
2013-10-14 15:12                     ` Marc Zyngier
2013-10-14 15:22                       ` Paolo Bonzini
2013-10-14 15:36                         ` Marc Zyngier
2013-10-14 16:50                           ` Paolo Bonzini
2013-10-14 17:10                             ` Michael S. Tsirkin
2013-10-14 23:23                               ` Rusty Russell
2013-10-15  6:38                                 ` Michael S. Tsirkin [this message]
2013-10-15  9:19                                   ` Marc Zyngier
2013-10-14 15:45                         ` Anup Patel

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=20131015063831.GA19143@redhat.com \
    --to=mst@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.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).