From: Thomas Huth <thuth@redhat.com>
To: Ilya Leoshkevich <iii@linux.ibm.com>,
Richard Henderson <richard.henderson@linaro.org>,
David Hildenbrand <david@redhat.com>
Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [PATCH v3 2/3] target/s390x: Fix missing clock-comparator interrupts after reset
Date: Thu, 16 Oct 2025 15:29:29 +0200 [thread overview]
Message-ID: <dd902f81-0dd7-4c11-ba15-eb9af71ad2a5@redhat.com> (raw)
In-Reply-To: <20251016120928.22467-3-iii@linux.ibm.com>
On 16/10/2025 14.07, Ilya Leoshkevich wrote:
> After reset, CKC value is set to 0, so if clock-comparator interrupts
> are enabled, one should occur very shortly thereafter.
>
> Currently the code that loads the respective control register does not
> set tod_timer, so this does not happen.
>
> Fix by adding a tcg_s390_tod_updated() call to LCTL and LCTLG.
(I just realized that I mixed up store and load in my previous mail to this
patch in v2, sorry for the confusion)
> Cc: qemu-stable@nongnu.org
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
> target/s390x/tcg/mem_helper.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
> index f1acb1618f7..24675fc818d 100644
> --- a/target/s390x/tcg/mem_helper.c
> +++ b/target/s390x/tcg/mem_helper.c
> @@ -1959,6 +1959,10 @@ void HELPER(lctlg)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)
> if (env->cregs[i] != val && i >= 9 && i <= 11) {
> PERchanged = true;
> }
> + if (i == 0 && !(env->cregs[i] & CR0_CKC_SC) && (val & CR0_CKC_SC)) {
> + BQL_LOCK_GUARD();
> + tcg_s390_tod_updated(env_cpu(env), RUN_ON_CPU_NULL);
> + }
> env->cregs[i] = val;
> HELPER_LOG("load ctl %d from 0x%" PRIx64 " == 0x%" PRIx64 "\n",
> i, src, val);
> @@ -1989,10 +1993,15 @@ void HELPER(lctl)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)
>
> for (i = r1;; i = (i + 1) % 16) {
> uint32_t val = cpu_ldl_data_ra(env, src, ra);
> + uint64_t val64 = deposit64(env->cregs[i], 0, 32, val);
> if ((uint32_t)env->cregs[i] != val && i >= 9 && i <= 11) {
> PERchanged = true;
> }
> - env->cregs[i] = deposit64(env->cregs[i], 0, 32, val);
> + if (i == 0 && !(env->cregs[i] & CR0_CKC_SC) && (val64 & CR0_CKC_SC)) {
> + BQL_LOCK_GUARD();
> + tcg_s390_tod_updated(env_cpu(env), RUN_ON_CPU_NULL);
> + }
> + env->cregs[i] = val64;
That looks nicer to me, indeed, thanks!
Reviewed-by: Thomas Huth <thuth@redhat.com>
next prev parent reply other threads:[~2025-10-16 13:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 12:06 [PATCH v3 0/3] target/s390x: Fix missing clock-comparator interrupts Ilya Leoshkevich
2025-10-16 12:06 ` [PATCH v3 1/3] target/s390x: Fix missing interrupts for small CKC values Ilya Leoshkevich
2025-10-16 12:07 ` [PATCH v3 2/3] target/s390x: Fix missing clock-comparator interrupts after reset Ilya Leoshkevich
2025-10-16 13:29 ` Thomas Huth [this message]
2025-10-16 12:07 ` [PATCH v3 3/3] 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=dd902f81-0dd7-4c11-ba15-eb9af71ad2a5@redhat.com \
--to=thuth@redhat.com \
--cc=david@redhat.com \
--cc=iii@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=richard.henderson@linaro.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).