All of lore.kernel.org
 help / color / mirror / Atom feed
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 15/15] target/riscv: Add time frequency migration support
Date: Thu, 3 Dec 2020 20:47:03 +0800	[thread overview]
Message-ID: <20201203124703.168-16-jiangyifei@huawei.com> (raw)
In-Reply-To: <20201203124703.168-1-jiangyifei@huawei.com>

If vcpu's time frequency is not specified by CPU option 'time-frequency'
on the destination, the time frequency of destination will follow
the source.

If vcpu's time frequency specified by CPU option 'time-frequency' on the
destination is different from migrated time frequency. The migration
will be abort.

Signed-off-by: Yifei Jiang <jiangyifei@huawei.com>
Signed-off-by: Yipeng Yin <yinyipeng1@huawei.com>
---
 target/riscv/machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index ef2d5395a8..6955542fef 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -144,6 +144,13 @@ static int cpu_post_load(void *opaque, int version_id)
     CPURISCVState *env = &cpu->env;
 
     env->kvm_timer_dirty = true;
+
+    if (env->user_frequency && env->user_frequency != env->frequency) {
+        error_report("Mismatch between user-specified time frequency and "
+                     "migrated time frequency");
+        return -EINVAL;
+    }
+
     return 0;
 }
 
@@ -198,6 +205,7 @@ const VMStateDescription vmstate_riscv_cpu = {
         VMSTATE_UINT64(env.kvm_timer_time, RISCVCPU),
         VMSTATE_UINT64(env.kvm_timer_compare, RISCVCPU),
         VMSTATE_UINT64(env.kvm_timer_state, RISCVCPU),
+        VMSTATE_UINT64(env.frequency, RISCVCPU),
 
         VMSTATE_END_OF_LIST()
     },
-- 
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 15/15] target/riscv: Add time frequency migration support
Date: Thu, 3 Dec 2020 20:47:03 +0800	[thread overview]
Message-ID: <20201203124703.168-16-jiangyifei@huawei.com> (raw)
In-Reply-To: <20201203124703.168-1-jiangyifei@huawei.com>

If vcpu's time frequency is not specified by CPU option 'time-frequency'
on the destination, the time frequency of destination will follow
the source.

If vcpu's time frequency specified by CPU option 'time-frequency' on the
destination is different from migrated time frequency. The migration
will be abort.

Signed-off-by: Yifei Jiang <jiangyifei@huawei.com>
Signed-off-by: Yipeng Yin <yinyipeng1@huawei.com>
---
 target/riscv/machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index ef2d5395a8..6955542fef 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -144,6 +144,13 @@ static int cpu_post_load(void *opaque, int version_id)
     CPURISCVState *env = &cpu->env;
 
     env->kvm_timer_dirty = true;
+
+    if (env->user_frequency && env->user_frequency != env->frequency) {
+        error_report("Mismatch between user-specified time frequency and "
+                     "migrated time frequency");
+        return -EINVAL;
+    }
+
     return 0;
 }
 
@@ -198,6 +205,7 @@ const VMStateDescription vmstate_riscv_cpu = {
         VMSTATE_UINT64(env.kvm_timer_time, RISCVCPU),
         VMSTATE_UINT64(env.kvm_timer_compare, RISCVCPU),
         VMSTATE_UINT64(env.kvm_timer_state, RISCVCPU),
+        VMSTATE_UINT64(env.frequency, RISCVCPU),
 
         VMSTATE_END_OF_LIST()
     },
-- 
2.19.1



  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 ` [PATCH RFC v4 14/15] target/riscv: Synchronize vcpu's frequency with KVM Yifei Jiang
2020-12-03 12:47   ` Yifei Jiang
2020-12-03 12:47 ` Yifei Jiang [this message]
2020-12-03 12:47   ` [PATCH RFC v4 15/15] target/riscv: Add time frequency migration support 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-16-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: link
Be 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.