Skip to content

KVM: arm64: PSCI SYSTEM_SUSPEND support

Oliver Upton kvm kvmarm linux-arm-kernel lkml 5 versions – Applied

Status from this message: Applied to next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest12 patches 1 replyApplied
  2. v513 patches 10 repliesSuperseded
  3. v319 patches 27 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v211 patches32 repliesSuperseded
v16 patches9 repliesSuperseded

Changes in v6 from the cover letter

- Rebase to 5.18-rc5
- Collect Reiji's R-b's
- Drop the system_event helper. Since we now have variadic data returning to userspace it doesn't make much sense to roll it up into a helper. Meh.
- Put back the pointless kvm_vcpu_request() in kvm_arm_vcpu_suspend(). We'll rip out the reliance on vCPU requests for power state later on. It is entirely benign, even when a vCPU targets itself.

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/12KVM: arm64: Don't depend on fallthrough to hide SYSTEM_RESET2arch/arm64/kvm/psci.c+5 -80 replies
2/12KVM: arm64: Dedupe vCPU power off helpersarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c arch/arm64/kvm/psci.c+7 -120 replies
3/12KVM: arm64: Track vCPU power state using MP state valuesarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c arch/arm64/kvm/psci.c+21 -180 replies
4/12KVM: arm64: Rename the KVM_REQ_SLEEP handlerarch/arm64/kvm/arm.c+2 -20 replies
5/12KVM: arm64: Return a value from check_vcpu_requests()arch/arm64/kvm/arm.c+14 -20 replies
6/12KVM: arm64: Add support for userspace to suspend a vCPUDocumentation/virt/kvm/api.rst arch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c +1 more+89 -20 replies
7/12KVM: arm64: Implement PSCI SYSTEM_SUSPENDDocumentation/virt/kvm/api.rst arch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c +2 more+77 -00 replies
8/12selftests: KVM: Rename psci_cpu_on_test to psci_testtools/testing/selftests/kvm/.gitignore tools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/aarch64/psci_test.c+2 -20 replies
9/12selftests: KVM: Create helper for making SMCCC callstools/testing/selftests/kvm/aarch64/psci_test.c tools/testing/selftests/kvm/include/aarch64/processor.h tools/testing/selftests/kvm/lib/aarch64/processor.c +1 more+58 -270 replies
10/12selftests: KVM: Use KVM_SET_MP_STATE to power off vCPU in psci_testtools/testing/selftests/kvm/aarch64/psci_test.c+11 -20 replies
11/12selftests: KVM: Refactor psci_test to make it amenable to new teststools/testing/selftests/kvm/aarch64/psci_test.c+60 -370 replies
12/12selftests: KVM: Test SYSTEM_SUSPEND PSCI calltools/testing/selftests/kvm/aarch64/psci_test.c+69 -00 replies

Reviews trailers per patch

8 of 12 patches have a Reviewed-by or Acked-by.

PatchReiji WatanabeAndrew Jones
1/12R-b
2/12R-b
3/12R-b
4/12R-b
5/12
6/12
7/12R-b
8/12R-b
9/12R-b
10/12
11/12R-b
12/12

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH v6 00/12] KVM: arm64: PSCI SYSTEM_SUSPEND support

The PSCI v1.0 specification describes a call, SYSTEM_SUSPEND, which allows software to request that the system be placed into the lowest possible power state and await a wakeup event. This call is optional in v1.0 and v1.1. KVM does not currently support this optional call.

This series adds support for the PSCI SYSTEM_SUSPEND call to KVM/arm64. For reasons best described in patch 8, it is infeasible to correctly implement PSCI SYSTEM_SUSPEND (or any system-wide event for that matter) in a split design between kernel/userspace. As such, this series cheaply exits to userspace so it can decide what to do with the call. This series also gives userspace some help to emulate suspension with a new MP state that awaits an unmasked pending interrupt.

Patches 1-5 are small reworks to more easily shoehorn the new features into the kernel.

Patch 6 stands up the new suspend MP state, allowing userspace to emulate the PSCI call.

Patch 7 actually allows userspace to enable the PSCI call, which requires explicit opt-in for the new KVM_EXIT_SYSTEM_EVENT type.

Patches 8-11 clean up the way PSCI is tested in selftests to more easily add new test cases.

Finally, the last patch actually tests that PSCI SYSTEM_SUSPEND calls within the guest result in userspace exits.

Applies cleanly to 5.18-rc5. I'm sure you're already aware of it Marc, but for the sake of everyone else there's some light conflict with Raghu's patches that you've got queued up [1].

Tested with the included selftest and a hacked up kvmtool [2] with support for the new UAPI.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/hcall-selection
[2]: https://lore.kernel.org/all/[email protected]/

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

v5 -> v6:
- Rebase to 5.18-rc5
- Collect Reiji's R-b's
- Drop the system_event helper. Since we now have variadic data returning to userspace it doesn't make much sense to roll it up into a helper. Meh.
- Put back the pointless kvm_vcpu_request() in kvm_arm_vcpu_suspend(). We'll rip out the reliance on vCPU requests for power state later on. It is entirely benign, even when a vCPU targets itself.

Oliver Upton (12):
KVM: arm64: Don't depend on fallthrough to hide SYSTEM_RESET2
KVM: arm64: Dedupe vCPU power off helpers
KVM: arm64: Track vCPU power state using MP state values
KVM: arm64: Rename the KVM_REQ_SLEEP handler
KVM: arm64: Return a value from check_vcpu_requests()
KVM: arm64: Add support for userspace to suspend a vCPU
KVM: arm64: Implement PSCI SYSTEM_SUSPEND
selftests: KVM: Rename psci_cpu_on_test to psci_test
selftests: KVM: Create helper for making SMCCC calls
selftests: KVM: Use KVM_SET_MP_STATE to power off vCPU in psci_test
selftests: KVM: Refactor psci_test to make it amenable to new tests
selftests: KVM: Test SYSTEM_SUSPEND PSCI call

 Documentation/virt/kvm/api.rst                |  76 ++++++-
 arch/arm64/include/asm/kvm_host.h             |  10 +-
 arch/arm64/kvm/arm.c                          | 104 +++++++--
 arch/arm64/kvm/psci.c                         |  65 ++++--
 include/uapi/linux/kvm.h                      |   4 +
 tools/testing/selftests/kvm/.gitignore        |   2 +-
 tools/testing/selftests/kvm/Makefile          |   2 +-
 .../selftests/kvm/aarch64/psci_cpu_on_test.c  | 121 ----------
 .../testing/selftests/kvm/aarch64/psci_test.c | 213 ++++++++++++++++++
 .../selftests/kvm/include/aarch64/processor.h |  22 ++
 .../selftests/kvm/lib/aarch64/processor.c     |  25 ++
 tools/testing/selftests/kvm/steal_time.c      |  13 +-
 12 files changed, 480 insertions(+), 177 deletions(-)
 delete mode 100644 tools/testing/selftests/kvm/aarch64/psci_cpu_on_test.c
 create mode 100644 tools/testing/selftests/kvm/aarch64/psci_test.c
Signature · 1 line
2.36.0.464.gb9c8b46e94-goog