From patchwork Mon Dec 8 07:53:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 418595 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 46AF21400E2 for ; Mon, 8 Dec 2014 18:53:56 +1100 (AEDT) Received: from localhost ([::1]:60452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xxt8k-0005Vn-7z for incoming@patchwork.ozlabs.org; Mon, 08 Dec 2014 02:53:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xxt8D-0004jd-Ax for qemu-devel@nongnu.org; Mon, 08 Dec 2014 02:53:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xxt84-0000Ld-UZ for qemu-devel@nongnu.org; Mon, 08 Dec 2014 02:53:21 -0500 Received: from mail.ispras.ru ([83.149.199.45]:58215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xxt84-0000LM-MN for qemu-devel@nongnu.org; Mon, 08 Dec 2014 02:53:12 -0500 Received: from [10.10.150.181] (unknown [85.142.117.224]) by mail.ispras.ru (Postfix) with ESMTPSA id C642754006F; Mon, 8 Dec 2014 10:53:11 +0300 (MSK) To: qemu-devel@nongnu.org From: Pavel Dovgalyuk Date: Mon, 08 Dec 2014 10:53:12 +0300 Message-ID: <20141208075311.7108.53970.stgit@PASHA-ISP> In-Reply-To: <20141208075255.7108.19079.stgit@PASHA-ISP> References: <20141208075255.7108.19079.stgit@PASHA-ISP> User-Agent: StGit/0.16 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, alex.bennee@linaro.org, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, maria.klimushenkova@ispras.ru, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, afaerber@suse.de, fred.konrad@greensocs.com Subject: [Qemu-devel] [RFC PATCH v6 02/32] cpu-exec: fix cpu_exec_nocache 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 In icount mode cpu_exec_nocache function is used to execute part of the existing TB. At the end of cpu_exec_nocache newly created TB is deleted. Sometimes io_read function needs to recompile current TB and restart TB lookup and execution. After that tb_find_fast function finds old (bigger) TB again. This TB cannot be executed (because icount is not big enough) and cpu_exec_nocache is called again. Such a loop continues over and over. This patch deletes old TB and avoids finding it in the TB cache. Signed-off-by: Pavel Dovgalyuk --- cpu-exec.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index c976095..f52f292 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -202,13 +202,18 @@ static void cpu_exec_nocache(CPUArchState *env, int max_cycles, { CPUState *cpu = ENV_GET_CPU(env); TranslationBlock *tb; + target_ulong pc = orig_tb->pc; + target_ulong cs_base = orig_tb->cs_base; + uint64_t flags = orig_tb->flags; /* Should never happen. We only end up here when an existing TB is too long. */ if (max_cycles > CF_COUNT_MASK) max_cycles = CF_COUNT_MASK; - tb = tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base, orig_tb->flags, + /* tb_gen_code can flush our orig_tb, invalidate it now */ + tb_phys_invalidate(orig_tb, -1); + tb = tb_gen_code(cpu, pc, cs_base, flags, max_cycles); cpu->current_tb = tb; /* execute the generated code */