From nobody Sat Apr 20 05:26:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544135229314749.4505726622054; Thu, 6 Dec 2018 14:27:09 -0800 (PST) Received: from localhost ([::1]:43258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gV26p-0000Ds-86 for importer@patchew.org; Thu, 06 Dec 2018 17:27:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gV255-0007nM-Uv for qemu-devel@nongnu.org; Thu, 06 Dec 2018 17:25:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gV24x-00036W-R4 for qemu-devel@nongnu.org; Thu, 06 Dec 2018 17:25:14 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55566 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 1gV24x-00035t-DP for qemu-devel@nongnu.org; Thu, 06 Dec 2018 17:25:07 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wB6MIx5l039671 for ; Thu, 6 Dec 2018 17:25:07 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2p7bddbg70-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 06 Dec 2018 17:25:06 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Dec 2018 22:25:06 -0000 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 6 Dec 2018 22:25:02 -0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wB6MP1e618481290 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 6 Dec 2018 22:25:01 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EBE66E056; Thu, 6 Dec 2018 22:25:01 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 055606E04E; Thu, 6 Dec 2018 22:25:01 +0000 (GMT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.52]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 6 Dec 2018 22:25:00 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com, rth@twiddle.net, david@redhat.com, borntraeger@de.ibm.com, thuth@redhat.com Date: Thu, 6 Dec 2018 17:24:16 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544135058-21380-1-git-send-email-walling@linux.ibm.com> References: <1544135058-21380-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18120622-0036-0000-0000-00000A66C11D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010184; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000270; SDB=6.01127998; UDB=6.00585943; IPR=6.00908129; MB=3.00024517; MTD=3.00000008; XFM=3.00000015; UTC=2018-12-06 22:25:04 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18120622-0037-0000-0000-000049E2F107 Message-Id: <1544135058-21380-2-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-12-06_08:, , 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 mlxscore=0 impostorscore=0 mlxlogscore=991 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812060188 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 v2 1/3] s390: linux header sync for diagnose 318 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Introduce VM group, attribute, and CPU feat defines for diagnose 318. Signed-off-by: Collin Walling --- linux-headers/asm-s390/kvm.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h index 0265482..4b655e3 100644 --- a/linux-headers/asm-s390/kvm.h +++ b/linux-headers/asm-s390/kvm.h @@ -74,6 +74,7 @@ struct kvm_s390_io_adapter_req { #define KVM_S390_VM_CRYPTO 2 #define KVM_S390_VM_CPU_MODEL 3 #define KVM_S390_VM_MIGRATION 4 +#define KVM_S390_VM_MACHINE 5 =20 /* kvm attributes for mem_ctrl */ #define KVM_S390_VM_MEM_ENABLE_CMMA 0 @@ -130,6 +131,7 @@ struct kvm_s390_vm_cpu_machine { #define KVM_S390_VM_CPU_FEAT_PFMFI 11 #define KVM_S390_VM_CPU_FEAT_SIGPIF 12 #define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_DIAG318 14 struct kvm_s390_vm_cpu_feat { __u64 feat[16]; }; @@ -168,6 +170,9 @@ struct kvm_s390_vm_cpu_subfunc { #define KVM_S390_VM_MIGRATION_START 1 #define KVM_S390_VM_MIGRATION_STATUS 2 =20 +/* kvm attributes for KVM_S390_VM_MACHINE */ +#define KVM_S390_VM_MACHINE_CPC 0 + /* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs { /* general purpose regs for s390 */ --=20 2.7.4 From nobody Sat Apr 20 05:26:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544135321258773.1729304460691; Thu, 6 Dec 2018 14:28:41 -0800 (PST) Received: from localhost ([::1]:43269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gV28O-0002I8-1b for importer@patchew.org; Thu, 06 Dec 2018 17:28:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gV255-0007nJ-Uq for qemu-devel@nongnu.org; Thu, 06 Dec 2018 17:25:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gV24z-00039f-Ln for qemu-devel@nongnu.org; Thu, 06 Dec 2018 17:25:14 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44400 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 1gV24z-00038M-CW for qemu-devel@nongnu.org; Thu, 06 Dec 2018 17:25:09 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wB6MJ23v023043 for ; Thu, 6 Dec 2018 17:25:08 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2p7cf4088u-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 06 Dec 2018 17:25:08 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Dec 2018 22:25:08 -0000 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 6 Dec 2018 22:25:04 -0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wB6MP3tF23789684 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 6 Dec 2018 22:25:03 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FB9C6E058; Thu, 6 Dec 2018 22:25:03 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D06B76E050; Thu, 6 Dec 2018 22:25:02 +0000 (GMT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.52]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 6 Dec 2018 22:25:02 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com, rth@twiddle.net, david@redhat.com, borntraeger@de.ibm.com, thuth@redhat.com Date: Thu, 6 Dec 2018 17:24:17 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544135058-21380-1-git-send-email-walling@linux.ibm.com> References: <1544135058-21380-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18120622-0036-0000-0000-00000A66C121 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010184; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000270; SDB=6.01127998; UDB=6.00585943; IPR=6.00908129; MB=3.00024517; MTD=3.00000008; XFM=3.00000015; UTC=2018-12-06 22:25:06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18120622-0037-0000-0000-000049E2F110 Message-Id: <1544135058-21380-3-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-12-06_08:, , 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 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812060188 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 v2 2/3] s390: cpu feature for diagnose 318 andlimit max VCPUs to 247 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Diagnose 318 is a new z14.2 CPU feature. Since we are able to emulate it entirely via KVM, we can add guest support for earlier models. A new CPU feature for diagnose 318 (shortened to diag318) will be made available to guests starting with the zEC12-full CPU model. The z14.2 adds a new read SCP info byte (let's call it byte 134) to detect the availability of diag318. Because of this, we have room for one less VCPU and thus limit the max VPUs supported in a configuration to 247 (down from 248). Signed-off-by: Collin Walling . --- hw/s390x/sclp.c | 2 ++ include/hw/s390x/sclp.h | 2 ++ target/s390x/cpu.h | 2 +- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h | 3 +++ target/s390x/gen-features.c | 1 + target/s390x/kvm.c | 1 + 8 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 4510a80..183c627 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -73,6 +73,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->conf_char); s390_get_feat_block(S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, read_info->conf_char_ext); + /* Read Info byte 134 */ + s390_get_feat_block(S390_FEAT_TYPE_SCLP_BYTE_134, read_info->byte_134); =20 read_info->facilities =3D cpu_to_be64(SCLP_HAS_CPU_INFO | SCLP_HAS_IOA_RECONFIG); diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index f9db243..eb12ba2 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -133,6 +133,8 @@ typedef struct ReadInfo { uint16_t highest_cpu; uint8_t _reserved5[124 - 122]; /* 122-123 */ uint32_t hmfai; + uint8_t _reserved7[134 - 128]; /* 128-133 */ + uint8_t byte_134[1]; struct CPUEntry entries[0]; } QEMU_PACKED ReadInfo; =20 diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 8c2320e..594b4a4 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -52,7 +52,7 @@ =20 #define MMU_USER_IDX 0 =20 -#define S390_MAX_CPUS 248 +#define S390_MAX_CPUS 247 =20 typedef struct PSW { uint64_t mask; diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c index 60cfeba..d05afa5 100644 --- a/target/s390x/cpu_features.c +++ b/target/s390x/cpu_features.c @@ -121,6 +121,9 @@ static const S390FeatDef s390_features[] =3D { FEAT_INIT("pfmfi", S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, 9, "SIE: PFMF in= terpretation facility"), FEAT_INIT("ibs", S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, 10, "SIE: Interloc= k-and-broadcast-suppression facility"), =20 + /* SCLP SCCB Byte 134 */ + FEAT_INIT("diag318", S390_FEAT_TYPE_SCLP_BYTE_134, 0, "SIE: Diagnose 3= 18"), + FEAT_INIT("sief2", S390_FEAT_TYPE_SCLP_CPU, 4, "SIE: interception form= at 2 (Virtual SIE)"), FEAT_INIT("skey", S390_FEAT_TYPE_SCLP_CPU, 5, "SIE: Storage-key facili= ty"), FEAT_INIT("gpereh", S390_FEAT_TYPE_SCLP_CPU, 10, "SIE: Guest-PER enhan= cement facility"), diff --git a/target/s390x/cpu_features.h b/target/s390x/cpu_features.h index effe790..e7248df 100644 --- a/target/s390x/cpu_features.h +++ b/target/s390x/cpu_features.h @@ -23,6 +23,7 @@ typedef enum { S390_FEAT_TYPE_STFL, S390_FEAT_TYPE_SCLP_CONF_CHAR, S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, + S390_FEAT_TYPE_SCLP_BYTE_134, S390_FEAT_TYPE_SCLP_CPU, S390_FEAT_TYPE_MISC, S390_FEAT_TYPE_PLO, diff --git a/target/s390x/cpu_features_def.h b/target/s390x/cpu_features_de= f.h index 5fc7e7b..d99da1d 100644 --- a/target/s390x/cpu_features_def.h +++ b/target/s390x/cpu_features_def.h @@ -109,6 +109,9 @@ typedef enum { S390_FEAT_SIE_PFMFI, S390_FEAT_SIE_IBS, =20 + /* Read Info Byte 134 */ + S390_FEAT_DIAG318, + /* Sclp Cpu */ S390_FEAT_SIE_F2, S390_FEAT_SIE_SKEY, diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index 70015ea..a3d1457 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -450,6 +450,7 @@ static uint16_t full_GEN12_GA1[] =3D { S390_FEAT_AP_QUERY_CONFIG_INFO, S390_FEAT_AP_FACILITIES_TEST, S390_FEAT_AP, + S390_FEAT_DIAG318, }; =20 static uint16_t full_GEN12_GA2[] =3D { diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 2ebf26a..3915e36 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2142,6 +2142,7 @@ static int kvm_to_feat[][2] =3D { { KVM_S390_VM_CPU_FEAT_PFMFI, S390_FEAT_SIE_PFMFI}, { KVM_S390_VM_CPU_FEAT_SIGPIF, S390_FEAT_SIE_SIGPIF}, { KVM_S390_VM_CPU_FEAT_KSS, S390_FEAT_SIE_KSS}, + { KVM_S390_VM_CPU_FEAT_DIAG318, S390_FEAT_DIAG318}, }; =20 static int query_cpu_feat(S390FeatBitmap features) --=20 2.7.4 From nobody Sat Apr 20 05:26:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544135232236526.19801022772; Thu, 6 Dec 2018 14:27:12 -0800 (PST) Received: from localhost ([::1]:43259 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gV26x-0000KM-0N for importer@patchew.org; Thu, 06 Dec 2018 17:27:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gV259-0007rA-Lm for qemu-devel@nongnu.org; Thu, 06 Dec 2018 17:25:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gV256-0003EN-0Z for qemu-devel@nongnu.org; Thu, 06 Dec 2018 17:25:17 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46498 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 1gV252-0003BL-Dw for qemu-devel@nongnu.org; Thu, 06 Dec 2018 17:25:14 -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 wB6MJ0xl023691 for ; Thu, 6 Dec 2018 17:25:11 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2p79gdg8cu-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 06 Dec 2018 17:25:10 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Dec 2018 22:25:10 -0000 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 6 Dec 2018 22:25:06 -0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wB6MP5Yb17432768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 6 Dec 2018 22:25:05 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B9F06E04E; Thu, 6 Dec 2018 22:25:05 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D3526E053; Thu, 6 Dec 2018 22:25:04 +0000 (GMT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.52]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 6 Dec 2018 22:25:04 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com, rth@twiddle.net, david@redhat.com, borntraeger@de.ibm.com, thuth@redhat.com Date: Thu, 6 Dec 2018 17:24:18 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544135058-21380-1-git-send-email-walling@linux.ibm.com> References: <1544135058-21380-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18120622-0036-0000-0000-00000A66C123 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010184; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000270; SDB=6.01127998; UDB=6.00585943; IPR=6.00908129; MB=3.00024517; MTD=3.00000008; XFM=3.00000015; UTC=2018-12-06 22:25:08 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18120622-0037-0000-0000-000049E2F116 Message-Id: <1544135058-21380-4-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-12-06_08:, , 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 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812060188 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 v2 3/3] s390: migration and reset support for diagnose 318 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Diagnose 318 contains data regarding the guest's name code and version code (collectively called the cpc) and must be captured for migration. Since this instruction is executed in the kernel during IPL, we register the migration handlers during IPL as well. Also add a reset method for the diagnose 318 related data so we can clear it during a machine reset. Signed-off-by: Collin Walling --- hw/s390x/ipl.c | 3 +++ hw/s390x/s390-virtio-ccw.c | 3 +++ target/s390x/diag.c | 52 ++++++++++++++++++++++++++++++++++++++++++= ++++ target/s390x/internal.h | 4 +++- target/s390x/kvm-stub.c | 10 +++++++++ target/s390x/kvm.c | 22 ++++++++++++++++++++ target/s390x/kvm_s390x.h | 2 ++ 7 files changed, 95 insertions(+), 1 deletion(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 21f64ad..6e3af65 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -27,6 +27,7 @@ #include "qemu/cutils.h" #include "qemu/option.h" #include "exec/exec-all.h" +#include "internal.h" =20 #define KERN_IMAGE_START 0x010000UL #define LINUX_MAGIC_ADDR 0x010008UL @@ -230,6 +231,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **= errp) ipl->compat_start_addr =3D ipl->start_addr; ipl->compat_bios_start_addr =3D ipl->bios_start_addr; qemu_register_reset(qdev_reset_all_fn, dev); + + diag318_register(); error: error_propagate(errp, err); } diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index a0615a8..2c670fc 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -37,6 +37,7 @@ #include "cpu_models.h" #include "hw/nmi.h" #include "hw/s390x/tod.h" +#include "internal.h" =20 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr) { @@ -357,6 +358,7 @@ static void s390_machine_reset(void) } subsystem_reset(); s390_crypto_reset(); + diag318_reset(); run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL); break; case S390_RESET_LOAD_NORMAL: @@ -364,6 +366,7 @@ static void s390_machine_reset(void) run_on_cpu(t, s390_do_cpu_reset, RUN_ON_CPU_NULL); } subsystem_reset(); + diag318_reset(); run_on_cpu(cs, s390_do_cpu_initial_reset, RUN_ON_CPU_NULL); run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL); break; diff --git a/target/s390x/diag.c b/target/s390x/diag.c index acb0f3d..935862d 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -20,6 +20,7 @@ #include "sysemu/cpus.h" #include "hw/s390x/ipl.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "kvm_s390x.h" =20 int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3) { @@ -134,3 +135,54 @@ out: break; } } + +typedef struct Diag318Data { + uint64_t cpc; +} Diag318Data; +static Diag318Data diag318data; + +void diag318_reset(void) +{ + if (s390_has_feat(S390_FEAT_DIAG318)) { + kvm_s390_set_cpc(0); + } +} + +static int diag318_post_load(void *opaque, int version_id) +{ + Diag318Data *d =3D opaque; + + kvm_s390_set_cpc(d->cpc); + return 0; +} + +static int diag318_pre_save(void *opaque) +{ + Diag318Data *d =3D opaque; + + kvm_s390_get_cpc(&d->cpc); + return 0; +} + +static bool diag318_needed(void *opaque) +{ + return s390_has_feat(S390_FEAT_DIAG318); +} + +const VMStateDescription vmstate_diag318 =3D { + .name =3D "diag318", + .post_load =3D diag318_post_load, + .pre_save =3D diag318_pre_save, + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D diag318_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(cpc, Diag318Data), + VMSTATE_END_OF_LIST() + } +}; + +void diag318_register(void) +{ + vmstate_register(NULL, 0, &vmstate_diag318, &diag318data); +} diff --git a/target/s390x/internal.h b/target/s390x/internal.h index f2a771e..d53b1d0 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -383,10 +383,12 @@ int mmu_translate_real(CPUS390XState *env, target_ulo= ng raddr, int rw, target_ulong *addr, int *flags); =20 =20 -/* misc_helper.c */ +/* diag.c */ int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3); void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra); +void diag318_register(void); +void diag318_reset(void); =20 =20 /* translate.c */ diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c index bf7795e..1f0bee3 100644 --- a/target/s390x/kvm-stub.c +++ b/target/s390x/kvm-stub.c @@ -104,3 +104,13 @@ void kvm_s390_stop_interrupt(S390CPU *cpu) void kvm_s390_restart_interrupt(S390CPU *cpu) { } + +int kvm_s390_get_cpc(uint64_t *cpc) +{ + return 0; +} + +int kvm_s390_set_cpc(uint64_t cpc) +{ + return 0; +} \ No newline at end of file diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 3915e36..432f8ea 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -749,6 +749,28 @@ int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t = tod_low) return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); } =20 +int kvm_s390_get_cpc(uint64_t *cpc) +{ + struct kvm_device_attr attr =3D { + .group =3D KVM_S390_VM_MACHINE, + .attr =3D KVM_S390_VM_MACHINE_CPC, + .addr =3D (uint64_t)cpc, + }; + + return kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); +} + +int kvm_s390_set_cpc(uint64_t cpc) +{ + struct kvm_device_attr attr =3D { + .group =3D KVM_S390_VM_MACHINE, + .attr =3D KVM_S390_VM_MACHINE_CPC, + .addr =3D (uint64_t)&cpc, + }; + + return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); +} + /** * kvm_s390_mem_op: * @addr: the logical start address in guest memory diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h index 6e52287..8c7b6a8 100644 --- a/target/s390x/kvm_s390x.h +++ b/target/s390x/kvm_s390x.h @@ -29,6 +29,8 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_c= lock); int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_clock); int kvm_s390_set_clock(uint8_t tod_high, uint64_t tod_clock); int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_clock); +int kvm_s390_get_cpc(uint64_t *cpc); +int kvm_s390_set_cpc(uint64_t cpc); void kvm_s390_enable_css_support(S390CPU *cpu); int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, int vq, bool assign); --=20 2.7.4