* [Qemu-devel] [PATCH v2] target/arm: Fix stlxp for aarch64_be
@ 2017-12-30 22:56 Michael Weiser
2018-01-01 23:06 ` Richard Henderson
2018-01-08 12:09 ` Peter Maydell
0 siblings, 2 replies; 4+ messages in thread
From: Michael Weiser @ 2017-12-30 22:56 UTC (permalink / raw)
To: qemu-arm; +Cc: Peter Maydell, qemu-devel, Michael Weiser
ldxp loads two consecutive doublewords from memory regardless of CPU
endianness. On store, stlxp currently assumes to work with a 128bit
value and consequently switches order in big-endian mode. With this
change it packs the doublewords in reverse order in anticipation of the
128bit big-endian store operation interposing them so they end up in
memory in the right order. This makes it work for both MTTCG and !MTTCG.
It effectively implements the ARM ARM STLXP operation pseudo-code:
data = if BigEndian() then el1:el2 else el2:el1;
With this change an aarch64_be Linux 4.14.4 kernel succeeds to boot up
in system emulation mode.
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
---
target/arm/helper-a64.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
v2:
- make it work for MTTCG as well by catering to the 128bit expectation
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
index b84ebcae6e..3adb88db6a 100644
--- a/target/arm/helper-a64.c
+++ b/target/arm/helper-a64.c
@@ -506,8 +506,10 @@ static uint64_t do_paired_cmpxchg64_be(CPUARMState *env, uint64_t addr,
Int128 oldv, cmpv, newv;
bool success;
- cmpv = int128_make128(env->exclusive_val, env->exclusive_high);
- newv = int128_make128(new_lo, new_hi);
+ /* high and low need to be switched here because this is not actually a
+ * 128bit store but two doulbewords stored consecutively */
+ cmpv = int128_make128(env->exclusive_high, env->exclusive_val);
+ newv = int128_make128(new_hi, new_lo);
if (parallel) {
#ifndef CONFIG_ATOMIC128
--
2.15.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] target/arm: Fix stlxp for aarch64_be
2017-12-30 22:56 [Qemu-devel] [PATCH v2] target/arm: Fix stlxp for aarch64_be Michael Weiser
@ 2018-01-01 23:06 ` Richard Henderson
2018-01-02 19:02 ` Michael Weiser
2018-01-08 12:09 ` Peter Maydell
1 sibling, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2018-01-01 23:06 UTC (permalink / raw)
To: Michael Weiser, qemu-arm; +Cc: Peter Maydell, qemu-devel
On 12/30/2017 02:56 PM, Michael Weiser wrote:
> ldxp loads two consecutive doublewords from memory regardless of CPU
> endianness. On store, stlxp currently assumes to work with a 128bit
> value and consequently switches order in big-endian mode. With this
> change it packs the doublewords in reverse order in anticipation of the
> 128bit big-endian store operation interposing them so they end up in
> memory in the right order. This makes it work for both MTTCG and !MTTCG.
> It effectively implements the ARM ARM STLXP operation pseudo-code:
>
> data = if BigEndian() then el1:el2 else el2:el1;
>
> With this change an aarch64_be Linux 4.14.4 kernel succeeds to boot up
> in system emulation mode.
>
> Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
> ---
> target/arm/helper-a64.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> v2:
> - make it work for MTTCG as well by catering to the 128bit expectation
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> + * 128bit store but two doulbewords stored consecutively */
^^ typo
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] target/arm: Fix stlxp for aarch64_be
2018-01-01 23:06 ` Richard Henderson
@ 2018-01-02 19:02 ` Michael Weiser
0 siblings, 0 replies; 4+ messages in thread
From: Michael Weiser @ 2018-01-02 19:02 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-arm, Peter Maydell, qemu-devel
Hi Richard,
On Mon, Jan 01, 2018 at 03:06:21PM -0800, Richard Henderson wrote:
> > v2:
> > - make it work for MTTCG as well by catering to the 128bit expectation
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> > + * 128bit store but two doulbewords stored consecutively */
> ^^ typo
Fixed for v3. Thanks!
--
Michael
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] target/arm: Fix stlxp for aarch64_be
2017-12-30 22:56 [Qemu-devel] [PATCH v2] target/arm: Fix stlxp for aarch64_be Michael Weiser
2018-01-01 23:06 ` Richard Henderson
@ 2018-01-08 12:09 ` Peter Maydell
1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2018-01-08 12:09 UTC (permalink / raw)
To: Michael Weiser; +Cc: qemu-arm, QEMU Developers
On 30 December 2017 at 22:56, Michael Weiser <michael.weiser@gmx.de> wrote:
> ldxp loads two consecutive doublewords from memory regardless of CPU
> endianness. On store, stlxp currently assumes to work with a 128bit
> value and consequently switches order in big-endian mode. With this
> change it packs the doublewords in reverse order in anticipation of the
> 128bit big-endian store operation interposing them so they end up in
> memory in the right order. This makes it work for both MTTCG and !MTTCG.
> It effectively implements the ARM ARM STLXP operation pseudo-code:
>
> data = if BigEndian() then el1:el2 else el2:el1;
>
> With this change an aarch64_be Linux 4.14.4 kernel succeeds to boot up
> in system emulation mode.
>
> Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Thanks, applied to target-arm.next (with the typo rth pointed out
fixed).
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-01-08 12:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-30 22:56 [Qemu-devel] [PATCH v2] target/arm: Fix stlxp for aarch64_be Michael Weiser
2018-01-01 23:06 ` Richard Henderson
2018-01-02 19:02 ` Michael Weiser
2018-01-08 12:09 ` Peter Maydell
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).