[PATCH v1 00/27] KVM: s390: Introduce arm64 KVM

Steffen Eiden posted 27 patches 2 months, 2 weeks ago
There is a newer version of this series
MAINTAINERS                                   |    5 +
arch/arm64/Makefile                           |    2 +
arch/arm64/include/asm/Kbuild                 |    2 +-
arch/arm64/include/asm/el2_setup.h            |    2 +-
arch/arm64/include/asm/hardirq.h              |    2 +-
arch/arm64/include/asm/kvm_emulate.h          |  245 +--
arch/arm64/include/asm/kvm_host.h             |  200 +-
arch/arm64/include/asm/kvm_mmu.h              |   41 +-
arch/arm64/include/asm/ptrace.h               |   34 +-
arch/arm64/include/asm/sysreg.h               |  972 +---------
arch/arm64/include/uapi/asm/Kbuild            |    4 +
arch/arm64/include/uapi/asm/ptrace.h          |   49 +-
arch/arm64/kernel/head.S                      |    2 +-
arch/arm64/kernel/hyp-stub.S                  |    2 +-
arch/arm64/kernel/traps.c                     |   53 -
arch/arm64/kvm/Kconfig                        |    1 -
arch/arm64/kvm/Makefile                       |    5 +-
arch/arm64/kvm/arm.c                          |   54 +-
arch/arm64/kvm/debug.c                        |    2 +-
arch/arm64/kvm/guest.c                        |  294 +--
arch/arm64/kvm/handle_exit.c                  |   52 +-
arch/arm64/kvm/hyp/entry.S                    |    2 +-
arch/arm64/kvm/hyp/exception.c                |    7 +-
arch/arm64/kvm/hyp/hyp-entry.S                |    2 +-
arch/arm64/kvm/hyp/include/hyp/adjust_pc.h    |   17 +-
arch/arm64/kvm/hyp/include/hyp/switch.h       |    6 +-
arch/arm64/kvm/hyp/nvhe/host.S                |    2 +-
arch/arm64/kvm/hyp/nvhe/hyp-init.S            |    2 +-
arch/arm64/kvm/mmu.c                          |   20 +-
arch/arm64/kvm/nested.c                       |    2 +-
arch/arm64/kvm/reset.c                        |   34 +-
arch/arm64/kvm/sys_regs.c                     |    2 +-
arch/arm64/kvm/trace_arm.h                    |   25 -
arch/arm64/kvm/vgic/vgic-its.c                |    2 +-
arch/arm64/kvm/vgic/vgic-mmio-v3.c            |    2 +-
arch/arm64/kvm/vgic/vgic-v3-nested.c          |    2 +-
arch/arm64/tools/Makefile                     |   14 +-
arch/arm64/tools/Makefile.sysreg              |   12 +
arch/arm64/tools/gen-sysreg.awk               |    6 +-
arch/loongarch/include/asm/kvm_host.h         |    2 +
arch/loongarch/kvm/Kconfig                    |    1 -
arch/mips/include/asm/kvm_host.h              |    2 +
arch/mips/kvm/Kconfig                         |    1 -
arch/powerpc/include/asm/kvm_host.h           |    7 +
arch/powerpc/kvm/Kconfig                      |    4 -
arch/riscv/include/asm/kvm_host.h             |    2 +
arch/riscv/kvm/Kconfig                        |    1 -
arch/s390/Kconfig                             |    2 +-
arch/s390/boot/ipl_parm.c                     |    2 +-
arch/s390/boot/uv.c                           |    2 +-
arch/s390/configs/defconfig                   |    3 +-
arch/s390/include/asm/asm-prototypes.h        |    1 +
arch/s390/include/asm/elf.h                   |    2 +
arch/s390/include/asm/kvm.h                   |    6 +
arch/s390/include/asm/kvm_emulate.h           |  135 ++
arch/s390/include/asm/kvm_host.h              |  748 +-------
arch/s390/include/asm/kvm_host_arm64.h        |  199 ++
arch/s390/include/asm/kvm_host_arm64_types.h  |  128 ++
.../asm/{kvm_host.h => kvm_host_s390.h}       |   19 +-
...kvm_host_types.h => kvm_host_s390_types.h} |    0
arch/s390/include/asm/kvm_mmu.h               |   12 +
arch/s390/include/asm/kvm_nested.h            |   13 +
arch/s390/include/asm/sae.h                   |   39 +
arch/s390/include/asm/sclp.h                  |    5 +-
arch/s390/include/asm/stacktrace.h            |    5 +
arch/s390/kernel/asm-offsets.c                |    3 +-
arch/s390/kernel/early.c                      |    2 +-
arch/s390/kernel/entry.S                      |   34 +-
arch/s390/kernel/perf_event.c                 |    2 +-
arch/s390/kernel/processor.c                  |    3 +
arch/s390/kvm/Kconfig                         |   36 +-
arch/s390/kvm/Makefile                        |   12 +-
arch/s390/kvm/arm64/Kconfig                   |   23 +
arch/s390/kvm/arm64/Makefile                  |  107 ++
arch/s390/kvm/arm64/arm.c                     |  704 +++++++
arch/s390/kvm/arm64/arm.h                     |   61 +
arch/s390/kvm/arm64/guest.c                   |  162 ++
arch/s390/kvm/arm64/guest.h                   |   15 +
arch/s390/kvm/arm64/handle_exit.c             |   52 +
arch/s390/kvm/arm64/inject_fault.c            |   15 +
arch/s390/kvm/arm64/mmu.c                     |  153 ++
arch/s390/kvm/arm64/reset.c                   |   42 +
arch/s390/kvm/arm64/reset.h                   |   11 +
arch/s390/kvm/gmap/Makefile                   |    5 +
arch/s390/kvm/{ => gmap}/dat.c                |    0
arch/s390/kvm/{ => gmap}/dat.h                |    6 +-
arch/s390/kvm/{ => gmap}/faultin.c            |   11 +-
arch/s390/kvm/{ => gmap}/faultin.h            |    6 +-
arch/s390/kvm/{ => gmap}/gmap.c               |   13 +-
arch/s390/kvm/{ => gmap}/gmap.h               |   17 +-
arch/s390/kvm/gmap/mmu.c                      |  154 ++
arch/s390/kvm/gmap/trace-gmap.h               |   59 +
arch/s390/kvm/{ => s390}/Kconfig              |   25 +-
arch/s390/kvm/{ => s390}/Makefile             |   10 +-
arch/s390/kvm/{ => s390}/diag.c               |    2 +-
arch/s390/kvm/{ => s390}/gaccess.c            |    2 +-
arch/s390/kvm/{ => s390}/gaccess.h            |    2 +-
arch/s390/kvm/{ => s390}/guestdbg.c           |    2 +-
arch/s390/kvm/{ => s390}/intercept.c          |    2 +-
arch/s390/kvm/{ => s390}/interrupt.c          |    2 +-
arch/s390/kvm/{ => s390}/pci.c                |    2 +-
arch/s390/kvm/{ => s390}/pci.h                |    0
arch/s390/kvm/{ => s390}/priv.c               |    2 +-
arch/s390/kvm/{ => s390}/pv.c                 |    2 +-
arch/s390/kvm/{kvm-s390.c => s390/s390.c}     |  126 +-
arch/s390/kvm/{kvm-s390.h => s390/s390.h}     |   18 +-
arch/s390/kvm/{ => s390}/sigp.c               |    2 +-
arch/s390/kvm/{ => s390}/trace-s390.h         |    0
arch/s390/kvm/{ => s390}/trace.h              |   14 -
arch/s390/kvm/{ => s390}/vsie.c               |    2 +-
arch/s390/tools/Makefile                      |    2 +
arch/s390/tools/opcodes.txt                   |    3 +
arch/x86/include/asm/kvm_host.h               |    2 +
arch/x86/kvm/Kconfig                          |    1 -
arch/x86/kvm/mmu/tdp_mmu.c                    |    2 +-
arch/x86/kvm/vmx/nested.h                     |    4 +-
drivers/s390/char/sclp_early.c                |    1 +
drivers/vfio/device_cdev.c                    |    2 +-
drivers/vfio/group.c                          |    5 +-
drivers/vfio/vfio.h                           |   15 +-
drivers/vfio/vfio_main.c                      |   49 +-
.../arch/arm64}/asm/brk-imm.h                 |    0
.../include => include/arch/arm64}/asm/esr.h  |   56 +-
include/arch/arm64/asm/pstate.h               |   46 +
.../arch/arm64/asm/sysreg-defs.h              |  344 +---
include/kvm/arm64/guest.h                     |   13 +
include/kvm/arm64/handle_exit.h               |   14 +
.../asm => include/kvm/arm64}/kvm_arm.h       |    5 +-
include/kvm/arm64/kvm_emulate.h               |  268 +++
include/kvm/arm64/kvm_host.h                  |  205 ++
include/kvm/arm64/kvm_mmu.h                   |   47 +
include/kvm/arm64/reset.h                     |    8 +
include/linux/kvm_host.h                      |   18 +-
include/linux/kvm_types.h                     |   33 +
include/linux/vfio.h                          |    4 +-
include/uapi/Kbuild                           |    6 +
.../uapi/arch/arm64}/asm/kvm.h                |   24 +-
include/uapi/arch/arm64/asm/pstate.h          |   53 +
.../uapi/arch/arm64}/asm/sve_context.h        |    0
include/uapi/arch/arm64/linux/kvm.h           |    8 +
include/uapi/linux/{kvm.h => kvm-generic.h}   |   11 +-
include/uapi/linux/kvm.h                      | 1649 +----------------
scripts/Makefile.asm-headers                  |   14 +-
usr/include/Makefile                          |    1 +
virt/kvm/Kconfig                              |    3 -
virt/kvm/Makefile.kvm                         |    3 +-
virt/kvm/arm64/Makefile.kvm                   |   13 +
virt/kvm/arm64/arm.c                          |   75 +
virt/kvm/arm64/guest.c                        |  302 +++
virt/kvm/arm64/handle_exit.c                  |   54 +
{arch/arm64/kvm => virt/kvm/arm64}/mmio.c     |    1 +
virt/kvm/arm64/reset.c                        |   42 +
virt/kvm/arm64/trace.h                        |   42 +
virt/kvm/coalesced_mmio.c                     |    3 +
virt/kvm/coalesced_mmio.h                     |    2 +-
virt/kvm/kvm_main.c                           |   62 +-
virt/kvm/vfio.c                               |   14 +-
157 files changed, 3855 insertions(+), 5120 deletions(-)
create mode 100644 arch/arm64/tools/Makefile.sysreg
create mode 100644 arch/s390/include/asm/kvm.h
create mode 100644 arch/s390/include/asm/kvm_emulate.h
create mode 100644 arch/s390/include/asm/kvm_host_arm64.h
create mode 100644 arch/s390/include/asm/kvm_host_arm64_types.h
copy arch/s390/include/asm/{kvm_host.h => kvm_host_s390.h} (98%)
rename arch/s390/include/asm/{kvm_host_types.h => kvm_host_s390_types.h} (100%)
create mode 100644 arch/s390/include/asm/kvm_mmu.h
create mode 100644 arch/s390/include/asm/kvm_nested.h
create mode 100644 arch/s390/include/asm/sae.h
create mode 100644 arch/s390/kvm/arm64/Kconfig
create mode 100644 arch/s390/kvm/arm64/Makefile
create mode 100644 arch/s390/kvm/arm64/arm.c
create mode 100644 arch/s390/kvm/arm64/arm.h
create mode 100644 arch/s390/kvm/arm64/guest.c
create mode 100644 arch/s390/kvm/arm64/guest.h
create mode 100644 arch/s390/kvm/arm64/handle_exit.c
create mode 100644 arch/s390/kvm/arm64/inject_fault.c
create mode 100644 arch/s390/kvm/arm64/mmu.c
create mode 100644 arch/s390/kvm/arm64/reset.c
create mode 100644 arch/s390/kvm/arm64/reset.h
create mode 100644 arch/s390/kvm/gmap/Makefile
rename arch/s390/kvm/{ => gmap}/dat.c (100%)
rename arch/s390/kvm/{ => gmap}/dat.h (99%)
rename arch/s390/kvm/{ => gmap}/faultin.c (96%)
rename arch/s390/kvm/{ => gmap}/faultin.h (96%)
rename arch/s390/kvm/{ => gmap}/gmap.c (99%)
rename arch/s390/kvm/{ => gmap}/gmap.h (93%)
create mode 100644 arch/s390/kvm/gmap/mmu.c
create mode 100644 arch/s390/kvm/gmap/trace-gmap.h
copy arch/s390/kvm/{ => s390}/Kconfig (62%)
copy arch/s390/kvm/{ => s390}/Makefile (53%)
rename arch/s390/kvm/{ => s390}/diag.c (99%)
rename arch/s390/kvm/{ => s390}/gaccess.c (99%)
rename arch/s390/kvm/{ => s390}/gaccess.h (99%)
rename arch/s390/kvm/{ => s390}/guestdbg.c (99%)
rename arch/s390/kvm/{ => s390}/intercept.c (99%)
rename arch/s390/kvm/{ => s390}/interrupt.c (99%)
rename arch/s390/kvm/{ => s390}/pci.c (99%)
rename arch/s390/kvm/{ => s390}/pci.h (100%)
rename arch/s390/kvm/{ => s390}/priv.c (99%)
rename arch/s390/kvm/{ => s390}/pv.c (99%)
rename arch/s390/kvm/{kvm-s390.c => s390/s390.c} (98%)
rename arch/s390/kvm/{kvm-s390.h => s390/s390.h} (97%)
rename arch/s390/kvm/{ => s390}/sigp.c (99%)
rename arch/s390/kvm/{ => s390}/trace-s390.h (100%)
rename arch/s390/kvm/{ => s390}/trace.h (97%)
rename arch/s390/kvm/{ => s390}/vsie.c (99%)
rename {arch/arm64/include => include/arch/arm64}/asm/brk-imm.h (100%)
rename {arch/arm64/include => include/arch/arm64}/asm/esr.h (88%)
create mode 100644 include/arch/arm64/asm/pstate.h
copy arch/arm64/include/asm/sysreg.h => include/arch/arm64/asm/sysreg-defs.h (80%)
create mode 100644 include/kvm/arm64/guest.h
create mode 100644 include/kvm/arm64/handle_exit.h
rename {arch/arm64/include/asm => include/kvm/arm64}/kvm_arm.h (99%)
create mode 100644 include/kvm/arm64/kvm_emulate.h
create mode 100644 include/kvm/arm64/kvm_host.h
create mode 100644 include/kvm/arm64/kvm_mmu.h
create mode 100644 include/kvm/arm64/reset.h
rename {arch/arm64/include/uapi => include/uapi/arch/arm64}/asm/kvm.h (97%)
create mode 100644 include/uapi/arch/arm64/asm/pstate.h
rename {arch/arm64/include/uapi => include/uapi/arch/arm64}/asm/sve_context.h (100%)
create mode 100644 include/uapi/arch/arm64/linux/kvm.h
copy include/uapi/linux/{kvm.h => kvm-generic.h} (99%)
create mode 100644 virt/kvm/arm64/Makefile.kvm
create mode 100644 virt/kvm/arm64/arm.c
create mode 100644 virt/kvm/arm64/guest.c
create mode 100644 virt/kvm/arm64/handle_exit.c
rename {arch/arm64/kvm => virt/kvm/arm64}/mmio.c (99%)
create mode 100644 virt/kvm/arm64/reset.c
create mode 100644 virt/kvm/arm64/trace.h
[PATCH v1 00/27] KVM: s390: Introduce arm64 KVM
Posted by Steffen Eiden 2 months, 2 weeks ago
By introducing a novel virtualization acceleration for the ARM architecture on
s390 architecture, we aim to expand the platform's software ecosystem. This
initial patch series lays the groundwork by enabling KVM-accelerated ARM CPU
virtualization on s390. To achieve this, a common KVM layer between s390 and
arm64 is introduced (see below for more details). Design considerations of
arm64 on the s390 Architecture The s390 virtualization architecture is extended
with a set of new instructions dedicated to supporting ARM-based virtual
machines. The s390 KVM host acts as EL2 (hypervisor) for a EL1/EL0
(OS/application) arm64 guest. To achieve this, the new Start-Arm-Execution
(SAE) instruction enables accelerated execution of arm64 VMs.  Additional new
s390 instructions are introduced to query available arm64 features, used to
populate the arm64 ID register contents, as well as, new s390 instructions to
save/restore various arm64 registers in the VM context.

