From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: frankja@linux.ibm.com, nrb@linux.ibm.com, seiden@linux.ibm.com,
scgl@linux.ibm.com, thuth@redhat.com
Subject: [kvm-unit-tests PATCH v1 1/2] lib: s390x: terminate if PGM interrupt in interrupt handler
Date: Tue, 18 Oct 2022 16:09:50 +0200 [thread overview]
Message-ID: <20221018140951.127093-2-imbrenda@linux.ibm.com> (raw)
In-Reply-To: <20221018140951.127093-1-imbrenda@linux.ibm.com>
If a program interrupt is received while in an interrupt handler,
terminate immediately, stopping all CPUs and leaving the last CPU in
disabled wait with a specific PSW code.
This will aid debugging by not cluttering the output, avoiding further
interrupts (that would be needed to write to the output), and providing
an indication of the cause of the termination.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
lib/s390x/asm/arch_def.h | 11 +++++++++++
lib/s390x/interrupt.c | 18 ++++++++++++++----
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
index b92291e8..124449a8 100644
--- a/lib/s390x/asm/arch_def.h
+++ b/lib/s390x/asm/arch_def.h
@@ -51,6 +51,7 @@ struct cpu {
bool active;
bool pgm_int_expected;
bool ext_int_expected;
+ bool in_interrupt_handler;
};
#define AS_PRIM 0
@@ -330,6 +331,16 @@ static inline void load_psw_mask(uint64_t mask)
: "+r" (tmp) : "a" (&psw) : "memory", "cc" );
}
+static inline void disabled_wait(uint64_t message)
+{
+ struct psw psw = {
+ .mask = PSW_MASK_WAIT, /* Disabled wait */
+ .addr = message,
+ };
+
+ asm volatile(" lpswe 0(%0)\n" : : "a" (&psw) : "memory", "cc");
+}
+
/**
* psw_mask_clear_bits - clears bits from the current PSW mask
* @clear: bitmask of bits that will be cleared
diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
index 7cc2c5fb..22bf443b 100644
--- a/lib/s390x/interrupt.c
+++ b/lib/s390x/interrupt.c
@@ -14,6 +14,7 @@
#include <sie.h>
#include <fault.h>
#include <asm/page.h>
+#include "smp.h"
/**
* expect_pgm_int - Expect a program interrupt on the current CPU.
@@ -226,6 +227,11 @@ static void print_pgm_info(struct stack_frame_int *stack)
void handle_pgm_int(struct stack_frame_int *stack)
{
+ if (THIS_CPU->in_interrupt_handler) {
+ /* Something went very wrong, stop everything now without printing anything */
+ smp_teardown();
+ disabled_wait(0xfa12edbad21);
+ }
if (!THIS_CPU->pgm_int_expected) {
/* Force sclp_busy to false, otherwise we will loop forever */
sclp_handle_ext();
@@ -242,6 +248,7 @@ void handle_pgm_int(struct stack_frame_int *stack)
void handle_ext_int(struct stack_frame_int *stack)
{
+ THIS_CPU->in_interrupt_handler = true;
if (!THIS_CPU->ext_int_expected && lowcore.ext_int_code != EXT_IRQ_SERVICE_SIG) {
report_abort("Unexpected external call interrupt (code %#x): on cpu %d at %#lx",
lowcore.ext_int_code, stap(), lowcore.ext_old_psw.addr);
@@ -260,6 +267,7 @@ void handle_ext_int(struct stack_frame_int *stack)
if (THIS_CPU->ext_cleanup_func)
THIS_CPU->ext_cleanup_func(stack);
+ THIS_CPU->in_interrupt_handler = false;
}
void handle_mcck_int(void)
@@ -272,11 +280,13 @@ static void (*io_int_func)(void);
void handle_io_int(void)
{
+ THIS_CPU->in_interrupt_handler = true;
if (io_int_func)
- return io_int_func();
-
- report_abort("Unexpected io interrupt: on cpu %d at %#lx",
- stap(), lowcore.io_old_psw.addr);
+ io_int_func();
+ else
+ report_abort("Unexpected io interrupt: on cpu %d at %#lx",
+ stap(), lowcore.io_old_psw.addr);
+ THIS_CPU->in_interrupt_handler = false;
}
int register_io_int_func(void (*f)(void))
--
2.37.3
next prev parent reply other threads:[~2022-10-18 14:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 14:09 [kvm-unit-tests PATCH v1 0/2] s390x misc fixes Claudio Imbrenda
2022-10-18 14:09 ` Claudio Imbrenda [this message]
2022-10-19 7:34 ` [kvm-unit-tests PATCH v1 1/2] lib: s390x: terminate if PGM interrupt in interrupt handler Nico Boehr
2022-10-19 9:51 ` Claudio Imbrenda
2022-10-20 7:58 ` Nico Boehr
2022-10-20 8:57 ` Claudio Imbrenda
2022-10-20 11:19 ` Janosch Frank
2022-10-20 11:45 ` Claudio Imbrenda
2022-10-20 12:12 ` Janosch Frank
2022-10-18 14:09 ` [kvm-unit-tests PATCH v1 2/2] s390x: uv-host: fix allocation of UV memory Claudio Imbrenda
2022-10-19 6:34 ` Janosch Frank
2022-10-20 8:07 ` Steffen Eiden
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=20221018140951.127093-2-imbrenda@linux.ibm.com \
--to=imbrenda@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=nrb@linux.ibm.com \
--cc=scgl@linux.ibm.com \
--cc=seiden@linux.ibm.com \
--cc=thuth@redhat.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.