From nobody Sat Apr 27 21:40:50 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499942529223215.66912262473863; Thu, 13 Jul 2017 03:42:09 -0700 (PDT) Received: from localhost ([::1]:58623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVbZP-0005xO-07 for importer@patchew.org; Thu, 13 Jul 2017 06:42:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVbXy-00054w-7V for qemu-devel@nongnu.org; Thu, 13 Jul 2017 06:40:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVbXv-0002Fq-5a for qemu-devel@nongnu.org; Thu, 13 Jul 2017 06:40:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55707 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 1dVbXu-0002Fg-Vs for qemu-devel@nongnu.org; Thu, 13 Jul 2017 06:40:35 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6DAdi62049738 for ; Thu, 13 Jul 2017 06:40:34 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bp61fk0r0-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 13 Jul 2017 06:40:34 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Jul 2017 11:40:32 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 13 Jul 2017 11:40:30 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6DAeUwq39583920; Thu, 13 Jul 2017 10:40:30 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9EF0852049; Thu, 13 Jul 2017 10:36:48 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 8E0865203F; Thu, 13 Jul 2017 10:36:48 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id D535820F69C; Thu, 13 Jul 2017 12:40:29 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Thu, 13 Jul 2017 12:40:27 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499942429-55449-1-git-send-email-borntraeger@de.ibm.com> References: <1499942429-55449-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071310-0020-0000-0000-000003A17B4A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071310-0021-0000-0000-00004226C8B5 Message-Id: <1499942429-55449-2-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-13_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707130166 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/s390-next 1/3] s390x: initialize cpu firstly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Halil Pasic , Yi Min Zhao , Cornelia Huck , Pierre Morel , Alexander Graf , Christian Borntraeger , Thomas Huth , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Yi Min Zhao By initializing the CPU firstly, we are able to retrieve and use the CPU model features when initializing other subsystem or devices. Signed-off-by: Yi Min Zhao Reviewed-by: Pierre Morel Signed-off-by: Christian Borntraeger Reviewed-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index e086cb5..23e9658 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -122,6 +122,9 @@ static void ccw_init(MachineState *machine) s390_sclp_init(); s390_memory_init(machine->ram_size); =20 + /* init CPUs */ + s390_init_cpus(machine); + s390_flic_init(); =20 /* get a BUS */ @@ -138,9 +141,6 @@ static void ccw_init(MachineState *machine) /* register hypercalls */ virtio_ccw_register_hcalls(); =20 - /* init CPUs */ - s390_init_cpus(machine); - if (kvm_enabled()) { kvm_s390_enable_css_support(s390_cpu_addr2state(0)); } --=20 2.7.4 From nobody Sat Apr 27 21:40:50 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499942534246556.848209370951; Thu, 13 Jul 2017 03:42:14 -0700 (PDT) Received: from localhost ([::1]:58624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVbZS-00060r-Nm for importer@patchew.org; Thu, 13 Jul 2017 06:42:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVbY0-00056U-V0 for qemu-devel@nongnu.org; Thu, 13 Jul 2017 06:40:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVbXx-0002Gh-PM for qemu-devel@nongnu.org; Thu, 13 Jul 2017 06:40:40 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59764 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 1dVbXx-0002GY-Ja for qemu-devel@nongnu.org; Thu, 13 Jul 2017 06:40:37 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6DAdSUe133187 for ; Thu, 13 Jul 2017 06:40:36 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2bp1sqkt9x-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 13 Jul 2017 06:40:35 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Jul 2017 11:40:34 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 13 Jul 2017 11:40:31 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6DAeUqY65536152; Thu, 13 Jul 2017 10:40:30 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0221652045; Thu, 13 Jul 2017 10:36:49 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id DF5835203F; Thu, 13 Jul 2017 10:36:48 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 2F3AE20F69C; Thu, 13 Jul 2017 12:40:30 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Thu, 13 Jul 2017 12:40:28 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499942429-55449-1-git-send-email-borntraeger@de.ibm.com> References: <1499942429-55449-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071310-0020-0000-0000-000003A17B4B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071310-0021-0000-0000-00004226C8B7 Message-Id: <1499942429-55449-3-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-13_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707130166 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/s390-next 2/3] s390x/cpumodel: add zpci, aen and ais facilities X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Halil Pasic , Yi Min Zhao , Cornelia Huck , Pierre Morel , Alexander Graf , Christian Borntraeger , Thomas Huth , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Yi Min Zhao zPCI instructions and facilities are available since IBM zEnterprise EC12. To support z/PCI in QEMU we enable zpci, aen and ais facilities starting with zEC12 GA1. And we always set zpci and aen bits in max cpu model. Later they might be switched off due to applied real cpu model. For ais bit, we only provide it in the full cpu model beginning with zEC12 and defer its enablement in the default cpu model to a later point in time. At the same time, disable them for 2.9 and older machines. Because of introducing AIS facility, we could check if it's enabled to initialize flic->ais_supported with the real value. Signed-off-by: Yi Min Zhao Signed-off-by: Christian Borntraeger Reviewed-by: Cornelia Huck --- hw/intc/s390_flic.c | 3 ++- hw/intc/s390_flic_kvm.c | 3 --- hw/s390x/s390-virtio-ccw.c | 3 +++ target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features_def.h | 3 +++ target/s390x/gen-features.c | 5 +++++ target/s390x/kvm.c | 7 +++++++ 7 files changed, 23 insertions(+), 4 deletions(-) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index ff6e4ec..6e7c610 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -163,9 +163,10 @@ static void s390_flic_common_realize(DeviceState *dev,= Error **errp) if (max_batch > ADAPTER_ROUTES_MAX_GSI) { error_setg(errp, "flic property adapter_routes_max_batch too big" " (%d > %d)", max_batch, ADAPTER_ROUTES_MAX_GSI); + return; } =20 - fs->ais_supported =3D true; + fs->ais_supported =3D s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION); } =20 static void s390_flic_class_init(ObjectClass *oc, void *data) diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index a587ace..d93503f 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -444,7 +444,6 @@ typedef struct KVMS390FLICStateClass { =20 static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) { - S390FLICState *fs =3D S390_FLIC_COMMON(dev); KVMS390FLICState *flic_state =3D KVM_S390_FLIC(dev); struct kvm_create_device cd =3D {0}; struct kvm_device_attr test_attr =3D {0}; @@ -476,8 +475,6 @@ static void kvm_s390_flic_realize(DeviceState *dev, Err= or **errp) test_attr.group =3D KVM_DEV_FLIC_CLEAR_IO_IRQ; flic_state->clear_io_supported =3D !ioctl(flic_state->fd, KVM_HAS_DEVICE_ATTR, test_attr= ); - - fs->ais_supported =3D false; return; fail: error_propagate(errp, errp_local); diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 23e9658..e484aed 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -503,6 +503,9 @@ DEFINE_CCW_MACHINE(2_10, "2.10", true); static void ccw_machine_2_9_instance_options(MachineState *machine) { ccw_machine_2_10_instance_options(machine); + s390_cpudef_featoff_greater(12, 1, S390_FEAT_ZPCI); + s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_INT_SUPPRESSION); + s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_EVENT_NOTIFICATIO= N); } =20 static void ccw_machine_2_9_class_options(MachineClass *mc) diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c index 0436dc2..8ab5cd7 100644 --- a/target/s390x/cpu_features.c +++ b/target/s390x/cpu_features.c @@ -74,6 +74,9 @@ static const S390FeatDef s390_features[] =3D { FEAT_INIT("stfle53", S390_FEAT_TYPE_STFL, 53, "Various facilities intr= oduced with z13"), FEAT_INIT("msa5-base", S390_FEAT_TYPE_STFL, 57, "Message-security-assi= st-extension-5 facility (excluding subfunctions)"), FEAT_INIT("ri", S390_FEAT_TYPE_STFL, 64, "CPU runtime-instrumentation = facility"), + FEAT_INIT("zpci", S390_FEAT_TYPE_STFL, 69, "z/PCI facility"), + FEAT_INIT("aen", S390_FEAT_TYPE_STFL, 71, "General-purpose-adapter-eve= nt-notification facility"), + FEAT_INIT("ais", S390_FEAT_TYPE_STFL, 72, "General-purpose-adapter-int= erruption-suppression facility"), FEAT_INIT("te", S390_FEAT_TYPE_STFL, 73, "Transactional-execution faci= lity"), FEAT_INIT("sthyi", S390_FEAT_TYPE_STFL, 74, "Store-hypervisor-informat= ion facility"), FEAT_INIT("aefsi", S390_FEAT_TYPE_STFL, 75, "Access-exception-fetch/st= ore-indication facility"), diff --git a/target/s390x/cpu_features_def.h b/target/s390x/cpu_features_de= f.h index f5bb7ed..c939a00 100644 --- a/target/s390x/cpu_features_def.h +++ b/target/s390x/cpu_features_def.h @@ -65,6 +65,9 @@ typedef enum { S390_FEAT_STFLE_53, S390_FEAT_MSA_EXT_5, S390_FEAT_RUNTIME_INSTRUMENTATION, + S390_FEAT_ZPCI, + S390_FEAT_ADAPTER_EVENT_NOTIFICATION, + S390_FEAT_ADAPTER_INT_SUPPRESSION, S390_FEAT_TRANSACTIONAL_EXE, S390_FEAT_STORE_HYPERVISOR_INFO, S390_FEAT_ACCESS_EXCEPTION_FS_INDICATION, diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index 8ca2b47..622ee24 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -389,6 +389,9 @@ static uint16_t full_GEN12_GA1[] =3D { S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE, S390_FEAT_TRANSACTIONAL_EXE, S390_FEAT_RUNTIME_INSTRUMENTATION, + S390_FEAT_ZPCI, + S390_FEAT_ADAPTER_EVENT_NOTIFICATION, + S390_FEAT_ADAPTER_INT_SUPPRESSION, S390_FEAT_EDAT_2, }; =20 @@ -446,6 +449,8 @@ static uint16_t default_GEN12_GA1[] =3D { S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE, S390_FEAT_TRANSACTIONAL_EXE, S390_FEAT_RUNTIME_INSTRUMENTATION, + S390_FEAT_ZPCI, + S390_FEAT_ADAPTER_EVENT_NOTIFICATION, S390_FEAT_EDAT_2, }; =20 diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 78ebe83..1901153 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -302,6 +302,9 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } =20 + /* Try to enable AIS facility */ + kvm_vm_enable_cap(s, KVM_CAP_S390_AIS, 0); + qemu_mutex_init(&qemu_sigp_mutex); =20 return 0; @@ -2635,6 +2638,10 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model= , Error **errp) set_bit(S390_FEAT_CMM, model->features); } =20 + /* set zpci and aen facilities */ + set_bit(S390_FEAT_ZPCI, model->features); + set_bit(S390_FEAT_ADAPTER_EVENT_NOTIFICATION, model->features); + if (s390_known_cpu_type(cpu_type)) { /* we want the exact model, even if some features are missing */ model->def =3D s390_find_cpu_def(cpu_type, ibc_gen(unblocked_ibc), --=20 2.7.4 From nobody Sat Apr 27 21:40:50 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499942637057138.16343320774536; Thu, 13 Jul 2017 03:43:57 -0700 (PDT) Received: from localhost ([::1]:58630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVbb6-0007Im-PF for importer@patchew.org; Thu, 13 Jul 2017 06:43:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVbY1-00056s-Fp for qemu-devel@nongnu.org; Thu, 13 Jul 2017 06:40:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVbXy-0002Gp-69 for qemu-devel@nongnu.org; Thu, 13 Jul 2017 06:40:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVbXx-0002GJ-Nc for qemu-devel@nongnu.org; Thu, 13 Jul 2017 06:40:38 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6DAdQDX029155 for ; Thu, 13 Jul 2017 06:40:36 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bnt3pjk1w-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 13 Jul 2017 06:40:36 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Jul 2017 11:40:33 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 13 Jul 2017 11:40:31 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6DAeUh039321628; Thu, 13 Jul 2017 10:40:30 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 76D47AE055; Thu, 13 Jul 2017 11:37:06 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EF0DAE053; Thu, 13 Jul 2017 11:37:06 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 13 Jul 2017 11:37:06 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 712EF20F69D; Thu, 13 Jul 2017 12:40:30 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Thu, 13 Jul 2017 12:40:29 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499942429-55449-1-git-send-email-borntraeger@de.ibm.com> References: <1499942429-55449-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071310-0040-0000-0000-000003C37AEB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071310-0041-0000-0000-000025BEBF28 Message-Id: <1499942429-55449-4-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-13_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707130166 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH/s390-next 3/3] s390x/flic: migrate ais states X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Halil Pasic , Yi Min Zhao , Cornelia Huck , Pierre Morel , Alexander Graf , Christian Borntraeger , Thomas Huth , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Yi Min Zhao During migration we should transfer ais states to the target guest. This patch introduces a subsection to kvm_s390_flic_vmstate and new vmsd for qemu_flic. The ais states need to be migrated only when ais is supported. Signed-off-by: Yi Min Zhao Signed-off-by: Christian Borntraeger Reviewed-by: Cornelia Huck --- hw/intc/s390_flic.c | 20 ++++++++++++ hw/intc/s390_flic_kvm.c | 75 ++++++++++++++++++++++++++++++++++++++++= ++++ include/hw/s390x/s390_flic.h | 1 + 3 files changed, 96 insertions(+) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index 6e7c610..6eaf178 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -134,12 +134,32 @@ static void qemu_s390_flic_reset(DeviceState *dev) flic->nimm =3D 0; } =20 +bool ais_needed(void *opaque) +{ + S390FLICState *s =3D opaque; + + return s->ais_supported; +} + +static const VMStateDescription qemu_s390_flic_vmstate =3D { + .name =3D "qemu-s390-flic", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D ais_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(simm, QEMUS390FLICState), + VMSTATE_UINT8(nimm, QEMUS390FLICState), + VMSTATE_END_OF_LIST() + } +}; + static void qemu_s390_flic_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); S390FLICStateClass *fsc =3D S390_FLIC_COMMON_CLASS(oc); =20 dc->reset =3D qemu_s390_flic_reset; + dc->vmsd =3D &qemu_s390_flic_vmstate; fsc->register_io_adapter =3D qemu_s390_register_io_adapter; fsc->io_adapter_map =3D qemu_s390_io_adapter_map; fsc->add_adapter_routes =3D qemu_s390_add_adapter_routes; diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index d93503f..4cf73ee 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -413,7 +413,78 @@ out: return r; } =20 +typedef struct KVMS390FLICStateMigTmp { + KVMS390FLICState *parent; + uint8_t simm; + uint8_t nimm; +} KVMS390FLICStateMigTmp; + +static void kvm_flic_ais_pre_save(void *opaque) +{ + KVMS390FLICStateMigTmp *tmp =3D opaque; + KVMS390FLICState *flic =3D tmp->parent; + struct kvm_s390_ais_all ais; + struct kvm_device_attr attr =3D { + .group =3D KVM_DEV_FLIC_AISM_ALL, + .addr =3D (uint64_t)&ais, + .attr =3D sizeof(ais), + }; + + if (ioctl(flic->fd, KVM_GET_DEVICE_ATTR, &attr)) { + error_report("Failed to retrieve kvm flic ais states"); + return; + } + + tmp->simm =3D ais.simm; + tmp->nimm =3D ais.nimm; +} + +static int kvm_flic_ais_post_load(void *opaque, int version_id) +{ + KVMS390FLICStateMigTmp *tmp =3D opaque; + KVMS390FLICState *flic =3D tmp->parent; + struct kvm_s390_ais_all ais =3D { + .simm =3D tmp->simm, + .nimm =3D tmp->nimm, + }; + struct kvm_device_attr attr =3D { + .group =3D KVM_DEV_FLIC_AISM_ALL, + .addr =3D (uint64_t)&ais, + }; + + if (!ais_needed(flic)) { + return -ENOSYS; + } + + return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0; +} + +static const VMStateDescription kvm_s390_flic_ais_tmp =3D { + .name =3D "s390-flic-ais-tmp", + .pre_save =3D kvm_flic_ais_pre_save, + .post_load =3D kvm_flic_ais_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(simm, KVMS390FLICStateMigTmp), + VMSTATE_UINT8(nimm, KVMS390FLICStateMigTmp), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription kvm_s390_flic_vmstate_ais =3D { + .name =3D "s390-flic/ais", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D ais_needed, + .fields =3D (VMStateField[]) { + VMSTATE_WITH_TMP(KVMS390FLICState, KVMS390FLICStateMigTmp, + kvm_s390_flic_ais_tmp), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription kvm_s390_flic_vmstate =3D { + /* should have been like kvm-s390-flic, + * can't change without breaking compat */ .name =3D "s390-flic", .version_id =3D FLIC_SAVEVM_VERSION, .minimum_version_id =3D FLIC_SAVEVM_VERSION, @@ -428,6 +499,10 @@ static const VMStateDescription kvm_s390_flic_vmstate = =3D { .flags =3D VMS_SINGLE, }, VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * []) { + &kvm_s390_flic_vmstate_ais, + NULL } }; =20 diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h index 2f173d9..7aab6ef 100644 --- a/include/hw/s390x/s390_flic.h +++ b/include/hw/s390x/s390_flic.h @@ -89,6 +89,7 @@ typedef struct QEMUS390FLICState { void s390_flic_init(void); =20 S390FLICState *s390_get_flic(void); +bool ais_needed(void *opaque); =20 #ifdef CONFIG_KVM DeviceState *s390_flic_kvm_create(void); --=20 2.7.4