qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Liu Ping Fan" <pingfank@linux.vnet.ibm.com>,
	"Alexander Graf" <agraf@suse.de>,
	"qemu-devel Developers" <qemu-devel@nongnu.org>,
	"qemu-ppc@nongnu.org list:PowerPC" <qemu-ppc@nongnu.org>,
	"Anthony Liguori" <anthony@codemonkey.ws>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Jan Kiszka" <jan.kiszka@web.de>,
	"Andreas Färber" <afaerber@suse.de>,
	"Hervé Poussineau" <hpoussin@reactos.org>
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH v3 11/14] ioport: Switch dispatching to memory core layer
Date: Sat, 13 Jul 2013 08:50:27 +1000	[thread overview]
Message-ID: <1373669427.19894.202.camel@pasglop> (raw)
In-Reply-To: <CAFEAcA_okAq8noQSJeS-Kb9rfT43bu+m3c0cdjMuaOg7OVzp4g@mail.gmail.com>

On Fri, 2013-07-12 at 19:26 +0100, Peter Maydell wrote:

> It's not wrong when the hardware actually does a byteswap at
> some level in the memory hierarchy. You can see this for instance
> on ARMv7M systems, where byteswapping for bigendian happens at
> an intermediate level that not all accesses go through:
> 
>  [CPU] ---->  [byteswap here] --> [memory and ext. devices]
>          |
>          -->  [internal memory mapped devices]
> 
> so some things see always little endian regardless.

Ugh ? That's so completely fucked up, if that's indeed what the HW is
doing this is a piece of trash and the designers are in urgent need of
being turned into fertilizer.

Unless again you are talking about "lane swapping" which allows to
preserve the byte address invariance when the CPU decides to flip its
bus around, but I would have thought that modern CPUs do not do that
sort of shit anymore.

In any case, it cannot be represented with an "endian" attribute at the
bridge level, that doesn't mean anything. Again, the only endian
attribute that exists are the byte order of the original access (which
byte has the lowest address, regardless of significance of those bytes
in the target, ie, purely from a qemu standpoint, in the variable that
carries the access around inside qemu, which byte has the lowest
address), and the same on the target device (at which point a concept of
significance does apply, but it's a guest driver business to get it
right, qemu just need to make sure byte 0 goes to byte 0).

If a bridge flips things around in a way that breaks the model, then add
some property describing the flipping properties but don't call it "big
endian" or "little endian" at the bridge level, that has no meaning,
confuses things and introduces breakage like we have seen.

> >> The whole business of endianness in qemu is a mess. In the end what
> >> matters and the only thing that does is:
> >
> > It's not as bad as you think I suspect.
> >
> >>  * The endianness of a given memory access by the guest (which may or
> >> may not be the endianness of the guest -> MSR:LE, byteswap load/store
> >> instsructions, etc..)
> >
> > Correct.
> >
> >> vs.
> >>
> >>  * The endianness of the target device register (and I say register ...
> >> a framebuffer does NOT have endianness per-se and thus accesses to BAR
> >> mapping a "memory" range (framebuffer, ROM, ...) should go such that the
> >> *byte order* of individual bytes is preserved, which typically means
> >> untranslated).
> >
> > Yes.  To put it another way, an MMIO write is a store and depending on
> > the VCPU, that will result in a write with a certain byte order.  That
> > byte order should be preserved.
> >
> > However, what we don't model today, and why we have the silly
> > endianness in MemoryRegionOps, is the fact that I/O may pass through
> > multiple layers and those layers may change byte ordering.
> >
> > We jump through great hoops to have a flat dispatch table.  I've never
> > liked it but that's what we do.  That means that in cases where a host
> > bridge may do byte swapping, we cannot easily support that.
> 
> We could support that if we cared to -- you just have to have a
> container MemoryRegion type which is a byte-swapping container
> (or just have a flag on existing containers, I suppose).
> Then as you flatten the regions into the flat table you keep
> track of how many levels of byteswapping each region goes through,
> and you end up with a single 'byteswap or not?' flag for each
> section of your flat dispatch table.
> 
> (Our other serious endianness problem is that we don't really
> do very well at supporting a TCG CPU arbitrarily flipping
> endianness -- TARGET_WORDS_BIGENDIAN is a compile time setting
> and ideally it should not be.)

Our experience is that it actually works fine for almost everything
except virtio :-) ie mostly TARGET_WORDS_BIGENDIAN is irrelevant (and
should be).

