[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/30] target/riscv: Restrict KVM-specific fields from ArchCPU
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 26/30] target/riscv: Restrict KVM-specific fields from ArchCPU |
Date: |
Wed, 28 Jun 2023 17:53:09 +0200 |
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>
---
target/riscv/cpu.h | 2 ++
target/riscv/cpu.c | 2 +-
target/riscv/machine.c | 8 ++++++--
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index 7bff1d47f6..7adb8706ac 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -363,12 +363,14 @@ struct CPUArchState {
hwaddr kernel_addr;
hwaddr fdt_addr;
+#ifdef CONFIG_KVM
/* kvm timer */
bool kvm_timer_dirty;
uint64_t kvm_timer_time;
uint64_t kvm_timer_compare;
uint64_t kvm_timer_state;
uint64_t kvm_timer_frequency;
+#endif /* CONFIG_KVM */
};
/*
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 881bddf393..4035fe0e62 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -584,7 +584,7 @@ static void riscv_host_cpu_init(Object *obj)
#endif
riscv_cpu_add_user_properties(obj);
}
-#endif
+#endif /* CONFIG_KVM */
static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model)
{
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index 3ce2970785..c7c862cdd3 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -194,12 +194,13 @@ static const VMStateDescription vmstate_rv128 = {
}
};
+#ifdef CONFIG_KVM
static bool kvmtimer_needed(void *opaque)
{
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;
CPURISCVState *env = &cpu->env;
@@ -213,7 +214,7 @@ static const VMStateDescription vmstate_kvmtimer = {
.version_id = 1,
.minimum_version_id = 1,
.needed = kvmtimer_needed,
- .post_load = cpu_post_load,
+ .post_load = cpu_kvmtimer_post_load,
.fields = (VMStateField[]) {
VMSTATE_UINT64(env.kvm_timer_time, RISCVCPU),
VMSTATE_UINT64(env.kvm_timer_compare, RISCVCPU),
@@ -221,6 +222,7 @@ static const VMStateDescription vmstate_kvmtimer = {
VMSTATE_END_OF_LIST()
}
};
+#endif
static bool debug_needed(void *opaque)
{
@@ -409,7 +411,9 @@ const VMStateDescription vmstate_riscv_cpu = {
&vmstate_vector,
&vmstate_pointermasking,
&vmstate_rv128,
+#ifdef CONFIG_KVM
&vmstate_kvmtimer,
+#endif
&vmstate_envcfg,
&vmstate_debug,
&vmstate_smstateen,
--
2.38.1
- [PULL 17/30] accel: Rename 'cpu_state' -> 'cs', (continued)
- [PULL 17/30] accel: Rename 'cpu_state' -> 'cs', Philippe Mathieu-Daudé, 2023/06/28
- [PULL 16/30] accel: Inline WHPX get_whpx_vcpu(), Philippe Mathieu-Daudé, 2023/06/28
- [PULL 19/30] accel/kvm: Re-include "exec/memattrs.h" header, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 18/30] accel: Rename HVF 'struct hvf_vcpu_state' -> AccelCPUState, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 21/30] hw/intc/arm_gic: Un-inline GIC*/ITS class_name() helpers, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 28/30] exec/memory: Add symbolic value for memory listener priority for accel, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 20/30] accel/kvm: Declare kvm_direct_msi_allowed in stubs, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 24/30] target/arm: Restrict KVM-specific fields from ArchCPU, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 25/30] target/ppc: Restrict KVM-specific fields from ArchCPU, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 23/30] hw/arm/sbsa-ref: Include missing 'sysemu/kvm.h' header, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 26/30] target/riscv: Restrict KVM-specific fields from ArchCPU,
Philippe Mathieu-Daudé <=
- [PULL 29/30] exec/memory: Add symbol for memory listener priority for device backend, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 22/30] hw/intc/arm_gic: Rename 'first_cpu' argument, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 30/30] exec/memory: Add symbol for the min value of memory listener priority, Philippe Mathieu-Daudé, 2023/06/28
- [PULL 27/30] target/i386/WHPX: Fix error message when fail to set ProcessorCount, Philippe Mathieu-Daudé, 2023/06/28
- Re: [PULL 00/30] Accelerator patches for 2023-06-28, Richard Henderson, 2023/06/29