Skip to contentSkip to conversation

s390x: next batch of patches

GIT PULL Applied Cornelia Huck 2 participants 9 messages Jun 14, 2016

lore
Share & tools
lore
#0 lore raw

The following changes since commit a28aae041aa76a779df6467a7fe68b9e8a8b2c0a:

Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.7-20160614' into staging (2016-06-14 09:30:05 +0100)

are available in the git repository at:

git://github.com/cohuck/qemu tags/s390x-20160614

for you to fetch changes up to 393ad2a4a15db3836698de0e11249b4ec9dafb11:

s390x/kvm: Fixup interrupt type for non-adapter I/O interrupts (2016-06-14 14:00:05 +0200)

----------------------------------------------------------------
More s390x patches, this time mostly dealing with channel I/O:
Bugfixes and cleanups, and dequeue pending interrupts after machine checks.

----------------------------------------------------------------

Christian Borntraeger (3):
virtio-ccw: Provide traces for indicator changes
s390x: Limit s390-ccw machines to 248 CPUs s390x/kvm: Fixup interrupt type for non-adapter I/O interrupts

Cornelia Huck (2):
linux-headers: update
s390x/css: introduce property type for device ids

Halil Pasic (2):
s390x/kvm: add interface for clearing IO irqs s390x/css: clear IO irqs when generating IPI CRW

 hw/intc/s390_flic.c                            |   8 ++
 hw/intc/s390_flic_kvm.c                        |  26 ++++++
 hw/s390x/css.c                                 | 124 ++++++++++++++++++++++++-
 hw/s390x/s390-virtio-ccw.c                     |   2 +-
 hw/s390x/virtio-ccw.c                          |  80 +++++++---------
 hw/s390x/virtio-ccw.h                          |   2 +-
 include/hw/s390x/css.h                         |  17 ++++
 include/hw/s390x/s390_flic.h                   |   2 +
 include/standard-headers/linux/pci_regs.h      |  20 +++-
 include/standard-headers/linux/virtio_config.h |   2 +
 linux-headers/asm-arm/unistd.h                 |   2 +
 linux-headers/asm-arm64/unistd.h               |   3 +
 linux-headers/asm-powerpc/unistd.h             |   2 +
 linux-headers/asm-s390/kvm.h                   |   1 +
 linux-headers/asm-s390/unistd.h                |   4 +-
 linux-headers/asm-x86/kvm.h                    |   6 +-
 linux-headers/asm-x86/unistd_x32.h             |   2 +
 linux-headers/linux/kvm.h                      |   1 +
 target-s390x/kvm.c                             |   5 +-
 trace-events                                   |   1 +
 20 files changed, 251 insertions(+), 59 deletions(-)
Signature · 1 line
2.9.0
#1 lore raw

[Qemu-devel] [PULL 3/7] s390x/css: clear IO irqs when generating IPI CRW

From: Halil Pasic <[email protected]>

According to the Principles of Operation (more precisely the subsection 'Channel-Report Word'), a subchannel put into the installed parameters initialized state is in the same state as after an I/O system reset (just parameters possibly changed). This implies that any I/O interrupts for that subchannel are no longer pending (as I/O system resets clear I/O interrupts). Therefore, we need an interface to clear pending I/O interrupts. Make css_generate_sch_crws clear the pending IO interrupts for the subchannel.

---
 hw/s390x/css.c | 43 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)
hw/s390x/css.c +40 -3
index 1675a19..aceb1c0 100644
@@ -10,6 +10,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qapi/error.h"
 #include <hw/qdev.h>
 #include "qemu/bitops.h"
 #include "exec/address-spaces.h"
@@ -192,12 +193,46 @@ out:
     return ret;
 }
 