Summary of changes to arm64 KVM

UAPI / KAPI changes

The arm64 KVM UAPI headers are relocated to include/uapi/arch/arm64/,
allowing non‑arm64 hosts (such as s390) to use the arm64 KVM userspace API.
Likewise, the arm64 KVM kernel‑internal headers are relocated to
include/kvm/arm64/, and several arm64 asm headers are relocated to
include/arch/arm64/asm for architecture‑independent consumption.

Refactoring of arm64 headers and shared arm64 KVM functionality

To avoid code duplication, sharing logic between arm64/kvm and s390/kvm/arm64
is maximized while refactoring noise was minimized. IOCTL (arch) entry points
are deliberately kept separate for arm64 and arm64 on s390. This ensures full
control over execution paths for each KVM implementation. The arm64 sysreg
definitions and pstate/SPSR constants are extracted from their native headers
into dedicated, shareable files (sysreg-defs.h, pstate.h). This enables
other architectures to access sysreg name‑to‑ID mappings and pstate definitions
without relying on arm64‑specific, non‑shareable headers.

A new virt/kvm/arm64/ source directory is introduced to hold shared Arm64 KVM
implementation code, including guest register handling, exit handling,
general‑register reset logic, and IPA size/shift
calculations. Several functions are also refactored to improve portability for
non‑arm64 KVM implementations. 

Maintainership considerations

Introducing a shared arm64 KVM code base for both native arm64 and s390
implementations may have subtle implications for each architecture,
depending on the context and the contributor’s expertise. We therefore
recognize the importance of clear maintainership guidelines and
well-defined review processes to ensure the stability and correctness of
both implementations. We welcome community feedback on how best to
structure maintainership and the review workflow, and we are open to
suggestions for effective coordination between the arm64 and s390
maintainer teams.

UAPI design

The arm64 KVM UAPI headers are relocated from arch/arm64/include/uapi/
to the new include/uapi/arch/arm64/ directory, and generic KVM definitions are
split into include/uapi/linux/kvm-generic.h for use across all architectures.
To maintain ABI compatibility, type aliases are introduced; they resolve to
native arm64 types on arm64 and to equivalent inline struct definitions on
foreign hosts. The build system installs the headers in their original location
on arm64, while conditionally exporting them to the new location for s390.

KAPI design

The include/arch/arm64/asm/ directory is introduced to host arm64 asm headers
that are independent of the host CPU. On native arm64 systems, this path is
added with the highest precedence so that existing <asm/header.h> includes
continue to work without modification. Foreign architectures can opt in by
adding this path to their include search, enabling them to use these
architecture‑agnostic headers.

The KVM‑related headers are moved to include/kvm/arm64/, decoupling them from
the arm64 architecture directory. The design convention is that
architecture‑specific headers under <arch>/include/asm/ include from this
shared location, allowing non‑arm64 hosts to consume the arm64 KVM
infrastructure without duplicating code.

Series structure

KVM symbol cleanup:
	Three preparatory patches clean up KVM module symbol exports, making it
	possible to load two KVM modules side by side.

Arm64 header and code sharing:
	Selected arm64 UAPI, asm, and KVM kernel headers are
	refactored into architecture-agnostic include paths, and shared arm64 KVM code
	is relocated accordingly. This enables non-arm64 hosts to use the arm64 KVM
	infrastructure without duplication. 

s390 & KVM reorganization:
	The existing s390 KVM code is moved into a dedicated s390 subdirectory
	to make room for a second KVM implementation alongside it. The KVM
	core is extended to support a configurable device name (needed for two
	KVM devices on one architecture) Arm64

KVM on s390:
	The SAE (Start Arm Execution) instruction is introduced as the
	s390 mechanism for running Arm64 guests, and a new kvm-arm64 module is
	built up incrementally.

Upcoming patch series will introduce system-register handling, interrupt
support, hypercalls, and additional features such as PMU.

We appreciate your feedback and review.

The Linux on s390 team

Hendrik Brueckner (1):
  s390/hwcaps: Report SAE support as hwcap

Nina Schoetterl-Glausch (3):
  arm64: Extract sysreg definitions
  arm64: Extract pstate definitions from ptrace
  KVM: arm64: Share reset general register code

Paolo Bonzini (3):
  VFIO: take reference to the KVM module
  KVM, vfio: remove symbol_get(kvm_get_kvm_safe) from vfio
  KVM, vfio: remove symbol_get(kvm_put_kvm) from vfio

