From patchwork Fri Oct 8 20:31:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Farman X-Patchwork-Id: 12546387 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1786DC4167B for ; Fri, 8 Oct 2021 20:31:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F317661152 for ; Fri, 8 Oct 2021 20:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242304AbhJHUdb (ORCPT ); Fri, 8 Oct 2021 16:33:31 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:31660 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231727AbhJHUd1 (ORCPT ); Fri, 8 Oct 2021 16:33:27 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 198KRLKm005256; Fri, 8 Oct 2021 16:31:31 -0400 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=uHpyvHqjwJ8IYZVsiMIsYPtYhbbZRSqkxRJzIWRN7vU=; b=NWAB1ghH9vf5tsfGqnH+PdokC1FDc/kVbD2BD4RSdxQhbzySQnNAO+kzVCMtJvPq590R RqWH9tO3Wyu6rFW6dcs3y0DiRrv6ruN+OrjZ6LKuUzqKZDQokqXlz7zGhb1e/cK+zwOy Pjt6X+3PiAJRtDYEwrPkEF6K3wGA4/v33XUabwpYTAjuzEtTTlkNg4tjtcHf/5chwPen xoNjtVscAr5bt3qqAcH6yHHy81lapa1MK858JFpR1zqvEPR3oWAVBW8zSoQDS2F9zJAB pveGgi1oh1t8TCxWfZEEGG+Zl1/x3fYkhvSlOg1UVeV8KXuLv6g89XyzVJQExZ/xjPyQ lw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bjvcagwec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:31 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 198KRI8r005205; Fri, 8 Oct 2021 16:31:31 -0400 Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bjvcagwdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:30 -0400 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 198KMqCf004726; Fri, 8 Oct 2021 20:31:28 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06fra.de.ibm.com with ESMTP id 3beepkhfbw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 20:31:28 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 198KVO2Q60228044 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Oct 2021 20:31:24 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A85F752065; Fri, 8 Oct 2021 20:31:24 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 9C0DE5205A; Fri, 8 Oct 2021 20:31:24 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 3A08DE032A; Fri, 8 Oct 2021 22:31:24 +0200 (CEST) From: Eric Farman To: Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Jason Herne Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, Eric Farman Subject: [RFC PATCH v1 1/6] KVM: s390: Simplify SIGP Set Arch handling Date: Fri, 8 Oct 2021 22:31:07 +0200 Message-Id: <20211008203112.1979843-2-farman@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008203112.1979843-1-farman@linux.ibm.com> References: <20211008203112.1979843-1-farman@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: pYCpqghDSiebbWvHwvSlz1HiJFrX53wf X-Proofpoint-GUID: KfGNC0xgXfGoH2QjCzMICnGE90cVJD-e X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-08_06,2021-10-07_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 priorityscore=1501 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 phishscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110080112 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The Principles of Operations describe the various reasons that each individual SIGP orders might be rejected, and the status bit that are set for each condition. For example, for the Set Architecture order, it states: "If it is not true that all other CPUs in the configu- ration are in the stopped or check-stop state, ... bit 54 (incorrect state) ... is set to one." However, it also states: "... if the CZAM facility is installed, ... bit 55 (invalid parameter) ... is set to one." Since the Configuration-z/Architecture-Architectural Mode (CZAM) facility is unconditionally presented, there is no need to examine each VCPU to determine if it is started/stopped. It can simply be rejected outright with the Invalid Parameter bit. Fixes: b697e435aeee ("KVM: s390: Support Configuration z/Architecture Mode") Signed-off-by: Eric Farman Reviewed-by: Thomas Huth Reviewed-by: Christian Borntraeger Reviewed-by: David Hildenbrand Reviewed-by: Claudio Imbrenda --- arch/s390/kvm/sigp.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c index 683036c1c92a..cf4de80bd541 100644 --- a/arch/s390/kvm/sigp.c +++ b/arch/s390/kvm/sigp.c @@ -151,22 +151,10 @@ static int __sigp_stop_and_store_status(struct kvm_vcpu *vcpu, static int __sigp_set_arch(struct kvm_vcpu *vcpu, u32 parameter, u64 *status_reg) { - unsigned int i; - struct kvm_vcpu *v; - bool all_stopped = true; - - kvm_for_each_vcpu(i, v, vcpu->kvm) { - if (v == vcpu) - continue; - if (!is_vcpu_stopped(v)) - all_stopped = false; - } - *status_reg &= 0xffffffff00000000UL; /* Reject set arch order, with czam we're always in z/Arch mode. */ - *status_reg |= (all_stopped ? SIGP_STATUS_INVALID_PARAMETER : - SIGP_STATUS_INCORRECT_STATE); + *status_reg |= SIGP_STATUS_INVALID_PARAMETER; return SIGP_CC_STATUS_STORED; } From patchwork Fri Oct 8 20:31:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Farman X-Patchwork-Id: 12546383 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60A68C4332F for ; Fri, 8 Oct 2021 20:31:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AFF061100 for ; Fri, 8 Oct 2021 20:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242366AbhJHUd3 (ORCPT ); Fri, 8 Oct 2021 16:33:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:8898 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230303AbhJHUd1 (ORCPT ); Fri, 8 Oct 2021 16:33:27 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 198KRTTQ020044; Fri, 8 Oct 2021 16:31:30 -0400 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=KGFP6+v7naDoDb1g0cPnnmWUW3Km1AW6dvdrAVHe56c=; b=P0zbgNsTutFIcCtfUOw6xDS5o5PdwvF7m2/RyrOF0AC0BL++MK4q3RZUUj/LdvImagyw Cw4pa56H7UoCY1J2C2w1aIOdSr7G/uw/Pe2gwObZUK9n39As0kUCvO4y40fV6B2UNMwi LJT8WGAWuGCuGZD8Wm83yu6JrKe9jJkWZsynL3l0OMp/Ivre+6zoQPwOWQ8ZmA5kn765 MWjpMJxzY64HuAKDhxc1OgRzWkF9yHKedXrGt+/LqhMEcaA45r13yjainFP2+DXzxXFL Z+FZoLlBkYF9Irzv7IhcLx8V1h4eBrntgkNDzZcgud7XAa++UxZmC2cjpkkbp5yI0b56 ZQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bjueat6xc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:30 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 198KTxS2000869; Fri, 8 Oct 2021 16:31:30 -0400 Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bjueat6wb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:30 -0400 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 198KMASa004204; Fri, 8 Oct 2021 20:31:28 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma01fra.de.ibm.com with ESMTP id 3bef2as9kk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 20:31:28 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 198KVOHS43975080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Oct 2021 20:31:25 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CF8DDA4065; Fri, 8 Oct 2021 20:31:24 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6FB6A404D; Fri, 8 Oct 2021 20:31:24 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 8 Oct 2021 20:31:24 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 3CA8CE0352; Fri, 8 Oct 2021 22:31:24 +0200 (CEST) From: Eric Farman To: Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Jason Herne Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, Eric Farman Subject: [RFC PATCH v1 2/6] KVM: s390: Reject SIGP when destination CPU is busy Date: Fri, 8 Oct 2021 22:31:08 +0200 Message-Id: <20211008203112.1979843-3-farman@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008203112.1979843-1-farman@linux.ibm.com> References: <20211008203112.1979843-1-farman@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: T7fXkddOm6M0QCrRWUeGnxRd9FGb8eI6 X-Proofpoint-ORIG-GUID: -L31TlYNSmr5BqvQt62PYkLqyEakRXld X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-08_06,2021-10-07_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 impostorscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110080112 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org With KVM_CAP_USER_SIGP enabled, most orders are handled by userspace. However, some orders (such as STOP or STOP AND STORE STATUS) end up injecting work back into the kernel. Userspace itself should (and QEMU does) look for this conflict, and reject additional (non-reset) orders until this work completes. But there's no need to delay that. If the kernel knows about the STOP IRQ that is in process, the newly-requested SIGP order can be rejected with a BUSY condition right up front. Signed-off-by: Eric Farman Reviewed-by: Christian Borntraeger --- arch/s390/kvm/sigp.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c index cf4de80bd541..6ca01bbc72cf 100644 --- a/arch/s390/kvm/sigp.c +++ b/arch/s390/kvm/sigp.c @@ -394,6 +394,45 @@ static int handle_sigp_order_in_user_space(struct kvm_vcpu *vcpu, u8 order_code, return 1; } +static int handle_sigp_order_is_blocked(struct kvm_vcpu *vcpu, u8 order_code, + u16 cpu_addr) +{ + struct kvm_vcpu *dst_vcpu = kvm_get_vcpu_by_id(vcpu->kvm, cpu_addr); + int rc = 0; + + /* + * SIGP orders directed at invalid vcpus are not blocking, + * and should not return busy here. The code that handles + * the actual SIGP order will generate the "not operational" + * response for such a vcpu. + */ + if (!dst_vcpu) + return 0; + + /* + * SIGP orders that process a flavor of reset would not be + * blocked through another SIGP on the destination CPU. + */ + if (order_code == SIGP_CPU_RESET || + order_code == SIGP_INITIAL_CPU_RESET) + return 0; + + /* + * Any other SIGP order could race with an existing SIGP order + * on the destination CPU, and thus encounter a busy condition + * on the CPU processing the SIGP order. Reject the order at + * this point, rather than racing with the STOP IRQ injection. + */ + spin_lock(&dst_vcpu->arch.local_int.lock); + if (kvm_s390_is_stop_irq_pending(dst_vcpu)) { + kvm_s390_set_psw_cc(vcpu, SIGP_CC_BUSY); + rc = 1; + } + spin_unlock(&dst_vcpu->arch.local_int.lock); + + return rc; +} + int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu) { int r1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; @@ -408,6 +447,10 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu) return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); order_code = kvm_s390_get_base_disp_rs(vcpu, NULL); + + if (handle_sigp_order_is_blocked(vcpu, order_code, cpu_addr)) + return 0; + if (handle_sigp_order_in_user_space(vcpu, order_code, cpu_addr)) return -EOPNOTSUPP; From patchwork Fri Oct 8 20:31:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Farman X-Patchwork-Id: 12546385 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B827C433EF for ; Fri, 8 Oct 2021 20:31:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26DBA60BD3 for ; Fri, 8 Oct 2021 20:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242193AbhJHUda (ORCPT ); Fri, 8 Oct 2021 16:33:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:31192 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231643AbhJHUd1 (ORCPT ); Fri, 8 Oct 2021 16:33:27 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 198KRNc8029611; Fri, 8 Oct 2021 16:31:31 -0400 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=D0Ng5W6WETR3elvHra4RklqaF/XAofJOUiyq8K6cqeI=; b=nT5jIvyWIsj4kG7GNVq7ocZHZhOb8siCQXcAZlgb5/k5DTtmKfiMphuSEuUcKK9sRl4w sTN28AYi/SiRfmtA9P9F05IBdfRZFs9+1yV3rzWByDHYBtzTpqzwZwOGX6PmfvvdP/3q dIWR00HPUVYdsogTTXQNVA9ZESsImiknvcvJTuQQGikJa8wvElVAMX/DxLECSdWnsuKO 7B1Kw68pbk0gDp4oKDxlUzbn2N3q29NKM3m+bWBufkQLXEUVX/y9TK6+/Ww7VVbQWL9z Gb0QJAe9v0czQiolodAwfXOsUTKJBiLT4kz384X9PF8av9ZA5+h3MvLgw1U3ECaN53Hp pA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bjtwh2wka-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:30 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 198KRRa7030257; Fri, 8 Oct 2021 16:31:30 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bjtwh2wjt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:30 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 198KMMsA020988; Fri, 8 Oct 2021 20:31:28 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 3bhepdebkd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 20:31:28 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 198KVO2X19726806 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Oct 2021 20:31:25 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CF6FFA405F; Fri, 8 Oct 2021 20:31:24 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7A6DA4059; Fri, 8 Oct 2021 20:31:24 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 8 Oct 2021 20:31:24 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 3EF47E035B; Fri, 8 Oct 2021 22:31:24 +0200 (CEST) From: Eric Farman To: Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Jason Herne Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, Eric Farman Subject: [RFC PATCH v1 3/6] KVM: s390: Simplify SIGP Restart Date: Fri, 8 Oct 2021 22:31:09 +0200 Message-Id: <20211008203112.1979843-4-farman@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008203112.1979843-1-farman@linux.ibm.com> References: <20211008203112.1979843-1-farman@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: BI4OmBB6EC-KkGvf3mHlT_hL7i-XUzSc X-Proofpoint-ORIG-GUID: NcpPmHkKEqDn3eJuQHBWPKi_lGaOWZmH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-08_06,2021-10-07_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 phishscore=0 suspectscore=0 clxscore=1011 impostorscore=0 spamscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 mlxlogscore=898 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110080112 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Now that we check for the STOP IRQ injection at the top of the SIGP handler (before the userspace/kernelspace check), we don't need to do it down here for the Restart order. Signed-off-by: Eric Farman --- arch/s390/kvm/sigp.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c index 6ca01bbc72cf..0c08927ca7c9 100644 --- a/arch/s390/kvm/sigp.c +++ b/arch/s390/kvm/sigp.c @@ -240,17 +240,8 @@ static int __sigp_sense_running(struct kvm_vcpu *vcpu, static int __prepare_sigp_re_start(struct kvm_vcpu *vcpu, struct kvm_vcpu *dst_vcpu, u8 order_code) { - struct kvm_s390_local_interrupt *li = &dst_vcpu->arch.local_int; /* handle (RE)START in user space */ - int rc = -EOPNOTSUPP; - - /* make sure we don't race with STOP irq injection */ - spin_lock(&li->lock); - if (kvm_s390_is_stop_irq_pending(dst_vcpu)) - rc = SIGP_CC_BUSY; - spin_unlock(&li->lock); - - return rc; + return -EOPNOTSUPP; } static int __prepare_sigp_cpu_reset(struct kvm_vcpu *vcpu, From patchwork Fri Oct 8 20:31:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Farman X-Patchwork-Id: 12546393 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47749C4332F for ; Fri, 8 Oct 2021 20:31:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32E4261100 for ; Fri, 8 Oct 2021 20:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242698AbhJHUdd (ORCPT ); Fri, 8 Oct 2021 16:33:33 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36140 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232005AbhJHUd1 (ORCPT ); Fri, 8 Oct 2021 16:33:27 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 198KRNJJ028884; Fri, 8 Oct 2021 16:31:32 -0400 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=q7Hc0tUEef6F8wb96Wz846QVmW+nQ2Hmp579MBFksJA=; b=mGp48cStrdeswOozNBI1UUkiasaN3xGs+PWf4k/o6zoxCMTSnmpyO/YX3m9R1I8CqC76 27H3jtqoC7wz0s58QkHrhDs8Rq4FfQILOcAjLjOl1d1yRef8XNwxc0iVxCpO3byaC+Ga ARjAvCb03cMW6v+SpJsZ+2+0aXRh3vddUF9zY6HK0FRCdny+lfi57fbEBgdnU6jEOTk4 lVI1UkqgHzipgArV3Ug5O2wi6UW3ZLl582v3xCgCTxGnuFDmZM0uVAuw0IL0cUU5tm3W 3PmF7bzdsm20A/VSEFUlymVjl5cZR3yK0jff9twWZOrpUQooHdT+wWimZgrLJKpUCxvd WQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bjtm3k970-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:31 -0400 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 198KRfID030210; Fri, 8 Oct 2021 16:31:30 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bjtm3k96b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:30 -0400 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 198KMW2B014258; Fri, 8 Oct 2021 20:31:28 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3bef2b5j12-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 20:31:28 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 198KVO0c53477742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Oct 2021 20:31:24 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7B6C52051; Fri, 8 Oct 2021 20:31:24 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 9C27E5205F; Fri, 8 Oct 2021 20:31:24 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 41647E0394; Fri, 8 Oct 2021 22:31:24 +0200 (CEST) From: Eric Farman To: Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Jason Herne Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, Eric Farman Subject: [RFC PATCH v1 4/6] KVM: s390: Restart IRQ should also block SIGP Date: Fri, 8 Oct 2021 22:31:10 +0200 Message-Id: <20211008203112.1979843-5-farman@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008203112.1979843-1-farman@linux.ibm.com> References: <20211008203112.1979843-1-farman@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: fBFOXhhgqk8VlMg__9gfjvLWrvgiTQ0J X-Proofpoint-GUID: bnc22Vxx4brb2tRMyaLe9WRbmfBQml6p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-08_06,2021-10-07_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 mlxscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110080112 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When userspace handles a SIGP Restart, it first looks at the destination CPU state to determine its next course of action: if (cpu is online) inject restart IRQ else set cpu online load restart PSW Since we already have logic for dealing with an in-flight STOP IRQ when a new SIGP comes in, let's include the RESTART IRQ in the same logic, so we don't race with that work. Signed-off-by: Eric Farman --- arch/s390/kvm/interrupt.c | 7 +++++++ arch/s390/kvm/kvm-s390.h | 1 + arch/s390/kvm/sigp.c | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index 10722455fd02..77c5d73ff0e2 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c @@ -2108,6 +2108,13 @@ int s390int_to_s390irq(struct kvm_s390_interrupt *s390int, return 0; } +int kvm_s390_is_restart_irq_pending(struct kvm_vcpu *vcpu) +{ + struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; + + return test_bit(IRQ_PEND_RESTART, &li->pending_irqs); +} + int kvm_s390_is_stop_irq_pending(struct kvm_vcpu *vcpu) { struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index 52bc8fbaa60a..57c5e9369d65 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h @@ -417,6 +417,7 @@ int psw_extint_disabled(struct kvm_vcpu *vcpu); void kvm_s390_destroy_adapters(struct kvm *kvm); int kvm_s390_ext_call_pending(struct kvm_vcpu *vcpu); extern struct kvm_device_ops kvm_flic_ops; +int kvm_s390_is_restart_irq_pending(struct kvm_vcpu *vcpu); int kvm_s390_is_stop_irq_pending(struct kvm_vcpu *vcpu); void kvm_s390_clear_stop_irq(struct kvm_vcpu *vcpu); int kvm_s390_set_irq_state(struct kvm_vcpu *vcpu, diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c index 0c08927ca7c9..c64e37f4347d 100644 --- a/arch/s390/kvm/sigp.c +++ b/arch/s390/kvm/sigp.c @@ -412,10 +412,11 @@ static int handle_sigp_order_is_blocked(struct kvm_vcpu *vcpu, u8 order_code, * Any other SIGP order could race with an existing SIGP order * on the destination CPU, and thus encounter a busy condition * on the CPU processing the SIGP order. Reject the order at - * this point, rather than racing with the STOP IRQ injection. + * this point, rather than racing with any IRQ injection. */ spin_lock(&dst_vcpu->arch.local_int.lock); - if (kvm_s390_is_stop_irq_pending(dst_vcpu)) { + if (kvm_s390_is_stop_irq_pending(dst_vcpu) || + kvm_s390_is_restart_irq_pending(dst_vcpu)) { kvm_s390_set_psw_cc(vcpu, SIGP_CC_BUSY); rc = 1; } From patchwork Fri Oct 8 20:31:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Farman X-Patchwork-Id: 12546395 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23351C433F5 for ; Fri, 8 Oct 2021 20:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C57861100 for ; Fri, 8 Oct 2021 20:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242741AbhJHUde (ORCPT ); Fri, 8 Oct 2021 16:33:34 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35016 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231997AbhJHUd1 (ORCPT ); Fri, 8 Oct 2021 16:33:27 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 198KRS93016081; Fri, 8 Oct 2021 16:31:31 -0400 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=n2+7wlHfRulREAtja+GTuv8/96rm57QhYif0ZXDg9fQ=; b=ayxSDbWYJr0kKYg3FALNzn3hl01+pC1ZRWP1iSGpVb/A4OAEtvOSNuqCzZ+V6diCvhuy ofQQit+GCZy6pL7UohQv1am6/XJ+RP5xPD3Q3gTei676xOit/0wfVmzV4xZjm11Ghn9K B5PzQFGr/sc6ffsIpNNOaF+whcvHsw+E+VwA1B1XQVtoDK19LAyQ+JMti3zh4dC25Gjf qyP51M2benfbhNPni6DvIMs8h+ZSFLsnvfTTD8iQMsyNgWFNg3hccgvcsYY9bSh2weMJ 73xDJyYzt9rPHCMMUFe0TwFpVAUQa253tBVPI7z2n7TIZxcgt8KDAbE5fVXFZiAmt5Xs pw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bjvnj8kdh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:31 -0400 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 198KSaIG022766; Fri, 8 Oct 2021 16:31:31 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bjvnj8kcq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:30 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 198KM6SP027430; Fri, 8 Oct 2021 20:31:28 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03fra.de.ibm.com with ESMTP id 3bef2ahbv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 20:31:28 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 198KQ0m255443786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Oct 2021 20:26:01 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3EF03A405E; Fri, 8 Oct 2021 20:31:25 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28A90A4069; Fri, 8 Oct 2021 20:31:25 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 8 Oct 2021 20:31:25 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 43AADE039C; Fri, 8 Oct 2021 22:31:24 +0200 (CEST) From: Eric Farman To: Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Jason Herne Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, Eric Farman Subject: [RFC PATCH v1 5/6] KVM: s390: Give BUSY to SIGP SENSE during Restart Date: Fri, 8 Oct 2021 22:31:11 +0200 Message-Id: <20211008203112.1979843-6-farman@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008203112.1979843-1-farman@linux.ibm.com> References: <20211008203112.1979843-1-farman@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7ShPxSm6rchvGz3mzSBlx_E1qSStGbep X-Proofpoint-ORIG-GUID: W3ZYuLc1CJ8WD5pN3MkgvooYwwjkDKQF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-08_06,2021-10-07_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 adultscore=0 priorityscore=1501 clxscore=1015 spamscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110080112 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org A SIGP RESTART is a special animal, in that it directs the destination CPU to perform the restart operation. This is basically the loading of the Restart PSW and letting it take over, but a stopped CPU must first be made operating for this to work correctly. As this can take a moment, let's leave a reminder that this SIGP is being processed, such that the SIGP SENSE logic (which is not handled in userspace) can return CC=2 instead of CC=1 (and STOPPED) until the CPU is started. Signed-off-by: Eric Farman --- arch/s390/include/asm/kvm_host.h | 1 + arch/s390/kvm/kvm-s390.c | 1 + arch/s390/kvm/sigp.c | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h index a604d51acfc8..536f174c5e81 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h @@ -746,6 +746,7 @@ struct kvm_vcpu_arch { __u64 cputm_start; bool gs_enabled; bool skey_enabled; + bool sigp_restart; struct kvm_s390_pv_vcpu pv; union diag318_info diag318_info; }; diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 6a6dd5e1daf6..33d71fa42d68 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -4603,6 +4603,7 @@ int kvm_s390_vcpu_start(struct kvm_vcpu *vcpu) } kvm_s390_clear_cpuflags(vcpu, CPUSTAT_STOPPED); + vcpu->arch.sigp_restart = 0; /* * The real PSW might have changed due to a RESTART interpreted by the * ultravisor. We block all interrupts and let the next sie exit diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c index c64e37f4347d..5a21354d0265 100644 --- a/arch/s390/kvm/sigp.c +++ b/arch/s390/kvm/sigp.c @@ -27,6 +27,8 @@ static int __sigp_sense(struct kvm_vcpu *vcpu, struct kvm_vcpu *dst_vcpu, ext_call_pending = kvm_s390_ext_call_pending(dst_vcpu); if (!stopped && !ext_call_pending) rc = SIGP_CC_ORDER_CODE_ACCEPTED; + else if (stopped && dst_vcpu->arch.sigp_restart) + rc = SIGP_CC_BUSY; else { *reg &= 0xffffffff00000000UL; if (ext_call_pending) @@ -385,6 +387,18 @@ static int handle_sigp_order_in_user_space(struct kvm_vcpu *vcpu, u8 order_code, return 1; } +static void handle_sigp_restart(struct kvm_vcpu *vcpu, u16 cpu_addr) +{ + struct kvm_vcpu *dst_vcpu = kvm_get_vcpu_by_id(vcpu->kvm, cpu_addr); + + /* Ignore SIGP Restart to non-existent CPUs */ + if (!dst_vcpu) + return; + + if (is_vcpu_stopped(dst_vcpu)) + dst_vcpu->arch.sigp_restart = 1; +} + static int handle_sigp_order_is_blocked(struct kvm_vcpu *vcpu, u8 order_code, u16 cpu_addr) { @@ -443,6 +457,9 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu) if (handle_sigp_order_is_blocked(vcpu, order_code, cpu_addr)) return 0; + if (order_code == SIGP_RESTART) + handle_sigp_restart(vcpu, cpu_addr); + if (handle_sigp_order_in_user_space(vcpu, order_code, cpu_addr)) return -EOPNOTSUPP; From patchwork Fri Oct 8 20:31:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Farman X-Patchwork-Id: 12546391 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73035C433F5 for ; Fri, 8 Oct 2021 20:31:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BA3661152 for ; Fri, 8 Oct 2021 20:31:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242602AbhJHUdd (ORCPT ); Fri, 8 Oct 2021 16:33:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34336 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231684AbhJHUd1 (ORCPT ); Fri, 8 Oct 2021 16:33:27 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 198KRTLT019995; Fri, 8 Oct 2021 16:31:31 -0400 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=UA6q3jUaNN7g2IM6Ia2YJ9iu6qE7Ksg5WFSf4U8H6eo=; b=gTnko5evMKG4WAL7PiensrABoec1sJ2YOcjytmgPB+28UPGig9wVGbdR1JXn/81NN3L+ +oa8EKxUQ9qhOQou4OJThPfzBgPNiC+kAAW4wWfZfLscE4k4NbCoZijiuu4uqVNKDnyn E0Cs76DxTwuAr2RxPNOebKb+eyd02YVZ5SIPPIg0kXytFtMIX+rqz0RB4PIApGSUstHm Yf1H3RHJQjArRzaH3+qdHbYuZuKDQBxo8IpL4WBrSZiGnYuwQtvbHzgLGieRF3WhjegL XFUIQvAgMm2bqKbEaRE0zrSYvMBPMnyM6i2r0PNJtTMCfjAybHnQhPVDbcnzvlMQbXFg 7g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bjueat6xn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:31 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 198KTxS4000869; Fri, 8 Oct 2021 16:31:31 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bjueat6wx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 16:31:30 -0400 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 198KMZRk014291; Fri, 8 Oct 2021 20:31:29 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3bef2b5j13-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Oct 2021 20:31:29 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 198KVPiJ28639504 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Oct 2021 20:31:25 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3559C4C052; Fri, 8 Oct 2021 20:31:25 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E4574C040; Fri, 8 Oct 2021 20:31:25 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 8 Oct 2021 20:31:25 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 466A6E03A2; Fri, 8 Oct 2021 22:31:24 +0200 (CEST) From: Eric Farman To: Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Jason Herne Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, Eric Farman Subject: [RFC PATCH v1 6/6] KVM: s390: Add a routine for setting userspace CPU state Date: Fri, 8 Oct 2021 22:31:12 +0200 Message-Id: <20211008203112.1979843-7-farman@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211008203112.1979843-1-farman@linux.ibm.com> References: <20211008203112.1979843-1-farman@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Uchr0fwuZmDTZDLpefSf0seXm2BBWvMA X-Proofpoint-ORIG-GUID: QHRRlztsJ1iFFasi_pL--QSZp1WwomxH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-08_06,2021-10-07_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 mlxlogscore=990 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 impostorscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110080112 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This capability exists, but we don't record anything when userspace enables it. Let's refactor that code so that a note can be made in the debug logs that it was enabled. Signed-off-by: Eric Farman Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand Reviewed-by: Claudio Imbrenda --- arch/s390/kvm/kvm-s390.c | 6 +++--- arch/s390/kvm/kvm-s390.h | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 33d71fa42d68..48ac0bd05bee 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2487,8 +2487,8 @@ long kvm_arch_vm_ioctl(struct file *filp, case KVM_S390_PV_COMMAND: { struct kvm_pv_cmd args; - /* protvirt means user sigp */ - kvm->arch.user_cpu_state_ctrl = 1; + /* protvirt means user cpu state */ + kvm_s390_set_user_cpu_state_ctrl(kvm); r = 0; if (!is_prot_virt_host()) { r = -EINVAL; @@ -3801,7 +3801,7 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, vcpu_load(vcpu); /* user space knows about this interface - let it control the state */ - vcpu->kvm->arch.user_cpu_state_ctrl = 1; + kvm_s390_set_user_cpu_state_ctrl(vcpu->kvm); switch (mp_state->mp_state) { case KVM_MP_STATE_STOPPED: diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index 57c5e9369d65..36f4d585513c 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h @@ -208,6 +208,15 @@ static inline int kvm_s390_user_cpu_state_ctrl(struct kvm *kvm) return kvm->arch.user_cpu_state_ctrl != 0; } +static inline void kvm_s390_set_user_cpu_state_ctrl(struct kvm *kvm) +{ + if (kvm->arch.user_cpu_state_ctrl) + return; + + VM_EVENT(kvm, 3, "%s", "ENABLE: Userspace CPU state control"); + kvm->arch.user_cpu_state_ctrl = 1; +} + /* implemented in pv.c */ int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc); int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc);