* [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug
@ 2013-10-31 17:21 Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 1/8 v4] s390-sclp: Define New SCLP Codes Jason J. Herne
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Jason J. Herne @ 2013-10-31 17:21 UTC (permalink / raw)
To: afaerber, agraf, borntraeger, jfrei, imammedo, qemu-devel,
ehabkost
Cc: Jason J. Herne
From: "Jason J. Herne" <jjherne@us.ibm.com>
Latest code for cpu Hotplug on S390 architecture.
The last version can be found here:
http://lists.gnu.org/archive/html/qemu-devel/2013-08/msg00076.html
There is also a patch in this series to add cpu-add to the Qemu monitor
interface.
Hotplugged cpus are created in the configured state and can be used by the
guest after the guest onlines the cpu by:
"echo 1 > /sys/bus/cpu/devices/cpuN/online"
Hot unplugging is currently not implemented by this code.
Jason J. Herne (8):
s390-sclp: Define New SCLP Codes
s390-sclp: SCLP CPU Info
s390-sclp: SCLP Event integration
s390: Storage key global access
s390-cpu: ipi_states enhancements
s390-cpu: s390 cpu init improvements for hotplug
s390-hotplug: Implement hot_add_cpu hook
qemu-monitor: HMP cpu-add wrapper
hmp-commands.hx | 13 +++++
hmp.c | 10 ++++
hmp.h | 1 +
hw/s390x/Makefile.objs | 1 +
hw/s390x/event-facility.c | 6 ++
hw/s390x/s390-virtio-ccw.c | 4 +-
hw/s390x/s390-virtio.c | 36 ++++++------
hw/s390x/s390-virtio.h | 2 +-
hw/s390x/sclp.c | 53 ++++++++++++++++-
hw/s390x/sclpcpu.c | 118 ++++++++++++++++++++++++++++++++++++++
include/hw/s390x/event-facility.h | 3 +
include/hw/s390x/sclp.h | 41 +++++++++++++
target-s390x/cpu.c | 43 +++++++++++++-
target-s390x/cpu.h | 6 ++
14 files changed, 315 insertions(+), 22 deletions(-)
create mode 100644 hw/s390x/sclpcpu.c
--
1.8.3.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 1/8 v4] s390-sclp: Define New SCLP Codes
2013-10-31 17:21 [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
@ 2013-10-31 17:21 ` Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 2/8 v4] s390-sclp: SCLP CPU Info Jason J. Herne
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jason J. Herne @ 2013-10-31 17:21 UTC (permalink / raw)
To: afaerber, agraf, borntraeger, jfrei, imammedo, qemu-devel,
ehabkost
Cc: Jason J. Herne
From: "Jason J. Herne" <jjherne@us.ibm.com>
Define new SCLP codes to improve code readability.
Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
---
hw/s390x/sclp.c | 2 +-
include/hw/s390x/sclp.h | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index 86d6ae0..cb035e9 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -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);
diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
index 231a38a..74e8d94 100644
--- a/include/hw/s390x/sclp.h
+++ b/include/hw/s390x/sclp.h
@@ -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
--
1.8.3.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 2/8 v4] s390-sclp: SCLP CPU Info
2013-10-31 17:21 [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 1/8 v4] s390-sclp: Define New SCLP Codes Jason J. Herne
@ 2013-10-31 17:21 ` Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 3/8 v4] s390-sclp: SCLP Event integration Jason J. Herne
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jason J. Herne @ 2013-10-31 17:21 UTC (permalink / raw)
To: afaerber, agraf, borntraeger, jfrei, imammedo, qemu-devel,
ehabkost
Cc: Jason J. Herne
From: "Jason J. Herne" <jjherne@us.ibm.com>
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.
Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
---
hw/s390x/sclp.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
include/hw/s390x/sclp.h | 32 +++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index cb035e9..4e0c564 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -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;
diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
index 74e8d94..a625098 100644
--- a/include/hw/s390x/sclp.h
+++ b/include/hw/s390x/sclp.h
@@ -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];
--
1.8.3.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 3/8 v4] s390-sclp: SCLP Event integration
2013-10-31 17:21 [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 1/8 v4] s390-sclp: Define New SCLP Codes Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 2/8 v4] s390-sclp: SCLP CPU Info Jason J. Herne
@ 2013-10-31 17:21 ` Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 4/8 v4] s390: Storage key global access Jason J. Herne
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jason J. Herne @ 2013-10-31 17:21 UTC (permalink / raw)
To: afaerber, agraf, borntraeger, jfrei, imammedo, qemu-devel,
ehabkost
Cc: Jason J. Herne
From: "Jason J. Herne" <jjherne@us.ibm.com>
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.
Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
---
hw/s390x/Makefile.objs | 1 +
hw/s390x/event-facility.c | 6 ++
hw/s390x/sclpcpu.c | 118 ++++++++++++++++++++++++++++++++++++++
include/hw/s390x/event-facility.h | 3 +
include/hw/s390x/sclp.h | 1 +
5 files changed, 129 insertions(+)
create mode 100644 hw/s390x/sclpcpu.c
diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
index 77e1218..1ba6c3a 100644
--- a/hw/s390x/Makefile.objs
+++ b/hw/s390x/Makefile.objs
@@ -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
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index a3aceef..1281bd2 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -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;
}
diff --git a/hw/s390x/sclpcpu.c b/hw/s390x/sclpcpu.c
new file mode 100644
index 0000000..d6c3f44
--- /dev/null
+++ b/hw/s390x/sclpcpu.c
@@ -0,0 +1,118 @@
+/*
+ * SCLP event type
+ * Signal CPU - Trigger SCLP interrupt for system CPU configure or
+ * de-configure
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ * Thang Pham <thang.pham@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at your
+ * option) any later version. See the COPYING file in the top-level directory.
+ *
+ */
+#include "sysemu/sysemu.h"
+#include "hw/s390x/sclp.h"
+#include "hw/s390x/event-facility.h"
+#include "cpu.h"
+#include "sysemu/cpus.h"
+#include "sysemu/kvm.h"
+
+typedef struct ConfigMgtData {
+ EventBufferHeader ebh;
+ uint8_t reserved;
+ uint8_t event_qualifier;
+} QEMU_PACKED ConfigMgtData;
+
+static qemu_irq irq_cpu_hotplug; /* Only used in this file */
+
+#define EVENT_QUAL_CPU_CHANGE 1
+
+void raise_irq_cpu_hotplug(void)
+{
+ qemu_irq_raise(irq_cpu_hotplug);
+}
+
+static int event_type(void)
+{
+ return SCLP_EVENT_CONFIG_MGT_DATA;
+}
+
+static unsigned int send_mask(void)
+{
+ return SCLP_EVENT_MASK_CONFIG_MGT_DATA;
+}
+
+static unsigned int receive_mask(void)
+{
+ return 0;
+}
+
+static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,
+ int *slen)
+{
+ ConfigMgtData *cdata = (ConfigMgtData *) evt_buf_hdr;
+ if (*slen < sizeof(ConfigMgtData)) {
+ return 0;
+ }
+
+ /* Event is no longer pending */
+ if (!event->event_pending) {
+ return 0;
+ }
+ event->event_pending = false;
+
+ /* Event header data */
+ cdata->ebh.length = cpu_to_be16(sizeof(ConfigMgtData));
+ cdata->ebh.type = SCLP_EVENT_CONFIG_MGT_DATA;
+ cdata->ebh.flags |= SCLP_EVENT_BUFFER_ACCEPTED;
+
+ /* Trigger a rescan of CPUs by setting event qualifier */
+ cdata->event_qualifier = EVENT_QUAL_CPU_CHANGE;
+ *slen -= sizeof(ConfigMgtData);
+
+ return 1;
+}
+
+static void trigger_signal(void *opaque, int n, int level)
+{
+ SCLPEvent *event = opaque;
+ event->event_pending = true;
+
+ /* Trigger SCLP read operation */
+ sclp_service_interrupt(0);
+}
+
+static int irq_cpu_hotplug_init(SCLPEvent *event)
+{
+ irq_cpu_hotplug = *qemu_allocate_irqs(trigger_signal, event, 1);
+ return 0;
+}
+
+static void cpu_class_init(ObjectClass *klass, void *data)
+{
+ 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->event_type = event_type;
+ k->read_event_data = read_event_data;
+ k->write_event_data = NULL;
+}
+
+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)
+{
+ type_register_static(&sclp_cpu_info);
+}
+
+type_init(register_types)
diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-facility.h
index 791ab2a..d63969f 100644
--- a/include/hw/s390x/event-facility.h
+++ b/include/hw/s390x/event-facility.h
@@ -17,14 +17,17 @@
#include <hw/qdev.h>
#include "qemu/thread.h"
+#include "hw/s390x/sclp.h"
/* SCLP event types */
+#define SCLP_EVENT_CONFIG_MGT_DATA 0x04
#define SCLP_EVENT_ASCII_CONSOLE_DATA 0x1a
#define SCLP_EVENT_SIGNAL_QUIESCE 0x1d
/* 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_UNCONDITIONAL_READ 0x00
#define SCLP_SELECTIVE_READ 0x01
diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
index a625098..2fec2f8 100644
--- a/include/hw/s390x/sclp.h
+++ b/include/hw/s390x/sclp.h
@@ -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
--
1.8.3.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 4/8 v4] s390: Storage key global access
2013-10-31 17:21 [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
` (2 preceding siblings ...)
2013-10-31 17:21 ` [Qemu-devel] [PATCH 3/8 v4] s390-sclp: SCLP Event integration Jason J. Herne
@ 2013-10-31 17:21 ` Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 5/8 v4] s390-cpu: ipi_states enhancements Jason J. Herne
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jason J. Herne @ 2013-10-31 17:21 UTC (permalink / raw)
To: afaerber, agraf, borntraeger, jfrei, imammedo, qemu-devel,
ehabkost
Cc: Jason J. Herne
From: "Jason J. Herne" <jjherne@us.ibm.com>
Introduces global access to storage key data so we can set it for each cpu in
the S390 cpu initialization routine.
Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
---
hw/s390x/s390-virtio-ccw.c | 3 +--
hw/s390x/s390-virtio.c | 6 +++---
hw/s390x/s390-virtio.h | 2 +-
target-s390x/cpu.h | 3 +++
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 733d988..62319b9 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -80,7 +80,6 @@ static void ccw_init(QEMUMachineInitArgs *args)
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
int shift = 0;
- uint8_t *storage_keys;
int ret;
VirtualCssBus *css_bus;
@@ -112,7 +111,7 @@ static void ccw_init(QEMUMachineInitArgs *args)
storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);
/* init CPUs */
- s390_init_cpus(args->cpu_model, storage_keys);
+ s390_init_cpus(args->cpu_model);
if (kvm_enabled()) {
kvm_s390_enable_css_support(s390_cpu_addr2state(0));
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 7adf92a..804483f 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -53,6 +53,7 @@
static VirtIOS390Bus *s390_bus;
static S390CPU **ipi_states;
+uint8_t *storage_keys;
S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
{
@@ -176,7 +177,7 @@ void s390_init_ipl_dev(const char *kernel_filename,
qdev_init_nofail(dev);
}
-void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
+void s390_init_cpus(const char *cpu_model)
{
int i;
@@ -231,7 +232,6 @@ static void s390_init(QEMUMachineInitArgs *args)
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
int shift = 0;
- uint8_t *storage_keys;
void *virtio_region;
hwaddr virtio_region_len;
hwaddr virtio_region_start;
@@ -273,7 +273,7 @@ static void s390_init(QEMUMachineInitArgs *args)
storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);
/* init CPUs */
- s390_init_cpus(args->cpu_model, storage_keys);
+ s390_init_cpus(args->cpu_model);
/* Create VirtIO network adapters */
s390_create_virtio_net((BusState *)s390_bus, "virtio-net-s390");
diff --git a/hw/s390x/s390-virtio.h b/hw/s390x/s390-virtio.h
index 5c405e7..c1cb042 100644
--- a/hw/s390x/s390-virtio.h
+++ b/hw/s390x/s390-virtio.h
@@ -20,7 +20,7 @@
typedef int (*s390_virtio_fn)(const uint64_t *args);
void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn);
-void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys);
+void s390_init_cpus(const char *cpu_model);
void s390_init_ipl_dev(const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 8be5648..81e494d 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -377,6 +377,9 @@ static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
{
}
#endif
+
+extern uint8_t *storage_keys;
+
S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
void s390_add_running_cpu(S390CPU *cpu);
unsigned s390_del_running_cpu(S390CPU *cpu);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 5/8 v4] s390-cpu: ipi_states enhancements
2013-10-31 17:21 [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
` (3 preceding siblings ...)
2013-10-31 17:21 ` [Qemu-devel] [PATCH 4/8 v4] s390: Storage key global access Jason J. Herne
@ 2013-10-31 17:21 ` Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 6/8 v4] [PATCH RFC v4] s390-cpu: s390 cpu init improvements for hotplug Jason J. Herne
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jason J. Herne @ 2013-10-31 17:21 UTC (permalink / raw)
To: afaerber, agraf, borntraeger, jfrei, imammedo, qemu-devel,
ehabkost
Cc: Jason J. Herne
From: "Jason J. Herne" <jjherne@us.ibm.com>
Modify s390_cpu_addr2state to allow fetching state information for cpu addresses
above smp_cpus. Hotplug requires this capability.
Also add s390_cpu_set_state function to allow modification of ipi_state entries
during hotplug.
Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
---
hw/s390x/s390-virtio.c | 9 +++++----
target-s390x/cpu.h | 1 +
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 804483f..8fbff67 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -55,12 +55,13 @@ static VirtIOS390Bus *s390_bus;
static S390CPU **ipi_states;
uint8_t *storage_keys;
-S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
+void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state)
{
- if (cpu_addr >= smp_cpus) {
- return NULL;
- }
+ ipi_states[cpu_addr] = state;
+}
+S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
+{
return ipi_states[cpu_addr];
}
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 81e494d..8873536 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -380,6 +380,7 @@ static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
extern uint8_t *storage_keys;
+void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state);
S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
void s390_add_running_cpu(S390CPU *cpu);
unsigned s390_del_running_cpu(S390CPU *cpu);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 6/8 v4] [PATCH RFC v4] s390-cpu: s390 cpu init improvements for hotplug
2013-10-31 17:21 [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
` (4 preceding siblings ...)
2013-10-31 17:21 ` [Qemu-devel] [PATCH 5/8 v4] s390-cpu: ipi_states enhancements Jason J. Herne
@ 2013-10-31 17:21 ` Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 7/8 v4] [PATCH RFC v4] s390-hotplug: Implement hot_add_cpu hook Jason J. Herne
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jason J. Herne @ 2013-10-31 17:21 UTC (permalink / raw)
To: afaerber, agraf, borntraeger, jfrei, imammedo, qemu-devel,
ehabkost
Cc: Jason J. Herne
From: "Jason J. Herne" <jjherne@us.ibm.com>
s390_new_cpu is created to encapsulate the creation of a new QOM S390CPU
object given a cpuid and a model string.
All actual cpu initialization code is moved from boot time specific functions to
s390_cpu_initfn (qom init routine) or to s390_new_cpu. This is done to allow us
to use the same basic code path for a cpu created at boot time and one created
during a hotplug operation.
Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
---
hw/s390x/s390-virtio.c | 27 +++++++++++++++------------
target-s390x/cpu.c | 14 ++++++++++++--
2 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 8fbff67..8d0e5e2 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -57,11 +57,16 @@ uint8_t *storage_keys;
void s390_cpu_set_ipistate(uint16_t cpu_addr, S390CPU *state)
{
- ipi_states[cpu_addr] = state;
+ if (cpu_addr < max_cpus) {
+ ipi_states[cpu_addr] = state;
+ }
}
S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
{
+ if (cpu_addr >= max_cpus) {
+ return NULL;
+ }
return ipi_states[cpu_addr];
}
@@ -181,24 +186,22 @@ void s390_init_ipl_dev(const char *kernel_filename,
void s390_init_cpus(const char *cpu_model)
{
int i;
+ char *name;
if (cpu_model == NULL) {
cpu_model = "host";
}
- ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus);
-
- for (i = 0; i < smp_cpus; i++) {
- S390CPU *cpu;
- CPUState *cs;
+ ipi_states = g_malloc0(sizeof(S390CPU *) * max_cpus);
- cpu = cpu_s390x_init(cpu_model);
- cs = CPU(cpu);
+ for (i = 0; i < max_cpus; i++) {
+ name = g_strdup_printf("cpu[%i]", i);
+ object_property_add_link(qdev_get_machine(), name, TYPE_S390_CPU,
+ (Object **)&ipi_states[i], NULL);
+ }
- ipi_states[i] = cpu;
- cs->halted = 1;
- cpu->env.exception_index = EXCP_HLT;
- cpu->env.storage_keys = storage_keys;
+ for (i = 0; i < smp_cpus; i++) {
+ cpu_s390x_init(cpu_model);
}
}
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 3c89f8a..3e7fa30 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -34,6 +34,8 @@
#define CR0_RESET 0xE0UL
#define CR14_RESET 0xC2000000UL;
+int next_cpu_num;
+
/* generate CPU information for cpu -? */
void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf)
{
@@ -150,6 +152,12 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
cpu_reset(cs);
scc->parent_realize(dev, errp);
+
+#if !defined(CONFIG_USER_ONLY)
+ if (dev->hotplugged) {
+ raise_irq_cpu_hotplug();
+ }
+#endif
}
static void s390_cpu_initfn(Object *obj)
@@ -158,13 +166,13 @@ static void s390_cpu_initfn(Object *obj)
S390CPU *cpu = S390_CPU(obj);
CPUS390XState *env = &cpu->env;
static bool inited;
- static int cpu_num = 0;
#if !defined(CONFIG_USER_ONLY)
struct tm tm;
#endif
cs->env_ptr = env;
cpu_exec_init(env);
+ env->cpu_num = next_cpu_num++;
#if !defined(CONFIG_USER_ONLY)
qemu_register_reset(s390_cpu_machine_reset_cb, cpu);
qemu_get_timedate(&tm, 0);
@@ -177,8 +185,10 @@ static void s390_cpu_initfn(Object *obj)
* cpu counter in s390_cpu_reset to a negative number at
* initial ipl */
cs->halted = 1;
+ cpu->env.exception_index = EXCP_HLT;
+ env->storage_keys = storage_keys;
+ s390_cpu_set_ipistate(env->cpu_num, cpu);
#endif
- env->cpu_num = cpu_num++;
env->ext_index = -1;
if (tcg_enabled() && !inited) {
--
1.8.3.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 7/8 v4] [PATCH RFC v4] s390-hotplug: Implement hot_add_cpu hook
2013-10-31 17:21 [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
` (5 preceding siblings ...)
2013-10-31 17:21 ` [Qemu-devel] [PATCH 6/8 v4] [PATCH RFC v4] s390-cpu: s390 cpu init improvements for hotplug Jason J. Herne
@ 2013-10-31 17:21 ` Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 8/8 v4] [PATCH RFC v4] qemu-monitor: HMP cpu-add wrapper Jason J. Herne
2013-11-13 17:24 ` [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
8 siblings, 0 replies; 10+ messages in thread
From: Jason J. Herne @ 2013-10-31 17:21 UTC (permalink / raw)
To: afaerber, agraf, borntraeger, jfrei, imammedo, qemu-devel,
ehabkost
Cc: Jason J. Herne
From: "Jason J. Herne" <jjherne@us.ibm.com>
Implement hot_add_cpu for S390 to allow hot plugging of cpus.
Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
---
hw/s390x/s390-virtio-ccw.c | 1 +
target-s390x/cpu.c | 29 +++++++++++++++++++++++++++++
target-s390x/cpu.h | 2 ++
3 files changed, 32 insertions(+)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 62319b9..8b89886 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -132,6 +132,7 @@ static QEMUMachine ccw_machine = {
.alias = "s390-ccw",
.desc = "VirtIO-ccw based S390 machine",
.init = ccw_init,
+ .hot_add_cpu = ccw_hot_add_cpu,
.block_default_type = IF_VIRTIO,
.no_cdrom = 1,
.no_floppy = 1,
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 3e7fa30..6b7e1fa 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -27,6 +27,8 @@
#include "qemu-common.h"
#include "qemu/timer.h"
#include "hw/hw.h"
+#include "hw/s390x/sclp.h"
+#include "sysemu/sysemu.h"
#ifndef CONFIG_USER_ONLY
#include "sysemu/arch_init.h"
#endif
@@ -206,6 +208,33 @@ static void s390_cpu_finalize(Object *obj)
#endif
}
+#if !defined(CONFIG_USER_ONLY)
+void ccw_hot_add_cpu(const int64_t id, Error **errp)
+{
+ S390CPU *new_cpu;
+ CPUState *cpu;
+ int cpu_count = 0;
+
+ CPU_FOREACH(cpu) {
+ cpu_count++;
+ }
+
+ if (cpu_count == max_cpus) {
+ error_setg(errp, "Maximum number of cpus already defined");
+ return;
+ }
+
+ if (id != next_cpu_num) {
+ error_setg(errp, "Unable to add CPU: %" PRIi64
+ ", The next available id is %d", id, next_cpu_num);
+ return;
+ }
+
+ new_cpu = S390_CPU(object_new(TYPE_S390_CPU));
+ object_property_set_bool(OBJECT(new_cpu), true, "realized", NULL);
+}
+#endif
+
static const VMStateDescription vmstate_s390_cpu = {
.name = "cpu",
.unmigratable = 1,
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 8873536..8c0bed7 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -385,6 +385,8 @@ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
void s390_add_running_cpu(S390CPU *cpu);
unsigned s390_del_running_cpu(S390CPU *cpu);
+void ccw_hot_add_cpu(const int64_t id, Error **errp);
+
/* service interrupts are floating therefore we must not pass an cpustate */
void s390_sclp_extint(uint32_t parm);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 8/8 v4] [PATCH RFC v4] qemu-monitor: HMP cpu-add wrapper
2013-10-31 17:21 [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
` (6 preceding siblings ...)
2013-10-31 17:21 ` [Qemu-devel] [PATCH 7/8 v4] [PATCH RFC v4] s390-hotplug: Implement hot_add_cpu hook Jason J. Herne
@ 2013-10-31 17:21 ` Jason J. Herne
2013-11-13 17:24 ` [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
8 siblings, 0 replies; 10+ messages in thread
From: Jason J. Herne @ 2013-10-31 17:21 UTC (permalink / raw)
To: afaerber, agraf, borntraeger, jfrei, imammedo, qemu-devel,
ehabkost
Cc: Jason J. Herne
From: "Jason J. Herne" <jjherne@us.ibm.com>
Add HMP cpu-add wrapper to allow cpu hot plugging via monitor.
Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
---
hmp-commands.hx | 13 +++++++++++++
hmp.c | 10 ++++++++++
hmp.h | 1 +
3 files changed, 24 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 65b7f60..40f0a6f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1587,6 +1587,19 @@ Executes a qemu-io command on the given block device.
ETEXI
{
+ .name = "cpu-add",
+ .args_type = "id:i",
+ .params = "id",
+ .help = "add cpu",
+ .mhandler.cmd = hmp_cpu_add,
+ },
+
+STEXI
+@item cpu-add @var{id}
+Add CPU with id @var{id}
+ETEXI
+
+ {
.name = "info",
.args_type = "item:s?",
.params = "[subcommand]",
diff --git a/hmp.c b/hmp.c
index fcca6ae..751bc14 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1475,6 +1475,16 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, &errp);
}
+void hmp_cpu_add(Monitor *mon, const QDict *qdict)
+{
+ int cpuid;
+ Error *err = NULL;
+
+ cpuid = qdict_get_int(qdict, "id");
+ qmp_cpu_add(cpuid, &err);
+ hmp_handle_error(mon, &err);
+}
+
void hmp_chardev_add(Monitor *mon, const QDict *qdict)
{
const char *args = qdict_get_str(qdict, "args");
diff --git a/hmp.h b/hmp.h
index 6c3bdcd..9effca5 100644
--- a/hmp.h
+++ b/hmp.h
@@ -87,5 +87,6 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
void hmp_qemu_io(Monitor *mon, const QDict *qdict);
+void hmp_cpu_add(Monitor *mon, const QDict *qdict);
#endif
--
1.8.3.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug
2013-10-31 17:21 [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
` (7 preceding siblings ...)
2013-10-31 17:21 ` [Qemu-devel] [PATCH 8/8 v4] [PATCH RFC v4] qemu-monitor: HMP cpu-add wrapper Jason J. Herne
@ 2013-11-13 17:24 ` Jason J. Herne
8 siblings, 0 replies; 10+ messages in thread
From: Jason J. Herne @ 2013-11-13 17:24 UTC (permalink / raw)
To: Jason J. Herne, afaerber, agraf, borntraeger, jfrei, imammedo,
qemu-devel, ehabkost
On 10/31/2013 01:21 PM, Jason J. Herne wrote:
Pinging this for review.
--
-- Jason J. Herne (jjherne@linux.vnet.ibm.com)
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-11-13 17:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-31 17:21 [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 1/8 v4] s390-sclp: Define New SCLP Codes Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 2/8 v4] s390-sclp: SCLP CPU Info Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 3/8 v4] s390-sclp: SCLP Event integration Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 4/8 v4] s390: Storage key global access Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 5/8 v4] s390-cpu: ipi_states enhancements Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 6/8 v4] [PATCH RFC v4] s390-cpu: s390 cpu init improvements for hotplug Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 7/8 v4] [PATCH RFC v4] s390-hotplug: Implement hot_add_cpu hook Jason J. Herne
2013-10-31 17:21 ` [Qemu-devel] [PATCH 8/8 v4] [PATCH RFC v4] qemu-monitor: HMP cpu-add wrapper Jason J. Herne
2013-11-13 17:24 ` [Qemu-devel] [PATCH 0/8 v4] s390-qemu: cpu hotplug Jason J. Herne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).