From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org
Subject: Re: [PATCH] target/arm: Store FPSR cumulative exception bits in env->vfp.fpsr
Date: Sun, 13 Oct 2024 10:30:05 -0700 [thread overview]
Message-ID: <e504719e-aa6a-41c5-b2f2-31e3400807b5@linaro.org> (raw)
In-Reply-To: <20241011162401.3672735-1-peter.maydell@linaro.org>
On 10/11/24 09:24, Peter Maydell wrote:
> Currently we store the FPSR cumulative exception bits in the
> float_status fields, and use env->vfp.fpsr only for the NZCV bits.
> (The QC bit is stored in env->vfp.qc[].)
>
> This works for TCG, but if QEMU was built without CONFIG_TCG (i.e.
> with KVM support only) then we use the stub versions of
> vfp_get_fpsr_from_host() and vfp_set_fpsr_to_host() which do nothing,
> throwing away the cumulative exception bit state. The effect is that
> if the FPSR state is round-tripped from KVM to QEMU then we lose the
> cumulative exception bits. In particular, this will happen if the VM
> is migrated. There is no user-visible bug when using KVM with a QEMU
> binary that was built with CONFIG_TCG.
Ok, noted.
> - int i = vfp_exceptbits_to_host(val);
> - set_float_exception_flags(i, &env->vfp.fp_status);
> + set_float_exception_flags(0, &env->vfp.fp_status);
> set_float_exception_flags(0, &env->vfp.fp_status_f16);
> set_float_exception_flags(0, &env->vfp.standard_fp_status);
> set_float_exception_flags(0, &env->vfp.standard_fp_status_f16);
I will note that this affects can_use_fpu() in softfpu.c, at least for the first operation
after setting FPSR: without float_flag_inexact set, we will always use the slow path.
In glibc, when manipulating FPSR, it tends to come in pairs: feholdsetround +
feresetround. With this, half of the time we'll be setting the exception flags to 0, and
half of the time we'll be restoring old values. The latter set is reasonably like to have
inexact set.
It might be worthwhile to set float_flag_inexact in all of these when IXC is set. We will
still sum to the same result when reading later.
That said, this fixes a bug and is not wrong so
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
prev parent reply other threads:[~2024-10-13 17:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 16:24 [PATCH] target/arm: Store FPSR cumulative exception bits in env->vfp.fpsr Peter Maydell
2024-10-13 17:30 ` Richard Henderson [this message]
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=e504719e-aa6a-41c5-b2f2-31e3400807b5@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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).