From: Steffen Eiden <seiden@linux.ibm.com>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>,
Fuad Tabba <fuad.tabba@linux.dev>,
Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Andreas Grapentin <gra@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Friedrich Welter <fritz@linux.ibm.com>,
Gautam Gala <ggala@linux.ibm.com>,
Hariharan Mari <hari55@linux.ibm.com>,
Hendrik Brueckner <brueckner@linux.ibm.com>,
Nico Boehr <nrb@linux.ibm.com>,
Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
Arnd Bergmann <arnd@arndb.de>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
linux-s390@vger.kernel.org, Steffen Eiden <seiden@linux.ibm.com>
Subject: [PATCH 04/12] KVM: s390: arm64: Use register shadow helper
Date: Wed, 02 Dec 2026 15:11:42 +0100 [thread overview]
Message-ID: <20261202-smccc-v1-4-48340e2737b6@linux.ibm.com> (raw)
In-Reply-To: <20261202-smccc-v1-0-48340e2737b6@linux.ibm.com>
To clearly mark the intention of the save/restore around SAE and to give
a single point for the shadowing process add and use hepler functions to
save and restore the shadow copy of the shadowed registers. For EL 0/1
this process is symmetrical. For EL2 registers the registers only need
to be restored as the EL0/1 guest could not have modified those.
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
---
arch/s390/kvm/arm64/arm.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/arch/s390/kvm/arm64/arm.c b/arch/s390/kvm/arm64/arm.c
index cd59a382a70c..2ca2d7e18032 100644
--- a/arch/s390/kvm/arm64/arm.c
+++ b/arch/s390/kvm/arm64/arm.c
@@ -447,6 +447,21 @@ static noinstr void arm_vcpu_enter_exit(phys_addr_t sae_block)
guest_timing_exit_irqoff();
}
+static void kvm_arm_restore_shadowed_regs(struct kvm_vcpu *vcpu)
+{
+ vcpu_write_host_sys_reg(vcpu, vcpu->arch.hcr_el2, SYS_HCR_EL2);
+ vcpu_write_host_sys_reg(vcpu, vcpu->arch.hcrx_el2, SYS_HCRX_EL2);
+ vcpu_write_host_sys_reg(vcpu, vcpu->arch.mpidr, SYS_VMPIDR_EL2);
+ _vcpu_write_sys_reg(vcpu, vcpu->arch.ctxt.elr_el1, SYS_ELR_EL1);
+ _vcpu_write_sys_reg(vcpu, vcpu->arch.ctxt.spsr_el1, SYS_SPSR_EL1);
+}
+
+static void kvm_arm_save_shadowed_regs(struct kvm_vcpu *vcpu)
+{
+ vcpu->arch.ctxt.elr_el1 = _vcpu_read_sys_reg(vcpu, SYS_ELR_EL1);
+ vcpu->arch.ctxt.spsr_el1 = _vcpu_read_sys_reg(vcpu, SYS_SPSR_EL1);
+}
+
/** kvm_arch_vcpu_ioctl_run() - run arm64 vCPU
*
* Execute arm64 guest instructions using SAE.
@@ -516,16 +531,10 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
trace_kvm_entry(*vcpu_pc(vcpu));
kvm_adjust_pc(vcpu);
- vcpu_write_host_sys_reg(vcpu, vcpu->arch.hcr_el2, SYS_HCR_EL2);
- vcpu_write_host_sys_reg(vcpu, vcpu->arch.hcrx_el2, SYS_HCRX_EL2);
- vcpu_write_host_sys_reg(vcpu, vcpu->arch.mpidr, SYS_VMPIDR_EL2);
- _vcpu_write_sys_reg(vcpu, vcpu->arch.ctxt.elr_el1, SYS_ELR_EL1);
- _vcpu_write_sys_reg(vcpu, vcpu->arch.ctxt.spsr_el1, SYS_SPSR_EL1);
+ kvm_arm_restore_shadowed_regs(vcpu);
arm_vcpu_enter_exit(virt_to_phys(&vcpu->arch.sae_block));
-
- vcpu->arch.ctxt.elr_el1 = _vcpu_read_sys_reg(vcpu, SYS_ELR_EL1);
- vcpu->arch.ctxt.spsr_el1 = _vcpu_read_sys_reg(vcpu, SYS_SPSR_EL1);
+ kvm_arm_save_shadowed_regs(vcpu);
vcpu->mode = OUTSIDE_GUEST_MODE;
vcpu->stat.exits++;
--
2.56.1
next prev parent reply other threads:[~2026-12-02 14:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 14:11 [PATCH 00/12] KVM: s390: arm64: SMCCC, timers and IRQ line Steffen Eiden
2026-12-02 14:11 ` [PATCH 01/12] arm64: Prepare for sharing with s390 Steffen Eiden
2026-12-02 14:11 ` [PATCH 02/12] arm64: Share timer and smccc functionality " Steffen Eiden
2026-12-02 14:11 ` [PATCH 03/12] KVM: arm64: Share timer and smccc code " Steffen Eiden
2026-12-02 14:11 ` Steffen Eiden [this message]
2026-12-02 14:11 ` [PATCH 05/12] KVM: s390: arm64: Shadow the guest timer CVAL registers Steffen Eiden
2026-12-02 14:11 ` [PATCH 06/12] KVM: s390: arm64: Use mpstate for guests Steffen Eiden
2026-12-02 14:11 ` [PATCH 07/12] KVM: s390: arm64: Enable full smccc support Steffen Eiden
2026-12-02 14:35 ` sashiko-bot
2026-12-02 14:11 ` [PATCH 08/12] KVM: s390: arm64: Report fwregs to userspace Steffen Eiden
2026-12-02 14:11 ` [PATCH 09/12] KVM: s390: arm64: Provide timer infrastructure Steffen Eiden
2026-12-02 14:26 ` sashiko-bot
2026-12-02 14:11 ` [PATCH 10/12] KVM: s390: arm64: Integrate guest timer Steffen Eiden
2026-12-02 14:34 ` sashiko-bot
2026-12-02 14:11 ` [PATCH 11/12] KVM: s390: arm64: Trap WFx Steffen Eiden
2026-12-02 14:11 ` [PATCH 12/12] KVM: s390: arm64: Add IRQ line Steffen Eiden
2026-12-02 14:54 ` sashiko-bot
2026-12-02 14:54 ` [PATCH 00/12] KVM: s390: arm64: SMCCC, timers and " sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202-smccc-v1-4-48340e2737b6@linux.ibm.com \
--to=seiden@linux.ibm.com \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=arnd@arndb.de \
--cc=borntraeger@linux.ibm.com \
--cc=brueckner@linux.ibm.com \
--cc=catalin.marinas@arm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=fritz@linux.ibm.com \
--cc=fuad.tabba@linux.dev \
--cc=ggala@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=gra@linux.ibm.com \
--cc=hari55@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=nrb@linux.ibm.com \
--cc=oupton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=suzuki.poulose@arm.com \
--cc=svens@linux.ibm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.