From nobody Tue Feb 10 16:22:13 2026 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 1506433103767212.5476033433472; Tue, 26 Sep 2017 06:38:23 -0700 (PDT) Received: from localhost ([::1]:47595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwq42-0006hF-2D for importer@patchew.org; Tue, 26 Sep 2017 09:38:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwq2T-0005pu-3M for qemu-devel@nongnu.org; Tue, 26 Sep 2017 09:36:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwq2P-0007WD-Sb for qemu-devel@nongnu.org; Tue, 26 Sep 2017 09:36:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51778) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwq2P-0007Va-Ik for qemu-devel@nongnu.org; Tue, 26 Sep 2017 09:36:37 -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 v8QDZkUr139470 for ; Tue, 26 Sep 2017 09:36:33 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2d7mpaxeds-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 26 Sep 2017 09:36:32 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 26 Sep 2017 14:36:29 +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; Tue, 26 Sep 2017 14:36:26 +0100 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 v8QDaPwn22151290; Tue, 26 Sep 2017 13:36:25 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ABDF1A4051; Tue, 26 Sep 2017 14:32:18 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96294A4040; Tue, 26 Sep 2017 14:32:18 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 26 Sep 2017 14:32:18 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 444B820F62D; Tue, 26 Sep 2017 15:36:25 +0200 (CEST) From: Christian Borntraeger To: Cornelia Huck Date: Tue, 26 Sep 2017 15:36:23 +0200 X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170926133624.155394-1-borntraeger@de.ibm.com> References: <20170926133624.155394-1-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17092613-0020-0000-0000-000003BB39C6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092613-0021-0000-0000-0000424D14A3 Message-Id: <20170926133624.155394-2-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-26_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-1707230000 definitions=main-1709260197 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 v2 1/2] s390x/ais: enable ais when migration is available 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 , David Hildenbrand , qemu-devel , Alexander Graf , Christian Borntraeger , "Jason J . Herne" , 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" Instead of unconditionally enabling the KVM AIS capability in the kvm arch init function, do this in the flic realize function when we know if migration is available. This requires to initialize flic before the CPUs. Signed-off-by: Christian Borntraeger Reviewed-by: David Hildenbrand --- hw/intc/s390_flic.c | 8 ++------ hw/intc/s390_flic_kvm.c | 16 +++++++++++----- hw/s390x/css.c | 4 ++-- hw/s390x/s390-virtio-ccw.c | 10 +++++++--- include/hw/s390x/s390_flic.h | 1 - target/s390x/kvm.c | 10 ++-------- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index 6eaf178..9858f0e 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -1,7 +1,7 @@ /* * QEMU S390x floating interrupt controller (flic) * - * Copyright 2014 IBM Corp. + * Copyright IBM Corp. 2014, 2017 * Author(s): Jens Freimann * Cornelia Huck * @@ -136,9 +136,7 @@ static void qemu_s390_flic_reset(DeviceState *dev) =20 bool ais_needed(void *opaque) { - S390FLICState *s =3D opaque; - - return s->ais_supported; + return s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION); } =20 static const VMStateDescription qemu_s390_flic_vmstate =3D { @@ -185,8 +183,6 @@ static void s390_flic_common_realize(DeviceState *dev, = Error **errp) " (%d > %d)", max_batch, ADAPTER_ROUTES_MAX_GSI); return; } - - 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 7ead17a..5c9d215 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -1,7 +1,7 @@ /* * QEMU S390x KVM floating interrupt controller (flic) * - * Copyright 2014 IBM Corp. + * Copyright IBM Corp. 2014, 2017 * Author(s): Jens Freimann * Cornelia Huck * @@ -164,7 +164,7 @@ static int kvm_s390_modify_ais_mode(S390FLICState *fs, = uint8_t isc, .addr =3D (uint64_t)&req, }; =20 - if (!fs->ais_supported) { + if (!s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION)) { return -ENOSYS; } =20 @@ -181,7 +181,7 @@ static int kvm_s390_inject_airq(S390FLICState *fs, uint= 8_t type, .attr =3D id, }; =20 - if (!fs->ais_supported) { + if (!s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION)) { return -ENOSYS; } =20 @@ -459,7 +459,7 @@ static int kvm_flic_ais_post_load(void *opaque, int ver= sion_id) * migration from a host that has AIS to a host that has no AIS. * In that case the target system will reject the migration here. */ - if (!ais_needed(flic)) { + if (!s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION)) { return -ENOSYS; } =20 @@ -557,6 +557,12 @@ static void kvm_s390_flic_realize(DeviceState *dev, Er= ror **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= ); + /* try enable the AIS facility */ + test_attr.group =3D KVM_DEV_FLIC_AISM_ALL; + if (!ioctl(flic_state->fd, KVM_HAS_DEVICE_ATTR, test_attr)) { + kvm_vm_enable_cap(kvm_state, KVM_CAP_S390_AIS, 0); + } + return; fail: error_propagate(errp, errp_local); @@ -578,7 +584,7 @@ static void kvm_s390_flic_reset(DeviceState *dev) =20 flic_disable_wait_pfault(flic); =20 - if (fs->ais_supported) { + if (s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION)) { for (isc =3D 0; isc <=3D MAX_ISC; isc++) { rc =3D kvm_s390_modify_ais_mode(fs, isc, SIC_IRQ_MODE_ALL); if (rc) { diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 75d4f30..1d4bb73 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1,7 +1,7 @@ /* * Channel subsystem base support. * - * Copyright 2012 IBM Corp. + * Copyright IBM Corp. 2012, 2017 * Author(s): Cornelia Huck * * This work is licensed under the terms of the GNU GPL, version 2 or (at @@ -672,7 +672,7 @@ void css_adapter_interrupt(CssIoAdapterType type, uint8= _t isc) } =20 trace_css_adapter_interrupt(isc); - if (fs->ais_supported) { + if (s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION)) { if (fsc->inject_airq(fs, type, isc, adapter->flags)) { error_report("Failed to inject airq with AIS supported"); exit(1); diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index fafbc6d..98c82c2 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -1,7 +1,7 @@ /* * virtio ccw machine * - * Copyright 2012 IBM Corp. + * Copyright IBM Corp. 2012, 2017 * Copyright (c) 2009 Alexander Graf * Author(s): Cornelia Huck * @@ -279,11 +279,15 @@ static void ccw_init(MachineState *machine) s390_sclp_init(); s390_memory_init(machine->ram_size); =20 + /* + * This might also enable some KVM features like AIS, so it must + * be called before the CPU model + */ + s390_flic_init(); + /* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus(machine); =20 - s390_flic_init(); - /* get a BUS */ css_bus =3D virtual_css_bus_init(); s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline, diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h index 7aab6ef..75fd83c 100644 --- a/include/hw/s390x/s390_flic.h +++ b/include/hw/s390x/s390_flic.h @@ -44,7 +44,6 @@ typedef struct S390FLICState { SysBusDevice parent_obj; /* to limit AdapterRoutes.num_routes for compat */ uint32_t adapter_routes_max_batch; - bool ais_supported; } S390FLICState; =20 #define S390_FLIC_COMMON_CLASS(klass) \ diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index ebb75ca..9ee2ada 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2,7 +2,7 @@ * QEMU S390x KVM implementation * * Copyright (c) 2009 Alexander Graf - * Copyright IBM Corp. 2012 + * Copyright IBM Corp. 2012, 2017 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -311,13 +311,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } =20 - /* - * The migration interface for ais was introduced with kernel 4.13 - * but the capability itself had been active since 4.12. As migration - * support is considered necessary let's disable ais in the 2.10 - * machine. - */ - /* kvm_vm_enable_cap(s, KVM_CAP_S390_AIS, 0); */ + /* The AIS enablement happens in the flic realize */ =20 qemu_mutex_init(&qemu_sigp_mutex); =20 --=20 2.9.4