@@ -38,6 +38,8 @@ void kvm_cpu__set_kvm_arm_generic_target(struct kvm_arm_target *target);
int kvm_cpu__register_kvm_arm_target(struct kvm_arm_target *target);
+void kvm_cpu__arm_reset(struct kvm_cpu *vcpu);
+
static inline bool kvm_cpu__emulate_io(struct kvm_cpu *vcpu, u16 port, void *data,
int direction, int size, u32 count)
{
@@ -35,6 +35,15 @@ int kvm_cpu__register_kvm_arm_target(struct kvm_arm_target *target)
return -ENOSPC;
}
+void kvm_cpu__arm_reset(struct kvm_cpu *vcpu)
+{
+ if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_INIT, &vcpu->init))
+ die_perror("KVM_ARM_VCPU_INIT failed");
+
+ if (kvm_cpu__configure_features(vcpu))
+ die("Unable to configure requested vcpu features");
+}
+
struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
{
struct kvm_arm_target *target;
@@ -122,15 +131,14 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
if (err || target->init(vcpu))
die("Unable to initialise vcpu");
+ kvm_cpu__arm_reset(vcpu);
+
coalesced_offset = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION,
KVM_CAP_COALESCED_MMIO);
if (coalesced_offset)
vcpu->ring = (void *)vcpu->kvm_run +
(coalesced_offset * PAGE_SIZE);
- if (kvm_cpu__configure_features(vcpu))
- die("Unable to configure requested vcpu features");
-
return vcpu;
}
In order to handle PSCI, we need a way to reset a vCPU. Fortunately, the KVM_ARM_VCPU_INIT ioctl is said to have the effect of an architectural reset. Reconfigure features after the INIT ioctl, if necessary (SVE). Signed-off-by: Oliver Upton <oliver.upton@linux.dev> --- arm/include/arm-common/kvm-cpu-arch.h | 2 ++ arm/kvm-cpu.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-)