From: Richard Henderson <richard.henderson@linaro.org>
To: "Víctor Colombo" <victor.colombo@eldorado.org.br>,
qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: clg@kaod.org, danielhb413@gmail.com, david@gibson.dropbear.id.au,
groug@kaod.org
Subject: Re: [PATCH 2/2] target/ppc: Fix FPSCR.FI changing in float_overflow_excp()
Date: Mon, 9 May 2022 16:01:43 -0700 [thread overview]
Message-ID: <bcd3200c-54b1-3647-a165-fe7c5f7687c9@linaro.org> (raw)
In-Reply-To: <20220509124836.27819-3-victor.colombo@eldorado.org.br>
On 5/9/22 07:48, Víctor Colombo wrote:
> This patch fixes another not-so-clear situation in Power ISA
> regarding the inexact bits in FPSCR. The ISA states that:
>
> """
> When Overflow Exception is disabled (OE=0) and an
> Overflow Exception occurs, the following actions are
> taken:
> ...
> 2. Inexact Exception is set
> XX <- 1
> ...
> FI is set to 1
> ...
> """
>
> However, when tested on a Power 9 hardware, some instructions that
> trigger an OX don't set the FI bit:
>
> xvcvdpsp(0x4050533fcdb7b95ff8d561c40bf90996) = FI: CLEARED -> CLEARED
> xvnmsubmsp(0xf3c0c1fc8f3230, 0xbeaab9c5) = FI: CLEARED -> CLEARED
> (just a few examples. Other instructions are also affected)
>
> The root cause for this seems to be that only instructions that list
> the bit FI in the "Special Registers Altered" should modify it.
>
> QEMU is, today, not working like the hardware:
>
> xvcvdpsp(0x4050533fcdb7b95ff8d561c40bf90996) = FI: CLEARED -> SET
> xvnmsubmsp(0xf3c0c1fc8f3230, 0xbeaab9c5) = FI: CLEARED -> SET
>
> (all tests assume FI is cleared beforehand)
>
> Fix this by passing an argument to float_overflow_excp() indicating
> if the FI should be set.
>
> Signed-off-by: Víctor Colombo <victor.colombo@eldorado.org.br>
> ---
> target/ppc/fpu_helper.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
> index 773c80e12d..ee1259ede1 100644
> --- a/target/ppc/fpu_helper.c
> +++ b/target/ppc/fpu_helper.c
> @@ -329,7 +329,7 @@ static inline void float_zero_divide_excp(CPUPPCState *env, uintptr_t raddr)
> }
> }
>
> -static inline void float_overflow_excp(CPUPPCState *env)
> +static inline void float_overflow_excp(CPUPPCState *env, bool set_fi)
> {
> CPUState *cs = env_cpu(env);
>
> @@ -345,7 +345,9 @@ static inline void float_overflow_excp(CPUPPCState *env)
> env->error_code = POWERPC_EXCP_FP | POWERPC_EXCP_FP_OX;
> } else {
> env->fpscr |= FP_XX;
> - env->fpscr |= FP_FI;
> + if (set_fi) {
> + env->fpscr |= FP_FI;
> + }
Again, I believe setting FP_FI here is wrong, it should only be set later in
do_float_check_status. Indeed, setting XX here probably isn't best...
..
> @@ -471,7 +473,7 @@ static void do_float_check_status(CPUPPCState *env, bool change_fi,
> int status = get_float_exception_flags(&env->fp_status);
>
> if (status & float_flag_overflow) {
> - float_overflow_excp(env);
> + float_overflow_excp(env, change_fi);
I think the ideal solution would be to return an update to status from float_overflow_excp
so that all of the inexact handling happens below. Since inexact is the last bit to be
processed, this could be as simple as
if (status & overflow) {
status = float_overflow_excp(env);
} else if (status & underflow) {
...
}
if (status & inexact) {
...
returning OE ? 0 : float_flag_inexact, without trying to merge inexact into the full set
of status flags.
r~
prev parent reply other threads:[~2022-05-09 23:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-09 12:48 [PATCH 0/2] target/ppc: Fix FPSCR.FI bit Víctor Colombo
2022-05-09 12:48 ` [PATCH 1/2] target/ppc: Fix FPSCR.FI bit being cleared when it shouldn't Víctor Colombo
2022-05-09 22:15 ` Richard Henderson
2022-05-09 12:48 ` [PATCH 2/2] target/ppc: Fix FPSCR.FI changing in float_overflow_excp() Víctor Colombo
2022-05-09 23:01 ` 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=bcd3200c-54b1-3647-a165-fe7c5f7687c9@linaro.org \
--to=richard.henderson@linaro.org \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=victor.colombo@eldorado.org.br \
/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).