Skip to contentSkip to conversation

S390 SCLP improvements for CPU Hotplug

PATCH Superseded Jason J. Herne 2 participants 5 messages Jan 20, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover S390 SCLP improvements for CPU Hotplug

From: "Jason J. Herne" <[email protected]>

Improvements to SCLP, mainly the Read SCP/CPU Info subcommands, to support future cpu hotplug operations on the s390 target.

Jason J. Herne (3):
s390-sclp: Define New SCLP Codes
s390-sclp: SCLP CPU Info
s390-sclp: SCLP Event integration

 hw/s390x/Makefile.objs            |   1 +
 hw/s390x/event-facility.c         |   6 ++
 hw/s390x/sclp.c                   |  53 +++++++++++++++++-
 hw/s390x/sclpcpu.c                | 113 ++++++++++++++++++++++++++++++++++++++
 include/hw/s390x/event-facility.h |   3 +
 include/hw/s390x/sclp.h           |  41 ++++++++++++++
 6 files changed, 216 insertions(+), 1 deletion(-)
 create mode 100644 hw/s390x/sclpcpu.c
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 1/3 s390-sclp: Define New SCLP Codes

From: "Jason J. Herne" <[email protected]>

Define new SCLP codes to improve code readability.

---
 hw/s390x/sclp.c         | 2 +-
 include/hw/s390x/sclp.h | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
