From patchwork Thu Oct 31 17:21:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason J. Herne" X-Patchwork-Id: 287578 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C8BB42C03EC for ; Fri, 1 Nov 2013 04:25:35 +1100 (EST) Received: from localhost ([::1]:58564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbvzx-00006U-W0 for incoming@patchwork.ozlabs.org; Thu, 31 Oct 2013 13:25:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbvwQ-0003AH-JL for qemu-devel@nongnu.org; Thu, 31 Oct 2013 13:22:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VbvwH-0002XU-6i for qemu-devel@nongnu.org; Thu, 31 Oct 2013 13:21:54 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:36415) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbvwH-0002XQ-3C for qemu-devel@nongnu.org; Thu, 31 Oct 2013 13:21:45 -0400 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 31 Oct 2013 13:21:42 -0400 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e8.ny.us.ibm.com (192.168.1.108) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 31 Oct 2013 13:21:41 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id DE4436E803C for ; Thu, 31 Oct 2013 13:21:38 -0400 (EDT) Received: from d01av05.pok.ibm.com (d01av05.pok.ibm.com [9.56.224.195]) by b01cxnp23032.gho.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r9VHLeYc2097410 for ; Thu, 31 Oct 2013 17:21:40 GMT Received: from d01av05.pok.ibm.com (localhost [127.0.0.1]) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r9VHLcSQ006445 for ; Thu, 31 Oct 2013 13:21:38 -0400 Received: from jason-ThinkPad-W500.endicott.ibm.com (jason-thinkpad-w500.endicott.ibm.com [9.60.75.166] (may be forged)) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r9VHLYvn006083; Thu, 31 Oct 2013 13:21:37 -0400 From: "Jason J. Herne" To: afaerber@suse.de, agraf@suse.de, borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, imammedo@redhat.com, qemu-devel@nongnu.org, ehabkost@redhat.com Date: Thu, 31 Oct 2013 13:21:32 -0400 Message-Id: <1383240094-28760-7-git-send-email-jjherne@us.ibm.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1383240094-28760-1-git-send-email-jjherne@us.ibm.com> References: <1383240094-28760-1-git-send-email-jjherne@us.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13103117-0320-0000-0000-00000195F5E4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.182.138 Cc: "Jason J. Herne" Subject: [Qemu-devel] [PATCH 6/8 v4] [PATCH RFC v4] s390-cpu: s390 cpu init improvements for hotplug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Jason J. Herne" 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 --- 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) {