From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
David Hildenbrand <david@redhat.com>
Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Heiko Carstens" <hca@linux.ibm.com>,
qemu-stable@nongnu.org
Subject: [PATCH v4 3/4] target/s390x: Use address generation for register branch targets
Date: Thu, 16 Oct 2025 19:58:32 +0200 [thread overview]
Message-ID: <20251016175954.41153-4-iii@linux.ibm.com> (raw)
In-Reply-To: <20251016175954.41153-1-iii@linux.ibm.com>
Indirect branches to addresses taken from registers go through address
generation, e.g., for BRANCH ON CONDITION Principles of Operation says:
In the RR format, the contents of general register R2 are used to
generate the branch address
QEMU uses r2_nz handler for the respective register operands. Currently
it does not zero out extra bits in 24- and 31-bit addressing modes as
required by address generation. The very frequently used
s390x_tr_init_disas_context() function has a workaround for this,
but the code for saving an old PSW during an interrupt does not.
Add the missing masking to r2_nz. Enforce PSW validity by replacing the
workaround with an assersion.
Reported-by: Thomas Weißschuh <linux@weissschuh.net>
Reported-by: Heiko Carstens <hca@linux.ibm.com>
Link: https://lore.kernel.org/lkml/ab3131a2-c42a-47ff-bf03-e9f68ac053c0@t-8ch.de/
Cc: qemu-stable@nongnu.org
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
target/s390x/tcg/translate.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index c7e8574438c..f9487f4044d 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -5613,6 +5613,7 @@ static void in2_r2_nz(DisasContext *s, DisasOps *o)
int r2 = get_field(s, r2);
if (r2 != 0) {
o->in2 = load_reg(r2);
+ gen_addi_and_wrap_i64(s, o->in2, o->in2, 0);
}
}
#define SPEC_in2_r2_nz 0
@@ -6379,10 +6380,12 @@ static void s390x_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
{
DisasContext *dc = container_of(dcbase, DisasContext, base);
- /* 31-bit mode */
- if (!(dc->base.tb->flags & FLAG_MASK_64)) {
- dc->base.pc_first &= 0x7fffffff;
- dc->base.pc_next = dc->base.pc_first;
+ if (dc->base.tb->flags & FLAG_MASK_32) {
+ if (!(dc->base.tb->flags & FLAG_MASK_64)) {
+ assert(!(dc->base.pc_first & ~((1ULL << 31) - 1)));
+ }
+ } else {
+ assert(!(dc->base.pc_first & ~((1ULL << 24) - 1)));
}
dc->cc_op = CC_OP_DYNAMIC;
--
2.51.0
next prev parent reply other threads:[~2025-10-16 18:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 17:58 [PATCH v4 0/3] target/s390x: Fix missing clock-comparator interrupts Ilya Leoshkevich
2025-10-16 17:58 ` [PATCH v4 1/4] target/s390x: Fix missing interrupts for small CKC values Ilya Leoshkevich
2025-11-27 16:43 ` Thomas Huth
2025-11-27 18:00 ` Ilya Leoshkevich
2025-11-27 21:54 ` Ilya Leoshkevich
2025-10-16 17:58 ` [PATCH v4 2/4] target/s390x: Fix missing clock-comparator interrupts after reset Ilya Leoshkevich
2025-10-16 17:58 ` Ilya Leoshkevich [this message]
2025-10-16 18:13 ` [PATCH v4 3/4] target/s390x: Use address generation for register branch targets Thomas Weißschuh
2025-10-16 17:58 ` [PATCH v4 4/4] tests/tcg/s390x: Test SET CLOCK COMPARATOR Ilya Leoshkevich
2025-10-29 9:55 ` [PATCH PING v4 0/3] target/s390x: Fix missing clock-comparator interrupts Ilya Leoshkevich
2025-10-29 12:19 ` Thomas Huth
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=20251016175954.41153-4-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=david@redhat.com \
--cc=hca@linux.ibm.com \
--cc=linux@weissschuh.net \
--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.