hw/s390x/sclp.c +1 -1
index 86d6ae0..cb035e9 100644
@@ -45,7 +45,7 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
 {
     S390SCLPDevice *sdev = get_event_facility();
 
-    switch (code) {
+    switch (code & SCLP_CMD_CODE_MASK) {
     case SCLP_CMDW_READ_SCP_INFO:
     case SCLP_CMDW_READ_SCP_INFO_FORCED:
         read_SCP_info(sccb);
include/hw/s390x/sclp.h +8 -0
index 231a38a..74e8d94 100644
@@ -17,6 +17,8 @@
 #include <hw/sysbus.h>
 #include <hw/qdev.h>
 
+#define SCLP_CMD_CODE_MASK                      0xffff00ff
+
 /* SCLP command codes */
 #define SCLP_CMDW_READ_SCP_INFO                 0x00020001
 #define SCLP_CMDW_READ_SCP_INFO_FORCED          0x00120001
@@ -26,6 +28,12 @@
 #define SCLP_CMD_WRITE_EVENT_DATA               0x00760005
 #define SCLP_CMD_WRITE_EVENT_MASK               0x00780005
 
+/* CPU hotplug SCLP codes */
+#define SCLP_HAS_CPU_INFO                       0x0C00000000000000ULL
+#define SCLP_CMDW_READ_CPU_INFO                 0x00010001
+#define SCLP_CMDW_CONFIGURE_CPU                 0x00110001
+#define SCLP_CMDW_DECONFIGURE_CPU               0x00100001
+
 /* SCLP response codes */
 #define SCLP_RC_NORMAL_READ_COMPLETION          0x0010
 #define SCLP_RC_NORMAL_COMPLETION               0x0020
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 2/3 s390-sclp: SCLP CPU Info

In reply to Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Implement the CPU data in SCLP "Read SCP Info". And implement "Read CPU Info" SCLP command. This data will be used by the guest to get information about hot plugged cpus.

---
 hw/s390x/sclp.c         | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/s390x/sclp.h | 32 +++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
hw/s390x/sclp.c +51 -0
index cb035e9..4e0c564 100644
@@ -15,6 +15,7 @@
 #include "cpu.h"
 #include "sysemu/kvm.h"
 #include "exec/memory.h"
+#include "sysemu/sysemu.h"
 
 #include "hw/s390x/sclp.h"
 
@@ -31,7 +32,26 @@ static inline S390SCLPDevice *get_event_facility(void)
 static void read_SCP_info(SCCB *sccb)
 {
     ReadInfo *read_info = (ReadInfo *) sccb;
+    CPUState *cpu;
     int shift = 0;
+    int cpu_count = 0;
+    int i = 0;
+
+    CPU_FOREACH(cpu) {
+        cpu_count++;
+    }
+
+    /* CPU information */
+    read_info->entries_cpu = cpu_to_be16(cpu_count);
+    read_info->offset_cpu = cpu_to_be16(offsetof(ReadInfo, entries));
+    read_info->highest_cpu = cpu_to_be16(max_cpus);
+
+    for (i = 0; i < cpu_count; i++) {
+        read_info->entries[i].address = i;
+        read_info->entries[i].type = 0;
+    }
+
+    read_info->facilities = cpu_to_be64(SCLP_HAS_CPU_INFO);
 
     while ((ram_size >> (20 + shift)) > 65535) {
         shift++;
@@ -41,6 +61,34 @@ static void read_SCP_info(SCCB *sccb)
     sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
 }
 
+/* Provide information about the CPU */
+static void sclp_read_cpu_info(SCCB *sccb)
+{
+    ReadCpuInfo *cpu_info = (ReadCpuInfo *) sccb;
+    CPUState *cpu;
+    int cpu_count = 0;
+    int i = 0;
+
+    CPU_FOREACH(cpu) {
+        cpu_count++;
+    }
+
+    cpu_info->nr_configured = cpu_to_be16(cpu_count);
+    cpu_info->offset_configured = cpu_to_be16(offsetof(ReadCpuInfo, entries));
+    cpu_info->nr_standby = cpu_to_be16(0);
+
+    /* The standby offset is 16-byte for each CPU */
+    cpu_info->offset_standby = cpu_to_be16(cpu_info->offset_configured
+        + cpu_info->nr_configured*sizeof(CPUEntry));
+
+    for (i = 0; i < cpu_count; i++) {
+        cpu_info->entries[i].address = i;
+        cpu_info->entries[i].type = 0;
+    }
+
+    sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
+}
+
 static void sclp_execute(SCCB *sccb, uint64_t code)
 {
     S390SCLPDevice *sdev = get_event_facility();
@@ -50,6 +98,9 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
     case SCLP_CMDW_READ_SCP_INFO_FORCED:
         read_SCP_info(sccb);
         break;
+    case SCLP_CMDW_READ_CPU_INFO:
+        sclp_read_cpu_info(sccb);
+        break;
     default:
         sdev->sclp_command_handler(sdev->ef, sccb, code);
         break;
include/hw/s390x/sclp.h +32 -0
index 74e8d94..a625098 100644
@@ -79,12 +79,44 @@ typedef struct SCCBHeader {
 
 #define SCCB_DATA_LEN (SCCB_SIZE - sizeof(SCCBHeader))
 
+/* CPU information */
+typedef struct CPUEntry {
+    uint8_t address;
+    uint8_t reserved0[13];
+    uint8_t type;
+    uint8_t reserved1;
+} QEMU_PACKED CPUEntry;
+
 typedef struct ReadInfo {
     SCCBHeader h;
     uint16_t rnmax;
     uint8_t rnsize;
+    uint8_t  _reserved1[16 - 11];       /* 11-15 */
+    uint16_t entries_cpu;               /* 16-17 */
+    uint16_t offset_cpu;                /* 18-19 */
+    uint8_t  _reserved2[24 - 20];       /* 20-23 */
+    uint8_t  loadparm[8];               /* 24-31 */
+    uint8_t  _reserved3[48 - 32];       /* 32-47 */
+    uint64_t facilities;                /* 48-55 */
+    uint8_t  _reserved0[100 - 56];
+    uint32_t rnsize2;
+    uint64_t rnmax2;
+    uint8_t  _reserved4[120-112];       /* 112-119 */
+    uint16_t highest_cpu;
+    uint8_t  _reserved5[128 - 122];     /* 122-127 */
+    struct CPUEntry entries[0];
 } QEMU_PACKED ReadInfo;
 
+typedef struct ReadCpuInfo {
+    SCCBHeader h;
+    uint16_t nr_configured;         /* 8-9 */
+    uint16_t offset_configured;     /* 10-11 */
+    uint16_t nr_standby;            /* 12-13 */
+    uint16_t offset_standby;        /* 14-15 */
+    uint8_t reserved0[24-16];       /* 16-23 */
+    struct CPUEntry entries[0];
+} QEMU_PACKED ReadCpuInfo;
+
 typedef struct SCCB {
     SCCBHeader h;
     char data[SCCB_DATA_LEN];
Signature · 1 line
1.8.3.2
#3 lore raw

PATCH 3/3 s390-sclp: SCLP Event integration

In reply to Jason J. Herne

From: "Jason J. Herne" <[email protected]>

Add an sclp event for "cpu was hot plugged". This allows Qemu to deliver an SCLP interrupt to the guest stating that the requested cpu hotplug was completed.

---
 hw/s390x/Makefile.objs            |   1 +
 hw/s390x/event-facility.c         |   6 ++
 hw/s390x/sclpcpu.c                | 113 ++++++++++++++++++++++++++++++++++++++
 include/hw/s390x/event-facility.h |   3 +
 include/hw/s390x/sclp.h           |   1 +
 5 files changed, 124 insertions(+)
 create mode 100644 hw/s390x/sclpcpu.c
hw/s390x/Makefile.objs +1 -0
index 77e1218..1ba6c3a 100644
@@ -3,6 +3,7 @@ obj-y += s390-virtio-hcall.o
 obj-y += sclp.o
 obj-y += event-facility.o
 obj-y += sclpquiesce.o
+obj-y += sclpcpu.o
 obj-y += ipl.o
 obj-y += css.o
 obj-y += s390-virtio-ccw.o
hw/s390x/event-facility.c +6 -0
index 25951a0..575d407 100644
@@ -32,6 +32,8 @@ struct SCLPEventFacility {
     unsigned int receive_mask;
 };
 
+SCLPEvent cpu_hotplug;
+
 /* return true if any child has event pending set */
 static bool event_pending(SCLPEventFacility *ef)
 {
@@ -335,6 +337,10 @@ static int init_event_facility(S390SCLPDevice *sdev)
     }
     qdev_init_nofail(quiesce);
 
+    object_initialize(&cpu_hotplug, sizeof(cpu_hotplug), "sclp-cpu-hotplug");
+    qdev_set_parent_bus(DEVICE(&cpu_hotplug), BUS(&event_facility->sbus));
+    object_property_set_bool(OBJECT(&cpu_hotplug), true, "realized", NULL);
+
     return 0;
 }
 
hw/s390x/sclpcpu.c new file +113 -0

113 lines not on this page · raw message

include/hw/s390x/event-facility.h +3 -0
index 7ce7079..4347f06 100644
@@ -17,10 +17,12 @@
 
 #include <hw/qdev.h>
 #include "qemu/thread.h"
+#include "hw/s390x/sclp.h"
 
 /* SCLP event types */
 #define SCLP_EVENT_OPRTNS_COMMAND               0x01
 #define SCLP_EVENT_MESSAGE                      0x02
+#define SCLP_EVENT_CONFIG_MGT_DATA              0x04
 #define SCLP_EVENT_PMSGCMD                      0x09
 #define SCLP_EVENT_ASCII_CONSOLE_DATA           0x1a
 #define SCLP_EVENT_SIGNAL_QUIESCE               0x1d
@@ -28,6 +30,7 @@
 /* SCLP event masks */
 #define SCLP_EVENT_MASK_SIGNAL_QUIESCE          0x00000008
 #define SCLP_EVENT_MASK_MSG_ASCII               0x00000040
+#define SCLP_EVENT_MASK_CONFIG_MGT_DATA         0x10000000
 #define SCLP_EVENT_MASK_OP_CMD                  0x80000000
 #define SCLP_EVENT_MASK_MSG                     0x40000000
 #define SCLP_EVENT_MASK_PMSGCMD                 0x00800000
include/hw/s390x/sclp.h +1 -0
index a625098..2fec2f8 100644
@@ -154,5 +154,6 @@ typedef struct S390SCLPDeviceClass {
 
 void s390_sclp_init(void);
 void sclp_service_interrupt(uint32_t sccb);
+void raise_irq_cpu_hotplug(void);
 
 #endif
Signature · 1 line
1.8.3.2
#4 lore raw

Re: [Qemu-devel] [PATCH 3/3] s390-sclp: SCLP Event integration

Hi,

Thanks for splitting these off.

Am 20.01.2014 17:56, schrieb Jason J. Herne:

Quoted 15 lines

From: "Jason J. Herne" <[email protected]>

Add an sclp event for "cpu was hot plugged". This allows Qemu to deliver an SCLP interrupt to the guest stating that the requested cpu hotplug was completed.

---
 hw/s390x/Makefile.objs            |   1 +
 hw/s390x/event-facility.c         |   6 ++
 hw/s390x/sclpcpu.c                | 113 ++++++++++++++++++++++++++++++++++++++
 include/hw/s390x/event-facility.h |   3 +
 include/hw/s390x/sclp.h           |   1 +
 5 files changed, 124 insertions(+)
 create mode 100644 hw/s390x/sclpcpu.c

[...]

Quoted 14 lines
hw/s390x/event-facility.c +2 -0
index 25951a0..575d407 100644
@@ -32,6 +32,8 @@ struct SCLPEventFacility {
     unsigned int receive_mask;
 };
 
+SCLPEvent cpu_hotplug;
+
 /* return true if any child has event pending set */
 static bool event_pending(SCLPEventFacility *ef)
 {

hw/s390x/event-facility.c static int init_event_facility(S390SCLPDevice *sdev) · line 340

Quoted 4 lines
hw/s390x/event-facility.c +1 -0
@@ -335,6 +337,10 @@ static int init_event_facility(S390SCLPDevice *sdev)
     }
     qdev_init_nofail(quiesce);
 
+    object_initialize(&cpu_hotplug, sizeof(cpu_hotplug), "sclp-cpu-hotplug");

Any chance we can use a TYPE_* define in event-facility.h?

hw/s390x/event-facility.c static int init_event_facility(S390SCLPDevice *sdev) · line 342

Quoted 2 lines
hw/s390x/event-facility.c +2 -0
+    qdev_set_parent_bus(DEVICE(&cpu_hotplug), BUS(&event_facility->sbus));
+    object_property_set_bool(OBJECT(&cpu_hotplug), true, "realized", NULL);

Otherwise looks okay to me, except for two minor nits below.

Quoted 9 lines
hw/s390x/event-facility.c +1 -0
+
     return 0;
 }
 
hw/s390x/sclpcpu.c new file +0 -0
new file mode 100644
index 0000000..7fd1f9e

[...]

Quoted 1 line

+static void cpu_class_init(ObjectClass *klass, void *data)

Please use oc to avoid the deliberately misspelled klass.

Quoted 9 lines
hw/s390x/sclpcpu.c new file +9 -0
+{
+    SCLPEventClass *k = SCLP_EVENT_CLASS(klass);
+
+    k->init = irq_cpu_hotplug_init;
+    k->get_send_mask = send_mask;
+    k->get_receive_mask = receive_mask;
+    k->read_event_data = read_event_data;
+    k->write_event_data = NULL;
+}

hw/s390x/sclpcpu.c line 107

Quoted 10 lines
hw/s390x/sclpcpu.c new file +10 -0
+
+static const TypeInfo sclp_cpu_info = {
+    .name          = "sclp-cpu-hotplug",
+    .parent        = TYPE_SCLP_EVENT,
+    .instance_size = sizeof(SCLPEvent),
+    .class_init    = cpu_class_init,
+    .class_size    = sizeof(SCLPEventClass),
+};
+
+static void register_types(void)

Please use your unique prefix: sclp_cpu_register_types

hw/s390x/sclpcpu.c line 113

Quoted 6 lines
hw/s390x/sclpcpu.c new file +6 -0
+{
+    type_register_static(&sclp_cpu_info);
+}
+
+type_init(register_types)
+

Trailing white line.

Quoted 18 lines
include/hw/s390x/event-facility.h +2 -0
index 7ce7079..4347f06 100644
@@ -17,10 +17,12 @@
 
 #include <hw/qdev.h>
 #include "qemu/thread.h"
+#include "hw/s390x/sclp.h"
 
 /* SCLP event types */
 #define SCLP_EVENT_OPRTNS_COMMAND               0x01
 #define SCLP_EVENT_MESSAGE                      0x02
+#define SCLP_EVENT_CONFIG_MGT_DATA              0x04
 #define SCLP_EVENT_PMSGCMD                      0x09
 #define SCLP_EVENT_ASCII_CONSOLE_DATA           0x1a
 #define SCLP_EVENT_SIGNAL_QUIESCE               0x1d

include/hw/s390x/event-facility.h line 36

Quoted 7 lines
include/hw/s390x/event-facility.h +1 -0
@@ -28,6 +30,7 @@
 /* SCLP event masks */
 #define SCLP_EVENT_MASK_SIGNAL_QUIESCE          0x00000008
 #define SCLP_EVENT_MASK_MSG_ASCII               0x00000040
+#define SCLP_EVENT_MASK_CONFIG_MGT_DATA         0x10000000
 #define SCLP_EVENT_MASK_OP_CMD                  0x80000000
 #define SCLP_EVENT_MASK_MSG                     0x40000000
 #define SCLP_EVENT_MASK_PMSGCMD                 0x00800000

[snip]

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg