From patchwork Wed Oct 5 19:38:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 678571 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sq5jS46tcz9ryn for ; Thu, 6 Oct 2016 06:40:28 +1100 (AEDT) Received: from localhost ([::1]:50988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brs3F-0002GL-Al for incoming@patchwork.ozlabs.org; Wed, 05 Oct 2016 15:40:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brs1y-0001AI-GO for qemu-devel@nongnu.org; Wed, 05 Oct 2016 15:39:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brs1w-0007UB-Qh for qemu-devel@nongnu.org; Wed, 05 Oct 2016 15:39:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brs1w-0007U0-HX for qemu-devel@nongnu.org; Wed, 05 Oct 2016 15:39:04 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E32C3335F73; Wed, 5 Oct 2016 19:39:03 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u95Jcsec010540; Wed, 5 Oct 2016 15:39:00 -0400 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 5 Oct 2016 21:38:35 +0200 Message-Id: <1475696333-8706-2-git-send-email-lvivier@redhat.com> In-Reply-To: <1475696333-8706-1-git-send-email-lvivier@redhat.com> References: <1475696333-8706-1-git-send-email-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 05 Oct 2016 19:39:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 01/19] exec: split cpu_exec_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Rosato , Peter Maydell , Eduardo Habkost , Laurent Vivier , Markus Armbruster , Bharata B Rao , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Extract the realize part to cpu_exec_realize(), update all calls to cpu_exec_init() to add cpu_exec_realize() to have no functionnal change. Put in cpu_exec_init() what initializes the CPU, in cpu_exec_realize() what adds it to the environment. CC: Paolo Bonzini Signed-off-by: Laurent Vivier --- exec.c | 8 +++++--- include/exec/exec-all.h | 1 + target-alpha/cpu.c | 1 + target-arm/cpu.c | 1 + target-cris/cpu.c | 1 + target-i386/cpu.c | 1 + target-lm32/cpu.c | 1 + target-m68k/cpu.c | 1 + target-microblaze/cpu.c | 1 + target-mips/cpu.c | 1 + target-moxie/cpu.c | 1 + target-openrisc/cpu.c | 1 + target-ppc/translate_init.c | 5 +++++ target-s390x/cpu.c | 4 ++++ target-sh4/cpu.c | 1 + target-sparc/cpu.c | 1 + target-tilegx/cpu.c | 1 + target-tricore/cpu.c | 1 + target-unicore32/cpu.c | 1 + target-xtensa/cpu.c | 1 + 20 files changed, 31 insertions(+), 3 deletions(-) diff --git a/exec.c b/exec.c index c8389f9..95b0aee 100644 --- a/exec.c +++ b/exec.c @@ -614,9 +614,6 @@ void cpu_exec_exit(CPUState *cpu) void cpu_exec_init(CPUState *cpu, Error **errp) { - CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); - Error *local_err ATTRIBUTE_UNUSED = NULL; - cpu->as = NULL; cpu->num_ases = 0; @@ -637,6 +634,11 @@ void cpu_exec_init(CPUState *cpu, Error **errp) cpu->memory = system_memory; object_ref(OBJECT(cpu->memory)); #endif +} + +void cpu_exec_realize(CPUState *cpu, Error **errp) +{ + CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); cpu_list_add(cpu); diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 336a57c..649187d 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -58,6 +58,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, int cflags); void cpu_exec_init(CPUState *cpu, Error **errp); +void cpu_exec_realize(CPUState *cpu, Error **errp); void QEMU_NORETURN cpu_loop_exit(CPUState *cpu); void QEMU_NORETURN cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c index 6d01d7f..19f2eb2 100644 --- a/target-alpha/cpu.c +++ b/target-alpha/cpu.c @@ -267,6 +267,7 @@ static void alpha_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); tlb_flush(cs, 1); alpha_translate_init(); diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 1b9540e..5fda716 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -445,6 +445,7 @@ static void arm_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free); diff --git a/target-cris/cpu.c b/target-cris/cpu.c index d680cfb..78753ed 100644 --- a/target-cris/cpu.c +++ b/target-cris/cpu.c @@ -188,6 +188,7 @@ static void cris_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); env->pregs[PR_VR] = ccc->vr; diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 1c57fce..125a10c 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -3159,6 +3159,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) } } cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); if (tcg_enabled()) { tcg_x86_init(); diff --git a/target-lm32/cpu.c b/target-lm32/cpu.c index a783d46..4b93454 100644 --- a/target-lm32/cpu.c +++ b/target-lm32/cpu.c @@ -161,6 +161,7 @@ static void lm32_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); env->flags = 0; diff --git a/target-m68k/cpu.c b/target-m68k/cpu.c index 116b784..307910a 100644 --- a/target-m68k/cpu.c +++ b/target-m68k/cpu.c @@ -177,6 +177,7 @@ static void m68k_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); if (tcg_enabled() && !inited) { inited = true; diff --git a/target-microblaze/cpu.c b/target-microblaze/cpu.c index 8edc00a..9ec2c9c 100644 --- a/target-microblaze/cpu.c +++ b/target-microblaze/cpu.c @@ -200,6 +200,7 @@ static void mb_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); set_float_rounding_mode(float_round_nearest_even, &env->fp_status); diff --git a/target-mips/cpu.c b/target-mips/cpu.c index 64ad112..8a42213 100644 --- a/target-mips/cpu.c +++ b/target-mips/cpu.c @@ -139,6 +139,7 @@ static void mips_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); if (tcg_enabled()) { mips_tcg_init(); diff --git a/target-moxie/cpu.c b/target-moxie/cpu.c index 50a0899..28beff1 100644 --- a/target-moxie/cpu.c +++ b/target-moxie/cpu.c @@ -76,6 +76,7 @@ static void moxie_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); if (tcg_enabled() && !inited) { inited = 1; diff --git a/target-openrisc/cpu.c b/target-openrisc/cpu.c index 155913f..1f2a084 100644 --- a/target-openrisc/cpu.c +++ b/target-openrisc/cpu.c @@ -96,6 +96,7 @@ static void openrisc_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); #ifndef CONFIG_USER_ONLY cpu_openrisc_mmu_init(cpu); diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index b66b40b..5e84e65 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -9683,6 +9683,11 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) error_propagate(errp, local_err); return; } + cpu_exec_realize(cs, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + return; + } #if !defined(CONFIG_USER_ONLY) cpu->cpu_dt_id = (cs->cpu_index / smp_threads) * max_smt diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 35ae2ce..20a88dd 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -211,6 +211,10 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp) if (err != NULL) { goto out; } + cpu_exec_realize(cs, &err); + if (err != NULL) { + goto out; + } scc->next_cpu_id++; #if !defined(CONFIG_USER_ONLY) diff --git a/target-sh4/cpu.c b/target-sh4/cpu.c index f589532..f172516 100644 --- a/target-sh4/cpu.c +++ b/target-sh4/cpu.c @@ -259,6 +259,7 @@ static void superh_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); env->movcal_backup_tail = &(env->movcal_backup); diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c index 800a25a..77cc920 100644 --- a/target-sparc/cpu.c +++ b/target-sparc/cpu.c @@ -815,6 +815,7 @@ static void sparc_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); if (tcg_enabled()) { gen_intermediate_code_init(env); diff --git a/target-tilegx/cpu.c b/target-tilegx/cpu.c index 7017cb6..f7ec920 100644 --- a/target-tilegx/cpu.c +++ b/target-tilegx/cpu.c @@ -108,6 +108,7 @@ static void tilegx_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); if (tcg_enabled() && !tcg_initialized) { tcg_initialized = true; diff --git a/target-tricore/cpu.c b/target-tricore/cpu.c index 35d4ee4..2fd3325 100644 --- a/target-tricore/cpu.c +++ b/target-tricore/cpu.c @@ -96,6 +96,7 @@ static void tricore_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); if (tcg_enabled()) { tricore_tcg_init(); diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c index e7a4984..2e5466a 100644 --- a/target-unicore32/cpu.c +++ b/target-unicore32/cpu.c @@ -117,6 +117,7 @@ static void uc32_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); #ifdef CONFIG_USER_ONLY env->uncached_asr = ASR_MODE_USER; diff --git a/target-xtensa/cpu.c b/target-xtensa/cpu.c index 5ad08a2..fc72726 100644 --- a/target-xtensa/cpu.c +++ b/target-xtensa/cpu.c @@ -118,6 +118,7 @@ static void xtensa_cpu_initfn(Object *obj) cs->env_ptr = env; env->config = xcc->config; cpu_exec_init(cs, &error_abort); + cpu_exec_realize(cs, &error_abort); if (tcg_enabled() && !tcg_inited) { tcg_inited = true;