From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
Artyom Tarasenko <atar4qemu@gmail.com>
Subject: Re: [PATCH] target/sparc: Handle FPRS correctly on big-endian hosts
Date: Fri, 14 Jul 2023 18:29:47 +0100 [thread overview]
Message-ID: <CAFEAcA-CT1ruvpgYfFn81n-xPup_FPNNmmDiAXJMj0=voBxHpQ@mail.gmail.com> (raw)
In-Reply-To: <20230714172602.397267-1-peter.maydell@linaro.org>
On Fri, 14 Jul 2023 at 18:26, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> In CPUSparcState we define the fprs field as uint64_t. However we
> then refer to it in translate.c via a TCGv_i32 which we set up with
> tcg_global_mem_new_ptr(). This means that on a big-endian host when
> the guest does something to writo te the FPRS register this value
> ends up in the wrong half of the uint64_t, and the QEMU C code that
> refers to env->fprs sees the wrong value. The effect of this is that
> guest code that enables the FPU crashes with spurious FPU Disabled
> exceptions. In particular, this is why
> tests/avocado/machine_sparc64_sun4u.py:Sun4uMachine.test_sparc64_sun4u
> times out on an s390 host.
>
> There are multiple ways we could fix this; since there are actually
> only three bits in the FPRS register and the code in translate.c
> would be a bit painful to convert to dealing with a TCGv_i64, change
> the type of the CPU state struct field to match what translate.c is
> expecting.
> diff --git a/target/sparc/machine.c b/target/sparc/machine.c
> index 44b9e7d75d6..5a8502804a4 100644
> --- a/target/sparc/machine.c
> +++ b/target/sparc/machine.c
> @@ -168,7 +168,8 @@ const VMStateDescription vmstate_sparc_cpu = {
> VMSTATE_UINT64_ARRAY(env.bgregs, SPARCCPU, 8),
> VMSTATE_UINT64_ARRAY(env.igregs, SPARCCPU, 8),
> VMSTATE_UINT64_ARRAY(env.mgregs, SPARCCPU, 8),
> - VMSTATE_UINT64(env.fprs, SPARCCPU),
> + VMSTATE_UINT32(env.fprs, SPARCCPU),
> + VMSTATE_UNUSED(4), /* was unused high half of uint64_t fprs */
Whoops, these two fields are the wrong way around. The on-the-wire
format for migration is always big-endian, so we need to put
the VMSTATE_UNUSED() placeholder before the VMSTATE_UINT32(),
not after it.
thanks
-- PMM
next prev parent reply other threads:[~2023-07-14 17:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 17:26 [PATCH] target/sparc: Handle FPRS correctly on big-endian hosts Peter Maydell
2023-07-14 17:29 ` Peter Maydell [this message]
2023-07-14 17:52 ` Philippe Mathieu-Daudé
2023-07-16 17:32 ` Peter Maydell
2023-07-17 11:42 ` Philippe Mathieu-Daudé
2023-07-16 17:09 ` Richard Henderson
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='CAFEAcA-CT1ruvpgYfFn81n-xPup_FPNNmmDiAXJMj0=voBxHpQ@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=atar4qemu@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--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).