From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Richard Henderson <richard.henderson@linaro.org>,
David Hildenbrand <david@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>,
qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
Michael Tokarev <mjt@tls.msk.ru>,
Ilya Leoshkevich <iii@linux.ibm.com>,
qemu-stable@nongnu.org
Subject: [PATCH 1/4] target/s390x: Fix CLC corrupting cc_src
Date: Tue, 31 Oct 2023 06:32:27 +0100 [thread overview]
Message-ID: <20231031053718.347100-2-iii@linux.ibm.com> (raw)
In-Reply-To: <20231031053718.347100-1-iii@linux.ibm.com>
CLC updates cc_src before accessing the second operand; if the latter
is inaccessible, the former ends up containing a bogus value.
Fix by reading cc_src into a temporary first.
Fixes: 4f7403d52b1c ("target-s390: Convert CLC")
Closes: https://gitlab.com/qemu-project/qemu/-/issues/1865
Cc: qemu-stable@nongnu.org
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
target/s390x/tcg/translate.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index 4bae1509f50..a0d6a2a35dd 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -2007,6 +2007,7 @@ static DisasJumpType op_cksm(DisasContext *s, DisasOps *o)
static DisasJumpType op_clc(DisasContext *s, DisasOps *o)
{
int l = get_field(s, l1);
+ TCGv_i64 src;
TCGv_i32 vl;
MemOp mop;
@@ -2016,9 +2017,11 @@ static DisasJumpType op_clc(DisasContext *s, DisasOps *o)
case 4:
case 8:
mop = ctz32(l + 1) | MO_TE;
- tcg_gen_qemu_ld_tl(cc_src, o->addr1, get_mem_index(s), mop);
+ /* Do not update cc_src yet: loading cc_dst may cause an exception. */
+ src = tcg_temp_new_i64();
+ tcg_gen_qemu_ld_tl(src, o->addr1, get_mem_index(s), mop);
tcg_gen_qemu_ld_tl(cc_dst, o->in2, get_mem_index(s), mop);
- gen_op_update2_cc_i64(s, CC_OP_LTUGTU_64, cc_src, cc_dst);
+ gen_op_update2_cc_i64(s, CC_OP_LTUGTU_64, src, cc_dst);
return DISAS_NEXT;
default:
vl = tcg_constant_i32(l);
--
2.41.0
next prev parent reply other threads:[~2023-10-31 5:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-31 5:32 [PATCH 0/4] target/s390x: CC fixes Ilya Leoshkevich
2023-10-31 5:32 ` Ilya Leoshkevich [this message]
2023-10-31 22:49 ` [PATCH 1/4] target/s390x: Fix CLC corrupting cc_src Richard Henderson
2023-10-31 5:32 ` [PATCH 2/4] tests/tcg/s390x: Test CLC with inaccessible second operand Ilya Leoshkevich
2023-10-31 22:53 ` Richard Henderson
2023-11-06 9:20 ` Ilya Leoshkevich
2023-10-31 5:32 ` [PATCH 3/4] target/s390x: Fix LAALG not updating cc_src Ilya Leoshkevich
2023-10-31 22:57 ` Richard Henderson
2023-10-31 5:32 ` [PATCH 4/4] tests/tcg/s390x: Test LAALG with negative cc_src Ilya Leoshkevich
2023-10-31 8:38 ` [PATCH 0/4] target/s390x: CC fixes David Hildenbrand
2023-11-03 16:44 ` Ilya Leoshkevich
2023-11-03 17:02 ` David Hildenbrand
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=20231031053718.347100-2-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=david@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.