From patchwork Mon May 23 19:24:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 625375 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 3rD7ny50srz9t6K for ; Tue, 24 May 2016 05:26:46 +1000 (AEST) Received: from localhost ([::1]:49996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4vUy-0004NS-C5 for incoming@patchwork.ozlabs.org; Mon, 23 May 2016 15:26:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4vTd-0003DT-SM for qemu-devel@nongnu.org; Mon, 23 May 2016 15:25:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4vTX-0004yt-N1 for qemu-devel@nongnu.org; Mon, 23 May 2016 15:25:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4vTX-0004yn-Hx for qemu-devel@nongnu.org; Mon, 23 May 2016 15:25:15 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 2B75E49479; Mon, 23 May 2016 19:25:15 +0000 (UTC) Received: from localhost (vpn1-7-9.gru2.redhat.com [10.97.7.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4NJPEJb001608; Mon, 23 May 2016 15:25:14 -0400 From: Eduardo Habkost To: Peter Maydell Date: Mon, 23 May 2016 16:24:20 -0300 Message-Id: <1464031467-20736-9-git-send-email-ehabkost@redhat.com> In-Reply-To: <1464031467-20736-1-git-send-email-ehabkost@redhat.com> References: <1464031467-20736-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 23 May 2016 19:25:15 +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] [PULL 08/15] target-i386: Move TCG initialization check to tcg_x86_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: Paolo Bonzini , Richard Henderson , =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Instead of requiring cpu.c to check if TCG was already initialized, simply let the function be called multiple times. Suggested-by: Igor Mammedov Reviewed-by: Igor Mammedov Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 4 +--- target-i386/translate.c | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index e615486..2dc3d3c 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -3088,7 +3088,6 @@ static void x86_cpu_initfn(Object *obj) X86CPUClass *xcc = X86_CPU_GET_CLASS(obj); CPUX86State *env = &cpu->env; FeatureWord w; - static int inited; cs->env_ptr = env; cpu_exec_init(cs, &error_abort); @@ -3139,8 +3138,7 @@ static void x86_cpu_initfn(Object *obj) x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort); /* init various static tables used in TCG mode */ - if (tcg_enabled() && !inited) { - inited = 1; + if (tcg_enabled()) { tcg_x86_init(); } } diff --git a/target-i386/translate.c b/target-i386/translate.c index 731b10d..bf33e6b 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -8144,6 +8144,12 @@ void tcg_x86_init(void) "bnd0_ub", "bnd1_ub", "bnd2_ub", "bnd3_ub" }; int i; + static bool initialized; + + if (initialized) { + return; + } + initialized = true; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); cpu_cc_op = tcg_global_mem_new_i32(cpu_env,