lib/qemu/qemu_cxl2.0v4/target/mips/kvm.c
/*
 * Restore the state of the KVM timer when VM clock is restarted or state is
 * synced to KVM.
 */
Restore the state of the KVM timer when VM clock is restarted or state is
synced to KVM.
Restore the state of the KVM timer when VM clock is restarted or state is synced to KVM .
static int kvm_mips_restore_count(CPUState *cs)
{
    MIPSCPU *cpu = MIPS_CPU(cs);
    CPUMIPSState *env = &cpu->env;
    uint64_t count_ctl;
    int err_dc, err, ret = 0;
    err_dc = kvm_mips_get_one_ureg64(cs, KVM_REG_MIPS_COUNT_CTL, &count_ctl);
    if (err_dc < 0) {
        DPRINTF("%s: Failed to get COUNT_CTL (%d)\n", __func__, err_dc);
        ret = err_dc;
    } else if (!(count_ctl & KVM_REG_MIPS_COUNT_CTL_DC)) {
        count_ctl |= KVM_REG_MIPS_COUNT_CTL_DC;
        err = kvm_mips_put_one_ureg64(cs, KVM_REG_MIPS_COUNT_CTL, &count_ctl);
        if (err < 0) {
            DPRINTF("%s: Failed to set COUNT_CTL.DC=1 (%d)\n", __func__, err);
            ret = err;
        }
    }
    err = kvm_mips_put_one_reg(cs, KVM_REG_MIPS_CP0_CAUSE, &env->CP0_Cause);
    if (err < 0) {
        DPRINTF("%s: Failed to put CP0_CAUSE (%d)\n", __func__, err);
        ret = err;
    }
    err = kvm_mips_put_one_reg(cs, KVM_REG_MIPS_CP0_COUNT, &env->CP0_Count);
    if (err < 0) {
        DPRINTF("%s: Failed to put CP0_COUNT (%d)\n", __func__, err);
        ret = err;
    }
    if (err_dc >= 0) {
        count_ctl &= ~KVM_REG_MIPS_COUNT_CTL_DC;
        err = kvm_mips_put_one_ureg64(cs, KVM_REG_MIPS_COUNT_CTL, &count_ctl);
        if (err < 0) {
            DPRINTF("%s: Failed to set COUNT_CTL.DC=0 (%d)\n", __func__, err);
            ret = err;
        }
    }
    return ret;
}
static int kvm_mips_restore_count ( CPUState * cs ) { MIPSCPU * cpu = MIPS_CPU ( cs ) ; CPUMIPSState * env = & cpu -> env ; uint64_t count_ctl ; int err_dc , err , ret = 0 ; err_dc = kvm_mips_get_one_ureg64 ( cs , KVM_REG_MIPS_COUNT_CTL , & count_ctl ) ; if ( err_dc < 0 ) { DPRINTF ( " \n " , __func__ , err_dc ) ; ret = err_dc ; } else if ( ! ( count_ctl & KVM_REG_MIPS_COUNT_CTL_DC ) ) { count_ctl |= KVM_REG_MIPS_COUNT_CTL_DC ; err = kvm_mips_put_one_ureg64 ( cs , KVM_REG_MIPS_COUNT_CTL , & count_ctl ) ; if ( err < 0 ) { DPRINTF ( " \n " , __func__ , err ) ; ret = err ; } } err = kvm_mips_put_one_reg ( cs , KVM_REG_MIPS_CP0_CAUSE , & env -> CP0_Cause ) ; if ( err < 0 ) { DPRINTF ( " \n " , __func__ , err ) ; ret = err ; } err = kvm_mips_put_one_reg ( cs , KVM_REG_MIPS_CP0_COUNT , & env -> CP0_Count ) ; if ( err < 0 ) { DPRINTF ( " \n " , __func__ , err ) ; ret = err ; } if ( err_dc >= 0 ) { count_ctl &= ~ KVM_REG_MIPS_COUNT_CTL_DC ; err = kvm_mips_put_one_ureg64 ( cs , KVM_REG_MIPS_COUNT_CTL , & count_ctl ) ; if ( err < 0 ) { DPRINTF ( " \n " , __func__ , err ) ; ret = err ; } } return ret ; }
Restore the state of the KVM timer when VM clock is restarted or state is
 synced to KVM.
Restore the state of the KVM timer when VM clock is restarted or state is synced to KVM .
/* check the timer is frozen */ /* freeze timer (sets COUNT_RESUME for us) */ /* load CP0_Cause */ /* load CP0_Count */ /* resume KVM timer */