Steffen Eiden (20):
  arm64: Provide arm64 UAPI for other host architectures
  arm64: Provide arm64 API for non-native architectures
  KVM: arm64: Provide arm64 KVM API for non-native architectures
  KVM: arm64: Share kvm_emulate definitions
  KVM: arm64: Make some arm64 KVM code shareable
  KVM: arm64: Access elements of vcpu_gp_regs individually
  KVM: arm64: Extract & share ipa size shift calculation
  KVM: s390: Move s390 kvm code into a subdirectory
  KVM: S390: Refactor gmap
  KVM: Make device name configurable
  KVM: Remove KVM_MMIO as config option
  KVM: s390: Prepare kvm-s390 for a second kvm module
  s390: Introduce Start Arm Execution instruction
  KVM: s390: arm64: Introduce host definitions
  KVM: s390: Add basic arm64 kvm module
  KVM: s390: arm64: Implement required functions
  KVM: s390: arm64: Implement vm/vcpu create destroy.
  KVM: s390: arm64: Implement vCPU IOCTLs
  KVM: s390: arm64: Implement basic page fault handler
  KVM: s390: arm64: Enable KVM_ARM64 config and Kbuild

 MAINTAINERS                                   |    5 +
 arch/arm64/Makefile                           |    2 +
 arch/arm64/include/asm/Kbuild                 |    2 +-
 arch/arm64/include/asm/el2_setup.h            |    2 +-
 arch/arm64/include/asm/hardirq.h              |    2 +-
 arch/arm64/include/asm/kvm_emulate.h          |  245 +--
 arch/arm64/include/asm/kvm_host.h             |  200 +-
 arch/arm64/include/asm/kvm_mmu.h              |   41 +-
 arch/arm64/include/asm/ptrace.h               |   34 +-
 arch/arm64/include/asm/sysreg.h               |  972 +---------
 arch/arm64/include/uapi/asm/Kbuild            |    4 +
 arch/arm64/include/uapi/asm/ptrace.h          |   49 +-
 arch/arm64/kernel/head.S                      |    2 +-
 arch/arm64/kernel/hyp-stub.S                  |    2 +-
 arch/arm64/kernel/traps.c                     |   53 -
 arch/arm64/kvm/Kconfig                        |    1 -
 arch/arm64/kvm/Makefile                       |    5 +-
 arch/arm64/kvm/arm.c                          |   54 +-
 arch/arm64/kvm/debug.c                        |    2 +-
 arch/arm64/kvm/guest.c                        |  294 +--
 arch/arm64/kvm/handle_exit.c                  |   52 +-
 arch/arm64/kvm/hyp/entry.S                    |    2 +-
 arch/arm64/kvm/hyp/exception.c                |    7 +-
 arch/arm64/kvm/hyp/hyp-entry.S                |    2 +-
 arch/arm64/kvm/hyp/include/hyp/adjust_pc.h    |   17 +-
 arch/arm64/kvm/hyp/include/hyp/switch.h       |    6 +-
 arch/arm64/kvm/hyp/nvhe/host.S                |    2 +-
 arch/arm64/kvm/hyp/nvhe/hyp-init.S            |    2 +-
 arch/arm64/kvm/mmu.c                          |   20 +-
 arch/arm64/kvm/nested.c                       |    2 +-
 arch/arm64/kvm/reset.c                        |   34 +-
 arch/arm64/kvm/sys_regs.c                     |    2 +-
 arch/arm64/kvm/trace_arm.h                    |   25 -
 arch/arm64/kvm/vgic/vgic-its.c                |    2 +-
 arch/arm64/kvm/vgic/vgic-mmio-v3.c            |    2 +-
 arch/arm64/kvm/vgic/vgic-v3-nested.c          |    2 +-
 arch/arm64/tools/Makefile                     |   14 +-
 arch/arm64/tools/Makefile.sysreg              |   12 +
 arch/arm64/tools/gen-sysreg.awk               |    6 +-
 arch/loongarch/include/asm/kvm_host.h         |    2 +
 arch/loongarch/kvm/Kconfig                    |    1 -
 arch/mips/include/asm/kvm_host.h              |    2 +
 arch/mips/kvm/Kconfig                         |    1 -
 arch/powerpc/include/asm/kvm_host.h           |    7 +
 arch/powerpc/kvm/Kconfig                      |    4 -
 arch/riscv/include/asm/kvm_host.h             |    2 +
 arch/riscv/kvm/Kconfig                        |    1 -
 arch/s390/Kconfig                             |    2 +-
 arch/s390/boot/ipl_parm.c                     |    2 +-
 arch/s390/boot/uv.c                           |    2 +-
 arch/s390/configs/defconfig                   |    3 +-
 arch/s390/include/asm/asm-prototypes.h        |    1 +
 arch/s390/include/asm/elf.h                   |    2 +
 arch/s390/include/asm/kvm.h                   |    6 +
 arch/s390/include/asm/kvm_emulate.h           |  135 ++
 arch/s390/include/asm/kvm_host.h              |  748 +-------
 arch/s390/include/asm/kvm_host_arm64.h        |  199 ++
 arch/s390/include/asm/kvm_host_arm64_types.h  |  128 ++
 .../asm/{kvm_host.h => kvm_host_s390.h}       |   19 +-
 ...kvm_host_types.h => kvm_host_s390_types.h} |    0
 arch/s390/include/asm/kvm_mmu.h               |   12 +
 arch/s390/include/asm/kvm_nested.h            |   13 +
 arch/s390/include/asm/sae.h                   |   39 +
 arch/s390/include/asm/sclp.h                  |    5 +-
 arch/s390/include/asm/stacktrace.h            |    5 +
 arch/s390/kernel/asm-offsets.c                |    3 +-
 arch/s390/kernel/early.c                      |    2 +-
 arch/s390/kernel/entry.S                      |   34 +-
 arch/s390/kernel/perf_event.c                 |    2 +-
 arch/s390/kernel/processor.c                  |    3 +
 arch/s390/kvm/Kconfig                         |   36 +-
 arch/s390/kvm/Makefile                        |   12 +-
 arch/s390/kvm/arm64/Kconfig                   |   23 +
 arch/s390/kvm/arm64/Makefile                  |  107 ++
 arch/s390/kvm/arm64/arm.c                     |  704 +++++++
 arch/s390/kvm/arm64/arm.h                     |   61 +
 arch/s390/kvm/arm64/guest.c                   |  162 ++
 arch/s390/kvm/arm64/guest.h                   |   15 +
 arch/s390/kvm/arm64/handle_exit.c             |   52 +
 arch/s390/kvm/arm64/inject_fault.c            |   15 +
 arch/s390/kvm/arm64/mmu.c                     |  153 ++
 arch/s390/kvm/arm64/reset.c                   |   42 +
 arch/s390/kvm/arm64/reset.h                   |   11 +
 arch/s390/kvm/gmap/Makefile                   |    5 +
 arch/s390/kvm/{ => gmap}/dat.c                |    0
 arch/s390/kvm/{ => gmap}/dat.h                |    6 +-
 arch/s390/kvm/{ => gmap}/faultin.c            |   11 +-
 arch/s390/kvm/{ => gmap}/faultin.h            |    6 +-
 arch/s390/kvm/{ => gmap}/gmap.c               |   13 +-
 arch/s390/kvm/{ => gmap}/gmap.h               |   17 +-
 arch/s390/kvm/gmap/mmu.c                      |  154 ++
 arch/s390/kvm/gmap/trace-gmap.h               |   59 +
 arch/s390/kvm/{ => s390}/Kconfig              |   25 +-
 arch/s390/kvm/{ => s390}/Makefile             |   10 +-
 arch/s390/kvm/{ => s390}/diag.c               |    2 +-
 arch/s390/kvm/{ => s390}/gaccess.c            |    2 +-
 arch/s390/kvm/{ => s390}/gaccess.h            |    2 +-
 arch/s390/kvm/{ => s390}/guestdbg.c           |    2 +-
 arch/s390/kvm/{ => s390}/intercept.c          |    2 +-
 arch/s390/kvm/{ => s390}/interrupt.c          |    2 +-
 arch/s390/kvm/{ => s390}/pci.c                |    2 +-
 arch/s390/kvm/{ => s390}/pci.h                |    0
 arch/s390/kvm/{ => s390}/priv.c               |    2 +-
 arch/s390/kvm/{ => s390}/pv.c                 |    2 +-
 arch/s390/kvm/{kvm-s390.c => s390/s390.c}     |  126 +-
 arch/s390/kvm/{kvm-s390.h => s390/s390.h}     |   18 +-
 arch/s390/kvm/{ => s390}/sigp.c               |    2 +-
 arch/s390/kvm/{ => s390}/trace-s390.h         |    0
 arch/s390/kvm/{ => s390}/trace.h              |   14 -
 arch/s390/kvm/{ => s390}/vsie.c               |    2 +-
 arch/s390/tools/Makefile                      |    2 +
 arch/s390/tools/opcodes.txt                   |    3 +
 arch/x86/include/asm/kvm_host.h               |    2 +
 arch/x86/kvm/Kconfig                          |    1 -
 arch/x86/kvm/mmu/tdp_mmu.c                    |    2 +-
 arch/x86/kvm/vmx/nested.h                     |    4 +-
 drivers/s390/char/sclp_early.c                |    1 +
 drivers/vfio/device_cdev.c                    |    2 +-
 drivers/vfio/group.c                          |    5 +-
 drivers/vfio/vfio.h                           |   15 +-
 drivers/vfio/vfio_main.c                      |   49 +-
 .../arch/arm64}/asm/brk-imm.h                 |    0
 .../include => include/arch/arm64}/asm/esr.h  |   56 +-
 include/arch/arm64/asm/pstate.h               |   46 +
 .../arch/arm64/asm/sysreg-defs.h              |  344 +---
 include/kvm/arm64/guest.h                     |   13 +
 include/kvm/arm64/handle_exit.h               |   14 +
 .../asm => include/kvm/arm64}/kvm_arm.h       |    5 +-
 include/kvm/arm64/kvm_emulate.h               |  268 +++
 include/kvm/arm64/kvm_host.h                  |  205 ++
 include/kvm/arm64/kvm_mmu.h                   |   47 +
 include/kvm/arm64/reset.h                     |    8 +
 include/linux/kvm_host.h                      |   18 +-
 include/linux/kvm_types.h                     |   33 +
 include/linux/vfio.h                          |    4 +-
 include/uapi/Kbuild                           |    6 +
 .../uapi/arch/arm64}/asm/kvm.h                |   24 +-
 include/uapi/arch/arm64/asm/pstate.h          |   53 +
 .../uapi/arch/arm64}/asm/sve_context.h        |    0
 include/uapi/arch/arm64/linux/kvm.h           |    8 +
 include/uapi/linux/{kvm.h => kvm-generic.h}   |   11 +-
 include/uapi/linux/kvm.h                      | 1649 +----------------
 scripts/Makefile.asm-headers                  |   14 +-
 usr/include/Makefile                          |    1 +
 virt/kvm/Kconfig                              |    3 -
 virt/kvm/Makefile.kvm                         |    3 +-
 virt/kvm/arm64/Makefile.kvm                   |   13 +
 virt/kvm/arm64/arm.c                          |   75 +
 virt/kvm/arm64/guest.c                        |  302 +++
 virt/kvm/arm64/handle_exit.c                  |   54 +
 {arch/arm64/kvm => virt/kvm/arm64}/mmio.c     |    1 +
 virt/kvm/arm64/reset.c                        |   42 +
 virt/kvm/arm64/trace.h                        |   42 +
 virt/kvm/coalesced_mmio.c                     |    3 +
 virt/kvm/coalesced_mmio.h                     |    2 +-
 virt/kvm/kvm_main.c                           |   62 +-
 virt/kvm/vfio.c                               |   14 +-
 157 files changed, 3855 insertions(+), 5120 deletions(-)
 create mode 100644 arch/arm64/tools/Makefile.sysreg
 create mode 100644 arch/s390/include/asm/kvm.h
 create mode 100644 arch/s390/include/asm/kvm_emulate.h
 create mode 100644 arch/s390/include/asm/kvm_host_arm64.h
 create mode 100644 arch/s390/include/asm/kvm_host_arm64_types.h
 copy arch/s390/include/asm/{kvm_host.h => kvm_host_s390.h} (98%)
 rename arch/s390/include/asm/{kvm_host_types.h => kvm_host_s390_types.h} (100%)
 create mode 100644 arch/s390/include/asm/kvm_mmu.h
 create mode 100644 arch/s390/include/asm/kvm_nested.h
 create mode 100644 arch/s390/include/asm/sae.h
 create mode 100644 arch/s390/kvm/arm64/Kconfig
 create mode 100644 arch/s390/kvm/arm64/Makefile
 create mode 100644 arch/s390/kvm/arm64/arm.c
 create mode 100644 arch/s390/kvm/arm64/arm.h
 create mode 100644 arch/s390/kvm/arm64/guest.c
 create mode 100644 arch/s390/kvm/arm64/guest.h
 create mode 100644 arch/s390/kvm/arm64/handle_exit.c
 create mode 100644 arch/s390/kvm/arm64/inject_fault.c
 create mode 100644 arch/s390/kvm/arm64/mmu.c
 create mode 100644 arch/s390/kvm/arm64/reset.c
 create mode 100644 arch/s390/kvm/arm64/reset.h
 create mode 100644 arch/s390/kvm/gmap/Makefile
 rename arch/s390/kvm/{ => gmap}/dat.c (100%)
 rename arch/s390/kvm/{ => gmap}/dat.h (99%)
 rename arch/s390/kvm/{ => gmap}/faultin.c (96%)
 rename arch/s390/kvm/{ => gmap}/faultin.h (96%)
 rename arch/s390/kvm/{ => gmap}/gmap.c (99%)
 rename arch/s390/kvm/{ => gmap}/gmap.h (93%)
 create mode 100644 arch/s390/kvm/gmap/mmu.c
 create mode 100644 arch/s390/kvm/gmap/trace-gmap.h
 copy arch/s390/kvm/{ => s390}/Kconfig (62%)
 copy arch/s390/kvm/{ => s390}/Makefile (53%)
 rename arch/s390/kvm/{ => s390}/diag.c (99%)
 rename arch/s390/kvm/{ => s390}/gaccess.c (99%)
 rename arch/s390/kvm/{ => s390}/gaccess.h (99%)
 rename arch/s390/kvm/{ => s390}/guestdbg.c (99%)
 rename arch/s390/kvm/{ => s390}/intercept.c (99%)
 rename arch/s390/kvm/{ => s390}/interrupt.c (99%)
 rename arch/s390/kvm/{ => s390}/pci.c (99%)
 rename arch/s390/kvm/{ => s390}/pci.h (100%)
 rename arch/s390/kvm/{ => s390}/priv.c (99%)
 rename arch/s390/kvm/{ => s390}/pv.c (99%)
 rename arch/s390/kvm/{kvm-s390.c => s390/s390.c} (98%)
 rename arch/s390/kvm/{kvm-s390.h => s390/s390.h} (97%)
 rename arch/s390/kvm/{ => s390}/sigp.c (99%)
 rename arch/s390/kvm/{ => s390}/trace-s390.h (100%)
 rename arch/s390/kvm/{ => s390}/trace.h (97%)
 rename arch/s390/kvm/{ => s390}/vsie.c (99%)
 rename {arch/arm64/include => include/arch/arm64}/asm/brk-imm.h (100%)
 rename {arch/arm64/include => include/arch/arm64}/asm/esr.h (88%)
 create mode 100644 include/arch/arm64/asm/pstate.h
 copy arch/arm64/include/asm/sysreg.h => include/arch/arm64/asm/sysreg-defs.h (80%)
 create mode 100644 include/kvm/arm64/guest.h
 create mode 100644 include/kvm/arm64/handle_exit.h
 rename {arch/arm64/include/asm => include/kvm/arm64}/kvm_arm.h (99%)
 create mode 100644 include/kvm/arm64/kvm_emulate.h
 create mode 100644 include/kvm/arm64/kvm_host.h
 create mode 100644 include/kvm/arm64/kvm_mmu.h
 create mode 100644 include/kvm/arm64/reset.h
 rename {arch/arm64/include/uapi => include/uapi/arch/arm64}/asm/kvm.h (97%)
 create mode 100644 include/uapi/arch/arm64/asm/pstate.h
 rename {arch/arm64/include/uapi => include/uapi/arch/arm64}/asm/sve_context.h (100%)
 create mode 100644 include/uapi/arch/arm64/linux/kvm.h
 copy include/uapi/linux/{kvm.h => kvm-generic.h} (99%)
 create mode 100644 virt/kvm/arm64/Makefile.kvm
 create mode 100644 virt/kvm/arm64/arm.c
 create mode 100644 virt/kvm/arm64/guest.c
 create mode 100644 virt/kvm/arm64/handle_exit.c
 rename {arch/arm64/kvm => virt/kvm/arm64}/mmio.c (99%)
 create mode 100644 virt/kvm/arm64/reset.c
 create mode 100644 virt/kvm/arm64/trace.h


