[PATCH v3 00/23] KVM: arm64 on s390 System Register Handling

From: Steffen Eiden

Date: Fri Nov 06 2026 - 11:23:43 EST


Add system register handling for KVM/arm64 on s390. Share KVM/arm64
code, introduce ARM guest management functions for s390 hosts, and
implement host system register & exception handling.

This is the second 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. This series builds the system register
layer on top and closes the biggest of the remaining gaps towards a
functional guest support.

This series requires 5 fixup patches not yet merged in order to build
clean.

[PATCH 0/3] KVM: s390: arm64: Fixes for arm64 KVM support [0]
[PATCH v2] s390: Guard emitting assembler macros for insn-common-asm.h [1]
[PATCH] KVM: s390: arm64: Tolerate unused functions in extracted source [2]

The series applies without those patches on 7.4-rc1 but the build will
fail or trigger warnings w/o those patches.

Changes in detail:

arm64:

Refactor the id register fields in arch_vcpu into a dedicated structure
such that it can be reused by s390. Refactor detection of the number of
sysregs. Mark sysreg related code as shared.

A few code pieces are moved inside arm headers/code to reduce the amount
of shared sections. This adds a bit of churn in the diff but reduces the
shared marker __churn__ at the end.

The shared regions deliberately contain more code and more headers than
s390 currently needs. Larger contiguous regions mean less churn whenever
the surrounding arm64 code changes. Some of this code will be used by
later series anyways. Some of the shared code will probably never be
reused by s390 at all; I trust the compiler to remove it. The reduced
churn outweighs this drawback. Since unused function checking is
disabled for shared code [3], sharing more than required does not
introduce warnings once everything is merged.

s390:

Add s390 instruction support for ARM guest management: easr/sasr for
system register access, QAAF for feature queries, and ptff extensions
for guest time handling.

Implement complete sysreg handling for s390 including feature
sanitisation, register enumeration and access, exception injection,
and finalized page fault handling.

Emulation:

Guest accesses to ID registers are trapped and served from a sanitized
copy of the QAAF query results, using the ID register sanitisation and
finalisation infrastructure shared with arm64. Userspace sees and
controls guest ID registers with the usual semantics; after the first
vCPU run the values are final. All other system registers live in the
SAE save area and are accessed by the host via EASR/SASR, either on
guest traps or through the one-reg/two-reg UAPI. The save area itself is
initialized from the QAAF-provided initial save area.

Exception handling:

Unsupported or invalid guest actions now raise proper arm64 exceptions
instead of failing exits. Page faults beyond the guest's address limits
are injected as address size faults or synchronous external aborts,
mirroring arm64's kvm_handle_guest_abort(); injected faults re-enter the
guest with the pending exception instead of exiting to userspace.

Features and userspace:

SVE is offered to guests at 128-bit vector length, backed by s390's
Vector Extension, and pointer authentication is passed through where
hardware support exists. The AEF capabilities are reported under
/sys/firmware/aef/, including the raw QAAF query results; the interface
is documented in Documentation/ABI.

For merging we will need a feature branch.

A branch with patches [0,1,2] + this series is available at
kernel.org [3].

Steffen

[0] https://lore.kernel.org/all/20261103-s390_arm64_kvm_fixups-v1-0-21c36fedd878@xxxxxxxxxxxxx/
[1] https://lore.kernel.org/all/20261105-insn-v2-1-ff27987aa212@xxxxxxxxxxxxx
[2] https://lore.kernel.org/all/20261105-series1-fixups2-v1-1-55f59e6c4c7b@xxxxxxxxxxxxx
[3] https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git/log/?h=sae

---
Changes in v3:
- rebase into 7.4-rc2 (including the first batch of arm on s390 patches)
- guard style changed from `#ifdef ARM64_S390_COMMON` to `#if ARM64_S390_COMMON == 1`
- Improve and clarify commit messages
arm64:
- generate OSLSR definitions
- consolidate more shared sections by:
- moving some code in beforehand
- deliberately adding more code/header than required.
due to [3] there will not be any unused warnings when merged.
- reduce sharing churn

s390
- streamline sasr/easr instruction generation and use
- aef_info() aggregate removed; new minimal aef_usable()/aef_gisrsa() API
- qaaf enum numbering reorganized, on reserved field was incorrectly
identified as a register.
- aef.c no longer aggregates or gates on CONFIG_KVM_S390_ARM64.
- spectre.c stubs replaced with real queries of sanitized ID regs.
- Many new sys_reg_descs entries
- QAAF init save area: save area now memcpy'd from cached aef_gisrsa()
instead of kvm_vcpu_init_save_area()
- improved pagefault handling
- reworked SVE helpers
- fixed various smaller bugs
- Link to v2: https://lore.kernel.org/all/20260831145536.913567-1-seiden@xxxxxxxxxxxxx/

Changes in v2:
- rework the entire sharing code concept to use marker instead of moving
code.

