On 16/10/2025 11.53, Thomas Huth wrote:
  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?

... but it looks like your TCG test is failing without this second patch.

Ok, I think I understood it now: We don't re-arm the CKC timer in case the guest writes to the CR0. So we need to have the timer started during reset already to make the interrupt pending, so that it can fire when the guest changes CR0.

So I guess this patch is fine. Or alternatively you could maybe re-arm the CKC during stctg, would that be better? What do you think?

 Thomas


Reply via email to