base-commit: 46b513250491a7bfc97d98791dbe6a10bcc8129d
-- 
2.51.0

Re: [PATCH v1 00/27] KVM: s390: Introduce arm64 KVM
Posted by David Hildenbrand (Arm) 2 months, 2 weeks ago
> 
> KVM on s390:
> 	The SAE (Start Arm Execution) instruction is introduced as the
> 	s390 mechanism for running Arm64 guests, and a new kvm-arm64 module is
> 	built up incrementally.
> 
> Upcoming patch series will introduce system-register handling, interrupt
> support, hypercalls, and additional features such as PMU.

Pretty cool stuff.

What's the rough timeline for the other work?

Regarding I/O, I guess it is primarily VIRTIO (VIRTIO_PCI) for these VMs
only?

-- 
Cheers,

David
Re: [PATCH v1 00/27] KVM: s390: Introduce arm64 KVM
Posted by Christian Borntraeger 2 months, 2 weeks ago
Am 02.04.26 um 10:53 schrieb David Hildenbrand (Arm):
>>
>> KVM on s390:
>> 	The SAE (Start Arm Execution) instruction is introduced as the
>> 	s390 mechanism for running Arm64 guests, and a new kvm-arm64 module is
>> 	built up incrementally.
>>
>> Upcoming patch series will introduce system-register handling, interrupt
>> support, hypercalls, and additional features such as PMU.
> 
> Pretty cool stuff.
> 
> What's the rough timeline for the other work?

