From: Oliver Upton <oliver.upton@linux.dev>
Implement support for PSCI CPU_SUSPEND, leveraging in-kernel suspend
emulation (i.e. a WFI state). Eagerly resume the vCPU for any wakeup
event.
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
kvm-cpu.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/kvm-cpu.c b/kvm-cpu.c
index 7362f2e9..d718ef60 100644
--- a/kvm-cpu.c
+++ b/kvm-cpu.c
@@ -143,6 +143,16 @@ void kvm_cpu__run_on_all_cpus(struct kvm *kvm, struct kvm_cpu_task *task)
mutex_unlock(&task_lock);
}
+static void handle_wakeup(struct kvm_cpu *vcpu)
+{
+ struct kvm_mp_state mp_state = {
+ .mp_state = KVM_MP_STATE_RUNNABLE,
+ };
+
+ if (ioctl(vcpu->vcpu_fd, KVM_SET_MP_STATE, &mp_state))
+ die_perror("KVM_SET_MP_STATE failed");
+}
+
int kvm_cpu__start(struct kvm_cpu *cpu)
{
sigset_t sigset;
@@ -236,6 +246,9 @@ int kvm_cpu__start(struct kvm_cpu *cpu)
*/
kvm__reboot(cpu->kvm);
goto exit_kvm;
+ case KVM_SYSTEM_EVENT_WAKEUP:
+ handle_wakeup(cpu);
+ break;
};
break;
default: {
--
2.43.0