From: David Gibson <david@gibson.dropbear.id.au>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Cédric Le Goater" <clg@kaod.org>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Greg Kurz" <gkurz@linux.vnet.ibm.com>,
"Laurent Vivier" <lvivier@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qtest: add read/write accessors with a specific endianness
Date: Wed, 5 Oct 2016 10:43:52 +1100 [thread overview]
Message-ID: <20161004234352.GE18648@umbus.fritz.box> (raw)
In-Reply-To: <CAFEAcA-ok27Yybdse1w9K5cJL2KrfG3=VozcGtWa10UDkXp6NQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2716 bytes --]
On Tue, Oct 04, 2016 at 01:36:09PM +0100, Peter Maydell wrote:
> On 4 October 2016 at 13:17, Cédric Le Goater <clg@kaod.org> wrote:
> > Some test scenarios require to access memory regions using a specific
> > endianness, such as a device region, but the current qtest memory
> > accessors are done in native endian, which means that the values are
> > byteswapped in qtest if the endianness of the guest and the host are
> > different.
> >
> > To maintain the endianness of a value, we need a new set of memory
> > accessor. This can be done in two ways:
> >
> > - first, convert the value to the required endianness in libqtest and
> > then use the memread/write routines so that qtest accesses the guest
> > memory without doing any supplementary byteswapping
> >
> > - an alternative method would be to handle the byte swapping on the
> > qtest side. For that, we would need to extend the read/write
> > protocol with an ending word : "native|le|be" and modify the tswap
> > calls accordingly under the qtest_process_command() routine.
> >
> > The result is the same and the first method is simpler.
>
> The difficulty with this patch is that it's hard to tell whether
> it's really required, or if this is just adding an extra layer
> of byteswapping that should really be done in some other location
Actually, it's neither. It's not essential for anything, but it
*removes* an extra layer of byteswapping that really never should have
been done in the first place.
> in the stack. What's the actual test case here?
The current readw, readl, etc. all work in "guest endianness". But
guest endianness is not well defined - there are a number of targets
which can support either. And it's doubly meaningless since it's a
property of the guest cpu, which we're essentially replacing with the
qtest stub anyway.
Furthermore "guest endianness" isn't useful. With a tiny handful of
exceptions, all peripherals have their own endianness which is known
independent of the target. It makes more sense for test cases to
explicitly do their accesses in the correct endianness for the device,
without having to compensate for the fact that it'll be swapped into
the essentially arbitrary "guest endianness" along the way.
Basically, the existing byteswaps, instead of removing the need for
them in the testcase code, instead mean that target-conditional
byteswaps will be *required* in nearly every testcase. It's a recipe
for endianness-unsafe testcases.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-10-05 1:01 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-04 12:17 [Qemu-devel] [PATCH] qtest: add read/write accessors with a specific endianness Cédric Le Goater
2016-10-04 12:36 ` Peter Maydell
2016-10-04 14:04 ` Laurent Vivier
2016-10-04 14:07 ` Cédric Le Goater
2016-10-04 17:15 ` Paolo Bonzini
2016-10-04 23:43 ` David Gibson [this message]
2016-10-05 5:59 ` Cédric Le Goater
2016-10-05 12:31 ` Peter Maydell
2016-10-05 13:49 ` Cédric Le Goater
2016-10-05 13:53 ` Peter Maydell
2016-10-05 14:00 ` Cédric Le Goater
2016-10-05 14:20 ` Peter Maydell
2016-10-05 17:17 ` Cédric Le Goater
2016-10-05 17:32 ` Peter Maydell
2016-10-06 3:45 ` David Gibson
2016-10-06 7:23 ` Paolo Bonzini
2016-10-06 8:37 ` David Gibson
2016-10-06 9:40 ` Paolo Bonzini
2016-10-06 10:44 ` Cédric Le Goater
2016-10-06 10:47 ` Peter Maydell
2016-10-06 23:09 ` David Gibson
2016-10-06 3:40 ` David Gibson
2016-10-06 3:38 ` David Gibson
2016-10-06 6:10 ` David Gibson
2016-10-06 11:03 ` Peter Maydell
2016-10-06 14:11 ` Greg Kurz
2016-10-06 15:36 ` Paolo Bonzini
2016-10-06 15:41 ` Peter Maydell
2016-10-06 15:59 ` Laurent Vivier
2016-10-06 23:34 ` David Gibson
2016-10-07 7:44 ` Laurent Vivier
2016-10-06 15:44 ` Cédric Le Goater
2016-10-06 15:45 ` Paolo Bonzini
2016-10-06 23:43 ` David Gibson
2016-10-06 23:31 ` David Gibson
2016-10-06 23:31 ` David Gibson
2016-10-07 9:52 ` Peter Maydell
2016-10-04 23:26 ` David Gibson
2016-10-05 5:36 ` Cédric Le Goater
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=20161004234352.GE18648@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=clg@kaod.org \
--cc=gkurz@linux.vnet.ibm.com \
--cc=lvivier@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).