[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/4] s390-cpu: s390 cpu init improvements for hotplu
From: |
Jason J. Herne |
Subject: |
[Qemu-devel] [PATCH 3/4] s390-cpu: s390 cpu init improvements for hotplug |
Date: |
Wed, 26 Feb 2014 12:18:33 -0500 |
From: "Jason J. Herne" <address@hidden>
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 <address@hidden>
---
hw/s390x/s390-virtio.c | 28 ++++++++++++++++------------
target-s390x/cpu.c | 14 ++++++++++++--
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index d47fecf..99a10d8 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,23 @@ void s390_init_ipl_dev(const char *kernel_filename,
void s390_init_cpus(const char *cpu_model)
{
int i;
+ gchar *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);
+ g_free(name);
+ }
- 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 ff57b80..a6fa82c 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