@@ -34,6 +34,7 @@ tests += $(TEST_DIR)/migration.elf
tests += $(TEST_DIR)/pv-attest.elf
tests += $(TEST_DIR)/migration-cmm.elf
tests += $(TEST_DIR)/migration-skey.elf
+tests += $(TEST_DIR)/panic-loop-extint.elf
pv-tests += $(TEST_DIR)/pv-diags.elf
new file mode 100644
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * External interrupt loop test
+ *
+ * Copyright IBM Corp. 2022
+ *
+ * Authors:
+ * Nico Boehr <nrb@linux.ibm.com>
+ */
+#include <libcflat.h>
+#include <asm/interrupt.h>
+#include <asm/barrier.h>
+#include <asm/time.h>
+#include <hardware.h>
+
+static void ext_int_handler(void)
+{
+ /*
+ * return to ext_old_psw. This gives us the chance to print the return_fail
+ * in case something goes wrong.
+ */
+ asm volatile (
+ "lpswe %[ext_old_psw]\n"
+ :
+ : [ext_old_psw] "Q"(lowcore.ext_old_psw)
+ : "memory"
+ );
+}
+
+int main(void)
+{
+ struct psw ext_new_psw_orig;
+
+ report_prefix_push("panic-loop-extint");
+
+ if (!host_is_qemu() || host_is_tcg()) {
+ report_skip("QEMU-KVM-only test");
+ goto out;
+ }
+
+ ext_new_psw_orig = lowcore.ext_new_psw;
+ lowcore.ext_new_psw.addr = (uint64_t)ext_int_handler;
+ lowcore.ext_new_psw.mask |= PSW_MASK_EXT;
+
+ load_psw_mask(extract_psw_mask() | PSW_MASK_EXT);
+ ctl_set_bit(0, CTL0_CLOCK_COMPARATOR);
+
+ cpu_timer_set(1);
+
+ mdelay(2000);
+
+ /* restore previous ext_new_psw so QEMU can properly terminate */
+ lowcore.ext_new_psw = ext_new_psw_orig;
+
+ report_fail("survived extint loop");
+
+out:
+ report_prefix_pop();
+ return report_summary();
+}
@@ -184,3 +184,9 @@ groups = migration
[migration-skey]
file = migration-skey.elf
groups = migration
+
+[panic-loop-extint]
+file = panic-loop-extint.elf
+groups = panic
+accel = kvm
+timeout = 5