From patchwork Mon Feb 5 20:57:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Collin L. Walling" X-Patchwork-Id: 10201843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C1969602CA for ; Mon, 5 Feb 2018 21:11:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B19B3288CE for ; Mon, 5 Feb 2018 21:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A553B288D9; Mon, 5 Feb 2018 21:11:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 476E8288CE for ; Mon, 5 Feb 2018 21:11:23 +0000 (UTC) Received: from localhost ([::1]:36576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eio2s-0005ga-FM for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Feb 2018 16:11:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eintd-0005ku-PG for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1einta-0003VS-M4 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:49 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41300 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1einta-0003V9-H8 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 16:01:46 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15KxS4K010011 for ; Mon, 5 Feb 2018 16:01:45 -0500 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fxxmt0cyh-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 16:01:44 -0500 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 16:01:44 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 16:01:41 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15L1ewu47906942; Mon, 5 Feb 2018 21:01:40 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 153F1112034; Mon, 5 Feb 2018 15:59:44 -0500 (EST) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.149]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 0703A11204B; Mon, 5 Feb 2018 15:59:44 -0500 (EST) From: "Collin L. Walling" To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 15:57:25 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> References: <1517864246-11101-1-git-send-email-walling@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18020521-2213-0000-0000-000002680BE6 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008478; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000248; SDB=6.00985441; UDB=6.00500015; IPR=6.00764812; BA=6.00005812; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019386; XFM=3.00000015; UTC=2018-02-05 21:01:43 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020521-2214-0000-0000-000059031794 Message-Id: <1517864246-11101-12-git-send-email-walling@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v5 11/12] s390-ccw: clear pending irqs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: frankja@linux.vnet.ibm.com, thuth@redhat.com, cohuck@redhat.com, david@redhat.com, alifm@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP It is possible while waiting for multiple types of external interrupts that we might have pending irqs remaining between irq consumption and irq disabling. Those interrupts could propagate to the guest after IPL completes and cause unwanted behavior. To avoid this, we clear the write event mask to prevent further service interrupts from ASCII events and then consume all pending irqs for a miniscule duration. Once finished, we reset the write event mask and resume business as usual. Signed-off-by: Collin L. Walling --- pc-bios/s390-ccw/menu.c | 16 ++++++++++++++++ pc-bios/s390-ccw/sclp.c | 12 ++++++++++++ 2 files changed, 28 insertions(+) diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index 85d285f..971f6b6 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -64,6 +64,20 @@ static inline bool check_clock_int(void) return *code == 0x1004; } +static void clear_pending_irqs(void) +{ + uint64_t time = 50 * TOD_CLOCK_SECOND / 0x3e8; + + sclp_clear_write_mask(); + + set_clock_comparator(get_clock() + time); + enable_clock_int(); + consume_sclp_int(); + disable_clock_int(); + + sclp_setup(); /* re-enable write mask */ +} + static int read_prompt(char *buf, size_t len) { char inp[2] = {}; @@ -165,6 +179,8 @@ static int get_boot_index(int entries) sclp_print("\nBooting entry #"); sclp_print(itostr(boot_index, tmp, sizeof(tmp))); + clear_pending_irqs(); + return boot_index; } diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c index 5902d5b..025eb2d 100644 --- a/pc-bios/s390-ccw/sclp.c +++ b/pc-bios/s390-ccw/sclp.c @@ -46,6 +46,18 @@ static int sclp_service_call(unsigned int command, void *sccb) return 0; } +void sclp_clear_write_mask(void) +{ + WriteEventMask *sccb = (void *)_sccb; + + sccb->h.length = sizeof(WriteEventMask); + sccb->mask_length = sizeof(unsigned int); + sccb->cp_receive_mask = 0; + sccb->cp_send_mask = 0; + + sclp_service_call(SCLP_CMD_WRITE_EVENT_MASK, sccb); +} + static void sclp_set_write_mask(void) { WriteEventMask *sccb = (void *)_sccb;