Over the next months. The idea was to split this into consumable chunks and start
with those things where a lot of people have to agree (code movement, code sharing
and shared maintainership). This will certainly evolve depending on patch feedback
and merge progress.

> 
> Regarding I/O, I guess it is primarily VIRTIO (VIRTIO_PCI) for these VMs
> only?

yes, virtio-pci.

Re: [PATCH v1 00/27] KVM: s390: Introduce arm64 KVM
Posted by Marc Zyngier 2 months ago
Hi Steffen, s390 folks,

On Thu, 02 Apr 2026 05:20:56 +0100,
Steffen Eiden <seiden@linux.ibm.com> wrote:
> 
> By introducing a novel virtualization acceleration for the ARM architecture on
> s390 architecture, we aim to expand the platform's software ecosystem. This
> initial patch series lays the groundwork by enabling KVM-accelerated ARM CPU
> virtualization on s390. To achieve this, a common KVM layer between s390 and
> arm64 is introduced (see below for more details). Design considerations of
> arm64 on the s390 Architecture The s390 virtualization architecture is extended
> with a set of new instructions dedicated to supporting ARM-based virtual
> machines. The s390 KVM host acts as EL2 (hypervisor) for a EL1/EL0
> (OS/application) arm64 guest. To achieve this, the new Start-Arm-Execution
> (SAE) instruction enables accelerated execution of arm64 VMs.  Additional new
> s390 instructions are introduced to query available arm64 features, used to
> populate the arm64 ID register contents, as well as, new s390 instructions to
> save/restore various arm64 registers in the VM context.

Apologises for the delay in responding to this, things got delayed a
bit with the Easter break. Since then, Will and I have been discussing
this series and what it means for the future of the arm64 port.

By way of opening the discussion, we want to be clear that we are
supportive of the effort. Our comments here should be seen as areas of
potential improvement and not as rejection of what you are trying to
achieve.

* Code movement:

  The patches you have posted demonstrate that it is possible to
  expose a large amount of arm64-specific code and definition to s390,
  and yet still manage to build both architectures without regression.
  However, the result looks rather messy and may adversely affect
  maintainability on the arm64 side.

  The moving of files into shared locations is particularly painful,
  and gets in the way of overall maintainability. Not only does it
  break our comfortable habits, it makes the backporting of fixes
  harder.  Importantly, these changes come with no benefit on the
  arm64 side.

  Would it be possible to try some other means of reaching the
  arm64-specific files *in situ*, either by making use of relative
  paths, or by using symbolic links? Even better, files that are
  generated on arm64 (such as the sysreg definitions) should equally
  be generated for s390, locally to the s390 part of the tree.

  But that doesn't mean that we consider that the arm64 tree is
  immutable and that we are not open to change, quite the opposite.
  Most of the KVM/arm64 include files are an unholy mix of arch
  definitions, data structures that have some arch relevance, but also
  code and data that is strictly implementation specific. Splitting
  these (as you already have for some include files) could both help
  with sharing what is actually needed, keep the arm64-specific stuff
  at bay, *and* benefit arm64's overall maintainability. We would need
  some tooling to enforce the split and avoid regressing it, something
  that could happen quickly given the level of activity on arm64. Yet
  another way to achieve this could be to mechanically process the
  arm64 files as part of the s390 build to extract the relevant
  information, and we could help with this.

  Looking a bit more into the distance, it is likely that KVM/arm64
  will grow feature support quicker than s390 can absorb them, and
  that some feature won't ever make any sense of s390 (pKVM, for
  example).  We need to establish how these features can be built
  without arm64 being hindered by s390. This is also true when adding
  architectural support for features that don't exist in the s390 view
  of arm64.

