Révision | 1eb9a5da31abb0a7b613756f5bb7c887b7ef60ea (tree) |
---|---|
l'heure | 2022-01-21 14:52:56 |
Auteur | Yifei Jiang <jiangyifei@huaw...> |
Commiter | Alistair Francis |
target/riscv: Support virtual time context synchronization
Add virtual time context description to vmstate_kvmtimer. After cpu being
loaded, virtual time context is updated to KVM.
Signed-off-by: Yifei Jiang <jiangyifei@huawei.com>
Signed-off-by: Mingwang Li <limingwang@huawei.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20220112081329.1835-13-jiangyifei@huawei.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
@@ -185,6 +185,35 @@ static const VMStateDescription vmstate_rv128 = { | ||
185 | 185 | } |
186 | 186 | }; |
187 | 187 | |
188 | +static bool kvmtimer_needed(void *opaque) | |
189 | +{ | |
190 | + return kvm_enabled(); | |
191 | +} | |
192 | + | |
193 | +static int cpu_post_load(void *opaque, int version_id) | |
194 | +{ | |
195 | + RISCVCPU *cpu = opaque; | |
196 | + CPURISCVState *env = &cpu->env; | |
197 | + | |
198 | + env->kvm_timer_dirty = true; | |
199 | + return 0; | |
200 | +} | |
201 | + | |
202 | +static const VMStateDescription vmstate_kvmtimer = { | |
203 | + .name = "cpu/kvmtimer", | |
204 | + .version_id = 1, | |
205 | + .minimum_version_id = 1, | |
206 | + .needed = kvmtimer_needed, | |
207 | + .post_load = cpu_post_load, | |
208 | + .fields = (VMStateField[]) { | |
209 | + VMSTATE_UINT64(env.kvm_timer_time, RISCVCPU), | |
210 | + VMSTATE_UINT64(env.kvm_timer_compare, RISCVCPU), | |
211 | + VMSTATE_UINT64(env.kvm_timer_state, RISCVCPU), | |
212 | + | |
213 | + VMSTATE_END_OF_LIST() | |
214 | + } | |
215 | +}; | |
216 | + | |
188 | 217 | const VMStateDescription vmstate_riscv_cpu = { |
189 | 218 | .name = "cpu", |
190 | 219 | .version_id = 3, |
@@ -240,6 +269,7 @@ const VMStateDescription vmstate_riscv_cpu = { | ||
240 | 269 | &vmstate_vector, |
241 | 270 | &vmstate_pointermasking, |
242 | 271 | &vmstate_rv128, |
272 | + &vmstate_kvmtimer, | |
243 | 273 | NULL |
244 | 274 | } |
245 | 275 | }; |