-uint16_t css_build_subchannel_id(SubchDev *sch)
+static void css_clear_io_interrupt(uint16_t subchannel_id,
+                                   uint16_t subchannel_nr)
+{
+    Error *err = NULL;
+    static bool no_clear_irq;
+    S390FLICState *fs = s390_get_flic();
+    S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);
+    int r;
+
+    if (unlikely(no_clear_irq)) {
+        return;
+    }
+    r = fsc->clear_io_irq(fs, subchannel_id, subchannel_nr);
+    switch (r) {
+    case 0:
+        break;
+    case -ENOSYS:
+        no_clear_irq = true;
+        /*
+        * Ignore unavailability, as the user can't do anything
+        * about it anyway.
+        */
+        break;
+    default:
+        error_setg_errno(&err, -r, "unexpected error condition");
+        error_propagate(&error_abort, err);
+    }
+}
+
+static inline uint16_t css_do_build_subchannel_id(uint8_t cssid, uint8_t ssid)
 {
     if (channel_subsys.max_cssid > 0) {
-        return (sch->cssid << 8) | (1 << 3) | (sch->ssid << 1) | 1;
+        return (cssid << 8) | (1 << 3) | (ssid << 1) | 1;
     }
-    return (sch->ssid << 1) | 1;
+    return (ssid << 1) | 1;
+}
+
+uint16_t css_build_subchannel_id(SubchDev *sch)
+{
+    return css_do_build_subchannel_id(sch->cssid, sch->ssid);
 }
 
 static void css_inject_io_interrupt(SubchDev *sch)
@@ -1429,6 +1464,8 @@ void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
         css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, 0,
                       (guest_cssid << 8) | (ssid << 4));
     }
+    /* RW_ERC_IPI --> clear pending interrupts */
+    css_clear_io_interrupt(css_do_build_subchannel_id(cssid, ssid), schid);
 }
 
 void css_generate_chp_crws(uint8_t cssid, uint8_t chpid)
Signature · 1 line
2.9.0
#2 lore raw

[Qemu-devel] [PULL 1/7] linux-headers: update

In reply to Cornelia Huck

Update to 4.7-rc2.

---
 include/standard-headers/linux/pci_regs.h      | 20 +++++++++++++++++++-
 include/standard-headers/linux/virtio_config.h |  2 ++
 linux-headers/asm-arm/unistd.h                 |  2 ++
 linux-headers/asm-arm64/unistd.h               |  3 +++
 linux-headers/asm-powerpc/unistd.h             |  2 ++
 linux-headers/asm-s390/kvm.h                   |  1 +
 linux-headers/asm-s390/unistd.h                |  4 +++-
 linux-headers/asm-x86/kvm.h                    |  6 +++---
 linux-headers/asm-x86/unistd_x32.h             |  2 ++
 linux-headers/linux/kvm.h                      |  1 +
 10 files changed, 38 insertions(+), 5 deletions(-)
include/standard-headers/linux/pci_regs.h +19 -1
index 1becea8..4040951 100644
@@ -670,7 +670,8 @@
 #define PCI_EXT_CAP_ID_SECPCI	0x19	/* Secondary PCIe Capability */
 #define PCI_EXT_CAP_ID_PMUX	0x1A	/* Protocol Multiplexing */
 #define PCI_EXT_CAP_ID_PASID	0x1B	/* Process Address Space ID */
-#define PCI_EXT_CAP_ID_MAX	PCI_EXT_CAP_ID_PASID
+#define PCI_EXT_CAP_ID_DPC	0x1D	/* Downstream Port Containment */
+#define PCI_EXT_CAP_ID_MAX	PCI_EXT_CAP_ID_DPC
 
 #define PCI_EXT_CAP_DSN_SIZEOF	12
 #define PCI_EXT_CAP_MCAST_ENDPOINT_SIZEOF 40
@@ -946,4 +947,21 @@
 #define PCI_TPH_CAP_ST_SHIFT	16	/* st table shift */
 #define PCI_TPH_BASE_SIZEOF	12	/* size with no st table */
 
