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: Alexey Kardashevskiy <aik@ozlabs.ru>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Alexander Graf <agraf@suse.de>, Gerd Hoffmann <kraxel@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Greg Kurz <gkurz@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [RFC] qemu VGA endian swap low level drawing changes
Date: Tue, 17 Jun 2014 20:57:46 +1000	[thread overview]
Message-ID: <1403002666.7661.142.camel@pasglop> (raw)
In-Reply-To: <CAFEAcA9mqow=-1AP1LZWocj7JsPZQfsL6nWAwLY-Ly5ij23kpQ@mail.gmail.com>

On Tue, 2014-06-17 at 11:19 +0100, Peter Maydell wrote:
> On 17 June 2014 11:09, Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> > On Tue, 2014-06-17 at 12:00 +0200, Greg Kurz wrote:
> >> There has been a discussion already about virtio endianness: relying on
> >> a guest system wide setting such as LPCR_ILE has been strongly rejected
> >> at the time... The consensus for virtio is "device endianness is the
> >> endianness of the CPU that does the reset" (hence MSR_LE for PPC).
> >
> > How on earth did anybody reach such a conclusion ? Of all the possible
> > options I can think of this is the one that makes the *less* sense !
> 
> Well, the right conclusion is "virtio should have specified
> endianness sanely, ie to be independent of the CPU". However
> we can't rewind time to make that decision correctly, so this
> is the best we can usefully do without breaking existing
> working guests.

Agreed about original breakage.

> It's absolutely a virtio-specific thing, though, given that
> virtio has the weird "endianness of the guest" semantics in
> it, so it's not a good model for anything else.
> 
> My personal opinion here is that device models should just
> have a fixed byte order, and the guest should deal with it
> (except in the cases where we're modelling real hardware
> which has a real config register for flipping byte order,
> in which case the answer is "work like that hardware").
> So I'm still really dubious about adding endian swapping to
> the VGA model at all. Why can't you just have the guest
> do the right thing?

I absolutely agree with you on the fixed byte order model.

Sadly, graphics carries a very long legacy of brokenness in that area
that we really can't fix easily.

X assumes at compile time pretty much a native byte order and expresses
color components locations as masks and shifts inside the N-bit "words"
based on the pixel BPP. There are ways to play with the masks and shifts
for 32bpp to work but 15/16 is always busted when the green gets split,
X really can't deal with it.

But that's the tip of the iceberg. Those assumptions about pixel formats
percolate all the way through the gfx stack, it's a real mess. For GL,
for example, an ARGB format is not A,R,G,B in memory in that order but
"ARGB" from MSB to LSB in the smallest word loaded that can encompass
the pixel size (Funnily enough, I heard Direct X got that right !) and
layers of code exist out there that just can't deal with "the other
way".

This is why graphics card have historically carried all sort of weird
byte swapping hardware, more or less working, trying to solve that at
the HW level because SW is basically a trainwreck :-)

Now, Egbert is still trying to make base X and qt5 at least somewhat
work with the reverse order at least for 32bpp, but that's mostly an
academic exercise at this stage.

So yes, you are absolutely right for the general case. But graphics
sadly has to be the exception to the rule.

Cheers,
Ben.

> thanks
> -- PMM

  reply	other threads:[~2014-06-17 10:58 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-17  3:07 [Qemu-devel] [RFC] qemu VGA endian swap low level drawing changes Benjamin Herrenschmidt
2014-06-17  4:40 ` Paolo Bonzini
2014-06-17  4:59   ` Benjamin Herrenschmidt
2014-06-17  5:36     ` Paolo Bonzini
2014-06-17  6:06       ` Benjamin Herrenschmidt
2014-06-17  9:18       ` Alexey Kardashevskiy
2014-06-17  9:26         ` Alexander Graf
2014-06-17 10:00         ` Greg Kurz
2014-06-17 10:09           ` Benjamin Herrenschmidt
2014-06-17 10:19             ` Peter Maydell
2014-06-17 10:57               ` Benjamin Herrenschmidt [this message]
2014-06-17 11:40             ` Greg Kurz
2014-06-17 11:53               ` Benjamin Herrenschmidt
2014-06-17 12:05                 ` Peter Maydell
2014-06-17 10:45 ` Gerd Hoffmann
2014-06-17 11:08   ` Peter Maydell
2014-06-17 11:24     ` Gerd Hoffmann
2014-06-17 11:42       ` Peter Maydell
2014-06-19 12:33         ` Gerd Hoffmann
2014-06-19 13:01           ` Paolo Bonzini
2014-06-17 11:15   ` Benjamin Herrenschmidt
2014-06-17 11:57     ` Gerd Hoffmann
2014-06-17 21:32       ` Benjamin Herrenschmidt
2014-06-17 22:12         ` Peter Maydell
2014-06-17 22:55           ` Benjamin Herrenschmidt
2014-06-17 23:05             ` Alexander Graf
2014-06-17 23:16               ` Benjamin Herrenschmidt
2014-06-18 11:18         ` Gerd Hoffmann
2014-06-18 13:03           ` Benjamin Herrenschmidt
2014-06-19  9:36             ` Gerd Hoffmann
2014-06-21  5:37               ` Benjamin Herrenschmidt
2014-06-22  2:10                 ` Benjamin Herrenschmidt
2014-06-23  1:13                   ` Benjamin Herrenschmidt
2014-06-30 11:14                   ` Gerd Hoffmann
2014-06-30 12:32                     ` Benjamin Herrenschmidt
2014-07-01  8:20                       ` Gerd Hoffmann
2014-07-01  8:26                         ` Alexander Graf
2014-07-01  8:31                           ` Paolo Bonzini
2014-07-01  9:07                             ` Gerd Hoffmann
2014-07-01  9:19                               ` Paolo Bonzini
2014-07-01 11:15                                 ` Gerd Hoffmann
2014-07-01 11:23                                   ` Benjamin Herrenschmidt
2014-07-02  9:19                                     ` Benjamin Herrenschmidt
2014-07-02  9:21                                       ` Benjamin Herrenschmidt
2014-07-02 12:12                                       ` Gerd Hoffmann
2014-07-02 12:16                                         ` Benjamin Herrenschmidt
2014-07-06  2:19                                         ` Benjamin Herrenschmidt
2014-07-06  5:49                                           ` Benjamin Herrenschmidt
2014-07-06  6:46                                             ` Benjamin Herrenschmidt
2014-07-06  7:05                                               ` Benjamin Herrenschmidt
2014-07-06  7:22                                                 ` Benjamin Herrenschmidt
2014-07-06  8:15                                                   ` Benjamin Herrenschmidt
2014-07-06 10:13                                                   ` Benjamin Herrenschmidt
2014-07-06 11:08                                                     ` Alexander Graf
2014-07-06 11:13                                                       ` Peter Maydell
2014-07-06 11:23                                                         ` Benjamin Herrenschmidt
2014-07-06 13:09                                                           ` Peter Maydell
2014-07-06 20:56                                                             ` Benjamin Herrenschmidt
2014-07-07  0:08                                                               ` Benjamin Herrenschmidt
2014-07-07 10:13                                                       ` Gerd Hoffmann
2014-07-07  9:38                                                   ` Gerd Hoffmann
2014-07-06  5:53                                           ` Benjamin Herrenschmidt
2014-07-01 12:06                                   ` Paolo Bonzini
2014-07-01  8:59                           ` Gerd Hoffmann
2014-07-01  9:35                           ` Benjamin Herrenschmidt
2014-07-01  9:33                         ` Benjamin Herrenschmidt

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=1403002666.7661.142.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=gkurz@linux.vnet.ibm.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@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).