From: Peter Maydell <peter.maydell@linaro.org>
To: KONRAD Frederic <frederic.konrad@adacore.com>
Cc: Peter Crosthwaite <crosthwaite.peter@gmail.com>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] big endian arm.
Date: Fri, 11 Aug 2017 11:18:19 +0100 [thread overview]
Message-ID: <CAFEAcA-WJizoHGftAaHgNTmL5kTXM-yyFZBxVRBHU_K4BQ6edQ@mail.gmail.com> (raw)
In-Reply-To: <3710e9b8-4b16-1bcc-da17-80fb2cc2c644@adacore.com>
On 11 August 2017 at 10:59, KONRAD Frederic <frederic.konrad@adacore.com> wrote:
> Hi Peters,
>
> I got some strange results since this commit:
>
> commit 9776f636455b6f0d9c14dce112242ed653f954b4
> Author: Peter Crosthwaite <crosthwaitepeter@gmail.com>
> Date: Fri Mar 4 11:30:21 2016 +0000
>
> arm: boot: Support big-endian elfs
>
> Support ARM big-endian ELF files in system-mode emulation. When loading
> an elf, determine the endianness mode expected by the elf, and set the
> relevant CPU state accordingly.
>
> With this, big-endian modes are now fully supported via system-mode LE,
> so there is no need to restrict the elf loading to the TARGET
> endianness so the ifdeffery on TARGET_WORDS_BIGENDIAN goes away.
>
> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> [PMM: fix typo in comments]
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>
> It seems that when I try to load a big endian image on a
> Cortex-R5 it gets confused:
> * the instructions are fine it executes some code.
> * GDB address / insns are wrong endianness.
> * in monitor x command is good endianness.
> * the data order seems to be wrong endianness:
> Here is my Hello World: lleHlroW
R profile bigendian is weird (ie not like A profile) because
it has a special fudge: SCTLR.IE is an Instruction Endianness
bit which lets you specify big-endian instruction order (IMPDEF
how it's set, but for the Cortex-R5 it's an external config
signal so the SoC can hardwire it as it likes). For A profile
this bit is always 0 and instructions are LE always. We
don't implement letting the board model set SCTLR.IE (or
the code needed to honour it being non-zero).
If your code requires SCTLR.IE to be 1 then you'll need
to implement that handling (if the instructions are being
correctly executed then that suggests it doesn't, but
you should check).
> We used to add a armeb-softmmu/qemu-system-armeb target for the
> big endian cpu but it doesn't work anymore as it's double
> reversed by the elf endianness (data_swab <= 2).
This was never the right way to do system BE :-) We should
fix up whatever the R profile issues you see are...
> And I'm surprised we don't set the CPSR_E and SCTLR_EE bits
> accordingly?
Setting SCTLR_EE is the job of the board model: a BE board
model sets the 'cfgend' property on the CPU, which configures
the reset SCTLR.EE (or SCTLR.B for v5/v6 cores). (You may
also be able to set -cpu=something,cfgend=true on the command
line but that's kind of a hack.) SCTLR.EE is then supposed
to set the CPSR.E on exception entry including reset.
There is I think a bug here though: we set CPSR.E on
exception entry in arm_cpu_do_interrupt_aarch32():
/* Set new mode endianness */
env->uncached_cpsr &= ~CPSR_E;
if (env->cp15.sctlr_el[arm_current_el(env)] & SCTLR_EE) {
env->uncached_cpsr |= CPSR_E;
}
but we forgot to do anything in arm_cpu_reset() to get
the CPSR.E bit right on initial reset.
That said, if you specify a BE elf file then we do
set the SCTLR.EE and CPSR.E bits on reset in do_cpu_reset()
(a change added in the commit you quote), which is probably
why we haven't noticed the arm_cpu_reset() bug.
Dunno about the gdbstub stuff.
thanks
-- PMM
next prev parent reply other threads:[~2017-08-11 10:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-11 9:59 [Qemu-devel] big endian arm KONRAD Frederic
2017-08-11 10:18 ` Peter Maydell [this message]
2017-08-11 11:03 ` KONRAD Frederic
2017-08-11 11:05 ` Peter Maydell
2017-08-11 11:08 ` KONRAD Frederic
2017-08-11 14:27 ` Philippe Mathieu-Daudé
2017-08-11 11:29 ` Philippe Mathieu-Daudé
2017-08-11 13:53 ` KONRAD Frederic
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=CAFEAcA-WJizoHGftAaHgNTmL5kTXM-yyFZBxVRBHU_K4BQ6edQ@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=crosthwaite.peter@gmail.com \
--cc=frederic.konrad@adacore.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 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).