[PATCH v2 10/12] target/riscv: Add kvm_riscv_get/put_regs_timer

Jiangyifei jiangyifei at huawei.com
Mon Dec 20 05:02:01 PST 2021


> -----Original Message-----
> From: Richard Henderson [mailto:richard.henderson at linaro.org]
> Sent: Monday, December 13, 2021 11:20 PM
> To: Anup Patel <anup at brainfault.org>; Jiangyifei <jiangyifei at huawei.com>
> Cc: Bin Meng <bin.meng at windriver.com>; open list:RISC-V
> <qemu-riscv at nongnu.org>; limingwang (A) <limingwang at huawei.com>; KVM
> General <kvm at vger.kernel.org>; libvir-list at redhat.com; Anup Patel
> <anup.patel at wdc.com>; QEMU Developers <qemu-devel at nongnu.org>;
> wanbo (G) <wanbo13 at huawei.com>; Palmer Dabbelt <palmer at dabbelt.com>;
> kvm-riscv at lists.infradead.org; Wanghaibin (D)
> <wanghaibin.wang at huawei.com>; Alistair Francis
> <Alistair.Francis at wdc.com>; Fanliang (EulerOS) <fanliang at huawei.com>;
> Wubin (H) <wu.wubin at huawei.com>
> Subject: Re: [PATCH v2 10/12] target/riscv: Add kvm_riscv_get/put_regs_timer
> 
> On 12/12/21 9:05 PM, Anup Patel wrote:
> >> +    ret = kvm_get_one_reg(cs, RISCV_TIMER_REG(env, state), &reg);
> >> +    if (ret) {
> >> +        abort();
> >> +    }
> >> +    env->kvm_timer_state = reg;
> >
> > Please read the timer frequency here.
> 
> Yep.
> 
> >> +
> >> +    env->kvm_timer_dirty = true;
> >> +}
> >> +
> >> +static void kvm_riscv_put_regs_timer(CPUState *cs) {
> >> +    int ret;
> >> +    uint64_t reg;
> >> +    CPURISCVState *env = &RISCV_CPU(cs)->env;
> >> +
> >> +    if (!env->kvm_timer_dirty) {
> >> +        return;
> >> +    }
> >
> > Over here, we should get the timer frequency and abort() with an error
> > message if it does not match env->kvm_timer_frequency
> >
> > For now, migration will not work between Hosts with different timer
> > frequency.
> 
> You shouldn't have to do this every "put", only on migration, at which point you
> can actually signal a migration error rather than aborting directly.
> 
> 
> r~

Yes, it will be modified in the next series.

Yifei


More information about the kvm-riscv mailing list