* UAPI and guest API:

  Obviously, one of our biggest concerns is the userspace API. We
  appreciate that you want to reuse it as it is, warts and all, and
  directly incorporate additional feature support as it becomes
  available. This means that, should any divergence in UAPI appear,
  the source of truth must be on the arm64 side. This has the
  following consequences:

    - s390 cannot add extensions to the UAPI

    - s390 must be compatible with all future arm64 extensions

  Similar concerns exist on the guest/hypervisor API, including:

  - errata mitigation: this is unsurprisingly a hot topic, which keeps
    causing us some massive headaches. We are particularly concerned
    about errata that need to be disclosed to the guest and acted upon
    via a hypercall. Should there be a need for those, how will we
    coordinate the deployment of such hypercall?

    The way it has been deployed so far is that PSCI has grown an
    errata discovery mechanism. ARM assigns function numbers and
    specifies what these hypercalls mitigate. KVM, in turn, takes part
    in implementing the mitigation. We expect that s390 would follow
    the same behaviour, including coordination with ARM for the
    function numbering.

  - device assignment: this is unknown territory for us, as we
    commonly use vfio-pci (and more occasionally vfio-platform). How
    would that look for an arm64 guest on s390?

  - s390-specific ISA extension: although we obviously cannot control
    how you will decide to expose features to your arm64 guests,
    KVM/arm64 makes a point of forbidding any use of implementation
    specific instruction or system registers. We expect the s390
    implementation to uphold this.

  - s390-specific hypercalls: aside from the errata handling
    mentioned above, we would very much like to avoid anything that is
    implementation specific, and keep the hypercall space as small as
    possible. In other words, an unenlightened arm64 guest must work
    and continue to work.

* Overall maintenance

  Unsurprisingly, we are not totally familiar with s390. To say that
  there is a learning gap would only be an understatement. So how do
  we make sure we don't break things out of pure ignorance? Is there
  any documentation we can refer to when hacking on code that will
  eventually run on your side of the computing universe?

  We need to be able to build and test what we produce. How do we go
  about that? We appreciate that you may not be in a position to help
  with this right now, but at least having a plan would be reassuring.
  This should include things like automatic testing of our CI branches.
  We are happy to test build s390 as part of our maintenance flow, if
  pointed to existing binary toolchains compiled for arm64 and x86,
  together with a typical configuration.

  What about debugging? We expect that you'd have to help, should an
  arm64 change cause a regression on s390, as it is fairly unlikely
  that we would be able to reproduce it.

  Finally, we feel it would be beneficial for both projects to swap
  prisoners and have cross-reviewers in MAINTAINERS, so that there is
  an s390 reviewer added to KVM/arm64, and an arm64 reviewer added to
  KVM/s390.

It probably would be beneficial to work through some of these things
face-to-face. Maybe around LPC or KVM Forum if you manage to get
there? Or some other place/time?

Thanks,

	Marc and Will

-- 
Without deviation from the norm, progress is not possible.
Re: [PATCH v1 00/27] KVM: s390: Introduce arm64 KVM
Posted by Steffen Eiden 1 month, 4 weeks ago
Hi Marc & Will,

On Mon, Apr 20, 2026 at 11:57:38AM +0100, Marc Zyngier wrote:

> Hi Steffen, s390 folks,
> 
> On Thu, 02 Apr 2026 05:20:56 +0100,
> Steffen Eiden <seiden@linux.ibm.com> wrote:
> > 
> > By introducing a novel virtualization acceleration for the ARM architecture on
> > s390 architecture, we aim to expand the platform's software ecosystem. This
> > initial patch series lays the groundwork by enabling KVM-accelerated ARM CPU
> > virtualization on s390. To achieve this, a common KVM layer between s390 and
> > arm64 is introduced (see below for more details). Design considerations of
> > arm64 on the s390 Architecture The s390 virtualization architecture is extended
> > with a set of new instructions dedicated to supporting ARM-based virtual
> > machines. The s390 KVM host acts as EL2 (hypervisor) for a EL1/EL0
> > (OS/application) arm64 guest. To achieve this, the new Start-Arm-Execution
> > (SAE) instruction enables accelerated execution of arm64 VMs.  Additional new
> > s390 instructions aLre introduced to query available arm64 features, used to
> > populate the arm64 ID register contents, as well as, new s390 instructions to
> > save/restore various arm64 registers in the VM context.
> 
> Apologises for the delay in responding to this, things got delayed a
> bit with the Easter break. Since then, Will and I have been discussing
> this series and what it means for the future of the arm64 port.
> 
> By way of opening the discussion, we want to be clear that we are
> supportive of the effort. Our comments here should be seen as areas of
> potential improvement and not as rejection of what you are trying to
> achieve.
>
Thank you for your answer. We are happy to hear that you support our
efforts.
 
> * Code movement:
> 
>   The patches you have posted demonstrate that it is possible to
>   expose a large amount of arm64-specific code and definition to s390,
>   and yet still manage to build both architectures without regression.
>   However, the result looks rather messy and may adversely affect
>   maintainability on the arm64 side.
> 
>   The moving of files into shared locations is particularly painful,
>   and gets in the way of overall maintainability. Not only does it
>   break our comfortable habits, it makes the backporting of fixes
>   harder.  Importantly, these changes come with no benefit on the
>   arm64 side.
> 
>   Would it be possible to try some other means of reaching the
>   arm64-specific files *in situ*, either by making use of relative
>   paths, or by using symbolic links? Even better, files that are
>   generated on arm64 (such as the sysreg definitions) should equally
>   be generated for s390, locally to the s390 part of the tree.
> 
Yes, we can do that. Our first iteration had an extensive use of symlinks for
headers. We feared that this approach would gain no big support as it was
quite messy and gave a lot of surface for future errors. So we moved to the
current implementation. For the non-KVM headers I could see moving back to the
symlink approach to reduce the backport & maintainability burden for you.
Preferably, those headers are kept clean of any arm implementation specific
things (e.g. sysreg vs sysreg-defs).

For shared kvm headers and code, we think moving them to the proposed location
helps reducing regression issues when someone changes a function as that
location makes it 100% clear that this is shared code. Tagging a file 
as __shared__ by other means (e.g. by a file name suffix) may 
be OK for us as well if that reduces your maintenance burden.

The generated (e.g. sysreg) definitions are already generated into the s390
tree:
{outdir}/arch/s390/include/generated/asm/sysreg-gen-defs.h
We just reuse the makefile definitions from arm.

As a side note: We tried to reuse as much arm code as possible - to not
reinvent the wheel - while keeping the arm churn minimal. While going through
the arm code, we tried to spot parts that could benefit from refactoring and
did that. By moving especially the kvm code to another location we wanted to
emphasize that this code is shared between arm and s390 and possibly other
architectures in the future.

