From: Eric Farman <farman@linux.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, Matthew Rosato <mjrosato@linux.ibm.com>,
Cornelia Huck <cohuck@redhat.com>,
Ilya Leoshkevich <iii@linux.ibm.com>,
Ido Plat <Ido.Plat1@ibm.com>,
qemu-stable@nongnu.org, Eric Farman <farman@linux.ibm.com>
Subject: [PULL 11/15] target/s390x/tcg: Set STCK/STCKF condition code after the store
Date: Wed, 12 Aug 2026 13:17:03 -0400 [thread overview]
Message-ID: <20260812171707.1605637-12-farman@linux.ibm.com> (raw)
In-Reply-To: <20260812171707.1605637-1-farman@linux.ibm.com>
From: Ilya Leoshkevich <iii@linux.ibm.com>
STORE CLOCK [FAST] to an inaccessible address aborts QEMU:
$ qemu-s390x ./stckf
ERROR:cc_helper.c:128:cc_calc_addu: assertion failed: (carry_out <= 1)
op_stck() sets the condition code with gen_op_movi_cc() before the
output operand store, which is deferred to wout_m1_64(). Assigning a
constant condition code discards the lazy CC values, so the optimizer
drops the writes that produced them. When the store then raises an
exception, the instruction is suppressed and
s390x_restore_state_to_opc() reinstates the cc_op recorded at the start
of STCK[F], but cc_src/cc_dst now hold stale values, so the next
condition code evaluation reads garbage.
Fix by performing the store manually. The alternative of not discarding
in gen_op_movi_cc() keeps the inputs live, but results in less optimal
code.
Reported-by: Ido Plat <Ido.Plat1@ibm.com>
Fixes: 434c91a5f4ed ("target-s390: Convert STCK")
Cc: qemu-stable@nongnu.org
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/20260714203206.363028-2-iii@linux.ibm.com
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
target/s390x/tcg/insn-data.h.inc | 4 ++--
target/s390x/tcg/translate.c | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/target/s390x/tcg/insn-data.h.inc b/target/s390x/tcg/insn-data.h.inc
index 0d5392eac5..1ea72248a6 100644
--- a/target/s390x/tcg/insn-data.h.inc
+++ b/target/s390x/tcg/insn-data.h.inc
@@ -887,8 +887,8 @@
C(0xe32f, STRVG, RXY_a, Z, la2, r1_o, new, m1_64, rev64, 0)
/* STORE CLOCK */
- F(0xb205, STCK, S, Z, la2, 0, new, m1_64, stck, 0, IF_IO)
- F(0xb27c, STCKF, S, SCF, la2, 0, new, m1_64, stck, 0, IF_IO)
+ F(0xb205, STCK, S, Z, la2, 0, new, 0, stck, 0, IF_IO)
+ F(0xb27c, STCKF, S, SCF, la2, 0, new, 0, stck, 0, IF_IO)
/* STORE CLOCK EXTENDED */
F(0xb278, STCKE, S, Z, 0, a2, 0, 0, stcke, 0, IF_IO)
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index 82165ac1ec..1b6023168b 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -4108,7 +4108,9 @@ static DisasJumpType op_stap(DisasContext *s, DisasOps *o)
static DisasJumpType op_stck(DisasContext *s, DisasOps *o)
{
gen_helper_stck(o->out, tcg_env);
+ tcg_gen_qemu_st_i64(o->out, o->addr1, get_mem_index(s), MO_BEUQ);
/* ??? We don't implement clock states. */
+ /* Set the CC after the store; a suppressed store must preserve it. */
gen_op_movi_cc(s, 0);
return DISAS_NEXT;
}
--
2.55.0
next prev parent reply other threads:[~2026-08-12 17:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 17:16 [PULL 00/15] s390x queue Eric Farman
2026-08-12 17:16 ` [PULL 01/15] target/s390x: Make PRNO TRNG interruptible Eric Farman
2026-08-12 17:16 ` [PULL 02/15] tests/tcg/s390x: Test PRNO TRNG interruptibility Eric Farman
2026-08-12 17:16 ` [PULL 03/15] target/s390x: Fix DR/D INT64_MIN / -1 host crash Eric Farman
2026-08-12 17:16 ` [PULL 04/15] tests/tcg/s390x: Test DR overflow (INT64_MIN / -1) Eric Farman
2026-08-12 17:16 ` [PULL 05/15] hw/char/sclpconsole-lm: avoid guest triggerable assert Eric Farman
2026-08-12 17:16 ` [PULL 06/15] s390x/ipl: validate num_comp against iplb length before iterating Eric Farman
2026-08-12 17:16 ` [PULL 07/15] pc-bios/s390-ccw: fix out-of-bounds read in iso_get_file_size() Eric Farman
2026-08-12 17:17 ` [PULL 08/15] pc-bios/s390-ccw: bounds-check zipl menu entry index before array write Eric Farman
2026-08-12 17:17 ` [PULL 09/15] pc-bios/s390-ccw: bound zipl menu strlen and replace VLA in zipl_print_entry Eric Farman
2026-08-12 17:17 ` [PULL 10/15] pc-bios/s390-ccw: Fix off-by-one errors with loadparm and boot entries Eric Farman
2026-08-12 17:17 ` Eric Farman [this message]
2026-08-12 17:17 ` [PULL 12/15] tests/tcg/s390x: Test STCKF condition code on a faulting store Eric Farman
2026-08-12 17:17 ` [PULL 13/15] target/s390x: Allow 2G hugepages guest backing Eric Farman
2026-08-12 17:17 ` [PULL 14/15] hw: add compat machines for 11.2 Eric Farman
2026-08-12 17:17 ` [PULL 15/15] pc-bios/s390-ccw.img: update s390x bios Eric Farman
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=20260812171707.1605637-12-farman@linux.ibm.com \
--to=farman@linux.ibm.com \
--cc=Ido.Plat1@ibm.com \
--cc=cohuck@redhat.com \
--cc=iii@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@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 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.