From nobody Sun Apr 28 21:32:26 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.zoho.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 1496066247104993.937180300537; Mon, 29 May 2017 06:57:27 -0700 (PDT) Received: from localhost ([::1]:48902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFLAj-0000q3-Ag for importer@patchew.org; Mon, 29 May 2017 09:57:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFL8z-00087x-Pp for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFL8v-0005Bu-Qb for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:37 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:32823) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFL8v-0005BW-Dp for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:33 -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 v4TDrV4I130409 for ; Mon, 29 May 2017 09:55:31 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2arf3hpt4c-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 29 May 2017 09:55:31 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 May 2017 14:55:28 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 29 May 2017 14:55:27 +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 v4TDtQNG38010964; Mon, 29 May 2017 13:55:26 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC87B5203F; Mon, 29 May 2017 13:52:25 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 6EE0E52041; Mon, 29 May 2017 13:52:25 +0100 (BST) From: Halil Pasic To: Cornelia Huck , "Dr. David Alan Gilbert" Date: Mon, 29 May 2017 15:55:14 +0200 X-Mailer: git-send-email 2.11.2 In-Reply-To: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> References: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17052913-0008-0000-0000-000004574A4F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052913-0009-0000-0000-00001DD8AD47 Message-Id: <20170529135520.101429-2-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-29_10:, , 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-1705290259 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/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: Dong Jia Shi , Halil Pasic , qemu-devel@nongnu.org, Juan Quintela 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" 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 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 --- Note: Do not review this here! There is a stand alone patch on the list. Having this here is to is just for convenience. --- hw/intc/s390_flic.c | 28 ++++ hw/s390x/ccw-device.c | 10 ++ hw/s390x/ccw-device.h | 4 + hw/s390x/css.c | 361 ++++++++++++++++++++++++++-------------= ---- hw/s390x/virtio-ccw.c | 154 +++++++++--------- include/hw/s390x/css.h | 12 +- include/hw/s390x/s390_flic.h | 5 + 7 files changed, 354 insertions(+), 220 deletions(-) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index 711c11454f..7e7546a576 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -18,6 +18,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) { @@ -137,3 +138,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 fb8d640a7e..f9bfa154d6 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 89c8e5dff7..4e6af287e7 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 15c4f4b249..15517a16e4 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -20,6 +20,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; @@ -38,6 +39,177 @@ 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 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), + VMSTATE_UINT8_EQUAL(ssid, SubchDev), + VMSTATE_UINT16(migrated_schid, SubchDev), + VMSTATE_UINT16(devno, SubchDev), + 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]; @@ -75,6 +247,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; @@ -1662,149 +1880,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; - uint16_t old_schid =3D s->schid; - 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); - /* 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 e7167e3d05..a75eedeffb 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_DEVICE(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 @@ -1234,85 +1312,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; - - s->driver_data =3D dev; - subch_device_load(s, f); - /* 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 e61fa74d9b..d74e44d312 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 *); @@ -95,22 +96,27 @@ struct SubchDev { void *driver_data; }; =20 +extern const VMStateDescription vmstate_subch_dev; + 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 f9e6890c90..caa6fc608d 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.11.2 From nobody Sun Apr 28 21:32:26 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.zoho.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 1496066238218511.125582007705; Mon, 29 May 2017 06:57:18 -0700 (PDT) Received: from localhost ([::1]:48899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFLAa-0000ip-97 for importer@patchew.org; Mon, 29 May 2017 09:57:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFL8z-00087w-3w for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFL8v-0005Bg-8o for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:37 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57808 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 1dFL8v-0005BX-2h for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:33 -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 v4TDrUP9012237 for ; Mon, 29 May 2017 09:55:32 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2arha4gt24-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 29 May 2017 09:55:31 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 May 2017 14:55:30 +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; Mon, 29 May 2017 14:55:28 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4TDtRrD33030150; Mon, 29 May 2017 13:55:27 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D53F852041; Mon, 29 May 2017 13:52:26 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id AC70B5204B; Mon, 29 May 2017 13:52:26 +0100 (BST) From: Halil Pasic To: Cornelia Huck , "Dr. David Alan Gilbert" Date: Mon, 29 May 2017 15:55:15 +0200 X-Mailer: git-send-email 2.11.2 In-Reply-To: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> References: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17052913-0012-0000-0000-0000053C862A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052913-0013-0000-0000-000018A4D17C Message-Id: <20170529135520.101429-3-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-29_10:, , 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-1705290259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v2 2/7] s390x: add helper get_machine_class 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: Dong Jia Shi , Halil Pasic , qemu-devel@nongnu.org, Juan Quintela 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" We will need the machine class at machine initialization time, so the usual way via qdev won't do. Let's cache the machine class and also use the default values of the base machine for capability discovery. Signed-off-by: Halil Pasic Acked-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 46 +++++++++++++++++++++++-------------------= ---- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index fdd4384ff0..04148916ed 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -242,36 +242,35 @@ static inline void machine_set_dea_key_wrap(Object *o= bj, bool value, ms->dea_key_wrap =3D value; } =20 -bool ri_allowed(void) -{ - if (kvm_enabled()) { - MachineClass *mc =3D MACHINE_GET_CLASS(qdev_get_machine()); - if (object_class_dynamic_cast(OBJECT_CLASS(mc), - TYPE_S390_CCW_MACHINE)) { - S390CcwMachineClass *s390mc =3D S390_MACHINE_CLASS(mc); +static S390CcwMachineClass *current_mc; =20 - return s390mc->ri_allowed; - } +static S390CcwMachineClass *get_machine_class(void) +{ + if (unlikely(!current_mc)) { /* - * Make sure the "none" machine can have ri, otherwise it won't * = be - * unlocked in KVM and therefore the host CPU model might be wrong. - */ - return true; + * No s390 ccw machine was instantiated, we are likely to + * be called for the 'none' machine. The properties will + * have their after-initialization values. + */ + current_mc =3D S390_MACHINE_CLASS( + object_class_by_name(TYPE_S390_CCW_MACHINE)); } - return 0; + return current_mc; } =20 -bool cpu_model_allowed(void) +bool ri_allowed(void) { - MachineClass *mc =3D MACHINE_GET_CLASS(qdev_get_machine()); - if (object_class_dynamic_cast(OBJECT_CLASS(mc), - TYPE_S390_CCW_MACHINE)) { - S390CcwMachineClass *s390mc =3D S390_MACHINE_CLASS(mc); - - return s390mc->cpu_model_allowed; + if (!kvm_enabled()) { + return false; } - /* allow CPU model qmp queries with the "none" machine */ - return true; + /* for "none" machine this results in true */ + return get_machine_class()->ri_allowed; +} + +bool cpu_model_allowed(void) +{ + /* for "none" machine this results in true */ + return get_machine_class()->cpu_model_allowed; } =20 static char *machine_get_loadparm(Object *obj, Error **errp) @@ -360,6 +359,7 @@ static const TypeInfo ccw_machine_info =3D { static void ccw_machine_##suffix##_instance_init(Object *obj) = \ { = \ MachineState *machine =3D MACHINE(obj); = \ + current_mc =3D S390_MACHINE_CLASS(MACHINE_GET_CLASS(machine)); = \ ccw_machine_##suffix##_instance_options(machine); = \ } = \ static const TypeInfo ccw_machine_##suffix##_info =3D { = \ --=20 2.11.2 From nobody Sun Apr 28 21:32:26 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.zoho.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 149606637096612.942734486927634; Mon, 29 May 2017 06:59:30 -0700 (PDT) Received: from localhost ([::1]:48908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFLCj-0002tX-IT for importer@patchew.org; Mon, 29 May 2017 09:59:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFL92-00088Z-C3 for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFL8y-0005CV-GH for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:40 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33849) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFL8y-0005CG-6S for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:36 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4TDrX0Q078409 for ; Mon, 29 May 2017 09:55:35 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2aqg1pf3kw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 29 May 2017 09:55:34 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 May 2017 14:55:32 +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; Mon, 29 May 2017 14:55:29 +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 v4TDtT7o7602456; Mon, 29 May 2017 13:55:29 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D6FC52052; Mon, 29 May 2017 13:52:28 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id DF45252051; Mon, 29 May 2017 13:52:27 +0100 (BST) From: Halil Pasic To: Cornelia Huck , "Dr. David Alan Gilbert" Date: Mon, 29 May 2017 15:55:16 +0200 X-Mailer: git-send-email 2.11.2 In-Reply-To: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> References: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17052913-0008-0000-0000-000004574A53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052913-0009-0000-0000-00001DD8AD51 Message-Id: <20170529135520.101429-4-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-29_10:, , 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-1705290259 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 3/7] s390x: add css_migration_enabled to machine class 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: Dong Jia Shi , Halil Pasic , qemu-devel@nongnu.org, Juan Quintela 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" Currently the migration of the channel subsystem (css) is only partial and is done by the virtio ccw proxies -- the only migratable css devices existing at the moment. With the current work on emulated and passthrough devices we need to decouple the migration of the channel subsystem state from virtio ccw, and have a separate section for it. A new section however necessarily breaks the migration compatibility. So let us introduce a switch at the machine class, and put it in 'off' state for now. We will turn the switch 'on' for future machines once all preparations are met. For compatibility machines the switch will stay 'off'. Signed-off-by: Halil Pasic Acked-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 13 +++++++++++++ include/hw/s390x/s390-virtio-ccw.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 04148916ed..95256d3982 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -196,6 +196,7 @@ static void ccw_machine_class_init(ObjectClass *oc, voi= d *data) =20 s390mc->ri_allowed =3D true; s390mc->cpu_model_allowed =3D true; + s390mc->css_migration_enabled =3D false; /* TODO: set to true */ mc->init =3D ccw_init; mc->reset =3D s390_machine_reset; mc->hot_add_cpu =3D s390_hot_add_cpu; @@ -344,6 +345,11 @@ static const TypeInfo ccw_machine_info =3D { }, }; =20 +bool css_migration_enabled(void) +{ + return get_machine_class()->css_migration_enabled; +} + #define DEFINE_CCW_MACHINE(suffix, verstr, latest) = \ static void ccw_machine_##suffix##_class_init(ObjectClass *oc, = \ void *data) = \ @@ -445,6 +451,10 @@ static const TypeInfo ccw_machine_info =3D { =20 static void ccw_machine_2_10_instance_options(MachineState *machine) { + /* + * TODO Once preparations are done register vmstate for the css if + * css_migration_enabled(). + */ } =20 static void ccw_machine_2_10_class_options(MachineClass *mc) @@ -459,8 +469,11 @@ static void ccw_machine_2_9_instance_options(MachineSt= ate *machine) =20 static void ccw_machine_2_9_class_options(MachineClass *mc) { + S390CcwMachineClass *s390mc =3D S390_MACHINE_CLASS(mc); + ccw_machine_2_10_class_options(mc); SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_9); + s390mc->css_migration_enabled =3D false; } DEFINE_CCW_MACHINE(2_9, "2.9", false); =20 diff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-vir= tio-ccw.h index 7b8a3e4d74..e9c4f4182b 100644 --- a/include/hw/s390x/s390-virtio-ccw.h +++ b/include/hw/s390x/s390-virtio-ccw.h @@ -38,6 +38,7 @@ typedef struct S390CcwMachineClass { /*< public >*/ bool ri_allowed; bool cpu_model_allowed; + bool css_migration_enabled; } S390CcwMachineClass; =20 /* runtime-instrumentation allowed by the machine */ @@ -45,4 +46,10 @@ bool ri_allowed(void); /* cpu model allowed by the machine */ bool cpu_model_allowed(void); =20 +/** + * Returns true if (vmstate based) migration of the channel subsystem + * is enabled, false if it is disabled. + */ +bool css_migration_enabled(void); + #endif --=20 2.11.2 From nobody Sun Apr 28 21:32:26 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.zoho.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 1496066241633267.5308597735826; Mon, 29 May 2017 06:57:21 -0700 (PDT) Received: from localhost ([::1]:48900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFLAe-0000mJ-5E for importer@patchew.org; Mon, 29 May 2017 09:57:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFL90-00087z-NM for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFL8z-0005Ce-6l for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59228) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFL8y-0005CN-T5 for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:37 -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 v4TDrVnx067503 for ; Mon, 29 May 2017 09:55:35 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2arfakp4mn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 29 May 2017 09:55:35 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 May 2017 14:55:33 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 29 May 2017 14:55:30 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4TDtUHa20775398; Mon, 29 May 2017 13:55:30 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 505DA5204F; Mon, 29 May 2017 13:52:29 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 1DE3D52051; Mon, 29 May 2017 13:52:29 +0100 (BST) From: Halil Pasic To: Cornelia Huck , "Dr. David Alan Gilbert" Date: Mon, 29 May 2017 15:55:17 +0200 X-Mailer: git-send-email 2.11.2 In-Reply-To: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> References: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17052913-0008-0000-0000-000004574A57 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052913-0009-0000-0000-00001DD8AD56 Message-Id: <20170529135520.101429-5-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-29_10:, , 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-1705290259 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 4/7] s390x/css: add missing css state conditionally 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: Dong Jia Shi , Halil Pasic , qemu-devel@nongnu.org, Juan Quintela 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" Although we have recently vmstatified the migration of some css infrastructure, for some css entities there is still state to be migrated left, because the focus was keeping migration stream compatibility (that is basically everything as-is). Let us add vmstate helpers and extend existing vmstate descriptions so that we have everything we need. Let us guard the added state with via css_migration_enabled, so we keep the compatible behavior if css migration is disabled. Let's also annotate the bits which do not need to be migrated for better readability. Signed-off-by: Halil Pasic Reviewed-by: Cornelia Huck Reviewed-by: Juan Quintela --- hw/intc/s390_flic.c | 20 +++++++++++++++ hw/s390x/css.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 94 insertions(+) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index 7e7546a576..b889e74571 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -139,6 +139,22 @@ static void qemu_s390_flic_register_types(void) =20 type_init(qemu_s390_flic_register_types) =20 +static bool adapter_info_so_needed(void *opaque) +{ + return css_migration_enabled(); +} + +const VMStateDescription vmstate_adapter_info_so =3D { + .name =3D "s390_adapter_info/summary_offset", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D adapter_info_so_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(summary_offset, AdapterInfo), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_adapter_info =3D { .name =3D "s390_adapter_info", .version_id =3D 1, @@ -152,6 +168,10 @@ const VMStateDescription vmstate_adapter_info =3D { */ VMSTATE_END_OF_LIST() }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_adapter_info_so, + NULL + } }; =20 const VMStateDescription vmstate_adapter_routes =3D { diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 15517a16e4..a15b58d303 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -27,12 +27,45 @@ typedef struct CrwContainer { QTAILQ_ENTRY(CrwContainer) sibling; } CrwContainer; =20 +static const VMStateDescription vmstate_crw =3D { + .name =3D "s390_crw", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT16(flags, CRW), + VMSTATE_UINT16(rsid, CRW), + VMSTATE_END_OF_LIST() + }, +}; + +static const VMStateDescription vmstate_crw_container =3D { + .name =3D "s390_crw_container", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(crw, CrwContainer, 0, vmstate_crw, CRW), + VMSTATE_END_OF_LIST() + }, +}; + typedef struct ChpInfo { uint8_t in_use; uint8_t type; uint8_t is_virtual; } ChpInfo; =20 +static const VMStateDescription vmstate_chp_info =3D { + .name =3D "s390_chp_info", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(in_use, ChpInfo), + VMSTATE_UINT8(type, ChpInfo), + VMSTATE_UINT8(is_virtual, ChpInfo), + VMSTATE_END_OF_LIST() + } +}; + typedef struct SubchSet { SubchDev *sch[MAX_SCHID + 1]; unsigned long schids_used[BITS_TO_LONGS(MAX_SCHID + 1)]; @@ -215,6 +248,19 @@ typedef struct CssImage { ChpInfo chpids[MAX_CHPID + 1]; } CssImage; =20 +static const VMStateDescription vmstate_css_img =3D { + .name =3D "s390_css_img", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + /* Subchannel sets have no relevant state. */ + VMSTATE_STRUCT_ARRAY(chpids, CssImage, MAX_CHPID + 1, 0, + vmstate_chp_info, ChpInfo), + VMSTATE_END_OF_LIST() + } + +}; + typedef struct IoAdapter { uint32_t id; uint8_t type; @@ -232,10 +278,34 @@ typedef struct ChannelSubSys { uint64_t chnmon_area; CssImage *css[MAX_CSSID + 1]; uint8_t default_cssid; + /* don't migrate */ IoAdapter *io_adapters[CSS_IO_ADAPTER_TYPE_NUMS][MAX_ISC + 1]; + /* don't migrate */ QTAILQ_HEAD(, IndAddr) indicator_addresses; } ChannelSubSys; =20 +static const VMStateDescription vmstate_css =3D { + .name =3D "s390_css", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_QTAILQ_V(pending_crws, ChannelSubSys, 1, vmstate_crw_conta= iner, + CrwContainer, sibling), + VMSTATE_BOOL(sei_pending, ChannelSubSys), + VMSTATE_BOOL(do_crw_mchk, ChannelSubSys), + VMSTATE_BOOL(crws_lost, ChannelSubSys), + /* These were kind of migrated by virtio */ + VMSTATE_UINT8(max_cssid, ChannelSubSys), + VMSTATE_UINT8(max_ssid, ChannelSubSys), + VMSTATE_BOOL(chnmon_active, ChannelSubSys), + VMSTATE_UINT64(chnmon_area, ChannelSubSys), + VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(css, ChannelSubSys, MAX_CSSID += 1, + 0, vmstate_css_img, CssImage), + VMSTATE_UINT8(default_cssid, ChannelSubSys), + VMSTATE_END_OF_LIST() + } +}; + static ChannelSubSys channel_subsys =3D { .pending_crws =3D QTAILQ_HEAD_INITIALIZER(channel_subsys.pending_crws), .do_crw_mchk =3D true, @@ -275,6 +345,10 @@ static int subch_dev_post_load(void *opaque, int versi= on_id) css_subch_assign(s->cssid, s->ssid, s->schid, s->devno, s); } =20 + if (css_migration_enabled()) { + /* No compat voodoo to do ;) */ + return 0; + } /* * Hack alert. If we don't migrate the channel subsystem status * we still need to find out if the guest enabled mss/mcss-e. --=20 2.11.2 From nobody Sun Apr 28 21:32:26 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.zoho.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 1496066464012774.7536684276677; Mon, 29 May 2017 07:01:04 -0700 (PDT) Received: from localhost ([::1]:48919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFLEE-00049I-MO for importer@patchew.org; Mon, 29 May 2017 10:01:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFL95-0008BC-7d for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFL91-0005Dg-BP for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:43 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43027) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFL91-0005D1-2m for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:39 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4TDrUVQ144881 for ; Mon, 29 May 2017 09:55:37 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2arm8p9myr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 29 May 2017 09:55:37 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 May 2017 14:55:35 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 29 May 2017 14:55:31 +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 v4TDtV1j30736500; Mon, 29 May 2017 13:55:31 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79B3E52050; Mon, 29 May 2017 13:52:30 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 5097952065; Mon, 29 May 2017 13:52:30 +0100 (BST) From: Halil Pasic To: Cornelia Huck , "Dr. David Alan Gilbert" Date: Mon, 29 May 2017 15:55:18 +0200 X-Mailer: git-send-email 2.11.2 In-Reply-To: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> References: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17052913-0040-0000-0000-000003B988C7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052913-0041-0000-0000-0000204BA5C7 Message-Id: <20170529135520.101429-6-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-29_10:, , 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-1705290259 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 5/7] s390x/css: add ORB to SubchDev 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: Dong Jia Shi , Halil Pasic , qemu-devel@nongnu.org, Juan Quintela 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" Since we are going to need a migration compatibility breaking change to activate ChannelSubSys migration let us use the opportunity to introduce ORB to the SubchDev before that (otherwise we would need separate handling e.g. a compat property). The ORB will be useful for implementing IDA, or async handling of subchannel work. Signed-off-by: Halil Pasic Reviewed-by: Guenther Hutzl Reviewed-by: Cornelia Huck --- hw/s390x/css.c | 35 +++++++++++++++++++++++++++++++++++ include/hw/s390x/css.h | 1 + 2 files changed, 36 insertions(+) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index a15b58d303..e840dfba2a 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -163,6 +163,36 @@ static const VMStateDescription vmstate_sense_id =3D { } }; =20 +static const VMStateDescription vmstate_orb =3D { + .name =3D "s390_orb", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(intparm, ORB), + VMSTATE_UINT16(ctrl0, ORB), + VMSTATE_UINT8(lpm, ORB), + VMSTATE_UINT8(ctrl1, ORB), + VMSTATE_UINT32(cpa, ORB), + VMSTATE_END_OF_LIST() + } +}; + +static bool vmstate_schdev_orb_needed(void *opaque) +{ + return css_migration_enabled(); +} + +static const VMStateDescription vmstate_schdev_orb =3D { + .name =3D "s390_subch_dev/orb", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vmstate_schdev_orb_needed, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(orb, SubchDev, 1, vmstate_orb, ORB), + VMSTATE_END_OF_LIST() + } +}; + static int subch_dev_post_load(void *opaque, int version_id); static void subch_dev_pre_save(void *opaque); =20 @@ -187,6 +217,10 @@ const VMStateDescription vmstate_subch_dev =3D { VMSTATE_BOOL(ccw_fmt_1, SubchDev), VMSTATE_UINT8(ccw_no_data_cnt, SubchDev), VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_schdev_orb, + NULL } }; =20 @@ -1253,6 +1287,7 @@ int css_do_ssch(SubchDev *sch, ORB *orb) if (channel_subsys.chnmon_active) { css_update_chnmon(sch); } + sch->orb =3D *orb; sch->channel_prog =3D orb->cpa; /* Trigger the start function. */ s->ctrl |=3D (SCSW_FCTL_START_FUNC | SCSW_ACTL_START_PEND); diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index d74e44d312..e9c02af550 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -89,6 +89,7 @@ struct SubchDev { bool thinint_active; uint8_t ccw_no_data_cnt; uint16_t migrated_schid; /* used for missmatch detection */ + ORB orb; /* transport-provided data: */ int (*ccw_cb) (SubchDev *, CCW1); void (*disable_cb)(SubchDev *); --=20 2.11.2 From nobody Sun Apr 28 21:32:26 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.zoho.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 1496066251391660.5234371430092; Mon, 29 May 2017 06:57:31 -0700 (PDT) Received: from localhost ([::1]:48903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFLAo-0000u3-2i for importer@patchew.org; Mon, 29 May 2017 09:57:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFL95-0008BZ-IR for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFL91-0005Dp-HC for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:43 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60618) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFL91-0005DL-8Q for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:39 -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 v4TDrTna054014 for ; Mon, 29 May 2017 09:55:38 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2argtctatn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 29 May 2017 09:55:37 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 May 2017 14:55:35 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 29 May 2017 14:55:33 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4TDtWnA37093572; Mon, 29 May 2017 13:55:32 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B67EA52050; Mon, 29 May 2017 13:52:31 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 83B0252041; Mon, 29 May 2017 13:52:31 +0100 (BST) From: Halil Pasic To: Cornelia Huck , "Dr. David Alan Gilbert" Date: Mon, 29 May 2017 15:55:19 +0200 X-Mailer: git-send-email 2.11.2 In-Reply-To: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> References: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17052913-0016-0000-0000-000004AD3EA8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052913-0017-0000-0000-000027D6018E Message-Id: <20170529135520.101429-7-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-29_10:, , 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-1705290259 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 6/7] s390x/css: activate ChannelSubSys migration 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: Dong Jia Shi , Halil Pasic , qemu-devel@nongnu.org, Juan Quintela 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" Turn on migration for the channel subsystem for the next machine. For legacy machines we still have to do things the old way. Signed-off-by: Halil Pasic Reviewed-by: Cornelia Huck --- hw/s390x/css.c | 5 +++++ hw/s390x/s390-virtio-ccw.c | 9 ++++----- hw/s390x/virtio-ccw.c | 1 - include/hw/s390x/css.h | 4 ++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index e840dfba2a..9857eb3d6f 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -401,6 +401,11 @@ static int subch_dev_post_load(void *opaque, int versi= on_id) return 0; } =20 +void css_register_vmstate(void) +{ + vmstate_register(NULL, 0, &vmstate_css, &channel_subsys); +} + IndAddr *get_indicator(hwaddr ind_addr, int len) { IndAddr *indicator; diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 95256d3982..3ad6323add 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -196,7 +196,7 @@ static void ccw_machine_class_init(ObjectClass *oc, voi= d *data) =20 s390mc->ri_allowed =3D true; s390mc->cpu_model_allowed =3D true; - s390mc->css_migration_enabled =3D false; /* TODO: set to true */ + s390mc->css_migration_enabled =3D true; mc->init =3D ccw_init; mc->reset =3D s390_machine_reset; mc->hot_add_cpu =3D s390_hot_add_cpu; @@ -451,10 +451,9 @@ bool css_migration_enabled(void) =20 static void ccw_machine_2_10_instance_options(MachineState *machine) { - /* - * TODO Once preparations are done register vmstate for the css if - * css_migration_enabled(). - */ + if (css_migration_enabled()) { + css_register_vmstate(); + } } =20 static void ccw_machine_2_10_class_options(MachineClass *mc) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index a75eedeffb..4a0271b0be 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1360,7 +1360,6 @@ static void virtio_ccw_device_plugged(DeviceState *d,= Error **errp) =20 sch->id.cu_model =3D virtio_bus_get_vdev_id(&dev->bus); =20 - css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, d->hotplugged, 1); } diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index e9c02af550..812fc05804 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -209,4 +209,8 @@ extern PropertyInfo css_devid_ro_propinfo; * is responsible for unregistering and freeing it. */ SubchDev *css_create_virtual_sch(CssDevId bus_id, Error **errp); + +/** Turn on css migration */ +void css_register_vmstate(void); + #endif --=20 2.11.2 From nobody Sun Apr 28 21:32:26 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.zoho.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 1496066377712890.3770441074493; Mon, 29 May 2017 06:59:37 -0700 (PDT) Received: from localhost ([::1]:48909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFLCq-0002yd-86 for importer@patchew.org; Mon, 29 May 2017 09:59:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFL96-0008CG-8b for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFL92-0005EA-Bg for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:44 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33155 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 1dFL92-0005E1-60 for qemu-devel@nongnu.org; Mon, 29 May 2017 09:55:40 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4TDrW8w115281 for ; Mon, 29 May 2017 09:55:39 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 2arghbb7am-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 29 May 2017 09:55:39 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 May 2017 14:55:37 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 29 May 2017 14:55:34 +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 v4TDtXkL6226324; Mon, 29 May 2017 13:55:34 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E96E55204B; Mon, 29 May 2017 13:52:32 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id B6E4B52041; Mon, 29 May 2017 13:52:32 +0100 (BST) From: Halil Pasic To: Cornelia Huck , "Dr. David Alan Gilbert" Date: Mon, 29 May 2017 15:55:20 +0200 X-Mailer: git-send-email 2.11.2 In-Reply-To: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> References: <20170529135520.101429-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17052913-0040-0000-0000-0000039A3890 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052913-0041-0000-0000-0000258B8420 Message-Id: <20170529135520.101429-8-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-29_10:, , 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-1705290259 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v2 7/7] s390x/css: use SubchDev.orb 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: Dong Jia Shi , Halil Pasic , qemu-devel@nongnu.org, Juan Quintela 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 passing around a pointer to ORB let us simplify some functions signatures by using the previously introduced ORB saved at the subchannel (SubchDev). Signed-off-by: Halil Pasic Reviewed-by: Guenther Hutzl Reviewed-by: Cornelia Huck --- hw/s390x/css.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 9857eb3d6f..0229cb9412 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -854,7 +854,7 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_= addr, return ret; } =20 -static void sch_handle_start_func(SubchDev *sch, ORB *orb) +static void sch_handle_start_func(SubchDev *sch) { =20 PMCW *p =3D &sch->curr_status.pmcw; @@ -868,10 +868,10 @@ static void sch_handle_start_func(SubchDev *sch, ORB = *orb) =20 if (!(s->ctrl & SCSW_ACTL_SUSP)) { /* Start Function triggered via ssch, i.e. we have an ORB */ + ORB *orb =3D &sch->orb; s->cstat =3D 0; s->dstat =3D 0; /* Look at the orb and try to execute the channel program. */ - assert(orb !=3D NULL); /* resume does not pass an orb */ p->intparm =3D orb->intparm; if (!(orb->lpm & path)) { /* Generate a deferred cc 3 condition. */ @@ -885,8 +885,7 @@ static void sch_handle_start_func(SubchDev *sch, ORB *o= rb) sch->ccw_no_data_cnt =3D 0; suspend_allowed =3D !!(orb->ctrl0 & ORB_CTRL0_MASK_SPND); } else { - /* Start Function resumed via rsch, i.e. we don't have an - * ORB */ + /* Start Function resumed via rsch */ s->ctrl &=3D ~(SCSW_ACTL_SUSP | SCSW_ACTL_RESUME_PEND); /* The channel program had been suspended before. */ suspend_allowed =3D true; @@ -962,7 +961,7 @@ static void sch_handle_start_func(SubchDev *sch, ORB *o= rb) * read/writes) asynchronous later on if we start supporting more than * our current very simple devices. */ -static void do_subchannel_work(SubchDev *sch, ORB *orb) +static void do_subchannel_work(SubchDev *sch) { =20 SCSW *s =3D &sch->curr_status.scsw; @@ -973,7 +972,7 @@ static void do_subchannel_work(SubchDev *sch, ORB *orb) sch_handle_halt_func(sch); } else if (s->ctrl & SCSW_FCTL_START_FUNC) { /* Triggered by both ssch and rsch. */ - sch_handle_start_func(sch, orb); + sch_handle_start_func(sch); } else { /* Cannot happen. */ return; @@ -1182,7 +1181,7 @@ int css_do_csch(SubchDev *sch) s->ctrl &=3D ~(SCSW_CTRL_MASK_FCTL | SCSW_CTRL_MASK_ACTL); s->ctrl |=3D SCSW_FCTL_CLEAR_FUNC | SCSW_ACTL_CLEAR_PEND; =20 - do_subchannel_work(sch, NULL); + do_subchannel_work(sch); ret =3D 0; =20 out: @@ -1223,7 +1222,7 @@ int css_do_hsch(SubchDev *sch) } s->ctrl |=3D SCSW_ACTL_HALT_PEND; =20 - do_subchannel_work(sch, NULL); + do_subchannel_work(sch); ret =3D 0; =20 out: @@ -1298,7 +1297,7 @@ int css_do_ssch(SubchDev *sch, ORB *orb) s->ctrl |=3D (SCSW_FCTL_START_FUNC | SCSW_ACTL_START_PEND); s->flags &=3D ~SCSW_FLAGS_MASK_PNO; =20 - do_subchannel_work(sch, orb); + do_subchannel_work(sch); ret =3D 0; =20 out: @@ -1578,7 +1577,7 @@ int css_do_rsch(SubchDev *sch) } =20 s->ctrl |=3D SCSW_ACTL_RESUME_PEND; - do_subchannel_work(sch, NULL); + do_subchannel_work(sch); ret =3D 0; =20 out: --=20 2.11.2