Skip to content

RFC ARM: Implement PSCI SYSTEM_SUSPEND

Oliver Upton kvm kvm-riscv kvmarm linux-arm-kernel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest5 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5TESTONLY: Sync KVM headers with pending changesinclude/linux/kvm.h+21 -00 replies
2/5Allow architectures to hook KVM_EXIT_SYSTEM_EVENTinclude/kvm/kvm-cpu.h kvm-cpu.c+9 -00 replies
3/5ARM: Stash vcpu_init in the vCPU structurearm/include/arm-common/kvm-cpu-arch.h arm/kvm-cpu.c+10 -100 replies
4/5ARM: Add a helper to re-init a vCPUarm/kvm-cpu.c+10 -20 replies
5/5ARM: Implement PSCI SYSTEM_SUSPENDarm/aarch32/kvm-cpu.c arm/aarch64/kvm-cpu.c arm/include/arm-common/kvm-cpu-arch.h +2 more+233 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH kvmtool 0/5] ARM: Implement PSCI SYSTEM_SUSPEND

This is a prototype for supporting KVM_CAP_ARM_SYSTEM_SUSPEND on kvmtool. The capability allows userspace to expose the SYSTEM_SUSPEND PSCI call to its guests.

Implement SYSTEM_SUSPEND using KVM_MP_STATE_SUSPENDED, which emulates the execution of a WFI instruction in the kernel. Resume the guest when a wakeup event is recognized and reset it to the requested entry address and context ID.

Patches 2-4 are small reworks to more easily shoehorn PSCI support into kvmtool.

Patch 5 adds some SMCCC handlers and makes use of them to implement PSCI SYSTEM_SUSPEND. For now, just check the bare-minimum, that all vCPUs besides the caller have stopped. There are also checks that can be made against the requested entry address, but they are at the discretion of the implementation.

Tested with 'echo mem > /sys/power/state' to see that the vCPU is in fact placed in a suspended state for the PSCI call. Hacked the switch statement to fall through to WAKEUP immediately after to verify the vCPU is set up correctly for resume.

It would be nice if kvmtool actually provided a device good for wakeups, since the RTC implementation has omitted any interrupt support.

kernel changes: http://lore.kernel.org/r/[email protected]

Oliver Upton (5):
TESTONLY: Sync KVM headers with pending changes Allow architectures to hook KVM_EXIT_SYSTEM_EVENT
ARM: Stash vcpu_init in the vCPU structure
ARM: Add a helper to re-init a vCPU
ARM: Implement PSCI SYSTEM_SUSPEND

 arm/aarch32/kvm-cpu.c                 | 72 ++++++++++++++++++++
 arm/aarch64/kvm-cpu.c                 | 66 +++++++++++++++++++
 arm/include/arm-common/kvm-cpu-arch.h | 23 ++++---
 arm/kvm-cpu.c                         | 95 ++++++++++++++++++++++++++-
 arm/kvm.c                             |  9 +++
 include/kvm/kvm-cpu.h                 |  1 +
 include/linux/kvm.h                   | 21 ++++++
 kvm-cpu.c                             |  8 +++
 8 files changed, 283 insertions(+), 12 deletions(-)
Signature · 1 line
2.35.1.723.g4982287a31-goog