+/* Downstream Port Containment */
+#define PCI_EXP_DPC_CAP			4	/* DPC Capability */
+#define  PCI_EXP_DPC_CAP_RP_EXT		0x20	/* Root Port Extensions for DPC */
+#define  PCI_EXP_DPC_CAP_POISONED_TLP	0x40	/* Poisoned TLP Egress Blocking Supported */
+#define  PCI_EXP_DPC_CAP_SW_TRIGGER	0x80	/* Software Triggering Supported */
+#define  PCI_EXP_DPC_CAP_DL_ACTIVE	0x1000	/* ERR_COR signal on DL_Active supported */
+
+#define PCI_EXP_DPC_CTL			6	/* DPC control */
+#define  PCI_EXP_DPC_CTL_EN_NONFATAL 	0x02	/* Enable trigger on ERR_NONFATAL message */
+#define  PCI_EXP_DPC_CTL_INT_EN 	0x08	/* DPC Interrupt Enable */
+
+#define PCI_EXP_DPC_STATUS		8	/* DPC Status */
+#define  PCI_EXP_DPC_STATUS_TRIGGER	0x01	/* Trigger Status */
+#define  PCI_EXP_DPC_STATUS_INTERRUPT	0x08	/* Interrupt Status */
+
+#define PCI_EXP_DPC_SOURCE_ID		10	/* DPC Source Identifier */
+
 #endif /* LINUX_PCI_REGS_H */
include/standard-headers/linux/virtio_config.h +2 -0
index bcc445b..b30d0cb 100644
@@ -40,6 +40,8 @@
 #define VIRTIO_CONFIG_S_DRIVER_OK	4
 /* Driver has finished configuring features */
 #define VIRTIO_CONFIG_S_FEATURES_OK	8
+/* Device entered invalid state, driver must reset it */
+#define VIRTIO_CONFIG_S_NEEDS_RESET	0x40
 /* We've given up on this device. */
 #define VIRTIO_CONFIG_S_FAILED		0x80
 
linux-headers/asm-arm/unistd.h +2 -0
index 3f6f727..ceb5450 100644
@@ -418,6 +418,8 @@
 #define __NR_membarrier			(__NR_SYSCALL_BASE+389)
 #define __NR_mlock2			(__NR_SYSCALL_BASE+390)
 #define __NR_copy_file_range		(__NR_SYSCALL_BASE+391)
+#define __NR_preadv2			(__NR_SYSCALL_BASE+392)
+#define __NR_pwritev2			(__NR_SYSCALL_BASE+393)
 
 /*
  * The following SWIs are ARM private.
linux-headers/asm-arm64/unistd.h +3 -0
index 1caadc2..043d17a 100644
@@ -13,4 +13,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+
+#define __ARCH_WANT_RENAMEAT
+
 #include <asm-generic/unistd.h>
linux-headers/asm-powerpc/unistd.h +2 -0
index cd92d98..1e66eba 100644
@@ -390,5 +390,7 @@
 #define __NR_membarrier		365
 #define __NR_mlock2		378
 #define __NR_copy_file_range	379
+#define __NR_preadv2		380
+#define __NR_pwritev2		381
 
 #endif /* _ASM_POWERPC_UNISTD_H_ */
linux-headers/asm-s390/kvm.h +1 -0
index a59499b..09ae5dc 100644
@@ -25,6 +25,7 @@
 #define KVM_DEV_FLIC_APF_DISABLE_WAIT	5
 #define KVM_DEV_FLIC_ADAPTER_REGISTER	6
 #define KVM_DEV_FLIC_ADAPTER_MODIFY	7
