qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Riku Voipio <riku.voipio@iki.fi>, Doug Kwan <dougkwan@google.com>,
	"qemu-ppc@nongnu.org" <qemu-ppc@nongnu.org>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 2/3] PPC: Allow little-endian user mode.
Date: Thu, 08 May 2014 14:44:20 +0200	[thread overview]
Message-ID: <536B7C24.1030000@suse.de> (raw)
In-Reply-To: <CAFEAcA9XJfH0SsU28TD7-EpzxfJfc2EucX-jVNCgQ_Gj_8ULwg@mail.gmail.com>

On 05/08/2014 02:39 PM, Peter Maydell wrote:
> On 8 May 2014 09:39, Alexander Graf <agraf@suse.de> wrote:
>> On 05/08/2014 10:26 AM, Doug Kwan wrote:
>>> This all running PPC64 little-endian in user mode if target is configured
>>> that way.  In PPC64 LE user mode we set MSR.LE during initialization.
>>> Byteswapping logic is reversed also when QEMU is running in that mode.
>>>
>>> Signed-off-by: Doug Kwan <dougkwan@google.com>
>>
>> I can't say I'm a huge fan of this patch. It allows for really tricky
>> subtile mistakes to happen. Can't we leave the target mode configured on big
>> endian?
> Unfortunately not if you care about linux-user mode:
> linux-user mode uses the target-endian setting to figure
> out if it needs to do swapping of data in all the syscall
> interfaces.
>
> If you're going to overhaul how PPC deals with endian
> dependent loads/stores, I suspect you'll end up with a
> cleaner result if you convert to the new "specify endian
> setting as part of the memory operation" TCG ops:
> So for instance rather than having:
>
>      tcg_gen_qemu_ld16u(arg1, arg2, ctx->mem_idx);
>      if (unlikely(ctx->le_mode)) {
>          tcg_gen_bswap16_tl(arg1, arg1);
>      }
>
> it would be better to do
>      TCGMemOp op = MO_UW | (ctx->le_mode ? MO_LE : MO_BE);
>      tcg_gen_qemu_ld_i32(arg1, arg2, ctx->mem_idx, op);
>
> This will work regardless of the TARGET_WORD_BIGENDIAN
> setting, since we directly ask TCG to do an LE or BE
> access, rather than doing a target-endian access and
> then swapping. (It's also more efficient if you're
> in little-endian mode on a little endian host since
> it won't swap at all rather than swapping twice.)

Good point. We could store the "default TCGMemOp mask" in ctx and then 
only add the width per operation.


Alex

  reply	other threads:[~2014-05-08 12:44 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08  8:26 [Qemu-devel] [PATCH 0/3] Adding new user mode target ppc64el-linux-user Doug Kwan
2014-05-08  8:26 ` [Qemu-devel] [PATCH 1/3] linux-user: Handle ELFv2 PPC64 binaries in user mode Doug Kwan
2014-05-08  8:36   ` Alexander Graf
2014-05-08  8:43     ` Doug Kwan (關振德)
2014-05-08  8:45       ` Alexander Graf
2014-05-08 13:30       ` Ulrich Weigand
2014-05-08  8:26 ` [Qemu-devel] [PATCH 2/3] PPC: Allow little-endian " Doug Kwan
2014-05-08  8:39   ` Alexander Graf
2014-05-08  8:49     ` Doug Kwan (關振德)
2014-05-08  8:55       ` Alexander Graf
2014-05-08  9:05         ` Doug Kwan (關振德)
2014-05-08  9:11           ` Alexander Graf
2014-05-08  9:24             ` Doug Kwan (關振德)
2014-05-08 12:39     ` Peter Maydell
2014-05-08 12:44       ` Alexander Graf [this message]
2014-05-08  8:26 ` [Qemu-devel] [PATCH 3/3] configure: Add new target ppc64el-linux-user Doug Kwan
2014-05-08  8:41   ` Alexander Graf
2014-05-08  8:46     ` Doug Kwan (關振德)
2014-05-08  8:56       ` Alexander Graf
2014-05-08  9:09         ` Doug Kwan (關振德)
2014-05-08 12:18   ` Andreas Färber
2014-05-08 12:28     ` Peter Maydell
2014-05-08 12:45       ` Alexander Graf
2014-05-08 15:57       ` Doug Kwan (關振德)
2014-05-08 14:41   ` Tom Musta
2014-05-08 15:19     ` Doug Kwan (關振德)
2014-05-08 15:25       ` Peter Maydell
2014-05-08 15:32         ` Doug Kwan (關振德)
2014-05-08 15:41           ` Peter Maydell
2014-05-08 15:51             ` Doug Kwan (關振德)
2014-05-08 15:56               ` Peter Maydell
2014-05-08 15:39         ` Tom Musta
2014-05-08 15:43           ` Peter Maydell

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=536B7C24.1030000@suse.de \
    --to=agraf@suse.de \
    --cc=dougkwan@google.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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).