Assorted s390x patches:
- updates for virtio-ccw and s390-virtio, making them more similar to virtio-pci - improvements regarding per-vcpu interrupts and migration -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABAgAGBQJVTHeVAAoJEN7Pa5PG8C+vLPEP/iSdI7n1uBAIdpvusJUSZo04 +YKsQXPzjCScSkGnH7bgIx3WwsWEm1k2VPH7uVhZTXH3rgPbhquWyIk/6taQLXq8 frF2EOsGuWLMxlgzejuRl6v927QX+sc93tD7e8vw7aDydSTy3tXAVqG7jM7CRfYD 9yUNJk0TdEgPrAoLsXV+vsO3Yr39wY3Q7WXYYCeNT5PIXTrFWF5avScXJuqhB7iq PH9fte6/zAfvFmH/+S+cm7sJ0FUT/T46tfbOj1EEjryFesPa47GVrMkcNH8TFpbP +sHb6vH+qhSEzKHgkR7dRXq5QJyjEF5ci8sbH3QxtRQhMc2YAV/x+WA0rfd/H7eZ PlTvbnX/cGf2yOza0iub6m3z+66iXpy7bYW4PBFBFpWPNfLXV/i1R6vDyw/dgx8p ZCB7wCvVHnUAIV1t8aoybaZUIVPjhqe+/niBnoi1jCIA2YOYsNLn3eltSLzY52eX uIQR+QnMIvMU1GW6EFEOraDkwNRNYmuQGz2jjEGtOdFoxuK/VQMfARgKEkicM6MH VI2ZkeK1nSX+GhMvuL7A7e3Uknya8A/o46xvGYF/OQAbSsNX5sbzkgPA4paL1Wdi xjpCIyOqnCP4iiCXBkNhCl6kK7UyNef5L08bg5JTDzwtyR909ax2Nc7p6W+SLV/+ BqJC7rTpiuthhgB0c+2J =qrI/ -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150508' into staging Assorted s390x patches: - updates for virtio-ccw and s390-virtio, making them more similar to virtio-pci - improvements regarding per-vcpu interrupts and migration # gpg: Signature made Fri May 8 09:45:09 2015 BST using RSA key ID C6F02FAF # gpg: Good signature from "Cornelia Huck <huckc@linux.vnet.ibm.com>" # gpg: aka "Cornelia Huck <cornelia.huck@de.ibm.com>" * remotes/cohuck/tags/s390x-20150508: s390x/kvm: migrate vcpu interrupt state s390x: move fpu regs into a subsection of the vmstate s390x/kvm: use ioctl KVM_S390_IRQ for vcpu interrupts virtio-ccw: implement ->device_plugged virtio-ccw: change realization sequence s390-virtio: clear {used,avail}_event_idx on reset as well s390-virtio: use common features s390-virtio: Accommodate guests using virtqueues too early Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
fc85cf4a81
|
@ -77,10 +77,18 @@ void s390_virtio_reset_idx(VirtIOS390Device *dev)
|
||||||
VIRTIO_VRING_AVAIL_IDX_OFFS;
|
VIRTIO_VRING_AVAIL_IDX_OFFS;
|
||||||
address_space_stw(&address_space_memory, idx_addr, 0,
|
address_space_stw(&address_space_memory, idx_addr, 0,
|
||||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||||
|
idx_addr = virtio_queue_get_avail_addr(dev->vdev, i) +
|
||||||
|
virtio_queue_get_avail_size(dev->vdev, i);
|
||||||
|
address_space_stw(&address_space_memory, idx_addr, 0,
|
||||||
|
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||||
idx_addr = virtio_queue_get_used_addr(dev->vdev, i) +
|
idx_addr = virtio_queue_get_used_addr(dev->vdev, i) +
|
||||||
VIRTIO_VRING_USED_IDX_OFFS;
|
VIRTIO_VRING_USED_IDX_OFFS;
|
||||||
address_space_stw(&address_space_memory, idx_addr, 0,
|
address_space_stw(&address_space_memory, idx_addr, 0,
|
||||||
MEMTXATTRS_UNSPECIFIED, NULL);
|
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||||
|
idx_addr = virtio_queue_get_used_addr(dev->vdev, i) +
|
||||||
|
virtio_queue_get_used_size(dev->vdev, i);
|
||||||
|
address_space_stw(&address_space_memory, idx_addr, 0,
|
||||||
|
MEMTXATTRS_UNSPECIFIED, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +538,6 @@ static unsigned virtio_s390_get_features(DeviceState *d)
|
||||||
/**************** S390 Virtio Bus Device Descriptions *******************/
|
/**************** S390 Virtio Bus Device Descriptions *******************/
|
||||||
|
|
||||||
static Property s390_virtio_net_properties[] = {
|
static Property s390_virtio_net_properties[] = {
|
||||||
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
|
|
||||||
DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features),
|
DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
@ -592,18 +599,12 @@ static const TypeInfo s390_virtio_serial = {
|
||||||
.class_init = s390_virtio_serial_class_init,
|
.class_init = s390_virtio_serial_class_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
static Property s390_virtio_rng_properties[] = {
|
|
||||||
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
|
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
|
||||||
};
|
|
||||||
|
|
||||||
static void s390_virtio_rng_class_init(ObjectClass *klass, void *data)
|
static void s390_virtio_rng_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
|
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
|
||||||
|
|
||||||
k->realize = s390_virtio_rng_realize;
|
k->realize = s390_virtio_rng_realize;
|
||||||
dc->props = s390_virtio_rng_properties;
|
|
||||||
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,10 +633,16 @@ static void s390_virtio_busdev_reset(DeviceState *dev)
|
||||||
virtio_reset(_dev->vdev);
|
virtio_reset(_dev->vdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Property virtio_s390_properties[] = {
|
||||||
|
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
|
||||||
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
};
|
||||||
|
|
||||||
static void virtio_s390_device_class_init(ObjectClass *klass, void *data)
|
static void virtio_s390_device_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
|
dc->props = virtio_s390_properties;
|
||||||
dc->realize = s390_virtio_busdev_realize;
|
dc->realize = s390_virtio_busdev_realize;
|
||||||
dc->bus_type = TYPE_S390_VIRTIO_BUS;
|
dc->bus_type = TYPE_S390_VIRTIO_BUS;
|
||||||
dc->reset = s390_virtio_busdev_reset;
|
dc->reset = s390_virtio_busdev_reset;
|
||||||
|
@ -651,7 +658,6 @@ static const TypeInfo virtio_s390_device_info = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static Property s390_virtio_scsi_properties[] = {
|
static Property s390_virtio_scsi_properties[] = {
|
||||||
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
|
|
||||||
DEFINE_VIRTIO_SCSI_FEATURES(VirtIOS390Device, host_features),
|
DEFINE_VIRTIO_SCSI_FEATURES(VirtIOS390Device, host_features),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
@ -675,18 +681,12 @@ static const TypeInfo s390_virtio_scsi = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_VHOST_SCSI
|
#ifdef CONFIG_VHOST_SCSI
|
||||||
static Property s390_vhost_scsi_properties[] = {
|
|
||||||
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
|
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
|
||||||
};
|
|
||||||
|
|
||||||
static void s390_vhost_scsi_class_init(ObjectClass *klass, void *data)
|
static void s390_vhost_scsi_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
|
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
|
||||||
|
|
||||||
k->realize = s390_vhost_scsi_realize;
|
k->realize = s390_vhost_scsi_realize;
|
||||||
dc->props = s390_vhost_scsi_properties;
|
|
||||||
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
|
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,16 @@ static int s390_virtio_hcall_notify(const uint64_t *args)
|
||||||
if (mem > ram_size) {
|
if (mem > ram_size) {
|
||||||
VirtIOS390Device *dev = s390_virtio_bus_find_vring(s390_bus, mem, &i);
|
VirtIOS390Device *dev = s390_virtio_bus_find_vring(s390_bus, mem, &i);
|
||||||
if (dev) {
|
if (dev) {
|
||||||
|
/*
|
||||||
|
* Older kernels will use the virtqueue before setting DRIVER_OK.
|
||||||
|
* In this case the feature bits are not yet up to date, meaning
|
||||||
|
* that several funny things can happen, e.g. the guest thinks
|
||||||
|
* EVENT_IDX is on and QEMU thinks it is off. Let's force a feature
|
||||||
|
* and status sync.
|
||||||
|
*/
|
||||||
|
if (!(dev->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
|
||||||
|
s390_virtio_device_update_status(dev);
|
||||||
|
}
|
||||||
virtio_queue_notify(dev->vdev, i);
|
virtio_queue_notify(dev->vdev, i);
|
||||||
} else {
|
} else {
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
|
|
|
@ -642,8 +642,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_ccw_device_realize(VirtioCcwDevice *dev,
|
static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp)
|
||||||
VirtIODevice *vdev, Error **errp)
|
|
||||||
{
|
{
|
||||||
unsigned int cssid = 0;
|
unsigned int cssid = 0;
|
||||||
unsigned int ssid = 0;
|
unsigned int ssid = 0;
|
||||||
|
@ -653,7 +652,8 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev,
|
||||||
bool found = false;
|
bool found = false;
|
||||||
SubchDev *sch;
|
SubchDev *sch;
|
||||||
int num;
|
int num;
|
||||||
DeviceState *parent = DEVICE(dev);
|
Error *err = NULL;
|
||||||
|
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
|
||||||
|
|
||||||
sch = g_malloc0(sizeof(SubchDev));
|
sch = g_malloc0(sizeof(SubchDev));
|
||||||
|
|
||||||
|
@ -766,17 +766,16 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev,
|
||||||
memset(&sch->id, 0, sizeof(SenseId));
|
memset(&sch->id, 0, sizeof(SenseId));
|
||||||
sch->id.reserved = 0xff;
|
sch->id.reserved = 0xff;
|
||||||
sch->id.cu_type = VIRTIO_CCW_CU_TYPE;
|
sch->id.cu_type = VIRTIO_CCW_CU_TYPE;
|
||||||
sch->id.cu_model = vdev->device_id;
|
|
||||||
|
|
||||||
/* Only the first 32 feature bits are used. */
|
if (k->realize) {
|
||||||
dev->host_features[0] = virtio_bus_get_vdev_features(&dev->bus,
|
k->realize(dev, &err);
|
||||||
dev->host_features[0]);
|
}
|
||||||
|
if (err) {
|
||||||
|
error_propagate(errp, err);
|
||||||
|
css_subch_assign(cssid, ssid, schid, devno, NULL);
|
||||||
|
goto out_err;
|
||||||
|
}
|
||||||
|
|
||||||
virtio_add_feature(&dev->host_features[0], VIRTIO_F_NOTIFY_ON_EMPTY);
|
|
||||||
virtio_add_feature(&dev->host_features[0], VIRTIO_F_BAD_FEATURE);
|
|
||||||
|
|
||||||
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
|
|
||||||
parent->hotplugged, 1);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
out_err:
|
out_err:
|
||||||
|
@ -813,10 +812,7 @@ static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_ccw_net_instance_init(Object *obj)
|
static void virtio_ccw_net_instance_init(Object *obj)
|
||||||
|
@ -839,10 +835,7 @@ static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_ccw_blk_instance_init(Object *obj)
|
static void virtio_ccw_blk_instance_init(Object *obj)
|
||||||
|
@ -879,10 +872,7 @@ static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -904,10 +894,7 @@ static void virtio_ccw_balloon_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void balloon_ccw_stats_get_all(Object *obj, struct Visitor *v,
|
static void balloon_ccw_stats_get_all(Object *obj, struct Visitor *v,
|
||||||
|
@ -972,10 +959,7 @@ static void virtio_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_ccw_scsi_instance_init(Object *obj)
|
static void virtio_ccw_scsi_instance_init(Object *obj)
|
||||||
|
@ -999,10 +983,7 @@ static void vhost_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||||
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vhost_ccw_scsi_instance_init(Object *obj)
|
static void vhost_ccw_scsi_instance_init(Object *obj)
|
||||||
|
@ -1030,8 +1011,6 @@ static void virtio_ccw_rng_realize(VirtioCcwDevice *ccw_dev, Error **errp)
|
||||||
object_property_set_link(OBJECT(dev),
|
object_property_set_link(OBJECT(dev),
|
||||||
OBJECT(dev->vdev.conf.rng), "rng",
|
OBJECT(dev->vdev.conf.rng), "rng",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DeviceState to VirtioCcwDevice. Note: used on datapath,
|
/* DeviceState to VirtioCcwDevice. Note: used on datapath,
|
||||||
|
@ -1434,6 +1413,30 @@ static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is called by virtio-bus just after the device is plugged. */
|
||||||
|
static void virtio_ccw_device_plugged(DeviceState *d)
|
||||||
|
{
|
||||||
|
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
|
||||||
|
SubchDev *sch = dev->sch;
|
||||||
|
|
||||||
|
sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
|
||||||
|
|
||||||
|
/* Only the first 32 feature bits are used. */
|
||||||
|
virtio_add_feature(&dev->host_features[0], VIRTIO_F_NOTIFY_ON_EMPTY);
|
||||||
|
virtio_add_feature(&dev->host_features[0], VIRTIO_F_BAD_FEATURE);
|
||||||
|
dev->host_features[0] = virtio_bus_get_vdev_features(&dev->bus,
|
||||||
|
dev->host_features[0]);
|
||||||
|
|
||||||
|
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
|
||||||
|
d->hotplugged, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void virtio_ccw_device_unplugged(DeviceState *d)
|
||||||
|
{
|
||||||
|
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
|
||||||
|
|
||||||
|
virtio_ccw_stop_ioeventfd(dev);
|
||||||
|
}
|
||||||
/**************** Virtio-ccw Bus Device Descriptions *******************/
|
/**************** Virtio-ccw Bus Device Descriptions *******************/
|
||||||
|
|
||||||
static Property virtio_ccw_net_properties[] = {
|
static Property virtio_ccw_net_properties[] = {
|
||||||
|
@ -1640,10 +1643,9 @@ static const TypeInfo virtio_ccw_rng = {
|
||||||
static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp)
|
static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
|
VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
|
||||||
VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
|
|
||||||
|
|
||||||
virtio_ccw_bus_new(&_dev->bus, sizeof(_dev->bus), _dev);
|
virtio_ccw_bus_new(&_dev->bus, sizeof(_dev->bus), _dev);
|
||||||
_info->realize(_dev, errp);
|
virtio_ccw_device_realize(_dev, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int virtio_ccw_busdev_exit(DeviceState *dev)
|
static int virtio_ccw_busdev_exit(DeviceState *dev)
|
||||||
|
@ -1759,6 +1761,8 @@ static void virtio_ccw_bus_class_init(ObjectClass *klass, void *data)
|
||||||
k->load_queue = virtio_ccw_load_queue;
|
k->load_queue = virtio_ccw_load_queue;
|
||||||
k->save_config = virtio_ccw_save_config;
|
k->save_config = virtio_ccw_save_config;
|
||||||
k->load_config = virtio_ccw_load_config;
|
k->load_config = virtio_ccw_load_config;
|
||||||
|
k->device_plugged = virtio_ccw_device_plugged;
|
||||||
|
k->device_unplugged = virtio_ccw_device_unplugged;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo virtio_ccw_bus_info = {
|
static const TypeInfo virtio_ccw_bus_info = {
|
||||||
|
|
|
@ -66,6 +66,9 @@ typedef struct S390CPU {
|
||||||
/*< public >*/
|
/*< public >*/
|
||||||
|
|
||||||
CPUS390XState env;
|
CPUS390XState env;
|
||||||
|
/* needed for live migration */
|
||||||
|
void *irqstate;
|
||||||
|
uint32_t irqstate_saved_size;
|
||||||
} S390CPU;
|
} S390CPU;
|
||||||
|
|
||||||
static inline S390CPU *s390_env_get_cpu(CPUS390XState *env)
|
static inline S390CPU *s390_env_get_cpu(CPUS390XState *env)
|
||||||
|
|
|
@ -213,6 +213,7 @@ static void s390_cpu_finalize(Object *obj)
|
||||||
S390CPU *cpu = S390_CPU(obj);
|
S390CPU *cpu = S390_CPU(obj);
|
||||||
|
|
||||||
qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu);
|
qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu);
|
||||||
|
g_free(cpu->irqstate);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1079,6 +1079,8 @@ void kvm_s390_clear_cmma_callback(void *opaque);
|
||||||
int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);
|
int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);
|
||||||
void kvm_s390_reset_vcpu(S390CPU *cpu);
|
void kvm_s390_reset_vcpu(S390CPU *cpu);
|
||||||
int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit);
|
int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit);
|
||||||
|
void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu);
|
||||||
|
int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu);
|
||||||
#else
|
#else
|
||||||
static inline void kvm_s390_io_interrupt(uint16_t subchannel_id,
|
static inline void kvm_s390_io_interrupt(uint16_t subchannel_id,
|
||||||
uint16_t subchannel_nr,
|
uint16_t subchannel_nr,
|
||||||
|
@ -1121,6 +1123,13 @@ static inline int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit,
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static inline void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
static inline int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit)
|
static inline int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit)
|
||||||
|
|
|
@ -109,6 +109,14 @@
|
||||||
#define ICPT_CPU_STOP 0x28
|
#define ICPT_CPU_STOP 0x28
|
||||||
#define ICPT_IO 0x40
|
#define ICPT_IO 0x40
|
||||||
|
|
||||||
|
#define NR_LOCAL_IRQS 32
|
||||||
|
/*
|
||||||
|
* Needs to be big enough to contain max_cpus emergency signals
|
||||||
|
* and in addition NR_LOCAL_IRQS interrupts
|
||||||
|
*/
|
||||||
|
#define VCPU_IRQ_BUF_SIZE (sizeof(struct kvm_s390_irq) * \
|
||||||
|
(max_cpus + NR_LOCAL_IRQS))
|
||||||
|
|
||||||
static CPUWatchpoint hw_watchpoint;
|
static CPUWatchpoint hw_watchpoint;
|
||||||
/*
|
/*
|
||||||
* We don't use a list because this structure is also used to transmit the
|
* We don't use a list because this structure is also used to transmit the
|
||||||
|
@ -124,6 +132,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
|
||||||
static int cap_sync_regs;
|
static int cap_sync_regs;
|
||||||
static int cap_async_pf;
|
static int cap_async_pf;
|
||||||
static int cap_mem_op;
|
static int cap_mem_op;
|
||||||
|
static int cap_s390_irq;
|
||||||
|
|
||||||
static void *legacy_s390_alloc(size_t size, uint64_t *align);
|
static void *legacy_s390_alloc(size_t size, uint64_t *align);
|
||||||
|
|
||||||
|
@ -249,6 +258,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
|
||||||
cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
|
cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
|
||||||
cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
|
cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
|
||||||
cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
|
cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
|
||||||
|
cap_s390_irq = kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ);
|
||||||
|
|
||||||
kvm_s390_enable_cmma(s);
|
kvm_s390_enable_cmma(s);
|
||||||
|
|
||||||
|
@ -272,6 +282,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
|
||||||
{
|
{
|
||||||
S390CPU *cpu = S390_CPU(cs);
|
S390CPU *cpu = S390_CPU(cs);
|
||||||
kvm_s390_set_cpu_state(cpu, cpu->env.cpu_state);
|
kvm_s390_set_cpu_state(cpu, cpu->env.cpu_state);
|
||||||
|
cpu->irqstate = g_malloc0(VCPU_IRQ_BUF_SIZE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -827,10 +838,9 @@ static int s390_kvm_irq_to_interrupt(struct kvm_s390_irq *irq,
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq)
|
static void inject_vcpu_irq_legacy(CPUState *cs, struct kvm_s390_irq *irq)
|
||||||
{
|
{
|
||||||
struct kvm_s390_interrupt kvmint = {};
|
struct kvm_s390_interrupt kvmint = {};
|
||||||
CPUState *cs = CPU(cpu);
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = s390_kvm_irq_to_interrupt(irq, &kvmint);
|
r = s390_kvm_irq_to_interrupt(irq, &kvmint);
|
||||||
|
@ -846,6 +856,23 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq)
|
||||||
|
{
|
||||||
|
CPUState *cs = CPU(cpu);
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (cap_s390_irq) {
|
||||||
|
r = kvm_vcpu_ioctl(cs, KVM_S390_IRQ, irq);
|
||||||
|
if (!r) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error_report("KVM failed to inject interrupt %llx", irq->type);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
inject_vcpu_irq_legacy(cs, irq);
|
||||||
|
}
|
||||||
|
|
||||||
static void __kvm_s390_floating_interrupt(struct kvm_s390_irq *irq)
|
static void __kvm_s390_floating_interrupt(struct kvm_s390_irq *irq)
|
||||||
{
|
{
|
||||||
struct kvm_s390_interrupt kvmint = {};
|
struct kvm_s390_interrupt kvmint = {};
|
||||||
|
@ -2041,6 +2068,52 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu)
|
||||||
|
{
|
||||||
|
struct kvm_s390_irq_state irq_state;
|
||||||
|
CPUState *cs = CPU(cpu);
|
||||||
|
int32_t bytes;
|
||||||
|
|
||||||
|
if (!kvm_check_extension(kvm_state, KVM_CAP_S390_IRQ_STATE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
irq_state.buf = (uint64_t) cpu->irqstate;
|
||||||
|
irq_state.len = VCPU_IRQ_BUF_SIZE;
|
||||||
|
|
||||||
|
bytes = kvm_vcpu_ioctl(cs, KVM_S390_GET_IRQ_STATE, &irq_state);
|
||||||
|
if (bytes < 0) {
|
||||||
|
cpu->irqstate_saved_size = 0;
|
||||||
|
error_report("Migration of interrupt state failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cpu->irqstate_saved_size = bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu)
|
||||||
|
{
|
||||||
|
CPUState *cs = CPU(cpu);
|
||||||
|
struct kvm_s390_irq_state irq_state;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (!kvm_check_extension(kvm_state, KVM_CAP_S390_IRQ_STATE)) {
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cpu->irqstate_saved_size == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
irq_state.buf = (uint64_t) cpu->irqstate;
|
||||||
|
irq_state.len = cpu->irqstate_saved_size;
|
||||||
|
|
||||||
|
r = kvm_vcpu_ioctl(cs, KVM_S390_SET_IRQ_STATE, &irq_state);
|
||||||
|
if (r) {
|
||||||
|
error_report("Setting interrupt state failed %d", r);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
|
int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
|
||||||
uint64_t address, uint32_t data)
|
uint64_t address, uint32_t data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,16 +28,24 @@ static int cpu_post_load(void *opaque, int version_id)
|
||||||
*/
|
*/
|
||||||
if (kvm_enabled()) {
|
if (kvm_enabled()) {
|
||||||
kvm_s390_set_cpu_state(cpu, cpu->env.cpu_state);
|
kvm_s390_set_cpu_state(cpu, cpu->env.cpu_state);
|
||||||
|
return kvm_s390_vcpu_interrupt_post_load(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static void cpu_pre_save(void *opaque)
|
||||||
|
{
|
||||||
|
S390CPU *cpu = opaque;
|
||||||
|
|
||||||
const VMStateDescription vmstate_s390_cpu = {
|
if (kvm_enabled()) {
|
||||||
.name = "cpu",
|
kvm_s390_vcpu_interrupt_pre_save(cpu);
|
||||||
.post_load = cpu_post_load,
|
}
|
||||||
.version_id = 2,
|
}
|
||||||
.minimum_version_id = 2,
|
|
||||||
|
const VMStateDescription vmstate_fpu = {
|
||||||
|
.name = "cpu/fpu",
|
||||||
|
.version_id = 1,
|
||||||
|
.minimum_version_id = 1,
|
||||||
.fields = (VMStateField[]) {
|
.fields = (VMStateField[]) {
|
||||||
VMSTATE_UINT64(env.fregs[0].ll, S390CPU),
|
VMSTATE_UINT64(env.fregs[0].ll, S390CPU),
|
||||||
VMSTATE_UINT64(env.fregs[1].ll, S390CPU),
|
VMSTATE_UINT64(env.fregs[1].ll, S390CPU),
|
||||||
|
@ -55,11 +63,27 @@ const VMStateDescription vmstate_s390_cpu = {
|
||||||
VMSTATE_UINT64(env.fregs[13].ll, S390CPU),
|
VMSTATE_UINT64(env.fregs[13].ll, S390CPU),
|
||||||
VMSTATE_UINT64(env.fregs[14].ll, S390CPU),
|
VMSTATE_UINT64(env.fregs[14].ll, S390CPU),
|
||||||
VMSTATE_UINT64(env.fregs[15].ll, S390CPU),
|
VMSTATE_UINT64(env.fregs[15].ll, S390CPU),
|
||||||
|
VMSTATE_UINT32(env.fpc, S390CPU),
|
||||||
|
VMSTATE_END_OF_LIST()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline bool fpu_needed(void *opaque)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const VMStateDescription vmstate_s390_cpu = {
|
||||||
|
.name = "cpu",
|
||||||
|
.post_load = cpu_post_load,
|
||||||
|
.pre_save = cpu_pre_save,
|
||||||
|
.version_id = 4,
|
||||||
|
.minimum_version_id = 3,
|
||||||
|
.fields = (VMStateField[]) {
|
||||||
VMSTATE_UINT64_ARRAY(env.regs, S390CPU, 16),
|
VMSTATE_UINT64_ARRAY(env.regs, S390CPU, 16),
|
||||||
VMSTATE_UINT64(env.psw.mask, S390CPU),
|
VMSTATE_UINT64(env.psw.mask, S390CPU),
|
||||||
VMSTATE_UINT64(env.psw.addr, S390CPU),
|
VMSTATE_UINT64(env.psw.addr, S390CPU),
|
||||||
VMSTATE_UINT64(env.psa, S390CPU),
|
VMSTATE_UINT64(env.psa, S390CPU),
|
||||||
VMSTATE_UINT32(env.fpc, S390CPU),
|
|
||||||
VMSTATE_UINT32(env.todpr, S390CPU),
|
VMSTATE_UINT32(env.todpr, S390CPU),
|
||||||
VMSTATE_UINT64(env.pfault_token, S390CPU),
|
VMSTATE_UINT64(env.pfault_token, S390CPU),
|
||||||
VMSTATE_UINT64(env.pfault_compare, S390CPU),
|
VMSTATE_UINT64(env.pfault_compare, S390CPU),
|
||||||
|
@ -72,6 +96,17 @@ const VMStateDescription vmstate_s390_cpu = {
|
||||||
VMSTATE_UINT64_ARRAY(env.cregs, S390CPU, 16),
|
VMSTATE_UINT64_ARRAY(env.cregs, S390CPU, 16),
|
||||||
VMSTATE_UINT8(env.cpu_state, S390CPU),
|
VMSTATE_UINT8(env.cpu_state, S390CPU),
|
||||||
VMSTATE_UINT8(env.sigp_order, S390CPU),
|
VMSTATE_UINT8(env.sigp_order, S390CPU),
|
||||||
|
VMSTATE_UINT32_V(irqstate_saved_size, S390CPU, 4),
|
||||||
|
VMSTATE_VBUFFER_UINT32(irqstate, S390CPU, 4, NULL, 0,
|
||||||
|
irqstate_saved_size),
|
||||||
VMSTATE_END_OF_LIST()
|
VMSTATE_END_OF_LIST()
|
||||||
},
|
},
|
||||||
|
.subsections = (VMStateSubsection[]) {
|
||||||
|
{
|
||||||
|
.vmsd = &vmstate_fpu,
|
||||||
|
.needed = fpu_needed,
|
||||||
|
} , {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue