From nobody Thu Apr 25 06:03:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1575037562; cv=none; d=zohomail.com; s=zohoarc; b=ZHwS0yYsCif0XiPQmc2G/v3uX9sq/OoN7Rf2AW1ANaHp2hTPu05hsyv4ka0M71u4A0dQ+d9m4QwSwb4vdrAezVjCZu/NjH0mGP+ILnZYGiWZln2eLKIyTH9wHUMMXvaErs1YozwykVPNOvXkgXcZDiEKE/v8JxtzCm80krh4JiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575037562; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w9T/rdFvgRNlya7N27ThXL1Y6YzfTTWNgev59NMJxNw=; b=Q6z0eTFGo8m7MCGIUJ0p7PGqSt69Gu9+qPI1MG8jrXX5qRchUkOICLURMJKLkPCiz3LpEEkzMK7kO05omcHhC7wGDHngwKMtbfYcrJLzhQRgG/m8aPVuKt6msYlMJmDpO/trTpnuB+3d9zvqt0lFIRbeAvPz6LAawPb7724vxl8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15750375625921009.0953558258749; Fri, 29 Nov 2019 06:26:02 -0800 (PST) Received: from localhost ([::1]:59640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iahDb-0000dU-UV for importer@patchew.org; Fri, 29 Nov 2019 09:25:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41897) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iah8j-0006d8-Tv for qemu-devel@nongnu.org; Fri, 29 Nov 2019 09:21:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iah8g-00076I-QN for qemu-devel@nongnu.org; Fri, 29 Nov 2019 09:20:56 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:23306 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 1iah8g-0006zg-J2 for qemu-devel@nongnu.org; Fri, 29 Nov 2019 09:20:54 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xATEI4hD126626 for ; Fri, 29 Nov 2019 09:20:52 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wjxaydy6v-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Nov 2019 09:20:52 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 29 Nov 2019 14:20:51 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 29 Nov 2019 14:20:47 -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 xATEKj4b66322668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Nov 2019 14:20:45 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0A9BA4040; Fri, 29 Nov 2019 14:20:45 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F1BD6A4057; Fri, 29 Nov 2019 14:20:43 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.188.128]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 29 Nov 2019 14:20:43 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 1/3] s390x: Properly fetch and test the short psw on diag308 subc 0/1 Date: Fri, 29 Nov 2019 09:20:23 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191129142025.21453-1-frankja@linux.ibm.com> References: <20191129142025.21453-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112914-0008-0000-0000-00000339F00A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112914-0009-0000-0000-00004A590058 Message-Id: <20191129142025.21453-2-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-29_04:2019-11-29,2019-11-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 phishscore=0 adultscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 suspectscore=1 impostorscore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911290124 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, david@redhat.com, cohuck@redhat.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, mihajlov@linux.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We need to actually fetch the cpu mask and set it. As we invert the short psw indication in the mask, SIE will report a specification exception, if it wasn't present in the reset psw. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand --- target/s390x/cpu.c | 12 ++++++++++-- target/s390x/cpu.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index bd39cb54b7..829ce6ad54 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -76,8 +76,16 @@ static bool s390_cpu_has_work(CPUState *cs) static void s390_cpu_load_normal(CPUState *s) { S390CPU *cpu =3D S390_CPU(s); - cpu->env.psw.addr =3D ldl_phys(s->as, 4) & PSW_MASK_ESA_ADDR; - cpu->env.psw.mask =3D PSW_MASK_32 | PSW_MASK_64; + uint64_t spsw =3D ldq_phys(s->as, 0); + + cpu->env.psw.mask =3D spsw & 0xffffffff80000000ULL; + /* + * Invert short psw indication, so SIE will report a specification + * exception if it was not set. + */ + cpu->env.psw.mask ^=3D PSW_MASK_SHORTPSW; + cpu->env.psw.addr =3D spsw & 0x7fffffffULL; + s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); } #endif diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index d2af13b345..d5e18b096e 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -265,6 +265,7 @@ extern const VMStateDescription vmstate_s390_cpu; #define PSW_MASK_EXT 0x0100000000000000ULL #define PSW_MASK_KEY 0x00F0000000000000ULL #define PSW_SHIFT_KEY 52 +#define PSW_MASK_SHORTPSW 0x0008000000000000ULL #define PSW_MASK_MCHECK 0x0004000000000000ULL #define PSW_MASK_WAIT 0x0002000000000000ULL #define PSW_MASK_PSTATE 0x0001000000000000ULL --=20 2.20.1 From nobody Thu Apr 25 06:03:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1575039762; cv=none; d=zohomail.com; s=zohoarc; b=Vp3U0xKUZEyBHWvD8LH+pg7sEfVVaC6e2pV1KORpsQgLHQrDmutQJsdErlg5xK2WGDdRMSQYlEk+4D9GCqf91hsGwrgvAhM+tsecmM6CMoOOCNGrrEahhmDuiYXcy1k7rRD5sG9HZHHrVHwPexTpLlC64qnmHXRAfDoALumdvZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575039762; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+STFtHBj8i7OkhFPpu9Jx5oCVfcOMfj/MGUqet9jH+I=; b=NHoDbOawP20IUQ3iEdXYgwulGZuxT/WkH2imhEFRQrrs1o37Z8OICp/5xoKMEwtgUXxpvfOdtxEG4hyOirgVY4g3HeLGXRf0qQK/BHEtAdFOqQLxHVsf8PrBPZe9sQ0O6WE0R8zU80Ab/nwZ+2hqHWicNnosonh20p8EUNLPiWw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157503976279093.01133816619938; Fri, 29 Nov 2019 07:02:42 -0800 (PST) Received: from localhost ([::1]:60014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iahn5-0005E4-Ni for importer@patchew.org; Fri, 29 Nov 2019 10:02:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41910) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iah8m-0006dU-4Y for qemu-devel@nongnu.org; Fri, 29 Nov 2019 09:21:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iah8i-0007BT-24 for qemu-devel@nongnu.org; Fri, 29 Nov 2019 09:20:57 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33242 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 1iah8h-00075F-TT for qemu-devel@nongnu.org; Fri, 29 Nov 2019 09:20:55 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xATEIf02023785 for ; Fri, 29 Nov 2019 09:20:54 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wjtq03mng-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Nov 2019 09:20:54 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 29 Nov 2019 14:20:52 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 29 Nov 2019 14:20:49 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xATEKliF47055020 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Nov 2019 14:20:47 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 968FCA4040; Fri, 29 Nov 2019 14:20:47 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F98FA4053; Fri, 29 Nov 2019 14:20:46 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.188.128]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 29 Nov 2019 14:20:45 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 2/3] Sync reset Date: Fri, 29 Nov 2019 09:20:24 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191129142025.21453-1-frankja@linux.ibm.com> References: <20191129142025.21453-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112914-0012-0000-0000-0000036DF1F9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112914-0013-0000-0000-000021A9A347 Message-Id: <20191129142025.21453-3-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-29_04:2019-11-29,2019-11-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 priorityscore=1501 suspectscore=1 adultscore=0 mlxscore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911290124 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, david@redhat.com, cohuck@redhat.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, mihajlov@linux.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Janosch Frank --- linux-headers/linux/kvm.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 3d9b18f7f8..3dd7c407e0 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1000,6 +1000,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_PMU_EVENT_FILTER 173 #define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174 #define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175 +#define KVM_CAP_S390_VCPU_RESETS 180 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 @@ -1461,6 +1462,12 @@ struct kvm_enc_region { /* Available with KVM_CAP_ARM_SVE */ #define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int) =20 +#define KVM_S390_VCPU_RESET_NORMAL 0 +#define KVM_S390_VCPU_RESET_INITIAL 1 +#define KVM_S390_VCPU_RESET_CLEAR 2 + +#define KVM_S390_VCPU_RESET _IO(KVMIO, 0xc3) + /* Secure Encrypted Virtualization command */ enum sev_cmd_id { /* Guest initialization commands */ --=20 2.20.1 From nobody Thu Apr 25 06:03:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1575038445; cv=none; d=zohomail.com; s=zohoarc; b=B/k54a6953JA8dB74sxvESQ0Z/bPh/7i4/k8hJ692kDj6EfygOfTkDyGqaTuBcALcxPEmmKQLsCZETgUfd2LChvNacNsYUU0xRxrfSVBMzWNbzKUMSbZsNSrkv58d/jGa7Dx4o+EX8Qy04RV4UVKLrvXntWvfRRbPqD2cNvgGrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575038445; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aEfLZxeD9OuPSEbU3k4lN8+QU3JvQoKJybInZY6uRyQ=; b=LkpmOx9H0kBdIggD6G/czjB+5Wdji564Q5G/jdSh6Szt7VVdda8I7oc6Bgk7TX1nYbKz0d9vKAOZVKPs69ZkAUCxgzL7IOB5Ipyxi8dnK0U4b1o6s6rmZ5lDf+R8B6fgoVmmzZBjQB8Da503tXUTQC6aJBN2/PED5lU6w43lC+c= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1575038445859878.480846949413; Fri, 29 Nov 2019 06:40:45 -0800 (PST) Received: from localhost ([::1]:59792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iahRp-0004iD-Na for importer@patchew.org; Fri, 29 Nov 2019 09:40:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42127) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iah8p-0006ge-Qy for qemu-devel@nongnu.org; Fri, 29 Nov 2019 09:21:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iah8m-0007Sz-FQ for qemu-devel@nongnu.org; Fri, 29 Nov 2019 09:21:02 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40924 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 1iah8m-0007Eu-8t for qemu-devel@nongnu.org; Fri, 29 Nov 2019 09:21:00 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xATEI28K126447 for ; Fri, 29 Nov 2019 09:20:56 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wjxaydy9m-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Nov 2019 09:20:56 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 29 Nov 2019 14:20:55 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 29 Nov 2019 14:20:51 -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 xATEKAiY46661930 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Nov 2019 14:20:10 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89DABA4051; Fri, 29 Nov 2019 14:20:49 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 02795A4053; Fri, 29 Nov 2019 14:20:48 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.188.128]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 29 Nov 2019 14:20:47 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 3/3] s390x: protvirt: Add new VCPU reset functions Date: Fri, 29 Nov 2019 09:20:25 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191129142025.21453-1-frankja@linux.ibm.com> References: <20191129142025.21453-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112914-0008-0000-0000-00000339F00C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112914-0009-0000-0000-00004A59005A Message-Id: <20191129142025.21453-4-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-29_04:2019-11-29,2019-11-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 phishscore=0 adultscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 suspectscore=1 impostorscore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911290124 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, david@redhat.com, cohuck@redhat.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, mihajlov@linux.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" CPU resets for protected guests need to be done via Ultravisor calls. Hence we need a way to issue these calls for each reset. As we formerly had only one reset function and it was called for initial, as well as for the clear reset, we now need a new interface. Signed-off-by: Janosch Frank --- target/s390x/cpu.c | 14 ++++++++++++-- target/s390x/kvm-stub.c | 10 +++++++++- target/s390x/kvm.c | 38 ++++++++++++++++++++++++++++++++------ target/s390x/kvm_s390x.h | 4 +++- 4 files changed, 56 insertions(+), 10 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 829ce6ad54..906285888e 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -139,8 +139,18 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type= type) } =20 /* Reset state inside the kernel that we cannot access yet from QEMU. = */ - if (kvm_enabled() && type !=3D S390_CPU_RESET_NORMAL) { - kvm_s390_reset_vcpu(cpu); + if (kvm_enabled()) { + switch (type) { + case S390_CPU_RESET_CLEAR: + kvm_s390_reset_vcpu_clear(cpu); + break; + case S390_CPU_RESET_INITIAL: + kvm_s390_reset_vcpu_initial(cpu); + break; + case S390_CPU_RESET_NORMAL: + kvm_s390_reset_vcpu_normal(cpu); + break; + } } } =20 diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c index 5152e2bdf1..c4cd497f85 100644 --- a/target/s390x/kvm-stub.c +++ b/target/s390x/kvm-stub.c @@ -83,7 +83,15 @@ void kvm_s390_cmma_reset(void) { } =20 -void kvm_s390_reset_vcpu(S390CPU *cpu) +void kvm_s390_reset_vcpu_initial(S390CPU *cpu) +{ +} + +void kvm_s390_reset_vcpu_clear(S390CPU *cpu) +{ +} + +void kvm_s390_reset_vcpu_normal(S390CPU *cpu) { } =20 diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index ad6e38c876..502fc71664 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -151,6 +151,7 @@ static int cap_s390_irq; static int cap_ri; static int cap_gs; static int cap_hpage_1m; +static int cap_vcpu_resets; =20 static int active_cmma; =20 @@ -342,6 +343,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_async_pf =3D kvm_check_extension(s, KVM_CAP_ASYNC_PF); cap_mem_op =3D kvm_check_extension(s, KVM_CAP_S390_MEM_OP); cap_s390_irq =3D kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ); + cap_vcpu_resets =3D kvm_check_extension(s, KVM_CAP_S390_VCPU_RESETS); =20 if (!kvm_check_extension(s, KVM_CAP_S390_GMAP) || !kvm_check_extension(s, KVM_CAP_S390_COW)) { @@ -403,20 +405,44 @@ int kvm_arch_destroy_vcpu(CPUState *cs) return 0; } =20 -void kvm_s390_reset_vcpu(S390CPU *cpu) +static void kvm_s390_reset_vcpu(S390CPU *cpu, unsigned long type) { CPUState *cs =3D CPU(cpu); =20 - /* The initial reset call is needed here to reset in-kernel - * vcpu data that we can't access directly from QEMU - * (i.e. with older kernels which don't support sync_regs/ONE_REG). - * Before this ioctl cpu_synchronize_state() is called in common kvm - * code (kvm-all) */ + /* + * The reset call is needed here to reset in-kernel vcpu data that + * we can't access directly from QEMU (i.e. with older kernels + * which don't support sync_regs/ONE_REG). Before this ioctl + * cpu_synchronize_state() is called in common kvm code + * (kvm-all). + */ + if (cap_vcpu_resets) { + if (kvm_vcpu_ioctl(cs, KVM_S390_VCPU_RESET, type)) { + error_report("CPU reset type %ld failed on CPU %i", + type, cs->cpu_index); + } + return; + } if (kvm_vcpu_ioctl(cs, KVM_S390_INITIAL_RESET, NULL)) { error_report("Initial CPU reset failed on CPU %i", cs->cpu_index); } } =20 +void kvm_s390_reset_vcpu_initial(S390CPU *cpu) +{ + kvm_s390_reset_vcpu(cpu, KVM_S390_VCPU_RESET_INITIAL); +} + +void kvm_s390_reset_vcpu_clear(S390CPU *cpu) +{ + kvm_s390_reset_vcpu(cpu, KVM_S390_VCPU_RESET_CLEAR); +} + +void kvm_s390_reset_vcpu_normal(S390CPU *cpu) +{ + kvm_s390_reset_vcpu(cpu, KVM_S390_VCPU_RESET_NORMAL); +} + static int can_sync_regs(CPUState *cs, int regs) { return cap_sync_regs && (cs->kvm_run->kvm_valid_regs & regs) =3D=3D re= gs; diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h index caf985955b..0b21789796 100644 --- a/target/s390x/kvm_s390x.h +++ b/target/s390x/kvm_s390x.h @@ -34,7 +34,9 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifi= er, uint32_t sch, int vq, bool assign); int kvm_s390_cmma_active(void); void kvm_s390_cmma_reset(void); -void kvm_s390_reset_vcpu(S390CPU *cpu); +void kvm_s390_reset_vcpu_clear(S390CPU *cpu); +void kvm_s390_reset_vcpu_normal(S390CPU *cpu); +void kvm_s390_reset_vcpu_initial(S390CPU *cpu); int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_t *hw_limit); void kvm_s390_set_max_pagesize(uint64_t pagesize, Error **errp); void kvm_s390_crypto_reset(void); --=20 2.20.1