From patchwork Thu Oct 20 12:31:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13013389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7C6DC43217 for ; Thu, 20 Oct 2022 12:32:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbiJTMcD (ORCPT ); Thu, 20 Oct 2022 08:32:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbiJTMcA (ORCPT ); Thu, 20 Oct 2022 08:32:00 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB0FD4B4AF for ; Thu, 20 Oct 2022 05:31:58 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29KBUxmW025215 for ; Thu, 20 Oct 2022 12:31:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=tl0oFLTFOjnYx6bNLeE09Fl3x7Crxve7fZ43T+bRP4c=; b=hVDpEpnYF9aPk6OPsQWFrKJJQQ9FdMvLSSqEZTvkM4g5VYtzXEMKw2lFVgwDxbJX4XPs fjDBFgJzde/8ESlYClfciNrQB0uR2ZfurjZEWsF2TJrl0OmiIdx+HEMMW+h4BZNGlQHQ ZKVchzs3T+yW3BuXqlx93O1yM+7nf6L/BEnL2xJUEXWoml2LAufmBkZOTc7fHTb1XiF+ tWWth2DIzDZ9LGaD7S90NnX5KcKWhbq+ukiRtxHzc9fN61gLXiFgIDtVGCBbRzj8nD+0 Kqo2QwAreCO5gI9I2w2TIU+BSvi9h5s3QNs52gEgqH93PloCkbJlMZ+FGaJOZPrRKUHz Lg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb5hbj4f6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Oct 2022 12:31:58 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29KBfxUE022204 for ; Thu, 20 Oct 2022 12:31:57 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb5hbj4dv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 12:31:57 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29KCLx69003544; Thu, 20 Oct 2022 12:31:55 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma05fra.de.ibm.com with ESMTP id 3k7mg8xp3n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 12:31:54 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29KCVpjG45351390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Oct 2022 12:31:51 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BADA542041; Thu, 20 Oct 2022 12:31:51 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6536342045; Thu, 20 Oct 2022 12:31:51 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.8.239]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 Oct 2022 12:31:51 +0000 (GMT) From: Claudio Imbrenda 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 v2 1/2] lib: s390x: terminate if PGM interrupt in interrupt handler Date: Thu, 20 Oct 2022 14:31:42 +0200 Message-Id: <20221020123143.213778-2-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221020123143.213778-1-imbrenda@linux.ibm.com> References: <20221020123143.213778-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: bC6YC38P8zKQ4yFGxd8F4t1yLOVi3MmR X-Proofpoint-ORIG-GUID: UGuDauqeaOCeUWKtQFR7_IFdbUNlakFV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-20_04,2022-10-20_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 lowpriorityscore=0 mlxlogscore=478 impostorscore=0 adultscore=0 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210200074 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 Reviewed-by: Nico Boehr --- lib/s390x/asm/arch_def.h | 11 +++++++++++ lib/s390x/interrupt.c | 20 ++++++++++++++++---- 2 files changed, 27 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..dadb7415 100644 --- a/lib/s390x/interrupt.c +++ b/lib/s390x/interrupt.c @@ -14,6 +14,7 @@ #include #include #include +#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)) From patchwork Thu Oct 20 12:31:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13013388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 516A1C4332F for ; Thu, 20 Oct 2022 12:32:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbiJTMcA (ORCPT ); Thu, 20 Oct 2022 08:32:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbiJTMb7 (ORCPT ); Thu, 20 Oct 2022 08:31:59 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51EDE42AF7 for ; Thu, 20 Oct 2022 05:31:58 -0700 (PDT) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29KCS4pC021262 for ; Thu, 20 Oct 2022 12:31:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=vRW/cHVW306AYCHJzYRZ10i0nVe6XF1mhOx+r/fQmKs=; b=hG+vZEoiOlwXPo66cIwcgzSB5F17P0RgQe/nW0I5QfHDutte4f5EnUda7ul4ZhqzHQeU PhzUOtesjIdvsGIpAjHtvxNS4XCD6xusDLeV9zOMaErhTm1WSSmr7yW6EDvdcNtbsf5A DUiHs1qw76ENtgGKpfMLB37cuyegaTX1iA2s1xEeU93RDMVG1kaBPRvldNYa3SH7c26q xYgNLiU4w1wBF6ghUKfqys1uIK0uH4I4d0FChngyDUC1ifZBynalAut8Z8Hqs9R+UbGw k42qOwybdqLmq9Fyw4iMq6kW2W5DbnHIWvMCoBI8VQS8ZFDSqPplB8/slviymccyyFV3 +w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb6c3g273-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Oct 2022 12:31:57 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29KCU7lb028212 for ; Thu, 20 Oct 2022 12:31:57 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb6c3g26n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 12:31:56 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29KCLimL010926; Thu, 20 Oct 2022 12:31:55 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 3k7mg98x35-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 12:31:55 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29KCWPDu52035858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Oct 2022 12:32:25 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 31F5A42041; Thu, 20 Oct 2022 12:31:52 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD7D642045; Thu, 20 Oct 2022 12:31:51 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.8.239]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 Oct 2022 12:31:51 +0000 (GMT) From: Claudio Imbrenda 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 v2 2/2] s390x: uv-host: fix allocation of UV memory Date: Thu, 20 Oct 2022 14:31:43 +0200 Message-Id: <20221020123143.213778-3-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221020123143.213778-1-imbrenda@linux.ibm.com> References: <20221020123143.213778-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: PPmBqTHyiTLW1C9hsRsU524v_KzRfPpP X-Proofpoint-ORIG-GUID: 947igDjtJKL8v54WGyhX3A25XnmLquMj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-20_03,2022-10-20_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 clxscore=1015 adultscore=0 bulkscore=0 spamscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210200072 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Allocate 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. Signed-off-by: Claudio Imbrenda Reviewed-by: Janosch Frank Reviewed-by; Steffen Eiden --- s390x/uv-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index a1a6d120..e1fc0213 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -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;