From patchwork Thu Jun 18 17:24:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 486456 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 C2DEE14027C for ; Fri, 19 Jun 2015 03:28:59 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=c+k76W+2; dkim-atps=neutral Received: from localhost ([::1]:54201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5dcX-0000A6-Tw for incoming@patchwork.ozlabs.org; Thu, 18 Jun 2015 13:28:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5dYu-0001vx-K0 for qemu-devel@nongnu.org; Thu, 18 Jun 2015 13:25:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5dYt-0007BE-9k for qemu-devel@nongnu.org; Thu, 18 Jun 2015 13:25:12 -0400 Received: from mail-pd0-x22d.google.com ([2607:f8b0:400e:c02::22d]:33403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5dYs-00079n-UA for qemu-devel@nongnu.org; Thu, 18 Jun 2015 13:25:11 -0400 Received: by pdjn11 with SMTP id n11so71074389pdj.0 for ; Thu, 18 Jun 2015 10:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kTkG/GfJFJEZE5IOzf0y/IBDCF8q96OSO3zBigHnmAI=; b=c+k76W+2uQe9P9xROf29aWFGc9uCTo1GAN//0IvniOz4E6lJQn/sQtFEIxzMhDYVGz sMx8bQH6l05fCwmrksx8ehmb+mkS0MAjccu83c9Tnkz+yr1Ub9Aa3TaaQk62I97/Hqtt JZdhtdHo8q+hGLk8HwKKAWDBks6/ourI2/LRJmZKGqLbELe8VcPzwD7kggEF05wVWKLb RwFJTnjer+tb9DYNEPgxmsoYptGxs380LbDMMpbSvybDzk/uT0ij6dBwKZwef9GiwWd1 2lHBTpBhxHoFVNu8Jnsu1EQuqF7eu7c8ehFFZ1mqOzwUcy4AIMW5DI3bBmsW8bDoUYdi Lq7A== X-Received: by 10.66.142.199 with SMTP id ry7mr23296466pab.14.1434648310267; Thu, 18 Jun 2015 10:25:10 -0700 (PDT) Received: from pcrost-laptop.hsd1.ca.comcast.net (c-73-15-58-35.hsd1.ca.comcast.net. [73.15.58.35]) by mx.google.com with ESMTPSA id cz1sm8605105pbc.84.2015.06.18.10.25.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Jun 2015 10:25:09 -0700 (PDT) From: Peter Crosthwaite X-Google-Original-From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Thu, 18 Jun 2015 10:24:51 -0700 Message-Id: <1434648295-30584-5-git-send-email-crosthwaite.peter@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434648295-30584-1-git-send-email-crosthwaite.peter@gmail.com> References: <1434648295-30584-1-git-send-email-crosthwaite.peter@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::22d Cc: ehabkost@redhat.com, Peter Crosthwaite , Riku Voipio , Paolo Bonzini , afaerber@suse.de, aurelien@aurel32.net, rth@twiddle.net Subject: [Qemu-devel] [PATCH v3 4/8] translate-all: Change tb_flush() env argument to cpu 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 All of the core-code usages of this API have the cpu pointer handy so pass it in. There are only 3 architecture specific usages (2 of which are commented out) which can just use ENV_GET_CPU() locally to get the cpu pointer. The reduces core code usage of the CPU env, which brings us closer to common-obj'ing these core files. Cc: Riku Voipio Cc: Eduardo Habkost Cc: Paolo Bonzini Reviewed-by: Eduardo Habkost Acked-by: Eduardo Habkost Signed-off-by: Peter Crosthwaite --- changed since v1: remove target-code uses of ENV_GET_CPU Add () to fns and macros in commit message --- dtc | 2 +- exec.c | 3 +-- gdbstub.c | 6 ++---- include/exec/exec-all.h | 2 +- linux-user/signal.c | 2 +- target-alpha/sys_helper.c | 2 +- target-i386/translate.c | 2 +- translate-all.c | 6 ++---- 8 files changed, 10 insertions(+), 15 deletions(-) diff --git a/dtc b/dtc index 65cc4d2..bc895d6 160000 --- a/dtc +++ b/dtc @@ -1 +1 @@ -Subproject commit 65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf +Subproject commit bc895d6d09695d05ceb8b52486ffe861d6cfbdde diff --git a/exec.c b/exec.c index 549c209..b1c8aae 100644 --- a/exec.c +++ b/exec.c @@ -798,8 +798,7 @@ void cpu_single_step(CPUState *cpu, int enabled) } else { /* must flush all the translated code to avoid inconsistencies */ /* XXX: only flush what is necessary */ - CPUArchState *env = cpu->env_ptr; - tb_flush(env); + tb_flush(cpu); } } } diff --git a/gdbstub.c b/gdbstub.c index 75563db..94e59fe 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1226,7 +1226,6 @@ void gdb_set_stop_cpu(CPUState *cpu) static void gdb_vm_state_change(void *opaque, int running, RunState state) { GDBState *s = gdbserver_state; - CPUArchState *env = s->c_cpu->env_ptr; CPUState *cpu = s->c_cpu; char buf[256]; const char *type; @@ -1261,7 +1260,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) cpu->watchpoint_hit = NULL; goto send_packet; } - tb_flush(env); + tb_flush(cpu); ret = GDB_SIGNAL_TRAP; break; case RUN_STATE_PAUSED: @@ -1490,7 +1489,6 @@ gdb_queuesig (void) int gdb_handlesig(CPUState *cpu, int sig) { - CPUArchState *env = cpu->env_ptr; GDBState *s; char buf[256]; int n; @@ -1502,7 +1500,7 @@ gdb_handlesig(CPUState *cpu, int sig) /* disable single step if it was enabled */ cpu_single_step(cpu, 0); - tb_flush(env); + tb_flush(cpu); if (sig != 0) { snprintf(buf, sizeof(buf), "S%02x", target_signal_to_gdb(sig)); diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index a68c2e3..cffd21e 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -216,7 +216,7 @@ static inline unsigned int tb_phys_hash_func(tb_page_addr_t pc) } void tb_free(TranslationBlock *tb); -void tb_flush(CPUArchState *env); +void tb_flush(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); #if defined(USE_DIRECT_JUMP) diff --git a/linux-user/signal.c b/linux-user/signal.c index 1166f2f..9d4cef4 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -2348,7 +2348,7 @@ static void setup_frame(int sig, struct target_sigaction *ka, /* Flush instruction space. */ //flush_sig_insns(current->mm, (unsigned long) &(sf->insns[0])); - // tb_flush(env); + // tb_flush(CPU(sparc_env_get_cpu(env))); } unlock_user(sf, sf_addr, sizeof(struct target_signal_frame)); return; diff --git a/target-alpha/sys_helper.c b/target-alpha/sys_helper.c index ae2e174..1c59e10 100644 --- a/target-alpha/sys_helper.c +++ b/target-alpha/sys_helper.c @@ -74,7 +74,7 @@ void helper_tbis(CPUAlphaState *env, uint64_t p) void helper_tb_flush(CPUAlphaState *env) { - tb_flush(env); + tb_flush(CPU(alpha_env_get_cpu(env))); } void helper_halt(uint64_t restart) diff --git a/target-i386/translate.c b/target-i386/translate.c index 58b1959..77367cf 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -6925,7 +6925,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, gen_debug(s, pc_start - s->cs_base); #else /* start debug */ - tb_flush(env); + tb_flush(CPU(x86_env_get_cpu(env))); qemu_set_log(CPU_LOG_INT | CPU_LOG_TB_IN_ASM); #endif break; diff --git a/translate-all.c b/translate-all.c index e2e7422..cfe251a 100644 --- a/translate-all.c +++ b/translate-all.c @@ -769,10 +769,8 @@ static void page_flush_tb(void) /* flush all the translation blocks */ /* XXX: tb_flush is currently not thread safe */ -void tb_flush(CPUArchState *env1) +void tb_flush(CPUState *cpu) { - CPUState *cpu = ENV_GET_CPU(env1); - #if defined(DEBUG_FLUSH) printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n", (unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer), @@ -1011,7 +1009,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb = tb_alloc(pc); if (!tb) { /* flush must be done */ - tb_flush(env); + tb_flush(cpu); /* cannot fail at this point */ tb = tb_alloc(pc); /* Don't forget to invalidate previous TB info. */