All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Liu Ping Fan" <pingfank@linux.vnet.ibm.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Alexander Graf" <agraf@suse.de>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Jan Kiszka" <jan.kiszka@web.de>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH v3 11/14] ioport: Switch dispatching to memory core layer
Date: Sun, 14 Jul 2013 08:05:00 -0500	[thread overview]
Message-ID: <874nbxqolf.fsf@codemonkey.ws> (raw)
In-Reply-To: <51E24216.4050406@redhat.com>

Paolo Bonzini <pbonzini@redhat.com> writes:

> Il 13/07/2013 17:22, Anthony Liguori ha scritto:
>> 1) MMIO request goes to sPAPR PIO area, the vCPU was in BE mode but by
>> the time the handler is called, the value is in host byte order.
>> 
>> 2) sPAPR (incorrectly) byte swaps by marking the region as little
>> endian (data is now garbage)
>> 
>> 3) The portio layer (incorrectly) byte swaps because it is marked as
>> little endian (data is now good)
>> 
>> 4) Dispatch happens to VGA device which (incorrectly) byte swaps
>> because it is marked as little endian (data is now bad)
>> 
>> (2), (3), and (4) are all wrong.  By removing either (2) or (3) we can
>> "fix" the regression but that's just because two wrongs make a right
>> in this situation.
>> 
>> We should remove *all* of the LE markings from ISA devices, remove the
>> portio mark, and the sPAPR mark.  That's the right fix.
>
> So the bug here is that we have multiple levels of dispatch.  Byte
> swapping in the dispatch level only works as long as every dispatch is
> merged, which is not the case.

It's not clear to me if "endianness" makes sense as a concept in the
memory API.  If a bus wants to byte swap, it would have to redispatch
anyway.

> However, I do suspect that you have broken PREP again, because PREP has
> 1/3/4 but not 2.

"Broken" is a relative term...  Not all ISA devices do (4)--see the
various audio devices.

Jan's original patch did code motion and added the LE flag to portio.
My patch simply reverted the added logic to the code motion so if it
broke PREP, PREP has been broken for quite some time.

> Removing (2) IIUC amounts to re-applying commit
> a178274efabcbbc5d44805b51def874e47051325, and I think that's a better
> fix.

It's a bigger change, but I think we should just remove
MemoryRegionOps::endianness altogether.

> Also, what devices exactly would have a non-native byte order?!?  I'm
> confused...

MMIO/PIO requests don't have a byte order.  It's literally 64 or 32 data
pins that are numbered D0..D31 whereas D0 is the LSB.  It doesn't matter
how the pins are arranged.

It's possible for busses to "byte lane swap" the data lines such that
D0..D7 is rerouted to D23..D31, etc. in order to deal with poorly
written drivers but as benh so colorfully put, this introduces more
problems than it solves.

Unfortunately, the existance of MemoryRegionOps::endianness makes this
difficult to untangle because we have a careful combination of "two
wrongs making a right".  In all fairness, this problem predates the
memory API.  The memory API just carried forward the brokenness.

Device originated DMA is a different story.  This has to happen with a
specific endianness but that is orthogonal to the memory API.

Regards,

Anthony Liguori

>
> Paolo

  reply	other threads:[~2013-07-14 13:05 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
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 [this message]
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=874nbxqolf.fsf@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=hpoussin@reactos.org \
    --cc=jan.kiszka@web.de \
    --cc=pbonzini@redhat.com \
    --cc=pingfank@linux.vnet.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.