From: Andreas Grapentin <gra@linux.ibm.com>
To: Steffen Eiden <seiden@linux.ibm.com>,
Marc Zyngier <maz@kernel.org>, Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Andreas Grapentin <gra@linux.ibm.com>
Subject: [PATCH 01/10] s390/sae: Prepare handling host interrupts during SAE execution
Date: Fri, 04 Dec 2026 13:09:13 +0100 [thread overview]
Message-ID: <20261204-host-irq-v1-1-a8387ee8a380@linux.ibm.com> (raw)
In-Reply-To: <20261204-host-irq-v1-0-a8387ee8a380@linux.ibm.com>
From: Steffen Eiden <seiden@linux.ibm.com>
Manage the host interrupt mask directly in assembly. Remove the
temporary raw_local_irq enable/ disable workaround from C code to
prepare to eliminate entry/exit races later.
Add a pointer to the current vCPU, SAE control block, and an IRQ state
slot to the SAE stack frame. The vCPU pointer can be used by s390 kernel
handlers to forward work to the arm on s390 module. The control block
can be used for correctly handling perf events for SAE guests. The IRQ
stack slot is used by the stosm/stnsm instructions to enable and disable
interrupts around SAE execution like SIE does.
Co-developed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Co-developed-by: Andreas Grapentin <gra@linux.ibm.com>
Signed-off-by: Andreas Grapentin <gra@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
---
arch/s390/include/asm/sae.h | 2 +-
arch/s390/include/asm/stacktrace.h | 3 +++
arch/s390/kernel/asm-offsets.c | 3 +++
arch/s390/kernel/entry.S | 11 ++++++++++-
arch/s390/kvm/arm64/arm.c | 18 ++++--------------
5 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/arch/s390/include/asm/sae.h b/arch/s390/include/asm/sae.h
index d1b9af770108..fd3f042fb497 100644
--- a/arch/s390/include/asm/sae.h
+++ b/arch/s390/include/asm/sae.h
@@ -9,7 +9,7 @@
#ifndef __ASSEMBLER__
/* defined in arch/s390/kernel/entry.S */
-asmlinkage void sae(phys_addr_t sae_block_phys);
+asmlinkage void sae(phys_addr_t sae_block_phys, void *sae_block, void *vcpu);
#include <linux/io.h>
#include <asm/extable.h>
diff --git a/arch/s390/include/asm/stacktrace.h b/arch/s390/include/asm/stacktrace.h
index 2d332d7c8145..d0cc948444d6 100644
--- a/arch/s390/include/asm/stacktrace.h
+++ b/arch/s390/include/asm/stacktrace.h
@@ -72,6 +72,9 @@ struct stack_frame {
/* SAE stack frame */
struct {
unsigned long sae_bear;
+ unsigned long sae_block;
+ unsigned long sae_vcpu;
+ unsigned long sae_irq;
};
};
unsigned long gprs[10];
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index f9f9c2246074..e09158248248 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -71,6 +71,9 @@ int main(void)
OFFSET(__SF_SIE_GUEST_ASCE, stack_frame, sie_guest_asce);
OFFSET(__SF_SIE_IRQ, stack_frame, sie_irq);
OFFSET(__SF_SAE_BEAR, stack_frame, sae_bear);
+ OFFSET(__SF_SAE_BLOCK, stack_frame, sae_block);
+ OFFSET(__SF_SAE_VCPU, stack_frame, sae_vcpu);
+ OFFSET(__SF_SAE_IRQ, stack_frame, sae_irq);
DEFINE(STACK_FRAME_OVERHEAD, sizeof(struct stack_frame));
BLANK();
OFFSET(__SFUSER_BACKCHAIN, stack_frame_user, back_chain);
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index 999dc7d0c637..14dea207b30e 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -248,12 +248,21 @@ EXPORT_SYMBOL(sie_exit)
#if IS_ENABLED(CONFIG_KVM)
/*
* SAE calling convention:
- * %r2 physical address of the SAE control block
+ * %r2 pointer to sae control block phys
+ * %r3 pointer to sae control block virt
+ * %r4 vcpu pointer
*/
SYM_FUNC_START(sae)
stmg %r6,%r14,__SF_GPRS(%r15) # store kernel registers
STBEAR __SF_SAE_BEAR(%r15) # save breaking event address register
+ stg %r3,__SF_SAE_BLOCK(%r15) # save sae block for perf
+ stg %r4,__SF_SAE_VCPU(%r15) # save vcpu ptr for interrupt handling
+ stosm __SF_SAE_IRQ(%r15),0x03
.insn rre,0xb9a50000,%r2,0 # Start Arm Execution
+# Let the next instruction be NOP to avoid triggering a machine check
+# and handling it in a guest as result of the instruction execution.
+ nopr 7
+ stnsm __SF_SAE_IRQ(%r15),0xfc
LBEAR __SF_SAE_BEAR(%r15) # restore breaking event address register
lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
xgr %r0,%r0 # clear guest registers to
diff --git a/arch/s390/kvm/arm64/arm.c b/arch/s390/kvm/arm64/arm.c
index cd59a382a70c..547f77be7e3c 100644
--- a/arch/s390/kvm/arm64/arm.c
+++ b/arch/s390/kvm/arm64/arm.c
@@ -425,23 +425,13 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,
return -EINVAL;
}
-static noinstr void arm_vcpu_enter_exit(phys_addr_t sae_block)
+static noinstr void arm_vcpu_enter_exit(struct kvm_sae_block *sae_block,
+ struct kvm_vcpu *vcpu)
{
guest_timing_enter_irqoff();
guest_state_enter_irqoff();
- /*
- * External interrupts may occur while the SAE instruction is executing
- * and must preempt guest execution to maintain responsiveness of the
- * host.
- *
- * As a temporary workaround, run SAE with interrupts enabled so that any
- * interrupt is taken via the normal host interrupt path rather than
- * being subsumed inside the SAE window.
- */
- raw_local_irq_enable();
- sae(sae_block);
- raw_local_irq_disable();
+ sae(virt_to_phys(sae_block), sae_block, vcpu);
guest_state_exit_irqoff();
guest_timing_exit_irqoff();
@@ -522,7 +512,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
_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);
- arm_vcpu_enter_exit(virt_to_phys(&vcpu->arch.sae_block));
+ arm_vcpu_enter_exit(&vcpu->arch.sae_block, 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);
--
2.55.0
next prev parent reply other threads:[~2026-12-04 12:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 12:09 [PATCH 00/10] s390: Host interrupt handling for SAE guests Andreas Grapentin
2026-12-04 12:09 ` Andreas Grapentin [this message]
2026-12-04 12:09 ` [PATCH 02/10] s390/sae: Add sae_entry and sae_exit symbols Andreas Grapentin
2026-12-04 12:09 ` [PATCH 03/10] KVM: s390: Share mcck_volatile_info between KVMs Andreas Grapentin
2026-12-04 12:09 ` [PATCH 04/10] s390/irq: Add kvm_exit callback for arm-on-s390 Andreas Grapentin
2026-12-04 12:09 ` [PATCH 05/10] KVM: s390: arm64: Enable host irq Andreas Grapentin
2026-12-04 12:09 ` [PATCH 06/10] s390: Rename CIF_MCCK_GUEST to CIF_MCCK_SIE Andreas Grapentin
2026-12-04 12:09 ` [PATCH 07/10] s390/nmi: Handle MCCKs for SAE guests Andreas Grapentin
2026-12-04 12:09 ` [PATCH 08/10] KVM: s390: arm64: Enable SError injection Andreas Grapentin
2026-12-04 12:09 ` [PATCH 09/10] KVM: s390: arm64: Enable mcck forwarding Andreas Grapentin
2026-12-04 12:09 ` [PATCH 10/10] s390/perf: Recognize SAE guests Andreas Grapentin
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=20261204-host-irq-v1-1-a8387ee8a380@linux.ibm.com \
--to=gra@linux.ibm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=agordeev@linux.ibm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=borntraeger@linux.ibm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=seiden@linux.ibm.com \
--cc=svens@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®