Skip to content

KVM: s390: arm64: SMCCC, timers and IRQ line

Steffen Eiden kvm kvmarm linux-arm-kernel linux-s390 lkml 1 version New

Get series with b4
b4 am [email protected] change-id 20261127-smccc-c8cb09f78ebc

Versions newest first

  1. v1 Latest12 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12arm64: Prepare for sharing with s390arch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arch_timer.c arch/arm64/kvm/arm.c +2 more+57 -500 replies
2/12arm64: Share timer and smccc functionality with s390arch/arm64/include/asm/kvm_emulate.h arch/arm64/include/asm/kvm_host.h arch/arm64/include/asm/kvm_mmu.h +1 more+25 -180 replies
3/12KVM: arm64: Share timer and smccc code with s390arch/arm64/kvm/arch_timer.c arch/arm64/kvm/arm.c arch/arm64/kvm/hypercalls.c +3 more+34 -00 replies
4/12KVM: s390: arm64: Use register shadow helperarch/s390/kvm/arm64/arm.c+17 -80 replies
5/12KVM: s390: arm64: Shadow the guest timer CVAL registersarch/s390/include/asm/kvm_host_arm64.h arch/s390/kvm/arm64/arm.c arch/s390/kvm/arm64/sys_regs.c+14 -60 replies
6/12KVM: s390: arm64: Use mpstate for guestsarch/s390/include/asm/kvm_host_arm64.h arch/s390/kvm/arm64/arm.c+37 -30 replies
7/12KVM: s390: arm64: Enable full smccc supportarch/s390/include/asm/kvm_host_arm64.h arch/s390/kvm/Kconfig arch/s390/kvm/arm64/Makefile +10 more+235 -370 replies
8/12KVM: s390: arm64: Report fwregs to userspacearch/s390/kvm/arm64/guest.c+14 -00 replies
9/12KVM: s390: arm64: Provide timer infrastructurearch/s390/include/arm64/kvm_emulate.h arch/s390/include/asm/kvm_host_arm64.h arch/s390/kvm/arm64/Makefile +3 more+233 -50 replies
10/12KVM: s390: arm64: Integrate guest timerarch/s390/kvm/arm64/arch_timer.c arch/s390/kvm/arm64/arm.c arch/s390/kvm/arm64/handle_exit.c +1 more+38 -20 replies
11/12KVM: s390: arm64: Trap WFxarch/s390/kvm/arm64/handle_exit.c arch/s390/kvm/arm64/reset.c+56 -10 replies
12/12KVM: s390: arm64: Add IRQ linearch/s390/include/arm64/kvm_emulate.h arch/s390/include/asm/kvm_host_arm64.h arch/s390/kvm/arm64/arm.c +2 more+77 -50 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 00/12] KVM: s390: arm64: SMCCC, timers and IRQ line

Add SMCCC/PSCI support, the arm64 architected timers, WFx* handling and the userspace IRQ line for KVM/arm64 on s390. The arm64 SMCCC, timer and vCPU power management code is shared with s390 and wired into the s390 KVM module.

This is the third series on the way to arm64 guests on s390. The first series laid the KVM foundation (basic module, vCPU run, simple page faults) and is included in v7.4. The second series built the system register layer [1]. This series adds the guest CPU management layer on top. Power management with PSCI, full SMCCC handling, the architected timers and interrupt injection from userspace.

This series depends on the second series [1], on the vCPU kick enabling series [2], and on the vgic stubs patch [3]

PATCH 04 and 05 can be squashed into series 2 [1] and will be when I send v5. I just did not want to send a respin after a few days w/o much comments.

Changes in detail:

arm64:

Prepare headers and code for sharing with s390: guard arm64 headers that reside in include/ such that s390 can consume them, and move a few things/ The moves add a bit of churn in the diff but reduce the number of shared sections required for the timer from seven to two.

Share the SMCCC related files (hypercalls, psci, trng, pvtime) as a whole.Share the timer functionality that is architecture agnostic. As timers work differently on s390 only a subset can be reused. Share the functions for managing SMP guests.

s390:

Implement the mp_state plumbing for arm64 guests backed by the shared power-off/suspend infrastructure and the MPIDR data used for SMP guest management.

Use the shared arm64 code for handling SMCCCs and implement the final host-side plumbing, removing the primitive SYSTEM_OFF only implementation.

Add support for the arm64 architected timers (virtual and physical) of an arm64 guest. The SAE block holds the timer control registers, and ISTATUS in CTL is set when a timer condition is met. The shared arm64 arch_timer.c is built with s390-specific backends: CTL and CVAL are accessed through vcpu_{read,write}_sys_reg(), and the guest counter is obtained with PTFF QAGPT from the guest physical time offset (GPTO) in the SAE block.

Trap WFx* and handle them in kvm_handle_wfx(). A vCPU halted in WFI or WFIT is woken by a background hrtimer armed for the earliest of the enabled guest timer expiries and the WFIT deadline; on expiry the hrtimer raises KVM_REQ_UNBLOCK and wakes the vCPU.

There is no in-kernel irqchip (yet!), so timer output level changes cannot be injected. After each guest exit handled in the kernel, including a timer interception (SAE_ICPTR_TIMER), ISTATUS in CTL is compared with the level last seen by userspace and the vCPU exits with KVM_EXIT_INTR on a change. On vCPU reset both timers are disabled and unmasked.

Implement the IRQ line for the !irqchip_in_kernel case, i.e. interrupt injection from userspace.

A branch with this series at kernel.org is available [4].

Steffen