Cheers,
Ben.

  reply	other threads:[~2013-07-12 22:50 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-22  6:06 [Qemu-devel] [PATCH v3 00/14] Refactor portio dispatching Jan Kiszka
2013-06-22  6:06 ` [Qemu-devel] [PATCH v3 01/14] adlib: replace register_ioport* Jan Kiszka
2013-06-22  6:06 ` [Qemu-devel] [PATCH v3 02/14] applesmc: " Jan Kiszka
2013-06-22  6:06 ` [Qemu-devel] [PATCH v3 03/14] wdt_ib700: " Jan Kiszka
2013-06-22  6:06 ` [Qemu-devel] [PATCH v3 04/14] i82374: " Jan Kiszka
2013-06-22  6:06 ` [Qemu-devel] [PATCH v3 05/14] prep: " Jan Kiszka
2013-06-22  6:06 ` [Qemu-devel] [PATCH v3 06/14] vt82c686: " Jan Kiszka
2013-06-22  6:07 ` [Qemu-devel] [PATCH v3 07/14] Privatize register_ioport_read/write Jan Kiszka
2013-06-22  6:07 ` [Qemu-devel] [PATCH v3 08/14] isa: implement isa_is_ioport_assigned via memory_region_find Jan Kiszka
2013-06-22  6:07 ` [Qemu-devel] [PATCH v3 09/14] vmware-vga: Accept unaligned I/O accesses Jan Kiszka
2013-06-22  6:07 ` [Qemu-devel] [PATCH v3 10/14] xen: Mark fixed platform I/O as unaligned Jan Kiszka
2013-06-22  6:07 ` [Qemu-devel] [PATCH v3 11/14] ioport: Switch dispatching to memory core layer Jan Kiszka
2013-06-23 20:50   ` Hervé Poussineau
2013-06-24  6:07     ` Jan Kiszka
2013-07-11 12:29       ` Alexander Graf
2013-07-11 12:34         ` Alexander Graf
2013-07-11 12:46           ` Andreas Färber
2013-07-11 12:48             ` Alexander Graf
2013-07-11 13:28               ` Alexander Graf
2013-07-11 13:35                 ` Alexander Graf
2013-07-11 22:30                 ` [Qemu-devel] [Qemu-ppc] " Benjamin Herrenschmidt
2013-07-11 22:32                 ` Benjamin Herrenschmidt
2013-07-12  3:18                   ` Alexander Graf
2013-07-12 11:35                     ` Benjamin Herrenschmidt
2013-07-12 17:04                       ` Hervé Poussineau
2013-07-12 19:06                         ` Anthony Liguori
2013-07-12 22:59                           ` Benjamin Herrenschmidt
2013-07-12 22:39                         ` Benjamin Herrenschmidt
2013-07-12 17:49                       ` Anthony Liguori
2013-07-12 18:26                         ` Peter Maydell
2013-07-12 22:50                           ` Benjamin Herrenschmidt [this message]
2013-07-12 23:10                             ` Peter Maydell
2013-07-12 23:49                               ` Benjamin Herrenschmidt
2013-07-15 14:01                               ` Anthony Liguori
2013-07-15 14:10                                 ` Peter Maydell
2013-07-15 14:16                                 ` Benjamin Herrenschmidt
2013-07-12 22:44                         ` Benjamin Herrenschmidt
2013-07-13 14:38             ` [Qemu-devel] " Paolo Bonzini
2013-07-13 15:22               ` Anthony Liguori
2013-07-13 18:11                 ` Hervé Poussineau
2013-07-14  6:15                 ` Paolo Bonzini
2013-07-14 13:05                   ` Anthony Liguori
2013-07-14 14:58                     ` Peter Maydell
2013-07-14 15:18                       ` Anthony Liguori
2013-07-14 16:50                         ` Peter Maydell
2013-07-16  7:18                         ` Jan Kiszka
2013-07-16  7:33                           ` Paolo Bonzini
2013-07-16 16:59                             ` Hervé Poussineau
2013-07-16 17:12                               ` Paolo Bonzini
2013-07-12 12:56           ` Anthony Liguori
2013-07-12 14:30             ` Alexander Graf
2013-07-19 11:09         ` [Qemu-devel] BUG: " Alexey Kardashevskiy
2013-07-19 12:49           ` Paolo Bonzini
2013-07-19 15:48             ` Alexey Kardashevskiy
2013-07-20  0:55               ` Alexey Kardashevskiy
2013-07-20  1:11                 ` Alexey Kardashevskiy
2013-07-20 10:11                   ` Paolo Bonzini
2013-07-20 20:53                     ` Edgar E. Iglesias
2013-07-21 15:13                     ` Hervé Poussineau
2013-07-22 10:25                       ` Paolo Bonzini
2013-06-24  8:45     ` [Qemu-devel] [PATCH v4 " Jan Kiszka
2013-07-12 19:36     ` [Qemu-devel] [PATCH v3 " Anthony Liguori
2013-06-22  6:07 ` [Qemu-devel] [PATCH v3 12/14] ioport: Remove unused old dispatching services Jan Kiszka
2013-06-22  6:07 ` [Qemu-devel] [PATCH v3 13/14] vmport: Disentangle read handler type from portio Jan Kiszka
2013-06-22  6:07 ` [Qemu-devel] [PATCH v3 14/14] ioport: Move portio types to ioport.h Jan Kiszka
2013-06-23 20:45 ` [Qemu-devel] [PATCH v3 00/14] Refactor portio dispatching Hervé Poussineau

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=1373669427.19894.202.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=hpoussin@reactos.org \
    --cc=jan.kiszka@web.de \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=pingfank@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).