s390x misc fixes
v2 cover s390x misc fixes
Two unrelated misc fixes for s390x:
* abort immediately and without printing anything if a program interrupt is received inside an interrupt handler
* fix the uv-host test so that it allocates UV memory properly
v1->v2
* set the flag to abort immediately also during program interrupts
Claudio Imbrenda (2):
lib: s390x: terminate if PGM interrupt in interrupt handler
s390x: uv-host: fix allocation of UV memory
lib/s390x/asm/arch_def.h | 11 +++++++++++ lib/s390x/interrupt.c | 20 ++++++++++++++++---- s390x/uv-host.c | 2 +- 3 files changed, 28 insertions(+), 5 deletions(-)
Signature · 1 line
2.37.3
PATCH v2 1/2 lib: s390x: terminate if PGM interrupt in interrupt handler
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.
--- lib/s390x/asm/arch_def.h | 11 +++++++++++ lib/s390x/interrupt.c | 20 ++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-)
lib/s390x/asm/arch_def.h +11 -0
@@ -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, + }; + + asmvolatile (" 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
lib/s390x/interrupt.c +16 -4
@@ -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 ();
@@ -233,15 +239,18 @@ void handle_pgm_int(struct stack_frame_int *stack) }THIS_CPU ->pgm_int_expected = false; +THIS_CPU ->in_interrupt_handler = true;if (THIS_CPU ->pgm_cleanup_func)THIS_CPU ->pgm_cleanup_func (stack);else fixup_pgm_int (stack); +THIS_CPU ->in_interrupt_handler = false; }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 +269,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 +282,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 ))
Signature · 1 line
2.37.3
Re: [kvm-unit-tests PATCH v2 1/2] lib: s390x: terminate if PGM interrupt in interrupt handler
Quoting Claudio Imbrenda (2022-10-20 14:31:42)
Quoted 9 lines
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 <[email protected]>
PATCH v2 2/2 s390x: uv-host: fix allocation of UV memory
In reply to Claudio ImbrendaAllocate the donated storage with 1M alignment from the normal pool, to force it to be above 2G without wasting a whole 2G block of memory.
Reviewed-by; Steffen Eiden <[email protected]>
--- s390x/uv-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
s390x/uv-host.c +1 -1
@@ -329,7 +329,7 @@ static void test_init(void)struct psw psw;/* Donated storage needs to be over 2GB */ - mem = (uint64_t )memalign (1UL <<31 , uvcb_qui.uv_base_stor_len); + mem = (uint64_t )memalign_pages_flags (SZ_1M , uvcb_qui.uv_base_stor_len,AREA_NORMAL ); uvcb_init.header.len =sizeof (uvcb_init); uvcb_init.header.cmd =UVC_CMD_INIT_UV ;
Signature · 1 line
2.37.3