From: Christoffer Dall <christoffer.dall@linaro.org>
To: Victor Kamensky <victor.kamensky@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Thomas Falcon <tlfalcon@linux.vnet.ibm.com>,
kvm-devel <kvm@vger.kernel.org>,
QEMU Developers <qemu-devel@nongnu.org>,
"qemu-ppc@nongnu.org" <qemu-ppc@nongnu.org>,
"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>
Subject: Re: [Qemu-devel] KVM and variable-endianness guest CPUs
Date: Thu, 23 Jan 2014 12:45:52 -0800 [thread overview]
Message-ID: <20140123204552.GA2977@lvm> (raw)
In-Reply-To: <CAA3XUr0CawvQ-JT05wmmdriNNAbv+xVNFbwVv-uSQmPeo5iduQ@mail.gmail.com>
On Thu, Jan 23, 2014 at 08:25:35AM -0800, Victor Kamensky wrote:
> On 23 January 2014 07:33, Peter Maydell <peter.maydell@linaro.org> wrote:
> > On 23 January 2014 15:06, Victor Kamensky <victor.kamensky@linaro.org> wrote:
> >> In [1] I wrote
> >>
> >> "I don't see why you so attached to desire to describe
> >> data part of memory transaction as just one of int
> >> types. If we are talking about bunch of hypothetical
> >> cases imagine such bus that allow transaction with
> >> size of 6 bytes. How do you describe such data in
> >> your ints speak? What endianity you can assign to
> >> sequence of 6 bytes? While note that description of
> >> such transaction as set of 6 byte values at address
> >> $whatever makes perfect sense."
> >>
> >> But notice that in your next reply [2] you just dropped it
> >
> > Yes. This is because it was one of the places where
> > I would have just had to repeat "no, I'm afraid you're wrong
> > about how hardware works". I think in general it's going
> > to be better if I don't try to reply point by point to this
> > email; I think you should go back and reread the emails I've
> > sent. Key points:
> > (1) hardware is not doing anything involving arrays
> > of bytes
>
> Array of bytes or integers is just a way to describe data lines
> on the bus. Did you look at this document?
>
> http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0290g/ch06s05s01.html
>
> A0, A1, ,,, A7 byte values are the same for both LE and BE-8
> case (first two columns in the table) and they unambiguously
> describe data bus signals
>
The point is simple, and Peter has made it over and over:
Any consumer of a memory operation sees "value, len, address".
This is what KVM_EXIT_MMIO emulates. So just by knowing the ABI
definition and having a pointer to the structure you need to be able to
tell me "value, len, address".
> > (2) the API between kernel and userspace needs to define
> > the semantics of mmio.data, ie how to map between
> > "x byte wide transaction with value v" and the array,
> > and that is primarily what this conversation is about
> > (3) the only choice which is both (a) sensible and (b)
> > not breaking existing usage is to say "the array is
> > in host-kernel-byte-order"
> > (4) PPC CPUs in BE mode and ARM CPUs in BE mode are not
> > the same, because in the ARM case it is doing an
> > internal-to-CPU byteswap, and in the PPC case it is not
>
> That is one of the key disconnects. I'll go find real examples
> in ARM LE, ARM BE, and PPC BE Linux kernel. Just for
> everybody sake's here is summary of the disconnect:
>
> If we have the same h/w connected to memory bus in ARM
> and PPC systems and we have the following three pieces
> of code that work with r0 having same device same
> register address:
>
> 1. ARM LE word write of 0x04030201:
> setend le
> mov r1, #0x04030201
> str r1, [r0]
>
> 2. ARM BE word write of 0x01020304:
> setend be
> mov r1, #0x01020304
> str r1, [r0]
>
> 3. PPC BE word write of 0x01020304:
> lis r1,0x102
> ori r1,r1,0x304
> stw r1,0(r0)
>
> I claim that h/w will see the same data on bus lines in all
> three cases, and h/w would acts the same in all three
> cases. Peter says that ARM BE and PPC BE case h/w
> would act differently.
>
> If anyone else can offer opinion on that while I am looking
> for real examples that would be great.
>
I really don't think listing all these examples help. You need to focus
on the key points that Peter listed in his previous mail.
I tried in our chat to ask you this questions:
vcpu_data_host_to_guest() is handling a read from an emulated device.
All the info you have is:
(1) len of memory access
(2) mmio.data pointer
(3) destination register
(4) host CPU endianness
(5) guest CPU endianness
Based on this information alone, you need to decide whether you do a
byteswap or not before loading the hardware register upon returning to
the guest.
You will find it impossible to answer, because you don't know the layout
of mmio.data, and that is the thing we are trying to solve.
If you cannot reply to this point in less than 50 lines or mention
anything about devices being LE or BE or come with examples, I am
probably not going to read your reply, sorry.
-Christoffer
next prev parent reply other threads:[~2014-01-23 20:46 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-17 17:53 [Qemu-devel] KVM and variable-endianness guest CPUs Peter Maydell
2014-01-17 18:52 ` Peter Maydell
2014-01-18 4:24 ` Christoffer Dall
2014-01-18 7:32 ` Alexander Graf
2014-01-18 10:15 ` Peter Maydell
2014-01-20 14:20 ` Alexander Graf
2014-01-20 14:31 ` Peter Maydell
2014-01-20 14:22 ` Alexander Graf
2014-01-20 19:19 ` Christoffer Dall
2014-01-22 5:39 ` Victor Kamensky
2014-01-22 6:31 ` Anup Patel
2014-01-22 6:41 ` [Qemu-devel] [Qemu-ppc] " Alexander Graf
2014-01-22 7:26 ` Victor Kamensky
2014-01-22 10:52 ` Alexander Graf
2014-01-23 4:25 ` Victor Kamensky
2014-01-23 10:32 ` Alexander Graf
2014-01-23 10:56 ` Greg Kurz
2014-01-22 8:57 ` Anup Patel
2014-01-23 23:28 ` Christoffer Dall
2014-01-22 10:22 ` [Qemu-devel] " Peter Maydell
2014-01-22 17:19 ` Victor Kamensky
2014-01-22 17:29 ` Peter Maydell
2014-01-22 19:29 ` Victor Kamensky
2014-01-22 20:02 ` Peter Maydell
2014-01-22 22:47 ` Victor Kamensky
2014-01-22 23:18 ` Peter Maydell
2014-01-23 0:22 ` Victor Kamensky
2014-01-23 10:23 ` Peter Maydell
2014-01-23 15:06 ` Victor Kamensky
2014-01-23 15:33 ` Peter Maydell
2014-01-23 16:25 ` Victor Kamensky
2014-01-23 20:45 ` Christoffer Dall [this message]
2014-01-24 0:50 ` Victor Kamensky
2014-01-24 2:14 ` Christoffer Dall
2014-01-24 4:11 ` Victor Kamensky
2014-01-28 0:32 ` [Qemu-devel] [Qemu-ppc] " Benjamin Herrenschmidt
2014-01-28 0:40 ` Christoffer Dall
2014-01-28 0:15 ` Benjamin Herrenschmidt
2014-01-24 0:09 ` [Qemu-devel] " Victor Kamensky
2014-01-28 0:07 ` [Qemu-devel] [Qemu-ppc] " Benjamin Herrenschmidt
2014-01-28 0:07 ` Benjamin Herrenschmidt
2014-01-27 23:34 ` Benjamin Herrenschmidt
2014-01-27 23:49 ` Peter Maydell
2014-01-28 0:36 ` Benjamin Herrenschmidt
2014-01-28 0:44 ` Christoffer Dall
2014-01-28 4:47 ` Benjamin Herrenschmidt
2014-01-28 16:31 ` Christoffer Dall
2014-01-27 23:31 ` Benjamin Herrenschmidt
2014-01-27 23:27 ` Benjamin Herrenschmidt
2014-01-28 9:16 ` Avi Kivity
2014-01-28 9:04 ` [Qemu-devel] " Avi Kivity
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=20140123204552.GA2977@lvm \
--to=christoffer.dall@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=tlfalcon@linux.vnet.ibm.com \
--cc=victor.kamensky@linaro.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).