From: Yifei Jiang <jiangyifei@huawei.com> To: <qemu-devel@nongnu.org>, <qemu-riscv@nongnu.org> Cc: <kvm-riscv@lists.infradead.org>, <kvm@vger.kernel.org>, <libvir-list@redhat.com>, <anup.patel@wdc.com>, <palmer@dabbelt.com>, <Alistair.Francis@wdc.com>, <sagark@eecs.berkeley.edu>, <kbastian@mail.uni-paderborn.de>, <victor.zhangxiaofeng@huawei.com>, <wu.wubin@huawei.com>, <zhang.zhanghailiang@huawei.com>, <dengkai1@huawei.com>, <yinyipeng1@huawei.com>, Yifei Jiang <jiangyifei@huawei.com> Subject: [PATCH RFC v4 14/15] target/riscv: Synchronize vcpu's frequency with KVM Date: Thu, 3 Dec 2020 20:47:02 +0800 [thread overview] Message-ID: <20201203124703.168-15-jiangyifei@huawei.com> (raw) In-Reply-To: <20201203124703.168-1-jiangyifei@huawei.com> If vcpu's frequency is specified by cpu option 'frequency', it will be set into KVM by KVM_SET_ONE_REG ioctl. Otherwise, vcpu's frequency will follow KVM by KVM_GET_ONE_REG ioctl. Signed-off-by: Yifei Jiang <jiangyifei@huawei.com> Signed-off-by: Yipeng Yin <yinyipeng1@huawei.com> --- target/riscv/kvm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index 1e16d24544..3499efd4eb 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -409,6 +409,8 @@ int kvm_arch_get_registers(CPUState *cs) int kvm_arch_put_registers(CPUState *cs, int level) { int ret = 0; + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; ret = kvm_riscv_put_regs_core(cs); if (ret) { @@ -425,6 +427,10 @@ int kvm_arch_put_registers(CPUState *cs, int level) return ret; } + if (env->frequency) { + ret = kvm_set_one_reg(cs, RISCV_TIMER_REG(frequency), &env->frequency); + } + return ret; } @@ -481,6 +487,17 @@ int kvm_arch_init_vcpu(CPUState *cs) } env->misa = isa; + /* + * Synchronize vcpu's frequency with KVM. If vcpu's frequency is specified + * by cpu option 'frequency', this will be set to KVM. Otherwise, vcpu's + * frequency will follow KVM. + */ + if (env->user_frequency) { + ret = kvm_set_one_reg(cs, RISCV_TIMER_REG(frequency), &env->frequency); + } else { + ret = kvm_get_one_reg(cs, RISCV_TIMER_REG(frequency), &env->frequency); + } + return ret; } -- 2.19.1
WARNING: multiple messages have this Message-ID (diff)
From: Yifei Jiang <jiangyifei@huawei.com> To: <qemu-devel@nongnu.org>, <qemu-riscv@nongnu.org> Cc: victor.zhangxiaofeng@huawei.com, sagark@eecs.berkeley.edu, kvm@vger.kernel.org, libvir-list@redhat.com, kbastian@mail.uni-paderborn.de, anup.patel@wdc.com, yinyipeng1@huawei.com, Alistair.Francis@wdc.com, Yifei Jiang <jiangyifei@huawei.com>, kvm-riscv@lists.infradead.org, palmer@dabbelt.com, dengkai1@huawei.com, wu.wubin@huawei.com, zhang.zhanghailiang@huawei.com Subject: [PATCH RFC v4 14/15] target/riscv: Synchronize vcpu's frequency with KVM Date: Thu, 3 Dec 2020 20:47:02 +0800 [thread overview] Message-ID: <20201203124703.168-15-jiangyifei@huawei.com> (raw) In-Reply-To: <20201203124703.168-1-jiangyifei@huawei.com> If vcpu's frequency is specified by cpu option 'frequency', it will be set into KVM by KVM_SET_ONE_REG ioctl. Otherwise, vcpu's frequency will follow KVM by KVM_GET_ONE_REG ioctl. Signed-off-by: Yifei Jiang <jiangyifei@huawei.com> Signed-off-by: Yipeng Yin <yinyipeng1@huawei.com> --- target/riscv/kvm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index 1e16d24544..3499efd4eb 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -409,6 +409,8 @@ int kvm_arch_get_registers(CPUState *cs) int kvm_arch_put_registers(CPUState *cs, int level) { int ret = 0; + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; ret = kvm_riscv_put_regs_core(cs); if (ret) { @@ -425,6 +427,10 @@ int kvm_arch_put_registers(CPUState *cs, int level) return ret; } + if (env->frequency) { + ret = kvm_set_one_reg(cs, RISCV_TIMER_REG(frequency), &env->frequency); + } + return ret; } @@ -481,6 +487,17 @@ int kvm_arch_init_vcpu(CPUState *cs) } env->misa = isa; + /* + * Synchronize vcpu's frequency with KVM. If vcpu's frequency is specified + * by cpu option 'frequency', this will be set to KVM. Otherwise, vcpu's + * frequency will follow KVM. + */ + if (env->user_frequency) { + ret = kvm_set_one_reg(cs, RISCV_TIMER_REG(frequency), &env->frequency); + } else { + ret = kvm_get_one_reg(cs, RISCV_TIMER_REG(frequency), &env->frequency); + } + return ret; } -- 2.19.1
next prev parent reply other threads:[~2020-12-03 12:48 UTC|newest] Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-03 12:46 [PATCH RFC v4 00/15] Add riscv kvm accel support Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-03 12:46 ` [PATCH RFC v4 01/15] linux-header: Update linux/kvm.h Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-03 12:46 ` [PATCH RFC v4 02/15] target/riscv: Add target/riscv/kvm.c to place the public kvm interface Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-03 12:46 ` [PATCH RFC v4 03/15] target/riscv: Implement function kvm_arch_init_vcpu Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-08 22:13 ` Alistair Francis 2020-12-08 22:13 ` Alistair Francis 2020-12-03 12:46 ` [PATCH RFC v4 04/15] target/riscv: Implement kvm_arch_get_registers Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-03 12:46 ` [PATCH RFC v4 05/15] target/riscv: Implement kvm_arch_put_registers Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-03 12:46 ` [PATCH RFC v4 06/15] target/riscv: Support start kernel directly by KVM Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-08 22:19 ` Alistair Francis 2020-12-08 22:19 ` Alistair Francis 2020-12-15 7:19 ` Jiangyifei 2020-12-15 7:19 ` Jiangyifei 2020-12-03 12:46 ` [PATCH RFC v4 07/15] hw/riscv: PLIC update external interrupt by KVM when kvm enabled Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-08 22:29 ` Alistair Francis 2020-12-08 22:29 ` Alistair Francis 2020-12-15 7:33 ` Jiangyifei 2020-12-15 7:33 ` Jiangyifei 2020-12-03 12:46 ` [PATCH RFC v4 08/15] target/riscv: Handle KVM_EXIT_RISCV_SBI exit Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-03 12:46 ` [PATCH RFC v4 09/15] target/riscv: Add host cpu type Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-08 22:21 ` Alistair Francis 2020-12-08 22:21 ` Alistair Francis 2020-12-15 7:21 ` Jiangyifei 2020-12-15 7:21 ` Jiangyifei 2020-12-03 12:46 ` [PATCH RFC v4 10/15] target/riscv: Add kvm_riscv_get/put_regs_timer Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-03 12:46 ` [PATCH RFC v4 11/15] target/riscv: Implement virtual time adjusting with vm state changing Yifei Jiang 2020-12-03 12:46 ` Yifei Jiang 2020-12-03 12:47 ` [PATCH RFC v4 12/15] target/riscv: Support virtual time context synchronization Yifei Jiang 2020-12-03 12:47 ` Yifei Jiang 2020-12-03 12:47 ` [PATCH RFC v4 13/15] target/riscv: Introduce dynamic time frequency for virt machine Yifei Jiang 2020-12-03 12:47 ` Yifei Jiang 2020-12-08 22:25 ` Alistair Francis 2020-12-08 22:25 ` Alistair Francis 2020-12-15 7:31 ` Jiangyifei 2020-12-15 7:31 ` Jiangyifei 2021-01-05 17:36 ` Alistair Francis 2021-01-05 17:36 ` Alistair Francis 2020-12-03 12:47 ` Yifei Jiang [this message] 2020-12-03 12:47 ` [PATCH RFC v4 14/15] target/riscv: Synchronize vcpu's frequency with KVM Yifei Jiang 2020-12-03 12:47 ` [PATCH RFC v4 15/15] target/riscv: Add time frequency migration support Yifei Jiang 2020-12-03 12:47 ` Yifei Jiang
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20201203124703.168-15-jiangyifei@huawei.com \ --to=jiangyifei@huawei.com \ --cc=Alistair.Francis@wdc.com \ --cc=anup.patel@wdc.com \ --cc=dengkai1@huawei.com \ --cc=kbastian@mail.uni-paderborn.de \ --cc=kvm-riscv@lists.infradead.org \ --cc=kvm@vger.kernel.org \ --cc=libvir-list@redhat.com \ --cc=palmer@dabbelt.com \ --cc=qemu-devel@nongnu.org \ --cc=qemu-riscv@nongnu.org \ --cc=sagark@eecs.berkeley.edu \ --cc=victor.zhangxiaofeng@huawei.com \ --cc=wu.wubin@huawei.com \ --cc=yinyipeng1@huawei.com \ --cc=zhang.zhanghailiang@huawei.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.