diff mbox

[v1,02/17] linux-user: arm: set CPSR.E/SCTLR.E0E correctly for BE mode

Message ID 4f92a762d0362bb4e75667518b60c3c719c26b8b.1453100525.git.crosthwaite.peter@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Crosthwaite Jan. 18, 2016, 7:12 a.m. UTC
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

If doing big-endian linux-user mode, set both the CPSR.E and SCTLR.E0E
bits. This sets big-endian mode for data accesses in AA32 and AA64
resp.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 linux-user/main.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Peter Maydell Jan. 19, 2016, 4:22 p.m. UTC | #1
On 18 January 2016 at 07:12, Peter Crosthwaite
<crosthwaitepeter@gmail.com> wrote:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> If doing big-endian linux-user mode, set both the CPSR.E and SCTLR.E0E
> bits. This sets big-endian mode for data accesses in AA32 and AA64
> resp.
>
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
>
>  linux-user/main.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/linux-user/main.c b/linux-user/main.c
> index ee12035..4f8ea9c 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -4454,6 +4454,10 @@ int main(int argc, char **argv, char **envp)
>          for(i = 0; i < 16; i++) {
>              env->regs[i] = regs->uregs[i];
>          }
> +#ifdef TARGET_WORDS_BIGENDIAN
> +        env->uncached_cpsr |= CPSR_E;
> +        env->cp15.sctlr_el[1] |= SCTLR_E0E;
> +#endif

This looks a bit weird. Setting CPSR_E or SCTLR_E0E doesn't
make sense for BE32, and for BE8 we want to do it inside the
runtime-conditional below, I would have thought.

The commit message implies that this will work for AArch64, but
this won't have any effect for A64 binaries because it's inside
an ifndef(TARGET_AARCH64) block.

>          /* Enable BE8.  */
>          if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4
>              && (info->elf_flags & EF_ARM_BE8)) {

Not sure how an AArch64 BE ELF file identifies itself, but I guess
if we're supporting it we want a similar condition for it.
Happy to leave the 64-bit support until we've got the 32-bit
stuff working though.

thanks
-- PMM
diff mbox

Patch

diff --git a/linux-user/main.c b/linux-user/main.c
index ee12035..4f8ea9c 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4454,6 +4454,10 @@  int main(int argc, char **argv, char **envp)
         for(i = 0; i < 16; i++) {
             env->regs[i] = regs->uregs[i];
         }
+#ifdef TARGET_WORDS_BIGENDIAN
+        env->uncached_cpsr |= CPSR_E;
+        env->cp15.sctlr_el[1] |= SCTLR_E0E;
+#endif
         /* Enable BE8.  */
         if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4
             && (info->elf_flags & EF_ARM_BE8)) {