Linux s390 Architecture development
 help / color / mirror / Atom feed
* [PATCH v4 00/25] KVM: s390: arm64: System Registers
@ 2026-11-27 14:22 Steffen Eiden
  2026-11-27 14:22 ` [PATCH v4 01/25] KVM: arm64: Route VM ID register accesses through helpers Steffen Eiden
                   ` (25 more replies)
  0 siblings, 26 replies; 31+ messages in thread
From: Steffen Eiden @ 2026-11-27 14:22 UTC (permalink / raw)
  To: Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly,
	Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon,
	Mark Rutland, Andreas Grapentin, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, David Hildenbrand,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
	Friedrich Welter, Gautam Gala, Hariharan Mari, Hendrik Brueckner,
	Nico Boehr, Ulrich Weigand, Arnd Bergmann, Paolo Bonzini
  Cc: linux-arm-kernel, kvmarm, linux-kernel, kvm, linux-s390,
	Steffen Eiden, Nina Schoetterl-Glausch, Jens Remus

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.

On top of master this series requires one patch[1] not yet merged in
order to build clean.

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

Regarding merging: 

Patches 1-10 can/should go via the KVM/arm64 tree. Note that PATCH 8 is
an s390 patch but is is required so be at this position. Otherwise, s390
will not compile when patch 10 is applied until patch 18. And I cannot
palce it before as the patch needs some stuff from the just shared
headers in PATCH 07.

Patches 11-25 can then be picked by KVM/s390. Those require the
perquisite patch [1] mentioned above.

A branch  with the prerequisite and this series is available at
kernel.org [2]. Another series may be added on top to that branch soon. 

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. For now s390 maintains its own sysreg
table but I intend to share the table with arm as soon as possible.

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. Pointer authentication is passed through where
hardware support exists. The AEF capabilities are reported under
/sys/firmware/aef/, including the raw QAAF query results.

	Steffen

[1] https://lore.kernel.org/all/20261105-insn-v2-1-ff27987aa212@linux.ibm.com
[2] https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git/log/?h=sae

---
Changes in v4:
arm64:
- split up id register refactroing into two: defineing helpers, then
  creating the new struct (marc)
- New patch "arm64: vdso: Define ARM64_S390_COMMON=1 for all vdso builds"
  to fix the arm64 (compat) vDSO build, which dies on -Wundef/-Werror
  when the sharing marker is unset.
- OSLSR conversion: also update the tools copy of sysreg.h

s390:
- The guest PT offset (EPD) is now tracked per-VM instead of per-vcpu.
- vcpu_reset_hcrx() is now non-static, runs after the feature set has
  been restricted (vcpu run pid change), and sets HCRX_EL2_MSCEn
  unconditionally, depending on MOPS
- Feature sanitisation: ARM64_HAS_HCR_NV1 no longer probes
  ID_AA64MMFR4_EL1.E2H0 and reports false, matching the other
  non-emulatable capabilities.
- AEF sysfs: dropped the redundant sae_avail/ptff_avail/edat2_avail
  attributes
- Authorship fixes: range-check asm macro patch is solely authored by
  Jens Remus. SVE patch authorship now credits Friedrich Welter.
- more smaller issues resolved

- Collected Reviewed-by tags from Joey Goulyand rebased onto master
- Link to v3: https://lore.kernel.org/r/20261106-sysreg-v3-0-75e95980fb10@linux.ibm.com

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@linux.ibm.com/

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

---
Friedrich Welter (1):
      KVM: s390: arm64: Implement SVE for arm guests

Jens Remus (1):
      s390: Add range check asm macro