---
Steffen Eiden (23):
KVM: arm64: Refactor idreg caching into dedicated structure
KVM: arm64: Extract number of sys_reg_desc into a constant
arm64: sysreg: Convert OSLSR to automatic register generation
arm64: Prepare headers for sysreg sharing with s390
arm64: Share system register related headers and functions with s390
KVM: s390: arm64: Prepare for sharing arm64 SVE and ftr-reg code
KVM: arm64: Prepare sys_regs.c for sharing with s390
KVM: arm64: Share system register code with s390
s390: tools: Share arm64/kvm headers
s390: Add range check asm macro
s390: Read/write ARM system registers
s390: Query arm guest time
KVM: s390: arm64: Query Available Arm features
KVM: s390: arm64: Verify machine feature set before loading
KVM: s390: arm64: Implement feature sanitisation
KVM: s390: arm64: Implement arm sysreg managing infrastructure
KVM: s390: arm64: Integrate sysreg into the host
KVM: s390: arm64: Use QAAF init save area
KVM: s390: arm64: Implement exception injection
KVM: s390: arm64: Finalize page fault handling
KVM: s390: arm64: Implement SVE for arm guests
KVM: s390: arm64: Promote PTRAUTH capability
s390: Report AEF features to sysfs

Documentation/ABI/testing/sysfs-firmware-aef | 70 +++
arch/arm64/include/asm/cache.h | 3 +
arch/arm64/include/asm/cputype.h | 3 +
arch/arm64/include/asm/kvm_emulate.h | 5 +-
arch/arm64/include/asm/kvm_host.h | 64 ++-
arch/arm64/include/asm/spectre.h | 13 +-
arch/arm64/include/asm/sysreg.h | 12 +-
arch/arm64/kvm/arm.c | 3 +
arch/arm64/kvm/config.c | 10 +-
arch/arm64/kvm/guest.c | 11 +-
arch/arm64/kvm/hyp/nvhe/pkvm.c | 7 +-
arch/arm64/kvm/hyp/nvhe/sys_regs.c | 4 +-
arch/arm64/kvm/sys_regs.c | 109 ++--
arch/arm64/kvm/sys_regs.h | 1 +
arch/arm64/tools/sysreg | 14 +
arch/s390/include/arm64/kvm_hyp.h | 18 +
arch/s390/include/arm64/kvm_nested.h | 5 +
arch/s390/include/arm64/sys_regs.h | 9 +
arch/s390/include/asm/aef.h | 12 +
arch/s390/include/asm/insn-common-asm.h | 28 +
arch/s390/include/asm/kvm_host_arm64.h | 237 +++++++-
arch/s390/include/asm/kvm_host_arm64_types.h | 115 ++++
arch/s390/include/asm/sae-asm.h | 45 ++
arch/s390/include/asm/sae.h | 93 +++
arch/s390/include/asm/timex.h | 53 ++
arch/s390/kernel/Makefile | 2 +-
arch/s390/kernel/aef.c | 207 +++++++
arch/s390/kernel/dis.c | 1 +
arch/s390/kvm/arm64/Makefile | 7 +-
arch/s390/kvm/arm64/Makefile.gen | 3 +-
arch/s390/kvm/arm64/arm.c | 101 +++-
arch/s390/kvm/arm64/exception.c | 109 ++++
arch/s390/kvm/arm64/feature.c | 188 ++++++
arch/s390/kvm/arm64/feature.h | 97 ++++
arch/s390/kvm/arm64/guest.c | 268 ++++++++-
arch/s390/kvm/arm64/handle_exit.c | 1 +
arch/s390/kvm/arm64/inject_fault.c | 65 ++-
arch/s390/kvm/arm64/mmu.c | 74 ++-
arch/s390/kvm/arm64/qaaf.c | 85 +++
arch/s390/kvm/arm64/qaaf.h | 12 +
arch/s390/kvm/arm64/reset.c | 71 +++
arch/s390/kvm/arm64/spectre.c | 51 ++
arch/s390/kvm/arm64/sys_regs.c | 826 +++++++++++++++++++++++++++
arch/s390/kvm/arm64/trace.h | 50 ++
arch/s390/tools/Makefile.arm64h | 11 +-
arch/s390/tools/opcodes.txt | 3 +
include/kvm/arm_arch_timer.h | 3 +
47 files changed, 3030 insertions(+), 149 deletions(-)

base-commit: bc71431221f5ba8bb33918399552636e059c2c45
change-id: 20261106-sysreg-d6adf0cd34d4
prerequisite-message-id: 20261103-s390_arm64_kvm_fixups-v1-0-21c36fedd878@xxxxxxxxxxxxx
prerequisite-patch-id: 93d5fe93939c707a0d0c57a847270c706a9bae29
prerequisite-patch-id: af10f106ab88b2632aa77e739bf8f64e8f3b5499
prerequisite-patch-id: cf8d158bdbb43de4ae2d524efe9005f9e42ead1f
prerequisite-message-id: 20261105-insn-v2-1-ff27987aa212@xxxxxxxxxxxxx
prerequisite-patch-id: ed28ef94c9056cb81bb738f1b54745d012cb613f
prerequisite-message-id: 20261105-series1-fixups2-v1-1-55f59e6c4c7b@xxxxxxxxxxxxx
prerequisite-patch-id: a1648acb9dedea7550a5bfcce937a21016d569a8