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>,
qemu-stable@nongnu.org
Subject: [PATCH v4 1/4] target/s390x: Fix missing interrupts for small CKC values
Date: Thu, 16 Oct 2025 19:58:30 +0200 [thread overview]
Message-ID: <20251016175954.41153-2-iii@linux.ibm.com> (raw)
In-Reply-To: <20251016175954.41153-1-iii@linux.ibm.com>
Suppose TOD clock value is 0x1111111111111111 and clock-comparator
value is 0, in which case clock-comparator interruption should occur
immediately.
With the current code, tod2time(env->ckc - td->base.low) ends up being
a very large number, so this interruption never happens.
Fix by firing the timer immediately if env->ckc < td->base.low.
Cc: qemu-stable@nongnu.org
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
target/s390x/tcg/misc_helper.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c
index 6d9d601d29a..215b5b9d933 100644
--- a/target/s390x/tcg/misc_helper.c
+++ b/target/s390x/tcg/misc_helper.c
@@ -199,11 +199,15 @@ static void update_ckc_timer(CPUS390XState *env)
return;
}
- /* difference between origins */
- time = env->ckc - td->base.low;
+ if (env->ckc < td->base.low) {
+ time = 0;
+ } else {
+ /* difference between origins */
+ time = env->ckc - td->base.low;
- /* nanoseconds */
- time = tod2time(time);
+ /* nanoseconds */
+ time = tod2time(time);
+ }
timer_mod(env->tod_timer, time);
}
--
2.51.0
next prev parent reply other threads:[~2025-10-16 18:01 UTC|newest]
Thread overview: 6+ 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 ` Ilya Leoshkevich [this message]
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 ` [PATCH v4 3/4] target/s390x: Use address generation for register branch targets Ilya Leoshkevich
2025-10-16 18:13 ` Thomas Weißschuh
2025-10-16 17:58 ` [PATCH v4 4/4] tests/tcg/s390x: Test SET CLOCK COMPARATOR Ilya Leoshkevich
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-2-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=david@redhat.com \
--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 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).