From: Richard Henderson <richard.henderson@linaro.org>
To: Helge Deller <deller@gmx.de>, Laurent Vivier <laurent@vivier.eu>,
qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: John Reiser <jreiser@bitwagon.com>,
"Markus F.X.J. Oberhumer" <markus@oberhumer.com>
Subject: Re: linux-user/armeb: Fix __kernel_cmpxchg() for armeb
Date: Thu, 27 Jul 2023 17:12:10 -0700 [thread overview]
Message-ID: <1e1db540-b07e-bcae-c614-67ec6c6300f0@linaro.org> (raw)
In-Reply-To: <ZMLfYE3fYCUhnaEE@p100>
On 7/27/23 14:19, Helge Deller wrote:
> Words are stored in big endian in the guest memory for armeb.
>
> Commit 7f4f0d9ea870 ("linux-user/arm: Implement __kernel_cmpxchg with
> host atomics") switched to use qatomic_cmpxchg() to swap a word with the
> memory content, but missed to endianess-swap the oldval and newval
> values when emulating an armeb CPU.
>
> The bug can be verified with qemu >= v7.2 on any little-endian host,
> when starting the armeb binary of the upx program, which just hangs
> without this patch.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: qemu-stable@nongnu.org
> Reported-by: "Markus F.X.J. Oberhumer" <markus@oberhumer.com>
> Reported-by: John Reiser <jreiser@BitWagon.com>
> Closes: https://github.com/upx/upx/issues/687
>
> diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
> index a992423257..ff0bff7c63 100644
> --- a/linux-user/arm/cpu_loop.c
> +++ b/linux-user/arm/cpu_loop.c
> @@ -117,8 +117,8 @@ static void arm_kernel_cmpxchg32_helper(CPUARMState *env)
> {
> uint32_t oldval, newval, val, addr, cpsr, *host_addr;
>
> - oldval = env->regs[0];
> - newval = env->regs[1];
> + oldval = tswap32(env->regs[0]);
> + newval = tswap32(env->regs[1]);
> addr = env->regs[2];
There's a similar bug with arm_kernel_cmpxchg64_helper just below, but
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
as far as this goes.
r~
next prev parent reply other threads:[~2023-07-28 0:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-27 21:19 linux-user/armeb: Fix __kernel_cmpxchg() for armeb Helge Deller
2023-07-28 0:12 ` Richard Henderson [this message]
2023-07-31 9:26 ` Philippe Mathieu-Daudé
2023-07-31 9:29 ` Michael Tokarev
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=1e1db540-b07e-bcae-c614-67ec6c6300f0@linaro.org \
--to=richard.henderson@linaro.org \
--cc=deller@gmx.de \
--cc=jreiser@bitwagon.com \
--cc=laurent@vivier.eu \
--cc=markus@oberhumer.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 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).