lib/qemu/qemu_cxl2.0v4/target/mips/kvm.c
/*
 * Save the state of the KVM timer when VM clock is stopped or state is synced
 * to QEMU.
 */
Save the state of the KVM timer when VM clock is stopped or state is synced
to QEMU.
Save the state of the KVM timer when VM clock is stopped or state is synced to QEMU .
static int kvm_mips_save_count(CPUState *cs)
{
    MIPSCPU *cpu = MIPS_CPU(cs);
    CPUMIPSState *env = &cpu->env;
    uint64_t count_ctl;
    int err, ret = 0;
    err = kvm_mips_get_one_ureg64(cs, KVM_REG_MIPS_COUNT_CTL, &count_ctl);
    if (err < 0) {
        DPRINTF("%s: Failed to get COUNT_CTL (%d)\n", __func__, err);
        ret = err;
    } 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_get_one_reg(cs, KVM_REG_MIPS_CP0_CAUSE, &env->CP0_Cause);
    if (err < 0) {
        DPRINTF("%s: Failed to get CP0_CAUSE (%d)\n", __func__, err);
        ret = err;
    }
    err = kvm_mips_get_one_reg(cs, KVM_REG_MIPS_CP0_COUNT, &env->CP0_Count);
    if (err < 0) {
        DPRINTF("%s: Failed to get CP0_COUNT (%d)\n", __func__, err);
        ret = err;
    }
    return ret;
}
static int kvm_mips_save_count ( CPUState * cs ) { MIPSCPU * cpu = MIPS_CPU ( cs ) ; CPUMIPSState * env = & cpu -> env ; uint64_t count_ctl ; int err , ret = 0 ; err = kvm_mips_get_one_ureg64 ( cs , KVM_REG_MIPS_COUNT_CTL , & count_ctl ) ; if ( err < 0 ) { DPRINTF ( " \n " , __func__ , err ) ; ret = err ; } 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_get_one_reg ( cs , KVM_REG_MIPS_CP0_CAUSE , & env -> CP0_Cause ) ; if ( err < 0 ) { DPRINTF ( " \n " , __func__ , err ) ; ret = err ; } err = kvm_mips_get_one_reg ( cs , KVM_REG_MIPS_CP0_COUNT , & env -> CP0_Count ) ; if ( err < 0 ) { DPRINTF ( " \n " , __func__ , err ) ; ret = err ; } return ret ; }
Save the state of the KVM timer when VM clock is stopped or state is synced
 to QEMU.
Save the state of the KVM timer when VM clock is stopped or state is synced to QEMU .
/* freeze KVM timer */ /* read CP0_Cause */ /* read CP0_Count */