+#define KVM_DEV_FLIC_CLEAR_IO_IRQ	8
 /*
  * We can have up to 4*64k pending subchannels + 8 adapter interrupts,
  * as well as up  to ASYNC_PF_PER_VCPU*KVM_MAX_VCPUS pfault done interrupts.
linux-headers/asm-s390/unistd.h +3 -1
index 885837e..8a404fd 100644
@@ -311,7 +311,9 @@
 #define __NR_shutdown		373
 #define __NR_mlock2		374
 #define __NR_copy_file_range	375
-#define NR_syscalls 376
+#define __NR_preadv2		376
+#define __NR_pwritev2		377
+#define NR_syscalls 378
 
 /* 
  * There are some system calls that are not present on 64 bit, some
linux-headers/asm-x86/kvm.h +3 -3
index cd54147..739c0c5 100644
@@ -216,9 +216,9 @@ struct kvm_cpuid_entry2 {
 	__u32 padding[3];
 };
 
-#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX		BIT(0)
-#define KVM_CPUID_FLAG_STATEFUL_FUNC		BIT(1)
-#define KVM_CPUID_FLAG_STATE_READ_NEXT		BIT(2)
+#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX		(1 << 0)
+#define KVM_CPUID_FLAG_STATEFUL_FUNC		(1 << 1)
+#define KVM_CPUID_FLAG_STATE_READ_NEXT		(1 << 2)
 
 /* for KVM_SET_CPUID2 */
 struct kvm_cpuid2 {
linux-headers/asm-x86/unistd_x32.h +2 -0
index 8f77ee8..0230779 100644
@@ -306,7 +306,9 @@
 #define __NR_vmsplice (__X32_SYSCALL_BIT + 532)
 #define __NR_move_pages (__X32_SYSCALL_BIT + 533)
 #define __NR_preadv (__X32_SYSCALL_BIT + 534)
+#define __NR_preadv2 (__X32_SYSCALL_BIT + 534)
 #define __NR_pwritev (__X32_SYSCALL_BIT + 535)
+#define __NR_pwritev2 (__X32_SYSCALL_BIT + 535)
 #define __NR_rt_tgsigqueueinfo (__X32_SYSCALL_BIT + 536)
 #define __NR_recvmmsg (__X32_SYSCALL_BIT + 537)
 #define __NR_sendmmsg (__X32_SYSCALL_BIT + 538)
linux-headers/linux/kvm.h +1 -0
index 3bae71a..e60e21b 100644
@@ -865,6 +865,7 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_SPAPR_TCE_64 125
 #define KVM_CAP_ARM_PMU_V3 126
 #define KVM_CAP_VCPU_ATTRIBUTES 127
+#define KVM_CAP_MAX_VCPU_ID 128
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
Signature · 1 line
2.9.0
#3 lore raw

[Qemu-devel] [PULL 7/7] s390x/kvm: Fixup interrupt type for non-adapter I/O interrupts

In reply to Cornelia Huck

From: Christian Borntraeger <[email protected]>

The current algorithm for I/O interrupts would result in a wrong interrupt type for subchannel numbers fffe and ffff. In addition a non adapter interrupt might look like an adapter interrupt for any subchannel number that has the 0x0400 bit set.

No kernel has ever used the type outside logging - and the logging was wrong all the time. For everything else the kernel used the interrupt parameters.

Let's use the KVM_S390_INT_IO macro as for adapter interrupts.

---
 target-s390x/kvm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target-s390x/kvm.c +3 -2
index 8f46fd0..f108cd3 100644
@@ -2071,8 +2071,9 @@ void kvm_s390_io_interrupt(uint16_t subchannel_id,
     if (io_int_word & IO_INT_WORD_AI) {
         irq.type = KVM_S390_INT_IO(1, 0, 0, 0);
     } else {
-        irq.type = ((subchannel_id & 0xff00) << 24) |
-            ((subchannel_id & 0x00060) << 22) | (subchannel_nr << 16);
+        irq.type = KVM_S390_INT_IO(0, (subchannel_id & 0xff00) >> 8,
+                                      (subchannel_id & 0x0006),
+                                      subchannel_nr);
     }
     kvm_s390_floating_interrupt(&irq);
 }
Signature · 1 line
2.9.0
#4 lore raw

[Qemu-devel] [PULL 4/7] s390x/css: introduce property type for device ids

In reply to Cornelia Huck

Let's introduce a CssDevId to handle device ids of the xx.x.xxxx type used for channel devices. This has some benefits:

- We can use them in virtio-ccw and split the validity checks for a channel device id in general from the constraint checking within the virtio-ccw scope.
- We can reuse the device id type for future non-virtio channel devices.

While we're at it, improve the validity checks and disallow e.g. trailing characters.

---
 hw/s390x/css.c         | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/s390x/virtio-ccw.c  | 79 ++++++++++++++++++++----------------------------
 hw/s390x/virtio-ccw.h  |  2 +-
 include/hw/s390x/css.h | 17 +++++++++++
 4 files changed, 131 insertions(+), 48 deletions(-)
hw/s390x/css.c +81 -0
index aceb1c0..7666881 100644
@@ -11,6 +11,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qapi/visitor.h"
 #include <hw/qdev.h>
 #include "qemu/bitops.h"
 #include "exec/address-spaces.h"
@@ -1681,3 +1682,83 @@ void css_reset(void)
     channel_subsys.max_cssid = 0;
     channel_subsys.max_ssid = 0;
 }
