All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v3 03/11] target-arm: implement SCTLR.B, drop bswap_code
Date: Thu, 26 Jun 2014 15:01:21 +0100	[thread overview]
Message-ID: <CAFEAcA8oZnQRDQ1WS-o-2ZK3Kyr8XMm0fCgQqpJwkWiiOU3k2g@mail.gmail.com> (raw)
In-Reply-To: <1403355502-12288-4-git-send-email-pbonzini@redhat.com>

On 21 June 2014 13:58, Paolo Bonzini <pbonzini@redhat.com> wrote:
> bswap_code is a CPU property of sorts ("is the iside endianness the
> opposite way round to TARGET_WORDS_BIGENDIAN?") but it is not the
> actual CPU state involved here which is SCTLR.B (set for BE32
> binaries, clear for BE8).
>
> Replace bswap_code with SCTLR.B, and pass that to arm_ld*_code.
> The next patches will make data fetches honor both SCTLR.B and
> CPSR.E appropriately.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

> @@ -4191,11 +4191,19 @@ int main(int argc, char **argv, char **envp)
>          for(i = 0; i < 16; i++) {
>              env->regs[i] = regs->uregs[i];
>          }
> +#ifdef TARGET_WORDS_BIGENDIAN
>          /* Enable BE8.  */
>          if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4
>              && (info->elf_flags & EF_ARM_BE8)) {
> -            env->bswap_code = 1;
> +            /* nothing for now, CPSR.E not emulated yet */
> +        } else {
> +            if (arm_feature(env, ARM_FEATURE_V7)) {
> +                fprintf(stderr, "BE32 binaries only supported until ARMv6\n");
> +                exit(1);
> +            }
> +            env->cp15.c1_sys |= SCTLR_B;

This will break running BE32 binaries with "-cpu any"
(which sets all the features we know about, including
ARM_FEATURE_V7).

> +static inline bool bswap_code(bool sctlr_b)
> +{
> +#ifdef CONFIG_USER_ONLY
> +    /* Mixed-endian modes are BE8 (SCTLR.B = 0, TARGET_WORDS_BIGENDIAN = 1)
> +     * and "LE8" (SCTLR.B = 1, TARGET_WORDS_BIGENDIAN = 0).

Huh? LE8 is SCTLR.B == 0...

> +     */
> +    return
> +#ifdef TARGET_WORDS_BIGENDIAN
> +        1 ^
> +#endif
> +        sctlr_b;
> +#else
> +    /* We do not implement BE32 mode for system-mode emulation, but
> +     * anyway it would always do little-endian accesses with
> +     * TARGET_WORDS_BIGENDIAN = 0.
> +     */
> +    return 0;
> +#endif
> +}

> --- a/target-arm/translate-a64.c
> +++ b/target-arm/translate-a64.c
> @@ -10786,7 +10786,7 @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s)
>  {
>      uint32_t insn;
>
> -    insn = arm_ldl_code(env, s->pc, s->bswap_code);
> +    insn = arm_ldl_code(env, s->pc, s->sctlr_b);

This is now slightly odd to read because by definition any
CPU with the A64 instruction set won't have BE32 and A64
insns are always loaded little-endian... Still, it's a
mechanical code transform so I guess it's ok.
We can clean that up later.

> @@ -10899,7 +10899,7 @@ static inline void gen_intermediate_code_internal(ARMCPU *cpu,
>
>      dc->aarch64 = 0;
>      dc->thumb = ARM_TBFLAG_THUMB(tb->flags);
> -    dc->bswap_code = ARM_TBFLAG_BSWAP_CODE(tb->flags);
> +    dc->sctlr_b = ARM_TBFLAG_SCTLR_B(tb->flags);
>      dc->condexec_mask = (ARM_TBFLAG_CONDEXEC(tb->flags) & 0xf) << 1;
>      dc->condexec_cond = ARM_TBFLAG_CONDEXEC(tb->flags) >> 4;
>  #if !defined(CONFIG_USER_ONLY)
> @@ -11142,7 +11142,7 @@ done_generating:
>          qemu_log("----------------\n");
>          qemu_log("IN: %s\n", lookup_symbol(pc_start));
>          log_target_disas(env, pc_start, dc->pc - pc_start,
> -                         dc->thumb | (dc->bswap_code << 1));
> +                         dc->thumb | (dc->sctlr_b << 1));

Don't we need a call to bswap_code() here, since we're
telling the disassembler which endianness to assume?

>          qemu_log("\n");
>      }
>  #endif
> diff --git a/target-arm/translate.h b/target-arm/translate.h
> index 31a0104..19f794c 100644
> --- a/target-arm/translate.h
> +++ b/target-arm/translate.h
> @@ -16,7 +16,7 @@ typedef struct DisasContext {
>      struct TranslationBlock *tb;
>      int singlestep_enabled;
>      int thumb;
> -    int bswap_code;
> +    int sctlr_b;
>  #if !defined(CONFIG_USER_ONLY)
>      int user;
>  #endif

thanks
-- PMM

  reply	other threads:[~2014-06-26 14:01 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-21 12:58 [Qemu-devel] [PATCH v3 00/11] implement dynamic endianness switching Paolo Bonzini
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 01/11] linux-user: arm: fix coding style for some linux-user signal functions Paolo Bonzini
2014-06-26 14:22   ` Peter Maydell
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 02/11] linux-user: arm: pass env to get_user_code_* Paolo Bonzini
2014-06-26 14:23   ` Peter Maydell
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 03/11] target-arm: implement SCTLR.B, drop bswap_code Paolo Bonzini
2014-06-26 14:01   ` Peter Maydell [this message]
2014-06-26 14:15     ` Paolo Bonzini
2014-06-26 14:53       ` Peter Maydell
2014-06-26 16:14         ` Paolo Bonzini
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 04/11] linux-user: arm: set CPSR.E correctly for BE8 mode Paolo Bonzini
2014-06-26 14:15   ` Peter Maydell
2014-06-26 14:18     ` Paolo Bonzini
2015-06-22 22:48       ` Peter Crosthwaite
2015-06-23  8:04         ` Peter Maydell
2015-06-23 18:43           ` Peter Crosthwaite
2015-06-23 18:54             ` Peter Maydell
2015-06-23 20:30               ` Peter Crosthwaite
2015-06-23 21:34                 ` Peter Maydell
2015-06-24 10:09                 ` Paolo Bonzini
2015-06-24 10:21                   ` Peter Maydell
2015-06-24 10:34                     ` Paolo Bonzini
2015-06-24 10:48                       ` Peter Maydell
2015-06-24 10:49                         ` Paolo Bonzini
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 05/11] linux-user: arm: handle CPSR.E correctly in strex emulation Paolo Bonzini
2014-06-26 14:21   ` Peter Maydell
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 06/11] target-arm: implement SCTLR.EE Paolo Bonzini
2014-06-26 14:29   ` Peter Maydell
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 07/11] target-arm: pass DisasContext to gen_aa32_ld*/st* Paolo Bonzini
2014-06-26 14:31   ` Peter Maydell
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 08/11] target-arm: introduce tbflag for CPSR.E Paolo Bonzini
2014-06-26 14:33   ` Peter Maydell
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 09/11] target-arm: implement setend Paolo Bonzini
2014-06-26 14:35   ` Peter Maydell
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 10/11] target-arm: reorganize gen_aa32_ld/st to prepare for BE32 system emulation Paolo Bonzini
2014-06-26 14:38   ` Peter Maydell
2014-06-21 12:58 ` [Qemu-devel] [PATCH v3 11/11] target-arm: implement BE32 mode in " Paolo Bonzini
2014-06-21 20:16   ` Richard Henderson
2014-06-26 14:43   ` Peter Maydell
2014-06-26 14:51     ` Paolo Bonzini
2014-12-28 12:12 ` [Qemu-devel] [PATCH v3 00/11] implement dynamic endianness switching Stefan Weil
2014-12-28 21:26   ` Paolo Bonzini
2015-06-18 18:37 ` Peter Crosthwaite
2015-06-18 19:00   ` Paolo Bonzini
2015-06-18 20:24     ` Peter Crosthwaite
2015-06-19  7:07       ` Paolo Bonzini

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=CAFEAcA8oZnQRDQ1WS-o-2ZK3Kyr8XMm0fCgQqpJwkWiiOU3k2g@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.