qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org
Subject: Re: [PATCH] target/i386: fix ADOX followed by ADCX
Date: Tue, 31 Jan 2023 04:57:13 -1000	[thread overview]
Message-ID: <50e20ede-a9ba-e340-8b8b-c88dfb799ff9@linaro.org> (raw)
In-Reply-To: <20230131085458.28764-1-pbonzini@redhat.com>

On 1/30/23 22:54, Paolo Bonzini wrote:
> When ADCX is followed by ADOX or vice versa, the second instruction's
> carry comes from EFLAGS.  This is handled by this bit of gen_ADCOX:
> 
>          tcg_gen_extract_tl(carry_in, cpu_cc_src,
>              ctz32(cc_op == CC_OP_ADCX ? CC_C : CC_O), 1);
> 
> Unfortunately, in this case cc_op has been overwritten by the previous
> "if" statement to CC_OP_ADCOX.  This works by chance when the first
> instruction is ADCX; however, if the first instruction is ADOX,
> ADCX will incorrectly take its carry from OF instead of CF.
> 
> Fix by moving the computation of the new cc_op at the end of the function.
> The included exhaustive test case fails without this patch and passes
> afterwards.
> 
> Because ADCX/ADOX need not be invoked through the VEX prefix, this
> regression bisects to commit 16fc5726a6e2 ("target/i386: reimplement
> 0x0f 0x38, add AVX", 2022-10-18).  However, the mistake happened a
> little earlier, when BMI instructions were rewritten using the new
> decoder framework.
> 
> Resolves:https://gitlab.com/qemu-project/qemu/-/issues/1471
> Reported-by: Paul Jolly<https://gitlab.com/myitcv>
> Fixes: 1d0b926150e5 ("target/i386: move scalar 0F 38 and 0F 3A instruction to new decoder", 2022-10-18)
> Cc:qemu-stable@nongnu.org
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   target/i386/tcg/emit.c.inc       | 20 +++++----
>   tests/tcg/i386/Makefile.target   |  6 ++-
>   tests/tcg/i386/test-i386-adcox.c | 75 ++++++++++++++++++++++++++++++++
>   3 files changed, 91 insertions(+), 10 deletions(-)
>   create mode 100644 tests/tcg/i386/test-i386-adcox.c

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


      reply	other threads:[~2023-01-31 15:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31  8:54 [PATCH] target/i386: fix ADOX followed by ADCX Paolo Bonzini
2023-01-31 14:57 ` 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=50e20ede-a9ba-e340-8b8b-c88dfb799ff9@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=pbonzini@redhat.com \
    --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).