+
+static void get_css_devid(Object *obj, Visitor *v, const char *name,
+                          void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    CssDevId *dev_id = qdev_get_prop_ptr(dev, prop);
+    char buffer[] = "xx.x.xxxx";
+    char *p = buffer;
+    int r;
+
+    if (dev_id->valid) {
+
+        r = snprintf(buffer, sizeof(buffer), "%02x.%1x.%04x", dev_id->cssid,
+                     dev_id->ssid, dev_id->devid);
+        assert(r == sizeof(buffer) - 1);
+
+        /* drop leading zero */
+        if (dev_id->cssid <= 0xf) {
+            p++;
+        }
+    } else {
+        snprintf(buffer, sizeof(buffer), "<unset>");
+    }
+
+    visit_type_str(v, name, &p, errp);
+}
+
+/*
+ * parse <cssid>.<ssid>.<devid> and assert valid range for cssid/ssid
+ */
+static void set_css_devid(Object *obj, Visitor *v, const char *name,
+                          void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    CssDevId *dev_id = qdev_get_prop_ptr(dev, prop);
+    Error *local_err = NULL;
+    char *str;
+    int num, n1, n2;
+    unsigned int cssid, ssid, devid;
+
+    if (dev->realized) {
+        qdev_prop_set_after_realize(dev, name, errp);
+        return;
+    }
+
+    visit_type_str(v, name, &str, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    num = sscanf(str, "%2x.%1x%n.%4x%n", &cssid, &ssid, &n1, &devid, &n2);
+    if (num != 3 || (n2 - n1) != 5 || strlen(str) != n2) {
+        error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+        goto out;
+    }
+    if ((cssid > MAX_CSSID) || (ssid > MAX_SSID)) {
+        error_setg(errp, "Invalid cssid or ssid: cssid %x, ssid %x",
+                   cssid, ssid);
+        goto out;
+    }
+
+    dev_id->cssid = cssid;
+    dev_id->ssid = ssid;
+    dev_id->devid = devid;
+    dev_id->valid = true;
+
+out:
+    g_free(str);
+}
+
+PropertyInfo css_devid_propinfo = {
+    .name = "str",
+    .description = "Identifier of an I/O device in the channel "
+                   "subsystem, example: fe.1.23ab",
+    .get = get_css_devid,
+    .set = set_css_devid,
+};
hw/s390x/virtio-ccw.c +32 -47

163 lines not on this page · raw message

hw/s390x/virtio-ccw.h +1 -1
index 86b9edb..0bfb5d9 100644
@@ -80,7 +80,7 @@ typedef struct VirtIOCCWDeviceClass {
 struct VirtioCcwDevice {
     DeviceState parent_obj;
     SubchDev *sch;
-    char *bus_id;
+    CssDevId bus_id;
     int revision;
     uint32_t max_rev;
     VirtioBusState bus;
include/hw/s390x/css.h +17 -0
index 98b2e2c..38f4d77 100644
@@ -151,5 +151,22 @@ int css_do_rsch(SubchDev *sch);
 int css_do_rchp(uint8_t cssid, uint8_t chpid);
 bool css_present(uint8_t cssid);
 #endif
+/*
+ * Identify a device within the channel subsystem.
+ * Note that this can be used to identify either the subchannel or
+ * the attached I/O device, as there's always one I/O device per
+ * subchannel.
+ */
+typedef struct CssDevId {
+    uint8_t cssid;
+    uint8_t ssid;
+    uint16_t devid;
+    bool valid;
+} CssDevId;
+
+extern PropertyInfo css_devid_propinfo;
+
+#define DEFINE_PROP_CSS_DEV_ID(_n, _s, _f) \
+    DEFINE_PROP(_n, _s, _f, css_devid_propinfo, CssDevId)
 
 #endif
Signature · 1 line
2.9.0
#5 lore raw

[Qemu-devel] [PULL 5/7] virtio-ccw: Provide traces for indicator changes

In reply to Cornelia Huck

From: Christian Borntraeger <[email protected]>

This allows to trace changes in the summary and queue indicators for the non-irqfd case. For irqfd, kernel traces are needed instead.

---
 hw/s390x/virtio-ccw.c | 1 +
 trace-events          | 1 +
 2 files changed, 2 insertions(+)
hw/s390x/virtio-ccw.c +1 -0
index e62a3a3..2192be8 100644
@@ -1091,6 +1091,7 @@ static uint8_t virtio_set_ind_atomic(SubchDev *sch, uint64_t ind_loc,
         ind_old = *ind_addr;
         ind_new = ind_old | to_be_set;
     } while (atomic_cmpxchg(ind_addr, ind_old, ind_new) != ind_old);
+    trace_virtio_ccw_set_ind(ind_loc, ind_old, ind_new);
     cpu_physical_memory_unmap(ind_addr, len, 1, len);
 
     return ind_old;
trace-events +1 -0
index 421d89f..2f14205 100644
@@ -1475,6 +1475,7 @@ css_adapter_interrupt(uint8_t isc) "CSS: adapter I/O interrupt (isc %x)"
 # hw/s390x/virtio-ccw.c
 virtio_ccw_interpret_ccw(int cssid, int ssid, int schid, int cmd_code) "VIRTIO-CCW: %x.%x.%04x: interpret command %x"
 virtio_ccw_new_device(int cssid, int ssid, int schid, int devno, const char *devno_mode) "VIRTIO-CCW: add subchannel %x.%x.%04x, devno %04x (%s)"
+virtio_ccw_set_ind(uint64_t ind_loc, uint8_t ind_old, uint8_t ind_new) "VIRTIO-CCW: indicator at %" PRIu64 ": %x->%x"
 
 # hw/intc/s390_flic_kvm.c
 flic_create_device(int err) "flic: create device failed %d"
Signature · 1 line
2.9.0
#6 lore raw

[Qemu-devel] [PULL 2/7] s390x/kvm: add interface for clearing IO irqs

In reply to Cornelia Huck

From: Halil Pasic <[email protected]>

According to the platform specification, under certain conditions, pending IO interruptions have to be cleared. Let's add an interface for that.

---
 hw/intc/s390_flic.c          |  8 ++++++++
 hw/intc/s390_flic_kvm.c      | 26 ++++++++++++++++++++++++++
 include/hw/s390x/s390_flic.h |  2 ++
 3 files changed, 36 insertions(+)
hw/intc/s390_flic.c +8 -0
index bc75fa7..6ab29ef 100644
@@ -67,6 +67,13 @@ static void qemu_s390_release_adapter_routes(S390FLICState *fs,
 {
 }
 
+static int qemu_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id,
+                           uint16_t subchannel_nr)
+{
+    /* Fixme TCG */
+    return -ENOSYS;
+}
+
 static void qemu_s390_flic_class_init(ObjectClass *oc, void *data)
 {
     S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc);
@@ -75,6 +82,7 @@ static void qemu_s390_flic_class_init(ObjectClass *oc, void *data)
     fsc->io_adapter_map = qemu_s390_io_adapter_map;
     fsc->add_adapter_routes = qemu_s390_add_adapter_routes;
     fsc->release_adapter_routes = qemu_s390_release_adapter_routes;
+    fsc->clear_io_irq = qemu_s390_clear_io_flic;
 }
 
 static const TypeInfo qemu_s390_flic_info = {
hw/intc/s390_flic_kvm.c +26 -0
index eed6325..680857f 100644
@@ -30,6 +30,7 @@ typedef struct KVMS390FLICState {
     S390FLICState parent_obj;
 
     uint32_t fd;
+    bool clear_io_supported;
 } KVMS390FLICState;
 
 DeviceState *s390_flic_kvm_create(void)
@@ -130,6 +131,24 @@ int kvm_s390_inject_flic(struct kvm_s390_irq *irq)
     return flic_enqueue_irqs(irq, sizeof(*irq), flic);
 }
 
+static int kvm_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id,
+                           uint16_t subchannel_nr)
+{
+    KVMS390FLICState *flic = KVM_S390_FLIC(fs);
+    int rc;
+    uint32_t sid = subchannel_id << 16 | subchannel_nr;
+    struct kvm_device_attr attr = {
+        .group = KVM_DEV_FLIC_CLEAR_IO_IRQ,
+        .addr = (uint64_t) &sid,
+        .attr = sizeof(sid),
+    };
+    if (unlikely(!flic->clear_io_supported)) {
+        return -ENOSYS;
+    }
+    rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
+    return rc ? -errno : 0;
+}
+
 /**
  * __get_all_irqs - store all pending irqs in buffer
  * @flic: pointer to flic device state
@@ -358,6 +377,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
 {
     KVMS390FLICState *flic_state = KVM_S390_FLIC(dev);
     struct kvm_create_device cd = {0};
+    struct kvm_device_attr test_attr = {0};
     int ret;
 
     flic_state->fd = -1;
@@ -374,6 +394,11 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
     }
     flic_state->fd = cd.fd;
 
+    /* Check clear_io_irq support */
+    test_attr.group = KVM_DEV_FLIC_CLEAR_IO_IRQ;
+    flic_state->clear_io_supported = !ioctl(flic_state->fd,
+                                            KVM_HAS_DEVICE_ATTR, test_attr);
+
     /* Register savevm handler for floating interrupts */
     register_savevm(NULL, "s390-flic", 0, 1, kvm_flic_save,
                     kvm_flic_load, (void *) flic_state);
@@ -420,6 +445,7 @@ static void kvm_s390_flic_class_init(ObjectClass *oc, void *data)
     fsc->io_adapter_map = kvm_s390_io_adapter_map;
     fsc->add_adapter_routes = kvm_s390_add_adapter_routes;
     fsc->release_adapter_routes = kvm_s390_release_adapter_routes;
+    fsc->clear_io_irq = kvm_s390_clear_io_flic;
 }
 
 static const TypeInfo kvm_s390_flic_info = {
include/hw/s390x/s390_flic.h +2 -0
index 200e7e9..1dac2ee 100644
@@ -49,6 +49,8 @@ typedef struct S390FLICStateClass {
                           bool do_map);
     int (*add_adapter_routes)(S390FLICState *fs, AdapterRoutes *routes);
     void (*release_adapter_routes)(S390FLICState *fs, AdapterRoutes *routes);
+    int (*clear_io_irq)(S390FLICState *fs, uint16_t subchannel_id,
+                        uint16_t subchannel_nr);
 } S390FLICStateClass;
 
 #define TYPE_KVM_S390_FLIC "s390-flic-kvm"