[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/all/[email protected]
[3] https://lore.kernel.org/all/[email protected]
[4] https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git/log/?h=sae

---
Andreas Grapentin (1):

      KVM: s390: arm64: Add IRQ line

Gautam Gala (2):
KVM: s390: arm64: Provide timer infrastructure
KVM: s390: arm64: Trap WFx

Steffen Eiden (9):
arm64: Prepare for sharing with s390
arm64: Share timer and smccc functionality with s390
KVM: arm64: Share timer and smccc code with s390
KVM: s390: arm64: Use register shadow helper
KVM: s390: arm64: Shadow the guest timer CVAL registers
KVM: s390: arm64: Use mpstate for guests
KVM: s390: arm64: Enable full smccc support
KVM: s390: arm64: Report fwregs to userspace
KVM: s390: arm64: Integrate guest timer

 arch/arm64/include/asm/kvm_emulate.h   |   4 +-
 arch/arm64/include/asm/kvm_host.h      |  40 +++---
 arch/arm64/include/asm/kvm_mmu.h       |   2 +
 arch/arm64/include/asm/pvclock-abi.h   |   1 +
 arch/arm64/kvm/arch_timer.c            |  95 +++++++-------
 arch/arm64/kvm/arm.c                   |  25 +++-
 arch/arm64/kvm/hypercalls.c            |   4 +
 arch/arm64/kvm/psci.c                  |   3 +
 arch/arm64/kvm/pvtime.c                |   2 +
 arch/arm64/kvm/trng.c                  |   2 +
 arch/s390/include/arm64/kvm_emulate.h  |   6 +
 arch/s390/include/asm/kvm_host_arm64.h |  45 ++++++-
 arch/s390/kvm/Kconfig                  |   1 +
 arch/s390/kvm/arm64/Makefile           |   7 +-
 arch/s390/kvm/arm64/Makefile.gen       |   7 +-
 arch/s390/kvm/arm64/arch_timer.c       | 226 ++++++++++++++++++++++++++++++++
 arch/s390/kvm/arm64/arm.c              | 227 ++++++++++++++++++++++++++++++---
 arch/s390/kvm/arm64/guest.c            |  14 ++
 arch/s390/kvm/arm64/handle_exit.c      | 105 ++++++++++-----
 arch/s390/kvm/arm64/hypercalls.c       |  32 +++++
 arch/s390/kvm/arm64/psci.c             |  20 +++
 arch/s390/kvm/arm64/pvtime.c           |  15 +++
 arch/s390/kvm/arm64/reset.c            |  14 +-
 arch/s390/kvm/arm64/sys_regs.c         |   8 +-
 arch/s390/kvm/arm64/trace.h            |  45 +++++++
 arch/s390/kvm/arm64/trng.c             |  12 ++
 arch/s390/tools/Makefile.arm64h        |   2 +
 include/kvm/arm_hypercalls.h           |   3 +
 include/kvm/arm_psci.h                 |   3 +
 29 files changed, 836 insertions(+), 134 deletions(-)

base-commit: 9437ee8b6cf607e883b36e44bd755968daaebd48
change-id: 20261127-smccc-c8cb09f78ebc
prerequisite-message-id: [email protected]
prerequisite-patch-id: ed28ef94c9056cb81bb738f1b54745d012cb613f
prerequisite-change-id: 20261106-sysreg-d6adf0cd34d4:v4
prerequisite-patch-id: ed28ef94c9056cb81bb738f1b54745d012cb613f
prerequisite-patch-id: 4f6b2386967522be268f77ca6eb9487a3503dc96
prerequisite-patch-id: 539f1138a427fddb952a5f7a0691e8acd974d0fb
prerequisite-patch-id: 3e9b8384f07ff18911f48eabe625a1c0507a5e96
prerequisite-patch-id: fc58c00a1006ecffd045728020ef01308022ac03
prerequisite-patch-id: 2c22bad7059a38c4ea01ca774d0c0b49cea27fba
prerequisite-patch-id: c809f818609fed0a0f8ccb1721b96f5329505543
prerequisite-patch-id: b35581eba719557148ea84232698457adc8c8cc4
prerequisite-patch-id: 0b8792bac82c24bfac0b5912d2eec5da32413747
prerequisite-patch-id: 58fb40b78dd793ca3b24cadadad8868bc54aa20e
prerequisite-patch-id: d986b0811f1feac0678eb135ce5c44140748431b
prerequisite-patch-id: 0e3d84b8259a175fceb67b01bc37c1830805636b
prerequisite-patch-id: 53a6741f3c6ec60c798995ccbf4d2b293619ec34
prerequisite-patch-id: b71ccf22e4cb8fccf4ca9eea558af14163b256db
prerequisite-patch-id: bba91e0c077b1f308e2ec914a54399f775d9090d
prerequisite-patch-id: 9be57897346558cd0bea61d946d85d3ba9a17f2e
prerequisite-patch-id: f4ae3a54ce24b78e335eb1f019b971419d82720a
prerequisite-patch-id: cc8dfe5b2b8a3f28b3c29b1a10827d99f987694d
prerequisite-patch-id: f27d96dacb5c7dadc01f1cc72158b8b3f64d7053
prerequisite-patch-id: 1c69a0380267279633c8ba33bf1d30c13877e033
prerequisite-patch-id: 20ac948d6ec4bfd4b9c3d053bcb0fcb3fe067486
prerequisite-patch-id: db6b83091a6107dbfd9c4311af14fadf1534375f
prerequisite-patch-id: af30d541a7cabea0981dfe79276d1e9991a8c91a
prerequisite-patch-id: 5eead648d962cbdc9f45ce40538f174faedd5775
prerequisite-patch-id: 97589af6c7ac9efe15c371883511fc05d4f1c870
prerequisite-patch-id: f661ef5923e8026fab81d73e596006ac30d5cbac
prerequisite-message-id: [email protected]
prerequisite-patch-id: bd1a0c1fa7ff80d9edd5fff5258d8af1de06d7d7
prerequisite-message-id: [email protected]
prerequisite-patch-id: 90cb98820a1c6fec2085ca6830827f90c6b659ab
prerequisite-patch-id: 36feb5c5ca141ca0a94f60e8cc27e3969f3ebefd