Steffen Eiden (23):
      KVM: arm64: Route VM ID register accesses through helpers
      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: vdso: Define ARM64_S390_COMMON=1 for all vdso builds
      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: 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 system register managing infrastructure
      KVM: s390: arm64: Integrate system registers 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: Promote PTRAUTH capability
      s390: Report AEF features to sysfs

 Documentation/ABI/testing/sysfs-firmware-aef |  51 ++
 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            | 101 +++-
 arch/arm64/include/asm/spectre.h             |  13 +-
 arch/arm64/include/asm/sysreg.h              |  12 +-
 arch/arm64/kernel/vdso32/Makefile            |   2 +
 arch/arm64/kvm/arm.c                         |   3 +
 arch/arm64/kvm/config.c                      |  12 +-
 arch/arm64/kvm/guest.c                       |  11 +-
 arch/arm64/kvm/hyp/nvhe/pkvm.c               |  10 +-
 arch/arm64/kvm/hyp/nvhe/sys_regs.c           |   5 +-
 arch/arm64/kvm/sys_regs.c                    | 113 ++--
 arch/arm64/kvm/sys_regs.h                    |   1 +
 arch/arm64/tools/sysreg                      |  14 +
 arch/s390/include/arm64/kvm_emulate.h        |   2 +
 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       | 238 +++++++-
 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                       | 192 +++++++
 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                    | 107 +++-
 arch/s390/kvm/arm64/exception.c              | 109 ++++
 arch/s390/kvm/arm64/feature.c                | 178 ++++++
 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                  |  72 +++
 arch/s390/kvm/arm64/spectre.c                |  51 ++
 arch/s390/kvm/arm64/sys_regs.c               | 831 +++++++++++++++++++++++++++
 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 +
 tools/arch/arm64/include/asm/sysreg.h        |  12 +-
 50 files changed, 3052 insertions(+), 159 deletions(-)

base-commit: 9437ee8b6cf607e883b36e44bd755968daaebd48
change-id: 20261106-sysreg-d6adf0cd34d4
prerequisite-message-id: 20261105-insn-v2-1-ff27987aa212@linux.ibm.com
prerequisite-patch-id: ed28ef94c9056cb81bb738f1b54745d012cb613f


^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2026-11-27 15:04 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 14:22 [PATCH v4 00/25] KVM: s390: arm64: System Registers Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 01/25] KVM: arm64: Route VM ID register accesses through helpers Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 02/25] KVM: arm64: Refactor idreg caching into dedicated structure Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 03/25] KVM: arm64: Extract number of sys_reg_desc into a constant Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 04/25] arm64: sysreg: Convert OSLSR to automatic register generation Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 05/25] arm64: vdso: Define ARM64_S390_COMMON=1 for all vdso builds Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 06/25] arm64: Prepare headers for sysreg sharing with s390 Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 07/25] arm64: Share system register related headers and functions " Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 08/25] KVM: s390: arm64: Prepare for sharing arm64 SVE and ftr-reg code Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 09/25] KVM: arm64: Prepare sys_regs.c for sharing with s390 Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 10/25] KVM: arm64: Share system register code " Steffen Eiden
2026-11-27 14:36   ` sashiko-bot
2026-11-27 14:22 ` [PATCH v4 11/25] s390: tools: Share arm64/kvm headers Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 12/25] s390: Add range check asm macro Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 13/25] s390: Read/write ARM system registers Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 14/25] s390: Query arm guest time Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 15/25] KVM: s390: arm64: Query Available Arm features Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 16/25] KVM: s390: arm64: Verify machine feature set before loading Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 17/25] KVM: s390: arm64: Implement feature sanitisation Steffen Eiden
2026-11-27 14:44   ` sashiko-bot
2026-11-27 14:22 ` [PATCH v4 18/25] KVM: s390: arm64: Implement arm system register managing infrastructure Steffen Eiden
2026-11-27 15:04   ` sashiko-bot
2026-11-27 14:22 ` [PATCH v4 19/25] KVM: s390: arm64: Integrate system registers into the host Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 20/25] KVM: s390: arm64: Use QAAF init save area Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 21/25] KVM: s390: arm64: Implement exception injection Steffen Eiden
2026-11-27 14:48   ` sashiko-bot
2026-11-27 14:22 ` [PATCH v4 22/25] KVM: s390: arm64: Finalize page fault handling Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 23/25] KVM: s390: arm64: Implement SVE for arm guests Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 24/25] KVM: s390: arm64: Promote PTRAUTH capability Steffen Eiden
2026-11-27 14:22 ` [PATCH v4 25/25] s390: Report AEF features to sysfs Steffen Eiden
2026-11-27 15:04 ` [PATCH v4 00/25] KVM: s390: arm64: System Registers sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox