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 v2 2/3] target/s390x: Fix missing clock-comparator interrupts after reset
Date: Thu, 16 Oct 2025 11:53:41 +0200	[thread overview]
Message-ID: <54485257-164e-485d-b82b-baae4b175a9c@redhat.com> (raw)
In-Reply-To: <20251015142141.3238-3-iii@linux.ibm.com>
  Hi Ilya!
On 15/10/2025 16.21, 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 does not set tod_timer, so this does not happen.
> 
> Fix by adding a tcg_s390_tod_updated() call. Initialize TOD clock
> before CPUs in order to ensure that the respective object exists
> during the CPU reset.
Can this really happen? Looking at CPUS390XState in target/s390x/cpu.h, the 
ckc is next to the cregs[] in the start_initial_reset_fields section, so if 
ckc gets cleared, the cregs get cleared, too. I.e. if ckc gets set to 0 
here, there is no way that the clock comparator interrupt could trigger 
immediately without the guest writing to the control registers first. So I 
think this patch is not really necessary. Or do I miss something?
  Thomas
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   hw/s390x/s390-virtio-ccw.c | 6 +++---
>   target/s390x/cpu.c         | 8 ++++++++
>   2 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index ad2c48188a8..9f37a96ae5a 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -286,6 +286,9 @@ static void ccw_init(MachineState *machine)
>       /* init memory + setup max page size. Required for the CPU model */
>       s390_memory_init(machine);
>   
> +    /* init the TOD clock */
> +    s390_init_tod();
> +
>       /* init CPUs (incl. CPU model) early so s390_has_feature() works */
>       s390_init_cpus(machine);
>   
> @@ -332,9 +335,6 @@ static void ccw_init(MachineState *machine)
>           s390_create_sclpconsole(ms->sclp, "sclplmconsole", serial_hd(1));
>       }
>   
> -    /* init the TOD clock */
> -    s390_init_tod();
> -
>       /* init SCLP event Control-Program Identification */
>       if (s390mc->use_cpi) {
>           s390_create_sclpcpi(ms->sclp);
> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
> index f05ce317da1..cc2de6ce08e 100644
> --- a/target/s390x/cpu.c
> +++ b/target/s390x/cpu.c
> @@ -40,6 +40,7 @@
>   #include "system/reset.h"
>   #endif
>   #include "hw/s390x/cpu-topology.h"
> +#include "tcg/tcg_s390x.h"
>   
>   #define CR0_RESET       0xE0UL
>   #define CR14_RESET      0xC2000000UL;
> @@ -215,6 +216,13 @@ static void s390_cpu_reset_hold(Object *obj, ResetType type)
>               break;
>           }
>       }
> +
> +#ifndef CONFIG_USER_ONLY
> +    if (tcg_enabled()) {
> +        /* Rearm the CKC timer if necessary */
> +        tcg_s390_tod_updated(CPU(cpu), RUN_ON_CPU_NULL);
> +    }
> +#endif
>   }
>   
>   static void s390_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
next prev parent reply	other threads:[~2025-10-16  9:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15 14:21 [PATCH v2 0/3] target/s390x: Fix missing clock-comparator interrupts Ilya Leoshkevich
2025-10-15 14:21 ` [PATCH v2 1/3] target/s390x: Fix missing interrupts for small CKC values Ilya Leoshkevich
2025-10-15 14:21 ` [PATCH v2 2/3] target/s390x: Fix missing clock-comparator interrupts after reset Ilya Leoshkevich
2025-10-16  9:53   ` Thomas Huth [this message]
2025-10-16 11:34     ` Thomas Huth
2025-10-15 14:21 ` [PATCH v2 3/3] tests/tcg/s390x: Test SET CLOCK COMPARATOR Ilya Leoshkevich
2025-10-16 10:01   ` 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=54485257-164e-485d-b82b-baae4b175a9c@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).