Linux Perf Users
 help / color / mirror / Atom feed
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 09/10] KVM: s390: arm64: Enable mcck forwarding
Date: Fri, 04 Dec 2026 13:09:21 +0100	[thread overview]
Message-ID: <20261204-host-irq-v1-9-a8387ee8a380@linux.ibm.com> (raw)
In-Reply-To: <20261204-host-irq-v1-0-a8387ee8a380@linux.ibm.com>

From: Steffen Eiden <seiden@linux.ibm.com>

Register KVM callback for machine check backup info. On resume,
translate saved machine check conditions into ARM64 SError exceptions
and reinject them into the guest via kvm_inject_serror_esr().

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>
---
 arch/s390/include/asm/kvm_host_arm64.h |  3 +++
 arch/s390/kvm/arm64/arm.c              | 44 ++++++++++++++++++++++++++++++++++
 arch/s390/kvm/arm64/reset.c            |  3 +++
 3 files changed, 50 insertions(+)

diff --git a/arch/s390/include/asm/kvm_host_arm64.h b/arch/s390/include/asm/kvm_host_arm64.h
index a76e1bfc64bb..5d9487f37482 100644
--- a/arch/s390/include/asm/kvm_host_arm64.h
+++ b/arch/s390/include/asm/kvm_host_arm64.h
@@ -116,6 +116,9 @@ struct kvm_vcpu_arch {
 
 	struct kvm_s390_mmu_cache *mc;
 
+	/* Saved machine check info when mcck occurs during SAE execution */
+	struct mcck_volatile_info mcck_info;
+
 	void *debugfs_state_data;
 };
 
diff --git a/arch/s390/kvm/arm64/arm.c b/arch/s390/kvm/arm64/arm.c
index 49e2ffcfdf22..22ed1109f7b8 100644
--- a/arch/s390/kvm/arm64/arm.c
+++ b/arch/s390/kvm/arm64/arm.c
@@ -13,8 +13,11 @@
 
 #include <asm/access-regs.h>
 #include <asm/aef.h>
+#include <asm/irq.h>
+#include <asm/nmi.h>
 
 #include <arm64/kvm_emulate.h>
+#include <arm64/esr.h>
 #include <arm64/sysreg.h>
 #include <arm64/sys_regs.h>
 
@@ -433,6 +436,42 @@ static noinstr void kvm_sae_exit_handler(unsigned long v)
 	WRITE_ONCE(vcpu->mode, OUTSIDE_GUEST_MODE);
 }
 
+static noinstr void
+kvm_sae_backup_mcck_info(void *v, struct mcck_volatile_info *mcck_info)
+{
+	struct kvm_vcpu *vcpu = v;
+
+	vcpu->arch.mcck_info = *mcck_info;
+}
+
+static u64 mci_to_esr(union mci mci)
+{
+	/* for now, as a reasonable approximation, consider any host
+	 * machine check during arm64 guest execution a fatal uncontainable
+	 * event for the arm64 guest.
+	 */
+	return ESR_ELx_AET_UEU | ESR_ELx_FSC_SERROR;
+}
+
+static void reinject_mcck(struct kvm_vcpu *vcpu)
+{
+	struct mcck_volatile_info *mcck;
+	union mci mci;
+	u64 esr;
+
+	mcck = &vcpu->arch.mcck_info;
+	mci.val = mcck->mcic;
+
+	if (!mcck->mcic)
+		return;
+
+	esr = mci_to_esr(mci);
+
+	memset(mcck, 0, sizeof(*mcck));
+
+	kvm_inject_serror_esr(vcpu, esr);
+}
+
 static noinstr void arm_vcpu_enter_exit(struct kvm_sae_block *sae_block,
 					struct kvm_vcpu *vcpu)
 {
@@ -492,6 +531,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
 		if (ret > 0)
 			ret = check_vcpu_requests(vcpu);
 
+		if (ret > 0)
+			reinject_mcck(vcpu);
+
 		vcpu->arch.sae_block.icptr = 0;
 
 		local_irq_disable();
@@ -816,6 +858,7 @@ static bool __init machine_supports_arm64_kvm(void)
 static void unregister_callbacks(void)
 {
 	kvm_s390_arm64_vcpu_exit = NULL;
+	kvm_sae_backup_mci = NULL;
 	/* wait for all possible users of the callback to quiesce */
 	synchronize_rcu();
 }
@@ -836,6 +879,7 @@ static int __init kvm_s390_arm64_init(void)
 	}
 
 	kvm_s390_arm64_vcpu_exit = kvm_sae_exit_handler;
+	kvm_sae_backup_mci = kvm_sae_backup_mcck_info;
 
 	/*
 	 *  kvm_init _must_ be the very last thing done, as this exposes
diff --git a/arch/s390/kvm/arm64/reset.c b/arch/s390/kvm/arm64/reset.c
index 2ae363f6821a..206f42ba3256 100644
--- a/arch/s390/kvm/arm64/reset.c
+++ b/arch/s390/kvm/arm64/reset.c
@@ -109,6 +109,9 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu)
 	vcpu_reset_cnthctl(vcpu);
 	vcpu_reset_icc(vcpu);
 
+	/* Discard any pending mcck's */
+	memset(&vcpu->arch.mcck_info, 0, sizeof(vcpu->arch.mcck_info));
+
 	if (reset_state.reset) {
 		*vcpu_pc(vcpu) = reset_state.pc;
 		vcpu_clear_flag(vcpu, PENDING_EXCEPTION);

-- 
2.55.0


  parent reply	other threads:[~2026-12-04 12:11 UTC|newest]

Thread overview: 20+ 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 ` [PATCH 01/10] s390/sae: Prepare handling host interrupts during SAE execution Andreas Grapentin
2026-12-04 12:31   ` sashiko-bot
2026-12-04 12:09 ` [PATCH 02/10] s390/sae: Add sae_entry and sae_exit symbols Andreas Grapentin
2026-12-04 12:30   ` sashiko-bot
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:40   ` sashiko-bot
2026-12-04 12:09 ` [PATCH 05/10] KVM: s390: arm64: Enable host irq Andreas Grapentin
2026-12-04 12:35   ` sashiko-bot
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:40   ` sashiko-bot
2026-12-04 12:09 ` [PATCH 08/10] KVM: s390: arm64: Enable SError injection Andreas Grapentin
2026-12-04 12:34   ` sashiko-bot
2026-12-04 12:09 ` Andreas Grapentin [this message]
2026-12-04 12:33   ` [PATCH 09/10] KVM: s390: arm64: Enable mcck forwarding sashiko-bot
2026-12-04 12:09 ` [PATCH 10/10] s390/perf: Recognize SAE guests Andreas Grapentin
2026-12-04 12:30   ` sashiko-bot
2026-12-04 12:40 ` [PATCH 00/10] s390: Host interrupt handling for " 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=20261204-host-irq-v1-9-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