Linux s390 Architecture development
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: imbrenda@linux.ibm.com, linux-s390@vger.kernel.org,
	borntraeger@linux.ibm.com
Subject: [kvm-unit-tests PATCH] s390x: firq: Trigger KVM flic injection bug
Date: Thu, 13 Aug 2026 14:40:15 +0000	[thread overview]
Message-ID: <20260813144058.7125-1-frankja@linux.ibm.com> (raw)

The flic will try to wakeup the last cpu that went to sleep since it
might still be in halt poll and therefore fast to take up work
again. Problem is that there's no check if that vcpu is even enabled
for the specific IRQ that's being injected or any other pending
floating IRQ.

To trigger this bug we setup a third cpu which enables its masks for
external calls and goes into enabled wait AFTER the second cpu went
into enabled wait. This will set KVM's tracking of the last sleeping
cpu to the third cpu. Once the service IRQ is injected KVM will wakeup
cpu #3 which will promptly go back to sleep and the test hangs.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/firq.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/s390x/firq.c b/s390x/firq.c
index 0d65d87f..03638a14 100644
--- a/s390x/firq.c
+++ b/s390x/firq.c
@@ -17,6 +17,12 @@
 #include <smp.h>
 #include <alloc_page.h>
 
+static void wait_for_ext_call(void)
+{
+	ctl_set_bit(0, CTL0_EXTERNAL_CALL);
+	wait_for_interrupt(PSW_MASK_EXT);
+}
+
 static void wait_for_sclp_int(void)
 {
 	/* Enable SCLP interrupts on this CPU only. */
@@ -57,6 +63,16 @@ static void test_wait_state_delivery(void)
 	ret = smp_cpu_setup(1, PSW_WITH_CUR_MASK(wait_for_sclp_int));
 	/* This must not fail because we have at least 3 CPUs */
 	assert(!ret);
+	while(smp_sense_running_status(2));
+
+	/*
+	 * Move CPU #2 into wait so it's the last that entered sleep
+	 * and therefore KVM will try to wake it up first since it
+	 * might still be polling. But since its masks are not open
+	 * for a service IRQ it's not a valid wakeup target.
+	 */
+	ret = smp_cpu_setup(2, PSW_WITH_CUR_MASK(wait_for_ext_call));
+	assert(!ret);
 
 	/*
 	 * We'd have to jump trough some hoops to sense e.g., via SIGP
@@ -90,6 +106,7 @@ static void test_wait_state_delivery(void)
 out_destroy:
 	free_page(h);
 	smp_cpu_destroy(1);
+	smp_cpu_destroy(2);
 out:
 	report_prefix_pop();
 }
-- 
2.53.0


                 reply	other threads:[~2026-08-13 14:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260813144058.7125-1-frankja@linux.ibm.com \
    --to=frankja@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    /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