From: Ilya Leoshkevich <[email protected]> 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. Cc: [email protected] Suggested-by: Thomas Huth <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Signed-off-by: Ilya Leoshkevich <[email protected]> Message-ID: <[email protected]> Signed-off-by: Thomas Huth <[email protected]> --- 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; HELPER_LOG("load ctl %d from 0x%" PRIx64 " == 0x%x\n", i, src, val); src += sizeof(uint32_t); -- 2.51.0