We will prototype alternatives including using symlinks and post them soon here. 

>   But that doesn't mean that we consider that the arm64 tree is
>   immutable and that we are not open to change, quite the opposite.
>   Most of the KVM/arm64 include files are an unholy mix of arch
>   definitions, data structures that have some arch relevance, but also
>   code and data that is strictly implementation specific. Splitting
>   these (as you already have for some include files) could both help
>   with sharing what is actually needed, keep the arm64-specific stuff
>   at bay, *and* benefit arm64's overall maintainability. We would need
>   some tooling to enforce the split and avoid regressing it, something
>   that could happen quickly given the level of activity on arm64. Yet
>   another way to achieve this could be to mechanically process the
>   arm64 files as part of the s390 build to extract the relevant
>   information, and we could help with this.

That is good to hear. We of course also wanted arm to improve with our changes.

> 
>   Looking a bit more into the distance, it is likely that KVM/arm64
>   will grow feature support quicker than s390 can absorb them, and
>   that some feature won't ever make any sense of s390 (pKVM, for
>   example).  We need to establish how these features can be built
>   without arm64 being hindered by s390. This is also true when adding
>   architectural support for features that don't exist in the s390 view
>   of arm64.

Yes, of course s390 should not hinder arm64 to progress. 120% agree! We will
be available in case that happens. However, I do not think this is a big
problem. By defining some arm feature macros to false we already did turn off
few arm features for us at compile time. Compiler optimization is a very good
friend here.

> 
> * UAPI and guest API:
> 
>   Obviously, one of our biggest concerns is the userspace API. We
>   appreciate that you want to reuse it as it is, warts and all, and
>   directly incorporate additional feature support as it becomes

Yes, implementing the arm64 kvm-UAPI was one of our primary goals so that we
can reuse existing arm64 VMMs e.g. Qemu.

>   available. This means that, should any divergence in UAPI appear,
>   the source of truth must be on the arm64 side. This has the
>   following consequences:

Yes, arm64 is the source of truth for us. That is the exact reason we did not
copy the (UAPI) headers but moved & share them.

> 
>     - s390 cannot add extensions to the UAPI
> 
>     - s390 must be compatible with all future arm64 extensions
yes
> 
>   Similar concerns exist on the guest/hypervisor API, including:
> 
>   - errata mitigation: this is unsurprisingly a hot topic, which keeps
>     causing us some massive headaches. We are particularly concerned
>     about errata that need to be disclosed to the guest and acted upon
>     via a hypercall. Should there be a need for those, how will we
>     coordinate the deployment of such hypercall?
> 
>     The way it has been deployed so far is that PSCI has grown an
>     errata discovery mechanism. ARM assigns function numbers and
>     specifies what these hypercalls mitigate. KVM, in turn, takes part
>     in implementing the mitigation. We expect that s390 would follow
>     the same behaviour, including coordination with ARM for the
>     function numbering.

Yes. s390 will follow those things. We are planning to reuse the complete 
arm hypercall code including the current (and future) errata detection that
comes with it.
This change will come in one of the future series. 

> 
>   - device assignment: this is unknown territory for us, as we
>     commonly use vfio-pci (and more occasionally vfio-platform). How
>     would that look for an arm64 guest on s390?
> 
We plan to work with virtio-pci and vfio-pci. No plans to assign ccw devices to
 arm guests.

>   - s390-specific ISA extension: although we obviously cannot control
>     how you will decide to expose features to your arm64 guests,
>     KVM/arm64 makes a point of forbidding any use of implementation
>     specific instruction or system registers. We expect the s390
>     implementation to uphold this.
>

We have no plans of using private ISA extensions or deviations.

>   - s390-specific hypercalls: aside from the errata handling
>     mentioned above, we would very much like to avoid anything that is
>     implementation specific, and keep the hypercall space as small as
>     possible. In other words, an unenlightened arm64 guest must work
>     and continue to work.

Of course an unenlightened arm64 guest must keep working and it should
work with good performance and usability. This is another primary goal of
this project.
Given that we have some history of paravirtual optimizations on s390, we 
might propose some hypercalls in the future. But this will then very likely to
the benefit of all arm platforms and implemented on both host variants. 

> 
> * Overall maintenance
> 
>   Unsurprisingly, we are not totally familiar with s390. To say that
>   there is a learning gap would only be an understatement. So how do
>   we make sure we don't break things out of pure ignorance? Is there
>   any documentation we can refer to when hacking on code that will
>   eventually run on your side of the computing universe?

I am aware of the Kernel Documentation for s390.
Also, for the z/Architecture in general:
Principles of Operation might be a good start to learn about s390 architecture.

Of course we will be available for answering s390 architecture questions. 

> 
>   We need to be able to build and test what we produce. How do we go
>   about that? We appreciate that you may not be in a position to help
>   with this right now, but at least having a plan would be reassuring.
>   This should include things like automatic testing of our CI branches.
>   We are happy to test build s390 as part of our maintenance flow, if
>   pointed to existing binary toolchains compiled for arm64 and x86,
>   together with a typical configuration.
>

For your side:
Cross compiling the kernel is a good starting point. GCC/Clang cross compile
toolchains for s390 are available on all major distros. They are typically
postfixed with ‘-s390x-linux-gnu‘, note the x after s390. defconfig has KVMARM
in it - this should be suitable for testing you do not break s390 compilation.

You can get access to s390 resources for doing native builds in the LinuxONE
community cloud. Those are VMs itself -> run tests are not possible.
https://community.ibm.com/zsystems/l1cc
They also offer permanent access to OSS communities if necessary. We can help
to connect you with those teams.

Another option would be to spin-up a s390 qemu-tcg guest to build the kernel
'native'.

For us:
Yes we are planning to do regular tests to prevent breaking arm. Testing your
CI branches seems to be a good starting point for this. Do you have a few
pointers which are suited best?

>   What about debugging? We expect that you'd have to help, should an
>   arm64 change cause a regression on s390, as it is fairly unlikely
>   that we would be able to reproduce it.

Positive, we will do whatever we can to support you in any way.

> 
>   Finally, we feel it would be beneficial for both projects to swap
>   prisoners and have cross-reviewers in MAINTAINERS, so that there is
>   an s390 reviewer added to KVM/arm64, and an arm64 reviewer added to
>   KVM/s390.

Great Idea and I like the wording :)
We’ll start with the exchange. I (Steffen) would volunteer to be sent over to you.
I will add myself as kvm/arm64 reviewer in v2 of this series if that is OK for
you.

For the other way we appreciate any volunteers and also will ask around for suitable
people with arm and preferably also s390 knowledge. 

> 
> It probably would be beneficial to work through some of these things
> face-to-face. Maybe around LPC or KVM Forum if you manage to get
> there? Or some other place/time?

Totally agree, although I would prefer an earlier date (probably virtual) to 
get rid of any serious misunderstandings that may be there early. 
Surely, we can meet at LPC and/or KVM-forum as well to discuss even more.

Thank you very much for your openness and your constructive, honest
feedback.

	Steffen & the KVM/s390 team

> 
> Thanks,
> 
> 	Marc and Will
> 
> -- 
> Without deviation from the norm, progress is not possible.