From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2 4/8] linux-user: arm: handle CPSR.E correctly in strex emulation
Date: Tue, 03 Jun 2014 13:12:58 +0200 [thread overview]
Message-ID: <538DADBA.4020309@redhat.com> (raw)
In-Reply-To: <CAFEAcA9uh3TACo8L6MtBiEiZvnRfQ7OtZd_V+HwktY9_rBo4Xw@mail.gmail.com>
Il 03/06/2014 11:54, Peter Maydell ha scritto:
> In user emulation, things are more complicated for BE32,
> because we're sort of emulating the word-invariant
> bigendian using byte-invariant big-endian (this is
> safe because there's no way for a userspace program
> to get at anything that would let it tell the
> difference). So we can't just say "set SCTLR.B
> and handle as if SCTLR.B is set in the way system
> emulation would", because the behaviour has to
> be different.
>
> So in summary I'm not sure of the right approach
> any more...
I think overall sctlr_b makes for more accurate and overall
clearer code.
Here are the functions I'm using to map between the various properties:
+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).
+ */
+ 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
+}
+
+#ifdef CONFIG_USER_ONLY
+static inline bool arm_cpu_bswap_data(CPUARMState *env)
+{
+ return
+#ifdef TARGET_WORDS_BIGENDIAN
+ 1 ^
+#endif
+ !!(env->cp15.c1_sys & SCTLR_B) ^
+ !!(env->uncached_cpsr & CPSR_E);
+}
+#endif
+
+static inline bool arm_tbflag_is_data_be(unsigned tbflags)
+{
+ return
+#ifdef CONFIG_USER_ONLY
+ ARM_TBFLAG_SCTLR_B(tbflags) ^
+#endif
+ ARM_TBFLAG_CPSR_E(tbflags);
+}
+
I think this is reasonably close to what you would have for SCTLR.B
emulation, only the XORing of addresses is missing.
bswap_code is used in much fewer places than the current env->bswap_code,
basically only in the definitions of arm_ld*_code and get_user_code_*.
Everywhere else the code is accessing SCTLR.B, which is "real"
architectural state. The confusing manner of handling it in user-mode
emulation is wrapped by the above three inline functions.
Paolo
next prev parent reply other threads:[~2014-06-03 11:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1401392813-29645-1-git-send-email-pbonzini@redhat.com>
[not found] ` <1401392813-29645-5-git-send-email-pbonzini@redhat.com>
[not found] ` <CAFEAcA-yi46ju3i6E+WJWFk-9JW0ydTMjgJHhjA3VCRxvZ13AQ@mail.gmail.com>
[not found] ` <53882A9D.7010501@redhat.com>
2014-06-02 16:17 ` [Qemu-devel] [PATCH v2 4/8] linux-user: arm: handle CPSR.E correctly in strex emulation Peter Maydell
2014-06-03 9:23 ` Paolo Bonzini
2014-06-03 9:54 ` Peter Maydell
2014-06-03 11:12 ` Paolo Bonzini [this message]
2014-06-04 7:48 ` Paolo Bonzini
2014-06-04 8:30 ` Peter Maydell
2014-10-31 20:52 ` [Qemu-devel] [PATCH v2 0/8] target-arm/linux-user-arm: implement setend, CPSR.E, SCTLR.EE Stefan Weil
2015-02-05 17:33 ` Paolo Bonzini
2015-02-05 17:49 ` 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=538DADBA.4020309@redhat.com \
--to=pbonzini@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 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.