Signature · 1 line
2.9.0
#7 lore raw

[Qemu-devel] [PULL 6/7] s390x: Limit s390-ccw machines to 248 CPUs

In reply to Cornelia Huck

From: Christian Borntraeger <[email protected]>

The sclp scp read info call fills in a buffer with information about the system. With more than 248 CPUs we overflow the 4k buffer of the SCCB, leading to random data corruption. Basically ALL guest operating systems call scp read info, so let's limit the machines to 248 CPUs to make it obvious that >=249 does not work.

As KVM also limits itself to 248 and TCG on s390 does not support SMP, this should cause no regression for any user as no VMs with more than 248 VCPUs were ever possible.

---
 hw/s390x/s390-virtio-ccw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +1 -1
index 95ff5e3..e257ca5 100644
@@ -204,7 +204,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
     mc->no_parallel = 1;
     mc->no_sdcard = 1;
     mc->use_sclp = 1;
-    mc->max_cpus = 255;
+    mc->max_cpus = 248;
     mc->get_hotplug_handler = s390_get_hotplug_handler;
     hc->plug = s390_machine_device_plug;
     nc->nmi_monitor_handler = s390_nmi;
Signature · 1 line
2.9.0
#8 lore raw
In reply to Cornelia Huck
Quoted 8 lines · Cornelia Huck

The following changes since commit a28aae041aa76a779df6467a7fe68b9e8a8b2c0a:

Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.7-20160614' into staging (2016-06-14 09:30:05 +0100)

are available in the git repository at:

git://github.com/cohuck/qemu tags/s390x-20160614

Quoted 9 lines

for you to fetch changes up to 393ad2a4a15db3836698de0e11249b4ec9dafb11:

s390x/kvm: Fixup interrupt type for non-adapter I/O interrupts (2016-06-14 14:00:05 +0200)

----------------------------------------------------------------
More s390x patches, this time mostly dealing with channel I/O:
Bugfixes and cleanups, and dequeue pending interrupts after machine checks.

Applied, thanks.

-- PMM