From nobody Sun May 5 02:48:05 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 1499177648277181.1366524554752; Tue, 4 Jul 2017 07:14:08 -0700 (PDT) Received: from localhost ([::1]:41620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOab-00050b-Sy for importer@patchew.org; Tue, 04 Jul 2017 10:14:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOUs-00088c-HY for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSOUo-0003WO-CL for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:10 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40120 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 1dSOUo-0003Uv-2k for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:06 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v64E4blC021883 for ; Tue, 4 Jul 2017 10:08:04 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2bg1rphdqy-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 04 Jul 2017 10:08:04 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jul 2017 15:08:02 +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, 4 Jul 2017 15:08:00 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v64E80Fg5046666; Tue, 4 Jul 2017 14:08:00 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D162CAE04D; Tue, 4 Jul 2017 15:04:50 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B653DAE045; Tue, 4 Jul 2017 15:04:50 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 4 Jul 2017 15:04:50 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id E449820F67D; Tue, 4 Jul 2017 16:07:59 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Tue, 4 Jul 2017 16:07:53 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> References: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17070414-0020-0000-0000-0000039943E8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070414-0021-0000-0000-0000421CAF7F Message-Id: <1499177279-131407-2-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-04_09:, , 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-1703280000 definitions=main-1707040241 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 1/7] s390x: vmstatify config migration for virtio-ccw 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: Christian Borntraeger , Halil Pasic , Cornelia Huck , Alexander Graf , 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: Halil Pasic Let's vmstatify virtio_ccw_save_config and virtio_ccw_load_config for flexibility (extending using subsections) and for fun. To achieve this we need to hack the config_vector, which is VirtIODevice (that is common virtio) state, in the middle of the VirtioCcwDevice state representation. This is somewhat ugly, but we have no choice because the stream format needs to be preserved. Almost no changes in behavior. Exception is everything that comes with vmstate like extra bookkeeping about what's in the stream, and maybe some extra checks and better error reporting. Signed-off-by: Halil Pasic Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Reviewed-by: Cornelia Huck Message-Id: <20170703213414.94298-1-pasic@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger --- hw/intc/s390_flic.c | 28 ++++ hw/s390x/ccw-device.c | 10 ++ hw/s390x/ccw-device.h | 4 + hw/s390x/css.c | 378 +++++++++++++++++++++++++--------------= ---- hw/s390x/virtio-ccw.c | 158 +++++++++--------- include/hw/s390x/css.h | 12 +- include/hw/s390x/s390_flic.h | 5 + 7 files changed, 358 insertions(+), 237 deletions(-) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index a26e906..a99a350 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -17,6 +17,7 @@ #include "trace.h" #include "hw/qdev.h" #include "qapi/error.h" +#include "hw/s390x/s390-virtio-ccw.h" =20 S390FLICState *s390_get_flic(void) { @@ -136,3 +137,30 @@ static void qemu_s390_flic_register_types(void) } =20 type_init(qemu_s390_flic_register_types) + +const VMStateDescription vmstate_adapter_info =3D { + .name =3D "s390_adapter_info", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(ind_offset, AdapterInfo), + /* + * We do not have to migrate neither the id nor the addresses. + * The id is set by css_register_io_adapter and the addresses + * are set based on the IndAddr objects after those get mapped. + */ + VMSTATE_END_OF_LIST() + }, +}; + +const VMStateDescription vmstate_adapter_routes =3D { + + .name =3D "s390_adapter_routes", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(adapter, AdapterRoutes, 1, vmstate_adapter_info, + AdapterInfo), + VMSTATE_END_OF_LIST() + } +}; diff --git a/hw/s390x/ccw-device.c b/hw/s390x/ccw-device.c index fb8d640..f9bfa15 100644 --- a/hw/s390x/ccw-device.c +++ b/hw/s390x/ccw-device.c @@ -50,6 +50,16 @@ static void ccw_device_class_init(ObjectClass *klass, vo= id *data) dc->props =3D ccw_device_properties; } =20 +const VMStateDescription vmstate_ccw_dev =3D { + .name =3D "s390_ccw_dev", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT_POINTER(sch, CcwDevice, vmstate_subch_dev, SubchDev= ), + VMSTATE_END_OF_LIST() + } +}; + static const TypeInfo ccw_device_info =3D { .name =3D TYPE_CCW_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/hw/s390x/ccw-device.h b/hw/s390x/ccw-device.h index 89c8e5d..4e6af28 100644 --- a/hw/s390x/ccw-device.h +++ b/hw/s390x/ccw-device.h @@ -27,6 +27,10 @@ typedef struct CcwDevice { CssDevId subch_id; } CcwDevice; =20 +extern const VMStateDescription vmstate_ccw_dev; +#define VMSTATE_CCW_DEVICE(_field, _state) \ + VMSTATE_STRUCT(_field, _state, 1, vmstate_ccw_dev, CcwDevice) + typedef struct CCWDeviceClass { DeviceClass parent_class; void (*unplug)(HotplugHandler *, DeviceState *, Error **); diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 599805d..d67fffa 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -22,6 +22,7 @@ #include "hw/s390x/css.h" #include "trace.h" #include "hw/s390x/s390_flic.h" +#include "hw/s390x/s390-virtio-ccw.h" =20 typedef struct CrwContainer { CRW crw; @@ -40,6 +41,181 @@ typedef struct SubchSet { unsigned long devnos_used[BITS_TO_LONGS(MAX_SCHID + 1)]; } SubchSet; =20 +static const VMStateDescription vmstate_scsw =3D { + .name =3D "s390_scsw", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT16(flags, SCSW), + VMSTATE_UINT16(ctrl, SCSW), + VMSTATE_UINT32(cpa, SCSW), + VMSTATE_UINT8(dstat, SCSW), + VMSTATE_UINT8(cstat, SCSW), + VMSTATE_UINT16(count, SCSW), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_pmcw =3D { + .name =3D "s390_pmcw", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(intparm, PMCW), + VMSTATE_UINT16(flags, PMCW), + VMSTATE_UINT16(devno, PMCW), + VMSTATE_UINT8(lpm, PMCW), + VMSTATE_UINT8(pnom, PMCW), + VMSTATE_UINT8(lpum, PMCW), + VMSTATE_UINT8(pim, PMCW), + VMSTATE_UINT16(mbi, PMCW), + VMSTATE_UINT8(pom, PMCW), + VMSTATE_UINT8(pam, PMCW), + VMSTATE_UINT8_ARRAY(chpid, PMCW, 8), + VMSTATE_UINT32(chars, PMCW), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_schib =3D { + .name =3D "s390_schib", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(pmcw, SCHIB, 0, vmstate_pmcw, PMCW), + VMSTATE_STRUCT(scsw, SCHIB, 0, vmstate_scsw, SCSW), + VMSTATE_UINT64(mba, SCHIB), + VMSTATE_UINT8_ARRAY(mda, SCHIB, 4), + VMSTATE_END_OF_LIST() + } +}; + + +static const VMStateDescription vmstate_ccw1 =3D { + .name =3D "s390_ccw1", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(cmd_code, CCW1), + VMSTATE_UINT8(flags, CCW1), + VMSTATE_UINT16(count, CCW1), + VMSTATE_UINT32(cda, CCW1), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_ciw =3D { + .name =3D "s390_ciw", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(type, CIW), + VMSTATE_UINT8(command, CIW), + VMSTATE_UINT16(count, CIW), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_sense_id =3D { + .name =3D "s390_sense_id", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(reserved, SenseId), + VMSTATE_UINT16(cu_type, SenseId), + VMSTATE_UINT8(cu_model, SenseId), + VMSTATE_UINT16(dev_type, SenseId), + VMSTATE_UINT8(dev_model, SenseId), + VMSTATE_UINT8(unused, SenseId), + VMSTATE_STRUCT_ARRAY(ciw, SenseId, MAX_CIWS, 0, vmstate_ciw, CIW), + VMSTATE_END_OF_LIST() + } +}; + +static int subch_dev_post_load(void *opaque, int version_id); +static void subch_dev_pre_save(void *opaque); + +const char err_hint_devno[] =3D "Devno mismatch, tried to load wrong secti= on!" + " Likely reason: some sequences of plug and unplug can break" + " migration for machine versions prior to 2.7 (known design flaw)."; + +const VMStateDescription vmstate_subch_dev =3D { + .name =3D "s390_subch_dev", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D subch_dev_post_load, + .pre_save =3D subch_dev_pre_save, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8_EQUAL(cssid, SubchDev, "Bug!"), + VMSTATE_UINT8_EQUAL(ssid, SubchDev, "Bug!"), + VMSTATE_UINT16(migrated_schid, SubchDev), + VMSTATE_UINT16_EQUAL(devno, SubchDev, err_hint_devno), + VMSTATE_BOOL(thinint_active, SubchDev), + VMSTATE_STRUCT(curr_status, SubchDev, 0, vmstate_schib, SCHIB), + VMSTATE_UINT8_ARRAY(sense_data, SubchDev, 32), + VMSTATE_UINT64(channel_prog, SubchDev), + VMSTATE_STRUCT(last_cmd, SubchDev, 0, vmstate_ccw1, CCW1), + VMSTATE_BOOL(last_cmd_valid, SubchDev), + VMSTATE_STRUCT(id, SubchDev, 0, vmstate_sense_id, SenseId), + VMSTATE_BOOL(ccw_fmt_1, SubchDev), + VMSTATE_UINT8(ccw_no_data_cnt, SubchDev), + VMSTATE_END_OF_LIST() + } +}; + +typedef struct IndAddrPtrTmp { + IndAddr **parent; + uint64_t addr; + int32_t len; +} IndAddrPtrTmp; + +static int post_load_ind_addr(void *opaque, int version_id) +{ + IndAddrPtrTmp *ptmp =3D opaque; + IndAddr **ind_addr =3D ptmp->parent; + + if (ptmp->len !=3D 0) { + *ind_addr =3D get_indicator(ptmp->addr, ptmp->len); + } else { + *ind_addr =3D NULL; + } + return 0; +} + +static void pre_save_ind_addr(void *opaque) +{ + IndAddrPtrTmp *ptmp =3D opaque; + IndAddr *ind_addr =3D *(ptmp->parent); + + if (ind_addr !=3D NULL) { + ptmp->len =3D ind_addr->len; + ptmp->addr =3D ind_addr->addr; + } else { + ptmp->len =3D 0; + ptmp->addr =3D 0L; + } +} + +const VMStateDescription vmstate_ind_addr_tmp =3D { + .name =3D "s390_ind_addr_tmp", + .pre_save =3D pre_save_ind_addr, + .post_load =3D post_load_ind_addr, + + .fields =3D (VMStateField[]) { + VMSTATE_INT32(len, IndAddrPtrTmp), + VMSTATE_UINT64(addr, IndAddrPtrTmp), + VMSTATE_END_OF_LIST() + } +}; + +const VMStateDescription vmstate_ind_addr =3D { + .name =3D "s390_ind_addr_tmp", + .fields =3D (VMStateField[]) { + VMSTATE_WITH_TMP(IndAddr*, IndAddrPtrTmp, vmstate_ind_addr_tmp), + VMSTATE_END_OF_LIST() + } +}; + typedef struct CssImage { SubchSet *sch_set[MAX_SSID + 1]; ChpInfo chpids[MAX_CHPID + 1]; @@ -77,6 +253,52 @@ static ChannelSubSys channel_subsys =3D { QTAILQ_HEAD_INITIALIZER(channel_subsys.indicator_addresses), }; =20 +static void subch_dev_pre_save(void *opaque) +{ + SubchDev *s =3D opaque; + + /* Prepare remote_schid for save */ + s->migrated_schid =3D s->schid; +} + +static int subch_dev_post_load(void *opaque, int version_id) +{ + + SubchDev *s =3D opaque; + + /* Re-assign the subchannel to remote_schid if necessary */ + if (s->migrated_schid !=3D s->schid) { + if (css_find_subch(true, s->cssid, s->ssid, s->schid) =3D=3D s) { + /* + * Cleanup the slot before moving to s->migrated_schid provided + * it still belongs to us, i.e. it was not changed by previous + * invocation of this function. + */ + css_subch_assign(s->cssid, s->ssid, s->schid, s->devno, NULL); + } + /* It's OK to re-assign without a prior de-assign. */ + s->schid =3D s->migrated_schid; + css_subch_assign(s->cssid, s->ssid, s->schid, s->devno, s); + } + + /* + * Hack alert. If we don't migrate the channel subsystem status + * we still need to find out if the guest enabled mss/mcss-e. + * If the subchannel is enabled, it certainly was able to access it, + * so adjust the max_ssid/max_cssid values for relevant ssid/cssid + * values. This is not watertight, but better than nothing. + */ + if (s->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA) { + if (s->ssid) { + channel_subsys.max_ssid =3D MAX_SSID; + } + if (s->cssid !=3D channel_subsys.default_cssid) { + channel_subsys.max_cssid =3D MAX_CSSID; + } + } + return 0; +} + IndAddr *get_indicator(hwaddr ind_addr, int len) { IndAddr *indicator; @@ -1747,162 +1969,6 @@ int css_enable_mss(void) return 0; } =20 -void subch_device_save(SubchDev *s, QEMUFile *f) -{ - int i; - - qemu_put_byte(f, s->cssid); - qemu_put_byte(f, s->ssid); - qemu_put_be16(f, s->schid); - qemu_put_be16(f, s->devno); - qemu_put_byte(f, s->thinint_active); - /* SCHIB */ - /* PMCW */ - qemu_put_be32(f, s->curr_status.pmcw.intparm); - qemu_put_be16(f, s->curr_status.pmcw.flags); - qemu_put_be16(f, s->curr_status.pmcw.devno); - qemu_put_byte(f, s->curr_status.pmcw.lpm); - qemu_put_byte(f, s->curr_status.pmcw.pnom); - qemu_put_byte(f, s->curr_status.pmcw.lpum); - qemu_put_byte(f, s->curr_status.pmcw.pim); - qemu_put_be16(f, s->curr_status.pmcw.mbi); - qemu_put_byte(f, s->curr_status.pmcw.pom); - qemu_put_byte(f, s->curr_status.pmcw.pam); - qemu_put_buffer(f, s->curr_status.pmcw.chpid, 8); - qemu_put_be32(f, s->curr_status.pmcw.chars); - /* SCSW */ - qemu_put_be16(f, s->curr_status.scsw.flags); - qemu_put_be16(f, s->curr_status.scsw.ctrl); - qemu_put_be32(f, s->curr_status.scsw.cpa); - qemu_put_byte(f, s->curr_status.scsw.dstat); - qemu_put_byte(f, s->curr_status.scsw.cstat); - qemu_put_be16(f, s->curr_status.scsw.count); - qemu_put_be64(f, s->curr_status.mba); - qemu_put_buffer(f, s->curr_status.mda, 4); - /* end SCHIB */ - qemu_put_buffer(f, s->sense_data, 32); - qemu_put_be64(f, s->channel_prog); - /* last cmd */ - qemu_put_byte(f, s->last_cmd.cmd_code); - qemu_put_byte(f, s->last_cmd.flags); - qemu_put_be16(f, s->last_cmd.count); - qemu_put_be32(f, s->last_cmd.cda); - qemu_put_byte(f, s->last_cmd_valid); - qemu_put_byte(f, s->id.reserved); - qemu_put_be16(f, s->id.cu_type); - qemu_put_byte(f, s->id.cu_model); - qemu_put_be16(f, s->id.dev_type); - qemu_put_byte(f, s->id.dev_model); - qemu_put_byte(f, s->id.unused); - for (i =3D 0; i < ARRAY_SIZE(s->id.ciw); i++) { - qemu_put_byte(f, s->id.ciw[i].type); - qemu_put_byte(f, s->id.ciw[i].command); - qemu_put_be16(f, s->id.ciw[i].count); - } - qemu_put_byte(f, s->ccw_fmt_1); - qemu_put_byte(f, s->ccw_no_data_cnt); -} - -int subch_device_load(SubchDev *s, QEMUFile *f) -{ - SubchDev *old_s; - Error *err =3D NULL; - uint16_t old_schid =3D s->schid; - uint16_t old_devno =3D s->devno; - int i; - - s->cssid =3D qemu_get_byte(f); - s->ssid =3D qemu_get_byte(f); - s->schid =3D qemu_get_be16(f); - s->devno =3D qemu_get_be16(f); - if (s->devno !=3D old_devno) { - /* Only possible if machine < 2.7 (no css_dev_path) */ - - error_setg(&err, "%x !=3D %x", old_devno, s->devno); - error_append_hint(&err, "Devno mismatch, tried to load wrong secti= on!" - " Likely reason: some sequences of plug and unpl= ug" - " can break migration for machine versions prior= to" - " 2.7 (known design flaw).\n"); - error_report_err(err); - return -EINVAL; - } - /* Re-assign subch. */ - if (old_schid !=3D s->schid) { - old_s =3D channel_subsys.css[s->cssid]->sch_set[s->ssid]->sch[old_= schid]; - /* - * (old_s !=3D s) means that some other device has its correct - * subchannel already assigned (in load). - */ - if (old_s =3D=3D s) { - css_subch_assign(s->cssid, s->ssid, old_schid, s->devno, NULL); - } - /* It's OK to re-assign without a prior de-assign. */ - css_subch_assign(s->cssid, s->ssid, s->schid, s->devno, s); - } - s->thinint_active =3D qemu_get_byte(f); - /* SCHIB */ - /* PMCW */ - s->curr_status.pmcw.intparm =3D qemu_get_be32(f); - s->curr_status.pmcw.flags =3D qemu_get_be16(f); - s->curr_status.pmcw.devno =3D qemu_get_be16(f); - s->curr_status.pmcw.lpm =3D qemu_get_byte(f); - s->curr_status.pmcw.pnom =3D qemu_get_byte(f); - s->curr_status.pmcw.lpum =3D qemu_get_byte(f); - s->curr_status.pmcw.pim =3D qemu_get_byte(f); - s->curr_status.pmcw.mbi =3D qemu_get_be16(f); - s->curr_status.pmcw.pom =3D qemu_get_byte(f); - s->curr_status.pmcw.pam =3D qemu_get_byte(f); - qemu_get_buffer(f, s->curr_status.pmcw.chpid, 8); - s->curr_status.pmcw.chars =3D qemu_get_be32(f); - /* SCSW */ - s->curr_status.scsw.flags =3D qemu_get_be16(f); - s->curr_status.scsw.ctrl =3D qemu_get_be16(f); - s->curr_status.scsw.cpa =3D qemu_get_be32(f); - s->curr_status.scsw.dstat =3D qemu_get_byte(f); - s->curr_status.scsw.cstat =3D qemu_get_byte(f); - s->curr_status.scsw.count =3D qemu_get_be16(f); - s->curr_status.mba =3D qemu_get_be64(f); - qemu_get_buffer(f, s->curr_status.mda, 4); - /* end SCHIB */ - qemu_get_buffer(f, s->sense_data, 32); - s->channel_prog =3D qemu_get_be64(f); - /* last cmd */ - s->last_cmd.cmd_code =3D qemu_get_byte(f); - s->last_cmd.flags =3D qemu_get_byte(f); - s->last_cmd.count =3D qemu_get_be16(f); - s->last_cmd.cda =3D qemu_get_be32(f); - s->last_cmd_valid =3D qemu_get_byte(f); - s->id.reserved =3D qemu_get_byte(f); - s->id.cu_type =3D qemu_get_be16(f); - s->id.cu_model =3D qemu_get_byte(f); - s->id.dev_type =3D qemu_get_be16(f); - s->id.dev_model =3D qemu_get_byte(f); - s->id.unused =3D qemu_get_byte(f); - for (i =3D 0; i < ARRAY_SIZE(s->id.ciw); i++) { - s->id.ciw[i].type =3D qemu_get_byte(f); - s->id.ciw[i].command =3D qemu_get_byte(f); - s->id.ciw[i].count =3D qemu_get_be16(f); - } - s->ccw_fmt_1 =3D qemu_get_byte(f); - s->ccw_no_data_cnt =3D qemu_get_byte(f); - /* - * Hack alert. We don't migrate the channel subsystem status (no - * device!), but we need to find out if the guest enabled mss/mcss-e. - * If the subchannel is enabled, it certainly was able to access it, - * so adjust the max_ssid/max_cssid values for relevant ssid/cssid - * values. This is not watertight, but better than nothing. - */ - if (s->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA) { - if (s->ssid) { - channel_subsys.max_ssid =3D MAX_SSID; - } - if (s->cssid !=3D channel_subsys.default_cssid) { - channel_subsys.max_cssid =3D MAX_CSSID; - } - } - return 0; -} - void css_reset_sch(SubchDev *sch) { PMCW *p =3D &sch->curr_status.pmcw; diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 90d37cb..f0e7fc8 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -34,9 +34,87 @@ #include "virtio-ccw.h" #include "trace.h" #include "hw/s390x/css-bridge.h" +#include "hw/s390x/s390-virtio-ccw.h" =20 #define NR_CLASSIC_INDICATOR_BITS 64 =20 +static int virtio_ccw_dev_post_load(void *opaque, int version_id) +{ + VirtioCcwDevice *dev =3D VIRTIO_CCW_DEVICE(opaque); + CcwDevice *ccw_dev =3D CCW_DEVICE(dev); + CCWDeviceClass *ck =3D CCW_DEVICE_GET_CLASS(ccw_dev); + + ccw_dev->sch->driver_data =3D dev; + if (ccw_dev->sch->thinint_active) { + dev->routes.adapter.adapter_id =3D css_get_adapter_id( + CSS_IO_ADAPTER_VIRTIO, + dev->thinint_isc); + } + /* Re-fill subch_id after loading the subchannel states.*/ + if (ck->refill_ids) { + ck->refill_ids(ccw_dev); + } + return 0; +} + +typedef struct VirtioCcwDeviceTmp { + VirtioCcwDevice *parent; + uint16_t config_vector; +} VirtioCcwDeviceTmp; + +static void virtio_ccw_dev_tmp_pre_save(void *opaque) +{ + VirtioCcwDeviceTmp *tmp =3D opaque; + VirtioCcwDevice *dev =3D tmp->parent; + VirtIODevice *vdev =3D virtio_bus_get_device(&dev->bus); + + tmp->config_vector =3D vdev->config_vector; +} + +static int virtio_ccw_dev_tmp_post_load(void *opaque, int version_id) +{ + VirtioCcwDeviceTmp *tmp =3D opaque; + VirtioCcwDevice *dev =3D tmp->parent; + VirtIODevice *vdev =3D virtio_bus_get_device(&dev->bus); + + vdev->config_vector =3D tmp->config_vector; + return 0; +} + +const VMStateDescription vmstate_virtio_ccw_dev_tmp =3D { + .name =3D "s390_virtio_ccw_dev_tmp", + .pre_save =3D virtio_ccw_dev_tmp_pre_save, + .post_load =3D virtio_ccw_dev_tmp_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT16(config_vector, VirtioCcwDeviceTmp), + VMSTATE_END_OF_LIST() + } +}; + +const VMStateDescription vmstate_virtio_ccw_dev =3D { + .name =3D "s390_virtio_ccw_dev", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D virtio_ccw_dev_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_CCW_DEVICE(parent_obj, VirtioCcwDevice), + VMSTATE_PTR_TO_IND_ADDR(indicators, VirtioCcwDevice), + VMSTATE_PTR_TO_IND_ADDR(indicators2, VirtioCcwDevice), + VMSTATE_PTR_TO_IND_ADDR(summary_indicator, VirtioCcwDevice), + /* + * Ugly hack because VirtIODevice does not migrate itself. + * This also makes legacy via vmstate_save_state possible. + */ + VMSTATE_WITH_TMP(VirtioCcwDevice, VirtioCcwDeviceTmp, + vmstate_virtio_ccw_dev_tmp), + VMSTATE_STRUCT(routes, VirtioCcwDevice, 1, vmstate_adapter_routes, + AdapterRoutes), + VMSTATE_UINT8(thinint_isc, VirtioCcwDevice), + VMSTATE_INT32(revision, VirtioCcwDevice), + VMSTATE_END_OF_LIST() + } +}; + static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size, VirtioCcwDevice *dev); =20 @@ -1239,89 +1317,13 @@ static int virtio_ccw_load_queue(DeviceState *d, in= t n, QEMUFile *f) static void virtio_ccw_save_config(DeviceState *d, QEMUFile *f) { VirtioCcwDevice *dev =3D VIRTIO_CCW_DEVICE(d); - CcwDevice *ccw_dev =3D CCW_DEVICE(d); - SubchDev *s =3D ccw_dev->sch; - VirtIODevice *vdev =3D virtio_ccw_get_vdev(s); - - subch_device_save(s, f); - if (dev->indicators !=3D NULL) { - qemu_put_be32(f, dev->indicators->len); - qemu_put_be64(f, dev->indicators->addr); - } else { - qemu_put_be32(f, 0); - qemu_put_be64(f, 0UL); - } - if (dev->indicators2 !=3D NULL) { - qemu_put_be32(f, dev->indicators2->len); - qemu_put_be64(f, dev->indicators2->addr); - } else { - qemu_put_be32(f, 0); - qemu_put_be64(f, 0UL); - } - if (dev->summary_indicator !=3D NULL) { - qemu_put_be32(f, dev->summary_indicator->len); - qemu_put_be64(f, dev->summary_indicator->addr); - } else { - qemu_put_be32(f, 0); - qemu_put_be64(f, 0UL); - } - qemu_put_be16(f, vdev->config_vector); - qemu_put_be64(f, dev->routes.adapter.ind_offset); - qemu_put_byte(f, dev->thinint_isc); - qemu_put_be32(f, dev->revision); + vmstate_save_state(f, &vmstate_virtio_ccw_dev, dev, NULL); } =20 static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f) { VirtioCcwDevice *dev =3D VIRTIO_CCW_DEVICE(d); - CcwDevice *ccw_dev =3D CCW_DEVICE(d); - CCWDeviceClass *ck =3D CCW_DEVICE_GET_CLASS(ccw_dev); - SubchDev *s =3D ccw_dev->sch; - VirtIODevice *vdev =3D virtio_ccw_get_vdev(s); - int len; - int ret; - - s->driver_data =3D dev; - ret =3D subch_device_load(s, f); - if (ret) { - return ret; - } - /* Re-fill subch_id after loading the subchannel states.*/ - if (ck->refill_ids) { - ck->refill_ids(ccw_dev); - } - len =3D qemu_get_be32(f); - if (len !=3D 0) { - dev->indicators =3D get_indicator(qemu_get_be64(f), len); - } else { - qemu_get_be64(f); - dev->indicators =3D NULL; - } - len =3D qemu_get_be32(f); - if (len !=3D 0) { - dev->indicators2 =3D get_indicator(qemu_get_be64(f), len); - } else { - qemu_get_be64(f); - dev->indicators2 =3D NULL; - } - len =3D qemu_get_be32(f); - if (len !=3D 0) { - dev->summary_indicator =3D get_indicator(qemu_get_be64(f), len); - } else { - qemu_get_be64(f); - dev->summary_indicator =3D NULL; - } - qemu_get_be16s(f, &vdev->config_vector); - dev->routes.adapter.ind_offset =3D qemu_get_be64(f); - dev->thinint_isc =3D qemu_get_byte(f); - dev->revision =3D qemu_get_be32(f); - if (s->thinint_active) { - dev->routes.adapter.adapter_id =3D css_get_adapter_id( - CSS_IO_ADAPTER_VIRTIO, - dev->thinint_isc); - } - - return 0; + return vmstate_load_state(f, &vmstate_virtio_ccw_dev, dev, 1); } =20 static void virtio_ccw_pre_plugged(DeviceState *d, Error **errp) diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index 596a2f2..eb0e26f 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -88,6 +88,7 @@ struct SubchDev { bool ccw_fmt_1; bool thinint_active; uint8_t ccw_no_data_cnt; + uint16_t migrated_schid; /* used for missmatch detection */ /* transport-provided data: */ int (*ccw_cb) (SubchDev *, CCW1); void (*disable_cb)(SubchDev *); @@ -96,6 +97,8 @@ struct SubchDev { void *driver_data; }; =20 +extern const VMStateDescription vmstate_subch_dev; + /* * Identify a device within the channel subsystem. * Note that this can be used to identify either the subchannel or @@ -118,18 +121,21 @@ typedef struct IndAddr { hwaddr addr; uint64_t map; unsigned long refcnt; - int len; + int32_t len; QTAILQ_ENTRY(IndAddr) sibling; } IndAddr; =20 +extern const VMStateDescription vmstate_ind_addr; + +#define VMSTATE_PTR_TO_IND_ADDR(_f, _s) \ + VMSTATE_STRUCT(_f, _s, 1, vmstate_ind_addr, IndAddr*) + IndAddr *get_indicator(hwaddr ind_addr, int len); void release_indicator(AdapterInfo *adapter, IndAddr *indicator); int map_indicator(AdapterInfo *adapter, IndAddr *indicator); =20 typedef SubchDev *(*css_subch_cb_func)(uint8_t m, uint8_t cssid, uint8_t s= sid, uint16_t schid); -void subch_device_save(SubchDev *s, QEMUFile *f); -int subch_device_load(SubchDev *s, QEMUFile *f); int css_create_css_image(uint8_t cssid, bool default_image); bool css_devno_used(uint8_t cssid, uint8_t ssid, uint16_t devno); void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid, diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h index f9e6890..caa6fc6 100644 --- a/include/hw/s390x/s390_flic.h +++ b/include/hw/s390x/s390_flic.h @@ -31,6 +31,11 @@ typedef struct AdapterRoutes { int gsi[ADAPTER_ROUTES_MAX_GSI]; } AdapterRoutes; =20 +extern const VMStateDescription vmstate_adapter_routes; + +#define VMSTATE_ADAPTER_ROUTES(_f, _s) \ + VMSTATE_STRUCT(_f, _s, 1, vmstate_adapter_routes, AdapterRoutes) + #define TYPE_S390_FLIC_COMMON "s390-flic" #define S390_FLIC_COMMON(obj) \ OBJECT_CHECK(S390FLICState, (obj), TYPE_S390_FLIC_COMMON) --=20 2.7.4 From nobody Sun May 5 02:48:05 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 1499177408650460.6181871258285; Tue, 4 Jul 2017 07:10:08 -0700 (PDT) Received: from localhost ([::1]:41601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOWi-0001XU-8M for importer@patchew.org; Tue, 04 Jul 2017 10:10:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOUt-00088g-IP for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSOUp-0003Wx-AS for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:11 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48993) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dSOUp-0003WI-0Q for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:07 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v64E4VDD000809 for ; Tue, 4 Jul 2017 10:08:06 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bg6j6jt07-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 04 Jul 2017 10:08:05 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jul 2017 15:08:03 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 4 Jul 2017 15:08:01 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v64E80S936175942; Tue, 4 Jul 2017 14:08:00 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 04BA011C054; Tue, 4 Jul 2017 15:05:38 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E62DA11C04C; Tue, 4 Jul 2017 15:05:37 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 4 Jul 2017 15:05:37 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 284A720F67C; Tue, 4 Jul 2017 16:08:00 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Tue, 4 Jul 2017 16:07:54 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> References: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17070414-0016-0000-0000-000004CE4793 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070414-0017-0000-0000-00002801A96E Message-Id: <1499177279-131407-3-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-04_09:, , 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-1703280000 definitions=main-1707040241 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 2/7] s390x/3270: fix instruction interception handler 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: Christian Borntraeger , Dong Jia Shi , Cornelia Huck , Alexander Graf , 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: Dong Jia Shi Commit bab482d7405f ("s390x/css: ccw translation infrastructure") introduced instruction interception handler for different types of subchannels. For emulated 3270 devices, we should assign the virtual subchannel handler to them during device realization process, or 3270 will not work. Fixes: bab482d7405f ("s390x/css: ccw translation infrastructure") Reviewed-by: Jing Liu Reviewed-by: Halil Pasic Signed-off-by: Dong Jia Shi Signed-off-by: Christian Borntraeger Reviewed-by: Cornelia Huck --- hw/s390x/3270-ccw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/s390x/3270-ccw.c b/hw/s390x/3270-ccw.c index 6e6eee4..1554aa2 100644 --- a/hw/s390x/3270-ccw.c +++ b/hw/s390x/3270-ccw.c @@ -126,6 +126,7 @@ static void emulated_ccw_3270_realize(DeviceState *ds, = Error **errp) sch->id.cu_type =3D EMULATED_CCW_3270_CU_TYPE; css_sch_build_virtual_schib(sch, (uint8_t)chpid, EMULATED_CCW_3270_CHPID_TYPE); + sch->do_subchannel_work =3D do_subchannel_work_virtual; sch->ccw_cb =3D emulated_ccw_3270_cb; =20 ck->init(dev, &err); --=20 2.7.4 From nobody Sun May 5 02:48:05 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 149917740956062.64182753580167; Tue, 4 Jul 2017 07:10:09 -0700 (PDT) Received: from localhost ([::1]:41603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOWj-0001Yf-7J for importer@patchew.org; Tue, 04 Jul 2017 10:10:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOUt-00088j-W9 for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSOUp-0003XI-Ti for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:12 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53349) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dSOUp-0003Wi-Jh for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:07 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v64E4VgZ134827 for ; Tue, 4 Jul 2017 10:08:06 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bg8uv0vv4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 04 Jul 2017 10:08:05 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jul 2017 15:08:03 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 4 Jul 2017 15:08:01 +0100 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 v64E80SE38338624; Tue, 4 Jul 2017 14:08:00 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15C49A405B; Tue, 4 Jul 2017 15:05:28 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 04380A404D; Tue, 4 Jul 2017 15:05:28 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 4 Jul 2017 15:05:27 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 6A43620F67D; Tue, 4 Jul 2017 16:08:00 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Tue, 4 Jul 2017 16:07:55 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> References: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17070414-0016-0000-0000-000004CE4796 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070414-0017-0000-0000-00002801A96F Message-Id: <1499177279-131407-4-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-04_09:, , 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-1703280000 definitions=main-1707040241 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 3/7] s390x: fix error propagation in kvm-flic's realize 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: Christian Borntraeger , Halil Pasic , Cornelia Huck , Alexander Graf , 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: Halil Pasic From the moment it was introduced by commit a2875e6f98 ("s390x/kvm: implement floating-interrupt controller device", 2013-07-16) the kvm-flic is not making realize fail properly in case it's impossible to create the KVM device which basically serves as a backend and is absolutely essential for having an operational kvm-flic. Let's fix this by making sure we do proper error propagation in realize. Signed-off-by: Halil Pasic Fixes: a2875e6f98 "s390x/kvm: implement floating-interrupt controller devic= e" Reviewed-by: Dong Jia Shi Reviewed-by: Yi Min Zhao Signed-off-by: Christian Borntraeger --- hw/intc/s390_flic_kvm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index b4c61d8..bea3997 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -15,6 +15,7 @@ #include "cpu.h" #include #include "qemu/error-report.h" +#include "qapi/error.h" #include "hw/sysbus.h" #include "sysemu/kvm.h" #include "hw/s390x/s390_flic.h" @@ -397,18 +398,22 @@ static void kvm_s390_flic_realize(DeviceState *dev, E= rror **errp) struct kvm_create_device cd =3D {0}; struct kvm_device_attr test_attr =3D {0}; int ret; + Error *errp_local =3D NULL; =20 flic_state->fd =3D -1; if (!kvm_check_extension(kvm_state, KVM_CAP_DEVICE_CTRL)) { + error_setg_errno(&errp_local, errno, "KVM is missing capability" + " KVM_CAP_DEVICE_CTRL"); trace_flic_no_device_api(errno); - return; + goto fail; } =20 cd.type =3D KVM_DEV_TYPE_FLIC; ret =3D kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd); if (ret < 0) { - trace_flic_create_device(errno); - return; + error_setg_errno(&errp_local, errno, "Creating the KVM device fail= ed"); + trace_flic_no_device_api(errno); + goto fail; } flic_state->fd =3D cd.fd; =20 @@ -417,6 +422,9 @@ static void kvm_s390_flic_realize(DeviceState *dev, Err= or **errp) flic_state->clear_io_supported =3D !ioctl(flic_state->fd, KVM_HAS_DEVICE_ATTR, test_attr= ); =20 + return; +fail: + error_propagate(errp, errp_local); } =20 static void kvm_s390_flic_reset(DeviceState *dev) --=20 2.7.4 From nobody Sun May 5 02:48:05 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 149917740823769.81076603708163; Tue, 4 Jul 2017 07:10:08 -0700 (PDT) Received: from localhost ([::1]:41602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOWi-0001Xk-KN for importer@patchew.org; Tue, 04 Jul 2017 10:10:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOUt-00088i-Vy for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSOUp-0003XO-V4 for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:11 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49034) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dSOUp-0003Wk-Kc for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:07 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v64E4VIQ000778 for ; Tue, 4 Jul 2017 10:08:06 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bg6j6jt12-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 04 Jul 2017 10:08:06 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jul 2017 15:08:03 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 4 Jul 2017 15:08:01 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v64E815I5046670; Tue, 4 Jul 2017 14:08:01 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B4124C044; Tue, 4 Jul 2017 15:05:52 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 140924C04E; Tue, 4 Jul 2017 15:05:52 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 4 Jul 2017 15:05:52 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id A9A9120F67C; Tue, 4 Jul 2017 16:08:00 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Tue, 4 Jul 2017 16:07:56 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> References: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17070414-0012-0000-0000-0000055E43EA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070414-0013-0000-0000-000018D0A7DB Message-Id: <1499177279-131407-5-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-04_09:, , 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-1703280000 definitions=main-1707040241 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 4/7] s390x: fix realize inheritance for kvm-flic 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: Christian Borntraeger , Halil Pasic , Cornelia Huck , Alexander Graf , 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: Halil Pasic Commit f6f4ce4211 ("s390x: add property adapter_routes_max_batch", 2016-12-09) introduces a common realize (intended to be common for all the subclasses) for flic, but fails to make sure the kvm-flic which had it's own is actually calling this common realize. This omission fortunately does not result in a grave problem. The common realize was only supposed to catch a possible programming mistake by validating a value of a property set via the compat machine macros. Since there was no programming mistake we don't need this fixed for stable. Let's fix this problem by making sure kvm flic honors the realize of its parent class. Let us also improve on the error message we would hypothetically emit when the validation fails. Signed-off-by: Halil Pasic Fixes: f6f4ce4211 ("s390x: add property adapter_routes_max_batch") Reviewed-by: Dong Jia Shi Reviewed-by: Yi Min Zhao Signed-off-by: Christian Borntraeger Reviewed-by: Cornelia Huck --- hw/intc/s390_flic.c | 4 ++-- hw/intc/s390_flic_kvm.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index a99a350..837158b 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -101,8 +101,8 @@ static void s390_flic_common_realize(DeviceState *dev, = Error **errp) uint32_t max_batch =3D S390_FLIC_COMMON(dev)->adapter_routes_max_batch; =20 if (max_batch > ADAPTER_ROUTES_MAX_GSI) { - error_setg(errp, "flic adapter_routes_max_batch too big" - "%d (%d allowed)", 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); } } =20 diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index bea3997..535d99d 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -392,6 +392,17 @@ static const VMStateDescription kvm_s390_flic_vmstate = =3D { } }; =20 +typedef struct KVMS390FLICStateClass { + S390FLICStateClass parent_class; + DeviceRealize parent_realize; +} KVMS390FLICStateClass; + +#define KVM_S390_FLIC_GET_CLASS(obj) \ + OBJECT_GET_CLASS(KVMS390FLICStateClass, (obj), TYPE_KVM_S390_FLIC) + +#define KVM_S390_FLIC_CLASS(klass) \ + OBJECT_CLASS_CHECK(KVMS390FLICStateClass, (klass), TYPE_KVM_S390_FLIC) + static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) { KVMS390FLICState *flic_state =3D KVM_S390_FLIC(dev); @@ -400,6 +411,10 @@ static void kvm_s390_flic_realize(DeviceState *dev, Er= ror **errp) int ret; Error *errp_local =3D NULL; =20 + KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &errp_local); + if (errp_local) { + goto fail; + } flic_state->fd =3D -1; if (!kvm_check_extension(kvm_state, KVM_CAP_DEVICE_CTRL)) { error_setg_errno(&errp_local, errno, "KVM is missing capability" @@ -454,6 +469,7 @@ static void kvm_s390_flic_class_init(ObjectClass *oc, v= oid *data) DeviceClass *dc =3D DEVICE_CLASS(oc); S390FLICStateClass *fsc =3D S390_FLIC_COMMON_CLASS(oc); =20 + KVM_S390_FLIC_CLASS(oc)->parent_realize =3D dc->realize; dc->realize =3D kvm_s390_flic_realize; dc->vmsd =3D &kvm_s390_flic_vmstate; dc->reset =3D kvm_s390_flic_reset; @@ -468,6 +484,7 @@ static const TypeInfo kvm_s390_flic_info =3D { .name =3D TYPE_KVM_S390_FLIC, .parent =3D TYPE_S390_FLIC_COMMON, .instance_size =3D sizeof(KVMS390FLICState), + .class_size =3D sizeof(KVMS390FLICStateClass), .class_init =3D kvm_s390_flic_class_init, }; =20 --=20 2.7.4 From nobody Sun May 5 02:48:05 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 1499177407907871.6956331007672; Tue, 4 Jul 2017 07:10:07 -0700 (PDT) Received: from localhost ([::1]:41600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOWi-0001X0-Bi for importer@patchew.org; Tue, 04 Jul 2017 10:10:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOUs-00088d-Qr for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSOUo-0003Wd-Ox for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:10 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38312 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 1dSOUo-0003W8-IZ for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:06 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v64E4UUw109315 for ; Tue, 4 Jul 2017 10:08:05 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 2bg6gdjp8k-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 04 Jul 2017 10:08:05 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jul 2017 15:08:04 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 4 Jul 2017 15:08:01 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v64E81kB28377164; Tue, 4 Jul 2017 14:08:01 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 887B242049; Tue, 4 Jul 2017 15:05:32 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7780F42045; Tue, 4 Jul 2017 15:05:32 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 4 Jul 2017 15:05:32 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id EE11720F67D; Tue, 4 Jul 2017 16:08:00 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Tue, 4 Jul 2017 16:07:57 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> References: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17070414-0012-0000-0000-0000055E43E9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070414-0013-0000-0000-000018D0A7DE Message-Id: <1499177279-131407-6-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-04_09:, , 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-1703280000 definitions=main-1707040241 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 5/7] s390x/MAINTAINERS: Update my email address 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: Christian Borntraeger , Cornelia Huck , Alexander Graf , 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: Cornelia Huck Signed-off-by: Cornelia Huck Message-Id: <20170704092215.13742-2-cohuck@redhat.com> Signed-off-by: Christian Borntraeger --- MAINTAINERS | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 839f7ca..4e17216 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -299,7 +299,7 @@ F: target/ppc/kvm.c =20 S390 M: Christian Borntraeger -M: Cornelia Huck +M: Cornelia Huck M: Alexander Graf S: Maintained F: target/s390x/kvm.c @@ -778,7 +778,7 @@ F: include/hw/sparc/grlib.h S390 Machines ------------- S390 Virtio-ccw -M: Cornelia Huck +M: Cornelia Huck M: Christian Borntraeger M: Alexander Graf S: Supported @@ -1006,7 +1006,7 @@ F: hw/vfio/* F: include/hw/vfio/ =20 vfio-ccw -M: Cornelia Huck +M: Cornelia Huck S: Supported F: hw/vfio/ccw.c F: hw/s390x/s390-ccw.c @@ -1048,7 +1048,7 @@ F: tests/virtio-blk-test.c T: git git://github.com/stefanha/qemu.git block =20 virtio-ccw -M: Cornelia Huck +M: Cornelia Huck M: Christian Borntraeger S: Supported F: hw/s390x/virtio-ccw.[hc] --=20 2.7.4 From nobody Sun May 5 02:48:05 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 1499177543138636.915881885848; Tue, 4 Jul 2017 07:12:23 -0700 (PDT) Received: from localhost ([::1]:41615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOYt-0003Xc-MQ for importer@patchew.org; Tue, 04 Jul 2017 10:12:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOUw-00089q-GV for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSOUq-0003Xg-B8 for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:14 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35306) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dSOUq-0003X1-1w for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:08 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v64E4WQo111361 for ; Tue, 4 Jul 2017 10:08:07 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bg9h65kgx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 04 Jul 2017 10:08:06 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jul 2017 15:08:04 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 4 Jul 2017 15:08:02 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v64E81QF64553032; Tue, 4 Jul 2017 14:08:01 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AF2304C050; Tue, 4 Jul 2017 15:05:52 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 97D2F4C046; Tue, 4 Jul 2017 15:05:52 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 4 Jul 2017 15:05:52 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 3BD3320F67C; Tue, 4 Jul 2017 16:08:01 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Tue, 4 Jul 2017 16:07:58 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> References: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17070414-0008-0000-0000-000004784352 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070414-0009-0000-0000-00001E029E75 Message-Id: <1499177279-131407-7-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-04_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1707040241 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 6/7] s390x: return unavailable features via query-cpu-definitions 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: Christian Borntraeger , Viktor Mihajlovski , Cornelia Huck , Alexander Graf , 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: Viktor Mihajlovski The response for query-cpu-definitions didn't include the unavailable-features field, which is used by libvirt to figure out whether a certain cpu model is usable on the host. The unavailable features are now computed by obtaining the host CPU model and comparing it against the known CPU models. The comparison takes into account the generation, the GA level and the feature bitmaps. In the case of a CPU generation/GA level mismatch a feature called "type" is reported to be missing. As a result, the output of virsh domcapabilities would change from something like ... z10EC-base z9EC-base z196.2-base z900-base z990 ... to ... z10EC-base z9EC-base z196.2-base z900-base z990 ... Signed-off-by: Viktor Mihajlovski Message-Id: <1499082529-16970-1-git-send-email-mihajlov@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand Signed-off-by: Christian Borntraeger Acked-by: Cornelia Huck --- target/s390x/cpu_models.c | 62 +++++++++++++++++++++++++++++++++++++++++++= ---- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 63903c2..7cb55dc 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -283,10 +283,41 @@ void s390_cpu_list(FILE *f, fprintf_function print) } } =20 +static S390CPUModel *get_max_cpu_model(Error **errp); + #ifndef CONFIG_USER_ONLY +static void list_add_feat(const char *name, void *opaque); + +static void check_unavailable_features(const S390CPUModel *max_model, + const S390CPUModel *model, + strList **unavailable) +{ + S390FeatBitmap missing; + + /* check general model compatibility */ + if (max_model->def->gen < model->def->gen || + (max_model->def->gen =3D=3D model->def->gen && + max_model->def->ec_ga < model->def->ec_ga)) { + list_add_feat("type", unavailable); + } + + /* detect missing features if any to properly report them */ + bitmap_andnot(missing, model->features, max_model->features, + S390_FEAT_MAX); + if (!bitmap_empty(missing, S390_FEAT_MAX)) { + s390_feat_bitmap_to_ascii(missing, unavailable, list_add_feat); + } +} + +struct CpuDefinitionInfoListData { + CpuDefinitionInfoList *list; + S390CPUModel *model; +}; + static void create_cpu_model_list(ObjectClass *klass, void *opaque) { - CpuDefinitionInfoList **cpu_list =3D opaque; + struct CpuDefinitionInfoListData *cpu_list_data =3D opaque; + CpuDefinitionInfoList **cpu_list =3D &cpu_list_data->list; CpuDefinitionInfoList *entry; CpuDefinitionInfo *info; char *name =3D g_strdup(object_class_get_name(klass)); @@ -300,7 +331,19 @@ static void create_cpu_model_list(ObjectClass *klass, = void *opaque) info->migration_safe =3D scc->is_migration_safe; info->q_static =3D scc->is_static; info->q_typename =3D g_strdup(object_class_get_name(klass)); - + /* check for unavailable features */ + if (cpu_list_data->model) { + Object *obj; + S390CPU *sc; + obj =3D object_new(object_class_get_name(klass)); + sc =3D S390_CPU(obj); + if (sc->model) { + info->has_unavailable_features =3D true; + check_unavailable_features(cpu_list_data->model, sc->model, + &info->unavailable_features); + } + object_unref(obj); + } =20 entry =3D g_malloc0(sizeof(*entry)); entry->value =3D info; @@ -310,11 +353,20 @@ static void create_cpu_model_list(ObjectClass *klass,= void *opaque) =20 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) { - CpuDefinitionInfoList *list =3D NULL; + struct CpuDefinitionInfoListData list_data =3D { + .list =3D NULL, + }; =20 - object_class_foreach(create_cpu_model_list, TYPE_S390_CPU, false, &lis= t); + list_data.model =3D get_max_cpu_model(errp); + if (*errp) { + error_free(*errp); + *errp =3D NULL; + } =20 - return list; + object_class_foreach(create_cpu_model_list, TYPE_S390_CPU, false, + &list_data); + + return list_data.list; } =20 static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *i= nfo, --=20 2.7.4 From nobody Sun May 5 02:48:05 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 1499177546513495.0725769577974; Tue, 4 Jul 2017 07:12:26 -0700 (PDT) Received: from localhost ([::1]:41613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOYs-0003Wb-H7 for importer@patchew.org; Tue, 04 Jul 2017 10:12:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSOUt-00088h-Vu for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSOUq-0003Y2-PG for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:11 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56056 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 1dSOUq-0003XZ-Jc for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:08:08 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v64E4Xhd051707 for ; Tue, 4 Jul 2017 10:08:08 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bfqtj1k58-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 04 Jul 2017 10:08:07 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jul 2017 15:08:06 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 4 Jul 2017 15:08:02 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v64E81xx64094264; Tue, 4 Jul 2017 14:08:01 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4ADC4C059; Tue, 4 Jul 2017 15:05:52 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D381E4C050; Tue, 4 Jul 2017 15:05:52 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 4 Jul 2017 15:05:52 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 748FB20F67D; Tue, 4 Jul 2017 16:08:01 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Tue, 4 Jul 2017 16:07:59 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> References: <1499177279-131407-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17070414-0012-0000-0000-0000055E43EC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070414-0013-0000-0000-000018D0A7E0 Message-Id: <1499177279-131407-8-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-04_09:, , 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-1703280000 definitions=main-1707040241 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 7/7] virtio-scsi-ccw: use ioeventfd even when KVM is disabled 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: QingFeng Hao , Cornelia Huck , Alexander Graf , Christian Borntraeger , 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: QingFeng Hao This patch is based on a similar patch from Stefan Hajnoczi - commit c324fd0a39c ("virtio-pci: use ioeventfd even when KVM is disabled") Do not check kvm_eventfds_enabled() when KVM is disabled since it always returns 0. Since commit 8c56c1a592b5092d91da8d8943c17777d6462a6f ("memory: emulate ioeventfd") it has been possible to use ioeventfds in qtest or TCG mode. This patch makes -device virtio-scsi-ccw,iothread=3Diothread0 work even when KVM is disabled. Currently we don't have an equivalent to "memory: emulate ioeventfd" for ccw yet, but that this doesn't hurt and qemu-iotests 068 can pass with skipping iothread arguments. I have tested that virtio-scsi-ccw works under tcg both with and without iothread. This patch fixes qemu-iotests 068, which was accidentally merged early despite the dependency on ioeventfd. Signed-off-by: QingFeng Hao Reviewed-by: Cornelia Huck Message-Id: <20170704132350.11874-2-haoqf@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger --- hw/s390x/virtio-ccw.c | 2 +- target/s390x/cpu.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index f0e7fc8..e18fd26 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -789,7 +789,7 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *= dev, Error **errp) sch->cssid, sch->ssid, sch->schid, sch->devno, ccw_dev->devno.valid ? "user-configured" : "auto-configured"); =20 - if (!kvm_eventfds_enabled()) { + if (kvm_enabled() && !kvm_eventfds_enabled()) { dev->flags &=3D ~VIRTIO_CCW_FLAG_USE_IOEVENTFD; } =20 diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 9faca04..bdb9bdb 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -1264,7 +1264,11 @@ static inline int s390_assign_subch_ioeventfd(EventN= otifier *notifier, uint32_t sch_id, int vq, bool assign) { - return kvm_s390_assign_subch_ioeventfd(notifier, sch_id, vq, assign); + if (kvm_enabled()) { + return kvm_s390_assign_subch_ioeventfd(notifier, sch_id, vq, assig= n); + } else { + return 0; + } } =20 static inline void s390_crypto_reset(void) --=20 2.7.4