mirror of https://github.com/xemu-project/xemu.git
target/riscv: Restrict KVM-specific fields from ArchCPU
These fields shouldn't be accessed when KVM is not available. Restrict the KVM timer migration state. Rename the KVM timer post_load() handler accordingly, because cpu_post_load() is too generic. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Message-Id: <20230626232007.8933-3-philmd@linaro.org>
This commit is contained in:
parent
0573997713
commit
9638cbde6c
|
@ -584,7 +584,7 @@ static void riscv_host_cpu_init(Object *obj)
|
||||||
#endif
|
#endif
|
||||||
riscv_cpu_add_user_properties(obj);
|
riscv_cpu_add_user_properties(obj);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_KVM */
|
||||||
|
|
||||||
static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model)
|
static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model)
|
||||||
{
|
{
|
||||||
|
|
|
@ -363,12 +363,14 @@ struct CPUArchState {
|
||||||
hwaddr kernel_addr;
|
hwaddr kernel_addr;
|
||||||
hwaddr fdt_addr;
|
hwaddr fdt_addr;
|
||||||
|
|
||||||
|
#ifdef CONFIG_KVM
|
||||||
/* kvm timer */
|
/* kvm timer */
|
||||||
bool kvm_timer_dirty;
|
bool kvm_timer_dirty;
|
||||||
uint64_t kvm_timer_time;
|
uint64_t kvm_timer_time;
|
||||||
uint64_t kvm_timer_compare;
|
uint64_t kvm_timer_compare;
|
||||||
uint64_t kvm_timer_state;
|
uint64_t kvm_timer_state;
|
||||||
uint64_t kvm_timer_frequency;
|
uint64_t kvm_timer_frequency;
|
||||||
|
#endif /* CONFIG_KVM */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -194,12 +194,13 @@ static const VMStateDescription vmstate_rv128 = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_KVM
|
||||||
static bool kvmtimer_needed(void *opaque)
|
static bool kvmtimer_needed(void *opaque)
|
||||||
{
|
{
|
||||||
return kvm_enabled();
|
return kvm_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cpu_post_load(void *opaque, int version_id)
|
static int cpu_kvmtimer_post_load(void *opaque, int version_id)
|
||||||
{
|
{
|
||||||
RISCVCPU *cpu = opaque;
|
RISCVCPU *cpu = opaque;
|
||||||
CPURISCVState *env = &cpu->env;
|
CPURISCVState *env = &cpu->env;
|
||||||
|
@ -213,7 +214,7 @@ static const VMStateDescription vmstate_kvmtimer = {
|
||||||
.version_id = 1,
|
.version_id = 1,
|
||||||
.minimum_version_id = 1,
|
.minimum_version_id = 1,
|
||||||
.needed = kvmtimer_needed,
|
.needed = kvmtimer_needed,
|
||||||
.post_load = cpu_post_load,
|
.post_load = cpu_kvmtimer_post_load,
|
||||||
.fields = (VMStateField[]) {
|
.fields = (VMStateField[]) {
|
||||||
VMSTATE_UINT64(env.kvm_timer_time, RISCVCPU),
|
VMSTATE_UINT64(env.kvm_timer_time, RISCVCPU),
|
||||||
VMSTATE_UINT64(env.kvm_timer_compare, RISCVCPU),
|
VMSTATE_UINT64(env.kvm_timer_compare, RISCVCPU),
|
||||||
|
@ -221,6 +222,7 @@ static const VMStateDescription vmstate_kvmtimer = {
|
||||||
VMSTATE_END_OF_LIST()
|
VMSTATE_END_OF_LIST()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool debug_needed(void *opaque)
|
static bool debug_needed(void *opaque)
|
||||||
{
|
{
|
||||||
|
@ -409,7 +411,9 @@ const VMStateDescription vmstate_riscv_cpu = {
|
||||||
&vmstate_vector,
|
&vmstate_vector,
|
||||||
&vmstate_pointermasking,
|
&vmstate_pointermasking,
|
||||||
&vmstate_rv128,
|
&vmstate_rv128,
|
||||||
|
#ifdef CONFIG_KVM
|
||||||
&vmstate_kvmtimer,
|
&vmstate_kvmtimer,
|
||||||
|
#endif
|
||||||
&vmstate_envcfg,
|
&vmstate_envcfg,
|
||||||
&vmstate_debug,
|
&vmstate_debug,
|
||||||
&vmstate_smstateen,
|
&vmstate_smstateen,
|
||||||
|
|
Loading…
Reference in New Issue